Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
//
// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
//
// This software is provided 'as-is', without any express or implied
// warranty.  In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
//    claim that you wrote the original software. If you use this software
//    in a product, an acknowledgment in the product documentation would be
//    appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
//    misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
//

#ifndef DEBUGDRAW_H
#define DEBUGDRAW_H

// Some math headers don't have PI defined.
static const float DU_PI = 3.14159265f;

enum duDebugDrawPrimitives
{
    DU_DRAW_POINTS,
    DU_DRAW_LINES,
    DU_DRAW_TRIS,
    DU_DRAW_QUADS,    
};

/// Abstract debug draw interface.
struct duDebugDraw
{
    virtual ~duDebugDraw() = 0;
    
    virtual void texture(bool state) = 0;

    /// Begin drawing primitives.
    ///  @param prim [in] primitive type to draw, one of rcDebugDrawPrimitives.
    ///  @param size [in] size of a primitive, applies to point size and line width only.
    virtual void begin(duDebugDrawPrimitives prim, float size = 1.0f) = 0;

    /// Submit a vertex
    ///  @param pos [in] position of the verts.
    ///  @param colour [in] colour of the verts.
    virtual void vertex(const float* pos, unsigned int colour) = 0;

    /// Submit a vertex
    ///  @param x,y,z [in] position of the verts.
    ///  @param colour [in] colour of the verts.
    virtual void vertex(const float x, const float y, const float z, unsigned int colour) = 0;

    /// Submit a vertex
    ///  @param pos [in] position of the verts.
    ///  @param colour [in] colour of the verts.
    virtual void vertex(const float* pos, unsigned int colour, const float* uv) = 0;
    
    /// Submit a vertex
    ///  @param x,y,z [in] position of the verts.
    ///  @param colour [in] colour of the verts.
    virtual void vertex(const float x, const float y, const float z, unsigned int colour, const float u, const float v) = 0;
    
    /// End drawing primitives.
    virtual void end() = 0;
};

inline unsigned int duRGBA(int r, int g, int b, int a)
{
    return ((unsigned int)r) | ((unsigned int)g << 8) | ((unsigned int)b << 16) | ((unsigned int)a << 24);
}

inline unsigned int duRGBAf(float fr, float fg, float fb, float fa)
{
    unsigned char r = (unsigned char)(fr*255.0f);
    unsigned char g = (unsigned char)(fg*255.0f);
    unsigned char b = (unsigned char)(fb*255.0f);
    unsigned char a = (unsigned char)(fa*255.0f);
    return duRGBA(r,g,b,a);
}

unsigned int duIntToCol(int i, int a);
void duIntToCol(int i, float* col);

inline unsigned int duMultCol(const unsigned int col, const unsigned int d)
{
    const unsigned int r = col & 0xff;
    const unsigned int g = (col >> 8) & 0xff;
    const unsigned int b = (col >> 16) & 0xff;
    const unsigned int a = (col >> 24) & 0xff;
    return duRGBA((r*d) >> 8, (g*d) >> 8, (b*d) >> 8, a);
}

inline unsigned int duDarkenCol(unsigned int col)
{
    return ((col >> 1) & 0x007f7f7f) | (col & 0xff000000);
}

inline unsigned int duLerpCol(unsigned int ca, unsigned int cb, unsigned int u)
{
    const unsigned int ra = ca & 0xff;
    const unsigned int ga = (ca >> 8) & 0xff;
    const unsigned int ba = (ca >> 16) & 0xff;
    const unsigned int aa = (ca >> 24) & 0xff;
    const unsigned int rb = cb & 0xff;
    const unsigned int gb = (cb >> 8) & 0xff;
    const unsigned int bb = (cb >> 16) & 0xff;
    const unsigned int ab = (cb >> 24) & 0xff;
    
    unsigned int r = (ra*(255-u) + rb*u)/255;
    unsigned int g = (ga*(255-u) + gb*u)/255;
    unsigned int b = (ba*(255-u) + bb*u)/255;
    unsigned int a = (aa*(255-u) + ab*u)/255;
    return duRGBA(r,g,b,a);
}

inline unsigned int duTransCol(unsigned int c, unsigned int a)
{
    return (a<<24) | (c & 0x00ffffff);
}


void duCalcBoxColours(unsigned int* colours, unsigned int colTop, unsigned int colSide);

void duDebugDrawCylinderWire(struct duDebugDraw* dd, float minx, float miny, float minz,
                             float maxx, float maxy, float maxz, unsigned int col, const float lineWidth);

