Page MenuHome

BKE: Attribute type name identifier
AbandonedPublic

Authored by Iliya Katueshenock (Moder) on Jul 6 2022, 9:33 PM.

Details

Summary

Standard attribute names can be used for printing
when debugging or testing. Before the advent of
dynamic sockets, this could be used as a unification
of the identifier_suffix. It also partially affects the
standardization of naming sockets of different types
of the same attribute.

Diff Detail

Event Timeline

Iliya Katueshenock (Moder) requested review of this revision.Jul 6 2022, 9:33 PM
Iliya Katueshenock (Moder) created this revision.
Iliya Katueshenock (Moder) planned changes to this revision.Jul 6 2022, 10:14 PM

Add Switch Node and Versioning Socket Names

Added a switch node.


Also, since it is now planned to add versioning to change the names of the sockets, I can also standardize the name, no matter what

socket_identifier = "Attribute/Value/..._"+default_name();
...
params.set_output(socket_identifier ,Field<T>())

, and immediately use the result of default_name:

params.set_output(default_name<T>(),Field<T>())

Most often only one group of sockets is dynamic, nodes such as accumulation can still use suffixes


Switch Node: Type Bool: Now input values are not hidden

  1. Also now i need to add a random attribute
  2. Added version change. This does not work for the switch node

(tomorrow I will finish it, now 4 am)

  1. I think to abandon Vectors in favor of
value = value ->next;

The random value node does not rely on names in
operation, so it is not modified.
A ray cast node has also been added.
Versioning completed. Due to the fact that changing the
order of sockets was not included in the plans, all nodes
have their own recording order.
So far, there are no prefixes for those socket names that
do not intersect with others. If needed, this can be changed.

Removed forgotten include

Named Attribute Save Node Support.
Returning socket prefixes.
Adding a warning that the Byte Color type name does
not match an existing socket. I'm also not sure if it's necessary
to mention somewhere that convert_to_static_type also requires
an exception to get a Color socket, although Byte Color is used.

maybe, for Byte Color
node_geometry_util.cc

template<typename Function>
void protect_static_type(const eCustomDataType data_type, Function &func){
  attribute_math::convert_to_static_type(data_type, [&](auto dummy) {
    if constexpr (std::is_same_v<decltype(dummy), ColorGeometry4b>) {
      func(dummy, ColorGeometry4f());
    }else{
      func(dummy, dummy);
    }
  });
}

node_geo_store_named_attribute.cc

protect_static_type(data_type, [&](auto dummy, auto socket_dummy){
  using socket_T = decltype(socket_dummy);
  field = params.extract_input<Field<socket_T >>("Value_" + attribute_math::default_name<socket_T >());
  if constexpr (!std::is_same_v<decltype(dummy), decltype(socket_dummy)>) {
    field = bke::get_implicit_type_conversions().try_convert(field, CPPType::get<decltype(dummy)>());
  }
});

Although, for one node it looks redundant

This comment was removed by Iliya Katueshenock (Moder).
Hans Goudey (HooglyBoogly) requested changes to this revision.Oct 12 2022, 8:12 PM

Thanks for working on this.
As long as the change is properly tested, I think this is a very nice improvement. And it would probably help for making changes to declarations in the future.

source/blender/blenkernel/BKE_attribute_math.hh
411–419 ↗(On Diff #53802)

These template specializations might make more sense in BKE_attribute.hh, they're not really math

416 ↗(On Diff #53802)

How about using StringRef instead of StringRefNull?

Also, maybe type_name_identifier would be a clearer name? "Default" is a bit vague.

source/blender/blenloader/intern/versioning_common.cc
256

I think this is a prefix rather than a suffix

source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc
126

postfix -> suffix

This revision now requires changes to proceed.Oct 12 2022, 8:12 PM
Iliya Katueshenock (Moder) planned changes to this revision.Oct 14 2022, 5:23 PM
Iliya Katueshenock (Moder) updated this revision to Diff 56808.
Iliya Katueshenock (Moder) retitled this revision from Geometry Nodes & Attribute math: Default attribute naming to BKE: Attribute type name identifier.
Iliya Katueshenock (Moder) set the repository for this revision to rB Blender.
Iliya Katueshenock (Moder) edited projects, added Nodes & Physics; removed BF Blender.
Iliya Katueshenock (Moder) marked 4 inline comments as done.
  • Merge master
  • Cleanup

Also I need to add new nodes.

  • Add Sample UV and Sample Index nodes
  • Add Sample Nearest Surface