Reformat the code, using:

find -type f |  # list all regular files
  grep -E '\.(h|cpp|mm)$' |  # filter for source files
  grep -v '/mt_' |  # filter out generated files
  grep -v '/vendor/' | # and vendored GL
  grep -v '/test/image_loader_test.cpp' |  # and this file (has giant literals arrays)
  xargs -n 1 -P $(nproc) clang-format -i  # reformat everything

Co-authored-by: numzero <numzer0@yandex.ru>
This commit is contained in:
Desour
2024-03-20 19:35:52 +01:00
committed by sfan5
parent 9814510b1b
commit f5c6d3e945
292 changed files with 37376 additions and 42421 deletions

View File

@ -31,28 +31,29 @@ enum E_VERTEX_TYPE
};
//! Array holding the built in vertex type names
const char* const sBuiltInVertexTypeNames[] =
{
"standard",
"2tcoords",
"tangents",
0
};
const char *const sBuiltInVertexTypeNames[] =
{
"standard",
"2tcoords",
"tangents",
0};
//! standard vertex used by the Irrlicht engine.
struct S3DVertex
{
//! default constructor
constexpr S3DVertex() : Color(0xffffffff) {}
constexpr S3DVertex() :
Color(0xffffffff) {}
//! constructor
constexpr S3DVertex(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv)
: Pos(x,y,z), Normal(nx,ny,nz), Color(c), TCoords(tu,tv) {}
constexpr S3DVertex(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv) :
Pos(x, y, z), Normal(nx, ny, nz), Color(c), TCoords(tu, tv) {}
//! constructor
constexpr S3DVertex(const core::vector3df& pos, const core::vector3df& normal,
SColor color, const core::vector2df& tcoords)
: Pos(pos), Normal(normal), Color(color), TCoords(tcoords) {}
constexpr S3DVertex(const core::vector3df &pos, const core::vector3df &normal,
SColor color, const core::vector2df &tcoords) :
Pos(pos),
Normal(normal), Color(color), TCoords(tcoords) {}
//! Position
core::vector3df Pos;
@ -66,19 +67,19 @@ struct S3DVertex
//! Texture coordinates
core::vector2df TCoords;
constexpr bool operator==(const S3DVertex& other) const
constexpr bool operator==(const S3DVertex &other) const
{
return ((Pos == other.Pos) && (Normal == other.Normal) &&
(Color == other.Color) && (TCoords == other.TCoords));
(Color == other.Color) && (TCoords == other.TCoords));
}
constexpr bool operator!=(const S3DVertex& other) const
constexpr bool operator!=(const S3DVertex &other) const
{
return ((Pos != other.Pos) || (Normal != other.Normal) ||
(Color != other.Color) || (TCoords != other.TCoords));
(Color != other.Color) || (TCoords != other.TCoords));
}
constexpr bool operator<(const S3DVertex& other) const
constexpr bool operator<(const S3DVertex &other) const
{
return ((Pos < other.Pos) ||
((Pos == other.Pos) && (Normal < other.Normal)) ||
@ -93,7 +94,7 @@ struct S3DVertex
}
//\param d d=0 returns other, d=1 returns this, values between interpolate.
S3DVertex getInterpolated(const S3DVertex& other, f32 d)
S3DVertex getInterpolated(const S3DVertex &other, f32 d)
{
d = core::clamp(d, 0.0f, 1.0f);
return S3DVertex(Pos.getInterpolated(other.Pos, d),
@ -103,7 +104,6 @@ struct S3DVertex
}
};
//! Vertex with two texture coordinates.
/** Usually used for geometry with lightmaps
or other special materials.
@ -111,61 +111,68 @@ or other special materials.
struct S3DVertex2TCoords : public S3DVertex
{
//! default constructor
constexpr S3DVertex2TCoords() : S3DVertex() {}
constexpr S3DVertex2TCoords() :
S3DVertex() {}
//! constructor with two different texture coords, but no normal
constexpr S3DVertex2TCoords(f32 x, f32 y, f32 z, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2)
: S3DVertex(x,y,z, 0.0f, 0.0f, 0.0f, c, tu,tv), TCoords2(tu2,tv2) {}
constexpr S3DVertex2TCoords(f32 x, f32 y, f32 z, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2) :
S3DVertex(x, y, z, 0.0f, 0.0f, 0.0f, c, tu, tv), TCoords2(tu2, tv2) {}
//! constructor with two different texture coords, but no normal
constexpr S3DVertex2TCoords(const core::vector3df& pos, SColor color,
const core::vector2df& tcoords, const core::vector2df& tcoords2)
: S3DVertex(pos, core::vector3df(), color, tcoords), TCoords2(tcoords2) {}
constexpr S3DVertex2TCoords(const core::vector3df &pos, SColor color,
const core::vector2df &tcoords, const core::vector2df &tcoords2) :
S3DVertex(pos, core::vector3df(), color, tcoords),
TCoords2(tcoords2) {}
//! constructor with all values
constexpr S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal, const SColor& color,
const core::vector2df& tcoords, const core::vector2df& tcoords2)
: S3DVertex(pos, normal, color, tcoords), TCoords2(tcoords2) {}
constexpr S3DVertex2TCoords(const core::vector3df &pos, const core::vector3df &normal, const SColor &color,
const core::vector2df &tcoords, const core::vector2df &tcoords2) :
S3DVertex(pos, normal, color, tcoords),
TCoords2(tcoords2) {}
//! constructor with all values
constexpr S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz,
SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2)
: S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), TCoords2(tu2,tv2) {}
SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2) :
S3DVertex(x, y, z, nx, ny, nz, c, tu, tv),
TCoords2(tu2, tv2) {}
//! constructor with the same texture coords and normal
constexpr S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz,
SColor c, f32 tu, f32 tv)
: S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), TCoords2(tu,tv) {}
SColor c, f32 tu, f32 tv) :
S3DVertex(x, y, z, nx, ny, nz, c, tu, tv),
TCoords2(tu, tv) {}
//! constructor with the same texture coords and normal
constexpr S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal,
SColor color, const core::vector2df& tcoords)
: S3DVertex(pos, normal, color, tcoords), TCoords2(tcoords) {}
constexpr S3DVertex2TCoords(const core::vector3df &pos, const core::vector3df &normal,
SColor color, const core::vector2df &tcoords) :
S3DVertex(pos, normal, color, tcoords),
TCoords2(tcoords) {}
//! constructor from S3DVertex
constexpr S3DVertex2TCoords(const S3DVertex& o) : S3DVertex(o) {}
constexpr S3DVertex2TCoords(const S3DVertex &o) :
S3DVertex(o) {}
//! Second set of texture coordinates
core::vector2df TCoords2;
//! Equality operator
constexpr bool operator==(const S3DVertex2TCoords& other) const
constexpr bool operator==(const S3DVertex2TCoords &other) const
{
return ((static_cast<S3DVertex>(*this)==static_cast<const S3DVertex&>(other)) &&
(TCoords2 == other.TCoords2));
return ((static_cast<S3DVertex>(*this) == static_cast<const S3DVertex &>(other)) &&
(TCoords2 == other.TCoords2));
}
//! Inequality operator
constexpr bool operator!=(const S3DVertex2TCoords& other) const
constexpr bool operator!=(const S3DVertex2TCoords &other) const
{
return ((static_cast<S3DVertex>(*this)!=static_cast<const S3DVertex&>(other)) ||
(TCoords2 != other.TCoords2));
return ((static_cast<S3DVertex>(*this) != static_cast<const S3DVertex &>(other)) ||
(TCoords2 != other.TCoords2));
}
constexpr bool operator<(const S3DVertex2TCoords& other) const
constexpr bool operator<(const S3DVertex2TCoords &other) const
{
return ((static_cast<S3DVertex>(*this) < other) ||
((static_cast<S3DVertex>(*this) == static_cast<const S3DVertex&>(other)) && (TCoords2 < other.TCoords2)));
((static_cast<S3DVertex>(*this) == static_cast<const S3DVertex &>(other)) && (TCoords2 < other.TCoords2)));
}
static E_VERTEX_TYPE getType()
@ -174,7 +181,7 @@ struct S3DVertex2TCoords : public S3DVertex
}
//\param d d=0 returns other, d=1 returns this, values between interpolate.
S3DVertex2TCoords getInterpolated(const S3DVertex2TCoords& other, f32 d)
S3DVertex2TCoords getInterpolated(const S3DVertex2TCoords &other, f32 d)
{
d = core::clamp(d, 0.0f, 1.0f);
return S3DVertex2TCoords(Pos.getInterpolated(other.Pos, d),
@ -185,7 +192,6 @@ struct S3DVertex2TCoords : public S3DVertex
}
};
//! Vertex with a tangent and binormal vector.
/** Usually used for tangent space normal mapping.
Usually tangent and binormal get send to shaders as texture coordinate sets 1 and 2.
@ -193,30 +199,34 @@ struct S3DVertex2TCoords : public S3DVertex
struct S3DVertexTangents : public S3DVertex
{
//! default constructor
S3DVertexTangents() : S3DVertex() { }
S3DVertexTangents() :
S3DVertex() {}
//! constructor
constexpr S3DVertexTangents(f32 x, f32 y, f32 z, f32 nx=0.0f, f32 ny=0.0f, f32 nz=0.0f,
SColor c = 0xFFFFFFFF, f32 tu=0.0f, f32 tv=0.0f,
f32 tanx=0.0f, f32 tany=0.0f, f32 tanz=0.0f,
f32 bx=0.0f, f32 by=0.0f, f32 bz=0.0f)
: S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), Tangent(tanx,tany,tanz), Binormal(bx,by,bz) { }
constexpr S3DVertexTangents(f32 x, f32 y, f32 z, f32 nx = 0.0f, f32 ny = 0.0f, f32 nz = 0.0f,
SColor c = 0xFFFFFFFF, f32 tu = 0.0f, f32 tv = 0.0f,
f32 tanx = 0.0f, f32 tany = 0.0f, f32 tanz = 0.0f,
f32 bx = 0.0f, f32 by = 0.0f, f32 bz = 0.0f) :
S3DVertex(x, y, z, nx, ny, nz, c, tu, tv),
Tangent(tanx, tany, tanz), Binormal(bx, by, bz) {}
//! constructor
constexpr S3DVertexTangents(const core::vector3df& pos, SColor c,
const core::vector2df& tcoords)
: S3DVertex(pos, core::vector3df(), c, tcoords) { }
constexpr S3DVertexTangents(const core::vector3df &pos, SColor c,
const core::vector2df &tcoords) :
S3DVertex(pos, core::vector3df(), c, tcoords) {}
//! constructor
constexpr S3DVertexTangents(const core::vector3df& pos,
const core::vector3df& normal, SColor c,
const core::vector2df& tcoords,
const core::vector3df& tangent=core::vector3df(),
const core::vector3df& binormal=core::vector3df())
: S3DVertex(pos, normal, c, tcoords), Tangent(tangent), Binormal(binormal) { }
constexpr S3DVertexTangents(const core::vector3df &pos,
const core::vector3df &normal, SColor c,
const core::vector2df &tcoords,
const core::vector3df &tangent = core::vector3df(),
const core::vector3df &binormal = core::vector3df()) :
S3DVertex(pos, normal, c, tcoords),
Tangent(tangent), Binormal(binormal) {}
//! constructor from S3DVertex
constexpr S3DVertexTangents(const S3DVertex& o) : S3DVertex(o) {}
constexpr S3DVertexTangents(const S3DVertex &o) :
S3DVertex(o) {}
//! Tangent vector along the x-axis of the texture
core::vector3df Tangent;
@ -224,25 +234,25 @@ struct S3DVertexTangents : public S3DVertex
//! Binormal vector (tangent x normal)
core::vector3df Binormal;
constexpr bool operator==(const S3DVertexTangents& other) const
constexpr bool operator==(const S3DVertexTangents &other) const
{
return ((static_cast<S3DVertex>(*this)==static_cast<const S3DVertex&>(other)) &&
(Tangent == other.Tangent) &&
(Binormal == other.Binormal));
return ((static_cast<S3DVertex>(*this) == static_cast<const S3DVertex &>(other)) &&
(Tangent == other.Tangent) &&
(Binormal == other.Binormal));
}
constexpr bool operator!=(const S3DVertexTangents& other) const
constexpr bool operator!=(const S3DVertexTangents &other) const
{
return ((static_cast<S3DVertex>(*this)!=static_cast<const S3DVertex&>(other)) ||
(Tangent != other.Tangent) ||
(Binormal != other.Binormal));
return ((static_cast<S3DVertex>(*this) != static_cast<const S3DVertex &>(other)) ||
(Tangent != other.Tangent) ||
(Binormal != other.Binormal));
}
constexpr bool operator<(const S3DVertexTangents& other) const
constexpr bool operator<(const S3DVertexTangents &other) const
{
return ((static_cast<S3DVertex>(*this) < other) ||
((static_cast<S3DVertex>(*this) == static_cast<const S3DVertex&>(other)) && (Tangent < other.Tangent)) ||
((static_cast<S3DVertex>(*this) == static_cast<const S3DVertex&>(other)) && (Tangent == other.Tangent) && (Binormal < other.Binormal)));
((static_cast<S3DVertex>(*this) == static_cast<const S3DVertex &>(other)) && (Tangent < other.Tangent)) ||
((static_cast<S3DVertex>(*this) == static_cast<const S3DVertex &>(other)) && (Tangent == other.Tangent) && (Binormal < other.Binormal)));
}
static E_VERTEX_TYPE getType()
@ -250,7 +260,7 @@ struct S3DVertexTangents : public S3DVertex
return EVT_TANGENTS;
}
S3DVertexTangents getInterpolated(const S3DVertexTangents& other, f32 d)
S3DVertexTangents getInterpolated(const S3DVertexTangents &other, f32 d)
{
d = core::clamp(d, 0.0f, 1.0f);
return S3DVertexTangents(Pos.getInterpolated(other.Pos, d),
@ -262,12 +272,9 @@ struct S3DVertexTangents : public S3DVertex
}
};
inline u32 getVertexPitchFromType(E_VERTEX_TYPE vertexType)
{
switch (vertexType)
{
switch (vertexType) {
case video::EVT_2TCOORDS:
return sizeof(video::S3DVertex2TCoords);
case video::EVT_TANGENTS:
@ -277,6 +284,5 @@ inline u32 getVertexPitchFromType(E_VERTEX_TYPE vertexType)
}
}
} // end namespace video
} // end namespace irr