Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
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
25namespace RoR {
26
28{
29 Ogre::Vector3 position;
30 Ogre::Vector3 velocity;
31};
32
34{
35 bool broken:1;
36 bool disabled:1;
37};
38
39class Replay
40{
41public:
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
58protected:
60 float m_replay_timer = 0.f;
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
Central state/object manager and communications hub.
beam_simple_t * beams
Definition Replay.h:73
int getCurrentFrame() const
Definition Replay.h:54
float getReplayPositionSec() const
Definition Replay.h:52
int numFrames
Definition Replay.h:65
Ogre::Timer * replayTimer
Definition Replay.h:64
unsigned long curFrameTime
Definition Replay.h:69
void * getWriteBuffer(int type)
Definition Replay.cpp:87
float ar_replay_precision
Definition Replay.h:61
int writeIndex
Definition Replay.h:67
void replayStepActor()
Definition Replay.cpp:215
float getPrecision() const
Definition Replay.h:51
int getNumFrames() const
Definition Replay.h:53
unsigned long getLastReadTime()
Definition Replay.cpp:178
int m_replay_pos_prev
Definition Replay.h:63
void writeDone()
Definition Replay.cpp:134
void onPhysicsStep()
Definition Replay.cpp:183
bool outOfMemory
Definition Replay.h:66
unsigned long * times
Definition Replay.h:74
bool isValid()
Definition Replay.h:55
int firstRun
Definition Replay.h:68
void UpdateInputEvents()
Definition Replay.cpp:251
node_simple_t * nodes
Definition Replay.h:72
ActorPtr m_actor
Definition Replay.h:59
float m_replay_timer
Definition Replay.h:60
int ar_replay_pos
Definition Replay.h:62
void * getReadBuffer(int offset, int type, unsigned long &time)
Definition Replay.cpp:147
Ogre::Vector3 position
Definition Replay.h:29
Ogre::Vector3 velocity
Definition Replay.h:30