Skip to content

Commit

Permalink
Avoid repeating return types in types/ (clang-tidy)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daft-Freak committed May 9, 2022
1 parent a4a6c61 commit d7bd600
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion 32blit/types/point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace blit {
inline bool operator== (const Point &lhs, const Point &rhs) { return lhs.x == rhs.x && lhs.y == rhs.y; }
inline bool operator!= (const Point &lhs, const Point &rhs) { return !(lhs == rhs); }
inline Point operator- (Point lhs, const Point &rhs) { lhs -= rhs; return lhs; }
inline Point operator- (const Point &rhs) { return Point(-rhs.x, -rhs.y); }
inline Point operator- (const Point &rhs) { return {-rhs.x, -rhs.y}; }
inline Point operator+ (Point lhs, const Point &rhs) { lhs += rhs; return lhs; }
inline Point operator* (Point lhs, const float a) { lhs *= a; return lhs; }
inline Point operator* (Point lhs, const Mat3 &a) { lhs *= a; return lhs; }
Expand Down
20 changes: 10 additions & 10 deletions 32blit/types/rect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace blit {
inline Rect& operator*= (const float a) { x = static_cast<int32_t>(x * a); y = static_cast<int32_t>(y * a); w = static_cast<int32_t>(w * a); h = static_cast<int32_t>(h * a); return *this; }

Size size() const {
return Size(w, h);
return {w, h};
}

bool empty() const {
Expand All @@ -40,11 +40,11 @@ namespace blit {
}

Rect intersection(const Rect &r) const {
return Rect(
return {
std::max(x, r.x),
std::max(y, r.y),
std::min(x + w, r.x + r.w) - std::max(x, r.x),
std::min(y + h, r.y + r.h) - std::max(y, r.y));
std::min(y + h, r.y + r.h) - std::max(y, r.y)};
}

// TODO: hate this function name
Expand Down Expand Up @@ -97,29 +97,29 @@ namespace blit {
}

Point clamp(Point p) const {
return Point(
return {
p.x < x ? x : (p.x > x + w ? x + w : p.x),
p.y < y ? y : (p.y > y + h ? y + h : p.y));
p.y < y ? y : (p.y > y + h ? y + h : p.y)};
}

Point tl() const {
return Point(x, y);
return {x, y};
}

Point tr() const {
return Point(x + w, y);
return {x + w, y};
}

Point bl() const {
return Point(x, y + h);
return {x, y + h};
}

Point br() const {
return Point(x + w, y + h);
return {x + w, y + h};
}

Point center() const {
return Point(x + w/2, y + h/2);
return {x + w/2, y + h/2};
}

};
Expand Down
4 changes: 2 additions & 2 deletions 32blit/types/vec3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ namespace blit {

void Vec3::normalize() { float d = this->length(); x /= d; y /= d; z /= d; }
float Vec3::length() { return sqrtf(x * x + y * y + z * z); }
Vec3 Vec3::cross(const Vec3 &a) { return Vec3(y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x); }
Vec3 Vec3::cross(const Vec3 *a) { return Vec3(y * a->z - z * a->y, z * a->x - x * a->z, x * a->y - y * a->x); }
Vec3 Vec3::cross(const Vec3 &a) { return {y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x}; }
Vec3 Vec3::cross(const Vec3 *a) { return {y * a->z - z * a->y, z * a->x - x * a->z, x * a->y - y * a->x}; }
float Vec3::dot(const Vec3 &a) { return (x * a.x) + (y * a.y) + (z * a.z); }
float Vec3::dot(const Vec3 *a) { return (x * a->x) + (y * a->y) + (z * a->z); }

Expand Down
2 changes: 1 addition & 1 deletion 32blit/types/vec3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace blit {
};

inline Vec3 operator- (Vec3 lhs, const Vec3 &rhs) { lhs -= rhs; return lhs; }
inline Vec3 operator- (const Vec3 &rhs) { return Vec3(-rhs.x, -rhs.y, -rhs.z); }
inline Vec3 operator- (const Vec3 &rhs) { return {-rhs.x, -rhs.y, -rhs.z}; }
inline Vec3 operator+ (Vec3 lhs, const Vec3 &rhs) { lhs += rhs; return lhs; }
inline Vec3 operator* (Vec3 lhs, const float a) { lhs *= a; return lhs; }
inline Vec3 operator* (Vec3 lhs, const Mat4 &a) { lhs *= a; return lhs; }
Expand Down

0 comments on commit d7bd600

Please sign in to comment.