void duDebugDrawBoxWire(struct duDebugDraw* dd, float minx, float miny, float minz,
                        float maxx, float maxy, float maxz, unsigned int col, const float lineWidth);

void duDebugDrawArc(struct duDebugDraw* dd, const float x0, const float y0, const float z0,
                    const float x1, const float y1, const float z1, const float h,
                    const float as0, const float as1, unsigned int col, const float lineWidth);

void duDebugDrawArrow(struct duDebugDraw* dd, const float x0, const float y0, const float z0,
                      const float x1, const float y1, const float z1,
                      const float as0, const float as1, unsigned int col, const float lineWidth);

void duDebugDrawCircle(struct duDebugDraw* dd, const float x, const float y, const float z,
                       const float r, unsigned int col, const float lineWidth);

void duDebugDrawCross(struct duDebugDraw* dd, const float x, const float y, const float z,
                      const float size, unsigned int col, const float lineWidth);

void duDebugDrawBox(struct duDebugDraw* dd, float minx, float miny, float minz,
                    float maxx, float maxy, float maxz, const unsigned int* fcol);

void duDebugDrawCylinder(struct duDebugDraw* dd, float minx, float miny, float minz,
                         float maxx, float maxy, float maxz, unsigned int col);

void duDebugDrawGridXZ(struct duDebugDraw* dd, const float ox, const float oy, const float oz,
                       const int w, const int h, const float size,
                       const unsigned int col, const float lineWidth);


// Versions without begin/end, can be used to draw multiple primitives.
void duAppendCylinderWire(struct duDebugDraw* dd, float minx, float miny, float minz,
                          float maxx, float maxy, float maxz, unsigned int col);

void duAppendBoxWire(struct duDebugDraw* dd, float minx, float miny, float minz,
                     float maxx, float maxy, float maxz, unsigned int col);

void duAppendBoxPoints(struct duDebugDraw* dd, float minx, float miny, float minz,
                       float maxx, float maxy, float maxz, unsigned int col);

void duAppendArc(struct duDebugDraw* dd, const float x0, const float y0, const float z0,
                 const float x1, const float y1, const float z1, const float h,
                 const float as0, const float as1, unsigned int col);

void duAppendArrow(struct duDebugDraw* dd, const float x0, const float y0, const float z0,
                   const float x1, const float y1, const float z1,
                   const float as0, const float as1, unsigned int col);

void duAppendCircle(struct duDebugDraw* dd, const float x, const float y, const float z,
                    const float r, unsigned int col);

void duAppendCross(struct duDebugDraw* dd, const float x, const float y, const float z,
                   const float size, unsigned int col);

void duAppendBox(struct duDebugDraw* dd, float minx, float miny, float minz,
                 float maxx, float maxy, float maxz, const unsigned int* fcol);

void duAppendCylinder(struct duDebugDraw* dd, float minx, float miny, float minz,
                      float maxx, float maxy, float maxz, unsigned int col);


class duDisplayList : public duDebugDraw
{
    float* m_pos;
    unsigned int* m_colour;
    int m_size;
    int m_cap;

    duDebugDrawPrimitives m_prim;
    float m_primSize;
    
    void resize(int cap);
    
public:
    duDisplayList(int cap = 512);
    ~duDisplayList();
    virtual void begin(duDebugDrawPrimitives prim, float size = 1.0f);
    virtual void vertex(const float x, const float y, const float z, unsigned int colour);
    virtual void vertex(const float* pos, unsigned int colour);
    virtual void end();
    void clear();
    void draw(struct duDebugDraw* dd);
};


#endif // DEBUGDRAW_H

Commits for Divide-Framework/trunk/Source Code/Libs/ReCast/DebugUtils/Include/DebugDraw.h

Diff revisions: vs.
Revision Author Commited Message
721 Diff Diff IonutCava picture IonutCava Wed 08 Jun, 2016 15:47:49 +0000

[IonutCava]
- Spelling: change all references from our code of “color” to the PROPER British version of “colour” because it sounds 100x better

617 Diff Diff IonutCava picture IonutCava Tue 05 Jan, 2016 16:47:21 +0000

[IonutCava]
- Depth writing is now a rendering API level toggle instead of a renderstateblock option
- Z-Pre-pass fixes and improvements
- Moved normal render target to the display stage from the pre-pass stage
— Normals are only used in post-processing. This improves pre-pass performance

456 IonutCava picture IonutCava Mon 01 Jun, 2015 16:11:31 +0000

[Ionut]
- More linux port work (does not compile)