AcademySoftwareFoundation / AcademySoftwareFoundation/MaterialX

Suggestion: provide string constants for all types

Open
#1,935 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.3k
Forks
451
Avg merge
4d 11h
Merged PRs (30d)
8

Description

Currently, many applications that use MaterialX repeatedly write out type strings:
```cpp
const bool colorInput = (type == "color3" || type == "color4");
```

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 of `vector2`, `bool` instead of `boolean`, ..). 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:
```cpp
const bool colorInput = (type == mx::TS_COLOR3 || type == mx::TS_COLOR4);
```

Contributor guide

Open the contributing guide

Research direction

Read the existing string constants in source/MaterialXCore/Types.cpp, especially the section linked in the issue, and compare them with the type strings used by applications. The issue proposes constants for missing types and shorter names such as TS_COLOR3, but leaves the naming design open; done would mean providing constants for all types with an agreed naming scheme.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.