Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OODebugGLDrawing.h
Go to the documentation of this file.
1/*
2
3OODebugDrawing.h
4
5A set of functions for drawing debug stuff like bounding boxes. These are
6drawn in wireframe without Z buffer reads or writes.
7
8
9Copyright (C) 2007-2013 Jens Ayton and contributors
10
11Permission is hereby granted, free of charge, to any person obtaining a copy
12of this software and associated documentation files (the "Software"), to deal
13in the Software without restriction, including without limitation the rights
14to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15copies of the Software, and to permit persons to whom the Software is
16furnished to do so, subject to the following conditions:
17
18The above copyright notice and this permission notice shall be included in all
19copies or substantial portions of the Software.
20
21THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27SOFTWARE.
28
29*/
30
31#import "OOMaths.h"
32#import "OOColor.h"
33
34
35#if !defined(OODEBUGLDRAWING_DISABLE) && defined(NDEBUG)
36#define OODEBUGLDRAWING_DISABLE 1
37#endif
38
39
40#ifndef OODEBUGLDRAWING_DISABLE
41
42@class OOMaterial;
43
44typedef struct
45{
48
49
52
53OOINLINE void OODebugDrawBoundingBox(BoundingBox box);
54OOINLINE void OODebugDrawBoundingBoxBetween(Vector min, Vector max);
55OOINLINE void OODebugDrawColoredBoundingBox(BoundingBox box, OOColor *color);
56void OODebugDrawColoredBoundingBoxBetween(Vector min, Vector max, OOColor *color);
57
58// Normals are drawn as cyan lines
59OOINLINE void OODebugDrawNormal(Vector position, Vector normal, GLfloat scale);
60OOINLINE void OODebugDrawNormalAtOrigin(Vector normal, GLfloat scale);
61
62// Other vectors are drawn as magenta lines by default
63OOINLINE void OODebugDrawVector(Vector position, Vector v);
64OOINLINE void OODebugDrawColoredVector(Vector position, Vector v, OOColor *color);
67
68// Lines are drawn white by default
69OOINLINE void OODebugDrawLine(Vector start, Vector end);
70void OODebugDrawColoredLine(Vector start, Vector end, OOColor *color);
71
72// Bases are drawn as one red, one green and one blue vector, representing x, y and z axes in the current coordinate frame.
73void OODebugDrawBasis(Vector position, GLfloat scale);
74OOINLINE void OODebugDrawBasisAtOrigin(GLfloat scale);
75
76void OODebugDrawPoint(Vector position, OOColor *color);
77
78
79/*** Only inline definitions beyond this point ***/
80
81OOINLINE void OODebugDrawBoundingBoxBetween(Vector min, Vector max)
82{
83 OODebugDrawColoredBoundingBoxBetween(min, max, [OOColor blueColor]);
84}
85
86
87OOINLINE void OODebugDrawBoundingBox(BoundingBox box)
88{
89 OODebugDrawBoundingBoxBetween(box.min, box.max);
90}
91
92
93OOINLINE void OODebugDrawColoredBoundingBox(BoundingBox box, OOColor *color)
94{
95 OODebugDrawColoredBoundingBoxBetween(box.min, box.max, color);
96}
97
98
99OOINLINE void OODebugDrawNormal(Vector position, Vector normal, GLfloat scale)
100{
101 OODebugDrawColoredVector(position, vector_add(position, vector_multiply_scalar(normal, scale)), [OOColor cyanColor]);
102}
103
104
105OOINLINE void OODebugDrawNormalAtOrigin(Vector normal, GLfloat scale)
106{
107 OODebugDrawNormal(kZeroVector, normal, scale);
108}
109
110
111OOINLINE void OODebugDrawColoredVector(Vector position, Vector v, OOColor *color)
112{
113 OODebugDrawColoredLine(position, vector_add(position, v), color);
114}
115
116
117OOINLINE void OODebugDrawVector(Vector position, Vector v)
118{
119 OODebugDrawColoredVector(position, v, [OOColor magentaColor]);
120}
121
122
127
128
133
134
135OOINLINE void OODebugDrawLine(Vector start, Vector end)
136{
137 OODebugDrawColoredLine(start, end, [OOColor whiteColor]);
138}
139
140
142{
144}
145
146#else // OODEBUGLDRAWING_DISABLE
147
148#define OODRAW_NOOP do {} while (0)
149
150#define OODebugDrawBoundingBox(box) OODRAW_NOOP
151#define OODebugDrawBoundingBoxBetween(min, max) OODRAW_NOOP
152#define OODebugDrawNormal(position, normal, scale) OODRAW_NOOP
153#define OODebugDrawNormalAtOrigin(normal, scale) OODRAW_NOOP
154#define OODebugDrawVector(position, v) OODRAW_NOOP
155#define OODebugDrawColoredVector(position, v, color) OODRAW_NOOP
156#define OODebugDrawVectorAtOrigin(v) OODRAW_NOOP
157#define OODebugDrawColoredVectorAtOrigin(v, color) OODRAW_NOOP
158#define OODebugDrawBasis(position, scale) OODRAW_NOOP
159#define OODebugDrawBasisAtOrigin(scale) OODRAW_NOOP
160
161#endif // OODEBUGLDRAWING_DISABLE
OOINLINE void OODebugDrawBasisAtOrigin(GLfloat scale)
OOINLINE void OODebugDrawColoredVectorAtOrigin(Vector v, OOColor *color)
OOINLINE void OODebugDrawVector(Vector position, Vector v)
void OODebugEndWireframe(OODebugWFState state)
OOINLINE void OODebugDrawNormal(Vector position, Vector normal, GLfloat scale)
OOINLINE void OODebugDrawColoredBoundingBox(BoundingBox box, OOColor *color)
OOINLINE void OODebugDrawBoundingBox(BoundingBox box)
void OODebugDrawColoredLine(Vector start, Vector end, OOColor *color)
OOINLINE void OODebugDrawVectorAtOrigin(Vector v)
OOINLINE void OODebugDrawLine(Vector start, Vector end)
OOINLINE void OODebugDrawNormalAtOrigin(Vector normal, GLfloat scale)
void OODebugDrawBasis(Vector position, GLfloat scale)
void OODebugDrawPoint(Vector position, OOColor *color)
OOINLINE void OODebugDrawColoredVector(Vector position, Vector v, OOColor *color)
void OODebugDrawColoredBoundingBoxBetween(Vector min, Vector max, OOColor *color)
OOINLINE void OODebugDrawBoundingBoxBetween(Vector min, Vector max)
OODebugWFState OODebugBeginWireframe(BOOL ignoreZ)
#define OOINLINE
const Vector kZeroVector
Definition OOVector.m:28
OOMaterial * material