Skip to content

Commit 11e16ec

Browse files
committed
Fixed grammar in comments; Renamed variables to align with overall naming conventions.
1 parent e9a34a4 commit 11e16ec

3 files changed

Lines changed: 34 additions & 30 deletions

File tree

SubSystems/VisualNodeArea/VisualNodeArea.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ void NodeArea::LoadFromJson(std::string JsonText)
417417

418418
Connection* NewConnection = Connections.back();
419419

420-
// First pass to fill information that does not depend other reroutes.
420+
// First pass to fill information that does not depend on other reroutes.
421421
std::vector<Json::String> RerouteList = root["connections"][ConnectionsList[i]]["reroute_connections"].getMemberNames();
422422
for (size_t j = 0; j < RerouteList.size(); j++)
423423
{
@@ -436,23 +436,23 @@ void NodeArea::LoadFromJson(std::string JsonText)
436436
for (size_t j = 0; j < RerouteList.size(); j++)
437437
{
438438
std::string BeginSocketID = root["connections"][ConnectionsList[i]]["reroute_connections"][std::to_string(j)]["begin_socket_ID"].asCString();
439-
if (BeginSocketID != "")
439+
if (!BeginSocketID.empty())
440440
{
441441
NodeSocket* BeginSocket = NewConnection->Out;
442442
if (BeginSocketID == BeginSocket->GetID())
443443
NewConnection->RerouteNodes[j]->BeginSocket = BeginSocket;
444444
}
445445

446446
std::string EndSocketID = root["connections"][ConnectionsList[i]]["reroute_connections"][std::to_string(j)]["end_socket_ID"].asCString();
447-
if (EndSocketID != "")
447+
if (!EndSocketID.empty())
448448
{
449449
NodeSocket* EndSocket = NewConnection->In;
450450
if (EndSocketID == EndSocket->GetID())
451451
NewConnection->RerouteNodes[j]->EndSocket = EndSocket;
452452
}
453453

454454
std::string BeginRerouteID = root["connections"][ConnectionsList[i]]["reroute_connections"][std::to_string(j)]["begin_reroute_ID"].asCString();
455-
if (BeginRerouteID != "")
455+
if (!BeginRerouteID.empty())
456456
{
457457
RerouteNode* BeginReroute = nullptr;
458458
for (size_t k = 0; k < NewConnection->RerouteNodes.size(); k++)
@@ -466,7 +466,7 @@ void NodeArea::LoadFromJson(std::string JsonText)
466466
}
467467

468468
std::string EndRerouteID = root["connections"][ConnectionsList[i]]["reroute_connections"][std::to_string(j)]["end_reroute_ID"].asCString();
469-
if (EndRerouteID != "")
469+
if (!EndRerouteID.empty())
470470
{
471471
RerouteNode* EndReroute = nullptr;
472472
for (size_t k = 0; k < NewConnection->RerouteNodes.size(); k++)
@@ -618,7 +618,7 @@ std::vector<ConnectionSegment> NodeArea::GetConnectionSegments(const Connection*
618618
CurrentSegment.End = EndPosition;
619619
Result.push_back(CurrentSegment);
620620

621-
// Than we will add segment from current reroute to end, only if it is last reroute
621+
// Then we will add segment from current reroute to end, only if it is last reroute
622622
if (i == Connection->RerouteNodes.size() - 1)
623623
{
624624
CurrentSegment = ConnectionSegment();

SubSystems/VisualNodeArea/VisualNodeAreaInput.cpp

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,39 +1109,43 @@ bool NodeArea::IsPointInRegion(const ImVec2& Point, const ImVec2& RegionMin, con
11091109
return (Point.x >= RegionMin.x && Point.x <= RegionMax.x && Point.y >= RegionMin.y && Point.y <= RegionMax.y);
11101110
}
11111111

1112-
int Orientation(const ImVec2& p, const ImVec2& q, const ImVec2& r)
1112+
int Orientation(const ImVec2& FirstPoint, const ImVec2& SecondPoint, const ImVec2& ThirdPoint)
11131113
{
1114-
float val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
1114+
const float Value = (SecondPoint.y - FirstPoint.y) * (ThirdPoint.x - SecondPoint.x) - (SecondPoint.x - FirstPoint.x) * (ThirdPoint.y - SecondPoint.y);
11151115

1116-
if (val == 0) return 0; // Collinear
1117-
return (val > 0) ? 1 : 2; // Clockwise or Counterclockwise
1116+
// Collinear
1117+
if (Value == 0)
1118+
return 0;
1119+
1120+
return (Value > 0) ? 1 : 2; // Clockwise or Counterclockwise
11181121
}
11191122

1120-
bool OnSegment(const ImVec2& p, const ImVec2& q, const ImVec2& r)
1123+
bool OnSegment(const ImVec2& SegmentStart, const ImVec2& SegmentEnd, const ImVec2& PointToCheck)
11211124
{
1122-
if (q.x <= std::max(p.x, r.x) && q.x >= std::min(p.x, r.x) &&
1123-
q.y <= std::max(p.y, r.y) && q.y >= std::min(p.y, r.y))
1125+
if (PointToCheck.x <= std::max(SegmentStart.x, SegmentEnd.x) && PointToCheck.x >= std::min(SegmentStart.x, SegmentEnd.x) &&
1126+
PointToCheck.y <= std::max(SegmentStart.y, SegmentEnd.y) && PointToCheck.y >= std::min(SegmentStart.y, SegmentEnd.y))
11241127
return true;
1128+
11251129
return false;
11261130
}
11271131

1128-
bool IsLineSegmentIntersecting(const ImVec2& p1, const ImVec2& q1, const ImVec2& p2, const ImVec2& q2)
1132+
bool IsLineSegmentIntersecting(const ImVec2& FirstSegmentStart, const ImVec2& FirstSegmentEnd, const ImVec2& SecondSegmentStart, const ImVec2& SecondSegmentEnd)
11291133
{
11301134
// Find the four orientations
1131-
int o1 = Orientation(p1, q1, p2);
1132-
int o2 = Orientation(p1, q1, q2);
1133-
int o3 = Orientation(p2, q2, p1);
1134-
int o4 = Orientation(p2, q2, q1);
1135+
int FirstLineToSecondStart = Orientation(FirstSegmentStart, FirstSegmentEnd, SecondSegmentStart);
1136+
int FirstLineToSecondEnd = Orientation(FirstSegmentStart, FirstSegmentEnd, SecondSegmentEnd);
1137+
int SecondLineToFirstStart = Orientation(SecondSegmentStart, SecondSegmentEnd, FirstSegmentStart);
1138+
int SecondLineToFirstEnd = Orientation(SecondSegmentStart, SecondSegmentEnd, FirstSegmentEnd);
11351139

11361140
// General case
1137-
if (o1 != o2 && o3 != o4)
1141+
if (FirstLineToSecondStart != FirstLineToSecondEnd && SecondLineToFirstStart != SecondLineToFirstEnd)
11381142
return true;
11391143

11401144
// Special cases: check if the segments are collinear and overlap
1141-
if (o1 == 0 && OnSegment(p1, p2, q1)) return true;
1142-
if (o2 == 0 && OnSegment(p1, q2, q1)) return true;
1143-
if (o3 == 0 && OnSegment(p2, p1, q2)) return true;
1144-
if (o4 == 0 && OnSegment(p2, q1, q2)) return true;
1145+
if (FirstLineToSecondStart == 0 && OnSegment(FirstSegmentStart, SecondSegmentStart, FirstSegmentEnd)) return true;
1146+
if (FirstLineToSecondEnd == 0 && OnSegment(FirstSegmentStart, SecondSegmentEnd, FirstSegmentEnd)) return true;
1147+
if (SecondLineToFirstStart == 0 && OnSegment(SecondSegmentStart, FirstSegmentStart, SecondSegmentEnd)) return true;
1148+
if (SecondLineToFirstEnd == 0 && OnSegment(SecondSegmentStart, FirstSegmentEnd, SecondSegmentEnd)) return true;
11451149

11461150
return false; // If none of the above cases, return false
11471151
}
@@ -1181,27 +1185,27 @@ bool NodeArea::IsSegmentInRegion(ImVec2 Begin, ImVec2 End, const int Steps)
11811185
float h3 = t * t * t - 2 * t * t + t;
11821186
float h4 = t * t * t - t * t;
11831187

1184-
ImVec2 segmentStart = ImVec2(h1 * Begin.x + h2 * End.x + h3 * t1.x + h4 * t2.x, h1 * Begin.y + h2 * End.y + h3 * t1.y + h4 * t2.y);
1188+
ImVec2 SegmentStart = ImVec2(h1 * Begin.x + h2 * End.x + h3 * t1.x + h4 * t2.x, h1 * Begin.y + h2 * End.y + h3 * t1.y + h4 * t2.y);
11851189

11861190
t = static_cast<float>(Step + 1) / static_cast<float>(Steps); // Update t for the end segment.
11871191
h1 = +2 * t * t * t - 3 * t * t + 1.0f;
11881192
h2 = -2 * t * t * t + 3 * t * t;
11891193
h3 = t * t * t - 2 * t * t + t;
11901194
h4 = t * t * t - t * t;
11911195

1192-
ImVec2 segmentEnd = ImVec2(h1 * Begin.x + h2 * End.x + h3 * t1.x + h4 * t2.x, h1 * Begin.y + h2 * End.y + h3 * t1.y + h4 * t2.y);
1196+
ImVec2 SegmentEnd = ImVec2(h1 * Begin.x + h2 * End.x + h3 * t1.x + h4 * t2.x, h1 * Begin.y + h2 * End.y + h3 * t1.y + h4 * t2.y);
11931197

11941198
// If either of the segment's points are in the region, the connection is in the region.
1195-
if (IsPointInRegion(segmentStart, MouseSelectRegionMin, MouseSelectRegionMax) ||
1196-
IsPointInRegion(segmentEnd, MouseSelectRegionMin, MouseSelectRegionMax))
1199+
if (IsPointInRegion(SegmentStart, MouseSelectRegionMin, MouseSelectRegionMax) ||
1200+
IsPointInRegion(SegmentEnd, MouseSelectRegionMin, MouseSelectRegionMax))
11971201
{
11981202
return true;
11991203
}
12001204

12011205
// Check if the segment intersects with any of the region's edges.
12021206
for (int i = 0; i < 4; i++)
12031207
{
1204-
if (IsLineSegmentIntersecting(regionCorners[i], regionCorners[(i + 1) % 4], segmentStart, segmentEnd))
1208+
if (IsLineSegmentIntersecting(regionCorners[i], regionCorners[(i + 1) % 4], SegmentStart, SegmentEnd))
12051209
{
12061210
return true;
12071211
}

VisualNodeSocket.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ namespace VisNodeSys
3939

4040
std::string GetType() const;
4141

42-
bool isOutput() const { return bOutput; }
43-
bool isInput() const { return !bOutput; }
42+
bool IsOutput() const { return bOutput; }
43+
bool IsInput() const { return !bOutput; }
4444

4545
void SetFunctionToOutputData(std::function<void* ()> NewFunction);
4646
void* GetData() { return OutputData(); }

0 commit comments

Comments
 (0)