Open pablode opened 1 month ago
For "base" types you can use the templated method getTypeString<>
in C++. An example usage can be found here or here
I do not think there are Python or Javascript equivalent wrappers however, but should help to prevent C++ typo errors.
The ones you mention are not concrete C++ structures (except color3).
Currently, many applications that use MaterialX repeatedly write out type strings:
One problem with this is that the correct spelling of the types is not ensured by the compiler (e.g. one could by accident write
float2
instead ofvector2
,bool
instead ofboolean
, ..). Additionally, this paradigm does not work well with auto-completion.Types.cpp already provides some string constants, but many others are missing: https://github.com/AcademySoftwareFoundation/MaterialX/blob/dfffe83f74e742edc3743f004da359c35cef5652/source/MaterialXCore/Types.cpp#L10-L23
Furthermore, the names are rather wordy. I believe that something short is to be preferred due to frequent use. As an example, Type String could be abbreviated and used as a prefix or namespace.
Above snippet would become: