[Scummvm-git-logs] scummvm master -> 7182be94dc9bf89a36bb0cfe8269d6f1fda268aa

OMGPizzaGuy noreply at scummvm.org
Sun Jun 9 21:45:52 UTC 2024


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:
7182be94dc ULTIMA8: Add more functions to Point3


Commit: 7182be94dc9bf89a36bb0cfe8269d6f1fda268aa
    https://github.com/scummvm/scummvm/commit/7182be94dc9bf89a36bb0cfe8269d6f1fda268aa
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2024-06-09T16:45:26-05:00

Commit Message:
ULTIMA8: Add more functions to Point3

Changed paths:
    engines/ultima/ultima8/misc/point3.h
    engines/ultima/ultima8/world/actors/pathfinder.cpp
    engines/ultima/ultima8/world/super_sprite_process.cpp


diff --git a/engines/ultima/ultima8/misc/point3.h b/engines/ultima/ultima8/misc/point3.h
index a2d513e08ac..4651dd901cd 100644
--- a/engines/ultima/ultima8/misc/point3.h
+++ b/engines/ultima/ultima8/misc/point3.h
@@ -38,6 +38,21 @@ struct Point3 {
 		return (x == p.x && y == p.y && z == p.z);
 	}
 
+	Point3 operator+(const Point3 &delta) const { return Point3(x + delta.x, y + delta.y, z + delta.z); }
+	Point3 operator-(const Point3 &delta) const { return Point3(x - delta.x, y - delta.y, z - delta.z); }
+
+	void operator+=(const Point3 &delta) {
+		x += delta.x;
+		y += delta.y;
+		z += delta.z;
+	}
+
+	void operator-=(const Point3 &delta) {
+		x -= delta.x;
+		y -= delta.y;
+		z -= delta.z;
+	}
+
 	int maxDistXYZ(const Point3 &other) const {
 		int xdiff = abs(x - other.x);
 		int ydiff = abs(y - other.y);
@@ -45,13 +60,20 @@ struct Point3 {
 		return MAX(xdiff, MAX(ydiff, zdiff));
 	}
 
+	uint32 sqrDist(const Point3 &other) const {
+		int xdiff = abs(x - other.x);
+		int ydiff = abs(y - other.y);
+		int zdiff = abs(z - other.z);
+		return uint32(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
+	}
+
 	void set(int32 nx, int32 ny, int32 nz) {
 		x = nx;
 		y = ny;
 		z = nz;
 	}
 
-	void move(int32 dx, int32 dy, int32 dz) {
+	void translate(int32 dx, int32 dy, int32 dz) {
 		x += dx;
 		y += dy;
 		z += dz;
diff --git a/engines/ultima/ultima8/world/actors/pathfinder.cpp b/engines/ultima/ultima8/world/actors/pathfinder.cpp
index d7810ce9916..5896850115f 100644
--- a/engines/ultima/ultima8/world/actors/pathfinder.cpp
+++ b/engines/ultima/ultima8/world/actors/pathfinder.cpp
@@ -61,7 +61,7 @@ void PathfindingState::load(const Actor *_actor) {
 
 bool PathfindingState::checkPoint(const Point3 &pt,
 								  int sqr_range) const {
-	int distance = (_point.x - pt.x) * (_point.x - pt.x) + (_point.y - pt.y) * (_point.y - pt.y) + (_point.z - pt.z) * (_point.z - pt.z);
+	int distance = _point.sqrDist(pt);
 	return distance < sqr_range;
 }
 
diff --git a/engines/ultima/ultima8/world/super_sprite_process.cpp b/engines/ultima/ultima8/world/super_sprite_process.cpp
index 3569dadf061..0a29de344ae 100644
--- a/engines/ultima/ultima8/world/super_sprite_process.cpp
+++ b/engines/ultima/ultima8/world/super_sprite_process.cpp
@@ -111,7 +111,7 @@ SuperSpriteProcess::SuperSpriteProcess(int shape, int frame, int sx, int sy, int
 			rng = 0x18;
 		int zoff = rs.getRandomNumberRngSigned(-rng, rng);
 
-		_destpt.move(xoff, yoff, zoff);
+		_destpt.translate(xoff, yoff, zoff);
 		if (_destpt.z > 0xfa)
 			_destpt.z = 0xfa;
 		else if (_destpt.z < 0)




More information about the Scummvm-git-logs mailing list