[Scummvm-git-logs] scummvm master -> 001dad733fb31b6c3f8b4ad953cc6a4128bd0024

scemino noreply at scummvm.org
Sun Mar 24 21:49:30 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:
001dad733f TWP: Use const when necessary


Commit: 001dad733fb31b6c3f8b4ad953cc6a4128bd0024
    https://github.com/scummvm/scummvm/commit/001dad733fb31b6c3f8b4ad953cc6a4128bd0024
Author: scemino (scemino74 at gmail.com)
Date: 2024-03-24T22:49:08+01:00

Commit Message:
TWP: Use const when necessary

Changed paths:
    engines/twp/actorswitcher.cpp
    engines/twp/actorswitcher.h
    engines/twp/camera.cpp
    engines/twp/camera.h
    engines/twp/dialog.cpp
    engines/twp/dialog.h
    engines/twp/font.cpp
    engines/twp/font.h
    engines/twp/gfx.cpp
    engines/twp/gfx.h
    engines/twp/graph.cpp
    engines/twp/graph.h
    engines/twp/hud.cpp
    engines/twp/hud.h
    engines/twp/motor.cpp
    engines/twp/motor.h
    engines/twp/object.cpp
    engines/twp/object.h
    engines/twp/rectf.cpp
    engines/twp/rectf.h
    engines/twp/room.cpp
    engines/twp/room.h
    engines/twp/scenegraph.cpp
    engines/twp/scenegraph.h
    engines/twp/twp.cpp
    engines/twp/twp.h
    engines/twp/util.cpp
    engines/twp/util.h
    engines/twp/walkboxnode.cpp
    engines/twp/walkboxnode.h


