Fix includes in source/maths

Make include-what-you-use happy with files in source/maths and fix what
needs to be fixed.

Ref: #8086
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser 2025-06-20 00:06:41 +02:00
parent 9970706deb
commit ed4e2587c2
No known key found for this signature in database
34 changed files with 141 additions and 55 deletions

View file

@ -27,8 +27,9 @@
#ifndef INCLUDED_CODE_ANNOTATION
#define INCLUDED_CODE_ANNOTATION
#include "lib/sysdep/compiler.h"
#include "lib/code_generation.h"
#include "lib/sysdep/arch.h" // ARCH_AMD64
#include "lib/sysdep/compiler.h"
#include <cstddef>

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -23,12 +23,15 @@
#include "BoundingBoxAligned.h"
#include "lib/debug.h"
#include "maths/BoundingBoxOriented.h"
#include "maths/Brush.h"
#include "maths/Frustum.h"
#include "maths/Matrix3D.h"
#include "maths/Plane.h"
#include <limits>
#include <utility>
const CBoundingBoxAligned CBoundingBoxAligned::EMPTY = CBoundingBoxAligned(); // initializes to an empty bound

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -23,11 +23,12 @@
#define INCLUDED_BOUND
#include "maths/Vector3D.h"
#include "graphics/ShaderProgramPtr.h"
#include <algorithm>
class CBoundingBoxOriented;
class CFrustum;
class CMatrix3D;
class CBoundingBoxOriented;
// Basic axis aligned bounding box (AABB) class
class CBoundingBoxAligned

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2019 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -20,7 +20,8 @@
#include "BoundingBoxOriented.h"
#include "maths/BoundingBoxAligned.h"
#include <float.h>
#include <cfloat>
#include <cmath>
const CBoundingBoxOriented CBoundingBoxOriented::EMPTY = CBoundingBoxOriented();

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2019 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -20,6 +20,9 @@
#include "maths/BoundingBoxAligned.h"
#include "maths/BoundingSphere.h"
#include <algorithm>
#include <cmath>
CBoundingSphere CBoundingSphere::FromSweptBox(const CBoundingBoxAligned& bbox)
{
float maxX = std::max(fabsf(bbox[0].X), fabsf(bbox[1].X));

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -19,8 +19,10 @@
#include "Brush.h"
#include "lib/debug.h"
#include "maths/BoundingBoxAligned.h"
#include "maths/Frustum.h"
#include "maths/Plane.h"
CBrush::CBrush() = default;

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -24,6 +24,7 @@
#include "maths/Vector3D.h"
#include <cstddef>
#include <vector>
class CBoundingBoxAligned;

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2010 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -22,6 +22,7 @@
#include "ps/CStr.h"
#include <sstream>
#include <string>
template<>
CFixed_15_16 CFixed_15_16::FromString(const CStr8& s)

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2022 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -18,9 +18,17 @@
#ifndef INCLUDED_FIXED
#define INCLUDED_FIXED
#include "lib/debug.h"
#include "lib/sysdep/compiler.h"
#include "lib/types.h"
#include "maths/Sqrt.h"
#include "ps/CStrForward.h"
#include <algorithm>
#include <cmath>
#include <limits>
class CStr8;
class CStrW;
#ifndef NDEBUG
#define USE_FIXED_OVERFLOW_CHECKS
@ -312,7 +320,7 @@ public:
return CFixed(t);
}
constexpr CFixed Absolute() const { return CFixed(abs(value)); }
constexpr CFixed Absolute() const { return CFixed(std::abs(value)); }
/**
* Multiply by a CFixed. Likely to overflow if both numbers are large,

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2020 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -18,6 +18,7 @@
#ifndef INCLUDED_FIXED_VECTOR2D
#define INCLUDED_FIXED_VECTOR2D
#include "lib/types.h"
#include "maths/Fixed.h"
#include "maths/Sqrt.h"

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2020 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -18,6 +18,7 @@
#ifndef INCLUDED_FIXED_VECTOR3D
#define INCLUDED_FIXED_VECTOR3D
#include "lib/types.h"
#include "maths/Fixed.h"
#include "maths/Sqrt.h"

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -25,8 +25,8 @@ portal rendering, where a portal may have 3 or more edges.
#include "Frustum.h"
#include "lib/debug.h"
#include "maths/BoundingBoxAligned.h"
#include "maths/MathUtil.h"
#include "maths/Matrix3D.h"
CFrustum::CFrustum()

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -28,8 +28,11 @@ portal rendering, where a portal may have 3 or more edges.
#ifndef INCLUDED_FRUSTUM
#define INCLUDED_FRUSTUM
#include "maths/Vector3D.h"
#include "maths/Plane.h"
#include <cstddef>
class CBoundingBoxAligned;
class CMatrix3D;

View file

@ -18,6 +18,9 @@
#ifndef INCLUDED_MD5
#define INCLUDED_MD5
#include "lib/code_annotation.h"
#include "lib/types.h"
#include <cstring>
/**

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2019 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -23,8 +23,10 @@
#include "precompiled.h"
#include "Matrix3D.h"
#include "Quaternion.h"
#include "Vector4D.h"
#include "maths/Quaternion.h"
#include <cmath>
//Sets the identity matrix
void CMatrix3D::SetIdentity ()

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2022 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -27,6 +27,8 @@
#include "maths/Vector4D.h"
#include "ps/containers/Span.h"
#include <cstddef>
class CQuaternion;
// CMatrix3D: a 4x4 matrix class for common operations in 3D

View file

@ -17,10 +17,15 @@
#include "precompiled.h"
#include <algorithm>
#include "NUSpline.h"
#include "Matrix3D.h"
#include "lib/debug.h"
#include "maths/FixedVector3D.h"
#include "maths/Matrix3D.h"
#include "maths/Vector3D.h"
#include <utility>
//Note: column major order! Each set of 4 constitutes a column.
CMatrix3D HermiteSpline(2.f, -3.f, 0.f, 1.f,

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2020 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -26,8 +26,9 @@
#define MAX_SPLINE_NODES 128
#include "FixedVector3D.h"
#include "Vector3D.h"
#include "maths/Fixed.h"
#include "maths/FixedVector3D.h"
#include "maths/Vector3D.h"
#include <vector>

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2009 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -25,7 +25,9 @@
#include "precompiled.h"
#include "Plane.h"
#include "MathUtil.h"
#include "maths/MathUtil.h"
#include "maths/Vector3D.h"
const float CPlane::m_EPS = 0.001f;

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2009 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -19,8 +19,11 @@
#include "Quaternion.h"
#include "MathUtil.h"
#include "Matrix3D.h"
#include "maths/MathUtil.h"
#include "maths/Matrix3D.h"
#include "maths/Vector3D.h"
#include <cmath>
const float EPSILON=0.0001f;

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2024 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -22,6 +22,8 @@
#include "maths/Size2D.h"
#include "maths/Vector2D.h"
#include <algorithm>
CRect::CRect() :
left(0.f), top(0.f), right(0.f), bottom(0.f)
{

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2010 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -18,6 +18,8 @@
#ifndef INCLUDED_MATH_SQRT
#define INCLUDED_MATH_SQRT
#include "lib/types.h"
/**
* 64-bit integer square root.
* Returns r such that r^2 <= n < (r+1)^2, for the complete u64 range.

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2022 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -20,7 +20,8 @@
#include "ps/containers/Span.h"
#include <math.h>
#include <cmath>
#include <cstddef>
class CSize2D;

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2022 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -25,6 +25,8 @@
#include "ps/containers/Span.h"
#include <cstddef>
class CFixedVector3D;
class CVector3D

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2022 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -25,7 +25,7 @@
#include "ps/containers/Span.h"
#include <math.h>
#include <cstddef>
class CVector4D
{

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2019 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -17,10 +17,12 @@
#include "lib/self_test.h"
#include "lib/posix/posix.h"
#include "maths/BoundingBoxAligned.h"
#include "maths/BoundingBoxOriented.h"
#include "maths/Matrix3D.h"
#include "maths/Vector3D.h"
#include <cmath>
#define TS_ASSERT_VEC_DELTA(v, x, y, z, delta) \
TS_ASSERT_DELTA(v.X, x, delta); \

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2019 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -19,8 +19,10 @@
#include "maths/BoundingBoxAligned.h"
#include "maths/BoundingSphere.h"
#include "maths/Vector3D.h"
#include <cmath>
#include <cstddef>
class TestBoundingSphere : public CxxTest::TestSuite
{

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -17,9 +17,18 @@
#include "lib/self_test.h"
#include "maths/Brush.h"
#include "maths/BoundingBoxAligned.h"
#include "maths/Frustum.h"
#include "maths/Brush.h"
#include "maths/Plane.h"
#include "maths/Vector3D.h"
#include "maths/Vector4D.h"
#include <algorithm>
#include <cmath>
#include <cstdarg>
#include <cstddef>
#include <iterator>
#include <vector>
class TestBrush : public CxxTest::TestSuite
{

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2022 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -22,8 +22,14 @@
# pragma warning(push, 1)
# pragma warning(disable: 4724)
#endif
#include "lib/types.h"
#include "maths/Fixed.h"
#include "maths/MathUtil.h"
#include "ps/CStr.h"
#include <algorithm>
#include <cmath>
#include <limits>
class TestFixed : public CxxTest::TestSuite
{

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2020 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -17,8 +17,12 @@
#include "lib/self_test.h"
#include "lib/types.h"
#include "maths/Fixed.h"
#include "maths/FixedVector2D.h"
#include <cmath>
#define TS_ASSERT_VEC_EQUALS(v, x, y) \
TS_ASSERT_EQUALS(v.X.ToDouble(), x); \
TS_ASSERT_EQUALS(v.Y.ToDouble(), y);

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2010 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -17,8 +17,12 @@
#include "lib/self_test.h"
#include "lib/types.h"
#include "maths/Fixed.h"
#include "maths/FixedVector3D.h"
#include <cmath>
#define TS_ASSERT_VEC_EQUALS(v, x, y, z) \
TS_ASSERT_EQUALS(v.X.ToDouble(), x); \
TS_ASSERT_EQUALS(v.Y.ToDouble(), y); \

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2018 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -17,9 +17,13 @@
#include "lib/self_test.h"
#include "lib/types.h"
#include "maths/MD5.h"
#include "ps/Util.h"
#include <cstring>
#include <string>
class TestMD5 : public CxxTest::TestSuite
{
public:

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2024 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -17,11 +17,12 @@
#include "lib/self_test.h"
#include "lib/lib.h"
#include "maths/Matrix3D.h"
#include "maths/Quaternion.h"
#include "maths/Vector3D.h"
#include <cmath>
#include <cstdlib>
#include <random>
class TestMatrix : public CxxTest::TestSuite

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2019 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -17,11 +17,14 @@
#include "lib/self_test.h"
#include "lib/types.h"
#include "maths/Sqrt.h"
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int_distribution.hpp>
#include <boost/random/variate_generator.hpp>
#include <cmath>
#include <cstddef>
class TestSqrt : public CxxTest::TestSuite
{