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/lltextureanim.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 '')
-rw-r--r-- | linden/indra/llprimitive/lltextureanim.cpp | 240 |
1 files changed, 240 insertions, 0 deletions
diff --git a/linden/indra/llprimitive/lltextureanim.cpp b/linden/indra/llprimitive/lltextureanim.cpp new file mode 100644 index 0000000..b496463 --- /dev/null +++ b/linden/indra/llprimitive/lltextureanim.cpp | |||
@@ -0,0 +1,240 @@ | |||
1 | /** | ||
2 | * @file lltextureanim.cpp | ||
3 | * @brief LLTextureAnim 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 "lltextureanim.h" | ||
31 | #include "message.h" | ||
32 | #include "lldatapacker.h" | ||
33 | |||
34 | const S32 TA_BLOCK_SIZE = 16; | ||
35 | |||
36 | LLTextureAnim::LLTextureAnim() | ||
37 | { | ||
38 | reset(); | ||
39 | } | ||
40 | |||
41 | |||
42 | LLTextureAnim::~LLTextureAnim() | ||
43 | { | ||
44 | } | ||
45 | |||
46 | |||
47 | void LLTextureAnim::reset() | ||
48 | { | ||
49 | mMode = 0; | ||
50 | mFace = -1; | ||
51 | mSizeX = 4; | ||
52 | mSizeY = 4; | ||
53 | mStart = 0.f; | ||
54 | mLength = 0.f; | ||
55 | mRate = 1.f; | ||
56 | } | ||
57 | |||
58 | BOOL LLTextureAnim::equals(const LLTextureAnim &other) const | ||
59 | { | ||
60 | if (mMode != other.mMode) | ||
61 | { | ||
62 | return FALSE; | ||
63 | } | ||
64 | if (mFace != other.mFace) | ||
65 | { | ||
66 | return FALSE; | ||
67 | } | ||
68 | if (mSizeX != other.mSizeX) | ||
69 | { | ||
70 | return FALSE; | ||
71 | } | ||
72 | if (mSizeY != other.mSizeY) | ||
73 | { | ||
74 | return FALSE; | ||
75 | } | ||
76 | if (mStart != other.mStart) | ||
77 | { | ||
78 | return FALSE; | ||
79 | } | ||
80 | if (mLength != other.mLength) | ||
81 | { | ||
82 | return FALSE; | ||
83 | } | ||
84 | if (mRate != other.mRate) | ||
85 | { | ||
86 | return FALSE; | ||
87 | } | ||
88 | |||
89 | return TRUE; | ||
90 | } | ||
91 | void LLTextureAnim::packTAMessage(LLMessageSystem *mesgsys) const | ||
92 | { | ||
93 | U8 data[TA_BLOCK_SIZE]; | ||
94 | data[0] = mMode; | ||
95 | data[1] = mFace; | ||
96 | data[2] = mSizeX; | ||
97 | data[3] = mSizeY; | ||
98 | htonmemcpy(data + 4, &mStart, MVT_F32, sizeof(F32)); | ||
99 | htonmemcpy(data + 8, &mLength, MVT_F32, sizeof(F32)); | ||
100 | htonmemcpy(data + 12, &mRate, MVT_F32, sizeof(F32)); | ||
101 | |||
102 | mesgsys->addBinaryDataFast(_PREHASH_TextureAnim, data, TA_BLOCK_SIZE); | ||
103 | } | ||
104 | |||
105 | |||
106 | void LLTextureAnim::packTAMessage(LLDataPacker &dp) const | ||
107 | { | ||
108 | U8 data[TA_BLOCK_SIZE]; | ||
109 | data[0] = mMode; | ||
110 | data[1] = mFace; | ||
111 | data[2] = mSizeX; | ||
112 | data[3] = mSizeY; | ||
113 | htonmemcpy(data + 4, &mStart, MVT_F32, sizeof(F32)); | ||
114 | htonmemcpy(data + 8, &mLength, MVT_F32, sizeof(F32)); | ||
115 | htonmemcpy(data + 12, &mRate, MVT_F32, sizeof(F32)); | ||
116 | |||
117 | dp.packBinaryData(data, TA_BLOCK_SIZE, "TextureAnimation"); | ||
118 | } | ||
119 | |||
120 | |||
121 | void LLTextureAnim::unpackTAMessage(LLMessageSystem *mesgsys, const S32 block_num) | ||
122 | { | ||
123 | S32 size = mesgsys->getSizeFast(_PREHASH_ObjectData, block_num, _PREHASH_TextureAnim); | ||
124 | |||
125 | if (size != TA_BLOCK_SIZE) | ||
126 | { | ||
127 | if (size) | ||
128 | { | ||
129 | llwarns << "Bad size " << size << " for TA block, ignoring." << llendl; | ||
130 | } | ||
131 | mMode = 0; | ||
132 | return; | ||
133 | } | ||
134 | |||
135 | U8 data[TA_BLOCK_SIZE]; | ||
136 | mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_TextureAnim, data, TA_BLOCK_SIZE, block_num); | ||
137 | |||
138 | mMode = data[0]; | ||
139 | mFace = data[1]; | ||
140 | if (mMode & LLTextureAnim::SMOOTH) | ||
141 | { | ||
142 | mSizeX = llmax((U8)0, data[2]); | ||
143 | mSizeY = llmax((U8)0, data[3]); | ||
144 | } | ||
145 | else | ||
146 | { | ||
147 | mSizeX = llmax((U8)1, data[2]); | ||
148 | mSizeY = llmax((U8)1, data[3]); | ||
149 | } | ||
150 | htonmemcpy(&mStart, data + 4, MVT_F32, sizeof(F32)); | ||
151 | htonmemcpy(&mLength, data + 8, MVT_F32, sizeof(F32)); | ||
152 | htonmemcpy(&mRate, data + 12, MVT_F32, sizeof(F32)); | ||
153 | } | ||
154 | |||
155 | void LLTextureAnim::unpackTAMessage(LLDataPacker &dp) | ||
156 | { | ||
157 | S32 size; | ||
158 | U8 data[TA_BLOCK_SIZE]; | ||
159 | dp.unpackBinaryData(data, size, "TextureAnimation"); | ||
160 | if (size != TA_BLOCK_SIZE) | ||
161 | { | ||
162 | if (size) | ||
163 | { | ||
164 | llwarns << "Bad size " << size << " for TA block, ignoring." << llendl; | ||
165 | } | ||
166 | mMode = 0; | ||
167 | return; | ||
168 | } | ||
169 | |||
170 | mMode = data[0]; | ||
171 | mFace = data[1]; | ||
172 | mSizeX = llmax((U8)1, data[2]); | ||
173 | mSizeY = llmax((U8)1, data[3]); | ||
174 | htonmemcpy(&mStart, data + 4, MVT_F32, sizeof(F32)); | ||
175 | htonmemcpy(&mLength, data + 8, MVT_F32, sizeof(F32)); | ||
176 | htonmemcpy(&mRate, data + 12, MVT_F32, sizeof(F32)); | ||
177 | } | ||
178 | |||
179 | LLSD LLTextureAnim::asLLSD() const | ||
180 | { | ||
181 | LLSD sd; | ||
182 | sd["mode"] = mMode; | ||
183 | sd["face"] = mFace; | ||
184 | sd["sizeX"] = mSizeX; | ||
185 | sd["sizeY"] = mSizeY; | ||
186 | sd["start"] = mStart; | ||
187 | sd["length"] = mLength; | ||
188 | sd["rate"] = mRate; | ||
189 | return sd; | ||
190 | } | ||
191 | |||
192 | bool LLTextureAnim::fromLLSD(LLSD& sd) | ||
193 | { | ||
194 | const char *w; | ||
195 | w = "mode"; | ||
196 | if (sd.has(w)) | ||
197 | { | ||
198 | mMode = (U8)sd[w].asInteger(); | ||
199 | } else goto fail; | ||
200 | |||
201 | w = "face"; | ||
202 | if (sd.has(w)) | ||
203 | { | ||
204 | mFace = (S8)sd[w].asInteger(); | ||
205 | } else goto fail; | ||
206 | |||
207 | w = "sizeX"; | ||
208 | if (sd.has(w)) | ||
209 | { | ||
210 | mSizeX = (U8)sd[w].asInteger(); | ||
211 | } else goto fail; | ||
212 | |||
213 | w = "sizeY"; | ||
214 | if (sd.has(w)) | ||
215 | { | ||
216 | mSizeY = (U8)sd[w].asInteger(); | ||
217 | } else goto fail; | ||
218 | |||
219 | w = "start"; | ||
220 | if (sd.has(w)) | ||
221 | { | ||
222 | mStart = (F32)sd[w].asReal(); | ||
223 | } else goto fail; | ||
224 | |||
225 | w = "length"; | ||
226 | if (sd.has(w)) | ||
227 | { | ||
228 | mLength = (F32)sd[w].asReal(); | ||
229 | } else goto fail; | ||
230 | |||
231 | w = "rate"; | ||
232 | if (sd.has(w)) | ||
233 | { | ||
234 | mRate = (F32)sd[w].asReal(); | ||
235 | } else goto fail; | ||
236 | |||
237 | return true; | ||
238 | fail: | ||
239 | return false; | ||
240 | } | ||