Ticket #3301: cinematic_camera_fix.patch

File cinematic_camera_fix.patch, 4.8 KB (added by Vladislav Belov, 8 years ago)

Hide cursor on the cinema playing, target save fix

  • source/graphics/CinemaManager.cpp

     
    3636#include "ps/CStr.h"
    3737#include "ps/Game.h"
    3838#include "ps/Hotkey.h"
     39#include "ps/GameSetup/GameSetup.h"
    3940#include "simulation2/components/ICmpOverlayRenderer.h"
    4041#include "simulation2/components/ICmpRangeManager.h"
    4142#include "simulation2/components/ICmpSelectable.h"
     
    9899    if (m_CinematicSimulationData.m_Enabled == enabled)
    99100        return;
    100101
     102    RenderCursor(!enabled);
     103
    101104    // TODO: Enabling/Disabling does not work if the session GUI page is not the top page.
    102105    // This can happen in various situations, for example when the player wins/looses the game
    103106    // while the cinematic is running (a message box is the top page in this case).
     
    151154    {
    152155        m_CinematicSimulationData.m_Paused = g_Game->m_Paused;
    153156
     157        RenderCursor(g_Game->m_Paused);
     158
    154159        // sn - session gui object
    155160        IGUIObject *sn = g_GUI->FindObjectByName("sn");
    156161
  • source/graphics/CinemaPath.h

     
    126126
    127127    fixed GetTimescale() const { return m_Timescale; }
    128128
    129     TNSpline* getTargetSpline() { return &m_TargetSpline; }
     129    const TNSpline& getTargetSpline() const { return m_TargetSpline; }
    130130
    131131private:
    132132
  • source/graphics/MapWriter.cpp

     
    410410            {
    411411                fixed timescale = it->second.GetTimescale();
    412412                const std::vector<SplineData>& nodes = it->second.GetAllNodes();
     413                const std::vector<SplineData>& target_nodes = it->second.getTargetSpline().GetAllNodes();
    413414                const CCinemaData* data = it->second.GetData();
    414415               
    415416                XML_Element("Path");
     
    419420                XML_Attribute("mode", data->m_Mode);
    420421                XML_Attribute("style", data->m_Style);
    421422
    422                 // TODO: write target nodes
    423                 for (size_t j = 0; j < nodes.size(); ++j)
     423                fixed last_target = fixed::Zero();
     424                for (size_t i = 0, j = 0; i < nodes.size(); ++i)
    424425                {
    425426                    XML_Element("Node");
    426                     if (j > 0)
    427                         XML_Attribute("deltatime", nodes[j - 1].Distance);
     427                    fixed distance;
     428                    if (i > 0)
     429                        distance = nodes[i - 1].Distance;
    428430                    else
    429                         XML_Attribute("deltatime", 0.0f);
    430                    
     431                        distance = fixed::Zero();
     432                    last_target += distance;
     433
     434                    XML_Attribute("deltatime", distance);
     435
    431436                    {
    432437                        XML_Element("Position");
    433                         XML_Attribute("x", nodes[j].Position.X);
    434                         XML_Attribute("y", nodes[j].Position.Y);
    435                         XML_Attribute("z", nodes[j].Position.Z);
     438                        XML_Attribute("x", nodes[i].Position.X);
     439                        XML_Attribute("y", nodes[i].Position.Y);
     440                        XML_Attribute("z", nodes[i].Position.Z);
    436441                    }
    437442
    438443                    {
    439444                        XML_Element("Rotation");
    440                         XML_Attribute("x", nodes[j].Rotation.X);
    441                         XML_Attribute("y", nodes[j].Rotation.Y);
    442                         XML_Attribute("z", nodes[j].Rotation.Z);
     445                        XML_Attribute("x", nodes[i].Rotation.X);
     446                        XML_Attribute("y", nodes[i].Rotation.Y);
     447                        XML_Attribute("z", nodes[i].Rotation.Z);
    443448                    }
     449
     450                    if (j >= target_nodes.size())
     451                        continue;
     452
     453                    fixed target_distance;
     454                    if (j > 0)
     455                        target_distance = target_nodes[j - 1].Distance;
     456                    else
     457                        target_distance = fixed::Zero();
     458
     459                    if (target_distance > last_target)
     460                        continue;
     461
     462                    {
     463                        XML_Element("Target");
     464                        XML_Attribute("x", target_nodes[j].Position.X);
     465                        XML_Attribute("y", target_nodes[j].Position.Y);
     466                        XML_Attribute("z", target_nodes[j].Position.Z);
     467                    }
     468
     469                    last_target = fixed::Zero();
     470                    ++j;
    444471                }
    445472            }
    446473        }
  • source/ps/GameSetup/GameSetup.cpp

     
    11161116
    11171117void RenderCursor(bool RenderingState)
    11181118{
     1119    SDL_ShowCursor(RenderingState);
    11191120    g_DoRenderCursor = RenderingState;
    11201121}
    11211122
  • source/simulation2/components/CCmpCinemaManager.cpp

     
    9696            if (!data->m_LookAtTarget)
    9797                continue;
    9898
    99             const std::vector<SplineData>& targetNodes = path.getTargetSpline()->GetAllNodes();
     99            const std::vector<SplineData>& targetNodes = path.getTargetSpline().GetAllNodes();
    100100            serialize.NumberU32("NumberOfTargetNodes", targetNodes.size(), 1, MAX_SPLINE_NODES);
    101101            for (size_t i = 0; i < targetNodes.size(); ++i)
    102102            {