mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
Add braces to C++ single-line loops and conditionals (NFC) (#2973)
This makes code easier to read and more consistent between C++ and Java. Also update clang-format settings to always add a line break (even if no braces are used).
This commit is contained in:
@@ -98,7 +98,9 @@ void WriteIni(ImGuiTextBuffer* out) {
|
||||
static void* Mechanism2DReadOpen(ImGuiContext* ctx,
|
||||
ImGuiSettingsHandler* handler,
|
||||
const char* name) {
|
||||
if (name == wpi::StringRef{"Mechanism2D"}) return &mechanism2DInfo;
|
||||
if (name == wpi::StringRef{"Mechanism2D"}) {
|
||||
return &mechanism2DInfo;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -109,7 +111,9 @@ static void Mechanism2DReadLine(ImGuiContext* ctx,
|
||||
auto [name, value] = line.split('=');
|
||||
name = name.trim();
|
||||
value = value.trim();
|
||||
if (entry == &mechanism2DInfo) ReadIni(name, value);
|
||||
if (entry == &mechanism2DInfo) {
|
||||
ReadIni(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
static void Mechanism2DWriteAll(ImGuiContext* ctx,
|
||||
@@ -166,20 +170,28 @@ static void buildDrawList(float startXLocation, float startYLocation,
|
||||
minSize = ImGui::GetWindowHeight() > ImGui::GetWindowWidth()
|
||||
? ImGui::GetWindowWidth()
|
||||
: ImGui::GetWindowHeight();
|
||||
if (devHandle == 0) devHandle = HALSIM_GetSimDeviceHandle("Mechanism2D");
|
||||
if (devHandle == 0) {
|
||||
devHandle = HALSIM_GetSimDeviceHandle("Mechanism2D");
|
||||
}
|
||||
// Get the length
|
||||
if (!lengthHandle)
|
||||
if (!lengthHandle) {
|
||||
lengthHandle = HALSIM_GetSimValueHandle(
|
||||
devHandle, (bodyConfig.name + "/length").c_str());
|
||||
if (lengthHandle) length = lengthHandle.Get();
|
||||
}
|
||||
if (lengthHandle) {
|
||||
length = lengthHandle.Get();
|
||||
}
|
||||
if (length <= 0) {
|
||||
length = bodyConfig.length;
|
||||
}
|
||||
// Get the angle
|
||||
if (!angleHandle)
|
||||
if (!angleHandle) {
|
||||
angleHandle = HALSIM_GetSimValueHandle(
|
||||
devHandle, (bodyConfig.name + "/angle").c_str());
|
||||
if (angleHandle) angle = angleHandle.Get();
|
||||
}
|
||||
if (angleHandle) {
|
||||
angle = angleHandle.Get();
|
||||
}
|
||||
// Calculate the next angle to go to
|
||||
float angleToGoTo = angle + bodyConfig.angle + previousAngle;
|
||||
// Draw the first line and get the ending coordinates
|
||||
|
||||
Reference in New Issue
Block a user