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
2102: Support for model scale #3889
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We remove the constructors and use these types as simple structs. On top of that we enable move semantics in more places.
Previously we used an enum to differentiate the different cases. With variant, we can save one alternative and make the code safer and less awkward to use.
kduske
force-pushed
the
feature/2102-2
branch
4 times, most recently
from
October 14, 2021 08:57
1043f07
to
1812201
Compare
This refactoring contains a number of cleanups and simplifications. The main takeaway is that we now store the expression that generated a value as a member of that value. To that end, we make both Value and Expression trivial to copy by storing their actual data using shared_ptr. To achieve this, we must make values and expressions immutable. We also extract all of the concrete expression types into a separate compilation unit to improve source code organization.
This iterator is useful when working with collections of pointers. It wraps another iterator and just dereferences that iterator twice when it is itself dereferenced.
We add support for setting a scale expression in the game configuration. This expression is evaluated at runtime against an entities' properties. The scale expression configured in the game configuration is used only if the model definition doesn't have its own scale expression.
The test cases we remove in the parser tests are redundant because they test the functionality of the ModelDefinition class, not the parser itself. We only leave one test each to ensure that parsing EL model expressions works at all.
This is necessary to make scale expressions work as expected, i.e., if a model definition has a scale expression that accesses an entity property that an entity doesn't have, then the global scale should be returned.
All other related types have the prefix "Entity", so we adapt these names to be more consistent.
In the following commits, we will add the model transformation to the cached entity properties. Once we start to consider the model scale in the model transformation, we need to access the default model scale expression from the game config, which we cannot access lazily. Therefore, we change the updating to the cached entity properties to be done eagerly here.
kduske
force-pushed
the
feature/2102-2
branch
from
October 14, 2021 13:22
1812201
to
ebc9ff3
Compare
EntityPropertyConfig encapsulates any information that controls how entity properties behave. Currently, it only contains a global scale expression that is used if a model definition doesn't have a scale expression itself, but in the future, it may also contain info about the semantics of special entity property keys such as target or targetname. This would then allow us to move away from hard coding property keys. EntityPropertyConfig must be passed to any member of Entity that modifies entity properties in some way. Nodes can access a global config object by calling Node::entityPropertyConfig, since the world node stores that global config.
kduske
force-pushed
the
feature/2102-2
branch
from
October 14, 2021 16:13
ebc9ff3
to
a4582ba
Compare
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #2102.
This PR adds support for configuring an entities' model scale. Currently, the scale is only applied to the model. The model scale can be configured in the game configuration as a default to be applied to all entity models, or it can be configured per entity definition in the entity definition file using TB's model syntax.
Regardless of where it is configured, the actual expression that yields a models' scale is evaluated at runtime, against the properties of the entity that has the model. This requires a couple of changes to the EL infrastructure so that we can efficiently store an expression in a value.
The first couple of commits just clean up the existing code and add some missing infrastructure such as comparison and stream insertion operators. Then we refactor the EL to support storing the expression that generated a value along with that value. Finally we add support for configuring model scale in the game configuration and the entity definition files.