aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/lldefs.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llcommon/lldefs.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r--linden/indra/llcommon/lldefs.h204
1 files changed, 204 insertions, 0 deletions
diff --git a/linden/indra/llcommon/lldefs.h b/linden/indra/llcommon/lldefs.h
new file mode 100644
index 0000000..2bba4f8
--- /dev/null
+++ b/linden/indra/llcommon/lldefs.h
@@ -0,0 +1,204 @@
1/**
2 * @file lldefs.h
3 * @brief Various generic constant definitions.
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_LLDEFS_H
29#define LL_LLDEFS_H
30
31#include "stdtypes.h"
32
33// Often used array indices
34const U32 VX = 0;
35const U32 VY = 1;
36const U32 VZ = 2;
37const U32 VW = 3;
38const U32 VS = 3;
39
40const U32 VRED = 0;
41const U32 VGREEN = 1;
42const U32 VBLUE = 2;
43const U32 VALPHA = 3;
44
45const U32 INVALID_DIRECTION = 0xFFFFFFFF;
46const U32 EAST = 0;
47const U32 NORTH = 1;
48const U32 WEST = 2;
49const U32 SOUTH = 3;
50
51const U32 NORTHEAST = 4;
52const U32 NORTHWEST = 5;
53const U32 SOUTHWEST = 6;
54const U32 SOUTHEAST = 7;
55const U32 MIDDLE = 8;
56
57const U8 LL_SOUND_FLAG_NONE = 0x00;
58const U8 LL_SOUND_FLAG_LOOP = 0x01;
59const U8 LL_SOUND_FLAG_SYNC_MASTER = 0x02;
60const U8 LL_SOUND_FLAG_SYNC_SLAVE = 0x04;
61const U8 LL_SOUND_FLAG_SYNC_PENDING = 0x08;
62const U8 LL_SOUND_FLAG_SYNC_MASK = LL_SOUND_FLAG_SYNC_MASTER | LL_SOUND_FLAG_SYNC_SLAVE | LL_SOUND_FLAG_SYNC_PENDING;
63const U8 LL_SOUND_FLAG_QUEUE = 0x10;
64
65const U32 gDirOpposite[8] = {2, 3, 0, 1, 6, 7, 4, 5};
66const U32 gDirAdjacent[8][2] = {
67 {4, 7},
68 {4, 5},
69 {5, 6},
70 {6, 7},
71 {0, 1},
72 {1, 2},
73 {2, 3},
74 {0, 3}
75 };
76
77// Magnitude along the x and y axis
78const S32 gDirAxes[8][2] = {
79 { 1, 0}, // east
80 { 0, 1}, // north
81 {-1, 0}, // west
82 { 0,-1}, // south
83 { 1, 1}, // ne
84 {-1, 1}, // nw
85 {-1,-1}, // sw
86 { 1,-1}, // se
87 };
88
89const U8 EAST_MASK = 1;
90const U8 NORTH_MASK = 2;
91const U8 WEST_MASK = 4;
92const U8 SOUTH_MASK = 8;
93const U8 NORTHEAST_MASK = NORTH_MASK | EAST_MASK;
94const U8 NORTHWEST_MASK = NORTH_MASK | WEST_MASK;
95const U8 SOUTHWEST_MASK = SOUTH_MASK | WEST_MASK;
96const U8 SOUTHEAST_MASK = SOUTH_MASK | EAST_MASK;
97
98const S32 gDirMasks[8] = {
99 EAST_MASK,
100 NORTH_MASK,
101 WEST_MASK,
102 SOUTH_MASK,
103 NORTHEAST_MASK,
104 NORTHWEST_MASK,
105 SOUTHWEST_MASK,
106 SOUTHEAST_MASK
107 };
108
109// Sides of a box...
110// . Z __.Y
111// /|\ /| 0 = NO_SIDE
112// | / 1 = FRONT_SIDE = +x
113// +------|-----------+ 2 = BACK_SIDE = -x
114// /| |/ / /| 3 = LEFT_SIDE = +y
115// / | -5- |/ / | 4 = RIGHT_SIDE = -y
116// / | /| -3- / | 5 = TOP_SIDE = +z
117// +------------------+ | 6 = BOTTOM_SIDE = -z
118// | | | / | |
119// | |/| | / | |/|
120// | 2 | | *-------|-1--------> X
121// |/| | -4- |/| |
122// | +----|---------|---+
123// | / / | /
124// | / -6- | /
125// |/ / |/
126// +------------------+
127const U32 NO_SIDE = 0;
128const U32 FRONT_SIDE = 1;
129const U32 BACK_SIDE = 2;
130const U32 LEFT_SIDE = 3;
131const U32 RIGHT_SIDE = 4;
132const U32 TOP_SIDE = 5;
133const U32 BOTTOM_SIDE = 6;
134
135const U32 LL_MAX_PATH = 1024; // buffer size of maximum path + filename string length
136
137// For strings we send in messages
138const U32 STD_STRING_BUF_SIZE = 255; // Buffer size
139const U32 STD_STRING_STR_LEN = 254; // Length of the string (not including \0)
140const U32 MAX_STRING = STD_STRING_BUF_SIZE; // Buffer size
141
142const U32 MAXADDRSTR = 17; // 123.567.901.345 = 15 chars + \0 + 1 for good luck
143
144// C++ is our friend. . . use template functions to make life easier!
145
146// specific inlines for basic types
147//
148// defined for all:
149// llmin(a,b)
150// llmax(a,b)
151// llclamp(a,minimum,maximum)
152//
153// defined for F32, F64:
154// llclampf(a) // clamps a to [0.0 .. 1.0]
155//
156// defined for U16, U32, U64, S16, S32, S64, :
157// llclampb(a) // clamps a to [0 .. 255]
158//
159
160template <class LLDATATYPE>
161inline LLDATATYPE llmax(const LLDATATYPE& d1, const LLDATATYPE& d2)
162{
163 return (d1 > d2) ? d1 : d2;
164}
165
166template <class LLDATATYPE>
167inline LLDATATYPE llmax(const LLDATATYPE& d1, const LLDATATYPE& d2, const LLDATATYPE& d3)
168{
169 LLDATATYPE r = llmax(d1,d2);
170 return (r > d3 ? r : d3);
171}
172
173template <class LLDATATYPE>
174inline LLDATATYPE llmin(const LLDATATYPE& d1, const LLDATATYPE& d2)
175{
176 return (d1 < d2) ? d1 : d2;
177}
178
179template <class LLDATATYPE>
180inline LLDATATYPE llmin(const LLDATATYPE& d1, const LLDATATYPE& d2, const LLDATATYPE& d3)
181{
182 LLDATATYPE r = llmin(d1,d2);
183 return (r < d3 ? r : d3);
184}
185
186template <class LLDATATYPE>
187inline LLDATATYPE llclamp(const LLDATATYPE& a, const LLDATATYPE& minval, const LLDATATYPE& maxval)
188{
189 return llmin(llmax(a, minval), maxval);
190}
191
192template <class LLDATATYPE>
193inline LLDATATYPE llclampf(const LLDATATYPE& a)
194{
195 return llmin(llmax(a, (LLDATATYPE)0), (LLDATATYPE)1);
196}
197
198template <class LLDATATYPE>
199inline LLDATATYPE llclampb(const LLDATATYPE& a)
200{
201 return llmin(llmax(a, (LLDATATYPE)0), (LLDATATYPE)255);
202}
203
204#endif // LL_LLDEFS_H