diff --git a/engines/twp/actorswitcher.cpp b/engines/twp/actorswitcher.cpp
index 1d142e6db71..420ac66d93f 100644
--- a/engines/twp/actorswitcher.cpp
+++ b/engines/twp/actorswitcher.cpp
@@ -33,7 +33,7 @@
 
 namespace Twp {
 
-ActorSwitcherSlot::ActorSwitcherSlot(const Common::String &icon_, Color back_, Color frame_, SelectFunc *selectFunc_, int id_) {
+ActorSwitcherSlot::ActorSwitcherSlot(const Common::String &icon_, const Color &back_, const Color &frame_, SelectFunc *selectFunc_, int id_) {
 	icon = icon_;
 	back = back_;
 	frame = frame_;
@@ -51,7 +51,8 @@ ActorSwitcher::ActorSwitcher() : Node("ActorSwitcher") {
 	_alpha = ENABLE_ALPHA;
 }
 
-Math::Matrix4 ActorSwitcher::transform(Math::Matrix4 trsf, int index) {
+Math::Matrix4 ActorSwitcher::transform(const Math::Matrix4 &t, int index) {
+	Math::Matrix4 trsf(t);
 	float animPos = _mouseOver ? _animPos : 1.f;
 	Math::Vector3d pos(SCREEN_WIDTH - MARGIN, SCREEN_HEIGHT - MARGIN - animPos * ACTOR_SEP * index, 0.f);
 	Math::Vector2d s(2.f, 2.f);
@@ -70,7 +71,7 @@ float ActorSwitcher::getAlpha(size_t index) const {
 	return _mouseOver ? INACTIVE_ALPHA : DISABLE_ALPHA;
 }
 
-void ActorSwitcher::drawIcon(const Common::String &icon, Color backColor, Color frameColor, Math::Matrix4 trsf, int index) {
+void ActorSwitcher::drawIcon(const Common::String &icon, const Color &backColor, const Color &frameColor, const Math::Matrix4 &trsf, int index) {
 	SpriteSheet *gameSheet = g_twp->_resManager->spriteSheet("GameSheet");
 	Texture *texture = g_twp->_resManager->texture(gameSheet->meta.image);
 	const SpriteSheetFrame &iconBackFrame = gameSheet->getFrame("icon_background");
@@ -84,7 +85,7 @@ void ActorSwitcher::drawIcon(const Common::String &icon, Color backColor, Color
 	drawSprite(iconFrame, texture, Color::withAlpha(frameColor, alpha), t);
 }
 
-void ActorSwitcher::drawCore(Math::Matrix4 trsf) {
+void ActorSwitcher::drawCore(const Math::Matrix4 &trsf) {
 	if (_mouseOver) {
 		for (size_t i = 0; i < _slots.size(); i++) {
 			ActorSwitcherSlot &slot = _slots[i];
@@ -96,10 +97,11 @@ void ActorSwitcher::drawCore(Math::Matrix4 trsf) {
 	}
 }
 
-void ActorSwitcher::drawSprite(const SpriteSheetFrame &sf, Texture *texture, Color color, Math::Matrix4 trsf) {
+void ActorSwitcher::drawSprite(const SpriteSheetFrame &sf, Texture *texture, const Color &color, const Math::Matrix4 &trsf) {
+	Math::Matrix4 t(trsf);
 	Math::Vector3d pos(sf.spriteSourceSize.left - sf.sourceSize.getX() / 2.f, -sf.spriteSourceSize.height() - sf.spriteSourceSize.top + sf.sourceSize.getY() / 2.f, 0.f);
-	trsf.translate(pos);
-	g_twp->getGfx().drawSprite(sf.frame, *texture, color, trsf);
+	t.translate(pos);
+	g_twp->getGfx().drawSprite(sf.frame, *texture, color, t);
 }
 
 float ActorSwitcher::height() const {
@@ -107,7 +109,7 @@ float ActorSwitcher::height() const {
 	return n * ACTOR_SEP;
 }
 
-int ActorSwitcher::iconIndex(Math::Vector2d pos) const {
+int ActorSwitcher::iconIndex(const Math::Vector2d &pos) const {
 	float y = SCREEN_HEIGHT - pos.getY();
 	return _slots.size() - 1 - (int)((height() - y) / ACTOR_SEP);
 }
diff --git a/engines/twp/actorswitcher.h b/engines/twp/actorswitcher.h
index cf5f28cd1c4..de8aa622992 100644
--- a/engines/twp/actorswitcher.h
+++ b/engines/twp/actorswitcher.h
@@ -35,7 +35,7 @@ typedef void SelectFunc(int id);
 
 // This is where all the information about the actor icon stands
 struct ActorSwitcherSlot {
-	ActorSwitcherSlot(const Common::String &icon_, Color back_, Color frame_, SelectFunc *selectFunc_, int id_ = 0);
+	ActorSwitcherSlot(const Common::String &icon_, const Color &back_, const Color &frame_, SelectFunc *selectFunc_, int id_ = 0);
 
 	void select();
 
@@ -55,13 +55,13 @@ public:
 	void setFlash(int flash) { _flash = flash; }
 
 protected:
-	void drawCore(Math::Matrix4 trsf) override final;
-	void drawSprite(const SpriteSheetFrame &sf, Texture *texture, Color color, Math::Matrix4 trsf);
-	void drawIcon(const Common::String &icon, Color backColor, Color frameColor, Math::Matrix4 trsf, int index);
-	Math::Matrix4 transform(Math::Matrix4 trsf, int index);
+	void drawCore(const Math::Matrix4 &trsf) override final;
+	void drawSprite(const SpriteSheetFrame &sf, Texture *texture, const Color &color, const Math::Matrix4 &trsf);
+	void drawIcon(const Common::String &icon, const Color &backColor, const Color &frameColor, const Math::Matrix4 &trsf, int index);
+	Math::Matrix4 transform(const Math::Matrix4 &trsf, int index);
 	float getAlpha(size_t index) const;
 	float height() const;
-	int iconIndex(Math::Vector2d pos) const;
+	int iconIndex(const Math::Vector2d &pos) const;
 	Common::Rect rect() const;
 
 public:
diff --git a/engines/twp/camera.cpp b/engines/twp/camera.cpp
index d2dc1aa7c32..0bbd5e24d94 100644
--- a/engines/twp/camera.cpp
+++ b/engines/twp/camera.cpp
@@ -25,12 +25,12 @@
 
 namespace Twp {
 
-void Camera::clamp(Math::Vector2d at) {
+void Camera::clamp(const Math::Vector2d &at) {
 	if (_room) {
 		Math::Vector2d roomSize = _room->_roomSize;
 		Math::Vector2d screenSize = _room->getScreenSize();
 		// fix assertion when screen size is greater than room height
-		if(screenSize.getY() > roomSize.getY()) {
+		if (screenSize.getY() > roomSize.getY()) {
 			screenSize.setY(roomSize.getY());
 		}
 
@@ -41,21 +41,21 @@ void Camera::clamp(Math::Vector2d at) {
 	}
 }
 
-void Camera::setAtCore(Math::Vector2d at) {
+void Camera::setAtCore(const Math::Vector2d &at) {
 	Math::Vector2d screenSize = _room->getScreenSize();
 	_pos = at;
 	clamp(_pos);
 	g_twp->getGfx().cameraPos(_pos - screenSize / 2.f);
 }
 
-void Camera::setAt(Math::Vector2d at) {
+void Camera::setAt(const Math::Vector2d &at) {
 	setAtCore(at);
 	_target = _pos;
 	_time = 0;
 	_moving = false;
 }
 
-void Camera::panTo(Math::Vector2d target, float time, InterpolationKind interpolation) {
+void Camera::panTo(const Math::Vector2d &target, float time, InterpolationKind interpolation) {
 	if (!_moving) {
 		_moving = true;
 		_init = _pos;
diff --git a/engines/twp/camera.h b/engines/twp/camera.h
index bb80bd44053..b38e60e9a31 100644
--- a/engines/twp/camera.h
+++ b/engines/twp/camera.h
@@ -93,7 +93,7 @@ inline EasingFunc_t easing(InterpolationKind kind) {
 
 class Camera {
 public:
-	void setAt(Math::Vector2d at);
+	void setAt(const Math::Vector2d &at);
 	inline Math::Vector2d getAt() const { return _pos; }
 
 	inline void setBounds(const Rectf &bounds) { _bounds = bounds; }
@@ -103,13 +103,13 @@ public:
 	inline Common::SharedPtr<Room> getRoom() const { return _room; }
 
 	inline bool isMoving() const { return _moving; }
-	void panTo(Math::Vector2d target, float time, InterpolationKind interpolation);
+	void panTo(const Math::Vector2d &target, float time, InterpolationKind interpolation);
 
 	void update(Common::SharedPtr<Room> room, Common::SharedPtr<Object> follow, float elapsed);
 
 private:
-	void clamp(Math::Vector2d at);
-	void setAtCore(Math::Vector2d at);
+	void clamp(const Math::Vector2d &at);
+	void setAtCore(const Math::Vector2d &at);
 
 private:
 	Math::Vector2d _pos;
diff --git a/engines/twp/dialog.cpp b/engines/twp/dialog.cpp
index 913df715a88..44d616fd83e 100644
--- a/engines/twp/dialog.cpp
+++ b/engines/twp/dialog.cpp
@@ -245,7 +245,7 @@ void Dialog::update(float dt) {
 		for (size_t i = 0; i < MAXDIALOGSLOTS; i++) {
 			DialogSlot *slot = &_slots[i];
 			if (slot->_isValid) {
-				Rectf rect = Rectf::fromPosAndSize(slot->getPos() - Math::Vector2d(0.f, -slot->_text.getBounds().getY()/2.f), slot->_text.getBounds());
+				Rectf rect = Rectf::fromPosAndSize(slot->getPos() - Math::Vector2d(0.f, -slot->_text.getBounds().getY() / 2.f), slot->_text.getBounds());
 				bool over = rect.contains(_mousePos);
 				if (rect.r.w > (SCREEN_WIDTH - SLOTMARGIN)) {
 					if (over) {
@@ -462,7 +462,7 @@ void Dialog::clearSlots() {
 	}
 }
 
-void Dialog::drawCore(Math::Matrix4 trsf) {
+void Dialog::drawCore(const Math::Matrix4 &trsf) {
 	for (auto &_slot : _slots) {
 		DialogSlot *slot = &_slot;
 		if (slot->_isValid) {
diff --git a/engines/twp/dialog.h b/engines/twp/dialog.h
index f8dbe6b0542..c73068f268a 100644
--- a/engines/twp/dialog.h
+++ b/engines/twp/dialog.h
@@ -182,7 +182,7 @@ public:
 	void update(float dt);
 	DialogState getState() const { return _state; }
 
-	void setMousePos(Math::Vector2d pos) { _mousePos = pos; }
+	void setMousePos(const Math::Vector2d& pos) { _mousePos = pos; }
 
 	void start(const Common::String &actor, const Common::String &name, const Common::String &node);
 	void selectLabel(int line, const Common::String &name);
@@ -206,7 +206,7 @@ private:
 	int numSlots() const;
 	void clearSlots();
 
-	virtual void drawCore(Math::Matrix4 trsf) override final;
+	virtual void drawCore(const Math::Matrix4 &trsf) override final;
 
 public:
 	Common::Array<DialogConditionState> _states;
diff --git a/engines/twp/font.cpp b/engines/twp/font.cpp
index 75c717761be..41f37e4dcc7 100644
--- a/engines/twp/font.cpp
+++ b/engines/twp/font.cpp
@@ -244,7 +244,7 @@ bool operator==(const KerningKey &l, const KerningKey &r) {
 	return l.first == r.first && l.second == r.second;
 }
 
-Text::Text(const Common::String &fontName, const Common::String &text, TextHAlignment hAlign, TextVAlignment vAlign, float maxWidth, Color color)
+Text::Text(const Common::String &fontName, const Common::String &text, TextHAlignment hAlign, TextVAlignment vAlign, float maxWidth, const Color &color)
 	: _font(NULL), _fontName(fontName), _texture(NULL), _txt(text), _col(color), _hAlign(hAlign), _vAlign(vAlign), _maxW(maxWidth), _dirty(true) {
 	update();
 }
@@ -361,15 +361,16 @@ void Text::update() {
 	}
 }
 
-void Text::draw(Gfx &gfx, Math::Matrix4 trsf) {
-	switch(_vAlign) {
-		case tvTop:
+void Text::draw(Gfx &gfx, const Math::Matrix4 &t) {
+	Math::Matrix4 trsf(t);
+	switch (_vAlign) {
+	case tvTop:
 		trsf.translate(Math::Vector3d(0.f, 0.f, 0.f));
 		break;
-		case tvCenter:
-		trsf.translate(Math::Vector3d(0.f, _bnds.getY()/2.f, 0.f));
+	case tvCenter:
+		trsf.translate(Math::Vector3d(0.f, _bnds.getY() / 2.f, 0.f));
 		break;
-		case tvBottom:
+	case tvBottom:
 		trsf.translate(Math::Vector3d(0.f, _bnds.getY(), 0.f));
 		break;
 	}
diff --git a/engines/twp/font.h b/engines/twp/font.h
index 55f499e9a41..3a2fc79018e 100644
--- a/engines/twp/font.h
+++ b/engines/twp/font.h
@@ -144,7 +144,7 @@ enum TextVAlignment {
 class Text {
 public:
 	Text();
-	Text(const Common::String &fontName, const Common::String &text, TextHAlignment hAlign = thCenter, TextVAlignment vAlign = tvCenter, float maxWidth = 0.0f, Color color = Color());
+	Text(const Common::String &fontName, const Common::String &text, TextHAlignment hAlign = thCenter, TextVAlignment vAlign = tvCenter, float maxWidth = 0.0f, const Color& color = Color());
 
 	void setText(const Common::String &text) {
 		_txt = text;
@@ -152,7 +152,7 @@ public:
 	}
 	Common::String getText() const { return _txt; }
 
-	void setColor(Color c) {
+	void setColor(const Color& c) {
 		_col = c;
 		_dirty = true;
 	}
@@ -180,7 +180,7 @@ public:
 	Common::SharedPtr<Font> getFont() { return _font; }
 	Math::Vector2d getBounds();
 
-	void draw(Gfx &gfx, Math::Matrix4 trsf = Math::Matrix4());
+	void draw(Gfx &gfx, const Math::Matrix4& trsf = Math::Matrix4());
 
 private:
 	void update();
diff --git a/engines/twp/gfx.cpp b/engines/twp/gfx.cpp
index 268fc002dad..25fcd480da9 100644
--- a/engines/twp/gfx.cpp
+++ b/engines/twp/gfx.cpp
@@ -36,7 +36,7 @@ int Color::toInt() const {
 
 Vertex::Vertex() {}
 
-Vertex::Vertex(Math::Vector2d p, Color c, Math::Vector2d t)
+Vertex::Vertex(const Math::Vector2d &p, const Color &c, const Math::Vector2d &t)
 	: pos(p), color(c), texCoords(t) {
 }
 
@@ -101,7 +101,7 @@ void Texture::capture(Common::Array<byte> &data) {
 	}
 }
 
-RenderTexture::RenderTexture(Math::Vector2d size) {
+RenderTexture::RenderTexture(const Math::Vector2d &size) {
 	width = size.getX();
 	height = size.getY();
 
@@ -217,12 +217,12 @@ void Gfx::init() {
 	glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFbo);
 }
 
-void Gfx::clear(Color color) {
+void Gfx::clear(const Color &color) {
 	glClearColor(color.rgba.r, color.rgba.g, color.rgba.b, color.rgba.a);
 	glClear(GL_COLOR_BUFFER_BIT);
 }
 
-Math::Matrix4 Gfx::getFinalTransform(Math::Matrix4 trsf) {
+Math::Matrix4 Gfx::getFinalTransform(const Math::Matrix4 &trsf) {
 	Math::Matrix4 t(trsf);
 	t.transpose();
 	return t * _mvp;
@@ -233,17 +233,17 @@ void Gfx::noTexture() {
 	GL_CALL(glBindTexture(GL_TEXTURE_2D, _emptyTexture.id));
 }
 
-void Gfx::drawLines(Vertex *vertices, int count, Math::Matrix4 trsf) {
+void Gfx::drawLines(Vertex *vertices, int count, const Math::Matrix4 &trsf) {
 	noTexture();
 	drawPrimitives(GL_LINE_STRIP, vertices, count, trsf);
 }
 
-void Gfx::drawLinesLoop(Vertex *vertices, int count, Math::Matrix4 trsf) {
+void Gfx::drawLinesLoop(Vertex *vertices, int count, const Math::Matrix4 &trsf) {
 	noTexture();
 	drawPrimitives(GL_LINE_LOOP, vertices, count, trsf);
 }
 
-void Gfx::drawPrimitives(uint32 primitivesType, Vertex *vertices, int v_size, Math::Matrix4 trsf, Texture *texture) {
+void Gfx::drawPrimitives(uint32 primitivesType, Vertex *vertices, int v_size, const Math::Matrix4 &trsf, Texture *texture) {
 	if (v_size > 0) {
 		_texture = texture ? texture : &_emptyTexture;
 		GL_CALL(glBindTexture(GL_TEXTURE_2D, _texture->id));
@@ -276,7 +276,7 @@ void Gfx::drawPrimitives(uint32 primitivesType, Vertex *vertices, int v_size, Ma
 	}
 }
 
-void Gfx::drawPrimitives(uint32 primitivesType, Vertex *vertices, int v_size, uint32 *indices, int i_size, Math::Matrix4 trsf, Texture *texture) {
+void Gfx::drawPrimitives(uint32 primitivesType, Vertex *vertices, int v_size, uint32 *indices, int i_size, const Math::Matrix4 &trsf, Texture *texture) {
 	if (i_size > 0) {
 		int num = _shader->getNumTextures();
 		if (num == 0) {
@@ -322,11 +322,11 @@ void Gfx::drawPrimitives(uint32 primitivesType, Vertex *vertices, int v_size, ui
 	}
 }
 
-void Gfx::draw(Vertex *vertices, int v_size, uint32 *indices, int i_size, Math::Matrix4 trsf, Texture *texture) {
+void Gfx::draw(Vertex *vertices, int v_size, uint32 *indices, int i_size, const Math::Matrix4 &trsf, Texture *texture) {
 	drawPrimitives(GL_TRIANGLES, vertices, v_size, indices, i_size, trsf, texture);
 }
 
-void Gfx::drawQuad(Math::Vector2d size, Color color, Math::Matrix4 trsf) {
+void Gfx::drawQuad(const Math::Vector2d &size, const Color &color, const Math::Matrix4 &trsf) {
 	float w = size.getX();
 	float h = size.getY();
 	float x = 0;
@@ -343,7 +343,7 @@ void Gfx::drawQuad(Math::Vector2d size, Color color, Math::Matrix4 trsf) {
 	draw(vertices, 4, quadIndices, 6, trsf);
 }
 
-void Gfx::drawSprite(Common::Rect textRect, Texture &texture, Color color, Math::Matrix4 trsf, bool flipX, bool flipY) {
+void Gfx::drawSprite(const Common::Rect &textRect, Texture &texture, const Color &color, const Math::Matrix4 &trsf, bool flipX, bool flipY) {
 	float l = textRect.left / (float)texture.width;
 	float r = textRect.right / (float)texture.width;
 	float t = textRect.top / (float)texture.height;
@@ -365,11 +365,11 @@ void Gfx::drawSprite(Common::Rect textRect, Texture &texture, Color color, Math:
 	draw(vertices, 4, quadIndices, 6, trsf, &texture);
 }
 
-void Gfx::drawSprite(Texture &texture, Color color, Math::Matrix4 trsf, bool flipX, bool flipY) {
+void Gfx::drawSprite(Texture &texture, const Color &color, const Math::Matrix4 &trsf, bool flipX, bool flipY) {
 	drawSprite(Common::Rect(texture.width, texture.height), texture, color, trsf, flipX, flipY);
 }
 
-void Gfx::camera(Math::Vector2d size) {
+void Gfx::camera(const Math::Vector2d &size) {
 	_cameraSize = size;
 	_mvp = ortho(0.f, size.getX(), 0.f, size.getY(), -1.f, 1.f);
 }
diff --git a/engines/twp/gfx.h b/engines/twp/gfx.h
index f9a077aac99..a1e75035869 100644
--- a/engines/twp/gfx.h
+++ b/engines/twp/gfx.h
@@ -50,7 +50,7 @@ struct Color {
 		rgba.a = alpha;
 	}
 
-	static Color withAlpha(Color c, float alpha = 1.0f) {
+	static Color withAlpha(const Color &c, float alpha = 1.0f) {
 		Color result = c;
 		result.rgba.a = alpha;
 		return result;
@@ -95,7 +95,7 @@ public:
 	Math::Vector2d texCoords;
 
 	Vertex();
-	Vertex(Math::Vector2d p, Color c = Color(), Math::Vector2d t = Math::Vector2d());
+	Vertex(const Math::Vector2d &p, const Color &c = Color(), const Math::Vector2d &t = Math::Vector2d());
 };
 
 class Texture {
@@ -115,7 +115,7 @@ public:
 
 class RenderTexture : public Texture {
 public:
-	explicit RenderTexture(Math::Vector2d size);
+	explicit RenderTexture(const Math::Vector2d &size);
 	~RenderTexture() override;
 };
 
@@ -165,27 +165,27 @@ public:
 public:
 	void init();
 
-	void camera(Math::Vector2d size);
+	void camera(const Math::Vector2d &size);
 	Math::Vector2d camera() const;
 	Math::Vector2d cameraPos() const { return _cameraPos; }
-	void cameraPos(Math::Vector2d pos) { _cameraPos = pos; }
+	void cameraPos(const Math::Vector2d &pos) { _cameraPos = pos; }
 
 	Shader *getShader() { return _shader; }
 	void use(Shader *shader);
 	void setRenderTarget(RenderTexture *target);
 
-	void clear(Color color);
-	void drawPrimitives(uint32 primitivesType, Vertex *vertices, int v_size, Math::Matrix4 transf = Math::Matrix4(), Texture *texture = NULL);
-	void drawPrimitives(uint32 primitivesType, Vertex *vertices, int v_size, uint32 *indices, int i_size, Math::Matrix4 transf = Math::Matrix4(), Texture *texture = NULL);
-	void drawLines(Vertex *vertices, int count, Math::Matrix4 trsf = Math::Matrix4());
-	void drawLinesLoop(Vertex *vertices, int count, Math::Matrix4 trsf = Math::Matrix4());
-	void draw(Vertex *vertices, int v_size, uint32 *indices, int i_size, Math::Matrix4 trsf = Math::Matrix4(), Texture *texture = NULL);
-	void drawQuad(Math::Vector2d size, Color color = Color(), Math::Matrix4 trsf = Math::Matrix4());
-	void drawSprite(Common::Rect textRect, Texture &texture, Color color = Color(), Math::Matrix4 trsf = Math::Matrix4(), bool flipX = false, bool flipY = false);
-	void drawSprite(Texture &texture, Color color = Color(), Math::Matrix4 trsf = Math::Matrix4(), bool flipX = false, bool flipY = false);
+	void clear(const Color &color);
+	void drawPrimitives(uint32 primitivesType, Vertex *vertices, int v_size, const Math::Matrix4 &transf = Math::Matrix4(), Texture *texture = NULL);
+	void drawPrimitives(uint32 primitivesType, Vertex *vertices, int v_size, uint32 *indices, int i_size, const Math::Matrix4 &transf = Math::Matrix4(), Texture *texture = NULL);
+	void drawLines(Vertex *vertices, int count, const Math::Matrix4 &trsf = Math::Matrix4());
+	void drawLinesLoop(Vertex *vertices, int count, const Math::Matrix4 &trsf = Math::Matrix4());
+	void draw(Vertex *vertices, int v_size, uint32 *indices, int i_size, const Math::Matrix4 &trsf = Math::Matrix4(), Texture *texture = NULL);
+	void drawQuad(const Math::Vector2d& size, const Color& color = Color(), const Math::Matrix4 &trsf = Math::Matrix4());
+	void drawSprite(const Common::Rect &textRect, Texture &texture, const Color &color = Color(), const Math::Matrix4 &trsf = Math::Matrix4(), bool flipX = false, bool flipY = false);
+	void drawSprite(Texture &texture, const Color &color = Color(), const Math::Matrix4 &trsf = Math::Matrix4(), bool flipX = false, bool flipY = false);
 
 private:
-	Math::Matrix4 getFinalTransform(Math::Matrix4 trsf);
+	Math::Matrix4 getFinalTransform(const Math::Matrix4 &trsf);
 	void noTexture();
 
 private:
diff --git a/engines/twp/graph.cpp b/engines/twp/graph.cpp
index 522556471fa..8e4b7a4ebfd 100644
--- a/engines/twp/graph.cpp
+++ b/engines/twp/graph.cpp
@@ -76,7 +76,7 @@ GraphEdge::GraphEdge(int s, int t, float c)
 	: start(s), to(t), cost(c) {
 }
 
-void Graph::addNode(Math::Vector2d node) {
+void Graph::addNode(const Math::Vector2d &node) {
 	_nodes.push_back(node);
 	_edges.push_back(Common::Array<GraphEdge>());
 }
@@ -113,7 +113,7 @@ void AStar::search(int source, int target) {
 	}
 }
 
-void Graph::addEdge(GraphEdge e) {
+void Graph::addEdge(const GraphEdge &e) {
 	if (!edge(e.start, e.to)) {
 		_edges[e.start].push_back(e);
 	}
@@ -154,7 +154,7 @@ void PathFinder::setWalkboxes(const Common::Array<Walkbox> &walkboxes) {
 	_graph = nullptr;
 }
 
-Math::Vector2d Walkbox::getClosestPointOnEdge(Math::Vector2d p) const {
+Math::Vector2d Walkbox::getClosestPointOnEdge(const Math::Vector2d &p) const {
 	int vi1 = -1;
 	int vi2 = -1;
 	float minDist = 100000.0f;
@@ -191,7 +191,7 @@ Math::Vector2d Walkbox::getClosestPointOnEdge(Math::Vector2d p) const {
 	return Math::Vector2d(xu, yu);
 }
 
-bool PathFinder::inLineOfSight(Math::Vector2d start, Math::Vector2d to) {
+bool PathFinder::inLineOfSight(const Math::Vector2d &start, const Math::Vector2d &to) {
 	const float epsilon = 0.5f;
 
 	// Not in LOS if any of the ends is outside the polygon
@@ -261,7 +261,9 @@ Common::SharedPtr<Graph> PathFinder::createGraph() {
 	return result;
 }
 
-Common::Array<Math::Vector2d> PathFinder::calculatePath(Math::Vector2d start, Math::Vector2d to) {
+Common::Array<Math::Vector2d> PathFinder::calculatePath(const Math::Vector2d &s, const Math::Vector2d &t) {
+	Math::Vector2d start(s);
+	Math::Vector2d to(t);
 	Common::Array<Math::Vector2d> result;
 	if (!_walkboxes.empty()) {
 		// find the walkbox where the actor is and put it first
diff --git a/engines/twp/graph.h b/engines/twp/graph.h
index a07c10c275f..117a58ef063 100644
--- a/engines/twp/graph.h
+++ b/engines/twp/graph.h
@@ -63,8 +63,8 @@ struct GraphEdge {
 class Graph {
 public:
 	Graph();
-	void addNode(Math::Vector2d node);
-	void addEdge(GraphEdge edge);
+	void addNode(const Math::Vector2d &node);
+	void addEdge(const GraphEdge &edge);
 	// Gets the edge from 'from' index to 'to' index.
 	GraphEdge *edge(int start, int to);
 	Common::Array<int> getPath(int source, int target);
@@ -92,12 +92,12 @@ public:
 	Walkbox(const Common::Array<Vector2i> &polygon, bool visible = true);
 
 	// Indicates whether or not the specified position is inside this walkbox.
-	bool contains(Math::Vector2d position, bool toleranceOnOutside = true) const;
+	bool contains(const Math::Vector2d &position, bool toleranceOnOutside = true) const;
 	bool concave(int vertex) const;
 	void setVisible(bool visible) { _visible = visible; }
 	bool isVisible() const { return _visible; }
 	const Common::Array<Vector2i> &getPoints() const { return _polygon; }
-	Math::Vector2d getClosestPointOnEdge(Math::Vector2d p) const;
+	Math::Vector2d getClosestPointOnEdge(const Math::Vector2d &p) const;
 
 public:
 	Common::String _name;
@@ -112,14 +112,14 @@ class PathFinder {
 public:
 	void setWalkboxes(const Common::Array<Walkbox> &walkboxes);
 	Common::Array<Walkbox> getWalkboxes() const { return _walkboxes; }
-	Common::Array<Math::Vector2d> calculatePath(Math::Vector2d start, Math::Vector2d to);
+	Common::Array<Math::Vector2d> calculatePath(const Math::Vector2d &start, const Math::Vector2d &to);
 	void setDirty(bool dirty) { _isDirty = dirty; }
 	bool isDirty() const { return _isDirty; }
 	const Graph &getGraph() const { return _walkgraph; }
 
 private:
 	Common::SharedPtr<Graph> createGraph();
-	bool inLineOfSight(Math::Vector2d start, Math::Vector2d to);
+	bool inLineOfSight(const Math::Vector2d &start, const Math::Vector2d &to);
 
 private:
 	Common::Array<Walkbox> _walkboxes;
diff --git a/engines/twp/hud.cpp b/engines/twp/hud.cpp
index 4bc557931ae..c1e89ba7410 100644
--- a/engines/twp/hud.cpp
+++ b/engines/twp/hud.cpp
@@ -34,7 +34,7 @@ Verb::Verb(VerbId verbId, const Common::String &img, const Common::String &f, co
 
 VerbUiColors::VerbUiColors() = default;
 
-VerbUiColors::VerbUiColors(Color s, Color vbNormal, Color vbNormalTint, Color vbHiglight, Color vbHiglightTint, Color dlgNormal, Color dlgHighlt, Color invFrame, Color inventoryBack, Color retroNml, Color retroHighlt)
+VerbUiColors::VerbUiColors(const Color &s, const Color &vbNormal, const Color &vbNormalTint, const Color &vbHiglight, const Color &vbHiglightTint, const Color &dlgNormal, const Color &dlgHighlt, const Color &invFrame, const Color &inventoryBack, const Color &retroNml, const Color &retroHighlt)
 	: sentence(s), verbNormal(vbNormal), verbNormalTint(vbNormalTint), verbHighlight(vbHiglight), verbHighlightTint(vbHiglightTint), dialogNormal(dlgNormal), dialogHighlight(dlgHighlt), inventoryFrame(invFrame), inventoryBackground(inventoryBack), retroNormal(retroNml), retroHighlight(retroHighlt) {
 }
 
@@ -129,13 +129,14 @@ ActorSlot *Hud::actorSlot(Common::SharedPtr<Object> actor) {
 	return nullptr;
 }
 
-void Hud::drawSprite(const SpriteSheetFrame &sf, Texture *texture, Color color, Math::Matrix4 trsf) {
+void Hud::drawSprite(const SpriteSheetFrame &sf, Texture *texture, const Color &color, const Math::Matrix4 &t) {
+	Math::Matrix4 trsf(t);
 	Math::Vector3d pos(sf.spriteSourceSize.left, -sf.spriteSourceSize.height() - sf.spriteSourceSize.top + sf.sourceSize.getY(), 0.f);
 	trsf.translate(pos);
 	g_twp->getGfx().drawSprite(sf.frame, *texture, color, trsf);
 }
 
-void Hud::drawCore(Math::Matrix4 trsf) {
+void Hud::drawCore(const Math::Matrix4 &trsf) {
 	ActorSlot *slot = actorSlot(_actor);
 	if (!slot)
 		return;
@@ -183,8 +184,8 @@ void Hud::drawCore(Math::Matrix4 trsf) {
 	_over = isOver;
 }
 
-void Hud::update(float elapsed, Math::Vector2d pos, Common::SharedPtr<Object> hotspot, bool mouseClick) {
-	if(_active) {
+void Hud::update(float elapsed, const Math::Vector2d &pos, Common::SharedPtr<Object> hotspot, bool mouseClick) {
+	if (_active) {
 		_mousePos = Math::Vector2d(pos.getX(), SCREEN_HEIGHT - pos.getY());
 		_defaultVerbId = !hotspot ? 0 : hotspot->defaultVerbId();
 		_mouseClick = mouseClick;
diff --git a/engines/twp/hud.h b/engines/twp/hud.h
index 4fd372bd8db..2a4db7a7402 100644
--- a/engines/twp/hud.h
+++ b/engines/twp/hud.h
@@ -45,7 +45,7 @@ struct VerbUiColors {
 	Color retroHighlight;
 
 	VerbUiColors();
-	VerbUiColors(Color s, Color vbNormal, Color vbNormalTint, Color vbHiglight, Color vbHiglightTint, Color dlgNormal, Color dlgHighlt, Color invFrame, Color inventoryBack, Color retroNml, Color retroHighlt);
+	VerbUiColors(const Color &s, const Color &vbNormal, const Color &vbNormalTint, const Color &vbHiglight, const Color &vbHiglightTint, const Color &dlgNormal, const Color &dlgHighlt, const Color &invFrame, const Color &inventoryBack, const Color &retroNml, const Color &retroHighlt);
 };
 
 struct Verb {
@@ -109,13 +109,13 @@ public:
 	void init();
 	ActorSlot *actorSlot(Common::SharedPtr<Object> actor);
 	bool isOverVerbs() const { return _over; }
-	void update(float elapsed, Math::Vector2d pos, Common::SharedPtr<Object> hotspot, bool mouseClick);
+	void update(float elapsed, const Math::Vector2d &pos, Common::SharedPtr<Object> hotspot, bool mouseClick);
 
 	void setVisible(bool visible) override;
 
 private:
-	void drawCore(Math::Matrix4 trsf) final;
-	void drawSprite(const SpriteSheetFrame &sf, Texture *texture, Color color, Math::Matrix4 trsf);
+	void drawCore(const Math::Matrix4 &trsf) final;
+	void drawSprite(const SpriteSheetFrame &sf, Texture *texture, const Color &color, const Math::Matrix4 &trsf);
 
 public:
 	ActorSlot _actorSlots[NUMACTORS];
diff --git a/engines/twp/motor.cpp b/engines/twp/motor.cpp
index 519b454dfe4..22c024e538d 100644
--- a/engines/twp/motor.cpp
+++ b/engines/twp/motor.cpp
@@ -32,7 +32,8 @@
 namespace Twp {
 
 void Motor::update(float elapsed) {
-	if(!isEnabled()) return;
+	if (!isEnabled())
+		return;
 	onUpdate(elapsed);
 }
 
@@ -135,7 +136,7 @@ void Shake::onUpdate(float elapsed) {
 	_node->setShakeOffset(Math::Vector2d(_amount * cos(_shakeTime + 0.3f), _amount * sin(_shakeTime)));
 }
 
-OverlayTo::OverlayTo(float duration, Common::SharedPtr<Room> room, Color to)
+OverlayTo::OverlayTo(float duration, Common::SharedPtr<Room> room, const Color &to)
 	: _room(room),
 	  _to(to),
 	  _tween(g_twp->_room->getOverlay(), to, duration, InterpolationMethod()) {
@@ -183,7 +184,7 @@ void ReachAnim::onUpdate(float elapsed) {
 	}
 }
 
-WalkTo::WalkTo(Common::SharedPtr<Object> obj, Math::Vector2d dest, int facing)
+WalkTo::WalkTo(Common::SharedPtr<Object> obj, const Math::Vector2d &dest, int facing)
 	: _obj(obj), _facing(facing) {
 	if (obj->_useWalkboxes) {
 		_path = obj->_room->calculatePath(obj->_node->getAbsPos(), dest);
@@ -306,7 +307,7 @@ void WalkTo::onUpdate(float elapsed) {
 	}
 }
 
-Talking::Talking(Common::SharedPtr<Object> obj, const Common::StringArray &texts, Color color) {
+Talking::Talking(Common::SharedPtr<Object> obj, const Common::StringArray &texts, const Color &color) {
 	_obj = obj;
 	_color = color;
 	_texts.assign(texts.begin() + 1, texts.end());
diff --git a/engines/twp/motor.h b/engines/twp/motor.h
index 7d553a49946..60e1c4de899 100644
--- a/engines/twp/motor.h
+++ b/engines/twp/motor.h
@@ -192,7 +192,7 @@ private:
 class OverlayTo : public Motor {
 public:
 	virtual ~OverlayTo();
-	OverlayTo(float duration, Common::SharedPtr<Room> room, Color to);
+	OverlayTo(float duration, Common::SharedPtr<Room> room, const Color &to);
 
 	virtual void onUpdate(float elapsed) override;
 
@@ -227,7 +227,7 @@ enum WalkToState {
 
 class WalkTo : public Motor {
 public:
-	WalkTo(Common::SharedPtr<Object> obj, Math::Vector2d dest, int facing = 0);
+	WalkTo(Common::SharedPtr<Object> obj, const Math::Vector2d &dest, int facing = 0);
 	void disable() override;
 
 	const Common::Array<Math::Vector2d> &getPath() const { return _path; }
@@ -248,7 +248,7 @@ class TextNode;
 // Creates a talking animation for a specified object.
 class Talking : public Motor {
 public:
-	Talking(Common::SharedPtr<Object> obj, const Common::StringArray &texts, Color color);
+	Talking(Common::SharedPtr<Object> obj, const Common::StringArray &texts, const Color &color);
 	virtual ~Talking() {}
 
 	void append(const Common::StringArray &texts);
diff --git a/engines/twp/object.cpp b/engines/twp/object.cpp
index 43ba6808756..f6867ee33eb 100644
--- a/engines/twp/object.cpp
+++ b/engines/twp/object.cpp
@@ -498,7 +498,7 @@ bool Object::inInventory() {
 	return g_twp->_resManager->isObject(getId()) && getIcon().size() > 0;
 }
 
-bool Object::contains(Math::Vector2d pos) {
+bool Object::contains(const Math::Vector2d &pos) {
 	Math::Vector2d p = pos - _node->getPos() - _node->getOffset();
 	return _hotspot.contains(p.getX(), p.getY());
 }
@@ -675,7 +675,7 @@ void Object::stopTalking() {
 	}
 }
 
-void Object::say(Common::SharedPtr<Object> obj, const Common::StringArray &texts, Color color) {
+void Object::say(Common::SharedPtr<Object> obj, const Common::StringArray &texts, const Color &color) {
 	if (texts.size() == 0)
 		return;
 	obj->_talkingState._obj.reset(obj);
@@ -816,7 +816,7 @@ void Object::execVerb(Common::SharedPtr<Object> obj) {
 }
 
 // Walks an actor to the `pos` or actor `obj` and then faces `dir`.
-void Object::walk(Common::SharedPtr<Object> obj, Math::Vector2d pos, int facing) {
+void Object::walk(Common::SharedPtr<Object> obj, const Math::Vector2d &pos, int facing) {
 	debugC(kDebugGame, "walk to obj %s: %f,%f, %d", obj->_key.c_str(), pos.getX(), pos.getY(), facing);
 	if (!obj->_walkTo || (!obj->_walkTo->isEnabled())) {
 		obj->play(obj->getAnimName(WALK_ANIMNAME), true);
diff --git a/engines/twp/object.h b/engines/twp/object.h
index 0e3fcb86985..e3f3d621f5e 100644
--- a/engines/twp/object.h
+++ b/engines/twp/object.h
@@ -175,7 +175,7 @@ public:
 	int getFlags();
 	UseFlag useFlag();
 
-	bool contains(Math::Vector2d pos);
+	bool contains(const Math::Vector2d &pos);
 	static void setRoom(Common::SharedPtr<Object> object, Common::SharedPtr<Room> room);
 	void stopObjectMotors();
 	void dependentOn(Common::SharedPtr<Object> dependentObj, int state);
@@ -199,7 +199,7 @@ public:
 	void setReach(Common::SharedPtr<Motor> reach);
 	Common::SharedPtr<Motor> getWalkTo() { return _walkTo; }
 	Common::SharedPtr<Motor> getReach() { return _reach; }
-	static void walk(Common::SharedPtr<Object> obj, Math::Vector2d pos, int facing = 0);
+	static void walk(Common::SharedPtr<Object> obj, const Math::Vector2d &pos, int facing = 0);
 	static void walk(Common::SharedPtr<Object> actor, Common::SharedPtr<Object> obj);
 
 	void setTalking(Common::SharedPtr<Motor> talking);
@@ -208,7 +208,7 @@ public:
 
 	Common::SharedPtr<Motor> getTalking() { return _talking; }
 	void stopTalking();
-	static void say(Common::SharedPtr<Object> obj, const Common::StringArray &texts, Color color);
+	static void say(Common::SharedPtr<Object> obj, const Common::StringArray &texts, const Color &color);
 
 	static void pickupObject(Common::SharedPtr<Object> actor, Common::SharedPtr<Object> obj);
 
diff --git a/engines/twp/rectf.cpp b/engines/twp/rectf.cpp
index 53300d30d8b..4a3962ed471 100644
--- a/engines/twp/rectf.cpp
+++ b/engines/twp/rectf.cpp
@@ -32,15 +32,15 @@ Rectf::Rectf(float x, float y, float w, float h) {
 	r.h = h;
 }
 
-Rectf Rectf::fromPosAndSize(Math::Vector2d pos, Math::Vector2d size) {
+Rectf Rectf::fromPosAndSize(const Math::Vector2d &pos, const Math::Vector2d &size) {
 	return {pos.getX(), pos.getY(), size.getX(), size.getY()};
 }
 
-Rectf Rectf::fromMinMax(Math::Vector2d min, Math::Vector2d max) {
+Rectf Rectf::fromMinMax(const Math::Vector2d &min, const Math::Vector2d &max) {
 	return {min.getX(), min.getY(), max.getX() - min.getX() + 1, max.getY() - min.getY() + 1};
 }
 
-Rectf Rectf::operator/(Math::Vector2d nv) {
+Rectf Rectf::operator/(const Math::Vector2d &nv) {
 	return Rectf(r.x / nv.getX(), r.y / nv.getY(), r.w / nv.getX(), r.h / nv.getY());
 }
 
diff --git a/engines/twp/rectf.h b/engines/twp/rectf.h
index dd1f16bc544..9337ebca9d1 100644
--- a/engines/twp/rectf.h
+++ b/engines/twp/rectf.h
@@ -32,10 +32,10 @@ public:
 	Rectf();
 	Rectf(float x, float y, float w, float h);
 
-	static Rectf fromPosAndSize(Math::Vector2d pos, Math::Vector2d size);
-	static Rectf fromMinMax(Math::Vector2d min, Math::Vector2d max);
+	static Rectf fromPosAndSize(const Math::Vector2d &pos, const Math::Vector2d &size);
+	static Rectf fromMinMax(const Math::Vector2d &min, const Math::Vector2d &max);
 
-	Rectf operator/(Math::Vector2d v);
+	Rectf operator/(const Math::Vector2d &v);
 
 	union {
 		float v[4];
@@ -52,7 +52,7 @@ public:
 	inline float top() { return r.y + r.h; }
 	inline float bottom() { return r.y; }
 
-	bool contains(Math::Vector2d pos) {
+	bool contains(const Math::Vector2d &pos) {
 		return pos.getX() >= r.x && pos.getX() <= (r.x + r.w) && pos.getY() >= r.y && pos.getY() <= r.y + r.h;
 	}
 };
diff --git a/engines/twp/room.cpp b/engines/twp/room.cpp
index b92a8f574e9..b5a2ea2061d 100644
--- a/engines/twp/room.cpp
+++ b/engines/twp/room.cpp
@@ -403,7 +403,7 @@ Common::SharedPtr<Object> Room::getObj(const Common::String &key) {
 	return nullptr;
 }
 
-Light *Room::createLight(Color color, Math::Vector2d pos) {
+Light *Room::createLight(const Color &color, const Math::Vector2d &pos) {
 	Light *result = &_lights._lights[_lights._numLights];
 	result->id = 100000 + _lights._numLights;
 	result->on = true;
@@ -434,7 +434,7 @@ void Room::objectParallaxLayer(Common::SharedPtr<Object> obj, int zsort) {
 	}
 }
 
-void Room::setOverlay(Color color) {
+void Room::setOverlay(const Color &color) {
 	_overlayNode.setOverlayColor(color);
 }
 
@@ -468,7 +468,7 @@ void Room::walkboxHidden(const Common::String &name, bool hidden) {
 	}
 }
 
-Common::Array<Math::Vector2d> Room::calculatePath(Math::Vector2d frm, Math::Vector2d to) {
+Common::Array<Math::Vector2d> Room::calculatePath(const Math::Vector2d &frm, const Math::Vector2d &to) {
 	if (_mergedPolygon.size() > 0) {
 		if (_pathFinder.isDirty()) {
 			_mergedPolygon = merge(_walkboxes);
@@ -480,13 +480,13 @@ Common::Array<Math::Vector2d> Room::calculatePath(Math::Vector2d frm, Math::Vect
 	return {};
 }
 
-Layer::Layer(const Common::String &name, Math::Vector2d parallax, int zsort) {
+Layer::Layer(const Common::String &name, const Math::Vector2d &parallax, int zsort) {
 	_names.push_back(name);
 	_parallax = parallax;
 	_zsort = zsort;
 }
 
-Layer::Layer(const Common::StringArray &name, Math::Vector2d parallax, int zsort) {
+Layer::Layer(const Common::StringArray &name, const Math::Vector2d &parallax, int zsort) {
 	_names.push_back(name);
 	_parallax = parallax;
 	_zsort = zsort;
@@ -508,7 +508,7 @@ bool Walkbox::concave(int vertex) const {
 	return cross < 0;
 }
 
-bool Walkbox::contains(Math::Vector2d position, bool toleranceOnOutside) const {
+bool Walkbox::contains(const Math::Vector2d &position, bool toleranceOnOutside) const {
 	Math::Vector2d point = position;
 	const float epsilon = 2.0f;
 	bool result = false;
diff --git a/engines/twp/room.h b/engines/twp/room.h
index a386a421806..17d334c2d02 100644
--- a/engines/twp/room.h
+++ b/engines/twp/room.h
@@ -52,8 +52,8 @@ class Object;
 
 class Layer {
 public:
-	Layer(const Common::String &name, Math::Vector2d parallax, int zsort);
-	Layer(const Common::StringArray &names, Math::Vector2d parallax, int zsort);
+	Layer(const Common::String &name, const Math::Vector2d &parallax, int zsort);
+	Layer(const Common::StringArray &names, const Math::Vector2d &parallax, int zsort);
 
 public:
 	Common::Array<Common::String> _names;
@@ -120,14 +120,14 @@ public:
 	Common::SharedPtr<Layer> layer(int zsort);
 	Common::SharedPtr<Object> getObj(const Common::String &key);
 
-	Light *createLight(Color color, Math::Vector2d pos);
+	Light *createLight(const Color &color, const Math::Vector2d &pos);
 	float getScaling(float yPos);
 	void objectParallaxLayer(Common::SharedPtr<Object> obj, int zsort);
-	void setOverlay(Color color);
+	void setOverlay(const Color &color);
 	Color getOverlay() const;
 
 	void walkboxHidden(const Common::String &name, bool hidden);
-	Common::Array<Math::Vector2d> calculatePath(Math::Vector2d frm, Math::Vector2d to);
+	Common::Array<Math::Vector2d> calculatePath(const Math::Vector2d &frm, const Math::Vector2d &to);
 
 public:
 	Common::String _name;                             // Name of the room
diff --git a/engines/twp/scenegraph.cpp b/engines/twp/scenegraph.cpp
index 559fbb9d668..150f85960d8 100644
--- a/engines/twp/scenegraph.cpp
+++ b/engines/twp/scenegraph.cpp
@@ -49,7 +49,7 @@ static float _getFps(float fps, float animFps) {
 	return (animFps < 1e-3) ? DEFAULT_FPS : animFps;
 }
 
-Node::Node(const Common::String &name, Math::Vector2d scale, Color color)
+Node::Node(const Common::String &name, const Math::Vector2d &scale, const Color &color)
 	: _name(name),
 	  _color(color),
 	  _computedColor(color),
@@ -120,7 +120,7 @@ void Node::remove() {
 		_parent->removeChild(this);
 }
 
-void Node::setColor(Color c) {
+void Node::setColor(const Color &c) {
 	_color.rgba.r = c.rgba.r;
 	_color.rgba.g = c.rgba.g;
 	_color.rgba.b = c.rgba.b;
@@ -146,7 +146,7 @@ void Node::updateAlpha() {
 	updateAlpha(parentOpacity);
 }
 
-void Node::updateColor(Color parentColor) {
+void Node::updateColor(const Color &parentColor) {
 	_computedColor.rgba.r = _color.rgba.r * parentColor.rgba.r;
 	_computedColor.rgba.g = _color.rgba.g * parentColor.rgba.g;
 	_computedColor.rgba.b = _color.rgba.b * parentColor.rgba.b;
@@ -166,21 +166,21 @@ void Node::updateAlpha(float parentAlpha) {
 	}
 }
 
-void Node::setAnchor(Math::Vector2d anchor) {
+void Node::setAnchor(const Math::Vector2d &anchor) {
 	if (_anchor != anchor) {
 		_anchorNorm = anchor / _size;
 		_anchor = anchor;
 	}
 }
 
-void Node::setAnchorNorm(Math::Vector2d anchorNorm) {
+void Node::setAnchorNorm(const Math::Vector2d &anchorNorm) {
 	if (_anchorNorm != anchorNorm) {
 		_anchorNorm = anchorNorm;
 		_anchor = _size * _anchorNorm;
 	}
 }
 
-void Node::setSize(Math::Vector2d size) {
+void Node::setSize(const Math::Vector2d &size) {
 	if (_size != size) {
 		_size = size;
 		_anchor = size * _anchorNorm;
@@ -200,7 +200,7 @@ static int cmpNodes(const NodeSort &x, const NodeSort &y) {
 	return x.node->getZSort() > y.node->getZSort();
 }
 
-void Node::onDrawChildren(Math::Matrix4 trsf) {
+void Node::onDrawChildren(const Math::Matrix4 &trsf) {
 	// use this "stable sort" until there is something better available
 	Common::Array<NodeSort> children;
 	for (size_t i = 0; i < _children.size(); i++) {
@@ -217,7 +217,7 @@ void Node::onDrawChildren(Math::Matrix4 trsf) {
 	}
 }
 
-void Node::draw(Math::Matrix4 parent) {
+void Node::draw(const Math::Matrix4 &parent) {
 	if (_visible) {
 		Math::Matrix4 trsf = getTrsf(parent);
 		Math::Matrix4 myTrsf(trsf);
@@ -231,7 +231,7 @@ Math::Vector2d Node::getAbsPos() const {
 	return !_parent ? _pos : _parent->getAbsPos() + _pos;
 }
 
-Math::Matrix4 Node::getTrsf(Math::Matrix4 parentTrsf) {
+Math::Matrix4 Node::getTrsf(const Math::Matrix4 &parentTrsf) {
 	return parentTrsf * getLocalTrsf();
 }
 
@@ -263,7 +263,7 @@ ParallaxNode::ParallaxNode(const Math::Vector2d &parallax, const Common::String
 
 ParallaxNode::~ParallaxNode() {}
 
-Math::Matrix4 ParallaxNode::getTrsf(Math::Matrix4 parentTrsf) {
+Math::Matrix4 ParallaxNode::getTrsf(const Math::Matrix4 &parentTrsf) {
 	Gfx &gfx = g_twp->getGfx();
 	Math::Matrix4 trsf = Node::getTrsf(parentTrsf);
 	Math::Vector2d camPos = gfx.cameraPos();
@@ -272,11 +272,11 @@ Math::Matrix4 ParallaxNode::getTrsf(Math::Matrix4 parentTrsf) {
 	return trsf;
 }
 
-void ParallaxNode::onDrawChildren(Math::Matrix4 trsf) {
+void ParallaxNode::onDrawChildren(const Math::Matrix4 &trsf) {
 	Node::onDrawChildren(trsf);
 }
 
-void ParallaxNode::drawCore(Math::Matrix4 trsf) {
+void ParallaxNode::drawCore(const Math::Matrix4 &trsf) {
 	Gfx &gfx = g_twp->getGfx();
 	SpriteSheet *sheet = g_twp->_resManager->spriteSheet(_sheet);
 	Texture *texture = g_twp->_resManager->texture(sheet->meta.image);
@@ -388,7 +388,8 @@ void Anim::update(float elapsed) {
 	}
 }
 
-void Anim::drawCore(Math::Matrix4 trsf) {
+void Anim::drawCore(const Math::Matrix4 &t) {
+	Math::Matrix4 trsf(t);
 	if (_frameIndex < _frames.size()) {
 		const Common::String &frame = _frames[_frameIndex];
 		if (frame == "null")
@@ -463,11 +464,11 @@ Rectf TextNode::getRect() const {
 	return Rectf::fromPosAndSize(getAbsPos() + Math::Vector2d(0, -size.getY()) + Math::Vector2d(-size.getX(), size.getY()) * _anchorNorm, size);
 }
 
-void TextNode::onColorUpdated(Color color) {
+void TextNode::onColorUpdated(const Color &color) {
 	_text.setColor(color);
 }
 
-void TextNode::drawCore(Math::Matrix4 trsf) {
+void TextNode::drawCore(const Math::Matrix4 &trsf) {
 	_text.draw(g_twp->getGfx(), trsf);
 }
 
@@ -500,7 +501,8 @@ Common::String InputState::getCursorName() const {
 	return "cursor";
 }
 
-void InputState::drawCore(Math::Matrix4 trsf) {
+void InputState::drawCore(const Math::Matrix4 &t) {
+	Math::Matrix4 trsf(t);
 	Common::String cursorName = getCursorName();
 	// draw cursor
 	SpriteSheet *gameSheet = g_twp->_resManager->spriteSheet("GameSheet");
@@ -556,7 +558,7 @@ OverlayNode::OverlayNode() : Node("overlay") {
 	_zOrder = INT_MIN;
 }
 
-void OverlayNode::drawCore(Math::Matrix4 trsf) {
+void OverlayNode::drawCore(const Math::Matrix4 &trsf) {
 	Math::Vector2d size = g_twp->getGfx().camera();
 	g_twp->getGfx().drawQuad(size, _ovlColor);
 }
@@ -587,13 +589,14 @@ Math::Vector2d Inventory::getPos(Common::SharedPtr<Object> inv) const {
 	return {};
 }
 
-void Inventory::drawSprite(const SpriteSheetFrame &sf, Texture *texture, Color color, Math::Matrix4 trsf) {
+void Inventory::drawSprite(const SpriteSheetFrame &sf, Texture *texture, const Color &color, const Math::Matrix4 &t) {
+	Math::Matrix4 trsf(t);
 	Math::Vector3d pos(sf.spriteSourceSize.left - sf.sourceSize.getX() / 2.f, -sf.spriteSourceSize.height() - sf.spriteSourceSize.top + sf.sourceSize.getY() / 2.f, 0.f);
 	trsf.translate(pos);
 	g_twp->getGfx().drawSprite(sf.frame, *texture, color, trsf);
 }
 
-void Inventory::drawArrows(Math::Matrix4 trsf) {
+void Inventory::drawArrows(const Math::Matrix4 &trsf) {
 	bool isRetro = ConfMan.getBool("retroVerbs");
 	SpriteSheet *gameSheet = g_twp->_resManager->spriteSheet("GameSheet");
 	Texture *texture = g_twp->_resManager->texture(gameSheet->meta.image);
@@ -610,7 +613,7 @@ void Inventory::drawArrows(Math::Matrix4 trsf) {
 	drawSprite(*arrowDn, texture, Color::withAlpha(_verbNormal, alphaDn * getAlpha()), tDn);
 }
 
-void Inventory::drawBack(Math::Matrix4 trsf) {
+void Inventory::drawBack(const Math::Matrix4 &trsf) {
 	SpriteSheet *gameSheet = g_twp->_resManager->spriteSheet("GameSheet");
 	Texture *texture = g_twp->_resManager->texture(gameSheet->meta.image);
 	const SpriteSheetFrame *back = &gameSheet->getFrame("inventory_background");
@@ -636,7 +639,7 @@ void Inventory::drawBack(Math::Matrix4 trsf) {
 	}
 }
 
-void Inventory::drawItems(Math::Matrix4 trsf) {
+void Inventory::drawItems(const Math::Matrix4 &trsf) {
 	float startOffsetX = SCREEN_WIDTH / 2.f + ARROWWIDTH + MARGIN + BACKWIDTH / 2.f;
 	float startOffsetY = MARGINBOTTOM + 1.5f * BACKHEIGHT + BACKOFFSET;
 	SpriteSheet *itemsSheet = g_twp->_resManager->spriteSheet("InventoryItems");
@@ -663,7 +666,7 @@ void Inventory::drawItems(Math::Matrix4 trsf) {
 	}
 }
 
-void Inventory::drawCore(Math::Matrix4 trsf) {
+void Inventory::drawCore(const Math::Matrix4 &trsf) {
 	if (_actor) {
 		drawArrows(trsf);
 		drawBack(trsf);
@@ -671,7 +674,7 @@ void Inventory::drawCore(Math::Matrix4 trsf) {
 	}
 }
 
-void Inventory::update(float elapsed, Common::SharedPtr<Object> actor, Color backColor, Color verbNormal) {
+void Inventory::update(float elapsed, Common::SharedPtr<Object> actor, const Color &backColor, const Color &verbNormal) {
 	_jiggleTime += 10.f * elapsed;
 	_fadeTime += elapsed;
 
@@ -751,7 +754,7 @@ void SentenceNode::setText(const Common::String &text) {
 	_text = text;
 }
 
-void SentenceNode::drawCore(Math::Matrix4 trsf) {
+void SentenceNode::drawCore(const Math::Matrix4 &trsf) {
 	Text text("sayline", _text);
 	float x, y;
 	if (ConfMan.getBool("hudSentence")) {
@@ -777,7 +780,7 @@ void SpriteNode::setSprite(const Common::String &sheet, const Common::String &fr
 	_frame = frame;
 }
 
-void SpriteNode::drawCore(Math::Matrix4 trsf) {
+void SpriteNode::drawCore(const Math::Matrix4 &trsf) {
 	SpriteSheet *sheet = g_twp->_resManager->spriteSheet(_sheet);
 	const SpriteSheetFrame *frame = &sheet->getFrame(_frame);
 
@@ -828,13 +831,14 @@ HotspotMarkerNode::HotspotMarkerNode() : Node("HotspotMarker") {
 
 HotspotMarkerNode::~HotspotMarkerNode() {}
 
-void HotspotMarkerNode::drawSprite(const SpriteSheetFrame &sf, Texture *texture, Color color, Math::Matrix4 trsf) {
+void HotspotMarkerNode::drawSprite(const SpriteSheetFrame &sf, Texture *texture, const Color &color, const Math::Matrix4 &t) {
+	Math::Matrix4 trsf(t);
 	Math::Vector3d pos(sf.spriteSourceSize.left - sf.sourceSize.getX() / 2.f, -sf.spriteSourceSize.height() - sf.spriteSourceSize.top + sf.sourceSize.getY() / 2.f, 0.f);
 	trsf.translate(pos);
 	g_twp->getGfx().drawSprite(sf.frame, *texture, color, trsf);
 }
 
-void HotspotMarkerNode::drawCore(Math::Matrix4 trsf) {
+void HotspotMarkerNode::drawCore(const Math::Matrix4 &trsf) {
 	SpriteSheet *gameSheet = g_twp->_resManager->spriteSheet("GameSheet");
 	Texture *texture = g_twp->_resManager->texture(gameSheet->meta.image);
 	const SpriteSheetFrame *frame = &gameSheet->getFrame("hotspot_marker");
diff --git a/engines/twp/scenegraph.h b/engines/twp/scenegraph.h
index e43f5ebacb6..dcd1b3cea9c 100644
--- a/engines/twp/scenegraph.h
+++ b/engines/twp/scenegraph.h
@@ -39,7 +39,7 @@ namespace Twp {
 // Represents a node in a scene graph.
 class Node {
 public:
-	Node(const Common::String &name, Math::Vector2d scale = Math::Vector2d(1, 1), Color color = Color());
+	Node(const Common::String &name, const Math::Vector2d &scale = Math::Vector2d(1, 1), const Color &color = Color());
 	virtual ~Node();
 
 	void setName(const Common::String &name) { _name = name; }
@@ -84,9 +84,9 @@ public:
 	Math::Vector2d getAbsPos() const;
 
 	// Gets the full transformation for this node.
-	virtual Math::Matrix4 getTrsf(Math::Matrix4 parentTrsf);
+	virtual Math::Matrix4 getTrsf(const Math::Matrix4 &parentTrsf);
 
-	void setColor(Color color);
+	void setColor(const Color &color);
 	Color getColor() const { return _color; }
 	Color getComputedColor() const { return _computedColor; }
 
@@ -102,24 +102,24 @@ public:
 	void setRotationOffset(float rotationOffset) { _rotationOffset = rotationOffset; }
 	float getRotationOffset() const { return _rotationOffset; }
 
-	void setAnchor(Math::Vector2d anchor);
-	void setAnchorNorm(Math::Vector2d anchorNorm);
-	void setSize(Math::Vector2d size);
+	void setAnchor(const Math::Vector2d &anchor);
+	void setAnchorNorm(const Math::Vector2d &anchorNorm);
+	void setSize(const Math::Vector2d &size);
 	Math::Vector2d getSize() const { return _size; }
 	virtual Rectf getRect() const;
 
-	void draw(Math::Matrix4 parent = Math::Matrix4());
+	void draw(const Math::Matrix4 &parent = Math::Matrix4());
 
 protected:
-	virtual void onDrawChildren(Math::Matrix4 trsf);
-	virtual void onColorUpdated(Color c) {}
-	virtual void drawCore(Math::Matrix4 trsf) {}
+	virtual void onDrawChildren(const Math::Matrix4 &trsf);
+	virtual void onColorUpdated(const Color &c) {}
+	virtual void drawCore(const Math::Matrix4 &trsf) {}
 
 private:
 	// Gets the location transformation = translation * rotation * scale.
 	Math::Matrix4 getLocalTrsf();
 	void updateColor();
-	void updateColor(Color parentColor);
+	void updateColor(const Color &parentColor);
 	void updateAlpha();
 	void updateAlpha(float parentAlpha);
 
@@ -141,11 +141,11 @@ public:
 	ParallaxNode(const Math::Vector2d &parallax, const Common::String &sheet, const Common::StringArray &frames);
 	virtual ~ParallaxNode();
 
-	Math::Matrix4 getTrsf(Math::Matrix4 parentTrsf) override final;
+	Math::Matrix4 getTrsf(const Math::Matrix4 &parentTrsf) override final;
 
 protected:
-	void onDrawChildren(Math::Matrix4 trsf) override;
-	void drawCore(Math::Matrix4 trsf) override final;
+	void onDrawChildren(const Math::Matrix4 &trsf) override;
+	void drawCore(const Math::Matrix4 &trsf) override final;
 
 private:
 	Math::Vector2d _parallax;
@@ -167,7 +167,7 @@ public:
 	void trigSound();
 
 private:
-	virtual void drawCore(Math::Matrix4 trsf) override final;
+	virtual void drawCore(const Math::Matrix4 &trsf) override final;
 
 public:
 	const ObjectAnimation *_anim = nullptr;
@@ -206,8 +206,8 @@ public:
 	virtual Rectf getRect() const override final;
 
 private:
-	virtual void onColorUpdated(Color color) override final;
-	virtual void drawCore(Math::Matrix4 trsf) override final;
+	virtual void onColorUpdated(const Color &color) override final;
+	virtual void drawCore(const Math::Matrix4 &trsf) override final;
 
 private:
 	Text _text;
@@ -265,7 +265,7 @@ public:
 	void setCursorShape(CursorShape shape);
 
 private:
-	virtual void drawCore(Math::Matrix4 trsf) override final;
+	virtual void drawCore(const Math::Matrix4 &trsf) override final;
 	Common::String getCursorName() const;
 
 public:
@@ -281,11 +281,11 @@ class OverlayNode final : public Node {
 public:
 	OverlayNode();
 
-	void setOverlayColor(Color color) { _ovlColor = color; }
+	void setOverlayColor(const Color &color) { _ovlColor = color; }
 	Color getOverlayColor() const { return _ovlColor; }
 
 private:
-	virtual void drawCore(Math::Matrix4 trsf) override final;
+	virtual void drawCore(const Math::Matrix4 &trsf) override final;
 
 private:
 	Color _ovlColor;
@@ -294,7 +294,7 @@ private:
 class Inventory : public Node {
 public:
 	Inventory();
-	void update(float elapsed, Common::SharedPtr<Object> actor = nullptr, Color backColor = Color(0, 0, 0), Color verbNormal = Color(0, 0, 0));
+	void update(float elapsed, Common::SharedPtr<Object> actor = nullptr,const Color &backColor = Color(0, 0, 0), const Color &verbNormal = Color(0, 0, 0));
 
 	bool isOver() const { return _over; }
 	Common::SharedPtr<Object> getObject() const { return _obj; }
@@ -303,11 +303,11 @@ public:
 	void setVisible(bool visible) override;
 
 private:
-	virtual void drawCore(Math::Matrix4 trsf) override final;
-	void drawArrows(Math::Matrix4 trsf);
-	void drawBack(Math::Matrix4 trsf);
-	void drawItems(Math::Matrix4 trsf);
-	void drawSprite(const SpriteSheetFrame &sf, Texture *texture, Color color, Math::Matrix4 trsf);
+	virtual void drawCore(const Math::Matrix4 &trsf) override final;
+	void drawArrows(const Math::Matrix4 &trsf);
+	void drawBack(const Math::Matrix4 &trsf);
+	void drawItems(const Math::Matrix4 &trsf);
+	void drawSprite(const SpriteSheetFrame &sf, Texture *texture, const Color &color, const Math::Matrix4 &trsf);
 
 public:
 	bool _active;
@@ -334,7 +334,7 @@ public:
 	void setText(const Common::String &text);
 
 private:
-	void drawCore(Math::Matrix4 trsf) override final;
+	void drawCore(const Math::Matrix4 &trsf) override final;
 
 private:
 	Common::String _text;
@@ -348,7 +348,7 @@ public:
 	void setSprite(const Common::String &sheet, const Common::String &frame);
 
 private:
-	void drawCore(Math::Matrix4 trsf) override final;
+	void drawCore(const Math::Matrix4 &trsf) override final;
 
 private:
 	Common::String _sheet;
@@ -374,8 +374,8 @@ public:
 	virtual ~HotspotMarkerNode();
 
 private:
-	void drawSprite(const SpriteSheetFrame &sf, Texture *texture, Color color, Math::Matrix4 trsf);
-	void drawCore(Math::Matrix4 trsf) override final;
+	void drawSprite(const SpriteSheetFrame &sf, Texture *texture, const Color &color, const Math::Matrix4 &trsf);
+	void drawCore(const Math::Matrix4 &trsf) override final;
 };
 
 } // End of namespace Twp
diff --git a/engines/twp/twp.cpp b/engines/twp/twp.cpp
index 76554dbee18..edefd209780 100644
--- a/engines/twp/twp.cpp
+++ b/engines/twp/twp.cpp
@@ -102,16 +102,16 @@ TwpEngine::~TwpEngine() {
 	delete _screen;
 }
 
-Math::Vector2d TwpEngine::winToScreen(Math::Vector2d pos) {
+Math::Vector2d TwpEngine::winToScreen(const Math::Vector2d &pos) {
 	return Math::Vector2d(pos.getX(), SCREEN_HEIGHT - pos.getY());
 }
 
-Math::Vector2d TwpEngine::roomToScreen(Math::Vector2d pos) {
+Math::Vector2d TwpEngine::roomToScreen(const Math::Vector2d &pos) {
 	Math::Vector2d screenSize = _room->getScreenSize();
 	return Math::Vector2d(SCREEN_WIDTH, SCREEN_HEIGHT) * (pos - _gfx.cameraPos()) / screenSize;
 }
 
-Math::Vector2d TwpEngine::screenToRoom(Math::Vector2d pos) {
+Math::Vector2d TwpEngine::screenToRoom(const Math::Vector2d &pos) {
 	Math::Vector2d screenSize = _room->getScreenSize();
 	return (pos * screenSize) / Math::Vector2d(SCREEN_WIDTH, SCREEN_HEIGHT) + _gfx.cameraPos();
 }
@@ -124,7 +124,7 @@ Common::String TwpEngine::getGameId() const {
 	return _gameDescription->desc.gameId;
 }
 
-bool TwpEngine::clickedAtHandled(Math::Vector2d roomPos) {
+bool TwpEngine::clickedAtHandled(const Math::Vector2d &roomPos) {
 	bool result = false;
 	int x = roomPos.getX();
 	int y = roomPos.getY();
@@ -228,7 +228,7 @@ void TwpEngine::walkFast(bool state) {
 	}
 }
 
-void TwpEngine::clickedAt(Math::Vector2d scrPos) {
+void TwpEngine::clickedAt(const Math::Vector2d &scrPos) {
 	if (_room && !_actorSwitcher.isMouseOver()) {
 		Math::Vector2d roomPos = screenToRoom(scrPos);
 		Common::SharedPtr<Object> obj = objAt(roomPos);
@@ -1472,7 +1472,7 @@ void TwpEngine::execNutEntry(HSQUIRRELVM v, const Common::String &entry) {
 	}
 }
 
-void TwpEngine::cameraAt(Math::Vector2d at) {
+void TwpEngine::cameraAt(const Math::Vector2d &at) {
 	_camera->setRoom(_room);
 	_camera->setAt(at);
 }
@@ -1528,7 +1528,7 @@ private:
 	int _zOrder = INT_MAX;
 };
 
-Common::SharedPtr<Object> TwpEngine::objAt(Math::Vector2d pos) {
+Common::SharedPtr<Object> TwpEngine::objAt(const Math::Vector2d &pos) {
 	Common::SharedPtr<Object> result;
 	objsAt(pos, GetByZOrder(result));
 	return result;
diff --git a/engines/twp/twp.h b/engines/twp/twp.h
index b9e61b74428..1b357a9617f 100644
--- a/engines/twp/twp.h
+++ b/engines/twp/twp.h
@@ -131,12 +131,12 @@ public:
 	bool canSaveAutosaveCurrently() override { return false; }
 	void capture(Graphics::Surface &surface, int width, int height);
 
-	Math::Vector2d winToScreen(Math::Vector2d pos);
-	Math::Vector2d roomToScreen(Math::Vector2d pos);
-	Math::Vector2d screenToRoom(Math::Vector2d pos);
+	Math::Vector2d winToScreen(const Math::Vector2d &pos);
+	Math::Vector2d roomToScreen(const Math::Vector2d &pos);
+	Math::Vector2d screenToRoom(const Math::Vector2d &pos);
 
 	void setActor(Common::SharedPtr<Object> actor, bool userSelected = false);
-	Common::SharedPtr<Object> objAt(Math::Vector2d pos);
+	Common::SharedPtr<Object> objAt(const Math::Vector2d& pos);
 	void flashSelectableActor(int flash);
 	void stopTalking();
 	void walkFast(bool state = true);
@@ -147,7 +147,7 @@ public:
 	void setRoom(Common::SharedPtr<Room> room, bool force = false);
 	void enterRoom(Common::SharedPtr<Room> room, Common::SharedPtr<Object> door = nullptr);
 
-	void cameraAt(Math::Vector2d at);
+	void cameraAt(const Math::Vector2d& at);
 	// Returns the camera position: the position of the middle of the screen.
 	Math::Vector2d cameraPos();
 	void follow(Common::SharedPtr<Object> actor);
@@ -168,8 +168,8 @@ private:
 	void draw(RenderTexture *texture = nullptr);
 	void exitRoom(Common::SharedPtr<Room> nextRoom);
 	void cancelSentence(Common::SharedPtr<Object> actor = nullptr);
-	void clickedAt(Math::Vector2d scrPos);
-	bool clickedAtHandled(Math::Vector2d roomPos);
+	void clickedAt(const Math::Vector2d &scrPos);
+	bool clickedAtHandled(const Math::Vector2d &roomPos);
 	void setShaderEffect(RoomEffect effect);
 	bool selectable(Common::SharedPtr<Object> actor);
 	void resetVerb();
diff --git a/engines/twp/util.cpp b/engines/twp/util.cpp
index 3b5d3bb7bb4..bd7605d9f5e 100644
--- a/engines/twp/util.cpp
+++ b/engines/twp/util.cpp
@@ -24,7 +24,7 @@
 
 namespace Twp {
 
-Math::Vector2d operator*(Math::Vector2d v, float f) {
+Math::Vector2d operator*(const Math::Vector2d &v, float f) {
 	return Math::Vector2d(v.getX() * f, v.getY() * f);
 }
 
@@ -130,13 +130,13 @@ void parseObjectAnimations(const Common::JSONArray &jAnims, Common::Array<Object
 	}
 }
 
-float distanceSquared(Math::Vector2d p1, Math::Vector2d p2) {
+float distanceSquared(const Math::Vector2d &p1, const Math::Vector2d &p2) {
 	const float dx = p1.getX() - p2.getX();
 	const float dy = p1.getY() - p2.getY();
 	return dx * dx + dy * dy;
 }
 
-float distanceToSegmentSquared(Math::Vector2d p, Math::Vector2d v, Math::Vector2d w) {
+float distanceToSegmentSquared(const Math::Vector2d &p, const Math::Vector2d &v, const Math::Vector2d &w) {
 	const float l2 = distanceSquared(v, w);
 	if (l2 == 0)
 		return distanceSquared(p, v);
@@ -148,11 +148,11 @@ float distanceToSegmentSquared(Math::Vector2d p, Math::Vector2d v, Math::Vector2
 	return distanceSquared(p, Math::Vector2d(v.getX() + t * (w.getX() - v.getX()), v.getY() + t * (w.getY() - v.getY())));
 }
 
-float distanceToSegment(Math::Vector2d p, Math::Vector2d v, Math::Vector2d w) {
+float distanceToSegment(const Math::Vector2d &p, const Math::Vector2d &v, const Math::Vector2d &w) {
 	return sqrt(distanceToSegmentSquared(p, v, w));
 }
 
-float distance(Math::Vector2d p1, Math::Vector2d p2) {
+float distance(const Math::Vector2d &p1, const Math::Vector2d &p2) {
 	return sqrt(distanceSquared(p1, p2));
 }
 
@@ -177,18 +177,19 @@ Common::String remove(const Common::String &txt, char startC, char endC) {
 	return txt;
 }
 
-Common::String replaceAll(const Common::String& s, const Common::String& what, const Common::String& by) {
+Common::String replaceAll(const Common::String &s, const Common::String &what, const Common::String &by) {
 	Common::String result;
 	uint i = 0;
 	size_t whatSize = what.size();
 	while (true) {
-      uint j = s.find(what, i);
-      if (j == Common::String::npos) break;
-      result += s.substr(i, j - i);
-      result += by;
-      i = j + whatSize;
+		uint j = s.find(what, i);
+		if (j == Common::String::npos)
+			break;
+		result += s.substr(i, j - i);
+		result += by;
+		i = j + whatSize;
 	}
-    result += s.substr(i);
+	result += s.substr(i);
 	return result;
 }
 
@@ -197,13 +198,13 @@ void scale(Math::Matrix4 &m, const Math::Vector2d &v) {
 	m(1, 1) *= v.getY();
 }
 
-float dot(Math::Vector2d u, Math::Vector2d v) {
+float dot(const Math::Vector2d &u, const Math::Vector2d &v) {
 	return (u.getX() * v.getX()) + (u.getY() * v.getY());
 }
 
-float length(Math::Vector2d v) { return sqrt(dot(v, v)); }
+float length(const Math::Vector2d &v) { return sqrt(dot(v, v)); }
 
-bool lineSegmentsCross(Math::Vector2d a, Math::Vector2d b, Math::Vector2d c, Math::Vector2d d) {
+bool lineSegmentsCross(const Math::Vector2d &a, const Math::Vector2d &b, const Math::Vector2d &c, const Math::Vector2d &d) {
 	const float EPSILON = 1e-3f;
 	const float denominator = ((b.getX() - a.getX()) * (d.getY() - c.getY())) - ((b.getY() - a.getY()) * (d.getX() - c.getX()));
 	if (abs(denominator) < EPSILON) {
diff --git a/engines/twp/util.h b/engines/twp/util.h
index 17a7da32481..a886c7bfb27 100644
--- a/engines/twp/util.h
+++ b/engines/twp/util.h
@@ -140,13 +140,13 @@ Common::String replaceAll(const Common::String &s, const Common::String &what, c
 
 // math util
 void scale(Math::Matrix4 &m, const Math::Vector2d &v);
-Math::Vector2d operator*(Math::Vector2d v, float f);
-float distance(Math::Vector2d p1, Math::Vector2d p2);
-float distanceSquared(Math::Vector2d p1, Math::Vector2d p2);
-float distanceToSegment(Math::Vector2d p, Math::Vector2d v, Math::Vector2d w);
-float dot(Math::Vector2d u, Math::Vector2d v);
-float length(Math::Vector2d v);
-bool lineSegmentsCross(Math::Vector2d a, Math::Vector2d b, Math::Vector2d c, Math::Vector2d d);
+Math::Vector2d operator*(const Math::Vector2d &v, float f);
+float distance(const Math::Vector2d &p1, const Math::Vector2d &p2);
+float distanceSquared(const Math::Vector2d &p1, const Math::Vector2d &p2);
+float distanceToSegment(const Math::Vector2d &p, const Math::Vector2d &v, const Math::Vector2d &w);
+float dot(const Math::Vector2d &u, const Math::Vector2d &v);
+float length(const Math::Vector2d &v);
+bool lineSegmentsCross(const Math::Vector2d &a, const Math::Vector2d &b, const Math::Vector2d &c, const Math::Vector2d &d);
 
 } // namespace Twp
 
diff --git a/engines/twp/walkboxnode.cpp b/engines/twp/walkboxnode.cpp
index 6851943e6ee..2be535521e2 100644
--- a/engines/twp/walkboxnode.cpp
+++ b/engines/twp/walkboxnode.cpp
@@ -32,7 +32,7 @@ WalkboxNode::WalkboxNode() : Node("Walkbox") {
 	_mode = WalkboxMode::None;
 }
 
-void WalkboxNode::drawCore(Math::Matrix4 trsf) {
+void WalkboxNode::drawCore(const Math::Matrix4& trsf) {
 	if (g_twp->_room) {
 		Color white;
 		Color red(1.f, 0.f, 0.f);
@@ -97,7 +97,7 @@ PathNode::PathNode() : Node("Path") {
 	_zOrder = -1000;
 }
 
-Math::Vector2d PathNode::fixPos(Math::Vector2d pos) {
+Math::Vector2d PathNode::fixPos(const Math::Vector2d &pos) {
 	for (size_t i = 0; i < g_twp->_room->_mergedPolygon.size(); i++) {
 		Walkbox &wb = g_twp->_room->_mergedPolygon[i];
 		if (!wb.isVisible() && wb.contains(pos)) {
@@ -110,7 +110,7 @@ Math::Vector2d PathNode::fixPos(Math::Vector2d pos) {
 	return pos;
 }
 
-void PathNode::drawCore(Math::Matrix4 trsf) {
+void PathNode::drawCore(const Math::Matrix4& trsf) {
 	if (!g_twp->_room)
 		return;
 
@@ -219,7 +219,7 @@ LightingNode::LightingNode() : Node("Lighting") {
 	_visible = false;
 }
 
-void LightingNode::drawCore(Math::Matrix4 trsf) {
+void LightingNode::drawCore(const Math::Matrix4& trsf) {
 	if (!g_twp->_room)
 		return;
 
diff --git a/engines/twp/walkboxnode.h b/engines/twp/walkboxnode.h
index b38b0404193..d7cc167a53e 100644
--- a/engines/twp/walkboxnode.h
+++ b/engines/twp/walkboxnode.h
@@ -40,7 +40,7 @@ public:
 	WalkboxMode getMode() const { return _mode; }
 
 private:
-	virtual void drawCore(Math::Matrix4 trsf) override;
+	virtual void drawCore(const Math::Matrix4 &trsf) override;
 
 private:
 	WalkboxMode _mode;
@@ -60,8 +60,8 @@ public:
 	PathMode getMode() const { return _mode; }
 
 private:
-	Math::Vector2d fixPos(Math::Vector2d pos);
-	virtual void drawCore(Math::Matrix4 trsf) override;
+	Math::Vector2d fixPos(const Math::Vector2d &pos);
+	virtual void drawCore(const Math::Matrix4 &trsf) override;
 
 private:
 	PathMode _mode = PathMode::None;
@@ -72,7 +72,7 @@ public:
 	LightingNode();
 
 private:
-	virtual void drawCore(Math::Matrix4 trsf) override;
+	virtual void drawCore(const Math::Matrix4 &trsf) override;
 };
 
 } // namespace Twp




More information about the Scummvm-git-logs mailing list