Skip to content

Commit

Permalink
dollycam should respect the los when tracking units (#1767)
Browse files Browse the repository at this point in the history
* dollycam should respect the los when tracking units

* more nurbs

---------

Co-authored-by: sprunk <[email protected]>
  • Loading branch information
loveridge and sprunk authored Nov 13, 2024
1 parent 57a8c50 commit 6f3a208
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion rts/Game/Camera/DollyController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Game/Camera.h"
#include "Game/Camera/CameraController.h"
#include "Game/CameraHandler.h"
#include "Game/GlobalUnsynced.h"
#include "Game/UI/MouseHandler.h"
#include "Map/ReadMap.h"
#include "Sim/Units/Unit.h"
Expand Down Expand Up @@ -109,7 +110,7 @@ void CDollyController::Update()
dir = (lookT - pos).Normalize();
} else if (lookMode == DOLLY_LOOKMODE_UNIT) {
CUnit* unit = unitHandler.GetUnit(lookUnit);
if (unit != nullptr) {
if (unit != nullptr && unit->IsInLosForAllyTeam(gu->myAllyTeam)) {
pos += unit->drawPos * relative;
dir = (unit->drawPos - pos).Normalize();
}
Expand Down
12 changes: 6 additions & 6 deletions rts/Lua/LuaUnsyncedCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ int LuaUnsyncedCtrl::RunDollyCamera(lua_State* L)
/*** Pause Dolly Camera
*
* @function Spring.PauseDollyCamera
* @number fraction fraction of the total runtime to pause at, 0 to 1 inclusive
* @number fraction fraction of the total runtime to pause at, 0 to 1 inclusive. A null value pauses at current percent
* @treturn nil
*/
int LuaUnsyncedCtrl::PauseDollyCamera(lua_State* L)
Expand Down Expand Up @@ -1310,7 +1310,7 @@ int LuaUnsyncedCtrl::SetDollyCameraPosition(lua_State* L)
*
* @function Spring.SetDollyCameraCurve
* @number degree
* @tparam table cpoints
* @tparam table cpoints NURBS control point positions {{x,y,z,weight}, ...}
* @tparam table knots
* @treturn nil
*/
Expand Down Expand Up @@ -1364,7 +1364,7 @@ int LuaUnsyncedCtrl::SetDollyCameraRelativeMode(lua_State* L)
*
* @function Spring.SetDollyCameraLookCurve
* @number degree
* @tparam table cpoints
* @tparam table cpoints NURBS control point positions {{x,y,z,weight}, ...}
* @tparam table knots
* @treturn nil
*/
Expand Down Expand Up @@ -1394,9 +1394,9 @@ int LuaUnsyncedCtrl::SetDollyCameraLookCurve(lua_State* L)
*/
int LuaUnsyncedCtrl::SetDollyCameraLookPosition(lua_State* L)
{
int x = luaL_checkint(L, 1);
int y = luaL_checkint(L, 2);
int z = luaL_checkint(L, 3);
float x = luaL_checkfloat(L, 1);
float y = luaL_checkfloat(L, 2);
float z = luaL_checkfloat(L, 3);

camHandler->GetDollyController().SetLookMode(CDollyController::DOLLY_LOOKMODE_POSITION);
camHandler->GetDollyController().SetLookPosition(float3(x, y, z));
Expand Down

0 comments on commit 6f3a208

Please sign in to comment.