[Scummvm-git-logs] scummvm master -> 18fb7e72d86615d44c87455327a445b3b1dcc25e

aquadran noreply at scummvm.org
Sun Jun 5 20:16:46 UTC 2022


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:
18fb7e72d8 GRIM: Implemented Lua V1 'GetCameraLookVector' opcode


Commit: 18fb7e72d86615d44c87455327a445b3b1dcc25e
    https://github.com/scummvm/scummvm/commit/18fb7e72d86615d44c87455327a445b3b1dcc25e
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2022-06-05T22:16:42+02:00

Commit Message:
GRIM: Implemented Lua V1 'GetCameraLookVector' opcode

Changed paths:
    engines/grim/lua_v1.cpp
    engines/grim/lua_v1_set.cpp
    engines/grim/set.h


diff --git a/engines/grim/lua_v1.cpp b/engines/grim/lua_v1.cpp
index 8b696715093..352b48746ed 100644
--- a/engines/grim/lua_v1.cpp
+++ b/engines/grim/lua_v1.cpp
@@ -786,10 +786,6 @@ void Lua_V1::SetCameraInterest() {
 	// it's referenced once in Grim dead lua code
 }
 
-void Lua_V1::GetCameraLookVector() {
-	warning("Stub function: GetCameraLookVector");
-}
-
 #define STUB_FUNC(name) void name() {}
 
 // Stub functions not used in games
diff --git a/engines/grim/lua_v1_set.cpp b/engines/grim/lua_v1_set.cpp
index d18797fe302..6e5d460437c 100644
--- a/engines/grim/lua_v1_set.cpp
+++ b/engines/grim/lua_v1_set.cpp
@@ -301,6 +301,39 @@ void Lua_V1::NextSetup() {
 	g_grim->makeCurrentSetup(num);
 }
 
+void Lua_V1::GetCameraLookVector() {
+	Set *scene = g_grim->getCurrSet();
+	if (!scene) {
+		lua_pushnil();
+		return;
+	}
+
+	Set::Setup *setup;
+	lua_Object setupObj = lua_getparam(1);
+	if (lua_isnumber(setupObj)) {
+		setup = scene->getSetup((int)lua_getnumber(setupObj));
+	} else {
+		setup = scene->getCurrSetup();
+	}
+
+	Math::Vector3d lookVector = setup->_pos - setup->_interest;
+	lookVector.normalize();
+	lua_Object result = lua_createtable();
+	lua_pushobject(result);
+	lua_pushstring("x");
+	lua_pushnumber(lookVector.x());
+	lua_settable();
+	lua_pushobject(result);
+	lua_pushstring("y");
+	lua_pushnumber(lookVector.y());
+	lua_settable();
+	lua_pushobject(result);
+	lua_pushstring("z");
+	lua_pushnumber(lookVector.z());
+	lua_settable();
+	lua_pushobject(result);
+}
+
 /* This function makes the walkplane sectors smaller by the
  * given size. This is used when manny is holding some big
  * thing, like his scythe, that is likely to clip with the
diff --git a/engines/grim/set.h b/engines/grim/set.h
index 09709699c91..9f8a4860295 100644
--- a/engines/grim/set.h
+++ b/engines/grim/set.h
@@ -46,6 +46,8 @@ public:
 	Set();
 	~Set();
 
+	struct Setup;
+
 	static int32 getStaticTag() { return MKTAG('S', 'E', 'T', ' '); }
 
 	void loadText(TextSplitter &ts);
@@ -143,6 +145,7 @@ public:
 	};
 
 	Setup *getCurrSetup() { return _currSetup; }
+	Setup *getSetup(int num) const { return _setups + num; }
 	const Common::List<Light *> &getLights(bool inOverworld) { return (inOverworld ? _overworldLightsList : _lightsList); }
 	const Math::Frustum &getFrustum() { return _frustum; }
 




More information about the Scummvm-git-logs mailing list