Skip to content

Commit

Permalink
#5746: Texture Tool is relying on the values returned by the GridModule
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Sep 25, 2021
1 parent 19c0eaa commit b8b08aa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
23 changes: 2 additions & 21 deletions radiant/textool/TexTool.cpp
Expand Up @@ -541,28 +541,9 @@ void TexTool::selectRelatedItems()
draw();
}

float TexTool::getGridSize()
{
// The Texture Tool is using the same grid "size" as the main orthographic views
// but since grid spacings >1 barely make sense when editing UV coordinates
// we offset the grid size such that GRID_1 refers to a UV spacing of 2^(-7) instead of 2^0.
int exponent = GlobalGrid().getGridPower() - 7;

if (exponent < -7)
{
exponent = -7; // not smaller than 2^-7
}
else if (exponent > 0)
{
exponent = 0; // not greater than 1.0
}

return pow(2.0f, exponent);
}

void TexTool::drawGrid()
{
auto gridSpacing = getGridSize();
auto gridSpacing = GlobalGrid().getGridSize(grid::Space::Texture);

const auto& texSpaceAABB = getVisibleTexSpace();
auto uPerPixel = texSpaceAABB.extents.x() / _windowDims.x();
Expand All @@ -575,7 +556,7 @@ void TexTool::drawGrid()
// Ensure that the grid spacing is at least 10 pixels wide
while (gridSpacingInPixels < 12)
{
gridSpacing *= 2.0f;
gridSpacing *= GlobalGrid().getGridBase(grid::Space::Texture);
gridSpacingInPixels = gridSpacing / smallestUvPerPixel;
}

Expand Down
2 changes: 0 additions & 2 deletions radiant/textool/TexTool.h
Expand Up @@ -244,8 +244,6 @@ class TexTool :
TextureToolMouseEvent createMouseEvent(const Vector2& point, const Vector2& delta = Vector2(0, 0));

void handleGLCapturedMouseMotion(const MouseToolPtr& tool, int x, int y, unsigned int mouseState);

float getGridSize();
};

} // namespace ui

0 comments on commit b8b08aa

Please sign in to comment.