Skip to content

Commit

Permalink
#5770: Change emitTextureCoordinates() behaviour to not call Face::pl…
Browse files Browse the repository at this point in the history
…ane3() which triggers a lot of callbacks internally. Instead, use the m_planeTransformed member which is up to date enough for all the call sites I checked. Texture coordinates are usually emitted long after the rest of the transform is calculated (in particular the normal vector), so it's not necessary to trigger some lazy transform evaluation callback just to apply the texture matrix. The method emitTextureCoordinates should do just as the name states, it's the job of the caller to make sure the normal vector is ready before emitTextureCoordinates is called.
  • Loading branch information
codereader committed Oct 3, 2021
1 parent 8385d90 commit c75a91b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion radiantcore/brush/Brush.cpp
Expand Up @@ -1134,7 +1134,7 @@ bool Brush::buildWindings() {
}

// update texture coordinates
f.EmitTextureCoordinates();
f.emitTextureCoordinates();
}

// greebo: Update the winding, now that it's constructed
Expand Down
12 changes: 7 additions & 5 deletions radiantcore/brush/Face.cpp
Expand Up @@ -298,6 +298,7 @@ void Face::revertTransform()
planepts_assign(m_move_planeptsTransformed, m_move_planepts);
m_texdefTransformed = _texdef;
updateWinding();
emitTextureCoordinates();
}

void Face::freezeTransform() {
Expand Down Expand Up @@ -351,7 +352,7 @@ void Face::testSelect_centroid(SelectionTest& test, SelectionIntersection& best)

void Face::shaderChanged()
{
EmitTextureCoordinates();
emitTextureCoordinates();
_owner.onFaceShaderChanged();

// Update the visibility flag, but leave out the contributes() check
Expand Down Expand Up @@ -390,7 +391,7 @@ void Face::revertTexdef()
void Face::texdefChanged()
{
revertTexdef();
EmitTextureCoordinates();
emitTextureCoordinates();

// Fire the signal to update the Texture Tools
signal_texdefChanged().emit();
Expand Down Expand Up @@ -607,7 +608,7 @@ void Face::setTexDefFromPoints(const Vector3 points[3], const Vector2 uvs[3])

m_texdefTransformed.setTransform(textureMatrix);

EmitTextureCoordinates();
emitTextureCoordinates();

// Fire the signal to update the Texture Tools
signal_texdefChanged().emit();
Expand Down Expand Up @@ -654,8 +655,9 @@ void Face::alignTexture(AlignEdge align)
texdefChanged();
}

void Face::EmitTextureCoordinates() {
m_texdefTransformed.emitTextureCoordinates(m_winding, plane3().normal(), Matrix4::getIdentity());
void Face::emitTextureCoordinates()
{
m_texdefTransformed.emitTextureCoordinates(m_winding, m_planeTransformed.getPlane().normal(), Matrix4::getIdentity());
}

void Face::applyDefaultTextureScale()
Expand Down
2 changes: 1 addition & 1 deletion radiantcore/brush/Face.h
Expand Up @@ -177,7 +177,7 @@ class Face :
*/
void normaliseTexture();

void EmitTextureCoordinates();
void emitTextureCoordinates();

// When constructing faces with a default-constructed TextureProjection the scale is very small
// fix that by calling this method.
Expand Down

0 comments on commit c75a91b

Please sign in to comment.