Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Fix ifs clang-format didn’t get
Browse files Browse the repository at this point in the history
  • Loading branch information
numberZero committed Nov 2, 2023
1 parent 9493e33 commit 805a036
Show file tree
Hide file tree
Showing 26 changed files with 70 additions and 140 deletions.
6 changes: 2 additions & 4 deletions examples/AutomatedTest/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ int main(int argc, char *argv[])
if (device->getTimer()->getTime() >= 1000) {
device->getTimer()->setTime(0);
++n;
if (n == 1) // Tooltip display
{
if (n == 1) { // Tooltip display
bzero(&event, sizeof(SEvent));
event.EventType = irr::EET_MOUSE_INPUT_EVENT;
event.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
Expand All @@ -127,8 +126,7 @@ int main(int argc, char *argv[])
device->postEventFromUser(event);
} else if (n == 2) // Text input focus
guienv->setFocus(editbox);
else if (n == 3) // Keypress for Text input
{
else if (n == 3) { // Keypress for Text input
bzero(&event, sizeof(SEvent));
event.EventType = irr::EET_KEY_INPUT_EVENT;
event.KeyInput.Char = L'a';
Expand Down
3 changes: 1 addition & 2 deletions include/SColor.h
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,7 @@ inline void SColorHSL::fromRGB(const SColorf &color)
inline void SColorHSL::toRGB(SColorf &color) const
{
const f32 l = Luminance / 100;
if (core::iszero(Saturation)) // grey
{
if (core::iszero(Saturation)) { // grey
color.set(l, l, l);
return;
}
Expand Down
12 changes: 4 additions & 8 deletions include/matrix4.h
Original file line number Diff line number Diff line change
Expand Up @@ -1553,8 +1553,7 @@ inline CMatrix4<T> &CMatrix4<T>::buildProjectionMatrixPerspectiveFovRH(
// M[14]
M[15] = 0;

if (zClipFromZero) // DirectX version
{
if (zClipFromZero) { // DirectX version
M[10] = (T)(zFar / (zNear - zFar));
M[14] = (T)(zNear * zFar / (zNear - zFar));
} else // OpenGL version
Expand Down Expand Up @@ -1599,8 +1598,7 @@ inline CMatrix4<T> &CMatrix4<T>::buildProjectionMatrixPerspectiveFovLH(
// M[14]
M[15] = 0;

if (zClipFromZero) // DirectX version
{
if (zClipFromZero) { // DirectX version
M[10] = (T)(zFar / (zFar - zNear));
M[14] = (T)(-zNear * zFar / (zFar - zNear));
} else // OpenGL version
Expand Down Expand Up @@ -1762,8 +1760,7 @@ inline CMatrix4<T> &CMatrix4<T>::buildProjectionMatrixPerspectiveRH(
// M[14]
M[15] = 0;

if (zClipFromZero) // DirectX version
{
if (zClipFromZero) { // DirectX version
M[10] = (T)(zFar / (zNear - zFar));
M[14] = (T)(zNear * zFar / (zNear - zFar));
} else // OpenGL version
Expand Down Expand Up @@ -1806,8 +1803,7 @@ inline CMatrix4<T> &CMatrix4<T>::buildProjectionMatrixPerspectiveLH(
// M[14] = (T)(zNear*zFar/(zNear-zFar));
M[15] = 0;

if (zClipFromZero) // DirectX version
{
if (zClipFromZero) { // DirectX version
M[10] = (T)(zFar / (zFar - zNear));
M[14] = (T)(zNear * zFar / (zNear - zFar));
} else // OpenGL version
Expand Down
9 changes: 3 additions & 6 deletions include/quaternion.h
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,7 @@ inline quaternion &quaternion::slerp(quaternion q1, quaternion q2, f32 time, f32
angle *= -1.0f;
}

if (angle <= (1 - threshold)) // spherical interpolation
{
if (angle <= (1 - threshold)) { // spherical interpolation
const f32 theta = acosf(angle);
const f32 invsintheta = reciprocal(sinf(theta));
const f32 scale = sinf(theta * (1.0f - time)) * invsintheta;
Expand Down Expand Up @@ -698,11 +697,9 @@ inline core::quaternion &quaternion::rotationFromTo(const vector3df &from, const
v1.normalize();

const f32 d = v0.dotProduct(v1);
if (d >= 1.0f) // If dot == 1, vectors are the same
{
if (d >= 1.0f) { // If dot == 1, vectors are the same
return makeIdentity();
} else if (d <= -1.0f) // exactly opposite
{
} else if (d <= -1.0f) { // exactly opposite
core::vector3df axis(1.0f, 0.f, 0.f);
axis = axis.crossProduct(v0);
if (axis.getLength() == 0) {
Expand Down
15 changes: 5 additions & 10 deletions source/Irrlicht/CAnimatedMeshSceneNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ void CAnimatedMeshSceneNode::buildFrameNr(u32 timeMs)

// We have no interpolation between EndFrame and StartFrame,
// the last frame must be identical to first one with our current solution.
if (FramesPerSecond > 0.f) // forwards...
{
if (FramesPerSecond > 0.f) { // forwards...
if (CurrentFrameNr > EndFrame)
CurrentFrameNr = StartFrame + fmodf(CurrentFrameNr - StartFrame, (f32)(EndFrame - StartFrame));
} else // backwards...
Expand All @@ -98,8 +97,7 @@ void CAnimatedMeshSceneNode::buildFrameNr(u32 timeMs)
// play animation non looped

CurrentFrameNr += timeMs * FramesPerSecond;
if (FramesPerSecond > 0.f) // forwards...
{
if (FramesPerSecond > 0.f) { // forwards...
if (CurrentFrameNr > (f32)EndFrame) {
CurrentFrameNr = (f32)EndFrame;
if (LoopCallBack)
Expand Down Expand Up @@ -176,8 +174,7 @@ IMesh *CAnimatedMeshSceneNode::getMeshForCurrentFrame()
// Update the skinned mesh for the current joint transforms.
skinnedMesh->skinMesh();

if (JointMode == EJUOR_READ) // read from mesh
{
if (JointMode == EJUOR_READ) { // read from mesh
skinnedMesh->recoverJointsFromMesh(JointChildSceneNodes);

//---slow---
Expand All @@ -199,8 +196,7 @@ IMesh *CAnimatedMeshSceneNode::getMeshForCurrentFrame()
//! OnAnimate() is called just before rendering the whole scene.
void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs)
{
if (LastTimeMs == 0) // first frame
{
if (LastTimeMs == 0) { // first frame
LastTimeMs = timeMs;
}

Expand Down Expand Up @@ -463,8 +459,7 @@ u32 CAnimatedMeshSceneNode::getJointCount() const
bool CAnimatedMeshSceneNode::removeChild(ISceneNode *child)
{
if (ISceneNode::removeChild(child)) {
if (JointsUsed) // stop weird bugs caused while changing parents as the joints are being created
{
if (JointsUsed) { // stop weird bugs caused while changing parents as the joints are being created
for (u32 i = 0; i < JointChildSceneNodes.size(); ++i) {
if (JointChildSceneNodes[i] == child) {
JointChildSceneNodes[i] = 0; // remove link to child
Expand Down
21 changes: 7 additions & 14 deletions source/Irrlicht/CB3DMeshFileLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,15 +456,13 @@ bool CB3DMeshFileLoader::readChunkTRIS(scene::SSkinMeshBuffer *meshBuffer, u32 m
}

if (AnimatedVertices_VertexID[vertex_id[i]] != -1) {
if (AnimatedVertices_BufferID[vertex_id[i]] != (s32)meshBufferID) // If this vertex is linked in a different meshbuffer
{
if (AnimatedVertices_BufferID[vertex_id[i]] != (s32)meshBufferID) { // If this vertex is linked in a different meshbuffer
AnimatedVertices_VertexID[vertex_id[i]] = -1;
AnimatedVertices_BufferID[vertex_id[i]] = -1;
showVertexWarning = true;
}
}
if (AnimatedVertices_VertexID[vertex_id[i]] == -1) // If this vertex is not in the meshbuffer
{
if (AnimatedVertices_VertexID[vertex_id[i]] == -1) { // If this vertex is not in the meshbuffer
// Check for lightmapping:
if (BaseVertices[vertex_id[i]].TCoords2 != core::vector2df(0.f, 0.f))
meshBuffer->convertTo2TCoords(); // Will only affect the meshbuffer the first time this is called
Expand Down Expand Up @@ -843,8 +841,7 @@ bool CB3DMeshFileLoader::readChunkBRUS()

// Fixes problems when the lightmap is on the first texture:
if (B3dMaterial.Textures[0] != 0) {
if (B3dMaterial.Textures[0]->Flags & 65536) // 65536 = secondary UV
{
if (B3dMaterial.Textures[0]->Flags & 65536) { // 65536 = secondary UV
SB3dTexture *TmpTexture;
TmpTexture = B3dMaterial.Textures[1];
B3dMaterial.Textures[1] = B3dMaterial.Textures[0];
Expand All @@ -868,11 +865,9 @@ bool CB3DMeshFileLoader::readChunkBRUS()
if (B3dMaterial.Textures[1]) {
B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
B3dMaterial.Material.ZWriteEnable = video::EZW_OFF;
} else if (B3dMaterial.Textures[0]) // One texture:
{
} else if (B3dMaterial.Textures[0]) { // One texture:
// Flags & 0x1 is usual SOLID, 0x8 is mipmap (handled before)
if (B3dMaterial.Textures[0]->Flags & 0x2) //(Alpha mapped)
{
if (B3dMaterial.Textures[0]->Flags & 0x2) { // (Alpha mapped)
B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
B3dMaterial.Material.ZWriteEnable = video::EZW_OFF;
} else if (B3dMaterial.Textures[0]->Flags & 0x4) //(Masked)
Expand All @@ -898,8 +893,7 @@ bool CB3DMeshFileLoader::readChunkBRUS()

//------ Material fx ------

if (B3dMaterial.fx & 1) // full-bright
{
if (B3dMaterial.fx & 1) { // full-bright
B3dMaterial.Material.AmbientColor = video::SColor(255, 255, 255, 255);
B3dMaterial.Material.Lighting = false;
} else
Expand All @@ -914,8 +908,7 @@ bool CB3DMeshFileLoader::readChunkBRUS()
if (B3dMaterial.fx & 16) // disable backface culling
B3dMaterial.Material.BackfaceCulling = false;

if (B3dMaterial.fx & 32) // force vertex alpha-blending
{
if (B3dMaterial.fx & 32) { // force vertex alpha-blending
B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
B3dMaterial.Material.ZWriteEnable = video::EZW_OFF;
}
Expand Down
6 changes: 2 additions & 4 deletions source/Irrlicht/CBlit.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,7 @@ static void executeBlit_TextureCombineColor_16_to_24(const SBlitJob *job)
const u32 src_x = (u32)(dx * wscale);
u32 color = PixelMul16_2(video::A1R5G5B5toA8R8G8B8(src[src_x]), jobColor);
u8 *writeTo = &dst[dx * 3];
if (video::getAlpha(src[src_x]) > 0) // only overlay if source has visible alpha (alpha == 1)
{
if (video::getAlpha(src[src_x]) > 0) { // only overlay if source has visible alpha (alpha == 1)
*writeTo++ = (color >> 16) & 0xFF;
*writeTo++ = (color >> 8) & 0xFF;
*writeTo++ = color & 0xFF;
Expand All @@ -634,8 +633,7 @@ static void executeBlit_TextureCombineColor_16_to_24(const SBlitJob *job)
for (u32 dx = 0; dx != w; ++dx) {
u32 color = PixelMul16_2(video::A1R5G5B5toA8R8G8B8(src[dx]), jobColor);
u8 *writeTo = &dst[dx * 3];
if (video::getAlpha(src[dx]) > 0) // only overlay if source has visible alpha (alpha == 1)
{
if (video::getAlpha(src[dx]) > 0) { // only overlay if source has visible alpha (alpha == 1)
*writeTo++ = (color >> 16) & 0xFF;
*writeTo++ = (color >> 8) & 0xFF;
*writeTo++ = color & 0xFF;
Expand Down
3 changes: 1 addition & 2 deletions source/Irrlicht/CColorConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ void CColorConverter::convert1BitTo16Bit(const u8 *in, s16 *out, s32 width, s32
for (s32 x = 0; x < width; ++x) {
out[x] = *in >> shift & 0x01 ? (s16)0xffff : (s16)0x8000;

if ((--shift) < 0) // 8 pixel done
{
if ((--shift) < 0) { // 8 pixel done
shift = 7;
++in;
}
Expand Down
12 changes: 4 additions & 8 deletions source/Irrlicht/CEGLManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ EGLConfig CEGLManager::chooseConfig(EConfigStyle confStyle)
}
break;
case 4: // alpha
if (Attribs[7]) // Params.WithAlphaChannel
{
if (Attribs[7]) { // Params.WithAlphaChannel
Attribs[7] = 0;

if (Params.AntiAlias) {
Expand All @@ -236,8 +235,7 @@ EGLConfig CEGLManager::chooseConfig(EConfigStyle confStyle)
--steps;
break;
case 3: // stencil
if (Attribs[15]) // Params.Stencilbuffer
{
if (Attribs[15]) { // Params.Stencilbuffer
Attribs[15] = 0;

if (Params.AntiAlias) {
Expand All @@ -249,15 +247,13 @@ EGLConfig CEGLManager::chooseConfig(EConfigStyle confStyle)
--steps;
break;
case 2: // depth size
if (Attribs[13] > 16) // Params.ZBufferBits
{
if (Attribs[13] > 16) { // Params.ZBufferBits
Attribs[13] -= 8;
} else
--steps;
break;
case 1: // buffer size
if (Attribs[9] > 16) // Params.Bits
{
if (Attribs[9] > 16) { // Params.Bits
Attribs[9] -= 8;
} else
--steps;
Expand Down
3 changes: 1 addition & 2 deletions source/Irrlicht/CFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,7 @@ io::path CFileSystem::getAbsolutePath(const io::path &filename) const
p = realpath(filename.c_str(), fpath);
if (!p) {
// content in fpath is unclear at this point
if (!fpath[0]) // seems like fpath wasn't altered, use our best guess
{
if (!fpath[0]) { // seems like fpath wasn't altered, use our best guess
io::path tmp(filename);
return flattenFilename(tmp);
} else
Expand Down
18 changes: 6 additions & 12 deletions source/Irrlicht/CGUIEditBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,7 @@ bool CGUIEditBox::processKey(const SEvent &event)
s.append(widep);
s.append(Text.subString(CursorPos, Text.size() - CursorPos));

if (!Max || s.size() <= Max) // thx to Fish FH for fix
{
if (!Max || s.size() <= Max) { // thx to Fish FH for fix
Text = s;
s = widep;
CursorPos += s.size();
Expand All @@ -340,8 +339,7 @@ bool CGUIEditBox::processKey(const SEvent &event)
s.append(widep);
s.append(Text.subString(realmend, Text.size() - realmend));

if (!Max || s.size() <= Max) // thx to Fish FH for fix
{
if (!Max || s.size() <= Max) { // thx to Fish FH for fix
Text = s;
s = widep;
CursorPos = realmbgn + s.size();
Expand Down Expand Up @@ -975,8 +973,7 @@ bool CGUIEditBox::processMouse(const SEvent &event)
}
} break;
case EMIE_LMOUSE_PRESSED_DOWN:
if (!Environment->hasFocus(this)) // can happen when events are manually send to the element
{
if (!Environment->hasFocus(this)) { // can happen when events are manually send to the element
BlinkStartTime = os::Timer::getTime();
MouseMarking = true;
CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y);
Expand Down Expand Up @@ -1106,12 +1103,10 @@ void CGUIEditBox::breakText()
c = Text[i];
bool lineBreak = false;

if (c == L'\r') // Mac or Windows breaks
{
if (c == L'\r') { // Mac or Windows breaks
lineBreak = true;
c = 0;
if (Text[i + 1] == L'\n') // Windows breaks
{
if (Text[i + 1] == L'\n') { // Windows breaks
// TODO: I (Michael) think that we shouldn't change the text given by the user for whatever reason.
// Instead rework the cursor positioning to be able to handle this (but not in stable release
// branch as users might already expect this behavior).
Expand All @@ -1120,8 +1115,7 @@ void CGUIEditBox::breakText()
if (CursorPos > i)
--CursorPos;
}
} else if (c == L'\n') // Unix breaks
{
} else if (c == L'\n') { // Unix breaks
lineBreak = true;
c = 0;
}
Expand Down
3 changes: 1 addition & 2 deletions source/Irrlicht/CGUIEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,7 @@ void CGUIEnvironment::OnPostRender(u32 time)
ToolTip.Element->setRelativePosition(pos);
}

if (ToolTip.Element && ToolTip.Element->isVisible()) // (isVisible() check only because we might use visibility for ToolTip one day)
{
if (ToolTip.Element && ToolTip.Element->isVisible()) { // (isVisible() check only because we might use visibility for ToolTip one day)
ToolTip.LastTime = time;

// got invisible or removed in the meantime?
Expand Down
12 changes: 4 additions & 8 deletions source/Irrlicht/CGUIFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,11 @@ core::dimension2d<u32> CGUIFont::getDimension(const wchar_t *text) const

for (const wchar_t *p = text; *p; ++p) {
bool lineBreak = false;
if (*p == L'\r') // Mac or Windows breaks
{
if (*p == L'\r') { // Mac or Windows breaks
lineBreak = true;
if (p[1] == L'\n') // Windows breaks
++p;
} else if (*p == L'\n') // Unix breaks
{
} else if (*p == L'\n') { // Unix breaks
lineBreak = true;
}
if (lineBreak) {
Expand Down Expand Up @@ -489,13 +487,11 @@ void CGUIFont::draw(const core::stringw &text, const core::rect<s32> &position,
wchar_t c = text[i];

bool lineBreak = false;
if (c == L'\r') // Mac or Windows breaks
{
if (c == L'\r') { // Mac or Windows breaks
lineBreak = true;
if (text[i + 1] == L'\n') // Windows breaks
c = text[++i];
} else if (c == L'\n') // Unix breaks
{
} else if (c == L'\n') { // Unix breaks
lineBreak = true;
}

Expand Down

0 comments on commit 805a036

Please sign in to comment.