[Scummvm-git-logs] scummvm master -> 1e3b41d71baeb499d2773f6f78712c90dae299e0

sev- sev at scummvm.org
Tue Oct 6 16:16:12 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
1e3b41d71b Add division and multiplication operators to Common::Point


Commit: 1e3b41d71baeb499d2773f6f78712c90dae299e0
    https://github.com/scummvm/scummvm/commit/1e3b41d71baeb499d2773f6f78712c90dae299e0
Author: Vladimir Serbinenko (phcoder at google.com)
Date: 2020-10-06T18:16:08+02:00

Commit Message:
Add division and multiplication operators to Common::Point

They're convenient for performing computations and I use
them in Hades Challenge engine

Changed paths:
    common/rect.h


diff --git a/common/rect.h b/common/rect.h
index c6a066603e..f43aa69e40 100644
--- a/common/rect.h
+++ b/common/rect.h
@@ -53,6 +53,10 @@ struct Point {
 	bool  operator!=(const Point &p)    const { return x != p.x || y != p.y; }
 	Point operator+(const Point &delta) const { return Point(x + delta.x, y + delta.y); }
 	Point operator-(const Point &delta) const { return Point(x - delta.x, y - delta.y); }
+	Point operator/(int divisor) const { return Point(x / divisor, y / divisor); }
+	Point operator*(int multiplier) const { return Point(x * multiplier, y * multiplier); }
+	Point operator/(double divisor) const { return Point(x / divisor, y / divisor); }
+	Point operator*(double multiplier) const { return Point(x * multiplier, y * multiplier); }
 
 	void operator+=(const Point &delta) {
 		x += delta.x;
@@ -83,6 +87,9 @@ struct Point {
 	}
 };
 
+static inline Point operator*(int multiplier, const Point &p) { return Point(p.x * multiplier, p.y * multiplier); }
+static inline Point operator*(double multiplier, const Point &p) { return Point(p.x * multiplier, p.y * multiplier); }
+
 /**
  * Simple class for handling a rectangular zone.
  *




More information about the Scummvm-git-logs mailing list