Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dual_display.cpp
Go to the documentation of this file.
1 // -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
2 
3 #include "dual_display.h"
4 
5 namespace Radar
6 {
7 
9  : isPaused(false),
10  randomEngine(),
11  randomDistribution(),
12  randomGenerator(randomEngine, randomDistribution),
13  lastRandomNumber(0.0)
14 {
15 }
16 
18 {
19  isPaused = true;
20 }
21 
23 {
24  isPaused = false;
25 }
26 
27 float DualDisplayBase::Jitter(float errorOffset, float errorRange)
28 {
29  if (!isPaused)
30  {
31  lastRandomNumber = randomGenerator();
32  }
33  return errorOffset + errorRange * lastRandomNumber;
34 }
35 
36 void DualDisplayBase::Jitter(float errorOffset, float errorRange, Vector& position)
37 {
38  if (!isPaused)
39  {
40  lastRandomVector = Vector(randomGenerator(), randomGenerator(), randomGenerator());
41  }
42  position.x += (-0.5 * errorOffset + (errorRange * lastRandomVector.x)) * position.x;
43  position.y += (-0.5 * errorOffset + (errorRange * lastRandomVector.y)) * position.y;
44  position.z += (-0.5 * errorOffset + (errorRange * lastRandomVector.z)) * position.z;
45 }
46 
47 } // namespace Radar