LCOV - code coverage report
Current view: top level - source/tools/atlas/GameInterface - Misc.cpp (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 37 0.0 %
Date: 2023-01-19 00:18:29 Functions: 0 4 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2009 Wildfire Games.
       2             :  * This file is part of 0 A.D.
       3             :  *
       4             :  * 0 A.D. is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 2 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * 0 A.D. is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #include "precompiled.h"
      19             : 
      20             : // TODO: organise things better, rather than sticking them in Misc
      21             : 
      22             : #include "Messages.h"
      23             : 
      24             : #include "maths/Vector3D.h"
      25             : #include "ps/Game.h"
      26             : #include "graphics/GameView.h"
      27             : #include "graphics/Camera.h"
      28             : 
      29           0 : CVector3D AtlasMessage::Position::GetWorldSpace(bool floating) const
      30             : {
      31           0 :     switch (type)
      32             :     {
      33           0 :     case 0:
      34           0 :         return CVector3D(type0.x, type0.y, type0.z);
      35             :         break;
      36             : 
      37           0 :     case 1:
      38           0 :         return g_Game->GetView()->GetCamera()->GetWorldCoordinates(type1.x, type1.y, floating);
      39             :         break;
      40             : 
      41           0 :     case 2:
      42           0 :         debug_warn(L"Invalid Position acquisition (unchanged without previous)");
      43           0 :         return CVector3D(0.f, 0.f, 0.f);
      44             :         break;
      45             : 
      46           0 :     default:
      47           0 :         debug_warn(L"Invalid Position type");
      48           0 :         return CVector3D(0.f, 0.f, 0.f);
      49             :     }
      50             : }
      51             : 
      52           0 : CVector3D AtlasMessage::Position::GetWorldSpace(float h, bool floating) const
      53             : {
      54           0 :     switch (type)
      55             :     {
      56           0 :     case 1:
      57           0 :         return g_Game->GetView()->GetCamera()->GetWorldCoordinates(type1.x, type1.y, h);
      58             : 
      59           0 :     default:
      60           0 :         return GetWorldSpace(floating);
      61             :     }
      62             : }
      63             : 
      64           0 : CVector3D AtlasMessage::Position::GetWorldSpace(const CVector3D& prev, bool floating) const
      65             : {
      66           0 :     switch (type)
      67             :     {
      68           0 :     case 2:
      69           0 :         return prev;
      70             : 
      71           0 :     default:
      72           0 :         return GetWorldSpace(floating);
      73             :     }
      74             : }
      75             : 
      76           0 : void AtlasMessage::Position::GetScreenSpace(float& x, float& y) const
      77             : {
      78           0 :     switch (type)
      79             :     {
      80           0 :     case 0:
      81           0 :         g_Game->GetView()->GetCamera()->GetScreenCoordinates(CVector3D(type0.x, type0.y, type0.x), x, y);
      82           0 :         break;
      83             : 
      84           0 :     case 1:
      85           0 :         x = type1.x;
      86           0 :         y = type1.y;
      87           0 :         break;
      88             : 
      89           0 :     default:
      90           0 :         debug_warn(L"Invalid Position type");
      91           0 :         x = y = 0.f;
      92             :     }
      93           0 : }

Generated by: LCOV version 1.13