Skip to content

Commit 70cb872

Browse files
falbrechtskirchingerFlamefire
authored andcommitted
Add using alias PointF = Point<float> and refactor
1 parent dff23f8 commit 70cb872

10 files changed

Lines changed: 13 additions & 18 deletions

File tree

libs/common/include/Point.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct Point //-V690
4646
using Position = Point<int>;
4747
/// Type for describing an extent/size etc. (unsigned type)
4848
using Extent = Point<unsigned>;
49+
using PointF = Point<float>;
4950
//-V:all:810
5051

5152
//////////////////////////////////////////////////////////////////////////

libs/libGamedata/gameData/TerrainDesc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ enum class ETexType : uint8_t
5555

5656
struct TerrainDesc
5757
{
58-
using PointF = Point<float>;
5958
struct Triangle
6059
{
6160
PointF tip, left, right;

libs/s25main/TerrainRenderer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static constexpr unsigned getFlatIndex(DescIdx<LandscapeDesc> ls, LandRoadType r
5656
return ls.value * helpers::NumEnumValues_v<LandRoadType> + rttr::enum_cast(road);
5757
}
5858

59-
TerrainRenderer::PointF TerrainRenderer::GetNeighbourVertexPos(MapPoint pt, const Direction dir) const
59+
PointF TerrainRenderer::GetNeighbourVertexPos(MapPoint pt, const Direction dir) const
6060
{
6161
// Note: We want the real neighbour point which might be outside of the map to get the offset right
6262
Position ptNb = ::GetNeighbour(Position(pt), dir);
@@ -67,8 +67,8 @@ TerrainRenderer::PointF TerrainRenderer::GetNeighbourVertexPos(MapPoint pt, cons
6767
return GetVertexPos(t) + PointF(offset);
6868
}
6969

70-
TerrainRenderer::PointF TerrainRenderer::GetNeighbourBorderPos(const MapPoint pt, const unsigned char triangle,
71-
const Direction dir) const
70+
PointF TerrainRenderer::GetNeighbourBorderPos(const MapPoint pt, const unsigned char triangle,
71+
const Direction dir) const
7272
{
7373
// Note: We want the real neighbour point which might be outside of the map to get the offset right
7474
Position ptNb = ::GetNeighbour(Position(pt), dir);
@@ -205,7 +205,7 @@ void TerrainRenderer::GenerateVertices(const GameWorldViewer& gwv)
205205

206206
void TerrainRenderer::UpdateVertexPos(const MapPoint pt, const GameWorldViewer& gwv)
207207
{
208-
GetVertex(pt).pos = Point<float>(gwv.GetWorld().GetNodePos(pt));
208+
GetVertex(pt).pos = PointF(gwv.GetWorld().GetNodePos(pt));
209209
}
210210

211211
void TerrainRenderer::UpdateVertexColor(const MapPoint pt, const GameWorldViewer& gwv)

libs/s25main/TerrainRenderer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ glArchivItem_Bitmap* new_clone(const glArchivItem_Bitmap& bmp);
2727
class TerrainRenderer : private boost::noncopyable
2828
{
2929
public:
30-
using PointF = Point<float>;
31-
3230
TerrainRenderer();
3331
~TerrainRenderer();
3432

libs/s25main/ogl/glSmartBitmap.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ void glSmartBitmap::generateTexture()
217217

218218
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bufSize.x, bufSize.y, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer.getPixelPtr());
219219

220-
using PointF = Point<float>;
221-
222220
/* 0--3/4--7
223221
* | | |
224222
* 1--2/5--6

libs/s25main/ogl/glSmartBitmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class glSmartBitmap : public ITexture
3535
void calcDimensions();
3636

3737
public:
38-
std::array<Point<float>, 8> texCoords;
38+
std::array<PointF, 8> texCoords;
3939

4040
glSmartBitmap();
4141
~glSmartBitmap();

libs/s25main/ogl/glTexturePackerNode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ bool glTexturePackerNode::insert(glSmartBitmap* b, libsiedler2::PixelBufferBGRA&
4040
b->drawTo(buffer, current->pos);
4141
current->bmp = b;
4242

43-
const Point<float> bufferSize(buffer.getWidth(), buffer.getHeight());
43+
const PointF bufferSize(buffer.getWidth(), buffer.getHeight());
4444
Extent currentSize(current->size);
4545
if(b->isPlayer())
4646
currentSize.x /= 2;

libs/s25main/world/GameWorldView.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ void GameWorldView::Draw(const RoadBuildState& rb, const MapPoint selected, bool
126126
glPushMatrix();
127127
glScalef(zoomFactor_, zoomFactor_, 1);
128128
// Offset to center view
129-
Point<float> diff(size_.x - size_.x / zoomFactor_, size_.y - size_.y / zoomFactor_);
129+
PointF diff(size_.x - size_.x / zoomFactor_, size_.y - size_.y / zoomFactor_);
130130
diff = diff / 2.f;
131131
glTranslatef(-diff.x, -diff.y, 0.f);
132132
// Also adjust mouse
133-
mousePos = Position(Point<float>(mousePos) / zoomFactor_ + diff);
133+
mousePos = Position(PointF(mousePos) / zoomFactor_ + diff);
134134
glMatrixMode(GL_MODELVIEW);
135135
}
136136

@@ -623,7 +623,7 @@ void GameWorldView::CalcFxLx()
623623
if(zoomFactor_ != 1.f) //-V550
624624
{
625625
// Calc pixels we can remove from sides, as they are not drawn due to zoom
626-
Point<float> diff(size_.x - size_.x / zoomFactor_, size_.y - size_.y / zoomFactor_);
626+
PointF diff(size_.x - size_.x / zoomFactor_, size_.y - size_.y / zoomFactor_);
627627
// Stay centered by removing half the pixels from opposite sites
628628
diff = diff / 2.f;
629629
// Convert to map points
@@ -632,8 +632,8 @@ void GameWorldView::CalcFxLx()
632632
// Don't remove to much
633633
diff.x = std::floor(diff.x);
634634
diff.y = std::floor(diff.y);
635-
firstPt = Position(Point<float>(firstPt) + diff);
636-
lastPt = Position(Point<float>(lastPt) - diff);
635+
firstPt = Position(PointF(firstPt) + diff);
636+
lastPt = Position(PointF(lastPt) - diff);
637637
}
638638
}
639639

tests/libGameData/testGameData.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ BOOST_AUTO_TEST_CASE(TextureCoords)
205205
WorldDescription desc;
206206
GameDataLoader loader(desc, tmp.get());
207207
BOOST_TEST_REQUIRE(loader.Load());
208-
using PointF = TerrainDesc::PointF;
209208
// Border points are inset by half a pixel for OpenGL (sample middle of pixel!)
210209
// Overlapped uses the full rectangle
211210
const TerrainDesc::Triangle rsuO = desc.terrain.tryGet("terrain1")->GetRSUTriangle();

tests/s25Main/UI/testTexturePacker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE(SizeAndPosCorrect)
3838

3939
// Sizes must be correct
4040
BOOST_TEST_REQUIRE(packer.getTextures().size() == 1u);
41-
const Point<float> size(packer.getTextures()[0].getSize());
41+
const PointF size(packer.getTextures()[0].getSize());
4242
for(const auto& bmp : smartBmps)
4343
{
4444
const auto curTexSize = bmp.texCoords[2] - bmp.texCoords[0];

0 commit comments

Comments
 (0)