Geometry Nodes: Add 8-bit integer attribute type to store attribute node #119879

Merged
Hans Goudey merged 1 commits from HooglyBoogly/blender:geometry-nodes-8-bit-integer into main 2024-03-25 23:04:20 +01:00
3 changed files with 11 additions and 12 deletions

View File

@ -4383,6 +4383,8 @@ std::optional<eNodeSocketDatatype> custom_data_type_to_socket_type(eCustomDataTy
switch (type) {
case CD_PROP_FLOAT:
return SOCK_FLOAT;
case CD_PROP_INT8:
return SOCK_INT;
case CD_PROP_INT32:
return SOCK_INT;
case CD_PROP_FLOAT3:

View File

@ -49,11 +49,11 @@ const EnumPropertyItem *attribute_type_type_with_socket_fn(bContext * /*C*/,
bool *r_free)
{
*r_free = true;
return enum_items_filter(rna_enum_attribute_type_items,
[](const EnumPropertyItem &item) -> bool {
return generic_attribute_type_supported(item) &&
!ELEM(item.value, CD_PROP_BYTE_COLOR, CD_PROP_FLOAT2);
});
return enum_items_filter(
rna_enum_attribute_type_items, [](const EnumPropertyItem &item) -> bool {
return generic_attribute_type_supported(item) &&
!ELEM(item.value, CD_PROP_INT8, CD_PROP_BYTE_COLOR, CD_PROP_FLOAT2);
});
}
bool generic_attribute_type_supported(const EnumPropertyItem &item)
@ -67,6 +67,7 @@ bool generic_attribute_type_supported(const EnumPropertyItem &item)
CD_PROP_FLOAT3,
CD_PROP_COLOR,
CD_PROP_BOOL,
CD_PROP_INT8,
CD_PROP_INT32,
CD_PROP_BYTE_COLOR,
CD_PROP_QUATERNION,

View File

@ -104,13 +104,9 @@ static void node_geo_exec(GeoNodeExecParams params)
const Field<bool> selection = params.extract_input<Field<bool>>("Selection");
GField field = params.extract_input<GField>("Value");
if (data_type == CD_PROP_FLOAT2) {
field = bke::get_implicit_type_conversions().try_convert(std::move(field),
CPPType::get<float2>());
}
if (data_type == CD_PROP_BYTE_COLOR) {
field = bke::get_implicit_type_conversions().try_convert(std::move(field),
CPPType::get<ColorGeometry4b>());
if (ELEM(data_type, CD_PROP_FLOAT2, CD_PROP_BYTE_COLOR, CD_PROP_INT8)) {
field = bke::get_implicit_type_conversions().try_convert(
std::move(field), *bke::custom_data_type_to_cpp_type(data_type));
}
std::atomic<bool> failure = false;