diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llmessage/partsyspacket.h | |
parent | README.txt (diff) | |
download | meta-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/llmessage/partsyspacket.h | 262 |
1 files changed, 262 insertions, 0 deletions
diff --git a/linden/indra/llmessage/partsyspacket.h b/linden/indra/llmessage/partsyspacket.h new file mode 100644 index 0000000..8e10e56 --- /dev/null +++ b/linden/indra/llmessage/partsyspacket.h | |||
@@ -0,0 +1,262 @@ | |||
1 | /** | ||
2 | * @file partsyspacket.h | ||
3 | * @brief Object for packing particle system initialization parameters | ||
4 | * before sending them over the network | ||
5 | * | ||
6 | * Copyright (c) 2000-2007, Linden Research, Inc. | ||
7 | * | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | #ifndef LL_PARTSYSPACKET_H | ||
30 | #define LL_PARTSYSPACKET_H | ||
31 | |||
32 | #include "lluuid.h" | ||
33 | |||
34 | // Particle system stuff | ||
35 | |||
36 | const U64 PART_SYS_MAX_TIME_IN_USEC = 1000000; // 1 second, die not quite near instantaneously | ||
37 | |||
38 | |||
39 | // this struct is for particle system initialization parameters | ||
40 | // I'm breaking some rules here, but I need a storage structure to hold initialization data | ||
41 | // for these things. Sorry guys, they're not simple enough (yet) to avoid this cleanly | ||
42 | struct LLPartInitData { | ||
43 | // please do not add functions to this class -- data only! | ||
44 | //F32 k[18]; // first 9 --> x,y,z last 9 --> scale, alpha, rot | ||
45 | //F32 kill_p[6]; // last one is for particles that die when they reach a spherical bounding radius | ||
46 | //F32 kill_plane[3]; | ||
47 | //F32 bounce_p[5]; | ||
48 | F32 bounce_b; // recently changed | ||
49 | // no need to store orientation and position here, as they're sent over seperately | ||
50 | //F32 pos_ranges[6]; | ||
51 | //F32 vel_ranges[6]; | ||
52 | F32 scale_range[4]; | ||
53 | F32 alpha_range[4]; | ||
54 | F32 vel_offset[3]; //new - more understandable! | ||
55 | |||
56 | F32 mDistBeginFadeout; // for fadeout LOD optimization | ||
57 | F32 mDistEndFadeout; | ||
58 | |||
59 | LLUUID mImageUuid; | ||
60 | //U8 n; // number of particles | ||
61 | U8 mFlags[8]; // for miscellaneous data --> its interpretation can change at my whim! | ||
62 | U8 createMe; // do I need to be created? or has the work allready been done? | ||
63 | //ActionFlag is now mFlags[PART_SYS_ACTION_BYTE] | ||
64 | //Spawn point is initially object creation center | ||
65 | |||
66 | F32 diffEqAlpha[3]; | ||
67 | F32 diffEqScale[3]; | ||
68 | |||
69 | U8 maxParticles; | ||
70 | //How many particles exist at any time within the system? | ||
71 | U8 initialParticles; | ||
72 | //How many particles exist when the system is created? | ||
73 | F32 killPlaneZ; | ||
74 | //For simplicity assume the XY plane, so this sets an altitude at which to die | ||
75 | F32 killPlaneNormal[3]; | ||
76 | //Normal if not planar XY | ||
77 | F32 bouncePlaneZ; | ||
78 | //For simplicity assume the XY plane, so this sets an altitude at which to bounce | ||
79 | F32 bouncePlaneNormal[3]; | ||
80 | //Normal if not planar XY | ||
81 | F32 spawnRange; | ||
82 | //Range of emission points about the mSpawnPoint | ||
83 | F32 spawnFrequency; | ||
84 | //Required if the system is to spawn new particles. | ||
85 | //This variable determines the time after a particle dies when it is respawned. | ||
86 | F32 spawnFreqencyRange; | ||
87 | //Determines the random range of time until a new particle is spawned. | ||
88 | F32 spawnDirection[3]; | ||
89 | //Direction vector giving the mean direction in which particles are spawned | ||
90 | F32 spawnDirectionRange; | ||
91 | //Direction limiting the angular range of emissions about the mean direction. 1.0f means everywhere, 0.0f means uni-directional | ||
92 | F32 spawnVelocity; | ||
93 | //The mean speed at which particles are emitted | ||
94 | F32 spawnVelocityRange; | ||
95 | //The range of speeds about the mean at which particles are emitted. | ||
96 | F32 speedLimit; | ||
97 | //Used to constrain particle maximum velocity | ||
98 | F32 windWeight; | ||
99 | //How much of an effect does wind have | ||
100 | F32 currentGravity[3]; | ||
101 | //Gravity direction used in update calculations | ||
102 | F32 gravityWeight; | ||
103 | //How much of an effect does gravity have | ||
104 | F32 globalLifetime; | ||
105 | //If particles re-spawn, a system can exist forever. | ||
106 | //If (ActionFlags & PART_SYS_GLOBAL_DIE) is TRUE this variable is used to determine how long the system lasts. | ||
107 | F32 individualLifetime; | ||
108 | //How long does each particle last if nothing else happens to it | ||
109 | F32 individualLifetimeRange; | ||
110 | //Range of variation in individual lifetimes | ||
111 | F32 alphaDecay; | ||
112 | //By what factor does alpha decrease as the lifetime of a particle is approached. | ||
113 | F32 scaleDecay; | ||
114 | //By what factor does scale decrease as the lifetime of a particle is approached. | ||
115 | F32 distanceDeath; | ||
116 | //With the increased functionality, particle systems can expand to indefinite size | ||
117 | //(e.g. wind can chaotically move particles into a wide spread). | ||
118 | //To avoid particles exceeding normal object size constraints, | ||
119 | //set the PART_SYS_DISTANCE_DEATH flag, and set a distance value here, representing a radius around the spawn point. | ||
120 | F32 dampMotionFactor; | ||
121 | //How much to damp motion | ||
122 | F32 windDiffusionFactor[3]; | ||
123 | //Change the size and alpha of particles as wind speed increases (scale gets bigger, alpha smaller) | ||
124 | }; | ||
125 | |||
126 | // constants for setting flag values | ||
127 | // BYTES are in range 0-8, bits are in range 2^0 - 2^8 and can only be powers of two | ||
128 | const int PART_SYS_NO_Z_BUFFER_BYTE = 0; // option to turn off z-buffer when rendering | ||
129 | const int PART_SYS_NO_Z_BUFFER_BIT = 2; // particle systems -- | ||
130 | // I advise against using this, as it looks bad in every case I've tried | ||
131 | |||
132 | const int PART_SYS_SLOW_ANIM_BYTE = 0; // slow animation down by a factor of 10 | ||
133 | const int PART_SYS_SLOW_ANIM_BIT = 1; // useful for tweaking anims during debugging | ||
134 | |||
135 | const int PART_SYS_FOLLOW_VEL_BYTE = 0; // indicates whether to orient sprites towards | ||
136 | const int PART_SYS_FOLLOW_VEL_BIT = 4; // their velocity vector -- default is FALSE | ||
137 | |||
138 | const int PART_SYS_IS_LIGHT_BYTE = 0; // indicates whether a particular particle system | ||
139 | const int PART_SYS_IS_LIGHT_BIT = 8; // is also a light object -- for andrew | ||
140 | // should deprecate this once there is a general method for setting light properties of objects | ||
141 | |||
142 | const int PART_SYS_SPAWN_COPY_BYTE = 0; // indicates whether to spawn baby particle systems on | ||
143 | const int PART_SYS_SPAWN_COPY_BIT = 0x10; // particle death -- intended for smoke trails | ||
144 | |||
145 | const int PART_SYS_COPY_VEL_BYTE = 0; // indicates whether baby particle systems inherit parents vel | ||
146 | const int PART_SYS_COPY_VEL_BIT = 0x20; // (by default they don't) | ||
147 | |||
148 | const int PART_SYS_INVISIBLE_BYTE = 0; // optional -- turn off display, just simulate | ||
149 | const int PART_SYS_INVISIBLE_BIT = 0x40; // useful for smoke trails | ||
150 | |||
151 | const int PART_SYS_ADAPT_TO_FRAMERATE_BYTE = 0; // drop sprites from render call proportionally | ||
152 | const int PART_SYS_ADAPT_TO_FRAMERATE_BIT = 0x80; // to how far we are below 60 fps | ||
153 | |||
154 | |||
155 | // 26 September 2001 - not even big enough to hold all changes, so should enlarge anyway | ||
156 | //const U16 MAX_PART_SYS_PACKET_SIZE = 180; | ||
157 | const U16 MAX_PART_SYS_PACKET_SIZE = 256; | ||
158 | |||
159 | //const U8 PART_SYS_K_MASK = 0x01; | ||
160 | const U8 PART_SYS_KILL_P_MASK = 0x02; | ||
161 | const U8 PART_SYS_BOUNCE_P_MASK = 0x04; | ||
162 | const U8 PART_SYS_BOUNCE_B_MASK = 0x08; | ||
163 | //const U8 PART_SYS_POS_RANGES_MASK = 0x10; | ||
164 | //const U8 PART_SYS_VEL_RANGES_MASK = 0x20; | ||
165 | const U8 PART_SYS_VEL_OFFSET_MASK = 0x10; //re-use one of the original slots now commented out | ||
166 | const U8 PART_SYS_ALPHA_SCALE_DIFF_MASK = 0x20; //re-use one of the original slots now commented out | ||
167 | const U8 PART_SYS_SCALE_RANGE_MASK = 0x40; | ||
168 | const U8 PART_SYS_M_IMAGE_UUID_MASK = 0x80; | ||
169 | const U8 PART_SYS_BYTE_3_ALPHA_MASK = 0x01; // wrapped around, didn't we? | ||
170 | |||
171 | const U8 PART_SYS_BYTE_SPAWN_MASK = 0x01; | ||
172 | const U8 PART_SYS_BYTE_ENVIRONMENT_MASK = 0x02; | ||
173 | const U8 PART_SYS_BYTE_LIFESPAN_MASK = 0x04; | ||
174 | const U8 PART_SYS_BYTE_DECAY_DAMP_MASK = 0x08; | ||
175 | const U8 PART_SYS_BYTE_WIND_DIFF_MASK = 0x10; | ||
176 | |||
177 | |||
178 | // 26 September 2001 - new constants for mActionFlags | ||
179 | const int PART_SYS_ACTION_BYTE = 1; | ||
180 | const U8 PART_SYS_SPAWN = 0x01; | ||
181 | const U8 PART_SYS_BOUNCE = 0x02; | ||
182 | const U8 PART_SYS_AFFECTED_BY_WIND = 0x04; | ||
183 | const U8 PART_SYS_AFFECTED_BY_GRAVITY = 0x08; | ||
184 | const U8 PART_SYS_EVALUATE_WIND_PER_PARTICLE = 0x10; | ||
185 | const U8 PART_SYS_DAMP_MOTION = 0x20; | ||
186 | const U8 PART_SYS_WIND_DIFFUSION = 0x40; | ||
187 | |||
188 | // 26 September 2001 - new constants for mKillFlags | ||
189 | const int PART_SYS_KILL_BYTE = 2; | ||
190 | const U8 PART_SYS_KILL_PLANE = 0x01; | ||
191 | const U8 PART_SYS_GLOBAL_DIE = 0x02; | ||
192 | const U8 PART_SYS_DISTANCE_DEATH = 0x04; | ||
193 | const U8 PART_SYS_TIME_DEATH = 0x08; | ||
194 | |||
195 | |||
196 | // global, because the sim-side also calls it in the LLPartInitDataFactory | ||
197 | |||
198 | |||
199 | void gSetInitDataDefaults(LLPartInitData *setMe); | ||
200 | |||
201 | class LLPartSysCompressedPacket | ||
202 | { | ||
203 | public: | ||
204 | LLPartSysCompressedPacket(); | ||
205 | ~LLPartSysCompressedPacket(); | ||
206 | BOOL fromLLPartInitData(LLPartInitData *in, U32 &bytesUsed); | ||
207 | BOOL toLLPartInitData(LLPartInitData *out, U32 *bytesUsed); | ||
208 | BOOL fromUnsignedBytes(U8 *in, U32 bytesUsed); | ||
209 | BOOL toUnsignedBytes(U8 *out); | ||
210 | U32 bufferSize(); | ||
211 | U8 *getBytePtr(); | ||
212 | |||
213 | protected: | ||
214 | U8 mData[MAX_PART_SYS_PACKET_SIZE]; | ||
215 | U32 mNumBytes; | ||
216 | LLPartInitData mDefaults; // this is intended to hold default LLPartInitData values | ||
217 | // please do not modify it | ||
218 | LLPartInitData mWorkingCopy; // uncompressed data I'm working with | ||
219 | |||
220 | protected: | ||
221 | // private functions (used only to break up code) | ||
222 | void writeFlagByte(LLPartInitData *in); | ||
223 | //U32 writeK(LLPartInitData *in, U32 startByte); | ||
224 | U32 writeKill_p(LLPartInitData *in, U32 startByte); | ||
225 | U32 writeBounce_p(LLPartInitData *in, U32 startByte); | ||
226 | U32 writeBounce_b(LLPartInitData *in, U32 startByte); | ||
227 | //U32 writePos_ranges(LLPartInitData *in, U32 startByte); | ||
228 | //U32 writeVel_ranges(LLPartInitData *in, U32 startByte); | ||
229 | U32 writeAlphaScaleDiffEqn_range(LLPartInitData *in, U32 startByte); | ||
230 | U32 writeScale_range(LLPartInitData *in, U32 startByte); | ||
231 | U32 writeAlpha_range(LLPartInitData *in, U32 startByte); | ||
232 | U32 writeUUID(LLPartInitData *in, U32 startByte); | ||
233 | |||
234 | U32 writeVelocityOffset(LLPartInitData *in, U32 startByte); | ||
235 | U32 writeSpawn(LLPartInitData *in, U32 startByte); //all spawn data | ||
236 | U32 writeEnvironment(LLPartInitData *in, U32 startByte); //wind and gravity | ||
237 | U32 writeLifespan(LLPartInitData *in, U32 startByte); //lifespan data - individual and global | ||
238 | U32 writeDecayDamp(LLPartInitData *in, U32 startByte); //alpha and scale, and motion damp | ||
239 | U32 writeWindDiffusionFactor(LLPartInitData *in, U32 startByte); | ||
240 | |||
241 | |||
242 | //U32 readK(LLPartInitData *in, U32 startByte); | ||
243 | U32 readKill_p(LLPartInitData *in, U32 startByte); | ||
244 | U32 readBounce_p(LLPartInitData *in, U32 startByte); | ||
245 | U32 readBounce_b(LLPartInitData *in, U32 startByte); | ||
246 | //U32 readPos_ranges(LLPartInitData *in, U32 startByte); | ||
247 | //U32 readVel_ranges(LLPartInitData *in, U32 startByte); | ||
248 | U32 readAlphaScaleDiffEqn_range(LLPartInitData *in, U32 startByte); | ||
249 | U32 readScale_range(LLPartInitData *in, U32 startByte); | ||
250 | U32 readAlpha_range(LLPartInitData *in, U32 startByte); | ||
251 | U32 readUUID(LLPartInitData *in, U32 startByte); | ||
252 | |||
253 | U32 readVelocityOffset(LLPartInitData *in, U32 startByte); | ||
254 | U32 readSpawn(LLPartInitData *in, U32 startByte); //all spawn data | ||
255 | U32 readEnvironment(LLPartInitData *in, U32 startByte); //wind and gravity | ||
256 | U32 readLifespan(LLPartInitData *in, U32 startByte); //lifespan data - individual and global | ||
257 | U32 readDecayDamp(LLPartInitData *in, U32 startByte); //alpha and scale, and motion damp | ||
258 | U32 readWindDiffusionFactor(LLPartInitData *in, U32 startByte); | ||
259 | }; | ||
260 | |||
261 | #endif | ||
262 | |||