-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--Add Configuration State Flags - Part 1 #2396
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, let's see downstream tests pass before merging to prevent issues with nightly.
I like that the per-property setters were replaced with a generic API.
Should also make searching for these easier.
// | ||
// ==== AssetType ==== | ||
// Describes the type of asset used for rendering, collsions, or semantics | ||
py::enum_<metadata::attributes::AssetType>(m, "AssetType") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why bind these? Does python need access?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getters provide this value as an enum. This does remind me, though , that this needs to be read only now, since we don't want manual manipulation of this as it could break things in arcane ways. The whole asset-type component system needs to be removed, since it has been obviated by various config settings.
init("use_bounding_box_for_collision", false); | ||
init("join_collision_meshes", false); | ||
|
||
init("semantic_id", 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this "unknown" or could it be a random class?
Should probably reserve the default for unknown.
Doesn't have to be this PR, just thought I'd mention it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This semantic ID being set to 0 corresponds to the stage.
8175ee2
to
f8ce851
Compare
If ConfigVal values are set programmatically to defaults, the process should use "init" instead of "set". This will make sure the isDefaultVal flag is set to true, and consequently not writing those values to file when requested to. Values set by the existing "set" methods will always be written to file.
Nearly all the values set in the constructors of the various attributes are defaults that are expected to be overwritten only if necessary. Writing these to file is redundant and can, in certain circumstances, cause written JSONs to be in an inappropriate state.
A hidden value would be a pertinent configuration value that is set programmatically and only used internally. These values should not be written to file or exposed to the user except perhaps for debugging.
Not sure if this could even happen (a situation could arise where two different instances could have their _data arrays both be pointers to the same memory location, but just in case.
Hidden fields are set and used internally and will generally not be written to file or exposed to the user except in a debugging capacity. Their labels in Configurations should be camel-case with 2 leading underscores, to help differentiate them from non-hidden fields.
binding value should not have lost "orient_" prefix
'Force_flat_shading should be considered a hidden value, only used internally.
This means a config value is translated by consuming code to some other representation, (i.e. an enum) before it is consumed. These values are stored internally and in files as strings, but require the implementation of custom read functionality to make sure the value read is within the acceptable bounds supported by the program.
f8ce851
to
03bc117
Compare
Motivation and Context
This is the first of 2 PRs to handle this functionality. The 2nd PR will handle making sure configuration filepaths do not get saved to JSON with inappropriate path information.
This PR is intended to expand the capabilities of the Configurations without incurring much cost by providing status flags for each ConfigValue that reside within the 4 byte gap the current _type field causes due to 8 byte alignment.
Modifies the ConfigValType (int) _type field to be u_int64_t _typeAndFlags, where the lower 32 bits correspond to the previous _type value and the higher 32 bits are used to record state of the ConfigValue, along with necessary plumbing to consume the type value in the same way as before.
Adds ConfigValStatus enum (u_int64_t) to hold bit flags representing state of the ConfigValue. Currently 3 flags are supported, ConfigValStatus::isDefault , ConfigValStatus::isHidden and ConfigValStatus::isTranslated.
-- isDefault : represents programmatic initialization of a value, as opposed to it being set intentionally from a file or user input.
-- isHidden : represents a value being used internally and not part of the actual Configuration data hierarchy. These values we never want to write to file or expose to a user unless for debugging purposes.
-- isTranslated : represents a value that is stored as a string but is translated, currently to enum values, upon consumption.
Adds "init" setters that set the ConfigValStatus::isDefault bit of the ConfigValue's _typeAndFlags variable to 1, while the legacy "set" setters set it to 0.
Adds "hidden" setters that will set the ConfigValStatus::isHidden bit. The Attributes that consume this bit have as their keys double-underscore + Hungarian notation names, to make them obvious compared to the standard camel-case format of non-hidden values.
All existing Attributes constructors have their default value setting changed from using variants of "set" to using the new "init" and "setHidden" setters where appropriate.
A check on the "isDefault" and "isHidden" flags is added when before writing to JSON.
Not only will these features prevent the unnecessary writing to disk of default fields, but they can also be used to prevent configurations being written in a potentially damaging or indeterminant state due to modifications done internally as part of the program's flow.
Also adds a repathing tool in the io namespace :
which converts the absolute path
toRelPath
to be relative to the given targetabsPath
How Has This Been Tested
Locally c++ and python tests pass
Types of changes
Checklist