diff --git a/source/blender/blenkernel/BKE_attribute_math.hh b/source/blender/blenkernel/BKE_attribute_math.hh index 1838ac5171a..646017d39a4 100644 --- a/source/blender/blenkernel/BKE_attribute_math.hh +++ b/source/blender/blenkernel/BKE_attribute_math.hh @@ -33,6 +33,7 @@ inline void convert_to_static_type(const CPPType &cpp_type, const Func &func) int2, bool, int8_t, + short2, ColorGeometry4f, ColorGeometry4b, math::Quaternion, @@ -78,6 +79,11 @@ template<> inline int mix2(const float factor, const int &a, const int &b) return int(std::round((1.0f - factor) * a + factor * b)); } +template<> inline short2 mix2(const float factor, const short2 &a, const short2 &b) +{ + return math::interpolate(a, b, factor); +} + template<> inline int2 mix2(const float factor, const int2 &a, const int2 &b) { return math::interpolate(a, b, factor); @@ -136,6 +142,12 @@ template<> inline int mix3(const float3 &weights, const int &v0, const int &v1, return int(std::round(weights.x * v0 + weights.y * v1 + weights.z * v2)); } +template<> +inline short2 mix3(const float3 &weights, const short2 &v0, const short2 &v1, const short2 &v2) +{ + return short2(weights.x * float2(v0) + weights.y * float2(v1) + weights.z * float2(v2)); +} + template<> inline int2 mix3(const float3 &weights, const int2 &v0, const int2 &v1, const int2 &v2) { return int2(weights.x * float2(v0) + weights.y * float2(v1) + weights.z * float2(v2)); @@ -214,6 +226,14 @@ inline int mix4(const float4 &weights, const int &v0, const int &v1, const int & return int(std::round(weights.x * v0 + weights.y * v1 + weights.z * v2 + weights.w * v3)); } +template<> +inline short2 mix4( + const float4 &weights, const short2 &v0, const short2 &v1, const short2 &v2, const short2 &v3) +{ + return short2(weights.x * float2(v0) + weights.y * float2(v1) + weights.z * float2(v2) + + weights.w * float2(v3)); +} + template<> inline int2 mix4( const float4 &weights, const int2 &v0, const int2 &v1, const int2 &v2, const int2 &v3) @@ -575,6 +595,17 @@ template<> struct DefaultMixerStruct { * uses double instead of float so that it is accurate for all 32 bit integers. */ using type = SimpleMixerWithAccumulationType; }; +template<> struct DefaultMixerStruct { + static float2 int_to_float(const short2 &value) + { + return float2(value); + } + static short2 float_to_int(const float2 &value) + { + return short2(math::round(value)); + } + using type = SimpleMixerWithAccumulationType; +}; template<> struct DefaultMixerStruct { static double2 int_to_double(const int2 &value) { diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index fff14577a84..8ea97bc9e3d 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -57,6 +57,8 @@ const blender::CPPType *custom_data_type_to_cpp_type(const eCustomDataType type) return &CPPType::get(); case CD_PROP_FLOAT4X4: return &CPPType::get(); + case CD_PROP_INT16_2D: + return &CPPType::get(); case CD_PROP_STRING: return &CPPType::get(); default: @@ -99,6 +101,9 @@ eCustomDataType cpp_type_to_custom_data_type(const blender::CPPType &type) if (type.is()) { return CD_PROP_FLOAT4X4; } + if (type.is()) { + return CD_PROP_INT16_2D; + } if (type.is()) { return CD_PROP_STRING; } @@ -154,23 +159,25 @@ static int attribute_data_type_complexity(const eCustomDataType data_type) return 2; case CD_PROP_FLOAT: return 3; - case CD_PROP_INT32_2D: + case CD_PROP_INT16_2D: return 4; - case CD_PROP_FLOAT2: + case CD_PROP_INT32_2D: return 5; - case CD_PROP_FLOAT3: + case CD_PROP_FLOAT2: return 6; - case CD_PROP_BYTE_COLOR: + case CD_PROP_FLOAT3: return 7; - case CD_PROP_QUATERNION: + case CD_PROP_BYTE_COLOR: return 8; - case CD_PROP_COLOR: + case CD_PROP_QUATERNION: return 9; - case CD_PROP_FLOAT4X4: + case CD_PROP_COLOR: return 10; + case CD_PROP_FLOAT4X4: + return 11; #if 0 /* These attribute types are not supported yet. */ case CD_PROP_STRING: - return 10; + return 12; #endif default: /* Only accept "generic" custom data types used by the attribute system. */ diff --git a/source/blender/blenkernel/intern/bake_items_serialize.cc b/source/blender/blenkernel/intern/bake_items_serialize.cc index 379512d610f..bb270e816a2 100644 --- a/source/blender/blenkernel/intern/bake_items_serialize.cc +++ b/source/blender/blenkernel/intern/bake_items_serialize.cc @@ -1271,6 +1271,10 @@ static std::shared_ptr serialize_primitive_value( const int value = *static_cast(value_ptr); return std::make_shared(value); } + case CD_PROP_INT16_2D: { + const int2 value = int2(*static_cast(value_ptr)); + return serialize_int_array({&value.x, 2}); + } case CD_PROP_INT32_2D: { const int2 value = *static_cast(value_ptr); return serialize_int_array({&value.x, 2}); @@ -1398,6 +1402,9 @@ template *static_cast(r_value) = *value; return true; } + case CD_PROP_INT16_2D: { + return deserialize_int_array(io_value, {static_cast(r_value), 2}); + } case CD_PROP_INT32_2D: { return deserialize_int_array(io_value, {static_cast(r_value), 2}); } diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index c301f6ff292..e80ac75c27a 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -1831,16 +1831,16 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { nullptr, nullptr}, /* 22: CD_TEXTURE_MCOL */ - {sizeof(MCol[4]), - alignof(MCol[4]), - "MCol", + {sizeof(blender::short2), + alignof(blender::short2), + "vec2s", 4, - N_("TexturedCol"), + N_("2D 16-Bit Integer"), nullptr, nullptr, - layerInterp_mcol, - layerSwap_mcol, - layerDefault_mcol}, + nullptr, + nullptr, + nullptr}, /* 23: CD_CLOTH_ORCO */ {sizeof(float[3]), alignof(float[3]), diff --git a/source/blender/blenkernel/intern/mesh_compare.cc b/source/blender/blenkernel/intern/mesh_compare.cc index dca3c05427c..52988b0a202 100644 --- a/source/blender/blenkernel/intern/mesh_compare.cc +++ b/source/blender/blenkernel/intern/mesh_compare.cc @@ -235,7 +235,7 @@ static bool values_different(const T value1, const float threshold, const int component_i) { - if constexpr (is_same_any_v) { + if constexpr (is_same_any_v) { /* These types already have a good implementation. */ return value1 != value2; } diff --git a/source/blender/blenkernel/intern/type_conversions.cc b/source/blender/blenkernel/intern/type_conversions.cc index eeee4658abf..77e35b7d8e6 100644 --- a/source/blender/blenkernel/intern/type_conversions.cc +++ b/source/blender/blenkernel/intern/type_conversions.cc @@ -53,6 +53,10 @@ static int32_t float_to_int(const float &a) { return int32_t(a); } +static short2 float_to_short2(const float &a) +{ + return short2(a); +} static int2 float_to_int2(const float &a) { return int2(a); @@ -91,6 +95,10 @@ static int float2_to_int(const float2 &a) { return int32_t((a.x + a.y) / 2.0f); } +static short2 float2_to_short2(const float2 &a) +{ + return short2(a.x, a.y); +} static int2 float2_to_int2(const float2 &a) { return int2(a.x, a.y); @@ -128,6 +136,10 @@ static int float3_to_int(const float3 &a) { return int((a.x + a.y + a.z) / 3.0f); } +static short2 float3_to_short2(const float3 &a) +{ + return short2(a.x, a.y); +} static int2 float3_to_int2(const float3 &a) { return int2(a.x, a.y); @@ -154,6 +166,10 @@ static int8_t int_to_int8(const int32_t &a) return std::clamp( a, int(std::numeric_limits::min()), int(std::numeric_limits::max())); } +static short2 int_to_short2(const int32_t &a) +{ + return short2(a); +} static int2 int_to_int2(const int32_t &a) { return int2(a); @@ -179,6 +195,43 @@ static ColorGeometry4b int_to_byte_color(const int32_t &a) return int_to_color(a).encode(); } +static bool short2_to_bool(const short2 &a) +{ + return !math::is_zero(a); +} +static float2 short2_to_float2(const short2 &a) +{ + return float2(a); +} +static int short2_to_int(const short2 &a) +{ + return math::midpoint(a.x, a.y); +} +static int2 short2_to_int2(const short2 &a) +{ + return int2(a.x, a.y); +} +static int8_t short2_to_int8(const short2 &a) +{ + return int_to_int8(short2_to_int(a)); +} +static float short2_to_float(const short2 &a) +{ + return float2_to_float(float2(a)); +} +static float3 short2_to_float3(const short2 &a) +{ + return float3(float(a.x), float(a.y), 0.0f); +} +static ColorGeometry4f short2_to_color(const short2 &a) +{ + return ColorGeometry4f(float(a.x), float(a.y), 0.0f, 1.0f); +} +static ColorGeometry4b short2_to_byte_color(const short2 &a) +{ + return short2_to_color(a).encode(); +} + static bool int2_to_bool(const int2 &a) { return !math::is_zero(a); @@ -191,6 +244,10 @@ static int int2_to_int(const int2 &a) { return math::midpoint(a.x, a.y); } +static short2 int2_to_short2(const int2 &a) +{ + return short2(a.x, a.y); +} static int8_t int2_to_int8(const int2 &a) { return int_to_int8(int2_to_int(a)); @@ -220,6 +277,10 @@ static int int8_to_int(const int8_t &a) { return int(a); } +static short2 int8_to_short2(const int8_t &a) +{ + return short2(a); +} static int2 int8_to_int2(const int8_t &a) { return int2(a); @@ -262,6 +323,10 @@ static int32_t bool_to_int(const bool &a) { return int32_t(a); } +static short2 bool_to_short2(const bool &a) +{ + return short2(a); +} static int2 bool_to_int2(const bool &a) { return int2(a); @@ -295,6 +360,10 @@ static int32_t color_to_int(const ColorGeometry4f &a) { return int(rgb_to_grayscale(a)); } +static short2 color_to_short2(const ColorGeometry4f &a) +{ + return short2(a.r, a.g); +} static int2 color_to_int2(const ColorGeometry4f &a) { return int2(a.r, a.g); @@ -328,6 +397,10 @@ static int32_t byte_color_to_int(const ColorGeometry4b &a) { return color_to_int(a.decode()); } +static short2 byte_color_to_short2(const ColorGeometry4b &a) +{ + return short2(a.r, a.g); +} static int2 byte_color_to_int2(const ColorGeometry4b &a) { return int2(a.r, a.g); @@ -371,6 +444,7 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); @@ -381,6 +455,7 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); @@ -391,6 +466,7 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); @@ -399,6 +475,7 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); @@ -406,9 +483,20 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); @@ -417,6 +505,7 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); @@ -427,6 +516,7 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); @@ -437,6 +527,7 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); @@ -446,6 +537,7 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); diff --git a/source/blender/blenlib/intern/cpp_types.cc b/source/blender/blenlib/intern/cpp_types.cc index eceb4990f31..84b51658862 100644 --- a/source/blender/blenlib/intern/cpp_types.cc +++ b/source/blender/blenlib/intern/cpp_types.cc @@ -56,6 +56,7 @@ BLI_CPP_TYPE_MAKE(blender::float4x4, CPPTypeFlags::BasicType) BLI_CPP_TYPE_MAKE(int8_t, CPPTypeFlags::BasicType) BLI_CPP_TYPE_MAKE(int16_t, CPPTypeFlags::BasicType) BLI_CPP_TYPE_MAKE(int32_t, CPPTypeFlags::BasicType) +BLI_CPP_TYPE_MAKE(blender::short2, CPPTypeFlags::BasicType) BLI_CPP_TYPE_MAKE(blender::int2, CPPTypeFlags::BasicType) BLI_CPP_TYPE_MAKE(blender::int3, CPPTypeFlags::BasicType) BLI_CPP_TYPE_MAKE(int64_t, CPPTypeFlags::BasicType) diff --git a/source/blender/draw/intern/draw_attributes.cc b/source/blender/draw/intern/draw_attributes.cc index 59d1fba958d..91b343332f1 100644 --- a/source/blender/draw/intern/draw_attributes.cc +++ b/source/blender/draw/intern/draw_attributes.cc @@ -93,9 +93,10 @@ bool drw_custom_data_match_attribute(const CustomData &custom_data, int *r_layer_index, eCustomDataType *r_type) { - const eCustomDataType possible_attribute_types[10] = { + const eCustomDataType possible_attribute_types[11] = { CD_PROP_BOOL, CD_PROP_INT8, + CD_PROP_INT16_2D, CD_PROP_INT32_2D, CD_PROP_INT32, CD_PROP_FLOAT, diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index f0a42635533..90567b59470 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -760,6 +760,7 @@ static bool ensure_attributes(const Curves &curves, case CD_PROP_BOOL: case CD_PROP_INT8: case CD_PROP_INT32: + case CD_PROP_INT16_2D: case CD_PROP_INT32_2D: case CD_PROP_FLOAT: case CD_PROP_FLOAT2: { diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.cc b/source/blender/draw/intern/draw_cache_impl_mesh.cc index 7011452d4fd..223f81e07c3 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.cc +++ b/source/blender/draw/intern/draw_cache_impl_mesh.cc @@ -397,6 +397,7 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object &object, case CD_PROP_BOOL: case CD_PROP_INT8: case CD_PROP_INT32: + case CD_PROP_INT16_2D: case CD_PROP_INT32_2D: case CD_PROP_FLOAT: case CD_PROP_FLOAT2: { diff --git a/source/blender/editors/geometry/geometry_attributes.cc b/source/blender/editors/geometry/geometry_attributes.cc index ae145fe417d..18415586921 100644 --- a/source/blender/editors/geometry/geometry_attributes.cc +++ b/source/blender/editors/geometry/geometry_attributes.cc @@ -67,6 +67,7 @@ StringRefNull rna_property_name_for_type(const eCustomDataType type) case CD_PROP_INT8: case CD_PROP_INT32: return "value_int"; + case CD_PROP_INT16_2D: case CD_PROP_INT32_2D: return "value_int_vector_2d"; default: @@ -131,11 +132,12 @@ GPointer rna_property_for_attribute_type_retrieve_value(PointerRNA &ptr, case CD_PROP_COLOR: RNA_float_get_array(&ptr, prop_name.c_str(), static_cast(buffer)); break; - case CD_PROP_BYTE_COLOR: + case CD_PROP_BYTE_COLOR: { ColorGeometry4f value; RNA_float_get_array(&ptr, prop_name.c_str(), value); *static_cast(buffer) = value.encode(); break; + } case CD_PROP_BOOL: *static_cast(buffer) = RNA_boolean_get(&ptr, prop_name.c_str()); break; @@ -145,6 +147,12 @@ GPointer rna_property_for_attribute_type_retrieve_value(PointerRNA &ptr, case CD_PROP_INT32: *static_cast(buffer) = RNA_int_get(&ptr, prop_name.c_str()); break; + case CD_PROP_INT16_2D: { + int2 value; + RNA_int_get_array(&ptr, prop_name.c_str(), value); + *static_cast(buffer) = short2(value); + break; + } case CD_PROP_INT32_2D: RNA_int_get_array(&ptr, prop_name.c_str(), static_cast(buffer)); break; @@ -184,6 +192,9 @@ void rna_property_for_attribute_type_set_value(PointerRNA &ptr, case CD_PROP_INT32: RNA_property_int_set(&ptr, &prop, *value.get()); break; + case CD_PROP_INT16_2D: + RNA_property_int_set_array(&ptr, &prop, int2(*value.get())); + break; case CD_PROP_INT32_2D: RNA_property_int_set_array(&ptr, &prop, *value.get()); break; diff --git a/source/blender/editors/space_node/node_geometry_attribute_search.cc b/source/blender/editors/space_node/node_geometry_attribute_search.cc index 3bfbac24e79..2b81bb3584e 100644 --- a/source/blender/editors/space_node/node_geometry_attribute_search.cc +++ b/source/blender/editors/space_node/node_geometry_attribute_search.cc @@ -165,6 +165,7 @@ static eCustomDataType data_type_in_attribute_input_node(const eCustomDataType t /* Unsupported currently. */ return CD_PROP_FLOAT; case CD_PROP_FLOAT2: + case CD_PROP_INT16_2D: case CD_PROP_INT32_2D: /* No 2D vector sockets currently. */ return CD_PROP_FLOAT3; diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_column.cc b/source/blender/editors/space_spreadsheet/spreadsheet_column.cc index 4f52619a3d2..32f8d96c910 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_column.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_column.cc @@ -34,7 +34,7 @@ eSpreadsheetColumnValueType cpp_type_to_column_type(const CPPType &type) if (type.is()) { return SPREADSHEET_VALUE_TYPE_INT32; } - if (type.is()) { + if (type.is_any()) { return SPREADSHEET_VALUE_TYPE_INT32_2D; } if (type.is()) { diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc b/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc index 603c8300ce3..1aa71e90f20 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc @@ -143,6 +143,10 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); UI_but_drawflag_enable(but, UI_BUT_TEXT_RIGHT); } + else if (data.type().is()) { + const int2 value = int2(data.get(real_index)); + this->draw_int_vector(params, Span(&value.x, 2)); + } else if (data.type().is()) { const int2 value = data.get(real_index); this->draw_int_vector(params, Span(&value.x, 2)); diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc index 909fe91c6ba..ecb18dbca8b 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc @@ -169,6 +169,36 @@ static IndexMask apply_row_filter(const SpreadsheetRowFilter &row_filter, } } } + else if (column_data.type().is()) { + const short2 value = short2(int2(row_filter.value_int2)); + switch (row_filter.operation) { + case SPREADSHEET_ROW_FILTER_EQUAL: { + const float threshold_sq = pow2f(row_filter.threshold); + apply_filter_operation( + column_data.typed(), + [&](const short2 cell) { return math::distance_squared(cell, value) <= threshold_sq; }, + prev_mask, + memory); + break; + } + case SPREADSHEET_ROW_FILTER_GREATER: { + apply_filter_operation( + column_data.typed(), + [&](const short2 cell) { return cell.x > value.x && cell.y > value.y; }, + prev_mask, + memory); + break; + } + case SPREADSHEET_ROW_FILTER_LESS: { + apply_filter_operation( + column_data.typed(), + [&](const short2 cell) { return cell.x < value.x && cell.y < value.y; }, + prev_mask, + memory); + break; + } + } + } else if (column_data.type().is()) { const float2 value = row_filter.value_float2; switch (row_filter.operation) { diff --git a/source/blender/io/ply/exporter/ply_export_load_plydata.cc b/source/blender/io/ply/exporter/ply_export_load_plydata.cc index 52f42860522..e7a89fc4fc6 100644 --- a/source/blender/io/ply/exporter/ply_export_load_plydata.cc +++ b/source/blender/io/ply/exporter/ply_export_load_plydata.cc @@ -217,6 +217,17 @@ static void load_custom_attributes(const Mesh *mesh, } break; } + case CD_PROP_INT16_2D: { + float *attr_x = find_or_add_attribute(iter.name + "_x", size, vertex_offset, r_attributes); + float *attr_y = find_or_add_attribute(iter.name + "_y", size, vertex_offset, r_attributes); + auto typed = attribute.typed(); + for (const int64_t i : ply_to_vertex.index_range()) { + int j = ply_to_vertex[i]; + attr_x[i] = typed[j].x; + attr_y[i] = typed[j].y; + } + break; + } case CD_PROP_INT32_2D: { float *attr_x = find_or_add_attribute(iter.name + "_x", size, vertex_offset, r_attributes); float *attr_y = find_or_add_attribute(iter.name + "_y", size, vertex_offset, r_attributes); diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index 30ccbba77cd..e369c0e2668 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -125,7 +125,7 @@ typedef enum eCustomDataType { CD_MDISPS = 19, CD_PROP_FLOAT4X4 = 20, /* CD_ID_MCOL = 21, */ - /* CD_TEXTURE_MLOOPCOL = 22, */ /* UNUSED */ + CD_PROP_INT16_2D = 22, CD_CLOTH_ORCO = 23, /* CD_RECAST = 24, */ /* UNUSED */ @@ -213,6 +213,7 @@ using eCustomDataMask = uint64_t; #define CD_MASK_PROP_FLOAT2 (1ULL << CD_PROP_FLOAT2) #define CD_MASK_PROP_BOOL (1ULL << CD_PROP_BOOL) #define CD_MASK_PROP_INT8 (1ULL << CD_PROP_INT8) +#define CD_MASK_PROP_INT16_2D (1ULL << CD_PROP_INT16_2D) #define CD_MASK_PROP_INT32_2D (1ULL << CD_PROP_INT32_2D) #define CD_MASK_PROP_QUATERNION (1ULL << CD_PROP_QUATERNION) #define CD_MASK_PROP_FLOAT4X4 (1ULL << CD_PROP_FLOAT4X4) @@ -227,7 +228,8 @@ using eCustomDataMask = uint64_t; #define CD_MASK_PROP_ALL \ (CD_MASK_PROP_FLOAT | CD_MASK_PROP_FLOAT2 | CD_MASK_PROP_FLOAT3 | CD_MASK_PROP_INT32 | \ CD_MASK_PROP_COLOR | CD_MASK_PROP_STRING | CD_MASK_PROP_BYTE_COLOR | CD_MASK_PROP_BOOL | \ - CD_MASK_PROP_INT8 | CD_MASK_PROP_INT32_2D | CD_MASK_PROP_QUATERNION | CD_MASK_PROP_FLOAT4X4) + CD_MASK_PROP_INT8 | CD_MASK_PROP_INT16_2D | CD_MASK_PROP_INT32_2D | CD_MASK_PROP_QUATERNION | \ + CD_MASK_PROP_FLOAT4X4) /* All color attributes */ #define CD_MASK_COLOR_ALL (CD_MASK_PROP_COLOR | CD_MASK_PROP_BYTE_COLOR) diff --git a/source/blender/makesrna/intern/rna_attribute.cc b/source/blender/makesrna/intern/rna_attribute.cc index 369bbe002ec..5329cfb264c 100644 --- a/source/blender/makesrna/intern/rna_attribute.cc +++ b/source/blender/makesrna/intern/rna_attribute.cc @@ -46,6 +46,7 @@ const EnumPropertyItem rna_enum_attribute_type_items[] = { {CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"}, {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"}, {CD_PROP_INT8, "INT8", 0, "8-Bit Integer", "Smaller integer with a range from -128 to 127"}, + {CD_PROP_INT16_2D, "INT16_2D", 0, "2D 16-Bit Integer Vector", "16-bit signed integer vector"}, {CD_PROP_INT32_2D, "INT32_2D", 0, "2D Integer Vector", "32-bit signed integer vector"}, {CD_PROP_QUATERNION, "QUATERNION", 0, "Quaternion", "Floating point quaternion rotation"}, {CD_PROP_FLOAT4X4, "FLOAT4X4", 0, "4x4 Matrix", "Floating point matrix"}, @@ -76,6 +77,7 @@ const EnumPropertyItem rna_enum_attribute_type_with_auto_items[] = { {CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"}, {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"}, {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"}, + {CD_PROP_INT16_2D, "INT16_2D", 0, "2D 16-Bit Integer Vector", "16-bit signed integer vector"}, {CD_PROP_INT32_2D, "INT32_2D", 0, "2D Integer Vector", "32-bit signed integer vector"}, {CD_PROP_QUATERNION, "QUATERNION", 0, "Quaternion", "Floating point quaternion rotation"}, {CD_PROP_FLOAT4X4, "FLOAT4X4", 0, "4x4 Matrix", "Floating point matrix"}, @@ -260,6 +262,8 @@ static StructRNA *srna_by_custom_data_layer_type(const eCustomDataType type) return &RNA_Float2Attribute; case CD_PROP_INT8: return &RNA_ByteIntAttribute; + case CD_PROP_INT16_2D: + return &RNA_Short2Attribute; case CD_PROP_INT32_2D: return &RNA_Int2Attribute; case CD_PROP_QUATERNION: @@ -1270,6 +1274,43 @@ static void rna_def_attribute_int8(BlenderRNA *brna) RNA_def_property_int_sdna(prop, nullptr, "i"); } +static void rna_def_attribute_short2(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "Short2Attribute", "Attribute"); + RNA_def_struct_sdna(srna, "CustomDataLayer"); + RNA_def_struct_ui_text(srna, + "2D 16-Bit Integer Vector Attribute", + "Geometry attribute that stores 2D integer vectors"); + + prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "Short2AttributeValue"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE); + RNA_def_property_collection_funcs(prop, + "rna_Attribute_data_begin", + "rna_iterator_array_next", + "rna_iterator_array_end", + "rna_iterator_array_get", + "rna_Attribute_data_length", + nullptr, + nullptr, + nullptr); + RNA_def_property_update(prop, 0, "rna_Attribute_update_data"); + + srna = RNA_def_struct(brna, "Short2AttributeValue", nullptr); + RNA_def_struct_sdna(srna, "vec2s"); + RNA_def_struct_ui_text( + srna, "2D 16-Bit Integer Vector Attribute Value", "2D value in geometry attribute"); + + prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE); + RNA_def_property_ui_text(prop, "Vector", "2D vector"); + RNA_def_property_int_sdna(prop, nullptr, "x"); + RNA_def_property_array(prop, 2); + RNA_def_property_update(prop, 0, "rna_Attribute_update_data"); +} + static void rna_def_attribute_int2(BlenderRNA *brna) { StructRNA *srna; @@ -1461,6 +1502,7 @@ static void rna_def_attribute(BlenderRNA *brna) rna_def_attribute_float_color(brna); rna_def_attribute_byte_color(brna); rna_def_attribute_int(brna); + rna_def_attribute_short2(brna); rna_def_attribute_int2(brna); rna_def_attribute_quaternion(brna); rna_def_attribute_float4x4(brna);