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/llprimitive/llvolumemessage.cpp | |
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 'linden/indra/llprimitive/llvolumemessage.cpp')
-rw-r--r-- | linden/indra/llprimitive/llvolumemessage.cpp | 553 |
1 files changed, 553 insertions, 0 deletions
diff --git a/linden/indra/llprimitive/llvolumemessage.cpp b/linden/indra/llprimitive/llvolumemessage.cpp new file mode 100644 index 0000000..cecd2c2 --- /dev/null +++ b/linden/indra/llprimitive/llvolumemessage.cpp | |||
@@ -0,0 +1,553 @@ | |||
1 | /** | ||
2 | * @file llvolumemessage.cpp | ||
3 | * @brief LLVolumeMessage base class | ||
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 | #include "linden_common.h" | ||
29 | |||
30 | #include "message.h" | ||
31 | #include "llvolumemessage.h" | ||
32 | #include "lldatapacker.h" | ||
33 | |||
34 | //============================================================================ | ||
35 | |||
36 | // LLVolumeMessage is just a wrapper class; all members are static | ||
37 | |||
38 | //============================================================================ | ||
39 | |||
40 | bool LLVolumeMessage::packProfileParams( | ||
41 | const LLProfileParams* params, | ||
42 | LLMessageSystem *mesgsys) | ||
43 | { | ||
44 | // Default to cylinder | ||
45 | static LLProfileParams defaultparams(LL_PCODE_PROFILE_CIRCLE, U8(0), U8(0), U8(0)); | ||
46 | |||
47 | if (!params) | ||
48 | params = &defaultparams; | ||
49 | |||
50 | U8 tempU8; | ||
51 | tempU8 = params->getCurveType(); | ||
52 | mesgsys->addU8Fast(_PREHASH_ProfileCurve, tempU8); | ||
53 | |||
54 | tempU8 = (U8) llround( params->getBegin() / CUT_QUANTA); | ||
55 | mesgsys->addU8Fast(_PREHASH_ProfileBegin, tempU8); | ||
56 | |||
57 | tempU8 = 200 - (U8) llround(params->getEnd() / CUT_QUANTA); | ||
58 | mesgsys->addU8Fast(_PREHASH_ProfileEnd, tempU8); | ||
59 | |||
60 | tempU8 = (S8) llround(params->getHollow() / SHEAR_QUANTA); | ||
61 | mesgsys->addU8Fast(_PREHASH_ProfileHollow, tempU8); | ||
62 | |||
63 | return true; | ||
64 | } | ||
65 | |||
66 | bool LLVolumeMessage::packProfileParams( | ||
67 | const LLProfileParams* params, | ||
68 | LLDataPacker &dp) | ||
69 | { | ||
70 | // Default to cylinder | ||
71 | static LLProfileParams defaultparams(LL_PCODE_PROFILE_CIRCLE, U8(0), U8(0), U8(0)); | ||
72 | |||
73 | if (!params) | ||
74 | params = &defaultparams; | ||
75 | |||
76 | U8 tempU8; | ||
77 | tempU8 = params->getCurveType(); | ||
78 | dp.packU8(tempU8, "Curve"); | ||
79 | |||
80 | tempU8 = (U8) llround( params->getBegin() / CUT_QUANTA); | ||
81 | dp.packU8(tempU8, "Begin"); | ||
82 | |||
83 | tempU8 = 200 - (U8) llround(params->getEnd() / CUT_QUANTA); | ||
84 | dp.packU8(tempU8, "End"); | ||
85 | |||
86 | tempU8 = (S8) llround(params->getHollow() / SHEAR_QUANTA); | ||
87 | dp.packU8(tempU8, "Hollow"); | ||
88 | return true; | ||
89 | } | ||
90 | |||
91 | bool LLVolumeMessage::unpackProfileParams( | ||
92 | LLProfileParams* params, | ||
93 | LLMessageSystem* mesgsys, | ||
94 | char* block_name, | ||
95 | S32 block_num) | ||
96 | { | ||
97 | bool ok = true; | ||
98 | U8 temp_u8; | ||
99 | F32 temp_f32; | ||
100 | |||
101 | mesgsys->getU8Fast(block_name, _PREHASH_ProfileCurve, temp_u8, block_num); | ||
102 | params->setCurveType(temp_u8); | ||
103 | |||
104 | mesgsys->getU8Fast(block_name, _PREHASH_ProfileBegin, temp_u8, block_num); | ||
105 | temp_f32 = temp_u8 * CUT_QUANTA; | ||
106 | if (temp_f32 > 1.f) | ||
107 | { | ||
108 | llwarns << "Profile begin out of range: " << temp_f32 | ||
109 | << ". Clamping to 0.0." << llendl; | ||
110 | temp_f32 = 0.f; | ||
111 | ok = false; | ||
112 | } | ||
113 | params->setBegin(temp_f32); | ||
114 | |||
115 | mesgsys->getU8Fast(block_name, _PREHASH_ProfileEnd, temp_u8, block_num); | ||
116 | temp_f32 = temp_u8 * CUT_QUANTA; | ||
117 | if (temp_f32 > 1.f) | ||
118 | { | ||
119 | llwarns << "Profile end out of range: " << 1.f - temp_f32 | ||
120 | << ". Clamping to 1.0." << llendl; | ||
121 | temp_f32 = 1.f; | ||
122 | ok = false; | ||
123 | } | ||
124 | params->setEnd(1.f - temp_f32); | ||
125 | |||
126 | mesgsys->getU8Fast(block_name, _PREHASH_ProfileHollow, temp_u8, block_num); | ||
127 | temp_f32 = temp_u8 * SCALE_QUANTA; | ||
128 | if (temp_f32 > 1.f) | ||
129 | { | ||
130 | llwarns << "Profile hollow out of range: " << temp_f32 | ||
131 | << ". Clamping to 0.0." << llendl; | ||
132 | temp_f32 = 0.f; | ||
133 | ok = false; | ||
134 | } | ||
135 | params->setHollow(temp_f32); | ||
136 | |||
137 | /* | ||
138 | llinfos << "Unpacking Profile Block " << block_num << llendl; | ||
139 | llinfos << "Curve: " << (U32)getCurve() << llendl; | ||
140 | llinfos << "Begin: " << getBegin() << llendl; | ||
141 | llinfos << "End: " << getEnd() << llendl; | ||
142 | llinfos << "Hollow: " << getHollow() << llendl; | ||
143 | */ | ||
144 | return ok; | ||
145 | |||
146 | } | ||
147 | |||
148 | bool LLVolumeMessage::unpackProfileParams( | ||
149 | LLProfileParams* params, | ||
150 | LLDataPacker &dp) | ||
151 | { | ||
152 | bool ok = true; | ||
153 | U8 temp_u8; | ||
154 | F32 temp_f32; | ||
155 | |||
156 | dp.unpackU8(temp_u8, "Curve"); | ||
157 | params->setCurveType(temp_u8); | ||
158 | |||
159 | dp.unpackU8(temp_u8, "Begin"); | ||
160 | temp_f32 = temp_u8 * CUT_QUANTA; | ||
161 | if (temp_f32 > 1.f) | ||
162 | { | ||
163 | llwarns << "Profile begin out of range: " << temp_f32 << llendl; | ||
164 | llwarns << "Clamping to 0.0" << llendl; | ||
165 | temp_f32 = 0.f; | ||
166 | ok = false; | ||
167 | } | ||
168 | params->setBegin(temp_f32); | ||
169 | |||
170 | dp.unpackU8(temp_u8, "End"); | ||
171 | temp_f32 = temp_u8 * CUT_QUANTA; | ||
172 | if (temp_f32 > 1.f) | ||
173 | { | ||
174 | llwarns << "Profile end out of range: " << 1.f - temp_f32 << llendl; | ||
175 | llwarns << "Clamping to 1.0" << llendl; | ||
176 | temp_f32 = 1.f; | ||
177 | ok = false; | ||
178 | } | ||
179 | params->setEnd(1.f - temp_f32); | ||
180 | |||
181 | dp.unpackU8(temp_u8, "Hollow"); | ||
182 | temp_f32 = temp_u8 * SCALE_QUANTA; | ||
183 | if (temp_f32 > 1.f) | ||
184 | { | ||
185 | llwarns << "Profile hollow out of range: " << temp_f32 << llendl; | ||
186 | llwarns << "Clamping to 0.0" << llendl; | ||
187 | temp_f32 = 0.f; | ||
188 | ok = false; | ||
189 | } | ||
190 | params->setHollow(temp_f32); | ||
191 | |||
192 | return ok; | ||
193 | } | ||
194 | |||
195 | //============================================================================ | ||
196 | |||
197 | // Quantization: | ||
198 | // For cut begin, range is 0 to 1, quanta is 0.005, 0 maps to 0 | ||
199 | // For cut end, range is 0 to 1, quanta is 0.005, 1 maps to 0 | ||
200 | // For scale, range is 0 to 1, quanta is 0.01, 0 maps to 0, 1 maps to 100 | ||
201 | // For shear, range is -0.5 to 0.5, quanta is 0.01, 0 maps to 0 | ||
202 | // For taper, range is -1 to 1, quanta is 0.01, 0 maps to 0 | ||
203 | bool LLVolumeMessage::packPathParams( | ||
204 | const LLPathParams* params, | ||
205 | LLMessageSystem *mesgsys) | ||
206 | { | ||
207 | // Default to cylinder with no cut, top same size as bottom, no shear, no twist | ||
208 | static LLPathParams defaultparams(LL_PCODE_PATH_LINE, U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), 0); | ||
209 | if (!params) | ||
210 | params = &defaultparams; | ||
211 | |||
212 | U8 curve = params->getCurveType(); | ||
213 | mesgsys->addU8Fast(_PREHASH_PathCurve, curve); | ||
214 | |||
215 | U8 begin = (U8) llround(params->getBegin() / SCALE_QUANTA); | ||
216 | mesgsys->addU8Fast(_PREHASH_PathBegin, begin); | ||
217 | |||
218 | U8 end = 100 - (U8) llround(params->getEnd() / SCALE_QUANTA); | ||
219 | mesgsys->addU8Fast(_PREHASH_PathEnd, end); | ||
220 | |||
221 | // Avoid truncation problem with direct F32->U8 cast. | ||
222 | // (e.g., (U8) (0.50 / 0.01) = (U8) 49.9999999 = 49 not 50. | ||
223 | |||
224 | U8 pack_scale_x = 200 - (U8) llround(params->getScaleX() / SCALE_QUANTA); | ||
225 | mesgsys->addU8Fast(_PREHASH_PathScaleX, pack_scale_x ); | ||
226 | |||
227 | U8 pack_scale_y = 200 - (U8) llround(params->getScaleY() / SCALE_QUANTA); | ||
228 | mesgsys->addU8Fast(_PREHASH_PathScaleY, pack_scale_y ); | ||
229 | |||
230 | U8 pack_shear_x = (U8) llround(params->getShearX() / SHEAR_QUANTA); | ||
231 | mesgsys->addU8Fast(_PREHASH_PathShearX, pack_shear_x ); | ||
232 | |||
233 | U8 pack_shear_y = (U8) llround(params->getShearY() / SHEAR_QUANTA); | ||
234 | mesgsys->addU8Fast(_PREHASH_PathShearY, pack_shear_y ); | ||
235 | |||
236 | S8 twist = (S8) llround(params->getTwist() / SCALE_QUANTA); | ||
237 | mesgsys->addS8Fast(_PREHASH_PathTwist, twist); | ||
238 | |||
239 | S8 twist_begin = (S8) llround(params->getTwistBegin() / SCALE_QUANTA); | ||
240 | mesgsys->addS8Fast(_PREHASH_PathTwistBegin, twist_begin); | ||
241 | |||
242 | S8 radius_offset = (S8) llround(params->getRadiusOffset() / SCALE_QUANTA); | ||
243 | mesgsys->addS8Fast(_PREHASH_PathRadiusOffset, radius_offset); | ||
244 | |||
245 | S8 taper_x = (S8) llround(params->getTaperX() / TAPER_QUANTA); | ||
246 | mesgsys->addS8Fast(_PREHASH_PathTaperX, taper_x); | ||
247 | |||
248 | S8 taper_y = (S8) llround(params->getTaperY() / TAPER_QUANTA); | ||
249 | mesgsys->addS8Fast(_PREHASH_PathTaperY, taper_y); | ||
250 | |||
251 | U8 revolutions = (U8) llround( (params->getRevolutions() - 1.0f) / REV_QUANTA); | ||
252 | mesgsys->addU8Fast(_PREHASH_PathRevolutions, revolutions); | ||
253 | |||
254 | S8 skew = (S8) llround(params->getSkew() / SCALE_QUANTA); | ||
255 | mesgsys->addS8Fast(_PREHASH_PathSkew, skew); | ||
256 | |||
257 | return true; | ||
258 | } | ||
259 | |||
260 | bool LLVolumeMessage::packPathParams( | ||
261 | const LLPathParams* params, | ||
262 | LLDataPacker &dp) | ||
263 | { | ||
264 | // Default to cylinder with no cut, top same size as bottom, no shear, no twist | ||
265 | static LLPathParams defaultparams(LL_PCODE_PATH_LINE, U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), 0); | ||
266 | if (!params) | ||
267 | params = &defaultparams; | ||
268 | |||
269 | U8 curve = params->getCurveType(); | ||
270 | dp.packU8(curve, "Curve"); | ||
271 | |||
272 | U8 begin = (U8) llround(params->getBegin() / SCALE_QUANTA); | ||
273 | dp.packU8(begin, "Begin"); | ||
274 | |||
275 | U8 end = 100 - (U8) llround(params->getEnd() / SCALE_QUANTA); | ||
276 | dp.packU8(end, "End"); | ||
277 | |||
278 | // Avoid truncation problem with direct F32->U8 cast. | ||
279 | // (e.g., (U8) (0.50 / 0.01) = (U8) 49.9999999 = 49 not 50. | ||
280 | |||
281 | U8 pack_scale_x = 200 - (U8) llround(params->getScaleX() / SCALE_QUANTA); | ||
282 | dp.packU8(pack_scale_x, "ScaleX"); | ||
283 | |||
284 | U8 pack_scale_y = 200 - (U8) llround(params->getScaleY() / SCALE_QUANTA); | ||
285 | dp.packU8(pack_scale_y, "ScaleY"); | ||
286 | |||
287 | S8 pack_shear_x = (S8) llround(params->getShearX() / SHEAR_QUANTA); | ||
288 | dp.packU8(*(U8 *)&pack_shear_x, "ShearX"); | ||
289 | |||
290 | S8 pack_shear_y = (S8) llround(params->getShearY() / SHEAR_QUANTA); | ||
291 | dp.packU8(*(U8 *)&pack_shear_y, "ShearY"); | ||
292 | |||
293 | S8 twist = (S8) llround(params->getTwist() / SCALE_QUANTA); | ||
294 | dp.packU8(*(U8 *)&twist, "Twist"); | ||
295 | |||
296 | S8 twist_begin = (S8) llround(params->getTwistBegin() / SCALE_QUANTA); | ||
297 | dp.packU8(*(U8 *)&twist_begin, "TwistBegin"); | ||
298 | |||
299 | S8 radius_offset = (S8) llround(params->getRadiusOffset() / SCALE_QUANTA); | ||
300 | dp.packU8(*(U8 *)&radius_offset, "RadiusOffset"); | ||
301 | |||
302 | S8 taper_x = (S8) llround(params->getTaperX() / TAPER_QUANTA); | ||
303 | dp.packU8(*(U8 *)&taper_x, "TaperX"); | ||
304 | |||
305 | S8 taper_y = (S8) llround(params->getTaperY() / TAPER_QUANTA); | ||
306 | dp.packU8(*(U8 *)&taper_y, "TaperY"); | ||
307 | |||
308 | U8 revolutions = (U8) llround( (params->getRevolutions() - 1.0f) / REV_QUANTA); | ||
309 | dp.packU8(*(U8 *)&revolutions, "Revolutions"); | ||
310 | |||
311 | S8 skew = (S8) llround(params->getSkew() / SCALE_QUANTA); | ||
312 | dp.packU8(*(U8 *)&skew, "Skew"); | ||
313 | |||
314 | return true; | ||
315 | } | ||
316 | |||
317 | bool LLVolumeMessage::unpackPathParams( | ||
318 | LLPathParams* params, | ||
319 | LLMessageSystem* mesgsys, | ||
320 | char* block_name, | ||
321 | S32 block_num) | ||
322 | { | ||
323 | U8 curve; | ||
324 | mesgsys->getU8Fast(block_name, _PREHASH_PathCurve, curve, block_num); | ||
325 | params->setCurveType(curve); | ||
326 | |||
327 | U8 begin; | ||
328 | mesgsys->getU8Fast(block_name, _PREHASH_PathBegin, begin, block_num); | ||
329 | params->setBegin((F32)(begin * SCALE_QUANTA)); | ||
330 | |||
331 | U8 end; | ||
332 | mesgsys->getU8Fast(block_name, _PREHASH_PathEnd, end, block_num); | ||
333 | params->setEnd((F32)((100 - end) * SCALE_QUANTA)); | ||
334 | |||
335 | U8 pack_scale_x, pack_scale_y; | ||
336 | mesgsys->getU8Fast(block_name, _PREHASH_PathScaleX, pack_scale_x, block_num); | ||
337 | mesgsys->getU8Fast(block_name, _PREHASH_PathScaleY, pack_scale_y, block_num); | ||
338 | F32 x = (F32) (200 - pack_scale_x) * SCALE_QUANTA; | ||
339 | F32 y = (F32) (200 - pack_scale_y) * SCALE_QUANTA; | ||
340 | params->setScale( x, y ); | ||
341 | |||
342 | S8 shear_x_quant, shear_y_quant; | ||
343 | mesgsys->getS8Fast(block_name, _PREHASH_PathShearX, shear_x_quant, block_num); | ||
344 | mesgsys->getS8Fast(block_name, _PREHASH_PathShearY, shear_y_quant, block_num); | ||
345 | F32 shear_x = (F32) shear_x_quant * SHEAR_QUANTA; | ||
346 | F32 shear_y = (F32) shear_y_quant * SHEAR_QUANTA; | ||
347 | params->setShear( shear_x, shear_y ); | ||
348 | |||
349 | S8 twist; | ||
350 | mesgsys->getS8Fast(block_name, _PREHASH_PathTwist, twist, block_num ); | ||
351 | params->setTwist((F32)(twist * SCALE_QUANTA)); | ||
352 | |||
353 | S8 twist_begin; | ||
354 | mesgsys->getS8Fast(block_name, _PREHASH_PathTwistBegin, twist_begin, block_num ); | ||
355 | params->setTwistBegin((F32)(twist_begin * SCALE_QUANTA)); | ||
356 | |||
357 | S8 radius_offset; | ||
358 | mesgsys->getS8Fast(block_name, _PREHASH_PathRadiusOffset, radius_offset, block_num ); | ||
359 | params->setRadiusOffset((F32)(radius_offset * SCALE_QUANTA)); | ||
360 | |||
361 | S8 taper_x_quant, taper_y_quant; | ||
362 | mesgsys->getS8Fast(block_name, _PREHASH_PathTaperX, taper_x_quant, block_num ); | ||
363 | mesgsys->getS8Fast(block_name, _PREHASH_PathTaperY, taper_y_quant, block_num ); | ||
364 | F32 taper_x = (F32)(taper_x_quant * TAPER_QUANTA); | ||
365 | F32 taper_y = (F32)(taper_y_quant * TAPER_QUANTA); | ||
366 | params->setTaper( taper_x, taper_y ); | ||
367 | |||
368 | U8 revolutions; | ||
369 | mesgsys->getU8Fast(block_name, _PREHASH_PathRevolutions, revolutions, block_num ); | ||
370 | params->setRevolutions((F32)(revolutions * REV_QUANTA + 1.0f)); | ||
371 | |||
372 | S8 skew; | ||
373 | mesgsys->getS8Fast(block_name, _PREHASH_PathSkew, skew, block_num ); | ||
374 | params->setSkew((F32)(skew * SCALE_QUANTA)); | ||
375 | |||
376 | /* | ||
377 | llinfos << "Unpacking Path Block " << block_num << llendl; | ||
378 | llinfos << "Curve: " << (U32)params->getCurve() << llendl; | ||
379 | llinfos << "Begin: " << params->getBegin() << llendl; | ||
380 | llinfos << "End: " << params->getEnd() << llendl; | ||
381 | llinfos << "Scale: " << params->getScale() << llendl; | ||
382 | llinfos << "Twist: " << params->getTwist() << llendl; | ||
383 | */ | ||
384 | |||
385 | return true; | ||
386 | |||
387 | } | ||
388 | |||
389 | bool LLVolumeMessage::unpackPathParams(LLPathParams* params, LLDataPacker &dp) | ||
390 | { | ||
391 | U8 value; | ||
392 | S8 svalue; | ||
393 | dp.unpackU8(value, "Curve"); | ||
394 | params->setCurveType( value ); | ||
395 | |||
396 | dp.unpackU8(value, "Begin"); | ||
397 | params->setBegin((F32)(value * SCALE_QUANTA)); | ||
398 | |||
399 | dp.unpackU8(value, "End"); | ||
400 | params->setEnd((F32)((100 - value) * SCALE_QUANTA)); | ||
401 | |||
402 | dp.unpackU8(value, "ScaleX"); | ||
403 | F32 x = (F32) (200 - value) * SCALE_QUANTA; | ||
404 | dp.unpackU8(value, "ScaleY"); | ||
405 | F32 y = (F32) (200 - value) * SCALE_QUANTA; | ||
406 | params->setScale( x, y ); | ||
407 | |||
408 | dp.unpackU8(value, "ShearX"); | ||
409 | svalue = *(S8 *)&value; | ||
410 | F32 shear_x = (F32) svalue * SHEAR_QUANTA; | ||
411 | dp.unpackU8(value, "ShearY"); | ||
412 | svalue = *(S8 *)&value; | ||
413 | F32 shear_y = (F32) svalue * SHEAR_QUANTA; | ||
414 | params->setShear( shear_x, shear_y ); | ||
415 | |||
416 | dp.unpackU8(value, "Twist"); | ||
417 | svalue = *(S8 *)&value; | ||
418 | params->setTwist((F32)(svalue * SCALE_QUANTA)); | ||
419 | |||
420 | dp.unpackU8(value, "TwistBegin"); | ||
421 | svalue = *(S8 *)&value; | ||
422 | params->setTwistBegin((F32)(svalue * SCALE_QUANTA)); | ||
423 | |||
424 | dp.unpackU8(value, "RadiusOffset"); | ||
425 | svalue = *(S8 *)&value; | ||
426 | params->setRadiusOffset((F32)(svalue * SCALE_QUANTA)); | ||
427 | |||
428 | dp.unpackU8(value, "TaperX"); | ||
429 | svalue = *(S8 *)&value; | ||
430 | params->setTaperX((F32)(svalue * TAPER_QUANTA)); | ||
431 | |||
432 | dp.unpackU8(value, "TaperY"); | ||
433 | svalue = *(S8 *)&value; | ||
434 | params->setTaperY((F32)(svalue * TAPER_QUANTA)); | ||
435 | |||
436 | dp.unpackU8(value, "Revolutions"); | ||
437 | params->setRevolutions((F32)(value * REV_QUANTA + 1.0f)); | ||
438 | |||
439 | dp.unpackU8(value, "Skew"); | ||
440 | svalue = *(S8 *)&value; | ||
441 | params->setSkew((F32)(svalue * SCALE_QUANTA)); | ||
442 | |||
443 | return true; | ||
444 | } | ||
445 | |||
446 | //============================================================================ | ||
447 | |||
448 | // static | ||
449 | bool LLVolumeMessage::constrainVolumeParams(LLVolumeParams& params) | ||
450 | { | ||
451 | bool ok = true; | ||
452 | |||
453 | // This is called immediately after an unpack. feed the raw data | ||
454 | // through the checked setters to constraint it to a valid set of | ||
455 | // volume params. | ||
456 | ok &= params.setType( | ||
457 | params.getProfileParams().getCurveType(), | ||
458 | params.getPathParams().getCurveType()); | ||
459 | ok &= params.setBeginAndEndS( | ||
460 | params.getProfileParams().getBegin(), | ||
461 | params.getProfileParams().getEnd()); | ||
462 | ok &= params.setBeginAndEndT( | ||
463 | params.getPathParams().getBegin(), | ||
464 | params.getPathParams().getEnd()); | ||
465 | ok &= params.setHollow(params.getProfileParams().getHollow()); | ||
466 | ok &= params.setTwistBegin(params.getPathParams().getTwistBegin()); | ||
467 | ok &= params.setTwistEnd(params.getPathParams().getTwistEnd()); | ||
468 | ok &= params.setRatio( | ||
469 | params.getPathParams().getScaleX(), | ||
470 | params.getPathParams().getScaleY()); | ||
471 | ok &= params.setShear( | ||
472 | params.getPathParams().getShearX(), | ||
473 | params.getPathParams().getShearY()); | ||
474 | ok &= params.setTaper( | ||
475 | params.getPathParams().getTaperX(), | ||
476 | params.getPathParams().getTaperY()); | ||
477 | ok &= params.setRevolutions(params.getPathParams().getRevolutions()); | ||
478 | ok &= params.setRadiusOffset(params.getPathParams().getRadiusOffset()); | ||
479 | ok &= params.setSkew(params.getPathParams().getSkew()); | ||
480 | if(!ok) | ||
481 | { | ||
482 | llwarns << "LLVolumeMessage::constrainVolumeParams() - " | ||
483 | << "forced to constrain incoming volume params." << llendl; | ||
484 | } | ||
485 | return ok; | ||
486 | } | ||
487 | |||
488 | bool LLVolumeMessage::packVolumeParams(const LLVolumeParams* params, LLMessageSystem *mesgsys) | ||
489 | { | ||
490 | // llinfos << "pack volume" << llendl; | ||
491 | if (params) | ||
492 | { | ||
493 | packPathParams(¶ms->getPathParams(), mesgsys); | ||
494 | packProfileParams(¶ms->getProfileParams(), mesgsys); | ||
495 | } | ||
496 | else | ||
497 | { | ||
498 | packPathParams(0, mesgsys); | ||
499 | packProfileParams(0, mesgsys); | ||
500 | } | ||
501 | return true; | ||
502 | } | ||
503 | |||
504 | bool LLVolumeMessage::packVolumeParams(const LLVolumeParams* params, LLDataPacker &dp) | ||
505 | { | ||
506 | // llinfos << "pack volume" << llendl; | ||
507 | if (params) | ||
508 | { | ||
509 | packPathParams(¶ms->getPathParams(), dp); | ||
510 | packProfileParams(¶ms->getProfileParams(), dp); | ||
511 | } | ||
512 | else | ||
513 | { | ||
514 | packPathParams(0, dp); | ||
515 | packProfileParams(0, dp); | ||
516 | } | ||
517 | return true; | ||
518 | } | ||
519 | |||
520 | bool LLVolumeMessage::unpackVolumeParams( | ||
521 | LLVolumeParams* params, | ||
522 | LLMessageSystem* mesgsys, | ||
523 | char* block_name, | ||
524 | S32 block_num) | ||
525 | { | ||
526 | bool ok = true; | ||
527 | ok &= unpackPathParams( | ||
528 | ¶ms->getPathParams(), | ||
529 | mesgsys, | ||
530 | block_name, | ||
531 | block_num); | ||
532 | ok &= unpackProfileParams( | ||
533 | ¶ms->getProfileParams(), | ||
534 | mesgsys, | ||
535 | block_name, | ||
536 | block_num); | ||
537 | ok &= constrainVolumeParams(*params); | ||
538 | |||
539 | return ok; | ||
540 | } | ||
541 | |||
542 | bool LLVolumeMessage::unpackVolumeParams( | ||
543 | LLVolumeParams* params, | ||
544 | LLDataPacker &dp) | ||
545 | { | ||
546 | bool ok = true; | ||
547 | ok &= unpackPathParams(¶ms->getPathParams(), dp); | ||
548 | ok &= unpackProfileParams(¶ms->getProfileParams(), dp); | ||
549 | ok &= constrainVolumeParams(*params); | ||
550 | return ok; | ||
551 | } | ||
552 | |||
553 | //============================================================================ | ||