-
Notifications
You must be signed in to change notification settings - Fork 224
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
Valve 220 texture lock fix #1458
Valve 220 texture lock fix #1458
Conversation
…tem." This reverts commit 36e49c4.
…lTexCoordSystem) without breaking the texture lock "on" case.
Hm.. just noticed a problem, rotating a brush with texture lock OFF stretches the texture. So I guess |
Reduce excessive number of translation test cases in checkTextureLockWithTranslationAnd90DegreeRotations because it was slow
All of my tests pass except for the ones testing ParallelTexCoordSystem with texture lock off. I'm not sure how to fix |
What is the problem? Why is rotation special? |
The problem looks like this: https://www.dropbox.com/s/50ayw9lqn1i8mgk/rotate.mov?dl=0 |
Is it not possible to compensate for the rotation? It sounds like you need to apply rotation to the texture axes in that case, essentially behaving as if texture lock was in, but undoing the translation? |
Thanks for the video. I think it makes sense that the texture coordinate system must be rotated even if texture lock is off. So that would mean that texture lock only applies to translation and nothing else in Valve 220. Do you know how other editors handle this? |
I just checked Sledge, it does what you said: "texture lock off" only applies to translation. Rotation always gets texture lock. Here is Sledge's texture lock code: I'll see if I can get "texture lock off" only for translation to work. |
Remember that you can very easily separate the translational component from a transformation matrix, as it is stored independently from the rest in the fourth column (or the fourth row?). That way, you can separate them (there should be methods for that already) and apply only the non-translational part to the texture axes. You may also have to update the stupid angle value somehow. It represents by how much a texture coordinate system has been rotated away from its default position. It's solely used by the UI and it's utterly stupid. |
See methods |
…compensate for the translation part of the transformation. Still compensate for the rotation.
Ok, using Only remaining concern I have is, will removing the |
… used, which could lead to tests incorrectly passing because the tests were making translations of integer units.
Those checks are important, because there is a bug elsewhere that sometimes produces 0 scaling factors, which then cause all sorts of havoc. |
…in ParallelTexCoordSystem::doTransform
Ok, I just restored those checks. I'm assuming there is no need to update the texture axes in that case, since the texture alignment is going to be nonsense anyway? |
Yes. I think I should add assertions to the setters of those attributes to catch the bug earlier. |
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.
I'll merge and make the requested changes myself. Thanks for your help!
@@ -102,18 +102,14 @@ namespace TrenchBroom { | |||
m_yAxis = rot * m_yAxis; | |||
} | |||
|
|||
void ParallelTexCoordSystem::doTransform(const Plane3& oldBoundary, const Mat4x4& transformation, BrushFaceAttributes& attribs, bool lockTexture, const Vec3& oldInvariant) { | |||
void ParallelTexCoordSystem::doTransform(const Plane3& oldBoundary, const Mat4x4& origTransformation, BrushFaceAttributes& attribs, bool lockTexture, const Vec3& oldInvariant) { |
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.
Please don't use abbreviated variable names. Also I think it's better to keep translation
as the variable name and use a different name below.
return; | ||
|
||
// when texture lock is off, don't compensate for the translation part of the transformation | ||
const Mat4x4 transformation = lockTexture ? origTransformation : stripTranslation(origTransformation); |
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.
I'd prefer to use a name like actualTransformation
or effectiveTransformation
here.
checkTextureLockOffWithTranslation(origFace); | ||
} | ||
|
||
TEST(BrushFaceTest, testTextureLock_Paraxial) { |
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.
Thanks for the test cases, looks like it was more work than the actual changes ;-)
return false; | ||
} | ||
return true; | ||
} | ||
|
||
TEST(TestUtilsTest, testTexCoordsEqual) { |
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.
Good man ;-)
Happy to help! The tests should be useful if any changes / bug fixes need to be made to the texture lock code in the future. They seem to be fairly thorough, e.g. they'll fail if some of the "magic" bits of ParaxialTexCoordSystem are commented out, like this thing |
Yeah, that "magic" stuff is annoying. I wish I understood it better and that the algorithm was easier, but at some point I just gave up and declared it good enough. |
ParallelTexCoordSystem::doTransform
iflockTexture
is false. Texture lock OFF and ON both seem to work now.testTextureLock_Parallel
fails without the fix toParallelTexCoordSystem
.There are no tests yet for the case when texture lock is offThere is a basic test of "texture lock off" now. It only tests the case when a face has reset texture alignment before being transfomed.