doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DebugGraph.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 #include "../../idlib/precompiled.h"
29 #pragma hdrstop
30 
31 #include "../Game_local.h"
32 
33 /*
34 ================
35 idDebugGraph::idDebugGraph
36 ================
37 */
39  index = 0;
40 }
41 
42 /*
43 ================
44 idDebugGraph::SetNumSamples
45 ================
46 */
48  index = 0;
49  samples.Clear();
50  samples.SetNum( num );
51  memset( samples.Ptr(), 0, samples.MemoryUsed() );
52 }
53 
54 /*
55 ================
56 idDebugGraph::AddValue
57 ================
58 */
60  samples[ index ] = value;
61  index++;
62  if ( index >= samples.Num() ) {
63  index = 0;
64  }
65 }
66 
67 /*
68 ================
69 idDebugGraph::Draw
70 ================
71 */
72 void idDebugGraph::Draw( const idVec4 &color, float scale ) const {
73  int i;
74  float value1;
75  float value2;
76  idVec3 vec1;
77  idVec3 vec2;
78 
79  const idMat3 &axis = gameLocal.GetLocalPlayer()->viewAxis;
80  const idVec3 pos = gameLocal.GetLocalPlayer()->GetPhysics()->GetOrigin() + axis[ 1 ] * samples.Num() * 0.5f;
81 
82  value1 = samples[ index ] * scale;
83  for( i = 1; i < samples.Num(); i++ ) {
84  value2 = samples[ ( i + index ) % samples.Num() ] * scale;
85 
86  vec1 = pos + axis[ 2 ] * value1 - axis[ 1 ] * ( i - 1 ) + axis[ 0 ] * samples.Num();
87  vec2 = pos + axis[ 2 ] * value2 - axis[ 1 ] * i + axis[ 0 ] * samples.Num();
88 
89  gameRenderWorld->DebugLine( color, vec1, vec2, gameLocal.msec, false );
90  value1 = value2;
91  }
92 }
virtual const idVec3 & GetOrigin(int id=0) const =0
idPlayer * GetLocalPlayer() const
byte color[4]
Definition: MegaTexture.cpp:54
GLsizei const GLfloat * value
Definition: glext.h:3614
void SetNum(int newnum, bool resize=true)
Definition: List.h:289
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:4804
Definition: Vector.h:316
type * Ptr(void)
Definition: List.h:596
void Draw(const idVec4 &color, float scale) const
Definition: DebugGraph.cpp:72
int i
Definition: process.py:33
GLuint GLuint num
Definition: glext.h:5390
void SetNumSamples(int num)
Definition: DebugGraph.cpp:47
idMat3 viewAxis
Definition: Actor.h:117
idPhysics * GetPhysics(void) const
Definition: Entity.cpp:2607
virtual void DebugLine(const idVec4 &color, const idVec3 &start, const idVec3 &end, const int lifetime=0, const bool depthTest=false)=0
GLuint index
Definition: glext.h:3476
Definition: Vector.h:808
idGameLocal gameLocal
Definition: Game_local.cpp:64
Definition: Matrix.h:333
void AddValue(float value)
Definition: DebugGraph.cpp:59
int Num(void) const
Definition: List.h:265
idList< float > samples
Definition: DebugGraph.h:37
idRenderWorld * gameRenderWorld
Definition: Game_local.cpp:55
size_t MemoryUsed(void) const
Definition: List.h:252
void Clear(void)
Definition: List.h:184