RigsofRods
Soft-body Physics Simulation
Replay.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5 
6  For more information, see http://www.rigsofrods.org/
7 
8  Rigs of Rods is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License version 3, as
10  published by the Free Software Foundation.
11 
12  Rigs of Rods is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #pragma once
22 
23 #include "Application.h"
24 
25 namespace RoR {
26 
28 {
29  Ogre::Vector3 position;
30  Ogre::Vector3 velocity;
31 };
32 
34 {
35  bool broken:1;
36  bool disabled:1;
37 };
38 
39 class Replay
40 {
41 public:
42  Replay(ActorPtr b, int nframes);
43  ~Replay();
44 
45  void* getWriteBuffer(int type);
46  void* getReadBuffer(int offset, int type, unsigned long& time);
47  unsigned long getLastReadTime();
48  void writeDone();
49  void onPhysicsStep();
50  void replayStepActor();
51  float getPrecision() const { return ar_replay_precision; }
52  float getReplayPositionSec() const { return ((float)curFrameTime) / 1000000.0f; }
53  int getNumFrames() const { return numFrames; }
54  int getCurrentFrame() const { return ar_replay_pos; }
55  bool isValid() { return numFrames && !outOfMemory; };
56  void UpdateInputEvents();
57 
58 protected:
60  float m_replay_timer = 0.f;
61  float ar_replay_precision = 1.f;
62  int ar_replay_pos = 0;
64  Ogre::Timer* replayTimer = nullptr;
65  int numFrames = 0;
66  bool outOfMemory = false;
67  int writeIndex = 0;
68  int firstRun = 0;
69  unsigned long curFrameTime = 0;
70 
71  // malloc'ed
72  node_simple_t* nodes = nullptr;
73  beam_simple_t* beams = nullptr;
74  unsigned long* times = nullptr;
75 };
76 
77 } // namespace RoR
RoR::Replay::Replay
Replay(ActorPtr b, int nframes)
Definition: Replay.cpp:35
RoR::Replay::m_actor
ActorPtr m_actor
Definition: Replay.h:59
RoR::Replay::replayTimer
Ogre::Timer * replayTimer
Definition: Replay.h:64
RoR::Replay::beams
beam_simple_t * beams
Definition: Replay.h:73
RoR::Replay::replayStepActor
void replayStepActor()
Definition: Replay.cpp:215
RoR::node_simple_t::position
Ogre::Vector3 position
Definition: Replay.h:29
RoR::Replay::outOfMemory
bool outOfMemory
Definition: Replay.h:66
RoR::Replay::writeDone
void writeDone()
Definition: Replay.cpp:134
RoR::beam_simple_t::disabled
bool disabled
Definition: Replay.h:36
RefCountingObjectPtr< Actor >
RoR::Replay::curFrameTime
unsigned long curFrameTime
Definition: Replay.h:69
RoR::Replay::getPrecision
float getPrecision() const
Definition: Replay.h:51
RoR::beam_simple_t
Definition: Replay.h:33
RoR::Replay::firstRun
int firstRun
Definition: Replay.h:68
RoR::Replay::getReadBuffer
void * getReadBuffer(int offset, int type, unsigned long &time)
Definition: Replay.cpp:147
RoR::Replay::m_replay_timer
float m_replay_timer
Definition: Replay.h:60
RoR::Replay
Definition: Replay.h:39
RoR::node_simple_t::velocity
Ogre::Vector3 velocity
Definition: Replay.h:30
Application.h
Central state/object manager and communications hub.
RoR::Replay::getReplayPositionSec
float getReplayPositionSec() const
Definition: Replay.h:52
RoR::Replay::getCurrentFrame
int getCurrentFrame() const
Definition: Replay.h:54
RoR::Replay::getNumFrames
int getNumFrames() const
Definition: Replay.h:53
RoR::Replay::numFrames
int numFrames
Definition: Replay.h:65
RoR::Replay::~Replay
~Replay()
Definition: Replay.cpp:73
RoR::Replay::UpdateInputEvents
void UpdateInputEvents()
Definition: Replay.cpp:251
RoR::Replay::getWriteBuffer
void * getWriteBuffer(int type)
Definition: Replay.cpp:87
RoR::Replay::m_replay_pos_prev
int m_replay_pos_prev
Definition: Replay.h:63
RoR::Replay::writeIndex
int writeIndex
Definition: Replay.h:67
RoR::Replay::onPhysicsStep
void onPhysicsStep()
Definition: Replay.cpp:183
RoR::Replay::getLastReadTime
unsigned long getLastReadTime()
Definition: Replay.cpp:178
RoR::Replay::isValid
bool isValid()
Definition: Replay.h:55
RoR::beam_simple_t::broken
bool broken
Definition: Replay.h:35
RoR::Replay::ar_replay_precision
float ar_replay_precision
Definition: Replay.h:61
RoR::Replay::times
unsigned long * times
Definition: Replay.h:74
RoR::node_simple_t
Definition: Replay.h:27
RoR
Definition: AppContext.h:36
RoR::Replay::nodes
node_simple_t * nodes
Definition: Replay.h:72
RoR::Replay::ar_replay_pos
int ar_replay_pos
Definition: Replay.h:62