Skip to content
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

3013: support missing Q2 surface attributes #3872

Merged
merged 33 commits into from Aug 22, 2021
Merged

3013: support missing Q2 surface attributes #3872

merged 33 commits into from Aug 22, 2021

Conversation

ericwa
Copy link
Collaborator

@ericwa ericwa commented Aug 8, 2021

Fixes #3013

Overview (best to review the overall diff, not by commits):

  • .wal reader now reads contents/flags/value and stores them in a Q2Data struct in Texture
  • Texture now has a std::variant<std::monostate, Q2Data> member for the above
  • BrushFaceAttributes::m_surfaceContents, m_surfaceFlags, m_surfaceValue, m_color are now std::optional
  • BrushFace gains surfaceContents(), surfaceFlags(), surfaceValue(), color() methods which return a "resolved"/computed value for each of these: if the BrushFaceAttributes has a non-empty optional, that is returned, otherwise we check for a Q2Data struct in the face's Texture.
  • MapFileSerializer uses the optionals to decide whether to write contents/flags/values on Q2 (and color on DKT) maps
    • one detail to note: since the file format only supports writing all of contents/flags/values, or none of them, we may need to write more than we want (e.g. if only "contents" is set, and the flags/value are empty optionals). Nothing we can do about this without a custom file format.
    • if we are forced to write more than desired, we use BrushFace::surfaceContents() etc., so we pick up what was being used in the texture
  • removed dead code from ChangeBrushFaceAttributesRequest
  • some adjustments to ChangeBrushFaceAttributesRequest to support working with optional values/flags
  • FaceAttribsEditor gains UI buttons for unsetting the optional values:

Capture

@ericwa ericwa changed the title 3013: support missing Q2 surface attributes (wip) 3013: support missing Q2 surface attributes Aug 11, 2021
@ericwa ericwa marked this pull request as ready for review August 11, 2021 05:56
@ericwa ericwa requested a review from kduske August 11, 2021 05:56
@kduske
Copy link
Collaborator

kduske commented Aug 13, 2021

Can I review this commit by commit?

@ericwa
Copy link
Collaborator Author

ericwa commented Aug 13, 2021

No, I left an note above :)

Overview (best to review the overall diff, not by commits):

Copy link
Collaborator

@kduske kduske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a few minor questions. Sorry for taking so long!

common/src/Assets/Texture.h Show resolved Hide resolved
common/src/Assets/Texture.h Show resolved Hide resolved
common/src/Model/BrushFace.cpp Outdated Show resolved Hide resolved
common/src/Model/BrushFace.cpp Outdated Show resolved Hide resolved
@@ -283,18 +355,26 @@ namespace TrenchBroom {
m_surfaceValueEditor->setRange(min, max);
m_surfaceValueEditor->setIncrements(1.0, 10.0, 100.0);
m_surfaceValueEditor->setDigits(0, 6);
m_surfaceValueUnsetButton = createBitmapButton("Unset.svg", tr("Unset surface value"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it's more fitting to use the "ResetTexture" icon here, too. Effectively, you are resetting these values to whatever is the default from the texture.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean this one?

Capture

I would rather use the specific icon I am using now because it's an idiom from Unreal.

That X button just resets texture alignment, leaving surface / content flags alone. So it's unrelated to what my new Unset buttons are doing and would be confusing to overload.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think of these icons in more general terms like + is for adding, - for deleting, X is for resetting, etc. The reason why I suggested X for this is that it also resets to defaults, in a sense. That one of them applies to UVs and the other applies to surface flags and such should be apparent from the placement of the buttons. So in that sense, we're not overloading this icon with a new meaning.

We originally used the curved arrow icon for this in the UV editor, but then changed it because we needed an icon for "Reset to world" and couldn't make that work with the curved arrow. In my view, if we now introduce the curved arrow again for something that also means "reset", then that's inconsistent, and I'd rather like to avoid that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see what you're saying. There's a subtle difference which is what I was trying to hint at with the different icons:

  • the face/contents/value one is "Unset (and inherit the value from the parent [the texture], including future changes if the parent changes)"
  • the texture axis one is "Set texture alignment to sensible defaults, based on the current face normal". i.e. there's no concept of inheritance here.

but for the sake of icons maybe these are close enough that we can call them both "Reset"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I agree that there is a slight semantic difference, but I believe that from the users' point of view, it doesn't matter as much.

@ericwa ericwa requested a review from kduske August 21, 2021 02:59
@ericwa
Copy link
Collaborator Author

ericwa commented Aug 21, 2021

Here is the update look with the X icons now:
Capture

Copy link
Collaborator

@kduske kduske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing my feedback!

@ericwa ericwa merged commit 2b14c3e into master Aug 22, 2021
@ericwa ericwa deleted the feature/3013 branch August 22, 2021 16:06
@kduske kduske added this to the 2022.2 milestone May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wal texture embedded values aren't being displayed
2 participants