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 | |
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')
20 files changed, 5596 insertions, 0 deletions
diff --git a/linden/indra/llprimitive/files.lst b/linden/indra/llprimitive/files.lst new file mode 100644 index 0000000..b9f5dbc --- /dev/null +++ b/linden/indra/llprimitive/files.lst | |||
@@ -0,0 +1,7 @@ | |||
1 | llprimitive/llmaterialtable.cpp | ||
2 | llprimitive/llprimitive.cpp | ||
3 | llprimitive/lltextureanim.cpp | ||
4 | llprimitive/lltextureentry.cpp | ||
5 | llprimitive/lltreeparams.cpp | ||
6 | llprimitive/llvolumemessage.cpp | ||
7 | llprimitive/llvolumexml.cpp | ||
diff --git a/linden/indra/llprimitive/legacy_object_types.h b/linden/indra/llprimitive/legacy_object_types.h new file mode 100644 index 0000000..19af9e6 --- /dev/null +++ b/linden/indra/llprimitive/legacy_object_types.h | |||
@@ -0,0 +1,78 @@ | |||
1 | /** | ||
2 | * @file legacy_object_types.h | ||
3 | * @brief Byte codes for basic object and primitive types | ||
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_LEGACY_OBJECT_TYPES_H | ||
29 | #define LL_LEGACY_OBJECT_TYPES_H | ||
30 | |||
31 | const S8 PLAYER = 'c'; | ||
32 | //const S8 BASIC_SHOT = 's'; | ||
33 | //const S8 BIG_SHOT = 'S'; | ||
34 | //const S8 TREE_SHOT = 'g'; | ||
35 | //const S8 PHYSICAL_BALL = 'b'; | ||
36 | |||
37 | const S8 TREE = 'T'; | ||
38 | const S8 TREE_NEW = 'R'; | ||
39 | //const S8 SPARK = 'p'; | ||
40 | //const S8 SMOKE = 'q'; | ||
41 | //const S8 BOX = 'x'; | ||
42 | //const S8 CYLINDER = 'y'; | ||
43 | //const S8 CONE = 'o'; | ||
44 | //const S8 SPHERE = 'h'; | ||
45 | //const S8 BIRD = 'r'; // ascii 114 | ||
46 | //const S8 ATOR = 'a'; | ||
47 | //const S8 ROCK = 'k'; | ||
48 | |||
49 | const S8 GRASS = 'd'; | ||
50 | const S8 PART_SYS = 'P'; | ||
51 | |||
52 | //const S8 ORACLE = 'O'; | ||
53 | //const S8 TEXTBUBBLE = 't'; // Text bubble to show communication | ||
54 | //const S8 DEMON = 'M'; // Maxwell's demon for scarfing legacy_object_types.h | ||
55 | //const S8 CUBE = 'f'; | ||
56 | //const S8 LSL_TEST = 'L'; | ||
57 | //const S8 PRISM = '1'; | ||
58 | //const S8 PYRAMID = '2'; | ||
59 | //const S8 TETRAHEDRON = '3'; | ||
60 | //const S8 HALF_CYLINDER = '4'; | ||
61 | //const S8 HALF_CONE = '5'; | ||
62 | //const S8 HALF_SPHERE = '6'; | ||
63 | |||
64 | const S8 PRIMITIVE_VOLUME = 'v'; | ||
65 | |||
66 | // Misc constants | ||
67 | |||
68 | //const F32 AVATAR_RADIUS = 0.5f; | ||
69 | //const F32 SHOT_RADIUS = 0.05f; | ||
70 | //const F32 BIG_SHOT_RADIUS = 0.05f; | ||
71 | //const F32 TREE_SIZE = 5.f; | ||
72 | //const F32 BALL_SIZE = 4.f; | ||
73 | |||
74 | //const F32 SHOT_VELOCITY = 100.f; | ||
75 | //const F32 GRENADE_BLAST_RADIUS = 5.f; | ||
76 | |||
77 | #endif | ||
78 | |||
diff --git a/linden/indra/llprimitive/llmaterialtable.cpp b/linden/indra/llprimitive/llmaterialtable.cpp new file mode 100644 index 0000000..201d0c9 --- /dev/null +++ b/linden/indra/llprimitive/llmaterialtable.cpp | |||
@@ -0,0 +1,676 @@ | |||
1 | /** | ||
2 | * @file llmaterialtable.cpp | ||
3 | * @brief Table of material names and IDs for viewer | ||
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 "llmaterialtable.h" | ||
31 | #include "material_codes.h" | ||
32 | #include "sound_ids.h" | ||
33 | #include "imageids.h" | ||
34 | |||
35 | LLMaterialTable LLMaterialTable::basic(1); | ||
36 | |||
37 | F32 const LLMaterialTable::DEFAULT_FRICTION = 0.5f; | ||
38 | F32 const LLMaterialTable::DEFAULT_RESTITUTION = 0.4f; | ||
39 | |||
40 | LLMaterialTable::LLMaterialTable() | ||
41 | { | ||
42 | } | ||
43 | |||
44 | LLMaterialTable::LLMaterialTable(U8 isBasic) | ||
45 | { | ||
46 | initBasicTable(); | ||
47 | } | ||
48 | |||
49 | LLMaterialTable::~LLMaterialTable() | ||
50 | { | ||
51 | if (mCollisionSoundMatrix) | ||
52 | { | ||
53 | delete [] mCollisionSoundMatrix; | ||
54 | mCollisionSoundMatrix = NULL; | ||
55 | } | ||
56 | |||
57 | if (mSlidingSoundMatrix) | ||
58 | { | ||
59 | delete [] mSlidingSoundMatrix; | ||
60 | mSlidingSoundMatrix = NULL; | ||
61 | } | ||
62 | |||
63 | if (mRollingSoundMatrix) | ||
64 | { | ||
65 | delete [] mRollingSoundMatrix; | ||
66 | mRollingSoundMatrix = NULL; | ||
67 | } | ||
68 | |||
69 | mMaterialInfoList.deleteAllData(); | ||
70 | } | ||
71 | |||
72 | void LLMaterialTable::initBasicTable() | ||
73 | { | ||
74 | add(LL_MCODE_STONE,"Stone", LL_DEFAULT_STONE_UUID); | ||
75 | add(LL_MCODE_METAL,"Metal", LL_DEFAULT_METAL_UUID); | ||
76 | add(LL_MCODE_GLASS,"Glass", LL_DEFAULT_GLASS_UUID); | ||
77 | add(LL_MCODE_WOOD,"Wood", LL_DEFAULT_WOOD_UUID); | ||
78 | add(LL_MCODE_FLESH,"Flesh", LL_DEFAULT_FLESH_UUID); | ||
79 | add(LL_MCODE_PLASTIC,"Plastic", LL_DEFAULT_PLASTIC_UUID); | ||
80 | add(LL_MCODE_RUBBER,"Rubber", LL_DEFAULT_RUBBER_UUID); | ||
81 | add(LL_MCODE_LIGHT,"Light", LL_DEFAULT_LIGHT_UUID); | ||
82 | |||
83 | // specify densities for these materials. . . | ||
84 | // these were taken from http://www.mcelwee.net/html/densities_of_various_materials.html | ||
85 | |||
86 | addDensity(LL_MCODE_STONE,30.f); | ||
87 | addDensity(LL_MCODE_METAL,50.f); | ||
88 | addDensity(LL_MCODE_GLASS,20.f); | ||
89 | addDensity(LL_MCODE_WOOD,10.f); | ||
90 | addDensity(LL_MCODE_FLESH,10.f); | ||
91 | addDensity(LL_MCODE_PLASTIC,5.f); | ||
92 | addDensity(LL_MCODE_RUBBER,0.5f); // | ||
93 | addDensity(LL_MCODE_LIGHT,20.f); // | ||
94 | |||
95 | // add damage and energy values | ||
96 | addDamageAndEnergy(LL_MCODE_STONE, 1.f, 1.f, 1.f); // concrete | ||
97 | addDamageAndEnergy(LL_MCODE_METAL, 1.f, 1.f, 1.f); // steel | ||
98 | addDamageAndEnergy(LL_MCODE_GLASS, 1.f, 1.f, 1.f); // borosilicate glass | ||
99 | addDamageAndEnergy(LL_MCODE_WOOD, 1.f, 1.f, 1.f); // southern pine | ||
100 | addDamageAndEnergy(LL_MCODE_FLESH, 1.f, 1.f, 1.f); // saltwater | ||
101 | addDamageAndEnergy(LL_MCODE_PLASTIC, 1.f, 1.f, 1.f); // HDPE | ||
102 | addDamageAndEnergy(LL_MCODE_RUBBER, 1.f, 1.f, 1.f); // | ||
103 | addDamageAndEnergy(LL_MCODE_LIGHT, 1.f, 1.f, 1.f); // | ||
104 | |||
105 | addFriction(LL_MCODE_STONE,0.8f); // concrete | ||
106 | addFriction(LL_MCODE_METAL,0.3f); // steel | ||
107 | addFriction(LL_MCODE_GLASS,0.2f); // borosilicate glass | ||
108 | addFriction(LL_MCODE_WOOD,0.6f); // southern pine | ||
109 | addFriction(LL_MCODE_FLESH,0.9f); // saltwater | ||
110 | addFriction(LL_MCODE_PLASTIC,0.4f); // HDPE | ||
111 | addFriction(LL_MCODE_RUBBER,0.9f); // | ||
112 | addFriction(LL_MCODE_LIGHT,0.2f); // | ||
113 | |||
114 | addRestitution(LL_MCODE_STONE,0.4f); // concrete | ||
115 | addRestitution(LL_MCODE_METAL,0.4f); // steel | ||
116 | addRestitution(LL_MCODE_GLASS,0.7f); // borosilicate glass | ||
117 | addRestitution(LL_MCODE_WOOD,0.5f); // southern pine | ||
118 | addRestitution(LL_MCODE_FLESH,0.3f); // saltwater | ||
119 | addRestitution(LL_MCODE_PLASTIC,0.7f); // HDPE | ||
120 | addRestitution(LL_MCODE_RUBBER,0.9f); // | ||
121 | addRestitution(LL_MCODE_LIGHT,0.7f); // | ||
122 | |||
123 | addShatterSound(LL_MCODE_STONE,LLUUID("ea296329-0f09-4993-af1b-e6784bab1dc9")); | ||
124 | addShatterSound(LL_MCODE_METAL,LLUUID("d1375446-1c4d-470b-9135-30132433b678")); | ||
125 | addShatterSound(LL_MCODE_GLASS,LLUUID("85cda060-b393-48e6-81c8-2cfdfb275351")); | ||
126 | addShatterSound(LL_MCODE_WOOD,LLUUID("6f00669f-15e0-4793-a63e-c03f62fee43a")); | ||
127 | addShatterSound(LL_MCODE_FLESH,LLUUID("2d8c6f51-149e-4e23-8413-93a379b42b67")); | ||
128 | addShatterSound(LL_MCODE_PLASTIC,LLUUID("d55c7f3c-e1c3-4ddc-9eff-9ef805d9190e")); | ||
129 | addShatterSound(LL_MCODE_RUBBER,LLUUID("212b6d1e-8d9c-4986-b3aa-f3c6df8d987d")); | ||
130 | addShatterSound(LL_MCODE_LIGHT,LLUUID("d55c7f3c-e1c3-4ddc-9eff-9ef805d9190e")); | ||
131 | |||
132 | // CollisionSounds | ||
133 | mCollisionSoundMatrix = new LLUUID[LL_MCODE_END*LL_MCODE_END]; | ||
134 | if (mCollisionSoundMatrix) | ||
135 | { | ||
136 | addCollisionSound(LL_MCODE_STONE, LL_MCODE_STONE, SND_STONE_STONE); | ||
137 | addCollisionSound(LL_MCODE_STONE, LL_MCODE_METAL, SND_STONE_METAL); | ||
138 | addCollisionSound(LL_MCODE_STONE, LL_MCODE_GLASS, SND_STONE_GLASS); | ||
139 | addCollisionSound(LL_MCODE_STONE, LL_MCODE_WOOD, SND_STONE_WOOD); | ||
140 | addCollisionSound(LL_MCODE_STONE, LL_MCODE_FLESH, SND_STONE_FLESH); | ||
141 | addCollisionSound(LL_MCODE_STONE, LL_MCODE_PLASTIC, SND_STONE_PLASTIC); | ||
142 | addCollisionSound(LL_MCODE_STONE, LL_MCODE_RUBBER, SND_STONE_RUBBER); | ||
143 | addCollisionSound(LL_MCODE_STONE, LL_MCODE_LIGHT, SND_STONE_PLASTIC); | ||
144 | |||
145 | addCollisionSound(LL_MCODE_METAL, LL_MCODE_METAL, SND_METAL_METAL); | ||
146 | addCollisionSound(LL_MCODE_METAL, LL_MCODE_GLASS, SND_METAL_GLASS); | ||
147 | addCollisionSound(LL_MCODE_METAL, LL_MCODE_WOOD, SND_METAL_WOOD); | ||
148 | addCollisionSound(LL_MCODE_METAL, LL_MCODE_FLESH, SND_METAL_FLESH); | ||
149 | addCollisionSound(LL_MCODE_METAL, LL_MCODE_PLASTIC, SND_METAL_PLASTIC); | ||
150 | addCollisionSound(LL_MCODE_METAL, LL_MCODE_LIGHT, SND_METAL_PLASTIC); | ||
151 | addCollisionSound(LL_MCODE_METAL, LL_MCODE_RUBBER, SND_METAL_RUBBER); | ||
152 | |||
153 | addCollisionSound(LL_MCODE_GLASS, LL_MCODE_GLASS, SND_GLASS_GLASS); | ||
154 | addCollisionSound(LL_MCODE_GLASS, LL_MCODE_WOOD, SND_GLASS_WOOD); | ||
155 | addCollisionSound(LL_MCODE_GLASS, LL_MCODE_FLESH, SND_GLASS_FLESH); | ||
156 | addCollisionSound(LL_MCODE_GLASS, LL_MCODE_PLASTIC, SND_GLASS_PLASTIC); | ||
157 | addCollisionSound(LL_MCODE_GLASS, LL_MCODE_RUBBER, SND_GLASS_RUBBER); | ||
158 | addCollisionSound(LL_MCODE_GLASS, LL_MCODE_LIGHT, SND_GLASS_PLASTIC); | ||
159 | |||
160 | addCollisionSound(LL_MCODE_WOOD, LL_MCODE_WOOD, SND_WOOD_WOOD); | ||
161 | addCollisionSound(LL_MCODE_WOOD, LL_MCODE_FLESH, SND_WOOD_FLESH); | ||
162 | addCollisionSound(LL_MCODE_WOOD, LL_MCODE_PLASTIC, SND_WOOD_PLASTIC); | ||
163 | addCollisionSound(LL_MCODE_WOOD, LL_MCODE_RUBBER, SND_WOOD_RUBBER); | ||
164 | addCollisionSound(LL_MCODE_WOOD, LL_MCODE_LIGHT, SND_WOOD_PLASTIC); | ||
165 | |||
166 | addCollisionSound(LL_MCODE_FLESH, LL_MCODE_FLESH, SND_FLESH_FLESH); | ||
167 | addCollisionSound(LL_MCODE_FLESH, LL_MCODE_PLASTIC, SND_FLESH_PLASTIC); | ||
168 | addCollisionSound(LL_MCODE_FLESH, LL_MCODE_RUBBER, SND_FLESH_RUBBER); | ||
169 | addCollisionSound(LL_MCODE_FLESH, LL_MCODE_LIGHT, SND_FLESH_PLASTIC); | ||
170 | |||
171 | addCollisionSound(LL_MCODE_RUBBER, LL_MCODE_RUBBER, SND_RUBBER_RUBBER); | ||
172 | addCollisionSound(LL_MCODE_RUBBER, LL_MCODE_PLASTIC, SND_RUBBER_PLASTIC); | ||
173 | addCollisionSound(LL_MCODE_RUBBER, LL_MCODE_LIGHT, SND_RUBBER_PLASTIC); | ||
174 | |||
175 | addCollisionSound(LL_MCODE_PLASTIC, LL_MCODE_PLASTIC, SND_PLASTIC_PLASTIC); | ||
176 | addCollisionSound(LL_MCODE_PLASTIC, LL_MCODE_LIGHT, SND_PLASTIC_PLASTIC); | ||
177 | |||
178 | addCollisionSound(LL_MCODE_LIGHT, LL_MCODE_LIGHT, SND_PLASTIC_PLASTIC); | ||
179 | } | ||
180 | |||
181 | // Sliding Sounds | ||
182 | mSlidingSoundMatrix = new LLUUID[LL_MCODE_END*LL_MCODE_END]; | ||
183 | if (mSlidingSoundMatrix) | ||
184 | { | ||
185 | addSlidingSound(LL_MCODE_STONE, LL_MCODE_STONE, SND_SLIDE_STONE_STONE); | ||
186 | addSlidingSound(LL_MCODE_STONE, LL_MCODE_METAL, SND_SLIDE_STONE_STONE_01); | ||
187 | addSlidingSound(LL_MCODE_STONE, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01); | ||
188 | addSlidingSound(LL_MCODE_STONE, LL_MCODE_WOOD, SND_SLIDE_STONE_WOOD); | ||
189 | addSlidingSound(LL_MCODE_STONE, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01); | ||
190 | addSlidingSound(LL_MCODE_STONE, LL_MCODE_PLASTIC, SND_SLIDE_STONE_PLASTIC); | ||
191 | addSlidingSound(LL_MCODE_STONE, LL_MCODE_RUBBER, SND_SLIDE_STONE_RUBBER); | ||
192 | addSlidingSound(LL_MCODE_STONE, LL_MCODE_LIGHT, SND_SLIDE_STONE_PLASTIC); | ||
193 | |||
194 | addSlidingSound(LL_MCODE_METAL, LL_MCODE_METAL, SND_SLIDE_METAL_METAL); | ||
195 | addSlidingSound(LL_MCODE_METAL, LL_MCODE_GLASS, SND_SLIDE_METAL_GLASS); | ||
196 | addSlidingSound(LL_MCODE_METAL, LL_MCODE_WOOD, SND_SLIDE_METAL_WOOD); | ||
197 | addSlidingSound(LL_MCODE_METAL, LL_MCODE_FLESH, SND_SLIDE_METAL_FLESH); | ||
198 | addSlidingSound(LL_MCODE_METAL, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01); | ||
199 | addSlidingSound(LL_MCODE_METAL, LL_MCODE_RUBBER, SND_SLIDE_METAL_RUBBER); | ||
200 | addSlidingSound(LL_MCODE_METAL, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01); | ||
201 | |||
202 | addSlidingSound(LL_MCODE_GLASS, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01); | ||
203 | addSlidingSound(LL_MCODE_GLASS, LL_MCODE_WOOD, SND_SLIDE_STONE_STONE_01); | ||
204 | addSlidingSound(LL_MCODE_GLASS, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01); | ||
205 | addSlidingSound(LL_MCODE_GLASS, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01); | ||
206 | addSlidingSound(LL_MCODE_GLASS, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01); | ||
207 | addSlidingSound(LL_MCODE_GLASS, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01); | ||
208 | |||
209 | addSlidingSound(LL_MCODE_WOOD, LL_MCODE_WOOD, SND_SLIDE_WOOD_WOOD); | ||
210 | addSlidingSound(LL_MCODE_WOOD, LL_MCODE_FLESH, SND_SLIDE_WOOD_FLESH); | ||
211 | addSlidingSound(LL_MCODE_WOOD, LL_MCODE_PLASTIC, SND_SLIDE_WOOD_PLASTIC); | ||
212 | addSlidingSound(LL_MCODE_WOOD, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01); | ||
213 | addSlidingSound(LL_MCODE_WOOD, LL_MCODE_LIGHT, SND_SLIDE_WOOD_PLASTIC); | ||
214 | |||
215 | addSlidingSound(LL_MCODE_FLESH, LL_MCODE_FLESH, SND_SLIDE_FLESH_FLESH); | ||
216 | addSlidingSound(LL_MCODE_FLESH, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01); | ||
217 | addSlidingSound(LL_MCODE_FLESH, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01); | ||
218 | addSlidingSound(LL_MCODE_FLESH, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01); | ||
219 | |||
220 | addSlidingSound(LL_MCODE_RUBBER, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01); | ||
221 | addSlidingSound(LL_MCODE_RUBBER, LL_MCODE_PLASTIC, SND_SLIDE_RUBBER_PLASTIC); | ||
222 | addSlidingSound(LL_MCODE_RUBBER, LL_MCODE_LIGHT, SND_SLIDE_RUBBER_PLASTIC); | ||
223 | |||
224 | addSlidingSound(LL_MCODE_PLASTIC, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01); | ||
225 | addSlidingSound(LL_MCODE_PLASTIC, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01); | ||
226 | |||
227 | addSlidingSound(LL_MCODE_LIGHT, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01); | ||
228 | } | ||
229 | |||
230 | // Rolling Sounds | ||
231 | mRollingSoundMatrix = new LLUUID[LL_MCODE_END*LL_MCODE_END]; | ||
232 | if (mRollingSoundMatrix) | ||
233 | { | ||
234 | addRollingSound(LL_MCODE_STONE, LL_MCODE_STONE, SND_ROLL_STONE_STONE); | ||
235 | addRollingSound(LL_MCODE_STONE, LL_MCODE_METAL, SND_SLIDE_STONE_STONE_01); | ||
236 | addRollingSound(LL_MCODE_STONE, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01); | ||
237 | addRollingSound(LL_MCODE_STONE, LL_MCODE_WOOD, SND_ROLL_STONE_WOOD); | ||
238 | addRollingSound(LL_MCODE_STONE, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01); | ||
239 | addRollingSound(LL_MCODE_STONE, LL_MCODE_PLASTIC, SND_ROLL_STONE_PLASTIC); | ||
240 | addRollingSound(LL_MCODE_STONE, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01); | ||
241 | addRollingSound(LL_MCODE_STONE, LL_MCODE_LIGHT, SND_ROLL_STONE_PLASTIC); | ||
242 | |||
243 | addRollingSound(LL_MCODE_METAL, LL_MCODE_METAL, SND_SLIDE_STONE_STONE_01); | ||
244 | addRollingSound(LL_MCODE_METAL, LL_MCODE_GLASS, SND_ROLL_METAL_GLASS); | ||
245 | addRollingSound(LL_MCODE_METAL, LL_MCODE_WOOD, SND_ROLL_METAL_WOOD); | ||
246 | addRollingSound(LL_MCODE_METAL, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01); | ||
247 | addRollingSound(LL_MCODE_METAL, LL_MCODE_PLASTIC, SND_ROLL_METAL_WOOD); | ||
248 | addRollingSound(LL_MCODE_METAL, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01); | ||
249 | addRollingSound(LL_MCODE_METAL, LL_MCODE_LIGHT, SND_ROLL_METAL_WOOD); | ||
250 | |||
251 | addRollingSound(LL_MCODE_GLASS, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01); | ||
252 | addRollingSound(LL_MCODE_GLASS, LL_MCODE_WOOD, SND_ROLL_GLASS_WOOD); | ||
253 | addRollingSound(LL_MCODE_GLASS, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01); | ||
254 | addRollingSound(LL_MCODE_GLASS, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01); | ||
255 | addRollingSound(LL_MCODE_GLASS, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01); | ||
256 | addRollingSound(LL_MCODE_GLASS, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01); | ||
257 | |||
258 | addRollingSound(LL_MCODE_WOOD, LL_MCODE_WOOD, SND_ROLL_WOOD_WOOD); | ||
259 | addRollingSound(LL_MCODE_WOOD, LL_MCODE_FLESH, SND_ROLL_WOOD_FLESH); | ||
260 | addRollingSound(LL_MCODE_WOOD, LL_MCODE_PLASTIC, SND_ROLL_WOOD_PLASTIC); | ||
261 | addRollingSound(LL_MCODE_WOOD, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01); | ||
262 | addRollingSound(LL_MCODE_WOOD, LL_MCODE_LIGHT, SND_ROLL_WOOD_PLASTIC); | ||
263 | |||
264 | addRollingSound(LL_MCODE_FLESH, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01); | ||
265 | addRollingSound(LL_MCODE_FLESH, LL_MCODE_PLASTIC, SND_ROLL_FLESH_PLASTIC); | ||
266 | addRollingSound(LL_MCODE_FLESH, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01); | ||
267 | addRollingSound(LL_MCODE_FLESH, LL_MCODE_LIGHT, SND_ROLL_FLESH_PLASTIC); | ||
268 | |||
269 | addRollingSound(LL_MCODE_RUBBER, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01); | ||
270 | addRollingSound(LL_MCODE_RUBBER, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01); | ||
271 | addRollingSound(LL_MCODE_RUBBER, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01); | ||
272 | |||
273 | addRollingSound(LL_MCODE_PLASTIC, LL_MCODE_PLASTIC, SND_ROLL_PLASTIC_PLASTIC); | ||
274 | addRollingSound(LL_MCODE_PLASTIC, LL_MCODE_LIGHT, SND_ROLL_PLASTIC_PLASTIC); | ||
275 | |||
276 | addRollingSound(LL_MCODE_LIGHT, LL_MCODE_LIGHT, SND_ROLL_PLASTIC_PLASTIC); | ||
277 | } | ||
278 | } | ||
279 | |||
280 | BOOL LLMaterialTable::add(U8 mcode, char* name, const LLUUID &uuid) | ||
281 | { | ||
282 | LLMaterialInfo *infop; | ||
283 | |||
284 | infop = new LLMaterialInfo(mcode,name,uuid); | ||
285 | if (!infop) return FALSE; | ||
286 | |||
287 | // Add at the end so the order in menus matches the order in this | ||
288 | // file. JNC 11.30.01 | ||
289 | mMaterialInfoList.addDataAtEnd(infop); | ||
290 | |||
291 | return TRUE; | ||
292 | } | ||
293 | |||
294 | BOOL LLMaterialTable::addCollisionSound(U8 mcode, U8 mcode2, const LLUUID &uuid) | ||
295 | { | ||
296 | if (mCollisionSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END)) | ||
297 | { | ||
298 | mCollisionSoundMatrix[mcode * LL_MCODE_END + mcode2] = uuid; | ||
299 | if (mcode != mcode2) | ||
300 | { | ||
301 | mCollisionSoundMatrix[mcode2 * LL_MCODE_END + mcode] = uuid; | ||
302 | } | ||
303 | } | ||
304 | return TRUE; | ||
305 | } | ||
306 | |||
307 | BOOL LLMaterialTable::addSlidingSound(U8 mcode, U8 mcode2, const LLUUID &uuid) | ||
308 | { | ||
309 | if (mSlidingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END)) | ||
310 | { | ||
311 | mSlidingSoundMatrix[mcode * LL_MCODE_END + mcode2] = uuid; | ||
312 | if (mcode != mcode2) | ||
313 | { | ||
314 | mSlidingSoundMatrix[mcode2 * LL_MCODE_END + mcode] = uuid; | ||
315 | } | ||
316 | } | ||
317 | return TRUE; | ||
318 | } | ||
319 | |||
320 | BOOL LLMaterialTable::addRollingSound(U8 mcode, U8 mcode2, const LLUUID &uuid) | ||
321 | { | ||
322 | if (mRollingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END)) | ||
323 | { | ||
324 | mRollingSoundMatrix[mcode * LL_MCODE_END + mcode2] = uuid; | ||
325 | if (mcode != mcode2) | ||
326 | { | ||
327 | mRollingSoundMatrix[mcode2 * LL_MCODE_END + mcode] = uuid; | ||
328 | } | ||
329 | } | ||
330 | return TRUE; | ||
331 | } | ||
332 | |||
333 | BOOL LLMaterialTable::addShatterSound(U8 mcode, const LLUUID &uuid) | ||
334 | { | ||
335 | LLMaterialInfo *infop; | ||
336 | |||
337 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
338 | { | ||
339 | if (mcode == infop->mMCode) | ||
340 | { | ||
341 | infop->mShatterSoundID = uuid; | ||
342 | return TRUE; | ||
343 | } | ||
344 | } | ||
345 | |||
346 | return FALSE; | ||
347 | } | ||
348 | |||
349 | BOOL LLMaterialTable::addDensity(U8 mcode, const F32 &density) | ||
350 | { | ||
351 | LLMaterialInfo *infop; | ||
352 | |||
353 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
354 | { | ||
355 | if (mcode == infop->mMCode) | ||
356 | { | ||
357 | infop->mDensity = density; | ||
358 | return TRUE; | ||
359 | } | ||
360 | } | ||
361 | |||
362 | return FALSE; | ||
363 | } | ||
364 | |||
365 | BOOL LLMaterialTable::addRestitution(U8 mcode, const F32 &restitution) | ||
366 | { | ||
367 | LLMaterialInfo *infop; | ||
368 | |||
369 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
370 | { | ||
371 | if (mcode == infop->mMCode) | ||
372 | { | ||
373 | infop->mRestitution = restitution; | ||
374 | return TRUE; | ||
375 | } | ||
376 | } | ||
377 | |||
378 | return FALSE; | ||
379 | } | ||
380 | |||
381 | BOOL LLMaterialTable::addFriction(U8 mcode, const F32 &friction) | ||
382 | { | ||
383 | LLMaterialInfo *infop; | ||
384 | |||
385 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
386 | { | ||
387 | if (mcode == infop->mMCode) | ||
388 | { | ||
389 | infop->mFriction = friction; | ||
390 | return TRUE; | ||
391 | } | ||
392 | } | ||
393 | |||
394 | return FALSE; | ||
395 | } | ||
396 | |||
397 | BOOL LLMaterialTable::addDamageAndEnergy(U8 mcode, const F32 &hp_mod, const F32 &damage_mod, const F32 &ep_mod) | ||
398 | { | ||
399 | LLMaterialInfo *infop; | ||
400 | |||
401 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
402 | { | ||
403 | if (mcode == infop->mMCode) | ||
404 | { | ||
405 | infop->mHPModifier = hp_mod; | ||
406 | infop->mDamageModifier = damage_mod; | ||
407 | infop->mEPModifier = ep_mod; | ||
408 | return TRUE; | ||
409 | } | ||
410 | } | ||
411 | |||
412 | return FALSE; | ||
413 | } | ||
414 | |||
415 | LLUUID LLMaterialTable::getDefaultTextureID(char* name) | ||
416 | { | ||
417 | LLMaterialInfo *infop; | ||
418 | |||
419 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
420 | { | ||
421 | if (!strcmp(name, infop->mName)) | ||
422 | { | ||
423 | return infop->mDefaultTextureID; | ||
424 | } | ||
425 | } | ||
426 | |||
427 | return LLUUID::null; | ||
428 | } | ||
429 | |||
430 | |||
431 | LLUUID LLMaterialTable::getDefaultTextureID(U8 mcode) | ||
432 | { | ||
433 | LLMaterialInfo *infop; | ||
434 | |||
435 | mcode &= LL_MCODE_MASK; | ||
436 | |||
437 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
438 | { | ||
439 | if (mcode == infop->mMCode) | ||
440 | { | ||
441 | return infop->mDefaultTextureID; | ||
442 | } | ||
443 | } | ||
444 | |||
445 | return LLUUID::null; | ||
446 | } | ||
447 | |||
448 | |||
449 | U8 LLMaterialTable::getMCode(const char* name) | ||
450 | { | ||
451 | LLMaterialInfo *infop; | ||
452 | |||
453 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
454 | { | ||
455 | if (!strcmp(name, infop->mName)) | ||
456 | { | ||
457 | return infop->mMCode; | ||
458 | } | ||
459 | } | ||
460 | |||
461 | return 0; | ||
462 | } | ||
463 | |||
464 | |||
465 | char* LLMaterialTable::getName(U8 mcode) | ||
466 | { | ||
467 | LLMaterialInfo *infop; | ||
468 | |||
469 | mcode &= LL_MCODE_MASK; | ||
470 | |||
471 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
472 | { | ||
473 | if (mcode == infop->mMCode) | ||
474 | { | ||
475 | return infop->mName; | ||
476 | } | ||
477 | } | ||
478 | |||
479 | return NULL; | ||
480 | } | ||
481 | |||
482 | |||
483 | LLUUID LLMaterialTable::getCollisionSoundUUID(U8 mcode, U8 mcode2) | ||
484 | { | ||
485 | mcode &= LL_MCODE_MASK; | ||
486 | mcode2 &= LL_MCODE_MASK; | ||
487 | |||
488 | //llinfos << "code 1: " << ((U32) mcode) << " code 2:" << ((U32) mcode2) << llendl; | ||
489 | if (mCollisionSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END)) | ||
490 | { | ||
491 | return(mCollisionSoundMatrix[mcode * LL_MCODE_END + mcode2]); | ||
492 | } | ||
493 | else | ||
494 | { | ||
495 | //llinfos << "Null Sound" << llendl; | ||
496 | return(SND_NULL); | ||
497 | } | ||
498 | } | ||
499 | |||
500 | LLUUID LLMaterialTable::getSlidingSoundUUID(U8 mcode, U8 mcode2) | ||
501 | { | ||
502 | mcode &= LL_MCODE_MASK; | ||
503 | mcode2 &= LL_MCODE_MASK; | ||
504 | |||
505 | if (mSlidingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END)) | ||
506 | { | ||
507 | return(mSlidingSoundMatrix[mcode * LL_MCODE_END + mcode2]); | ||
508 | } | ||
509 | else | ||
510 | { | ||
511 | return(SND_NULL); | ||
512 | } | ||
513 | } | ||
514 | |||
515 | LLUUID LLMaterialTable::getRollingSoundUUID(U8 mcode, U8 mcode2) | ||
516 | { | ||
517 | mcode &= LL_MCODE_MASK; | ||
518 | mcode2 &= LL_MCODE_MASK; | ||
519 | |||
520 | if (mRollingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END)) | ||
521 | { | ||
522 | return(mRollingSoundMatrix[mcode * LL_MCODE_END + mcode2]); | ||
523 | } | ||
524 | else | ||
525 | { | ||
526 | return(SND_NULL); | ||
527 | } | ||
528 | } | ||
529 | |||
530 | LLUUID LLMaterialTable::getGroundCollisionSoundUUID(U8 mcode) | ||
531 | { | ||
532 | // Create material appropriate sounds for collisions with the ground | ||
533 | // For now, simply return a single sound for all materials | ||
534 | return SND_STONE_DIRT_02; | ||
535 | } | ||
536 | |||
537 | LLUUID LLMaterialTable::getGroundSlidingSoundUUID(U8 mcode) | ||
538 | { | ||
539 | // Create material-specific sound for sliding on ground | ||
540 | // For now, just return a single sound | ||
541 | return SND_SLIDE_STONE_STONE_01; | ||
542 | } | ||
543 | |||
544 | LLUUID LLMaterialTable::getGroundRollingSoundUUID(U8 mcode) | ||
545 | { | ||
546 | // Create material-specific sound for rolling on ground | ||
547 | // For now, just return a single sound | ||
548 | return SND_SLIDE_STONE_STONE_01; | ||
549 | } | ||
550 | |||
551 | LLUUID LLMaterialTable::getCollisionParticleUUID(U8 mcode, U8 mcode2) | ||
552 | { | ||
553 | // Returns an appropriate UUID to use as sprite at collision betweeen objects | ||
554 | // For now, just return a single image | ||
555 | return IMG_SHOT; | ||
556 | } | ||
557 | |||
558 | LLUUID LLMaterialTable::getGroundCollisionParticleUUID(U8 mcode) | ||
559 | { | ||
560 | // Returns an appropriate | ||
561 | // For now, just return a single sound | ||
562 | return IMG_SMOKE_POOF; | ||
563 | } | ||
564 | |||
565 | |||
566 | F32 LLMaterialTable::getDensity(U8 mcode) | ||
567 | { | ||
568 | LLMaterialInfo *infop; | ||
569 | |||
570 | mcode &= LL_MCODE_MASK; | ||
571 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
572 | { | ||
573 | if (mcode == infop->mMCode) | ||
574 | { | ||
575 | return infop->mDensity; | ||
576 | } | ||
577 | } | ||
578 | |||
579 | return 0.f; | ||
580 | } | ||
581 | |||
582 | F32 LLMaterialTable::getRestitution(U8 mcode) | ||
583 | { | ||
584 | LLMaterialInfo *infop; | ||
585 | |||
586 | mcode &= LL_MCODE_MASK; | ||
587 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
588 | { | ||
589 | if (mcode == infop->mMCode) | ||
590 | { | ||
591 | return infop->mRestitution; | ||
592 | } | ||
593 | } | ||
594 | |||
595 | return LLMaterialTable::DEFAULT_RESTITUTION; | ||
596 | } | ||
597 | |||
598 | F32 LLMaterialTable::getFriction(U8 mcode) | ||
599 | { | ||
600 | LLMaterialInfo *infop; | ||
601 | |||
602 | mcode &= LL_MCODE_MASK; | ||
603 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
604 | { | ||
605 | if (mcode == infop->mMCode) | ||
606 | { | ||
607 | return infop->mFriction; | ||
608 | } | ||
609 | } | ||
610 | |||
611 | return LLMaterialTable::DEFAULT_FRICTION; | ||
612 | } | ||
613 | |||
614 | F32 LLMaterialTable::getHPMod(U8 mcode) | ||
615 | { | ||
616 | LLMaterialInfo *infop; | ||
617 | |||
618 | mcode &= LL_MCODE_MASK; | ||
619 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
620 | { | ||
621 | if (mcode == infop->mMCode) | ||
622 | { | ||
623 | return infop->mHPModifier; | ||
624 | } | ||
625 | } | ||
626 | |||
627 | return 1.f; | ||
628 | } | ||
629 | |||
630 | F32 LLMaterialTable::getDamageMod(U8 mcode) | ||
631 | { | ||
632 | LLMaterialInfo *infop; | ||
633 | |||
634 | mcode &= LL_MCODE_MASK; | ||
635 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
636 | { | ||
637 | if (mcode == infop->mMCode) | ||
638 | { | ||
639 | return infop->mDamageModifier; | ||
640 | } | ||
641 | } | ||
642 | |||
643 | return 1.f; | ||
644 | } | ||
645 | |||
646 | F32 LLMaterialTable::getEPMod(U8 mcode) | ||
647 | { | ||
648 | LLMaterialInfo *infop; | ||
649 | |||
650 | mcode &= LL_MCODE_MASK; | ||
651 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
652 | { | ||
653 | if (mcode == infop->mMCode) | ||
654 | { | ||
655 | return infop->mEPModifier; | ||
656 | } | ||
657 | } | ||
658 | |||
659 | return 1.f; | ||
660 | } | ||
661 | |||
662 | LLUUID LLMaterialTable::getShatterSoundUUID(U8 mcode) | ||
663 | { | ||
664 | LLMaterialInfo *infop; | ||
665 | |||
666 | mcode &= LL_MCODE_MASK; | ||
667 | for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() ) | ||
668 | { | ||
669 | if (mcode == infop->mMCode) | ||
670 | { | ||
671 | return infop->mShatterSoundID; | ||
672 | } | ||
673 | } | ||
674 | |||
675 | return SND_NULL; | ||
676 | } | ||
diff --git a/linden/indra/llprimitive/llmaterialtable.h b/linden/indra/llprimitive/llmaterialtable.h new file mode 100644 index 0000000..12be1e9 --- /dev/null +++ b/linden/indra/llprimitive/llmaterialtable.h | |||
@@ -0,0 +1,135 @@ | |||
1 | /** | ||
2 | * @file llmaterialtable.h | ||
3 | * @brief Table of material information for the viewer UI | ||
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_LLMATERIALTABLE_H | ||
29 | #define LL_LLMATERIALTABLE_H | ||
30 | |||
31 | #include "lluuid.h" | ||
32 | #include "linked_lists.h" | ||
33 | #include "llstring.h" | ||
34 | |||
35 | const U32 LLMATERIAL_INFO_NAME_LENGTH = 256; | ||
36 | |||
37 | class LLMaterialInfo | ||
38 | { | ||
39 | public: | ||
40 | U8 mMCode; | ||
41 | char mName[LLMATERIAL_INFO_NAME_LENGTH]; | ||
42 | LLUUID mDefaultTextureID; | ||
43 | LLUUID mShatterSoundID; | ||
44 | F32 mDensity; // kg/m^3 | ||
45 | F32 mFriction; | ||
46 | F32 mRestitution; | ||
47 | |||
48 | // damage and energy constants | ||
49 | F32 mHPModifier; // modifier on mass based HP total | ||
50 | F32 mDamageModifier; // modifier on KE based damage | ||
51 | F32 mEPModifier; // modifier on mass based EP total | ||
52 | |||
53 | LLMaterialInfo(U8 mcode, char* name, const LLUUID &uuid) | ||
54 | { | ||
55 | init(mcode,name,uuid); | ||
56 | }; | ||
57 | |||
58 | void init(U8 mcode, char* name, const LLUUID &uuid) | ||
59 | { | ||
60 | mName[0] = 0; | ||
61 | mDensity = 1000.f; // default to 1000.0 (water) | ||
62 | mHPModifier = 1.f; | ||
63 | mDamageModifier = 1.f; | ||
64 | mEPModifier = 1.f; | ||
65 | |||
66 | mMCode = mcode; | ||
67 | if (name) | ||
68 | { | ||
69 | LLString::copy(mName,name,LLMATERIAL_INFO_NAME_LENGTH); | ||
70 | } | ||
71 | mDefaultTextureID = uuid; | ||
72 | }; | ||
73 | |||
74 | ~LLMaterialInfo() | ||
75 | { | ||
76 | }; | ||
77 | |||
78 | }; | ||
79 | |||
80 | class LLMaterialTable | ||
81 | { | ||
82 | public: | ||
83 | LLLinkedList<LLMaterialInfo> mMaterialInfoList; | ||
84 | LLUUID *mCollisionSoundMatrix; | ||
85 | LLUUID *mSlidingSoundMatrix; | ||
86 | LLUUID *mRollingSoundMatrix; | ||
87 | |||
88 | static const F32 DEFAULT_FRICTION; | ||
89 | static const F32 DEFAULT_RESTITUTION; | ||
90 | |||
91 | public: | ||
92 | LLMaterialTable(); | ||
93 | LLMaterialTable(U8); // cheat with an overloaded constructor to build our basic table | ||
94 | ~LLMaterialTable(); | ||
95 | |||
96 | void initBasicTable(); | ||
97 | |||
98 | BOOL add(U8 mcode, char* name, const LLUUID &uuid); | ||
99 | BOOL addCollisionSound(U8 mcode, U8 mcode2, const LLUUID &uuid); | ||
100 | BOOL addSlidingSound(U8 mcode, U8 mcode2, const LLUUID &uuid); | ||
101 | BOOL addRollingSound(U8 mcode, U8 mcode2, const LLUUID &uuid); | ||
102 | BOOL addShatterSound(U8 mcode, const LLUUID &uuid); | ||
103 | BOOL addDensity(U8 mcode, const F32 &density); | ||
104 | BOOL addFriction(U8 mcode, const F32 &friction); | ||
105 | BOOL addRestitution(U8 mcode, const F32 &restitution); | ||
106 | BOOL addDamageAndEnergy(U8 mcode, const F32 &hp_mod, const F32 &damage_mod, const F32 &ep_mod); | ||
107 | |||
108 | LLUUID getDefaultTextureID(char* name); // LLUUID::null if not found | ||
109 | LLUUID getDefaultTextureID(U8 mcode); // LLUUID::null if not found | ||
110 | U8 getMCode(const char* name); // 0 if not found | ||
111 | char* getName(U8 mcode); | ||
112 | |||
113 | F32 getDensity(U8 mcode); // kg/m^3, 0 if not found | ||
114 | F32 getFriction(U8 mcode); // havok values | ||
115 | F32 getRestitution(U8 mcode); // havok values | ||
116 | F32 getHPMod(U8 mcode); | ||
117 | F32 getDamageMod(U8 mcode); | ||
118 | F32 getEPMod(U8 mcode); | ||
119 | |||
120 | LLUUID getCollisionSoundUUID(U8 mcode, U8 mcode2); | ||
121 | LLUUID getSlidingSoundUUID(U8 mcode, U8 mcode2); | ||
122 | LLUUID getRollingSoundUUID(U8 mcode, U8 mcode2); | ||
123 | LLUUID getShatterSoundUUID(U8 mcode); // LLUUID::null if not found | ||
124 | |||
125 | LLUUID getGroundCollisionSoundUUID(U8 mcode); | ||
126 | LLUUID getGroundSlidingSoundUUID(U8 mcode); | ||
127 | LLUUID getGroundRollingSoundUUID(U8 mcode); | ||
128 | LLUUID getCollisionParticleUUID(U8 mcode, U8 mcode2); | ||
129 | LLUUID getGroundCollisionParticleUUID(U8 mcode); | ||
130 | |||
131 | static LLMaterialTable basic; | ||
132 | }; | ||
133 | |||
134 | #endif | ||
135 | |||
diff --git a/linden/indra/llprimitive/llprimitive.cpp b/linden/indra/llprimitive/llprimitive.cpp new file mode 100644 index 0000000..5fb95c8 --- /dev/null +++ b/linden/indra/llprimitive/llprimitive.cpp | |||
@@ -0,0 +1,1768 @@ | |||
1 | /** | ||
2 | * @file llprimitive.cpp | ||
3 | * @brief LLPrimitive 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 "material_codes.h" | ||
31 | #include "llerror.h" | ||
32 | #include "message.h" | ||
33 | #include "llprimitive.h" | ||
34 | #include "llvolume.h" | ||
35 | #include "legacy_object_types.h" | ||
36 | #include "v4coloru.h" | ||
37 | #include "llvolumemgr.h" | ||
38 | #include "llstring.h" | ||
39 | #include "lldatapacker.h" | ||
40 | |||
41 | /** | ||
42 | * exported constants | ||
43 | */ | ||
44 | |||
45 | const F32 OBJECT_CUT_MIN = 0.f; | ||
46 | const F32 OBJECT_CUT_MAX = 1.f; | ||
47 | const F32 OBJECT_CUT_INC = 0.05f; | ||
48 | const F32 OBJECT_MIN_CUT_INC = 0.02f; | ||
49 | const F32 OBJECT_ROTATION_PRECISION = 0.05f; | ||
50 | |||
51 | const F32 OBJECT_TWIST_MIN = -360.f; | ||
52 | const F32 OBJECT_TWIST_MAX = 360.f; | ||
53 | const F32 OBJECT_TWIST_INC = 18.f; | ||
54 | |||
55 | // This is used for linear paths, | ||
56 | // since twist is used in a slightly different manner. | ||
57 | const F32 OBJECT_TWIST_LINEAR_MIN = -180.f; | ||
58 | const F32 OBJECT_TWIST_LINEAR_MAX = 180.f; | ||
59 | const F32 OBJECT_TWIST_LINEAR_INC = 9.f; | ||
60 | |||
61 | const F32 OBJECT_MIN_HOLE_SIZE = 0.05f; | ||
62 | const F32 OBJECT_MAX_HOLE_SIZE_X = 1.0f; | ||
63 | const F32 OBJECT_MAX_HOLE_SIZE_Y = 0.5f; | ||
64 | |||
65 | // Revolutions parameters. | ||
66 | const F32 OBJECT_REV_MIN = 1.0f; | ||
67 | const F32 OBJECT_REV_MAX = 4.0f; | ||
68 | const F32 OBJECT_REV_INC = 0.1f; | ||
69 | |||
70 | // lights | ||
71 | const F32 LIGHT_MIN_RADIUS = 0.0f; | ||
72 | const F32 LIGHT_DEFAULT_RADIUS = 5.0f; | ||
73 | const F32 LIGHT_MAX_RADIUS = 20.0f; | ||
74 | const F32 LIGHT_MIN_FALLOFF = 0.0f; | ||
75 | const F32 LIGHT_DEFAULT_FALLOFF = 1.0f; | ||
76 | const F32 LIGHT_MAX_FALLOFF = 2.0f; | ||
77 | const F32 LIGHT_MIN_CUTOFF = 0.0f; | ||
78 | const F32 LIGHT_DEFAULT_CUTOFF = 0.0f; | ||
79 | const F32 LIGHT_MAX_CUTOFF = 180.f; | ||
80 | |||
81 | // "Tension" => [0,10], increments of 0.1 | ||
82 | const F32 FLEXIBLE_OBJECT_MIN_TENSION = 0.0f; | ||
83 | const F32 FLEXIBLE_OBJECT_DEFAULT_TENSION = 1.0f; | ||
84 | const F32 FLEXIBLE_OBJECT_MAX_TENSION = 10.0f; | ||
85 | |||
86 | // "Drag" => [0,10], increments of 0.1 | ||
87 | const F32 FLEXIBLE_OBJECT_MIN_AIR_FRICTION = 0.0f; | ||
88 | const F32 FLEXIBLE_OBJECT_DEFAULT_AIR_FRICTION = 2.0f; | ||
89 | const F32 FLEXIBLE_OBJECT_MAX_AIR_FRICTION = 10.0f; | ||
90 | |||
91 | // "Gravity" = [-10,10], increments of 0.1 | ||
92 | const F32 FLEXIBLE_OBJECT_MIN_GRAVITY = -10.0f; | ||
93 | const F32 FLEXIBLE_OBJECT_DEFAULT_GRAVITY = 0.3f; | ||
94 | const F32 FLEXIBLE_OBJECT_MAX_GRAVITY = 10.0f; | ||
95 | |||
96 | // "Wind" = [0,10], increments of 0.1 | ||
97 | const F32 FLEXIBLE_OBJECT_MIN_WIND_SENSITIVITY = 0.0f; | ||
98 | const F32 FLEXIBLE_OBJECT_DEFAULT_WIND_SENSITIVITY = 0.0f; | ||
99 | const F32 FLEXIBLE_OBJECT_MAX_WIND_SENSITIVITY = 10.0f; | ||
100 | |||
101 | // I'll explain later... | ||
102 | const F32 FLEXIBLE_OBJECT_MAX_INTERNAL_TENSION_FORCE = 0.99f; | ||
103 | |||
104 | const F32 FLEXIBLE_OBJECT_DEFAULT_LENGTH = 1.0f; | ||
105 | const BOOL FLEXIBLE_OBJECT_DEFAULT_USING_COLLISION_SPHERE = FALSE; | ||
106 | const BOOL FLEXIBLE_OBJECT_DEFAULT_RENDERING_COLLISION_SPHERE = FALSE; | ||
107 | |||
108 | |||
109 | //=============================================================== | ||
110 | LLPrimitive::LLPrimitive() | ||
111 | { | ||
112 | mPrimitiveCode = 0; | ||
113 | |||
114 | mMaterial = LL_MCODE_STONE; | ||
115 | mVolumep = NULL; | ||
116 | |||
117 | mChanged = UNCHANGED; | ||
118 | |||
119 | mPosition.setVec(0.f,0.f,0.f); | ||
120 | mVelocity.setVec(0.f,0.f,0.f); | ||
121 | mAcceleration.setVec(0.f,0.f,0.f); | ||
122 | |||
123 | mRotation.loadIdentity(); | ||
124 | mAngularVelocity.setVec(0.f,0.f,0.f); | ||
125 | |||
126 | mScale.setVec(1.f,1.f,1.f); | ||
127 | |||
128 | mNumTEs = 0; | ||
129 | mTextureList = NULL; | ||
130 | } | ||
131 | |||
132 | //=============================================================== | ||
133 | LLPrimitive::~LLPrimitive() | ||
134 | { | ||
135 | if (mTextureList) | ||
136 | { | ||
137 | delete [] mTextureList; | ||
138 | mTextureList = NULL; | ||
139 | } | ||
140 | |||
141 | // Cleanup handled by volume manager | ||
142 | if (mVolumep) | ||
143 | { | ||
144 | gVolumeMgr->cleanupVolume(mVolumep); | ||
145 | } | ||
146 | mVolumep = NULL; | ||
147 | } | ||
148 | |||
149 | //=============================================================== | ||
150 | // static | ||
151 | LLPrimitive *LLPrimitive::createPrimitive(LLPCode p_code) | ||
152 | { | ||
153 | LLPrimitive *retval = new LLPrimitive(); | ||
154 | |||
155 | if (retval) | ||
156 | { | ||
157 | retval->init(p_code); | ||
158 | } | ||
159 | else | ||
160 | { | ||
161 | llerrs << "primitive allocation failed" << llendl; | ||
162 | } | ||
163 | |||
164 | return retval; | ||
165 | } | ||
166 | |||
167 | //=============================================================== | ||
168 | void LLPrimitive::init(LLPCode p_code) | ||
169 | { | ||
170 | if (mNumTEs) | ||
171 | { | ||
172 | if (mTextureList) | ||
173 | { | ||
174 | delete [] mTextureList; | ||
175 | } | ||
176 | mTextureList = new LLTextureEntry[mNumTEs]; | ||
177 | } | ||
178 | |||
179 | mPrimitiveCode = p_code; | ||
180 | } | ||
181 | |||
182 | void LLPrimitive::setPCode(const U8 p_code) | ||
183 | { | ||
184 | mPrimitiveCode = p_code; | ||
185 | } | ||
186 | |||
187 | //=============================================================== | ||
188 | const LLTextureEntry * LLPrimitive::getTE(const U8 te_num) const | ||
189 | { | ||
190 | // if we're asking for a non-existent face, return null | ||
191 | if (mNumTEs && (te_num< mNumTEs)) | ||
192 | { | ||
193 | return(&mTextureList[te_num]); | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | return(NULL); | ||
198 | } | ||
199 | } | ||
200 | |||
201 | //=============================================================== | ||
202 | void LLPrimitive::setNumTEs(const U8 num_tes) | ||
203 | { | ||
204 | if (num_tes == mNumTEs) | ||
205 | { | ||
206 | return; | ||
207 | } | ||
208 | |||
209 | // Right now, we don't try and preserve entries when the number of faces | ||
210 | // changes. | ||
211 | |||
212 | if (num_tes) | ||
213 | { | ||
214 | LLTextureEntry *new_tes; | ||
215 | new_tes = new LLTextureEntry[num_tes]; | ||
216 | U32 i; | ||
217 | for (i = 0; i < num_tes; i++) | ||
218 | { | ||
219 | if (i < mNumTEs) | ||
220 | { | ||
221 | new_tes[i] = mTextureList[i]; | ||
222 | } | ||
223 | else if (mNumTEs) | ||
224 | { | ||
225 | new_tes[i] = mTextureList[mNumTEs - 1]; | ||
226 | } | ||
227 | else | ||
228 | { | ||
229 | new_tes[i] = LLTextureEntry(); | ||
230 | } | ||
231 | } | ||
232 | delete[] mTextureList; | ||
233 | mTextureList = new_tes; | ||
234 | } | ||
235 | else | ||
236 | { | ||
237 | delete[] mTextureList; | ||
238 | mTextureList = NULL; | ||
239 | } | ||
240 | |||
241 | |||
242 | mNumTEs = num_tes; | ||
243 | } | ||
244 | |||
245 | //=============================================================== | ||
246 | void LLPrimitive::setAllTETextures(const LLUUID &tex_id) | ||
247 | { | ||
248 | U8 i; | ||
249 | |||
250 | for (i = 0; i < mNumTEs; i++) | ||
251 | { | ||
252 | mTextureList[i].setID(tex_id); | ||
253 | } | ||
254 | } | ||
255 | |||
256 | //=============================================================== | ||
257 | void LLPrimitive::setTE(const U8 index, const LLTextureEntry &te) | ||
258 | { | ||
259 | mTextureList[index] = te; | ||
260 | } | ||
261 | |||
262 | S32 LLPrimitive::setTETexture(const U8 te, const LLUUID &tex_id) | ||
263 | { | ||
264 | // if we're asking for a non-existent face, return null | ||
265 | if (te >= mNumTEs) | ||
266 | { | ||
267 | llwarns << "setting non-existent te " << te << llendl | ||
268 | return 0; | ||
269 | } | ||
270 | |||
271 | return mTextureList[te].setID(tex_id); | ||
272 | } | ||
273 | |||
274 | S32 LLPrimitive::setTEColor(const U8 te, const LLColor4 &color) | ||
275 | { | ||
276 | // if we're asking for a non-existent face, return null | ||
277 | if (te >= mNumTEs) | ||
278 | { | ||
279 | llwarns << "setting non-existent te " << te << llendl | ||
280 | return 0; | ||
281 | } | ||
282 | |||
283 | return mTextureList[te].setColor(color); | ||
284 | } | ||
285 | |||
286 | S32 LLPrimitive::setTEColor(const U8 te, const LLColor3 &color) | ||
287 | { | ||
288 | // if we're asking for a non-existent face, return null | ||
289 | if (te >= mNumTEs) | ||
290 | { | ||
291 | llwarns << "setting non-existent te " << te << llendl | ||
292 | return 0; | ||
293 | } | ||
294 | |||
295 | return mTextureList[te].setColor(color); | ||
296 | } | ||
297 | |||
298 | S32 LLPrimitive::setTEAlpha(const U8 te, const F32 alpha) | ||
299 | { | ||
300 | // if we're asking for a non-existent face, return null | ||
301 | if (te >= mNumTEs) | ||
302 | { | ||
303 | llwarns << "setting non-existent te " << te << llendl | ||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | return mTextureList[te].setAlpha(alpha); | ||
308 | } | ||
309 | |||
310 | //=============================================================== | ||
311 | S32 LLPrimitive::setTEScale(const U8 te, const F32 s, const F32 t) | ||
312 | { | ||
313 | // if we're asking for a non-existent face, return null | ||
314 | if (te >= mNumTEs) | ||
315 | { | ||
316 | llwarns << "Setting nonexistent face" << llendl; | ||
317 | return 0; | ||
318 | } | ||
319 | |||
320 | return mTextureList[te].setScale(s,t); | ||
321 | } | ||
322 | |||
323 | |||
324 | // BUG: slow - done this way because texture entries have some | ||
325 | // voodoo related to texture coords | ||
326 | S32 LLPrimitive::setTEScaleS(const U8 te, const F32 s) | ||
327 | { | ||
328 | if (te >= mNumTEs) | ||
329 | { | ||
330 | llwarns << "Setting nonexistent face" << llendl; | ||
331 | return 0; | ||
332 | } | ||
333 | |||
334 | F32 ignore, t; | ||
335 | mTextureList[te].getScale(&ignore, &t); | ||
336 | return mTextureList[te].setScale(s,t); | ||
337 | } | ||
338 | |||
339 | |||
340 | // BUG: slow - done this way because texture entries have some | ||
341 | // voodoo related to texture coords | ||
342 | S32 LLPrimitive::setTEScaleT(const U8 te, const F32 t) | ||
343 | { | ||
344 | if (te >= mNumTEs) | ||
345 | { | ||
346 | llwarns << "Setting nonexistent face" << llendl; | ||
347 | return 0; | ||
348 | } | ||
349 | |||
350 | F32 s, ignore; | ||
351 | mTextureList[te].getScale(&s, &ignore); | ||
352 | return mTextureList[te].setScale(s,t); | ||
353 | } | ||
354 | |||
355 | |||
356 | //=============================================================== | ||
357 | S32 LLPrimitive::setTEOffset(const U8 te, const F32 s, const F32 t) | ||
358 | { | ||
359 | // if we're asking for a non-existent face, return null | ||
360 | if (te >= mNumTEs) | ||
361 | { | ||
362 | llwarns << "Setting nonexistent face" << llendl; | ||
363 | return 0; | ||
364 | } | ||
365 | |||
366 | return mTextureList[te].setOffset(s,t); | ||
367 | } | ||
368 | |||
369 | |||
370 | // BUG: slow - done this way because texture entries have some | ||
371 | // voodoo related to texture coords | ||
372 | S32 LLPrimitive::setTEOffsetS(const U8 te, const F32 s) | ||
373 | { | ||
374 | if (te >= mNumTEs) | ||
375 | { | ||
376 | llwarns << "Setting nonexistent face" << llendl; | ||
377 | return 0; | ||
378 | } | ||
379 | |||
380 | F32 ignore, t; | ||
381 | mTextureList[te].getOffset(&ignore, &t); | ||
382 | return mTextureList[te].setOffset(s,t); | ||
383 | } | ||
384 | |||
385 | |||
386 | // BUG: slow - done this way because texture entries have some | ||
387 | // voodoo related to texture coords | ||
388 | S32 LLPrimitive::setTEOffsetT(const U8 te, const F32 t) | ||
389 | { | ||
390 | if (te >= mNumTEs) | ||
391 | { | ||
392 | llwarns << "Setting nonexistent face" << llendl; | ||
393 | return 0; | ||
394 | } | ||
395 | |||
396 | F32 s, ignore; | ||
397 | mTextureList[te].getOffset(&s, &ignore); | ||
398 | return mTextureList[te].setOffset(s,t); | ||
399 | } | ||
400 | |||
401 | |||
402 | //=============================================================== | ||
403 | S32 LLPrimitive::setTERotation(const U8 te, const F32 r) | ||
404 | { | ||
405 | // if we're asking for a non-existent face, return null | ||
406 | if (te >= mNumTEs) | ||
407 | { | ||
408 | llwarns << "Setting nonexistent face" << llendl; | ||
409 | return 0; | ||
410 | } | ||
411 | |||
412 | return mTextureList[te].setRotation(r); | ||
413 | } | ||
414 | |||
415 | |||
416 | //=============================================================== | ||
417 | S32 LLPrimitive::setTEBumpShinyFullbright(const U8 te, const U8 bump) | ||
418 | { | ||
419 | // if we're asking for a non-existent face, return null | ||
420 | if (te >= mNumTEs) | ||
421 | { | ||
422 | llwarns << "setting non-existent te " << te << llendl | ||
423 | return 0; | ||
424 | } | ||
425 | |||
426 | return mTextureList[te].setBumpShinyFullbright( bump ); | ||
427 | } | ||
428 | |||
429 | S32 LLPrimitive::setTEMediaTexGen(const U8 te, const U8 media) | ||
430 | { | ||
431 | // if we're asking for a non-existent face, return null | ||
432 | if (te >= mNumTEs) | ||
433 | { | ||
434 | llwarns << "setting non-existent te " << te << llendl | ||
435 | return 0; | ||
436 | } | ||
437 | |||
438 | return mTextureList[te].setMediaTexGen( media ); | ||
439 | } | ||
440 | |||
441 | S32 LLPrimitive::setTEBumpmap(const U8 te, const U8 bump) | ||
442 | { | ||
443 | // if we're asking for a non-existent face, return null | ||
444 | if (te >= mNumTEs) | ||
445 | { | ||
446 | llwarns << "setting non-existent te " << te << llendl | ||
447 | return 0; | ||
448 | } | ||
449 | |||
450 | return mTextureList[te].setBumpmap( bump ); | ||
451 | } | ||
452 | |||
453 | S32 LLPrimitive::setTEBumpShiny(const U8 te, const U8 bump_shiny) | ||
454 | { | ||
455 | // if we're asking for a non-existent face, return null | ||
456 | if (te >= mNumTEs) | ||
457 | { | ||
458 | llwarns << "setting non-existent te " << te << llendl | ||
459 | return 0; | ||
460 | } | ||
461 | |||
462 | return mTextureList[te].setBumpShiny( bump_shiny ); | ||
463 | } | ||
464 | |||
465 | S32 LLPrimitive::setTETexGen(const U8 te, const U8 texgen) | ||
466 | { | ||
467 | // if we're asking for a non-existent face, return null | ||
468 | if (te >= mNumTEs) | ||
469 | { | ||
470 | llwarns << "setting non-existent te " << te << llendl | ||
471 | return 0; | ||
472 | } | ||
473 | |||
474 | return mTextureList[te].setTexGen( texgen ); | ||
475 | } | ||
476 | |||
477 | S32 LLPrimitive::setTEShiny(const U8 te, const U8 shiny) | ||
478 | { | ||
479 | // if we're asking for a non-existent face, return null | ||
480 | if (te >= mNumTEs) | ||
481 | { | ||
482 | llwarns << "setting non-existent te " << te << llendl | ||
483 | return 0; | ||
484 | } | ||
485 | |||
486 | return mTextureList[te].setShiny( shiny ); | ||
487 | } | ||
488 | |||
489 | S32 LLPrimitive::setTEFullbright(const U8 te, const U8 fullbright) | ||
490 | { | ||
491 | // if we're asking for a non-existent face, return null | ||
492 | if (te >= mNumTEs) | ||
493 | { | ||
494 | llwarns << "setting non-existent te " << te << llendl | ||
495 | return 0; | ||
496 | } | ||
497 | |||
498 | return mTextureList[te].setFullbright( fullbright ); | ||
499 | } | ||
500 | |||
501 | S32 LLPrimitive::setTEMediaFlags(const U8 te, const U8 media_flags) | ||
502 | { | ||
503 | // if we're asking for a non-existent face, return null | ||
504 | if (te >= mNumTEs) | ||
505 | { | ||
506 | llwarns << "setting non-existent te " << te << llendl | ||
507 | return 0; | ||
508 | } | ||
509 | |||
510 | return mTextureList[te].setMediaFlags( media_flags ); | ||
511 | } | ||
512 | |||
513 | |||
514 | LLPCode LLPrimitive::legacyToPCode(const U8 legacy) | ||
515 | { | ||
516 | LLPCode pcode = 0; | ||
517 | |||
518 | switch (legacy) | ||
519 | { | ||
520 | /* | ||
521 | case BOX: | ||
522 | pcode = LL_PCODE_CUBE; | ||
523 | break; | ||
524 | case CYLINDER: | ||
525 | pcode = LL_PCODE_CYLINDER; | ||
526 | break; | ||
527 | case CONE: | ||
528 | pcode = LL_PCODE_CONE; | ||
529 | break; | ||
530 | case HALF_CONE: | ||
531 | pcode = LL_PCODE_CONE_HEMI; | ||
532 | break; | ||
533 | case HALF_CYLINDER: | ||
534 | pcode = LL_PCODE_CYLINDER_HEMI; | ||
535 | break; | ||
536 | case HALF_SPHERE: | ||
537 | pcode = LL_PCODE_SPHERE_HEMI; | ||
538 | break; | ||
539 | case PRISM: | ||
540 | pcode = LL_PCODE_PRISM; | ||
541 | break; | ||
542 | case PYRAMID: | ||
543 | pcode = LL_PCODE_PYRAMID; | ||
544 | break; | ||
545 | case SPHERE: | ||
546 | pcode = LL_PCODE_SPHERE; | ||
547 | break; | ||
548 | case TETRAHEDRON: | ||
549 | pcode = LL_PCODE_TETRAHEDRON; | ||
550 | break; | ||
551 | case DEMON: | ||
552 | pcode = LL_PCODE_LEGACY_DEMON; | ||
553 | break; | ||
554 | case LSL_TEST: | ||
555 | pcode = LL_PCODE_LEGACY_LSL_TEST; | ||
556 | break; | ||
557 | case ORACLE: | ||
558 | pcode = LL_PCODE_LEGACY_ORACLE; | ||
559 | break; | ||
560 | case TEXTBUBBLE: | ||
561 | pcode = LL_PCODE_LEGACY_TEXT_BUBBLE; | ||
562 | break; | ||
563 | case ATOR: | ||
564 | pcode = LL_PCODE_LEGACY_ATOR; | ||
565 | break; | ||
566 | case BASIC_SHOT: | ||
567 | pcode = LL_PCODE_LEGACY_SHOT; | ||
568 | break; | ||
569 | case BIG_SHOT: | ||
570 | pcode = LL_PCODE_LEGACY_SHOT_BIG; | ||
571 | break; | ||
572 | case BIRD: | ||
573 | pcode = LL_PCODE_LEGACY_BIRD; | ||
574 | break; | ||
575 | case ROCK: | ||
576 | pcode = LL_PCODE_LEGACY_ROCK; | ||
577 | break; | ||
578 | case SMOKE: | ||
579 | pcode = LL_PCODE_LEGACY_SMOKE; | ||
580 | break; | ||
581 | case SPARK: | ||
582 | pcode = LL_PCODE_LEGACY_SPARK; | ||
583 | break; | ||
584 | */ | ||
585 | case PRIMITIVE_VOLUME: | ||
586 | pcode = LL_PCODE_VOLUME; | ||
587 | break; | ||
588 | case GRASS: | ||
589 | pcode = LL_PCODE_LEGACY_GRASS; | ||
590 | break; | ||
591 | case PART_SYS: | ||
592 | pcode = LL_PCODE_LEGACY_PART_SYS; | ||
593 | break; | ||
594 | case PLAYER: | ||
595 | pcode = LL_PCODE_LEGACY_AVATAR; | ||
596 | break; | ||
597 | case TREE: | ||
598 | pcode = LL_PCODE_LEGACY_TREE; | ||
599 | break; | ||
600 | case TREE_NEW: | ||
601 | pcode = LL_PCODE_TREE_NEW; | ||
602 | break; | ||
603 | default: | ||
604 | llwarns << "Unknown legacy code " << legacy << "!" << llendl; | ||
605 | } | ||
606 | |||
607 | return pcode; | ||
608 | } | ||
609 | |||
610 | U8 LLPrimitive::pCodeToLegacy(const LLPCode pcode) | ||
611 | { | ||
612 | U8 legacy; | ||
613 | switch (pcode) | ||
614 | { | ||
615 | /* | ||
616 | case LL_PCODE_CUBE: | ||
617 | legacy = BOX; | ||
618 | break; | ||
619 | case LL_PCODE_CYLINDER: | ||
620 | legacy = CYLINDER; | ||
621 | break; | ||
622 | case LL_PCODE_CONE: | ||
623 | legacy = CONE; | ||
624 | break; | ||
625 | case LL_PCODE_CONE_HEMI: | ||
626 | legacy = HALF_CONE; | ||
627 | break; | ||
628 | case LL_PCODE_CYLINDER_HEMI: | ||
629 | legacy = HALF_CYLINDER; | ||
630 | break; | ||
631 | case LL_PCODE_SPHERE_HEMI: | ||
632 | legacy = HALF_SPHERE; | ||
633 | break; | ||
634 | case LL_PCODE_PRISM: | ||
635 | legacy = PRISM; | ||
636 | break; | ||
637 | case LL_PCODE_PYRAMID: | ||
638 | legacy = PYRAMID; | ||
639 | break; | ||
640 | case LL_PCODE_SPHERE: | ||
641 | legacy = SPHERE; | ||
642 | break; | ||
643 | case LL_PCODE_TETRAHEDRON: | ||
644 | legacy = TETRAHEDRON; | ||
645 | break; | ||
646 | case LL_PCODE_LEGACY_ATOR: | ||
647 | legacy = ATOR; | ||
648 | break; | ||
649 | case LL_PCODE_LEGACY_SHOT: | ||
650 | legacy = BASIC_SHOT; | ||
651 | break; | ||
652 | case LL_PCODE_LEGACY_SHOT_BIG: | ||
653 | legacy = BIG_SHOT; | ||
654 | break; | ||
655 | case LL_PCODE_LEGACY_BIRD: | ||
656 | legacy = BIRD; | ||
657 | break; | ||
658 | case LL_PCODE_LEGACY_DEMON: | ||
659 | legacy = DEMON; | ||
660 | break; | ||
661 | case LL_PCODE_LEGACY_LSL_TEST: | ||
662 | legacy = LSL_TEST; | ||
663 | break; | ||
664 | case LL_PCODE_LEGACY_ORACLE: | ||
665 | legacy = ORACLE; | ||
666 | break; | ||
667 | case LL_PCODE_LEGACY_ROCK: | ||
668 | legacy = ROCK; | ||
669 | break; | ||
670 | case LL_PCODE_LEGACY_TEXT_BUBBLE: | ||
671 | legacy = TEXTBUBBLE; | ||
672 | break; | ||
673 | case LL_PCODE_LEGACY_SMOKE: | ||
674 | legacy = SMOKE; | ||
675 | break; | ||
676 | case LL_PCODE_LEGACY_SPARK: | ||
677 | legacy = SPARK; | ||
678 | break; | ||
679 | */ | ||
680 | case LL_PCODE_VOLUME: | ||
681 | legacy = PRIMITIVE_VOLUME; | ||
682 | break; | ||
683 | case LL_PCODE_LEGACY_GRASS: | ||
684 | legacy = GRASS; | ||
685 | break; | ||
686 | case LL_PCODE_LEGACY_PART_SYS: | ||
687 | legacy = PART_SYS; | ||
688 | break; | ||
689 | case LL_PCODE_LEGACY_AVATAR: | ||
690 | legacy = PLAYER; | ||
691 | break; | ||
692 | case LL_PCODE_LEGACY_TREE: | ||
693 | legacy = TREE; | ||
694 | break; | ||
695 | case LL_PCODE_TREE_NEW: | ||
696 | legacy = TREE_NEW; | ||
697 | break; | ||
698 | default: | ||
699 | llwarns << "Unknown pcode " << (S32)pcode << ":" << pcode << "!" << llendl; | ||
700 | return 0; | ||
701 | } | ||
702 | return legacy; | ||
703 | } | ||
704 | |||
705 | |||
706 | // static | ||
707 | // Don't crash or llerrs here! This function is used for debug strings. | ||
708 | const char * LLPrimitive::pCodeToString(const LLPCode pcode) | ||
709 | { | ||
710 | static char pcode_string[255]; | ||
711 | |||
712 | U8 base_code = pcode & LL_PCODE_BASE_MASK; | ||
713 | pcode_string[0] = 0; | ||
714 | if (!pcode) | ||
715 | { | ||
716 | sprintf(pcode_string, "null"); | ||
717 | } | ||
718 | else if ((base_code) == LL_PCODE_LEGACY) | ||
719 | { | ||
720 | // It's a legacy object | ||
721 | switch (pcode) | ||
722 | { | ||
723 | case LL_PCODE_LEGACY_GRASS: | ||
724 | sprintf(pcode_string, "grass"); | ||
725 | break; | ||
726 | case LL_PCODE_LEGACY_PART_SYS: | ||
727 | sprintf(pcode_string, "particle system"); | ||
728 | break; | ||
729 | case LL_PCODE_LEGACY_AVATAR: | ||
730 | sprintf(pcode_string, "avatar"); | ||
731 | break; | ||
732 | case LL_PCODE_LEGACY_TEXT_BUBBLE: | ||
733 | sprintf(pcode_string, "text bubble"); | ||
734 | break; | ||
735 | case LL_PCODE_LEGACY_TREE: | ||
736 | sprintf(pcode_string, "tree"); | ||
737 | break; | ||
738 | case LL_PCODE_TREE_NEW: | ||
739 | sprintf(pcode_string, "tree_new"); | ||
740 | break; | ||
741 | default: | ||
742 | sprintf(pcode_string, "unknown legacy pcode %i",(U32)pcode); | ||
743 | } | ||
744 | } | ||
745 | else | ||
746 | { | ||
747 | char shape[32]; | ||
748 | char mask[32]; | ||
749 | if (base_code == LL_PCODE_CUBE) | ||
750 | { | ||
751 | sprintf(shape, "cube"); | ||
752 | } | ||
753 | else if (base_code == LL_PCODE_CYLINDER) | ||
754 | { | ||
755 | sprintf(shape, "cylinder"); | ||
756 | } | ||
757 | else if (base_code == LL_PCODE_CONE) | ||
758 | { | ||
759 | sprintf(shape, "cone"); | ||
760 | } | ||
761 | else if (base_code == LL_PCODE_PRISM) | ||
762 | { | ||
763 | sprintf(shape, "prism"); | ||
764 | } | ||
765 | else if (base_code == LL_PCODE_PYRAMID) | ||
766 | { | ||
767 | sprintf(shape, "pyramid"); | ||
768 | } | ||
769 | else if (base_code == LL_PCODE_SPHERE) | ||
770 | { | ||
771 | sprintf(shape, "sphere"); | ||
772 | } | ||
773 | else if (base_code == LL_PCODE_TETRAHEDRON) | ||
774 | { | ||
775 | sprintf(shape, "tetrahedron"); | ||
776 | } | ||
777 | else if (base_code == LL_PCODE_VOLUME) | ||
778 | { | ||
779 | sprintf(shape, "volume"); | ||
780 | } | ||
781 | else if (base_code == LL_PCODE_APP) | ||
782 | { | ||
783 | sprintf(shape, "app"); | ||
784 | } | ||
785 | else | ||
786 | { | ||
787 | llwarns << "Unknown base mask for pcode: " << base_code << llendl; | ||
788 | } | ||
789 | |||
790 | U8 mask_code = pcode & (~LL_PCODE_BASE_MASK); | ||
791 | if (base_code == LL_PCODE_APP) | ||
792 | { | ||
793 | sprintf(mask, "%x", mask_code); | ||
794 | } | ||
795 | else if (mask_code & LL_PCODE_HEMI_MASK) | ||
796 | { | ||
797 | sprintf(mask, "hemi"); | ||
798 | } | ||
799 | else if (mask != 0) | ||
800 | { | ||
801 | sprintf(mask, "%x", mask_code); | ||
802 | } | ||
803 | else | ||
804 | { | ||
805 | mask[0] = 0; | ||
806 | } | ||
807 | |||
808 | if (mask[0]) | ||
809 | { | ||
810 | sprintf(pcode_string, "%s-%s", shape, mask); | ||
811 | } | ||
812 | else | ||
813 | { | ||
814 | sprintf(pcode_string, "%s", shape); | ||
815 | } | ||
816 | } | ||
817 | return pcode_string; | ||
818 | } | ||
819 | |||
820 | |||
821 | void LLPrimitive::copyTEs(const LLPrimitive *primitivep) | ||
822 | { | ||
823 | U32 i; | ||
824 | if (primitivep->getNumTEs() != getNumTEs()) | ||
825 | { | ||
826 | llwarns << "Primitives don't have same number of TE's" << llendl; | ||
827 | } | ||
828 | U32 num_tes = llmin(primitivep->getNumTEs(), getNumTEs()); | ||
829 | for (i = 0; i < num_tes; i++) | ||
830 | { | ||
831 | const LLTextureEntry *tep = primitivep->getTE(i); | ||
832 | F32 s, t; | ||
833 | setTETexture(i, tep->getID()); | ||
834 | setTEColor(i, tep->getColor()); | ||
835 | tep->getScale(&s, &t); | ||
836 | setTEScale(i, s, t); | ||
837 | tep->getOffset(&s, &t); | ||
838 | setTEOffset(i, s, t); | ||
839 | setTERotation(i, tep->getRotation()); | ||
840 | setTEBumpShinyFullbright(i, tep->getBumpShinyFullbright()); | ||
841 | setTEMediaTexGen(i, tep->getMediaTexGen()); | ||
842 | } | ||
843 | } | ||
844 | |||
845 | S32 face_index_from_id(LLFaceID face_ID, const std::vector<LLProfile::Face>& faceArray) | ||
846 | { | ||
847 | S32 i; | ||
848 | for (i = 0; i < (S32)faceArray.size(); i++) | ||
849 | { | ||
850 | if (faceArray[i].mFaceID == face_ID) | ||
851 | { | ||
852 | return i; | ||
853 | } | ||
854 | } | ||
855 | return -1; | ||
856 | } | ||
857 | |||
858 | BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume) | ||
859 | { | ||
860 | LLVolume *volumep; | ||
861 | if (unique_volume) | ||
862 | { | ||
863 | F32 volume_detail = LLVolumeLODGroup::getVolumeScaleFromDetail(detail); | ||
864 | if (mVolumep.notNull() && volume_params == mVolumep->getParams() && (volume_detail == mVolumep->getDetail())) | ||
865 | { | ||
866 | return FALSE; | ||
867 | } | ||
868 | volumep = new LLVolume(volume_params, volume_detail, FALSE, TRUE); | ||
869 | } | ||
870 | else | ||
871 | { | ||
872 | if (mVolumep.notNull()) | ||
873 | { | ||
874 | F32 volume_detail = LLVolumeLODGroup::getVolumeScaleFromDetail(detail); | ||
875 | if (volume_params == mVolumep->getParams() && (volume_detail == mVolumep->getDetail())) | ||
876 | { | ||
877 | return FALSE; | ||
878 | } | ||
879 | } | ||
880 | |||
881 | volumep = gVolumeMgr->getVolume(volume_params, detail); | ||
882 | if (volumep == mVolumep) | ||
883 | { | ||
884 | gVolumeMgr->cleanupVolume( volumep ); // gVolumeMgr->getVolume() creates a reference, but we don't need a second one. | ||
885 | return TRUE; | ||
886 | } | ||
887 | } | ||
888 | |||
889 | setChanged(GEOMETRY); | ||
890 | |||
891 | |||
892 | if (!mVolumep) | ||
893 | { | ||
894 | mVolumep = volumep; | ||
895 | //mFaceMask = mVolumep->generateFaceMask(); | ||
896 | setNumTEs(mVolumep->getNumFaces()); | ||
897 | return TRUE; | ||
898 | } | ||
899 | |||
900 | U32 old_face_mask = mVolumep->mFaceMask; | ||
901 | |||
902 | S32 face_bit = 0; | ||
903 | S32 cur_mask = 0; | ||
904 | |||
905 | // grab copies of the old faces so we can determine the TE mappings... | ||
906 | std::vector<LLProfile::Face> old_faces; // list of old faces for remapping texture entries | ||
907 | LLTextureEntry old_tes[9]; | ||
908 | |||
909 | for (S32 face = 0; face < mVolumep->getNumFaces(); face++) | ||
910 | { | ||
911 | old_faces.push_back(mVolumep->getProfile().mFaces[face]); | ||
912 | } | ||
913 | |||
914 | for (face_bit = 0; face_bit < 9; face_bit++) | ||
915 | { | ||
916 | cur_mask = 0x1 << face_bit; | ||
917 | if (old_face_mask & cur_mask) | ||
918 | { | ||
919 | S32 te_index = face_index_from_id(cur_mask, old_faces); | ||
920 | old_tes[face_bit] = *getTE(te_index); | ||
921 | //llinfos << face_bit << ":" << te_index << ":" << old_tes[face_bit].getID() << llendl; | ||
922 | } | ||
923 | } | ||
924 | |||
925 | |||
926 | // build the new object | ||
927 | gVolumeMgr->cleanupVolume(mVolumep); | ||
928 | mVolumep = volumep; | ||
929 | |||
930 | U32 new_face_mask = mVolumep->mFaceMask; | ||
931 | S32 i; | ||
932 | |||
933 | /* | ||
934 | LLString old_mask_string; | ||
935 | for (i = 0; i < 9; i++) | ||
936 | { | ||
937 | if (old_face_mask & (1 << i)) | ||
938 | { | ||
939 | old_mask_string.append("1"); | ||
940 | } | ||
941 | else | ||
942 | { | ||
943 | old_mask_string.append("0"); | ||
944 | } | ||
945 | } | ||
946 | LLString new_mask_string; | ||
947 | for (i = 0; i < 9; i++) | ||
948 | { | ||
949 | if (new_face_mask & (1 << i)) | ||
950 | { | ||
951 | new_mask_string.append("1"); | ||
952 | } | ||
953 | else | ||
954 | { | ||
955 | new_mask_string.append("0"); | ||
956 | } | ||
957 | } | ||
958 | |||
959 | llinfos << "old mask: " << old_mask_string << llendl; | ||
960 | llinfos << "new mask: " << new_mask_string << llendl; | ||
961 | */ | ||
962 | |||
963 | |||
964 | if (old_face_mask == new_face_mask) | ||
965 | { | ||
966 | // nothing to do | ||
967 | return TRUE; | ||
968 | } | ||
969 | |||
970 | if (mVolumep->getNumFaces() == 0 && new_face_mask != 0) | ||
971 | { | ||
972 | llwarns << "Object with 0 faces found...INCORRECT!" << llendl; | ||
973 | setNumTEs(mVolumep->getNumFaces()); | ||
974 | return TRUE; | ||
975 | } | ||
976 | |||
977 | |||
978 | S32 face_mapping[9]; | ||
979 | for (face_bit = 0; face_bit < 9; face_bit++) | ||
980 | { | ||
981 | face_mapping[face_bit] = face_bit; | ||
982 | } | ||
983 | |||
984 | // Generate the face-type mappings | ||
985 | for (face_bit = 0; face_bit < 9; face_bit++) | ||
986 | { | ||
987 | cur_mask = 0x1 << face_bit; | ||
988 | if (!(new_face_mask & cur_mask)) | ||
989 | { | ||
990 | // Face doesn't exist in new map. | ||
991 | face_mapping[face_bit] = -1; | ||
992 | continue; | ||
993 | } | ||
994 | else if (old_face_mask & cur_mask) | ||
995 | { | ||
996 | // Face exists in new and old map. | ||
997 | face_mapping[face_bit] = face_bit; | ||
998 | continue; | ||
999 | } | ||
1000 | |||
1001 | // OK, how we've got a mismatch, where we have to fill a new face with one from | ||
1002 | // the old face. | ||
1003 | if (cur_mask & (LL_FACE_PATH_BEGIN | LL_FACE_PATH_END | LL_FACE_INNER_SIDE)) | ||
1004 | { | ||
1005 | // It's a top/bottom/hollow interior face. | ||
1006 | if (old_face_mask & LL_FACE_PATH_END) | ||
1007 | { | ||
1008 | face_mapping[face_bit] = 1; | ||
1009 | continue; | ||
1010 | } | ||
1011 | else | ||
1012 | { | ||
1013 | S32 cur_outer_mask = LL_FACE_OUTER_SIDE_0; | ||
1014 | for (i = 0; i < 4; i++) | ||
1015 | { | ||
1016 | if (old_face_mask & cur_outer_mask) | ||
1017 | { | ||
1018 | face_mapping[face_bit] = 5 + i; | ||
1019 | break; | ||
1020 | } | ||
1021 | cur_outer_mask <<= 1; | ||
1022 | } | ||
1023 | if (i == 4) | ||
1024 | { | ||
1025 | llwarns << "No path end or outer face in volume!" << llendl; | ||
1026 | } | ||
1027 | continue; | ||
1028 | } | ||
1029 | } | ||
1030 | |||
1031 | if (cur_mask & (LL_FACE_PROFILE_BEGIN | LL_FACE_PROFILE_END)) | ||
1032 | { | ||
1033 | // A cut slice. Use the hollow interior if we have it. | ||
1034 | if (old_face_mask & LL_FACE_INNER_SIDE) | ||
1035 | { | ||
1036 | face_mapping[face_bit] = 2; | ||
1037 | continue; | ||
1038 | } | ||
1039 | |||
1040 | // No interior, use the bottom face. | ||
1041 | // Could figure out which of the outer faces was nearest, but that would be harder. | ||
1042 | if (old_face_mask & LL_FACE_PATH_END) | ||
1043 | { | ||
1044 | face_mapping[face_bit] = 1; | ||
1045 | continue; | ||
1046 | } | ||
1047 | else | ||
1048 | { | ||
1049 | S32 cur_outer_mask = LL_FACE_OUTER_SIDE_0; | ||
1050 | for (i = 0; i < 4; i++) | ||
1051 | { | ||
1052 | if (old_face_mask & cur_outer_mask) | ||
1053 | { | ||
1054 | face_mapping[face_bit] = 5 + i; | ||
1055 | break; | ||
1056 | } | ||
1057 | cur_outer_mask <<= 1; | ||
1058 | } | ||
1059 | if (i == 4) | ||
1060 | { | ||
1061 | llwarns << "No path end or outer face in volume!" << llendl; | ||
1062 | } | ||
1063 | continue; | ||
1064 | } | ||
1065 | } | ||
1066 | |||
1067 | // OK, the face that's missing is an outer face... | ||
1068 | // Pull from the nearest adjacent outer face (there's always guaranteed to be one... | ||
1069 | S32 cur_outer = face_bit - 5; | ||
1070 | S32 min_dist = 5; | ||
1071 | S32 min_outer_bit = -1; | ||
1072 | S32 i; | ||
1073 | for (i = 0; i < 4; i++) | ||
1074 | { | ||
1075 | if (old_face_mask & (LL_FACE_OUTER_SIDE_0 << i)) | ||
1076 | { | ||
1077 | S32 dist = abs(i - cur_outer); | ||
1078 | if (dist < min_dist) | ||
1079 | { | ||
1080 | min_dist = dist; | ||
1081 | min_outer_bit = i + 5; | ||
1082 | } | ||
1083 | } | ||
1084 | } | ||
1085 | if (-1 == min_outer_bit) | ||
1086 | { | ||
1087 | llinfos << (LLVolume *)mVolumep << llendl; | ||
1088 | llwarns << "Bad! No outer faces, impossible!" << llendl; | ||
1089 | } | ||
1090 | face_mapping[face_bit] = min_outer_bit; | ||
1091 | } | ||
1092 | |||
1093 | |||
1094 | setNumTEs(mVolumep->getNumFaces()); | ||
1095 | for (face_bit = 0; face_bit < 9; face_bit++) | ||
1096 | { | ||
1097 | cur_mask = 0x1 << face_bit; | ||
1098 | if (new_face_mask & cur_mask) | ||
1099 | { | ||
1100 | if (-1 == face_mapping[face_bit]) | ||
1101 | { | ||
1102 | llwarns << "No mapping from old face to new face!" << llendl; | ||
1103 | } | ||
1104 | |||
1105 | S32 te_num = face_index_from_id(cur_mask, mVolumep->getProfile().mFaces); | ||
1106 | setTE(te_num, old_tes[face_mapping[face_bit]]); | ||
1107 | } | ||
1108 | } | ||
1109 | return TRUE; | ||
1110 | } | ||
1111 | |||
1112 | BOOL LLPrimitive::setMaterial(U8 material) | ||
1113 | { | ||
1114 | if (material != mMaterial) | ||
1115 | { | ||
1116 | mMaterial = material; | ||
1117 | return TRUE; | ||
1118 | } | ||
1119 | else | ||
1120 | { | ||
1121 | return FALSE; | ||
1122 | } | ||
1123 | } | ||
1124 | |||
1125 | void LLPrimitive::setTEArrays(const U8 size, | ||
1126 | const LLUUID* image_ids, | ||
1127 | const F32* scale_s, | ||
1128 | const F32* scale_t) | ||
1129 | { | ||
1130 | S32 cur_size = size; | ||
1131 | if (cur_size > getNumTEs()) | ||
1132 | { | ||
1133 | llwarns << "Trying to set more TEs than exist!" << llendl; | ||
1134 | cur_size = getNumTEs(); | ||
1135 | } | ||
1136 | |||
1137 | S32 i; | ||
1138 | // Copy over image information | ||
1139 | for (i = 0; i < cur_size; i++) | ||
1140 | { | ||
1141 | // This is very BAD!!!!!! | ||
1142 | if (image_ids != NULL) | ||
1143 | { | ||
1144 | setTETexture(i,image_ids[i]); | ||
1145 | } | ||
1146 | if (scale_s && scale_t) | ||
1147 | { | ||
1148 | setTEScale(i, scale_s[i], scale_t[i]); | ||
1149 | } | ||
1150 | } | ||
1151 | |||
1152 | if (i < getNumTEs()) | ||
1153 | { | ||
1154 | cur_size--; | ||
1155 | for (i=i; i < getNumTEs(); i++) // the i=i removes a gcc warning | ||
1156 | { | ||
1157 | if (image_ids != NULL) | ||
1158 | { | ||
1159 | setTETexture(i, image_ids[cur_size]); | ||
1160 | } | ||
1161 | if (scale_s && scale_t) | ||
1162 | { | ||
1163 | setTEScale(i, scale_s[cur_size], scale_t[cur_size]); | ||
1164 | } | ||
1165 | } | ||
1166 | } | ||
1167 | } | ||
1168 | |||
1169 | const F32 LL_MAX_SCALE_S = 100.0f; | ||
1170 | const F32 LL_MAX_SCALE_T = 100.0f; | ||
1171 | S32 LLPrimitive::packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const | ||
1172 | { | ||
1173 | S32 face_index; | ||
1174 | S32 i; | ||
1175 | U64 exception_faces; | ||
1176 | U8 *start_loc = cur_ptr; | ||
1177 | |||
1178 | htonmemcpy(cur_ptr,data_ptr + (last_face_index * data_size), type, data_size); | ||
1179 | cur_ptr += data_size; | ||
1180 | |||
1181 | for (face_index = last_face_index-1; face_index >= 0; face_index--) | ||
1182 | { | ||
1183 | BOOL already_sent = FALSE; | ||
1184 | for (i = face_index+1; i <= last_face_index; i++) | ||
1185 | { | ||
1186 | if (!memcmp(data_ptr+(data_size *face_index), data_ptr+(data_size *i), data_size)) | ||
1187 | { | ||
1188 | already_sent = TRUE; | ||
1189 | break; | ||
1190 | } | ||
1191 | } | ||
1192 | |||
1193 | if (!already_sent) | ||
1194 | { | ||
1195 | exception_faces = 0; | ||
1196 | for (i = face_index; i >= 0; i--) | ||
1197 | { | ||
1198 | if (!memcmp(data_ptr+(data_size *face_index), data_ptr+(data_size *i), data_size)) | ||
1199 | { | ||
1200 | exception_faces |= (1 << i); | ||
1201 | } | ||
1202 | } | ||
1203 | |||
1204 | //assign exception faces to cur_ptr | ||
1205 | if (exception_faces >= (0x1 << 7)) | ||
1206 | { | ||
1207 | if (exception_faces >= (0x1 << 14)) | ||
1208 | { | ||
1209 | if (exception_faces >= (0x1 << 21)) | ||
1210 | { | ||
1211 | if (exception_faces >= (0x1 << 28)) | ||
1212 | { | ||
1213 | *cur_ptr++ = (U8)(((exception_faces >> 28) & 0x7F) | 0x80); | ||
1214 | } | ||
1215 | *cur_ptr++ = (U8)(((exception_faces >> 21) & 0x7F) | 0x80); | ||
1216 | } | ||
1217 | *cur_ptr++ = (U8)(((exception_faces >> 14) & 0x7F) | 0x80); | ||
1218 | } | ||
1219 | *cur_ptr++ = (U8)(((exception_faces >> 7) & 0x7F) | 0x80); | ||
1220 | } | ||
1221 | |||
1222 | *cur_ptr++ = (U8)(exception_faces & 0x7F); | ||
1223 | |||
1224 | htonmemcpy(cur_ptr,data_ptr + (face_index * data_size), type, data_size); | ||
1225 | cur_ptr += data_size; | ||
1226 | } | ||
1227 | } | ||
1228 | return (S32)(cur_ptr - start_loc); | ||
1229 | } | ||
1230 | |||
1231 | S32 LLPrimitive::unpackTEField(U8 *cur_ptr, U8 *buffer_end, U8 *data_ptr, U8 data_size, U8 face_count, EMsgVariableType type) | ||
1232 | { | ||
1233 | U8 *start_loc = cur_ptr; | ||
1234 | U64 i; | ||
1235 | htonmemcpy(data_ptr,cur_ptr, type,data_size); | ||
1236 | cur_ptr += data_size; | ||
1237 | |||
1238 | for (i = 1; i < face_count; i++) | ||
1239 | { | ||
1240 | // Already unswizzled, don't need to unswizzle it again! | ||
1241 | memcpy(data_ptr+(i*data_size),data_ptr,data_size); | ||
1242 | } | ||
1243 | |||
1244 | while ((cur_ptr < buffer_end) && (*cur_ptr != 0)) | ||
1245 | { | ||
1246 | // llinfos << "TE exception" << llendl; | ||
1247 | i = 0; | ||
1248 | while (*cur_ptr & 0x80) | ||
1249 | { | ||
1250 | i |= ((*cur_ptr++) & 0x7F); | ||
1251 | i = i << 7; | ||
1252 | } | ||
1253 | |||
1254 | i |= *cur_ptr++; | ||
1255 | |||
1256 | for (S32 j = 0; j < face_count; j++) | ||
1257 | { | ||
1258 | if (i & 0x01) | ||
1259 | { | ||
1260 | htonmemcpy(data_ptr+(j*data_size),cur_ptr,type,data_size); | ||
1261 | // char foo[64]; | ||
1262 | // sprintf(foo,"%x %x",*(data_ptr+(j*data_size)), *(data_ptr+(j*data_size)+1)); | ||
1263 | // llinfos << "Assigning " << foo << " to face " << j << llendl; | ||
1264 | } | ||
1265 | i = i >> 1; | ||
1266 | } | ||
1267 | cur_ptr += data_size; | ||
1268 | } | ||
1269 | return (S32)(cur_ptr - start_loc); | ||
1270 | } | ||
1271 | |||
1272 | |||
1273 | // Pack information about all texture entries into container: | ||
1274 | // { TextureEntry Variable 2 } | ||
1275 | // Includes information about image ID, color, scale S,T, offset S,T and rotation | ||
1276 | BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const | ||
1277 | { | ||
1278 | const U32 MAX_TES = 32; | ||
1279 | |||
1280 | U8 image_ids[MAX_TES*16]; | ||
1281 | U8 colors[MAX_TES*4]; | ||
1282 | S16 scale_s[MAX_TES]; | ||
1283 | S16 scale_t[MAX_TES]; | ||
1284 | S16 offset_s[MAX_TES]; | ||
1285 | S16 offset_t[MAX_TES]; | ||
1286 | S16 image_rot[MAX_TES]; | ||
1287 | U8 bump[MAX_TES]; | ||
1288 | U8 media_flags[MAX_TES]; | ||
1289 | |||
1290 | const U32 MAX_TE_BUFFER = 4096; | ||
1291 | U8 packed_buffer[MAX_TE_BUFFER]; | ||
1292 | U8 *cur_ptr = packed_buffer; | ||
1293 | |||
1294 | S32 last_face_index = getNumTEs() - 1; | ||
1295 | |||
1296 | if (last_face_index > -1) | ||
1297 | { | ||
1298 | // ...if we hit the front, send one image id | ||
1299 | S8 face_index; | ||
1300 | LLColor4U coloru; | ||
1301 | for (face_index = 0; face_index <= last_face_index; face_index++) | ||
1302 | { | ||
1303 | // Directly sending image_ids is not safe! | ||
1304 | memcpy(&image_ids[face_index*16],getTE(face_index)->getID().mData,16); | ||
1305 | |||
1306 | // Cast LLColor4 to LLColor4U | ||
1307 | coloru.setVec( getTE(face_index)->getColor() ); | ||
1308 | |||
1309 | // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) | ||
1310 | // as all zeros. However, the subtraction and addition must be done in unsigned | ||
1311 | // byte space, not in float space, otherwise off-by-one errors occur. JC | ||
1312 | colors[4*face_index] = 255 - coloru.mV[0]; | ||
1313 | colors[4*face_index + 1] = 255 - coloru.mV[1]; | ||
1314 | colors[4*face_index + 2] = 255 - coloru.mV[2]; | ||
1315 | colors[4*face_index + 3] = 255 - coloru.mV[3]; | ||
1316 | |||
1317 | const LLTextureEntry* te = getTE(face_index); | ||
1318 | scale_s[face_index] = (S16) llround(((llclamp(te->mScaleS,-LL_MAX_SCALE_S, LL_MAX_SCALE_S)-1.0f)/(LL_MAX_SCALE_S+1.f) * (F32)0x7FFF)); | ||
1319 | scale_t[face_index] = (S16) llround(((llclamp(te->mScaleT,-LL_MAX_SCALE_T, LL_MAX_SCALE_T)-1.0f)/(LL_MAX_SCALE_T+1.f) * (F32)0x7FFF)); | ||
1320 | offset_s[face_index] = (S16) llround((llclamp(te->mOffsetS,-1.0f,1.0f) * (F32)0x7FFF)) ; | ||
1321 | offset_t[face_index] = (S16) llround((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ; | ||
1322 | image_rot[face_index] = (S16) llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * (F32)0x7FFF)); | ||
1323 | bump[face_index] = te->getBumpShinyFullbright(); | ||
1324 | media_flags[face_index] = te->getMediaTexGen(); | ||
1325 | // llinfos << "BUMP pack [" << (S32)face_index << "]=" << (S32) bump[face_index] << llendl; | ||
1326 | } | ||
1327 | |||
1328 | cur_ptr += packTEField(cur_ptr, (U8 *)image_ids, sizeof(LLUUID),last_face_index, MVT_LLUUID); | ||
1329 | *cur_ptr++ = 0; | ||
1330 | cur_ptr += packTEField(cur_ptr, (U8 *)colors, 4 ,last_face_index, MVT_U8); | ||
1331 | *cur_ptr++ = 0; | ||
1332 | cur_ptr += packTEField(cur_ptr, (U8 *)scale_s, 2 ,last_face_index, MVT_S16Array); | ||
1333 | *cur_ptr++ = 0; | ||
1334 | cur_ptr += packTEField(cur_ptr, (U8 *)scale_t, 2 ,last_face_index, MVT_S16Array); | ||
1335 | *cur_ptr++ = 0; | ||
1336 | cur_ptr += packTEField(cur_ptr, (U8 *)offset_s, 2 ,last_face_index, MVT_S16Array); | ||
1337 | *cur_ptr++ = 0; | ||
1338 | cur_ptr += packTEField(cur_ptr, (U8 *)offset_t, 2 ,last_face_index, MVT_S16Array); | ||
1339 | *cur_ptr++ = 0; | ||
1340 | cur_ptr += packTEField(cur_ptr, (U8 *)image_rot, 2 ,last_face_index, MVT_S16Array); | ||
1341 | *cur_ptr++ = 0; | ||
1342 | cur_ptr += packTEField(cur_ptr, (U8 *)bump, 1 ,last_face_index, MVT_U8); | ||
1343 | *cur_ptr++ = 0; | ||
1344 | cur_ptr += packTEField(cur_ptr, (U8 *)media_flags, 1 ,last_face_index, MVT_U8); | ||
1345 | } | ||
1346 | mesgsys->addBinaryDataFast(_PREHASH_TextureEntry, packed_buffer, (S32)(cur_ptr - packed_buffer)); | ||
1347 | |||
1348 | return FALSE; | ||
1349 | } | ||
1350 | |||
1351 | |||
1352 | BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const | ||
1353 | { | ||
1354 | const U32 MAX_TES = 32; | ||
1355 | |||
1356 | U8 image_ids[MAX_TES*16]; | ||
1357 | U8 colors[MAX_TES*4]; | ||
1358 | S16 scale_s[MAX_TES]; | ||
1359 | S16 scale_t[MAX_TES]; | ||
1360 | S16 offset_s[MAX_TES]; | ||
1361 | S16 offset_t[MAX_TES]; | ||
1362 | S16 image_rot[MAX_TES]; | ||
1363 | U8 bump[MAX_TES]; | ||
1364 | U8 media_flags[MAX_TES]; | ||
1365 | |||
1366 | const U32 MAX_TE_BUFFER = 4096; | ||
1367 | U8 packed_buffer[MAX_TE_BUFFER]; | ||
1368 | U8 *cur_ptr = packed_buffer; | ||
1369 | |||
1370 | S32 last_face_index = getNumTEs() - 1; | ||
1371 | |||
1372 | if (last_face_index > -1) | ||
1373 | { | ||
1374 | // ...if we hit the front, send one image id | ||
1375 | S8 face_index; | ||
1376 | LLColor4U coloru; | ||
1377 | for (face_index = 0; face_index <= last_face_index; face_index++) | ||
1378 | { | ||
1379 | // Directly sending image_ids is not safe! | ||
1380 | memcpy(&image_ids[face_index*16],getTE(face_index)->getID().mData,16); | ||
1381 | |||
1382 | // Cast LLColor4 to LLColor4U | ||
1383 | coloru.setVec( getTE(face_index)->getColor() ); | ||
1384 | |||
1385 | // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) | ||
1386 | // as all zeros. However, the subtraction and addition must be done in unsigned | ||
1387 | // byte space, not in float space, otherwise off-by-one errors occur. JC | ||
1388 | colors[4*face_index] = 255 - coloru.mV[0]; | ||
1389 | colors[4*face_index + 1] = 255 - coloru.mV[1]; | ||
1390 | colors[4*face_index + 2] = 255 - coloru.mV[2]; | ||
1391 | colors[4*face_index + 3] = 255 - coloru.mV[3]; | ||
1392 | |||
1393 | const LLTextureEntry* te = getTE(face_index); | ||
1394 | scale_s[face_index] = (S16) llround(((llclamp(te->mScaleS,-LL_MAX_SCALE_S, LL_MAX_SCALE_S)-1.0f)/(LL_MAX_SCALE_S+1.f) * (F32)0x7FFF)); | ||
1395 | scale_t[face_index] = (S16) llround(((llclamp(te->mScaleT,-LL_MAX_SCALE_T, LL_MAX_SCALE_T)-1.0f)/(LL_MAX_SCALE_T+1.f) * (F32)0x7FFF)); | ||
1396 | offset_s[face_index] = (S16) llround((llclamp(te->mOffsetS,-1.0f,1.0f) * (F32)0x7FFF)) ; | ||
1397 | offset_t[face_index] = (S16) llround((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ; | ||
1398 | image_rot[face_index] = (S16) llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * (F32)0x7FFF)); | ||
1399 | bump[face_index] = te->getBumpShinyFullbright(); | ||
1400 | media_flags[face_index] = te->getMediaTexGen(); | ||
1401 | |||
1402 | // llinfos << "BUMP pack (Datapacker) [" << (S32)face_index << "]=" << (S32) bump[face_index] << llendl; | ||
1403 | } | ||
1404 | |||
1405 | cur_ptr += packTEField(cur_ptr, (U8 *)image_ids, sizeof(LLUUID),last_face_index, MVT_LLUUID); | ||
1406 | *cur_ptr++ = 0; | ||
1407 | cur_ptr += packTEField(cur_ptr, (U8 *)colors, 4 ,last_face_index, MVT_U8); | ||
1408 | *cur_ptr++ = 0; | ||
1409 | cur_ptr += packTEField(cur_ptr, (U8 *)scale_s, 2 ,last_face_index, MVT_S16Array); | ||
1410 | *cur_ptr++ = 0; | ||
1411 | cur_ptr += packTEField(cur_ptr, (U8 *)scale_t, 2 ,last_face_index, MVT_S16Array); | ||
1412 | *cur_ptr++ = 0; | ||
1413 | cur_ptr += packTEField(cur_ptr, (U8 *)offset_s, 2 ,last_face_index, MVT_S16Array); | ||
1414 | *cur_ptr++ = 0; | ||
1415 | cur_ptr += packTEField(cur_ptr, (U8 *)offset_t, 2 ,last_face_index, MVT_S16Array); | ||
1416 | *cur_ptr++ = 0; | ||
1417 | cur_ptr += packTEField(cur_ptr, (U8 *)image_rot, 2 ,last_face_index, MVT_S16Array); | ||
1418 | *cur_ptr++ = 0; | ||
1419 | cur_ptr += packTEField(cur_ptr, (U8 *)bump, 1 ,last_face_index, MVT_U8); | ||
1420 | *cur_ptr++ = 0; | ||
1421 | cur_ptr += packTEField(cur_ptr, (U8 *)media_flags, 1 ,last_face_index, MVT_U8); | ||
1422 | } | ||
1423 | |||
1424 | dp.packBinaryData(packed_buffer, (S32)(cur_ptr - packed_buffer), "TextureEntry"); | ||
1425 | return FALSE; | ||
1426 | } | ||
1427 | |||
1428 | S32 LLPrimitive::unpackTEMessage(LLMessageSystem *mesgsys, char *block_name) | ||
1429 | { | ||
1430 | return(unpackTEMessage(mesgsys,block_name,-1)); | ||
1431 | } | ||
1432 | |||
1433 | S32 LLPrimitive::unpackTEMessage(LLMessageSystem *mesgsys, char *block_name, const S32 block_num) | ||
1434 | { | ||
1435 | // use a negative block_num to indicate a single-block read (a non-variable block) | ||
1436 | S32 retval = 0; | ||
1437 | const U32 MAX_TES = 32; | ||
1438 | |||
1439 | // Avoid construction of 32 UUIDs per call. JC | ||
1440 | |||
1441 | U8 image_data[MAX_TES*16]; | ||
1442 | U8 colors[MAX_TES*4]; | ||
1443 | S16 scale_s[MAX_TES]; | ||
1444 | S16 scale_t[MAX_TES]; | ||
1445 | S16 offset_s[MAX_TES]; | ||
1446 | S16 offset_t[MAX_TES]; | ||
1447 | S16 image_rot[MAX_TES]; | ||
1448 | U8 bump[MAX_TES]; | ||
1449 | U8 media_flags[MAX_TES]; | ||
1450 | |||
1451 | const U32 MAX_TE_BUFFER = 4096; | ||
1452 | U8 packed_buffer[MAX_TE_BUFFER]; | ||
1453 | U8 *cur_ptr = packed_buffer; | ||
1454 | |||
1455 | U32 size; | ||
1456 | U32 face_count = 0; | ||
1457 | |||
1458 | if (block_num < 0) | ||
1459 | { | ||
1460 | size = mesgsys->getSizeFast(block_name, _PREHASH_TextureEntry); | ||
1461 | } | ||
1462 | else | ||
1463 | { | ||
1464 | size = mesgsys->getSizeFast(block_name, block_num, _PREHASH_TextureEntry); | ||
1465 | } | ||
1466 | |||
1467 | if (size == 0) | ||
1468 | { | ||
1469 | return retval; | ||
1470 | } | ||
1471 | |||
1472 | if (block_num < 0) | ||
1473 | { | ||
1474 | mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, packed_buffer, 0, 0, MAX_TE_BUFFER); | ||
1475 | } | ||
1476 | else | ||
1477 | { | ||
1478 | mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, packed_buffer, 0, block_num, MAX_TE_BUFFER); | ||
1479 | } | ||
1480 | |||
1481 | face_count = getNumTEs(); | ||
1482 | |||
1483 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)image_data, 16, face_count, MVT_LLUUID); | ||
1484 | cur_ptr++; | ||
1485 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)colors, 4, face_count, MVT_U8); | ||
1486 | cur_ptr++; | ||
1487 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_s, 2, face_count, MVT_S16Array); | ||
1488 | cur_ptr++; | ||
1489 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_t, 2, face_count, MVT_S16Array); | ||
1490 | cur_ptr++; | ||
1491 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)offset_s, 2, face_count, MVT_S16Array); | ||
1492 | cur_ptr++; | ||
1493 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)offset_t, 2, face_count, MVT_S16Array); | ||
1494 | cur_ptr++; | ||
1495 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)image_rot, 2, face_count, MVT_S16Array); | ||
1496 | cur_ptr++; | ||
1497 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)bump, 1, face_count, MVT_U8); | ||
1498 | cur_ptr++; | ||
1499 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8); | ||
1500 | |||
1501 | LLColor4 color; | ||
1502 | LLColor4U coloru; | ||
1503 | for (U32 i = 0; i < face_count; i++) | ||
1504 | { | ||
1505 | retval |= setTETexture(i, ((LLUUID*)image_data)[i]); | ||
1506 | retval |= setTEScale(i, | ||
1507 | floor((1.0f + ((((F32)scale_s[i] / (F32)0x7FFF)) * (LL_MAX_SCALE_S+1.f))) * 100.f + 0.5f) / 100.f, | ||
1508 | floor((1.0f + ((((F32)scale_t[i] / (F32)0x7FFF)) * (LL_MAX_SCALE_T+1.f))) * 100.f + 0.5f) / 100.f); | ||
1509 | retval |= setTEOffset(i, (F32)offset_s[i] / (F32)0x7FFF, (F32) offset_t[i] / (F32) 0x7FFF); | ||
1510 | retval |= setTERotation(i, ((F32)image_rot[i]/ (F32)0x7FFF) * F_TWO_PI); | ||
1511 | retval |= setTEBumpShinyFullbright(i, bump[i]); | ||
1512 | retval |= setTEMediaTexGen(i, media_flags[i]); | ||
1513 | coloru = LLColor4U(colors + 4*i); | ||
1514 | |||
1515 | // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) | ||
1516 | // as all zeros. However, the subtraction and addition must be done in unsigned | ||
1517 | // byte space, not in float space, otherwise off-by-one errors occur. JC | ||
1518 | color.mV[VRED] = F32(255 - coloru.mV[VRED]) / 255.f; | ||
1519 | color.mV[VGREEN] = F32(255 - coloru.mV[VGREEN]) / 255.f; | ||
1520 | color.mV[VBLUE] = F32(255 - coloru.mV[VBLUE]) / 255.f; | ||
1521 | color.mV[VALPHA] = F32(255 - coloru.mV[VALPHA]) / 255.f; | ||
1522 | |||
1523 | retval |= setTEColor(i, color); | ||
1524 | } | ||
1525 | |||
1526 | return retval; | ||
1527 | } | ||
1528 | |||
1529 | S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) | ||
1530 | { | ||
1531 | // use a negative block_num to indicate a single-block read (a non-variable block) | ||
1532 | S32 retval = 0; | ||
1533 | const U32 MAX_TES = 32; | ||
1534 | |||
1535 | // Avoid construction of 32 UUIDs per call | ||
1536 | static LLUUID image_ids[MAX_TES]; | ||
1537 | |||
1538 | U8 image_data[MAX_TES*16]; | ||
1539 | U8 colors[MAX_TES*4]; | ||
1540 | S16 scale_s[MAX_TES]; | ||
1541 | S16 scale_t[MAX_TES]; | ||
1542 | S16 offset_s[MAX_TES]; | ||
1543 | S16 offset_t[MAX_TES]; | ||
1544 | S16 image_rot[MAX_TES]; | ||
1545 | U8 bump[MAX_TES]; | ||
1546 | U8 media_flags[MAX_TES]; | ||
1547 | |||
1548 | const U32 MAX_TE_BUFFER = 4096; | ||
1549 | U8 packed_buffer[MAX_TE_BUFFER]; | ||
1550 | U8 *cur_ptr = packed_buffer; | ||
1551 | |||
1552 | S32 size; | ||
1553 | U32 face_count = 0; | ||
1554 | |||
1555 | if (!dp.unpackBinaryData(packed_buffer, size, "TextureEntry")) | ||
1556 | { | ||
1557 | retval = TEM_INVALID; | ||
1558 | llwarns << "Bad texture entry block! Abort!" << llendl; | ||
1559 | return retval; | ||
1560 | } | ||
1561 | |||
1562 | if (size == 0) | ||
1563 | { | ||
1564 | return retval; | ||
1565 | } | ||
1566 | |||
1567 | face_count = getNumTEs(); | ||
1568 | U32 i; | ||
1569 | |||
1570 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)image_data, 16, face_count, MVT_LLUUID); | ||
1571 | cur_ptr++; | ||
1572 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)colors, 4, face_count, MVT_U8); | ||
1573 | cur_ptr++; | ||
1574 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_s, 2, face_count, MVT_S16Array); | ||
1575 | cur_ptr++; | ||
1576 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_t, 2, face_count, MVT_S16Array); | ||
1577 | cur_ptr++; | ||
1578 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)offset_s, 2, face_count, MVT_S16Array); | ||
1579 | cur_ptr++; | ||
1580 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)offset_t, 2, face_count, MVT_S16Array); | ||
1581 | cur_ptr++; | ||
1582 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)image_rot, 2, face_count, MVT_S16Array); | ||
1583 | cur_ptr++; | ||
1584 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)bump, 1, face_count, MVT_U8); | ||
1585 | cur_ptr++; | ||
1586 | cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8); | ||
1587 | |||
1588 | for (i = 0; i < face_count; i++) | ||
1589 | { | ||
1590 | // llinfos << "BUMP unpack (Datapacker) [" << i << "]=" << S32(bump[i]) <<llendl; | ||
1591 | memcpy(image_ids[i].mData,&image_data[i*16],16); | ||
1592 | } | ||
1593 | |||
1594 | LLColor4 color; | ||
1595 | LLColor4U coloru; | ||
1596 | for (i = 0; i < face_count; i++) | ||
1597 | { | ||
1598 | retval |= setTETexture(i, image_ids[i]); | ||
1599 | retval |= setTEScale(i, | ||
1600 | floor((1.0f + ((((F32)scale_s[i] / (F32)0x7FFF)) * (LL_MAX_SCALE_S+1.f))) * 100.f + 0.5f) / 100.f, | ||
1601 | floor((1.0f + ((((F32)scale_t[i] / (F32)0x7FFF)) * (LL_MAX_SCALE_T+1.f))) * 100.f + 0.5f) / 100.f); | ||
1602 | retval |= setTEOffset(i, (F32)offset_s[i] / (F32)0x7FFF, (F32) offset_t[i] / (F32) 0x7FFF); | ||
1603 | retval |= setTERotation(i, ((F32)image_rot[i]/ (F32)0x7FFF) * F_TWO_PI); | ||
1604 | retval |= setTEBumpShinyFullbright(i, bump[i]); | ||
1605 | retval |= setTEMediaTexGen(i, media_flags[i]); | ||
1606 | coloru = LLColor4U(colors + 4*i); | ||
1607 | |||
1608 | // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) | ||
1609 | // as all zeros. However, the subtraction and addition must be done in unsigned | ||
1610 | // byte space, not in float space, otherwise off-by-one errors occur. JC | ||
1611 | color.mV[VRED] = F32(255 - coloru.mV[VRED]) / 255.f; | ||
1612 | color.mV[VGREEN] = F32(255 - coloru.mV[VGREEN]) / 255.f; | ||
1613 | color.mV[VBLUE] = F32(255 - coloru.mV[VBLUE]) / 255.f; | ||
1614 | color.mV[VALPHA] = F32(255 - coloru.mV[VALPHA]) / 255.f; | ||
1615 | |||
1616 | retval |= setTEColor(i, color); | ||
1617 | } | ||
1618 | |||
1619 | return retval; | ||
1620 | } | ||
1621 | |||
1622 | void LLPrimitive::setTextureList(LLTextureEntry *listp) | ||
1623 | { | ||
1624 | LLTextureEntry* old_texture_list = mTextureList; | ||
1625 | mTextureList = listp; | ||
1626 | delete[] old_texture_list; | ||
1627 | } | ||
1628 | |||
1629 | //============================================================================ | ||
1630 | |||
1631 | LLLightParams::LLLightParams() | ||
1632 | { | ||
1633 | mColor.setToWhite(); | ||
1634 | mRadius = 10.f; | ||
1635 | mCutoff = 0.0f; | ||
1636 | mFalloff = 0.75f; | ||
1637 | |||
1638 | mType = PARAMS_LIGHT; | ||
1639 | } | ||
1640 | |||
1641 | BOOL LLLightParams::pack(LLDataPacker &dp) const | ||
1642 | { | ||
1643 | LLColor4U color4u(mColor); | ||
1644 | dp.packColor4U(color4u, "color"); | ||
1645 | dp.packF32(mRadius, "radius"); | ||
1646 | dp.packF32(mCutoff, "cutoff"); | ||
1647 | dp.packF32(mFalloff, "falloff"); | ||
1648 | return TRUE; | ||
1649 | } | ||
1650 | |||
1651 | BOOL LLLightParams::unpack(LLDataPacker &dp) | ||
1652 | { | ||
1653 | LLColor4U color4u; | ||
1654 | dp.unpackColor4U(color4u, "color"); | ||
1655 | mColor = LLColor4(color4u); | ||
1656 | dp.unpackF32(mRadius, "radius"); | ||
1657 | dp.unpackF32(mCutoff, "cutoff"); | ||
1658 | dp.unpackF32(mFalloff, "falloff"); | ||
1659 | return TRUE; | ||
1660 | } | ||
1661 | |||
1662 | bool LLLightParams::operator==(const LLNetworkData& data) const | ||
1663 | { | ||
1664 | if (data.mType != PARAMS_LIGHT) | ||
1665 | { | ||
1666 | return false; | ||
1667 | } | ||
1668 | const LLLightParams *param = (const LLLightParams*)&data; | ||
1669 | if (param->mColor != mColor || | ||
1670 | param->mRadius != mRadius || | ||
1671 | param->mCutoff != mCutoff || | ||
1672 | param->mFalloff != mFalloff) | ||
1673 | { | ||
1674 | return false; | ||
1675 | } | ||
1676 | return true; | ||
1677 | } | ||
1678 | |||
1679 | void LLLightParams::copy(const LLNetworkData& data) | ||
1680 | { | ||
1681 | const LLLightParams *param = (LLLightParams*)&data; | ||
1682 | mType = param->mType; | ||
1683 | mColor = param->mColor; | ||
1684 | mRadius = param->mRadius; | ||
1685 | mCutoff = param->mCutoff; | ||
1686 | mFalloff = param->mFalloff; | ||
1687 | } | ||
1688 | |||
1689 | //============================================================================ | ||
1690 | |||
1691 | LLFlexibleObjectData::LLFlexibleObjectData() | ||
1692 | { | ||
1693 | mSimulateLOD = FLEXIBLE_OBJECT_DEFAULT_NUM_SECTIONS; | ||
1694 | mGravity = FLEXIBLE_OBJECT_DEFAULT_GRAVITY; | ||
1695 | mAirFriction = FLEXIBLE_OBJECT_DEFAULT_AIR_FRICTION; | ||
1696 | mWindSensitivity = FLEXIBLE_OBJECT_DEFAULT_WIND_SENSITIVITY; | ||
1697 | mTension = FLEXIBLE_OBJECT_DEFAULT_TENSION; | ||
1698 | //mUsingCollisionSphere = FLEXIBLE_OBJECT_DEFAULT_USING_COLLISION_SPHERE; | ||
1699 | //mRenderingCollisionSphere = FLEXIBLE_OBJECT_DEFAULT_RENDERING_COLLISION_SPHERE; | ||
1700 | mUserForce = LLVector3(0.f, 0.f, 0.f); | ||
1701 | |||
1702 | mType = PARAMS_FLEXIBLE; | ||
1703 | } | ||
1704 | |||
1705 | BOOL LLFlexibleObjectData::pack(LLDataPacker &dp) const | ||
1706 | { | ||
1707 | // Custom, uber-svelte pack "softness" in upper bits of tension & drag | ||
1708 | U8 bit1 = (mSimulateLOD & 2) << 6; | ||
1709 | U8 bit2 = (mSimulateLOD & 1) << 7; | ||
1710 | dp.packU8((U8)(mTension*10.01f) + bit1, "tension"); | ||
1711 | dp.packU8((U8)(mAirFriction*10.01f) + bit2, "drag"); | ||
1712 | dp.packU8((U8)((mGravity+10.f)*10.01f), "gravity"); | ||
1713 | dp.packU8((U8)(mWindSensitivity*10.01f), "wind"); | ||
1714 | dp.packVector3(mUserForce, "userforce"); | ||
1715 | return TRUE; | ||
1716 | } | ||
1717 | |||
1718 | BOOL LLFlexibleObjectData::unpack(LLDataPacker &dp) | ||
1719 | { | ||
1720 | U8 tension, friction, gravity, wind; | ||
1721 | U8 bit1, bit2; | ||
1722 | dp.unpackU8(tension, "tension"); bit1 = (tension >> 6) & 2; | ||
1723 | mTension = ((F32)(tension&0x7f))/10.f; | ||
1724 | dp.unpackU8(friction, "drag"); bit2 = (friction >> 7) & 1; | ||
1725 | mAirFriction = ((F32)(friction&0x7f))/10.f; | ||
1726 | mSimulateLOD = bit1 | bit2; | ||
1727 | dp.unpackU8(gravity, "gravity"); mGravity = ((F32)gravity)/10.f - 10.f; | ||
1728 | dp.unpackU8(wind, "wind"); mWindSensitivity = ((F32)wind)/10.f; | ||
1729 | if (dp.hasNext()) | ||
1730 | { | ||
1731 | dp.unpackVector3(mUserForce, "userforce"); | ||
1732 | } | ||
1733 | else | ||
1734 | { | ||
1735 | mUserForce.setVec(0.f, 0.f, 0.f); | ||
1736 | } | ||
1737 | return TRUE; | ||
1738 | } | ||
1739 | |||
1740 | bool LLFlexibleObjectData::operator==(const LLNetworkData& data) const | ||
1741 | { | ||
1742 | if (data.mType != PARAMS_FLEXIBLE) | ||
1743 | { | ||
1744 | return false; | ||
1745 | } | ||
1746 | LLFlexibleObjectData *flex_data = (LLFlexibleObjectData*)&data; | ||
1747 | return (mSimulateLOD == flex_data->mSimulateLOD && | ||
1748 | mGravity == flex_data->mGravity && | ||
1749 | mAirFriction == flex_data->mAirFriction && | ||
1750 | mWindSensitivity == flex_data->mWindSensitivity && | ||
1751 | mTension == flex_data->mTension && | ||
1752 | mUserForce == flex_data->mUserForce); | ||
1753 | //mUsingCollisionSphere == flex_data->mUsingCollisionSphere && | ||
1754 | //mRenderingCollisionSphere == flex_data->mRenderingCollisionSphere | ||
1755 | } | ||
1756 | |||
1757 | void LLFlexibleObjectData::copy(const LLNetworkData& data) | ||
1758 | { | ||
1759 | const LLFlexibleObjectData *flex_data = (LLFlexibleObjectData*)&data; | ||
1760 | mSimulateLOD = flex_data->mSimulateLOD; | ||
1761 | mGravity = flex_data->mGravity; | ||
1762 | mAirFriction = flex_data->mAirFriction; | ||
1763 | mWindSensitivity = flex_data->mWindSensitivity; | ||
1764 | mTension = flex_data->mTension; | ||
1765 | mUserForce = flex_data->mUserForce; | ||
1766 | //mUsingCollisionSphere = flex_data->mUsingCollisionSphere; | ||
1767 | //mRenderingCollisionSphere = flex_data->mRenderingCollisionSphere; | ||
1768 | } | ||
diff --git a/linden/indra/llprimitive/llprimitive.h b/linden/indra/llprimitive/llprimitive.h new file mode 100644 index 0000000..e51fdcf --- /dev/null +++ b/linden/indra/llprimitive/llprimitive.h | |||
@@ -0,0 +1,529 @@ | |||
1 | /** | ||
2 | * @file llprimitive.h | ||
3 | * @brief LLPrimitive 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 | #ifndef LL_LLPRIMITIVE_H | ||
29 | #define LL_LLPRIMITIVE_H | ||
30 | |||
31 | #include "lluuid.h" | ||
32 | #include "v3math.h" | ||
33 | #include "xform.h" | ||
34 | #include "message.h" | ||
35 | #include "llmemory.h" | ||
36 | #include "llvolume.h" | ||
37 | #include "lltextureentry.h" | ||
38 | |||
39 | // Moved to stdtypes.h --JC | ||
40 | // typedef U8 LLPCode; | ||
41 | class LLMessageSystem; | ||
42 | class LLVolumeParams; | ||
43 | class LLColor4; | ||
44 | class LLColor3; | ||
45 | class LLTextureEntry; | ||
46 | class LLDataPacker; | ||
47 | |||
48 | enum LLGeomType // NOTE: same vals as GL Ids | ||
49 | { | ||
50 | LLInvalid = 0, | ||
51 | LLLineLoop = 2, | ||
52 | LLLineStrip = 3, | ||
53 | LLTriangles = 4, | ||
54 | LLTriStrip = 5, | ||
55 | LLTriFan = 6, | ||
56 | LLQuads = 7, | ||
57 | LLQuadStrip = 8 | ||
58 | }; | ||
59 | |||
60 | class LLVolume; | ||
61 | |||
62 | /** | ||
63 | * exported constants | ||
64 | */ | ||
65 | extern const F32 OBJECT_CUT_MIN; | ||
66 | extern const F32 OBJECT_CUT_MAX; | ||
67 | extern const F32 OBJECT_CUT_INC; | ||
68 | extern const F32 OBJECT_MIN_CUT_INC; | ||
69 | extern const F32 OBJECT_ROTATION_PRECISION; | ||
70 | |||
71 | extern const F32 OBJECT_TWIST_MIN; | ||
72 | extern const F32 OBJECT_TWIST_MAX; | ||
73 | extern const F32 OBJECT_TWIST_INC; | ||
74 | |||
75 | // This is used for linear paths, | ||
76 | // since twist is used in a slightly different manner. | ||
77 | extern const F32 OBJECT_TWIST_LINEAR_MIN; | ||
78 | extern const F32 OBJECT_TWIST_LINEAR_MAX; | ||
79 | extern const F32 OBJECT_TWIST_LINEAR_INC; | ||
80 | |||
81 | extern const F32 OBJECT_MIN_HOLE_SIZE; | ||
82 | extern const F32 OBJECT_MAX_HOLE_SIZE_X; | ||
83 | extern const F32 OBJECT_MAX_HOLE_SIZE_Y; | ||
84 | |||
85 | // Revolutions parameters. | ||
86 | extern const F32 OBJECT_REV_MIN; | ||
87 | extern const F32 OBJECT_REV_MAX; | ||
88 | extern const F32 OBJECT_REV_INC; | ||
89 | |||
90 | |||
91 | //============================================================================ | ||
92 | |||
93 | // TomY: Base class for things that pack & unpack themselves | ||
94 | class LLNetworkData | ||
95 | { | ||
96 | public: | ||
97 | // Extra parameter IDs | ||
98 | enum | ||
99 | { | ||
100 | PARAMS_FLEXIBLE = 0x10, | ||
101 | PARAMS_LIGHT = 0x20 | ||
102 | }; | ||
103 | |||
104 | public: | ||
105 | U16 mType; | ||
106 | virtual ~LLNetworkData() {}; | ||
107 | virtual BOOL pack(LLDataPacker &dp) const = 0; | ||
108 | virtual BOOL unpack(LLDataPacker &dp) = 0; | ||
109 | virtual bool operator==(const LLNetworkData& data) const = 0; | ||
110 | virtual void copy(const LLNetworkData& data) = 0; | ||
111 | }; | ||
112 | |||
113 | extern const F32 LIGHT_MIN_RADIUS; | ||
114 | extern const F32 LIGHT_DEFAULT_RADIUS; | ||
115 | extern const F32 LIGHT_MAX_RADIUS; | ||
116 | extern const F32 LIGHT_MIN_FALLOFF; | ||
117 | extern const F32 LIGHT_DEFAULT_FALLOFF; | ||
118 | extern const F32 LIGHT_MAX_FALLOFF; | ||
119 | extern const F32 LIGHT_MIN_CUTOFF; | ||
120 | extern const F32 LIGHT_DEFAULT_CUTOFF; | ||
121 | extern const F32 LIGHT_MAX_CUTOFF; | ||
122 | |||
123 | class LLLightParams : public LLNetworkData | ||
124 | { | ||
125 | protected: | ||
126 | LLColor4 mColor; // alpha = intensity | ||
127 | F32 mRadius; | ||
128 | F32 mFalloff; | ||
129 | F32 mCutoff; | ||
130 | |||
131 | public: | ||
132 | LLLightParams(); | ||
133 | /*virtual*/ BOOL pack(LLDataPacker &dp) const; | ||
134 | /*virtual*/ BOOL unpack(LLDataPacker &dp); | ||
135 | /*virtual*/ bool operator==(const LLNetworkData& data) const; | ||
136 | /*virtual*/ void copy(const LLNetworkData& data); | ||
137 | |||
138 | void setColor(const LLColor4& color) { mColor = color; mColor.clamp(); } | ||
139 | void setRadius(F32 radius) { mRadius = llclamp(radius, LIGHT_MIN_RADIUS, LIGHT_MAX_RADIUS); } | ||
140 | void setFalloff(F32 falloff) { mFalloff = llclamp(falloff, LIGHT_MIN_FALLOFF, LIGHT_MAX_FALLOFF); } | ||
141 | void setCutoff(F32 cutoff) { mCutoff = llclamp(cutoff, LIGHT_MIN_CUTOFF, LIGHT_MAX_CUTOFF); } | ||
142 | |||
143 | LLColor4 getColor() const { return mColor; } | ||
144 | F32 getRadius() const { return mRadius; } | ||
145 | F32 getFalloff() const { return mFalloff; } | ||
146 | F32 getCutoff() const { return mCutoff; } | ||
147 | }; | ||
148 | |||
149 | //------------------------------------------------- | ||
150 | // This structure is also used in the part of the | ||
151 | // code that creates new flexible objects. | ||
152 | //------------------------------------------------- | ||
153 | |||
154 | // These were made into enums so that they could be used as fixed size | ||
155 | // array bounds. | ||
156 | enum EFlexibleObjectConst | ||
157 | { | ||
158 | // "Softness" => [0,3], increments of 1 | ||
159 | // Represents powers of 2: 0 -> 1, 3 -> 8 | ||
160 | FLEXIBLE_OBJECT_MIN_SECTIONS = 0, | ||
161 | FLEXIBLE_OBJECT_DEFAULT_NUM_SECTIONS = 2, | ||
162 | FLEXIBLE_OBJECT_MAX_SECTIONS = 3 | ||
163 | }; | ||
164 | |||
165 | // "Tension" => [0,10], increments of 0.1 | ||
166 | extern const F32 FLEXIBLE_OBJECT_MIN_TENSION; | ||
167 | extern const F32 FLEXIBLE_OBJECT_DEFAULT_TENSION; | ||
168 | extern const F32 FLEXIBLE_OBJECT_MAX_TENSION; | ||
169 | |||
170 | // "Drag" => [0,10], increments of 0.1 | ||
171 | extern const F32 FLEXIBLE_OBJECT_MIN_AIR_FRICTION; | ||
172 | extern const F32 FLEXIBLE_OBJECT_DEFAULT_AIR_FRICTION; | ||
173 | extern const F32 FLEXIBLE_OBJECT_MAX_AIR_FRICTION; | ||
174 | |||
175 | // "Gravity" = [-10,10], increments of 0.1 | ||
176 | extern const F32 FLEXIBLE_OBJECT_MIN_GRAVITY; | ||
177 | extern const F32 FLEXIBLE_OBJECT_DEFAULT_GRAVITY; | ||
178 | extern const F32 FLEXIBLE_OBJECT_MAX_GRAVITY; | ||
179 | |||
180 | // "Wind" = [0,10], increments of 0.1 | ||
181 | extern const F32 FLEXIBLE_OBJECT_MIN_WIND_SENSITIVITY; | ||
182 | extern const F32 FLEXIBLE_OBJECT_DEFAULT_WIND_SENSITIVITY; | ||
183 | extern const F32 FLEXIBLE_OBJECT_MAX_WIND_SENSITIVITY; | ||
184 | |||
185 | extern const F32 FLEXIBLE_OBJECT_MAX_INTERNAL_TENSION_FORCE; | ||
186 | |||
187 | extern const F32 FLEXIBLE_OBJECT_DEFAULT_LENGTH; | ||
188 | extern const BOOL FLEXIBLE_OBJECT_DEFAULT_USING_COLLISION_SPHERE; | ||
189 | extern const BOOL FLEXIBLE_OBJECT_DEFAULT_RENDERING_COLLISION_SPHERE; | ||
190 | |||
191 | |||
192 | class LLFlexibleObjectData : public LLNetworkData | ||
193 | { | ||
194 | protected: | ||
195 | S32 mSimulateLOD; // 2^n = number of simulated sections | ||
196 | F32 mGravity; | ||
197 | F32 mAirFriction; // higher is more stable, but too much looks like it's underwater | ||
198 | F32 mWindSensitivity; // interacts with tension, air friction, and gravity | ||
199 | F32 mTension; //interacts in complex ways with other parameters | ||
200 | LLVector3 mUserForce; // custom user-defined force vector | ||
201 | //BOOL mUsingCollisionSphere; | ||
202 | //BOOL mRenderingCollisionSphere; | ||
203 | |||
204 | public: | ||
205 | void setSimulateLOD(S32 lod) { mSimulateLOD = llclamp(lod, (S32)FLEXIBLE_OBJECT_MIN_SECTIONS, (S32)FLEXIBLE_OBJECT_MAX_SECTIONS); } | ||
206 | void setGravity(F32 gravity) { mGravity = llclamp(gravity, FLEXIBLE_OBJECT_MIN_GRAVITY, FLEXIBLE_OBJECT_MAX_GRAVITY); } | ||
207 | void setAirFriction(F32 friction) { mAirFriction = llclamp(friction, FLEXIBLE_OBJECT_MIN_AIR_FRICTION, FLEXIBLE_OBJECT_MAX_AIR_FRICTION); } | ||
208 | void setWindSensitivity(F32 wind) { mWindSensitivity = llclamp(wind, FLEXIBLE_OBJECT_MIN_WIND_SENSITIVITY, FLEXIBLE_OBJECT_MAX_WIND_SENSITIVITY); } | ||
209 | void setTension(F32 tension) { mTension = llclamp(tension, FLEXIBLE_OBJECT_MIN_TENSION, FLEXIBLE_OBJECT_MAX_TENSION); } | ||
210 | void setUserForce(LLVector3 &force) { mUserForce = force; } | ||
211 | |||
212 | S32 getSimulateLOD() const { return mSimulateLOD; } | ||
213 | F32 getGravity() const { return mGravity; } | ||
214 | F32 getAirFriction() const { return mAirFriction; } | ||
215 | F32 getWindSensitivity() const { return mWindSensitivity; } | ||
216 | F32 getTension() const { return mTension; } | ||
217 | LLVector3 getUserForce() const { return mUserForce; } | ||
218 | |||
219 | //------ the constructor for the structure ------------ | ||
220 | LLFlexibleObjectData(); | ||
221 | BOOL pack(LLDataPacker &dp) const; | ||
222 | BOOL unpack(LLDataPacker &dp); | ||
223 | bool operator==(const LLNetworkData& data) const; | ||
224 | void copy(const LLNetworkData& data); | ||
225 | };// end of attributes structure | ||
226 | |||
227 | class LLPrimitive : public LLXform | ||
228 | { | ||
229 | public: | ||
230 | LLPrimitive(); | ||
231 | virtual ~LLPrimitive(); | ||
232 | |||
233 | static LLPrimitive *createPrimitive(LLPCode p_code); | ||
234 | void init(LLPCode p_code); | ||
235 | |||
236 | void setPCode(const LLPCode pcode); | ||
237 | const LLVolume *getVolumeConst() const { return mVolumep; } // HACK for Windoze confusion about ostream operator in LLVolume | ||
238 | LLVolume *getVolume() const { return mVolumep; } | ||
239 | virtual BOOL setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume = false); | ||
240 | |||
241 | // Modify texture entry properties | ||
242 | inline BOOL validTE(const U8 te_num) const; | ||
243 | const LLTextureEntry *getTE(const U8 te_num) const; | ||
244 | |||
245 | virtual void setNumTEs(const U8 num_tes); | ||
246 | virtual void setAllTETextures(const LLUUID &tex_id); | ||
247 | virtual void setTE(const U8 index, const LLTextureEntry &te); | ||
248 | virtual S32 setTEColor(const U8 te, const LLColor4 &color); | ||
249 | virtual S32 setTEColor(const U8 te, const LLColor3 &color); | ||
250 | virtual S32 setTEAlpha(const U8 te, const F32 alpha); | ||
251 | virtual S32 setTETexture(const U8 te, const LLUUID &tex_id); | ||
252 | virtual S32 setTEScale (const U8 te, const F32 s, const F32 t); | ||
253 | virtual S32 setTEScaleS(const U8 te, const F32 s); | ||
254 | virtual S32 setTEScaleT(const U8 te, const F32 t); | ||
255 | virtual S32 setTEOffset (const U8 te, const F32 s, const F32 t); | ||
256 | virtual S32 setTEOffsetS(const U8 te, const F32 s); | ||
257 | virtual S32 setTEOffsetT(const U8 te, const F32 t); | ||
258 | virtual S32 setTERotation(const U8 te, const F32 r); | ||
259 | virtual S32 setTEBumpShinyFullbright(const U8 te, const U8 bump); | ||
260 | virtual S32 setTEBumpShiny(const U8 te, const U8 bump); | ||
261 | virtual S32 setTEMediaTexGen(const U8 te, const U8 media); | ||
262 | virtual S32 setTEBumpmap(const U8 te, const U8 bump); | ||
263 | virtual S32 setTETexGen(const U8 te, const U8 texgen); | ||
264 | virtual S32 setTEShiny(const U8 te, const U8 shiny); | ||
265 | virtual S32 setTEFullbright(const U8 te, const U8 fullbright); | ||
266 | virtual S32 setTEMediaFlags(const U8 te, const U8 flags); | ||
267 | virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed | ||
268 | |||
269 | void setTEArrays(const U8 size, | ||
270 | const LLUUID* image_ids, | ||
271 | const F32* scale_s, | ||
272 | const F32* scale_t); | ||
273 | void copyTEs(const LLPrimitive *primitive); | ||
274 | S32 packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const; | ||
275 | S32 unpackTEField(U8 *cur_ptr, U8 *buffer_end, U8 *data_ptr, U8 data_size, U8 face_count, EMsgVariableType type); | ||
276 | BOOL packTEMessage(LLMessageSystem *mesgsys) const; | ||
277 | BOOL packTEMessage(LLDataPacker &dp) const; | ||
278 | S32 unpackTEMessage(LLMessageSystem *mesgsys, char *block_name); | ||
279 | S32 unpackTEMessage(LLMessageSystem *mesgsys, char *block_name, const S32 block_num); // Variable num of blocks | ||
280 | BOOL unpackTEMessage(LLDataPacker &dp); | ||
281 | |||
282 | #ifdef CHECK_FOR_FINITE | ||
283 | inline void setPosition(const LLVector3& pos); | ||
284 | inline void setPosition(const F32 x, const F32 y, const F32 z); | ||
285 | inline void addPosition(const LLVector3& pos); | ||
286 | |||
287 | inline void setAngularVelocity(const LLVector3& avel); | ||
288 | inline void setAngularVelocity(const F32 x, const F32 y, const F32 z); | ||
289 | inline void setVelocity(const LLVector3& vel); | ||
290 | inline void setVelocity(const F32 x, const F32 y, const F32 z); | ||
291 | inline void setVelocityX(const F32 x); | ||
292 | inline void setVelocityY(const F32 y); | ||
293 | inline void setVelocityZ(const F32 z); | ||
294 | inline void addVelocity(const LLVector3& vel); | ||
295 | inline void setAcceleration(const LLVector3& accel); | ||
296 | inline void setAcceleration(const F32 x, const F32 y, const F32 z); | ||
297 | #else | ||
298 | // Don't override the base LLXForm operators. | ||
299 | // Special case for setPosition. If not check-for-finite, fall through to LLXform method. | ||
300 | // void setPosition(F32 x, F32 y, F32 z) | ||
301 | // void setPosition(LLVector3) | ||
302 | |||
303 | void setAngularVelocity(const LLVector3& avel) { mAngularVelocity = avel; } | ||
304 | void setAngularVelocity(const F32 x, const F32 y, const F32 z) { mAngularVelocity.setVec(x,y,z); } | ||
305 | void setVelocity(const LLVector3& vel) { mVelocity = vel; } | ||
306 | void setVelocity(const F32 x, const F32 y, const F32 z) { mVelocity.setVec(x,y,z); } | ||
307 | void setVelocityX(const F32 x) { mVelocity.mV[VX] = x; } | ||
308 | void setVelocityY(const F32 y) { mVelocity.mV[VY] = y; } | ||
309 | void setVelocityZ(const F32 z) { mVelocity.mV[VZ] = z; } | ||
310 | void addVelocity(const LLVector3& vel) { mVelocity += vel; } | ||
311 | void setAcceleration(const LLVector3& accel) { mAcceleration = accel; } | ||
312 | void setAcceleration(const F32 x, const F32 y, const F32 z) { mAcceleration.setVec(x,y,z); } | ||
313 | #endif | ||
314 | |||
315 | const LLPCode getPCode() const { return mPrimitiveCode; } | ||
316 | const char * getPCodeString() const { return pCodeToString(mPrimitiveCode); } | ||
317 | const LLVector3& getAngularVelocity() const { return mAngularVelocity; } | ||
318 | const LLVector3& getVelocity() const { return mVelocity; } | ||
319 | const LLVector3& getAcceleration() const { return mAcceleration; } | ||
320 | const U8 getNumTEs() const { return mNumTEs; } | ||
321 | |||
322 | const U8 getMaterial() const { return mMaterial; } | ||
323 | |||
324 | void setVolumeType(const U8 code); | ||
325 | U8 getVolumeType(); | ||
326 | |||
327 | void setTextureList(LLTextureEntry *listp); | ||
328 | |||
329 | inline BOOL isAvatar() const; | ||
330 | |||
331 | static const char *pCodeToString(const LLPCode pcode); | ||
332 | static LLPCode legacyToPCode(const U8 legacy); | ||
333 | static U8 pCodeToLegacy(const LLPCode pcode); | ||
334 | |||
335 | inline static BOOL isPrimitive(const LLPCode pcode); | ||
336 | inline static BOOL isApp(const LLPCode pcode); | ||
337 | |||
338 | protected: | ||
339 | LLPCode mPrimitiveCode; // Primitive code | ||
340 | LLVector3 mVelocity; // how fast are we moving? | ||
341 | LLVector3 mAcceleration; // are we under constant acceleration? | ||
342 | LLVector3 mAngularVelocity; // angular velocity | ||
343 | LLPointer<LLVolume> mVolumep; | ||
344 | LLTextureEntry *mTextureList; // list of texture GUIDs, scales, offsets | ||
345 | U8 mMaterial; // Material code | ||
346 | U8 mNumTEs; // # of faces on the primitve | ||
347 | }; | ||
348 | |||
349 | inline BOOL LLPrimitive::isAvatar() const | ||
350 | { | ||
351 | return mPrimitiveCode == LL_PCODE_LEGACY_AVATAR; | ||
352 | } | ||
353 | |||
354 | // static | ||
355 | inline BOOL LLPrimitive::isPrimitive(const LLPCode pcode) | ||
356 | { | ||
357 | LLPCode base_type = pcode & LL_PCODE_BASE_MASK; | ||
358 | |||
359 | if (base_type && (base_type < LL_PCODE_APP)) | ||
360 | { | ||
361 | return TRUE; | ||
362 | } | ||
363 | return FALSE; | ||
364 | } | ||
365 | |||
366 | // static | ||
367 | inline BOOL LLPrimitive::isApp(const LLPCode pcode) | ||
368 | { | ||
369 | LLPCode base_type = pcode & LL_PCODE_BASE_MASK; | ||
370 | |||
371 | return (base_type == LL_PCODE_APP); | ||
372 | } | ||
373 | |||
374 | |||
375 | #ifdef CHECK_FOR_FINITE | ||
376 | // Special case for setPosition. If not check-for-finite, fall through to LLXform method. | ||
377 | void LLPrimitive::setPosition(const F32 x, const F32 y, const F32 z) | ||
378 | { | ||
379 | if (llfinite(x) && llfinite(y) && llfinite(z)) | ||
380 | { | ||
381 | LLXform::setPosition(x, y, z); | ||
382 | } | ||
383 | else | ||
384 | { | ||
385 | llerrs << "Non Finite in LLPrimitive::setPosition(x,y,z) for " << pCodeToString(mPrimitiveCode) << llendl; | ||
386 | } | ||
387 | } | ||
388 | |||
389 | // Special case for setPosition. If not check-for-finite, fall through to LLXform method. | ||
390 | void LLPrimitive::setPosition(const LLVector3& pos) | ||
391 | { | ||
392 | if (pos.isFinite()) | ||
393 | { | ||
394 | LLXform::setPosition(pos); | ||
395 | } | ||
396 | else | ||
397 | { | ||
398 | llerrs << "Non Finite in LLPrimitive::setPosition(LLVector3) for " << pCodeToString(mPrimitiveCode) << llendl; | ||
399 | } | ||
400 | } | ||
401 | |||
402 | void LLPrimitive::setAngularVelocity(const LLVector3& avel) | ||
403 | { | ||
404 | if (avel.isFinite()) | ||
405 | { | ||
406 | mAngularVelocity = avel; | ||
407 | } | ||
408 | else | ||
409 | { | ||
410 | llerror("Non Finite in LLPrimitive::setAngularVelocity", 0); | ||
411 | } | ||
412 | } | ||
413 | |||
414 | void LLPrimitive::setAngularVelocity(const F32 x, const F32 y, const F32 z) | ||
415 | { | ||
416 | if (llfinite(x) && llfinite(y) && llfinite(z)) | ||
417 | { | ||
418 | mAngularVelocity.setVec(x,y,z); | ||
419 | } | ||
420 | else | ||
421 | { | ||
422 | llerror("Non Finite in LLPrimitive::setAngularVelocity", 0); | ||
423 | } | ||
424 | } | ||
425 | |||
426 | void LLPrimitive::setVelocity(const LLVector3& vel) | ||
427 | { | ||
428 | if (vel.isFinite()) | ||
429 | { | ||
430 | mVelocity = vel; | ||
431 | } | ||
432 | else | ||
433 | { | ||
434 | llerrs << "Non Finite in LLPrimitive::setVelocity(LLVector3) for " << pCodeToString(mPrimitiveCode) << llendl; | ||
435 | } | ||
436 | } | ||
437 | |||
438 | void LLPrimitive::setVelocity(const F32 x, const F32 y, const F32 z) | ||
439 | { | ||
440 | if (llfinite(x) && llfinite(y) && llfinite(z)) | ||
441 | { | ||
442 | mVelocity.setVec(x,y,z); | ||
443 | } | ||
444 | else | ||
445 | { | ||
446 | llerrs << "Non Finite in LLPrimitive::setVelocity(F32,F32,F32) for " << pCodeToString(mPrimitiveCode) << llendl; | ||
447 | } | ||
448 | } | ||
449 | |||
450 | void LLPrimitive::setVelocityX(const F32 x) | ||
451 | { | ||
452 | if (llfinite(x)) | ||
453 | { | ||
454 | mVelocity.mV[VX] = x; | ||
455 | } | ||
456 | else | ||
457 | { | ||
458 | llerror("Non Finite in LLPrimitive::setVelocityX", 0); | ||
459 | } | ||
460 | } | ||
461 | |||
462 | void LLPrimitive::setVelocityY(const F32 y) | ||
463 | { | ||
464 | if (llfinite(y)) | ||
465 | { | ||
466 | mVelocity.mV[VY] = y; | ||
467 | } | ||
468 | else | ||
469 | { | ||
470 | llerror("Non Finite in LLPrimitive::setVelocityY", 0); | ||
471 | } | ||
472 | } | ||
473 | |||
474 | void LLPrimitive::setVelocityZ(const F32 z) | ||
475 | { | ||
476 | if (llfinite(z)) | ||
477 | { | ||
478 | mVelocity.mV[VZ] = z; | ||
479 | } | ||
480 | else | ||
481 | { | ||
482 | llerror("Non Finite in LLPrimitive::setVelocityZ", 0); | ||
483 | } | ||
484 | } | ||
485 | |||
486 | void LLPrimitive::addVelocity(const LLVector3& vel) | ||
487 | { | ||
488 | if (vel.isFinite()) | ||
489 | { | ||
490 | mVelocity += vel; | ||
491 | } | ||
492 | else | ||
493 | { | ||
494 | llerror("Non Finite in LLPrimitive::addVelocity", 0); | ||
495 | } | ||
496 | } | ||
497 | |||
498 | void LLPrimitive::setAcceleration(const LLVector3& accel) | ||
499 | { | ||
500 | if (accel.isFinite()) | ||
501 | { | ||
502 | mAcceleration = accel; | ||
503 | } | ||
504 | else | ||
505 | { | ||
506 | llerrs << "Non Finite in LLPrimitive::setAcceleration(LLVector3) for " << pCodeToString(mPrimitiveCode) << llendl; | ||
507 | } | ||
508 | } | ||
509 | |||
510 | void LLPrimitive::setAcceleration(const F32 x, const F32 y, const F32 z) | ||
511 | { | ||
512 | if (llfinite(x) && llfinite(y) && llfinite(z)) | ||
513 | { | ||
514 | mAcceleration.setVec(x,y,z); | ||
515 | } | ||
516 | else | ||
517 | { | ||
518 | llerrs << "Non Finite in LLPrimitive::setAcceleration(F32,F32,F32) for " << pCodeToString(mPrimitiveCode) << llendl; | ||
519 | } | ||
520 | } | ||
521 | #endif // CHECK_FOR_FINITE | ||
522 | |||
523 | inline BOOL LLPrimitive::validTE(const U8 te_num) const | ||
524 | { | ||
525 | return (mNumTEs && te_num < mNumTEs); | ||
526 | } | ||
527 | |||
528 | #endif | ||
529 | |||
diff --git a/linden/indra/llprimitive/llprimitive.vcproj b/linden/indra/llprimitive/llprimitive.vcproj new file mode 100644 index 0000000..60dc82e --- /dev/null +++ b/linden/indra/llprimitive/llprimitive.vcproj | |||
@@ -0,0 +1,219 @@ | |||
1 | <?xml version="1.0" encoding="Windows-1252"?> | ||
2 | <VisualStudioProject | ||
3 | ProjectType="Visual C++" | ||
4 | Version="7.10" | ||
5 | Name="llprimitive" | ||
6 | ProjectGUID="{FCC4483C-5B84-4944-B91F-4589A219BC0B}" | ||
7 | Keyword="Win32Proj"> | ||
8 | <Platforms> | ||
9 | <Platform | ||
10 | Name="Win32"/> | ||
11 | </Platforms> | ||
12 | <Configurations> | ||
13 | <Configuration | ||
14 | Name="Debug|Win32" | ||
15 | OutputDirectory="../lib_$(ConfigurationName)/i686-win32" | ||
16 | IntermediateDirectory="Debug" | ||
17 | ConfigurationType="4" | ||
18 | CharacterSet="1"> | ||
19 | <Tool | ||
20 | Name="VCCLCompilerTool" | ||
21 | Optimization="0" | ||
22 | AdditionalIncludeDirectories="..\llxml;..\llprimitive;..\llcommon;..\llmath;..\llmessage;..\..\libraries\i686-win32\include;..\..\libraries\include\" | ||
23 | PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;LL_DEBUG" | ||
24 | MinimalRebuild="TRUE" | ||
25 | BasicRuntimeChecks="3" | ||
26 | RuntimeLibrary="1" | ||
27 | StructMemberAlignment="4" | ||
28 | ForceConformanceInForLoopScope="TRUE" | ||
29 | UsePrecompiledHeader="0" | ||
30 | WarningLevel="3" | ||
31 | WarnAsError="TRUE" | ||
32 | Detect64BitPortabilityProblems="FALSE" | ||
33 | DebugInformationFormat="4"/> | ||
34 | <Tool | ||
35 | Name="VCCustomBuildTool"/> | ||
36 | <Tool | ||
37 | Name="VCLibrarianTool" | ||
38 | OutputFile="$(OutDir)/llprimitive.lib"/> | ||
39 | <Tool | ||
40 | Name="VCMIDLTool"/> | ||
41 | <Tool | ||
42 | Name="VCPostBuildEventTool"/> | ||
43 | <Tool | ||
44 | Name="VCPreBuildEventTool"/> | ||
45 | <Tool | ||
46 | Name="VCPreLinkEventTool"/> | ||
47 | <Tool | ||
48 | Name="VCResourceCompilerTool"/> | ||
49 | <Tool | ||
50 | Name="VCWebServiceProxyGeneratorTool"/> | ||
51 | <Tool | ||
52 | Name="VCXMLDataGeneratorTool"/> | ||
53 | <Tool | ||
54 | Name="VCManagedWrapperGeneratorTool"/> | ||
55 | <Tool | ||
56 | Name="VCAuxiliaryManagedWrapperGeneratorTool"/> | ||
57 | </Configuration> | ||
58 | <Configuration | ||
59 | Name="Release|Win32" | ||
60 | OutputDirectory="../lib_$(ConfigurationName)/i686-win32" | ||
61 | IntermediateDirectory="Release" | ||
62 | ConfigurationType="4" | ||
63 | CharacterSet="1"> | ||
64 | <Tool | ||
65 | Name="VCCLCompilerTool" | ||
66 | AdditionalIncludeDirectories="..\llxml;..\llprimitive;..\llcommon;..\llmath;..\llmessage;..\..\libraries\i686-win32\include;..\..\libraries\include\" | ||
67 | PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE" | ||
68 | RuntimeLibrary="0" | ||
69 | StructMemberAlignment="0" | ||
70 | ForceConformanceInForLoopScope="TRUE" | ||
71 | UsePrecompiledHeader="0" | ||
72 | WarningLevel="3" | ||
73 | WarnAsError="TRUE" | ||
74 | Detect64BitPortabilityProblems="FALSE" | ||
75 | DebugInformationFormat="3"/> | ||
76 | <Tool | ||
77 | Name="VCCustomBuildTool"/> | ||
78 | <Tool | ||
79 | Name="VCLibrarianTool" | ||
80 | OutputFile="$(OutDir)/llprimitive.lib"/> | ||
81 | <Tool | ||
82 | Name="VCMIDLTool"/> | ||
83 | <Tool | ||
84 | Name="VCPostBuildEventTool"/> | ||
85 | <Tool | ||
86 | Name="VCPreBuildEventTool"/> | ||
87 | <Tool | ||
88 | Name="VCPreLinkEventTool"/> | ||
89 | <Tool | ||
90 | Name="VCResourceCompilerTool"/> | ||
91 | <Tool | ||
92 | Name="VCWebServiceProxyGeneratorTool"/> | ||
93 | <Tool | ||
94 | Name="VCXMLDataGeneratorTool"/> | ||
95 | <Tool | ||
96 | Name="VCManagedWrapperGeneratorTool"/> | ||
97 | <Tool | ||
98 | Name="VCAuxiliaryManagedWrapperGeneratorTool"/> | ||
99 | </Configuration> | ||
100 | <Configuration | ||
101 | Name="ReleaseNoOpt|Win32" | ||
102 | OutputDirectory="../lib_$(ConfigurationName)/i686-win32" | ||
103 | IntermediateDirectory="$(ConfigurationName)" | ||
104 | ConfigurationType="4" | ||
105 | CharacterSet="1"> | ||
106 | <Tool | ||
107 | Name="VCCLCompilerTool" | ||
108 | Optimization="0" | ||
109 | AdditionalIncludeDirectories="..\llxml;..\llprimitive;..\llcommon;..\llmath;..\llmessage;..\..\libraries\i686-win32\include;..\..\libraries\include\" | ||
110 | PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE" | ||
111 | RuntimeLibrary="0" | ||
112 | StructMemberAlignment="0" | ||
113 | ForceConformanceInForLoopScope="TRUE" | ||
114 | UsePrecompiledHeader="0" | ||
115 | WarningLevel="3" | ||
116 | WarnAsError="TRUE" | ||
117 | Detect64BitPortabilityProblems="FALSE" | ||
118 | DebugInformationFormat="3"/> | ||
119 | <Tool | ||
120 | Name="VCCustomBuildTool"/> | ||
121 | <Tool | ||
122 | Name="VCLibrarianTool" | ||
123 | OutputFile="$(OutDir)/llprimitive.lib"/> | ||
124 | <Tool | ||
125 | Name="VCMIDLTool"/> | ||
126 | <Tool | ||
127 | Name="VCPostBuildEventTool"/> | ||
128 | <Tool | ||
129 | Name="VCPreBuildEventTool"/> | ||
130 | <Tool | ||
131 | Name="VCPreLinkEventTool"/> | ||
132 | <Tool | ||
133 | Name="VCResourceCompilerTool"/> | ||
134 | <Tool | ||
135 | Name="VCWebServiceProxyGeneratorTool"/> | ||
136 | <Tool | ||
137 | Name="VCXMLDataGeneratorTool"/> | ||
138 | <Tool | ||
139 | Name="VCManagedWrapperGeneratorTool"/> | ||
140 | <Tool | ||
141 | Name="VCAuxiliaryManagedWrapperGeneratorTool"/> | ||
142 | </Configuration> | ||
143 | </Configurations> | ||
144 | <References> | ||
145 | </References> | ||
146 | <Files> | ||
147 | <Filter | ||
148 | Name="Source Files" | ||
149 | Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" | ||
150 | UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> | ||
151 | <File | ||
152 | RelativePath=".\llmaterialtable.cpp"> | ||
153 | </File> | ||
154 | <File | ||
155 | RelativePath=".\llprimitive.cpp"> | ||
156 | </File> | ||
157 | <File | ||
158 | RelativePath=".\lltextureanim.cpp"> | ||
159 | </File> | ||
160 | <File | ||
161 | RelativePath=".\lltextureentry.cpp"> | ||
162 | </File> | ||
163 | <File | ||
164 | RelativePath=".\lltreeparams.cpp"> | ||
165 | </File> | ||
166 | <File | ||
167 | RelativePath=".\llvolumemessage.cpp"> | ||
168 | </File> | ||
169 | <File | ||
170 | RelativePath=".\llvolumexml.cpp"> | ||
171 | </File> | ||
172 | </Filter> | ||
173 | <Filter | ||
174 | Name="Header Files" | ||
175 | Filter="h;hpp;hxx;hm;inl;inc;xsd" | ||
176 | UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> | ||
177 | <File | ||
178 | RelativePath=".\legacy_object_types.h"> | ||
179 | </File> | ||
180 | <File | ||
181 | RelativePath=".\llmaterialtable.h"> | ||
182 | </File> | ||
183 | <File | ||
184 | RelativePath=".\llprimitive.h"> | ||
185 | </File> | ||
186 | <File | ||
187 | RelativePath=".\lltextureanim.h"> | ||
188 | </File> | ||
189 | <File | ||
190 | RelativePath=".\lltextureentry.h"> | ||
191 | </File> | ||
192 | <File | ||
193 | RelativePath=".\lltree_common.h"> | ||
194 | </File> | ||
195 | <File | ||
196 | RelativePath=".\lltreeparams.h"> | ||
197 | </File> | ||
198 | <File | ||
199 | RelativePath=".\llvolumemessage.h"> | ||
200 | </File> | ||
201 | <File | ||
202 | RelativePath=".\llvolumexml.h"> | ||
203 | </File> | ||
204 | <File | ||
205 | RelativePath=".\material_codes.h"> | ||
206 | </File> | ||
207 | <File | ||
208 | RelativePath=".\object_flags.h"> | ||
209 | </File> | ||
210 | </Filter> | ||
211 | <Filter | ||
212 | Name="Resource Files" | ||
213 | Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" | ||
214 | UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"> | ||
215 | </Filter> | ||
216 | </Files> | ||
217 | <Globals> | ||
218 | </Globals> | ||
219 | </VisualStudioProject> | ||
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 | } | ||
diff --git a/linden/indra/llprimitive/lltextureanim.h b/linden/indra/llprimitive/lltextureanim.h new file mode 100644 index 0000000..b47d492 --- /dev/null +++ b/linden/indra/llprimitive/lltextureanim.h | |||
@@ -0,0 +1,73 @@ | |||
1 | /** | ||
2 | * @file lltextureanim.h | ||
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 | #ifndef LL_LLTEXTUREANIM_H | ||
29 | #define LL_LLTEXTUREANIM_H | ||
30 | |||
31 | #include "stdtypes.h" | ||
32 | #include "llsd.h" | ||
33 | |||
34 | class LLMessageSystem; | ||
35 | class LLDataPacker; | ||
36 | |||
37 | class LLTextureAnim | ||
38 | { | ||
39 | public: | ||
40 | LLTextureAnim(); | ||
41 | virtual ~LLTextureAnim(); | ||
42 | |||
43 | virtual void reset(); | ||
44 | void packTAMessage(LLMessageSystem *mesgsys) const; | ||
45 | void packTAMessage(LLDataPacker &dp) const; | ||
46 | void unpackTAMessage(LLMessageSystem *mesgsys, const S32 block_num); | ||
47 | void unpackTAMessage(LLDataPacker &dp); | ||
48 | BOOL equals(const LLTextureAnim &other) const; | ||
49 | LLSD asLLSD() const; | ||
50 | operator LLSD() const { return asLLSD(); } | ||
51 | bool fromLLSD(LLSD& sd); | ||
52 | |||
53 | enum | ||
54 | { | ||
55 | ON = 0x01, | ||
56 | LOOP = 0x02, | ||
57 | REVERSE = 0x04, | ||
58 | PING_PONG = 0x08, | ||
59 | SMOOTH = 0x10, | ||
60 | ROTATE = 0x20, | ||
61 | SCALE = 0x40, | ||
62 | }; | ||
63 | |||
64 | public: | ||
65 | U8 mMode; | ||
66 | S8 mFace; | ||
67 | U8 mSizeX; | ||
68 | U8 mSizeY; | ||
69 | F32 mStart; | ||
70 | F32 mLength; | ||
71 | F32 mRate; // Rate in frames per second. | ||
72 | }; | ||
73 | #endif | ||
diff --git a/linden/indra/llprimitive/lltextureentry.cpp b/linden/indra/llprimitive/lltextureentry.cpp new file mode 100644 index 0000000..5099eef --- /dev/null +++ b/linden/indra/llprimitive/lltextureentry.cpp | |||
@@ -0,0 +1,367 @@ | |||
1 | /** | ||
2 | * @file lltextureentry.cpp | ||
3 | * @brief LLTextureEntry 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 "lltextureentry.h" | ||
31 | #include "llsdutil.h" | ||
32 | |||
33 | const U8 DEFAULT_BUMP_CODE = 0; // no bump or shininess | ||
34 | |||
35 | const LLTextureEntry LLTextureEntry::null; | ||
36 | |||
37 | //=============================================================== | ||
38 | LLTextureEntry::LLTextureEntry() | ||
39 | { | ||
40 | init(LLUUID::null,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE); | ||
41 | } | ||
42 | |||
43 | LLTextureEntry::LLTextureEntry(const LLUUID& tex_id) | ||
44 | { | ||
45 | init(tex_id,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE); | ||
46 | } | ||
47 | |||
48 | LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) | ||
49 | { | ||
50 | mID = rhs.mID; | ||
51 | mScaleS = rhs.mScaleS; | ||
52 | mScaleT = rhs.mScaleT; | ||
53 | mOffsetS = rhs.mOffsetS; | ||
54 | mOffsetT = rhs.mOffsetT; | ||
55 | mRotation = rhs.mRotation; | ||
56 | mColor = rhs.mColor; | ||
57 | mBump = rhs.mBump; | ||
58 | mMediaFlags = rhs.mMediaFlags; | ||
59 | } | ||
60 | |||
61 | LLTextureEntry &LLTextureEntry::operator=(const LLTextureEntry &rhs) | ||
62 | { | ||
63 | if (this != &rhs) | ||
64 | { | ||
65 | mID = rhs.mID; | ||
66 | mScaleS = rhs.mScaleS; | ||
67 | mScaleT = rhs.mScaleT; | ||
68 | mOffsetS = rhs.mOffsetS; | ||
69 | mOffsetT = rhs.mOffsetT; | ||
70 | mRotation = rhs.mRotation; | ||
71 | mColor = rhs.mColor; | ||
72 | mBump = rhs.mBump; | ||
73 | mMediaFlags = rhs.mMediaFlags; | ||
74 | } | ||
75 | |||
76 | return *this; | ||
77 | } | ||
78 | |||
79 | void LLTextureEntry::init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump) | ||
80 | { | ||
81 | setID(tex_id); | ||
82 | |||
83 | mScaleS = scale_s; | ||
84 | mScaleT = scale_t; | ||
85 | mOffsetS = offset_s; | ||
86 | mOffsetT = offset_t; | ||
87 | mRotation = rotation; | ||
88 | mBump = bump; | ||
89 | mMediaFlags = 0x0; | ||
90 | |||
91 | setColor(LLColor4(1.f, 1.f, 1.f, 1.f)); | ||
92 | } | ||
93 | |||
94 | LLTextureEntry::~LLTextureEntry() | ||
95 | { | ||
96 | } | ||
97 | |||
98 | bool LLTextureEntry::operator!=(const LLTextureEntry &rhs) const | ||
99 | { | ||
100 | if (mID != rhs.mID) return(true); | ||
101 | if (mScaleS != rhs.mScaleS) return(true); | ||
102 | if (mScaleT != rhs.mScaleT) return(true); | ||
103 | if (mOffsetS != rhs.mOffsetS) return(true); | ||
104 | if (mOffsetT != rhs.mOffsetT) return(true); | ||
105 | if (mRotation != rhs.mRotation) return(true); | ||
106 | if (mColor != rhs.mColor) return (true); | ||
107 | if (mBump != rhs.mBump) return (true); | ||
108 | if (mMediaFlags != rhs.mMediaFlags) return true; | ||
109 | return(false); | ||
110 | } | ||
111 | |||
112 | bool LLTextureEntry::operator==(const LLTextureEntry &rhs) const | ||
113 | { | ||
114 | if (mID != rhs.mID) return(false); | ||
115 | if (mScaleS != rhs.mScaleS) return(false); | ||
116 | if (mScaleT != rhs.mScaleT) return(false); | ||
117 | if (mOffsetS != rhs.mOffsetS) return(false); | ||
118 | if (mOffsetT != rhs.mOffsetT) return(false); | ||
119 | if (mRotation != rhs.mRotation) return(false); | ||
120 | if (mColor != rhs.mColor) return (false); | ||
121 | if (mBump != rhs.mBump) return (false); | ||
122 | if (mMediaFlags != rhs.mMediaFlags) return false; | ||
123 | return(true); | ||
124 | } | ||
125 | |||
126 | LLSD LLTextureEntry::asLLSD() const | ||
127 | { | ||
128 | LLSD sd; | ||
129 | |||
130 | sd["imageid"] = getID(); | ||
131 | sd["colors"] = ll_sd_from_color4(getColor()); | ||
132 | sd["scales"] = mScaleS; | ||
133 | sd["scalet"] = mScaleT; | ||
134 | sd["offsets"] = mOffsetS; | ||
135 | sd["offsett"] = mOffsetT; | ||
136 | sd["imagerot"] = getRotation(); | ||
137 | sd["bump"] = getBumpShiny(); | ||
138 | sd["fullbright"] = getFullbright(); | ||
139 | sd["media_flags"] = getMediaTexGen(); | ||
140 | |||
141 | return sd; | ||
142 | } | ||
143 | |||
144 | bool LLTextureEntry::fromLLSD(LLSD& sd) | ||
145 | { | ||
146 | const char *w, *x; | ||
147 | w = "imageid"; | ||
148 | if (sd.has(w)) | ||
149 | { | ||
150 | setID( sd[w] ); | ||
151 | } else goto fail; | ||
152 | w = "colors"; | ||
153 | if (sd.has(w)) | ||
154 | { | ||
155 | setColor( ll_color4_from_sd(sd["colors"]) ); | ||
156 | } else goto fail; | ||
157 | w = "scales"; | ||
158 | x = "scalet"; | ||
159 | if (sd.has(w) && sd.has(x)) | ||
160 | { | ||
161 | setScale( (F32)sd[w].asReal(), (F32)sd[x].asReal() ); | ||
162 | } else goto fail; | ||
163 | w = "offsets"; | ||
164 | x = "offsett"; | ||
165 | if (sd.has(w) && sd.has(x)) | ||
166 | { | ||
167 | setOffset( (F32)sd[w].asReal(), (F32)sd[x].asReal() ); | ||
168 | } else goto fail; | ||
169 | w = "imagerot"; | ||
170 | if (sd.has(w)) | ||
171 | { | ||
172 | setRotation( (F32)sd[w].asReal() ); | ||
173 | } else goto fail; | ||
174 | w = "bump"; | ||
175 | if (sd.has(w)) | ||
176 | { | ||
177 | setBumpShiny( sd[w].asInteger() ); | ||
178 | } else goto fail; | ||
179 | w = "fullbright"; | ||
180 | if (sd.has(w)) | ||
181 | { | ||
182 | setFullbright( sd[w].asInteger() ); | ||
183 | } else goto fail; | ||
184 | w = "media_flags"; | ||
185 | if (sd.has(w)) | ||
186 | { | ||
187 | setMediaTexGen( sd[w].asInteger() ); | ||
188 | } else goto fail; | ||
189 | |||
190 | return true; | ||
191 | fail: | ||
192 | return false; | ||
193 | } | ||
194 | |||
195 | S32 LLTextureEntry::setID(const LLUUID &tex_id) | ||
196 | { | ||
197 | if (mID != tex_id) | ||
198 | { | ||
199 | mID = tex_id; | ||
200 | return TEM_CHANGE_TEXTURE; | ||
201 | } | ||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | S32 LLTextureEntry::setScale(F32 s, F32 t) | ||
206 | { | ||
207 | S32 retval = 0; | ||
208 | |||
209 | if ( (mScaleS != s) | ||
210 | ||(mScaleT != t)) | ||
211 | { | ||
212 | mScaleS = s; | ||
213 | mScaleT = t; | ||
214 | |||
215 | retval = TEM_CHANGE_TEXTURE; | ||
216 | } | ||
217 | return retval; | ||
218 | } | ||
219 | |||
220 | S32 LLTextureEntry::setColor(const LLColor4 &color) | ||
221 | { | ||
222 | if (mColor != color) | ||
223 | { | ||
224 | mColor = color; | ||
225 | return TEM_CHANGE_COLOR; | ||
226 | } | ||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | S32 LLTextureEntry::setColor(const LLColor3 &color) | ||
231 | { | ||
232 | if (mColor != color) | ||
233 | { | ||
234 | // This preserves alpha. | ||
235 | mColor.setVec(color); | ||
236 | return TEM_CHANGE_COLOR; | ||
237 | } | ||
238 | return 0; | ||
239 | } | ||
240 | |||
241 | S32 LLTextureEntry::setAlpha(const F32 alpha) | ||
242 | { | ||
243 | if (mColor.mV[VW] != alpha) | ||
244 | { | ||
245 | mColor.mV[VW] = alpha; | ||
246 | return TEM_CHANGE_COLOR; | ||
247 | } | ||
248 | return 0; | ||
249 | } | ||
250 | |||
251 | S32 LLTextureEntry::setOffset(F32 s, F32 t) | ||
252 | { | ||
253 | S32 retval = 0; | ||
254 | |||
255 | if ( (mOffsetS != s) | ||
256 | ||(mOffsetT != t)) | ||
257 | { | ||
258 | mOffsetS = s; | ||
259 | mOffsetT = t; | ||
260 | |||
261 | retval = TEM_CHANGE_TEXTURE; | ||
262 | } | ||
263 | return retval; | ||
264 | } | ||
265 | |||
266 | S32 LLTextureEntry::setRotation(F32 theta) | ||
267 | { | ||
268 | if (mRotation != theta) | ||
269 | { | ||
270 | mRotation = theta; | ||
271 | return TEM_CHANGE_TEXTURE; | ||
272 | } | ||
273 | return 0; | ||
274 | } | ||
275 | |||
276 | S32 LLTextureEntry::setBumpShinyFullbright(U8 bump) | ||
277 | { | ||
278 | if (mBump != bump) | ||
279 | { | ||
280 | mBump = bump; | ||
281 | return TEM_CHANGE_TEXTURE; | ||
282 | } | ||
283 | return 0; | ||
284 | } | ||
285 | |||
286 | S32 LLTextureEntry::setMediaTexGen(U8 media) | ||
287 | { | ||
288 | if (mMediaFlags != media) | ||
289 | { | ||
290 | mMediaFlags = media; | ||
291 | return TEM_CHANGE_TEXTURE; | ||
292 | } | ||
293 | return 0; | ||
294 | } | ||
295 | |||
296 | S32 LLTextureEntry::setBumpmap(U8 bump) | ||
297 | { | ||
298 | bump &= TEM_BUMP_MASK; | ||
299 | if (getBumpmap() != bump) | ||
300 | { | ||
301 | mBump &= ~TEM_BUMP_MASK; | ||
302 | mBump |= bump; | ||
303 | return TEM_CHANGE_TEXTURE; | ||
304 | } | ||
305 | return 0; | ||
306 | } | ||
307 | |||
308 | S32 LLTextureEntry::setFullbright(U8 fullbright) | ||
309 | { | ||
310 | fullbright &= TEM_FULLBRIGHT_MASK; | ||
311 | if (getFullbright() != fullbright) | ||
312 | { | ||
313 | mBump &= ~(TEM_FULLBRIGHT_MASK<<TEM_FULLBRIGHT_SHIFT); | ||
314 | mBump |= fullbright << TEM_FULLBRIGHT_SHIFT; | ||
315 | return TEM_CHANGE_TEXTURE; | ||
316 | } | ||
317 | return 0; | ||
318 | } | ||
319 | |||
320 | S32 LLTextureEntry::setShiny(U8 shiny) | ||
321 | { | ||
322 | shiny &= TEM_SHINY_MASK; | ||
323 | if (getShiny() != shiny) | ||
324 | { | ||
325 | mBump &= ~(TEM_SHINY_MASK<<TEM_SHINY_SHIFT); | ||
326 | mBump |= shiny << TEM_SHINY_SHIFT; | ||
327 | return TEM_CHANGE_TEXTURE; | ||
328 | } | ||
329 | return 0; | ||
330 | } | ||
331 | |||
332 | S32 LLTextureEntry::setBumpShiny(U8 bump_shiny) | ||
333 | { | ||
334 | bump_shiny &= TEM_BUMP_SHINY_MASK; | ||
335 | if (getBumpShiny() != bump_shiny) | ||
336 | { | ||
337 | mBump &= ~TEM_BUMP_SHINY_MASK; | ||
338 | mBump |= bump_shiny; | ||
339 | return TEM_CHANGE_TEXTURE; | ||
340 | } | ||
341 | return 0; | ||
342 | } | ||
343 | |||
344 | S32 LLTextureEntry::setMediaFlags(U8 media_flags) | ||
345 | { | ||
346 | media_flags &= TEM_MEDIA_MASK; | ||
347 | if (getMediaFlags() != media_flags) | ||
348 | { | ||
349 | mMediaFlags &= ~TEM_MEDIA_MASK; | ||
350 | mMediaFlags |= media_flags; | ||
351 | return TEM_CHANGE_TEXTURE; | ||
352 | } | ||
353 | return 0; | ||
354 | } | ||
355 | |||
356 | S32 LLTextureEntry::setTexGen(U8 tex_gen) | ||
357 | { | ||
358 | tex_gen &= TEM_TEX_GEN_MASK; | ||
359 | if (getTexGen() != tex_gen) | ||
360 | { | ||
361 | mMediaFlags &= ~TEM_TEX_GEN_MASK; | ||
362 | mMediaFlags |= tex_gen; | ||
363 | return TEM_CHANGE_TEXTURE; | ||
364 | } | ||
365 | return 0; | ||
366 | } | ||
367 | |||
diff --git a/linden/indra/llprimitive/lltextureentry.h b/linden/indra/llprimitive/lltextureentry.h new file mode 100644 index 0000000..b06f9a1 --- /dev/null +++ b/linden/indra/llprimitive/lltextureentry.h | |||
@@ -0,0 +1,145 @@ | |||
1 | /** | ||
2 | * @file lltextureentry.h | ||
3 | * @brief LLTextureEntry 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 | #ifndef LL_LLTEXTUREENTRY_H | ||
29 | #define LL_LLTEXTUREENTRY_H | ||
30 | |||
31 | #include "lluuid.h" | ||
32 | #include "v4color.h" | ||
33 | #include "llsd.h" | ||
34 | |||
35 | const S32 TEM_CHANGE_COLOR = 0x1; | ||
36 | const S32 TEM_CHANGE_TEXTURE = 0x2; | ||
37 | const S32 TEM_INVALID = 0x4; | ||
38 | |||
39 | const S32 TEM_BUMPMAP_COUNT = 32; | ||
40 | |||
41 | // The Bump Shiny Fullbright values are bits in an eight bit field: | ||
42 | // +----------+ | ||
43 | // | SSFBBBBB | S = Shiny, F = Fullbright, B = Bumpmap | ||
44 | // | 76543210 | | ||
45 | // +----------+ | ||
46 | const S32 TEM_BUMP_MASK = 0x1f; // 5 bits | ||
47 | const S32 TEM_FULLBRIGHT_MASK = 0x01; // 1 bit | ||
48 | const S32 TEM_SHINY_MASK = 0x03; // 2 bits | ||
49 | const S32 TEM_BUMP_SHINY_MASK = (0xc0 | 0x1f); | ||
50 | const S32 TEM_FULLBRIGHT_SHIFT = 5; | ||
51 | const S32 TEM_SHINY_SHIFT = 6; | ||
52 | |||
53 | // The Media Tex Gen values are bits in a bit field: | ||
54 | // +----------+ | ||
55 | // | .....TTM | M = Media Flags (web page), T = LLTextureEntry::eTexGen, . = unused | ||
56 | // | 76543210 | | ||
57 | // +----------+ | ||
58 | const S32 TEM_MEDIA_MASK = 0x01; | ||
59 | const S32 TEM_TEX_GEN_MASK = 0x06; | ||
60 | const S32 TEM_TEX_GEN_SHIFT = 1; | ||
61 | |||
62 | |||
63 | class LLTextureEntry | ||
64 | { | ||
65 | public: | ||
66 | |||
67 | typedef enum e_texgen | ||
68 | { | ||
69 | TEX_GEN_DEFAULT = 0x00, | ||
70 | TEX_GEN_PLANAR = 0x02, | ||
71 | TEX_GEN_SPHERICAL = 0x04, | ||
72 | TEX_GEN_CYLINDRICAL = 0x06 | ||
73 | } eTexGen; | ||
74 | |||
75 | LLTextureEntry(); | ||
76 | LLTextureEntry(const LLUUID& tex_id); | ||
77 | LLTextureEntry(const LLTextureEntry &rhs); | ||
78 | |||
79 | LLTextureEntry &operator=(const LLTextureEntry &rhs); | ||
80 | ~LLTextureEntry(); | ||
81 | |||
82 | bool operator==(const LLTextureEntry &rhs) const; | ||
83 | bool operator!=(const LLTextureEntry &rhs) const; | ||
84 | |||
85 | LLSD asLLSD() const; | ||
86 | operator LLSD() const { return asLLSD(); } | ||
87 | bool fromLLSD(LLSD& sd); | ||
88 | |||
89 | void init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump); | ||
90 | |||
91 | // These return a TEM_ flag from above to indicate if something changed. | ||
92 | S32 setID (const LLUUID &tex_id); | ||
93 | S32 setColor(const LLColor4 &color); | ||
94 | S32 setColor(const LLColor3 &color); | ||
95 | S32 setAlpha(const F32 alpha); | ||
96 | S32 setScale(F32 s, F32 t); | ||
97 | S32 setOffset(F32 s, F32 t); | ||
98 | S32 setRotation(F32 theta); | ||
99 | |||
100 | S32 setBumpmap(U8 bump); | ||
101 | S32 setFullbright(U8 bump); | ||
102 | S32 setShiny(U8 bump); | ||
103 | S32 setBumpShiny(U8 bump); | ||
104 | S32 setBumpShinyFullbright(U8 bump); | ||
105 | |||
106 | S32 setMediaFlags(U8 media_flags); | ||
107 | S32 setTexGen(U8 texGen); | ||
108 | S32 setMediaTexGen(U8 media); | ||
109 | |||
110 | const LLUUID &getID() const { return mID; } | ||
111 | const LLColor4 &getColor() const { return mColor; } | ||
112 | void getScale(F32 *s, F32 *t) const { *s = mScaleS; *t = mScaleT; } | ||
113 | void getOffset(F32 *s, F32 *t) const { *s = mOffsetS; *t = mOffsetT; } | ||
114 | F32 getRotation() const { return mRotation; } | ||
115 | void getRotation(F32 *theta) const { *theta = mRotation; } | ||
116 | |||
117 | U8 getBumpmap() const { return mBump & TEM_BUMP_MASK; } | ||
118 | U8 getFullbright() const { return (mBump>>TEM_FULLBRIGHT_SHIFT) & TEM_FULLBRIGHT_MASK; } | ||
119 | U8 getShiny() const { return (mBump>>TEM_SHINY_SHIFT) & TEM_SHINY_MASK; } | ||
120 | U8 getBumpShiny() const { return mBump & TEM_BUMP_SHINY_MASK; } | ||
121 | U8 getBumpShinyFullbright() const { return mBump; } | ||
122 | |||
123 | U8 getMediaFlags() const { return mMediaFlags & TEM_MEDIA_MASK; } | ||
124 | U8 getTexGen() const { return mMediaFlags & TEM_TEX_GEN_MASK; } | ||
125 | U8 getMediaTexGen() const { return mMediaFlags; } | ||
126 | |||
127 | // Media flags | ||
128 | enum { MF_NONE = 0x0, MF_WEB_PAGE = 0x1 }; | ||
129 | |||
130 | public: | ||
131 | F32 mScaleS; // S, T offset | ||
132 | F32 mScaleT; // S, T offset | ||
133 | F32 mOffsetS; // S, T offset | ||
134 | F32 mOffsetT; // S, T offset | ||
135 | F32 mRotation; // anti-clockwise rotation in rad about the bottom left corner | ||
136 | |||
137 | static const LLTextureEntry null; | ||
138 | protected: | ||
139 | LLUUID mID; // Texture GUID | ||
140 | LLColor4 mColor; | ||
141 | U8 mBump; // Bump map, shiny, and fullbright | ||
142 | U8 mMediaFlags; // replace with web page, movie, etc. | ||
143 | }; | ||
144 | |||
145 | #endif | ||
diff --git a/linden/indra/llprimitive/lltree_common.h b/linden/indra/llprimitive/lltree_common.h new file mode 100644 index 0000000..0904f9d --- /dev/null +++ b/linden/indra/llprimitive/lltree_common.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /** | ||
2 | * @file lltree_common.h | ||
3 | * @brief LLTree_gene_0 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 | // Common data for trees shared between simulator and viewer | ||
29 | |||
30 | #ifndef LL_LLTREE_COMMON_H | ||
31 | #define LL_LLTREE_COMMON_H | ||
32 | |||
33 | struct LLTree_gene_0 | ||
34 | { | ||
35 | // | ||
36 | // The genome for a tree, species 0 | ||
37 | // | ||
38 | U8 scale; // Scales size of the tree ( / 50 = meter) | ||
39 | U8 branches; // When tree forks, how many branches emerge? | ||
40 | U8 twist; // twist about old branch axis for each branch (convert to degrees by dividing/255 * 180) | ||
41 | U8 droop; // Droop away from old branch axis (convert to degrees by dividing/255 * 180) | ||
42 | U8 species; // Branch coloring index | ||
43 | U8 trunk_depth; // max recursions in the main trunk | ||
44 | U8 branch_thickness; // Scales thickness of trunk ( / 50 = meter) | ||
45 | U8 max_depth; // Branch Recursions to flower | ||
46 | U8 scale_step; // How much to multiply scale size at each recursion 0-1.f to convert to float | ||
47 | }; | ||
48 | |||
49 | #endif | ||
diff --git a/linden/indra/llprimitive/lltreeparams.cpp b/linden/indra/llprimitive/lltreeparams.cpp new file mode 100644 index 0000000..ce52cae --- /dev/null +++ b/linden/indra/llprimitive/lltreeparams.cpp | |||
@@ -0,0 +1,206 @@ | |||
1 | /** | ||
2 | * @file lltreeparams.cpp | ||
3 | * @brief implementation of the LLTreeParams 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 | ////////////////////////////////////////////////////////////////////// | ||
29 | |||
30 | #include "linden_common.h" | ||
31 | |||
32 | #include "llmath.h" | ||
33 | |||
34 | #include "lltreeparams.h" | ||
35 | |||
36 | ////////////////////////////////////////////////////////////////////// | ||
37 | // Construction/Destruction | ||
38 | ////////////////////////////////////////////////////////////////////// | ||
39 | |||
40 | |||
41 | LLTreeParams::LLTreeParams() | ||
42 | { | ||
43 | |||
44 | // llinfos << "TREE PARAMS INITIALIZED" << llendl; | ||
45 | // init to basic something or other... | ||
46 | mShape = SR_TEND_FLAME; | ||
47 | mLevels = 1; | ||
48 | mScale = 15; | ||
49 | mScaleV = 0; | ||
50 | |||
51 | mBaseSize = 0.3f; | ||
52 | |||
53 | mRatio = 0.015f; | ||
54 | mRatioPower = 1.3f; | ||
55 | |||
56 | mLobes = 0; | ||
57 | mLobeDepth = .1f; | ||
58 | |||
59 | mFlare = 1.2f; | ||
60 | mFlarePercentage = 0.1f; | ||
61 | mFlareRes = 3; | ||
62 | |||
63 | //mAttractionUp = .5f; | ||
64 | |||
65 | mBaseSplits = 0; | ||
66 | |||
67 | mScale0 = 2.0; | ||
68 | mScaleV0 = 0.0; | ||
69 | |||
70 | // level 0 | ||
71 | |||
72 | // scaling | ||
73 | mLength[0] = 1.0f; | ||
74 | mLengthV[0] = 0; | ||
75 | mTaper[0] = 1.0f; | ||
76 | |||
77 | // stem splits | ||
78 | mSegSplits[0] = 0.15f; | ||
79 | mSplitAngle[0] = 15.0f; | ||
80 | mSplitAngleV[0] = 10.0f; | ||
81 | |||
82 | mVertices[0] = 5; | ||
83 | |||
84 | // curvature | ||
85 | mCurveRes[0] = 4; | ||
86 | mCurve[0] = 0; | ||
87 | mCurveV[0] = 25; | ||
88 | mCurveBack[0] = 0; | ||
89 | |||
90 | // level 1 | ||
91 | |||
92 | // scaling | ||
93 | mLength[1] = .3f; | ||
94 | mLengthV[1] = 0.05f; | ||
95 | mTaper[1] = 1.0f; | ||
96 | |||
97 | // angle params | ||
98 | mDownAngle[0] = 60.0f; | ||
99 | mDownAngleV[0] = 20.0f; | ||
100 | mRotate[0] = 140.0f; | ||
101 | mRotateV[0] = 0.0f; | ||
102 | mBranches[0] = 35; | ||
103 | |||
104 | mVertices[1] = 3; | ||
105 | |||
106 | // stem splits | ||
107 | mSplitAngle[1] = 0.0f; | ||
108 | mSplitAngleV[1] = 0.0f; | ||
109 | mSegSplits[1] = 0.0f; | ||
110 | |||
111 | // curvature | ||
112 | mCurveRes[1] = 4; | ||
113 | mCurve[1] = 0; | ||
114 | mCurveV[1] = 0; | ||
115 | mCurveBack[1] = 40; | ||
116 | |||
117 | // level 2 | ||
118 | mLength[2] = .6f; | ||
119 | mLengthV[2] = .1f; | ||
120 | mTaper[2] = 1; | ||
121 | |||
122 | mDownAngle[1] = 30; | ||
123 | mDownAngleV[1] = 10; | ||
124 | mRotate[1] = 140; | ||
125 | mRotateV[1] = 0; | ||
126 | |||
127 | mBranches[1] = 20; | ||
128 | mVertices[2] = 3; | ||
129 | |||
130 | mSplitAngle[2] = 0; | ||
131 | mSplitAngleV[2] = 0; | ||
132 | mSegSplits[2] = 0; | ||
133 | |||
134 | mCurveRes[2] = 3; | ||
135 | mCurve[2] = 10; | ||
136 | mCurveV[2] = 150; | ||
137 | mCurveBack[2] = 0; | ||
138 | |||
139 | // level 3 | ||
140 | mLength[3] = .4f; | ||
141 | mLengthV[3] = 0; | ||
142 | mTaper[3] = 1; | ||
143 | |||
144 | mDownAngle[2] = 45; | ||
145 | mDownAngleV[2] = 10; | ||
146 | mRotate[2] = 140; | ||
147 | mRotateV[2] = 0; | ||
148 | |||
149 | mBranches[2] = 5; | ||
150 | mVertices[3] = 3; | ||
151 | |||
152 | |||
153 | mSplitAngle[3] = 0; | ||
154 | mSplitAngleV[3] = 0; | ||
155 | mSegSplits[3] = 0; | ||
156 | |||
157 | mCurveRes[3] = 2; | ||
158 | mCurve[3] = 0; | ||
159 | mCurveV[3] = 0; | ||
160 | mCurveBack[3] = 0; | ||
161 | |||
162 | mLeaves = 0; | ||
163 | mLeafScaleX = 1.0f; | ||
164 | mLeafScaleY = 1.0f; | ||
165 | |||
166 | mLeafQuality = 1.25; | ||
167 | } | ||
168 | |||
169 | LLTreeParams::~LLTreeParams() | ||
170 | { | ||
171 | |||
172 | } | ||
173 | |||
174 | F32 LLTreeParams::ShapeRatio(EShapeRatio shape, F32 ratio) | ||
175 | { | ||
176 | switch (shape) { | ||
177 | case (SR_CONICAL): | ||
178 | return (.2f + .8f * ratio); | ||
179 | case (SR_SPHERICAL): | ||
180 | return (.2f + .8f * sinf(F_PI*ratio)); | ||
181 | case (SR_HEMISPHERICAL): | ||
182 | return (.2f + .8f * sinf(.5*F_PI*ratio)); | ||
183 | case (SR_CYLINDRICAL): | ||
184 | return (1); | ||
185 | case (SR_TAPERED_CYLINDRICAL): | ||
186 | return (.5f + .5f * ratio); | ||
187 | case (SR_FLAME): | ||
188 | if (ratio <= .7f) { | ||
189 | return ratio/.7f; | ||
190 | } else { | ||
191 | return ((1 - ratio)/.3f); | ||
192 | } | ||
193 | case (SR_INVERSE_CONICAL): | ||
194 | return (1 - .8f * ratio); | ||
195 | case (SR_TEND_FLAME): | ||
196 | if (ratio <= .7) { | ||
197 | return (.5f + .5f*(ratio/.7f)); | ||
198 | } else { | ||
199 | return (.5f + .5f * (1 - ratio)/.3f); | ||
200 | } | ||
201 | case (SR_ENVELOPE): | ||
202 | return 1; | ||
203 | default: | ||
204 | return 1; | ||
205 | } | ||
206 | } | ||
diff --git a/linden/indra/llprimitive/lltreeparams.h b/linden/indra/llprimitive/lltreeparams.h new file mode 100644 index 0000000..7822d31 --- /dev/null +++ b/linden/indra/llprimitive/lltreeparams.h | |||
@@ -0,0 +1,202 @@ | |||
1 | /** | ||
2 | * @file lltreeparams.h | ||
3 | * @brief Implementation of the LLTreeParams 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 | #ifndef LL_LLTREEPARAMS_H | ||
29 | #define LL_LLTREEPARAMS_H | ||
30 | |||
31 | /* for information about formulas associated with each type | ||
32 | * check the Weber + Penn paper | ||
33 | */ | ||
34 | typedef enum EShapeRatio { SR_CONICAL, SR_SPHERICAL, SR_HEMISPHERICAL, | ||
35 | SR_CYLINDRICAL, SR_TAPERED_CYLINDRICAL, SR_FLAME, | ||
36 | SR_INVERSE_CONICAL, SR_TEND_FLAME, SR_ENVELOPE}; | ||
37 | |||
38 | const U32 TREE_BLOCK_SIZE = 16; | ||
39 | |||
40 | const U8 MAX_NUM_LEVELS = 4; | ||
41 | |||
42 | class LLTreeParams | ||
43 | { | ||
44 | public: | ||
45 | LLTreeParams(); | ||
46 | virtual ~LLTreeParams(); | ||
47 | |||
48 | static F32 ShapeRatio(EShapeRatio shape, F32 ratio); | ||
49 | |||
50 | public: | ||
51 | |||
52 | // Variables with an asterick (*) cannot be modified without a re-instancing the | ||
53 | // trunk/branches | ||
54 | |||
55 | // Variables with an exclamation point (!) should probably not be modified outside and instead | ||
56 | // be tied directly to the species | ||
57 | |||
58 | // Variables with a tilde (~) should be tied to a range specified by the | ||
59 | // species type but still slightly controllable by the user | ||
60 | |||
61 | // GENERAL | ||
62 | |||
63 | //! determines length/radius of branches on tree -- ie: general 'shape' | ||
64 | EShapeRatio mShape; | ||
65 | |||
66 | //! number of recursive branch levels...limit to MAX_NUM_LEVELS | ||
67 | U8 mLevels; | ||
68 | |||
69 | //~ percentage of trunk at bottom without branches | ||
70 | F32 mBaseSize; | ||
71 | |||
72 | //~ the general scale + variance of tree | ||
73 | F32 mScale, mScaleV; | ||
74 | |||
75 | // general scale of tree | ||
76 | F32 mScale0, mScaleV0; | ||
77 | |||
78 | |||
79 | |||
80 | // LOBING | ||
81 | |||
82 | //*! number of peaks in the radial distance about the perimeter | ||
83 | U8 mLobes; | ||
84 | // even numbers = obvius symmetry ... use odd numbers | ||
85 | |||
86 | //*! magnitude of the variations as a fraction of the radius | ||
87 | F32 mLobeDepth; | ||
88 | |||
89 | |||
90 | |||
91 | // FLARE | ||
92 | |||
93 | //*! causes exponential expansion near base of trunk | ||
94 | F32 mFlare; | ||
95 | // scales radius base by min 1 to '1 + flare' | ||
96 | |||
97 | //*! percentage of the height of the trunk to flair -- likely less than baseSize | ||
98 | F32 mFlarePercentage; | ||
99 | |||
100 | //*! number of cross sections to make for the flair | ||
101 | U8 mFlareRes; | ||
102 | |||
103 | |||
104 | |||
105 | // LEAVES | ||
106 | |||
107 | //~ number of leaves to make | ||
108 | U8 mLeaves; | ||
109 | |||
110 | //! scale of the leaves | ||
111 | F32 mLeafScaleX, mLeafScaleY; | ||
112 | |||
113 | // quality/density of leaves | ||
114 | F32 mLeafQuality; | ||
115 | |||
116 | // several params don't have level 0 values | ||
117 | |||
118 | // BRANCHES | ||
119 | |||
120 | //~ angle away from parent | ||
121 | F32 mDownAngle[MAX_NUM_LEVELS - 1]; | ||
122 | F32 mDownAngleV[MAX_NUM_LEVELS - 1]; | ||
123 | |||
124 | //~ rotation around parent | ||
125 | F32 mRotate[MAX_NUM_LEVELS - 1]; | ||
126 | F32 mRotateV[MAX_NUM_LEVELS - 1]; | ||
127 | |||
128 | //~ num branches to spawn | ||
129 | U8 mBranches[MAX_NUM_LEVELS - 1]; | ||
130 | |||
131 | //~ fractional length of branch. 1 = same length as parent branch | ||
132 | F32 mLength[MAX_NUM_LEVELS]; | ||
133 | F32 mLengthV[MAX_NUM_LEVELS]; | ||
134 | |||
135 | //!~ ratio and ratiopower determine radius/length | ||
136 | F32 mRatio, mRatioPower; | ||
137 | |||
138 | //*! taper of branches | ||
139 | F32 mTaper[MAX_NUM_LEVELS]; | ||
140 | // 0 - non-tapering cylinder | ||
141 | // 1 - taper to a point | ||
142 | // 2 - taper to a spherical end | ||
143 | // 3 - periodic tapering (concatenated spheres) | ||
144 | |||
145 | //! SEG SPLITTING | ||
146 | U8 mBaseSplits; //! num segsplits at first curve cross section of trunk | ||
147 | F32 mSegSplits[MAX_NUM_LEVELS]; //~ splits per cross section. 1 = 1 split per section | ||
148 | F32 mSplitAngle[MAX_NUM_LEVELS]; //~ angle that splits go from parent (tempered by height) | ||
149 | F32 mSplitAngleV[MAX_NUM_LEVELS]; //~ variance of the splits | ||
150 | |||
151 | // CURVE | ||
152 | F32 mCurve[MAX_NUM_LEVELS]; //* general, 1-axis, overall curve of branch | ||
153 | F32 mCurveV[MAX_NUM_LEVELS]; //* curve variance at each cross section from general overall curve | ||
154 | U8 mCurveRes[MAX_NUM_LEVELS]; //* number of cross sections for curve | ||
155 | F32 mCurveBack[MAX_NUM_LEVELS]; //* curveback is amount branch curves back towards | ||
156 | |||
157 | // vertices per cross section | ||
158 | U8 mVertices[MAX_NUM_LEVELS]; | ||
159 | |||
160 | // * no longer useful with pre-instanced branches | ||
161 | // specifies upward tendency of branches. | ||
162 | //F32 mAttractionUp; | ||
163 | // 1 = each branch will slightly go upwards by the end of the branch | ||
164 | // >1 = branches tend to go upwards earlier in their length | ||
165 | // pruning not implemented | ||
166 | // Prune parameters | ||
167 | //F32 mPruneRatio; | ||
168 | //F32 mPruneWidth, mPruneWidthPeak; | ||
169 | //F32 mPrunePowerLow, mPrunePowerHigh; | ||
170 | |||
171 | |||
172 | // NETWORK MESSAGE DATA | ||
173 | // Below is the outline for network messages regarding trees. | ||
174 | // The general idea is that a user would pick a general 'tree type' (the first variable) | ||
175 | // and then several 'open ended' variables like 'branchiness' and 'leafiness'. | ||
176 | // The effect that each of these general user variables would then affect the actual | ||
177 | // tree parameters (like # branches, # segsplits) in different ways depending on | ||
178 | // the tree type selected. Essentially, each tree type should have a formula | ||
179 | // that expands the 'leafiness' and 'branchiness' user variables into actual | ||
180 | // values for the tree parameters. | ||
181 | |||
182 | // These formulas aren't made yet and will certainly require some tuning. The | ||
183 | // estimates below for the # bits required seems like a good guesstimate. | ||
184 | |||
185 | // VARIABLE - # bits (range) - VARIABLES AFFECTED | ||
186 | // tree type - 5 bits (32) - | ||
187 | // branches - 6 bits (64) - numBranches | ||
188 | // splits - 6 bits (64) - segsplits | ||
189 | // leafiness - 3 bits (8) - numLeaves | ||
190 | // branch spread - 5 bits (32) - splitAngle(V), rotate(V) | ||
191 | // angle - 5 bits (32) - downAngle(V) | ||
192 | // branch length - 6 bits (64) - branchlength(V) | ||
193 | // randomness - 7 bits (128) - percentage for randomness of the (V)'s | ||
194 | // basesize - 5 bits (32) - basesize | ||
195 | |||
196 | // total - 48 bits | ||
197 | |||
198 | //U8 mNetSpecies; | ||
199 | |||
200 | }; | ||
201 | |||
202 | #endif | ||
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 | //============================================================================ | ||
diff --git a/linden/indra/llprimitive/llvolumemessage.h b/linden/indra/llprimitive/llvolumemessage.h new file mode 100644 index 0000000..ad062a9 --- /dev/null +++ b/linden/indra/llprimitive/llvolumemessage.h | |||
@@ -0,0 +1,93 @@ | |||
1 | /** | ||
2 | * @file llvolumemessage.h | ||
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 | #ifndef LL_LLVOLUMEMESSAGE_H | ||
29 | #define LL_LLVOLUMEMESSAGE_H | ||
30 | |||
31 | #include "llvolume.h" | ||
32 | |||
33 | class LLMessageSystem; | ||
34 | class LLDataPacker; | ||
35 | |||
36 | // wrapper class for some volume/message functions | ||
37 | class LLVolumeMessage | ||
38 | { | ||
39 | protected: | ||
40 | // The profile and path params are protected since they do not do | ||
41 | // any kind of parameter validation or clamping. Use the public | ||
42 | // pack and unpack volume param methods below | ||
43 | |||
44 | static bool packProfileParams( | ||
45 | const LLProfileParams* params, | ||
46 | LLMessageSystem* mesgsys); | ||
47 | static bool packProfileParams( | ||
48 | const LLProfileParams* params, | ||
49 | LLDataPacker& dp); | ||
50 | static bool unpackProfileParams( | ||
51 | LLProfileParams* params, | ||
52 | LLMessageSystem* mesgsys, | ||
53 | char* block_name, | ||
54 | S32 block_num = 0); | ||
55 | static bool unpackProfileParams(LLProfileParams* params, LLDataPacker& dp); | ||
56 | |||
57 | static bool packPathParams( | ||
58 | const LLPathParams* params, | ||
59 | LLMessageSystem* mesgsys); | ||
60 | static bool packPathParams(const LLPathParams* params, LLDataPacker& dp); | ||
61 | static bool unpackPathParams( | ||
62 | LLPathParams* params, | ||
63 | LLMessageSystem* mesgsys, | ||
64 | char* block_name, | ||
65 | S32 block_num = 0); | ||
66 | static bool unpackPathParams(LLPathParams* params, LLDataPacker& dp); | ||
67 | |||
68 | public: | ||
69 | /** | ||
70 | * @brief This method constrains any volume params to make them valid. | ||
71 | * | ||
72 | * @param[in,out] Possibly invalid params in, always valid out. | ||
73 | * @return Returns true if the in params were valid, and therefore | ||
74 | * unchanged. | ||
75 | */ | ||
76 | static bool constrainVolumeParams(LLVolumeParams& params); | ||
77 | |||
78 | static bool packVolumeParams( | ||
79 | const LLVolumeParams* params, | ||
80 | LLMessageSystem* mesgsys); | ||
81 | static bool packVolumeParams( | ||
82 | const LLVolumeParams* params, | ||
83 | LLDataPacker& dp); | ||
84 | static bool unpackVolumeParams( | ||
85 | LLVolumeParams* params, | ||
86 | LLMessageSystem* mesgsys, | ||
87 | char* block_name, | ||
88 | S32 block_num = 0); | ||
89 | static bool unpackVolumeParams(LLVolumeParams* params, LLDataPacker &dp); | ||
90 | }; | ||
91 | |||
92 | #endif // LL_LLVOLUMEMESSAGE_H | ||
93 | |||
diff --git a/linden/indra/llprimitive/llvolumexml.cpp b/linden/indra/llprimitive/llvolumexml.cpp new file mode 100644 index 0000000..101eace --- /dev/null +++ b/linden/indra/llprimitive/llvolumexml.cpp | |||
@@ -0,0 +1,76 @@ | |||
1 | /** | ||
2 | * @file llvolumexml.cpp | ||
3 | * @brief LLVolumeXml 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 "llvolumexml.h" | ||
31 | |||
32 | //============================================================================ | ||
33 | |||
34 | // LLVolumeXml is just a wrapper class; all members are static | ||
35 | |||
36 | //============================================================================ | ||
37 | |||
38 | LLXMLNode *LLVolumeXml::exportProfileParams(const LLProfileParams* params) | ||
39 | { | ||
40 | LLXMLNode *ret = new LLXMLNode("profile", FALSE); | ||
41 | |||
42 | ret->createChild("curve_type", TRUE)->setByteValue(1, ¶ms->getCurveType()); | ||
43 | ret->createChild("interval", FALSE)->setFloatValue(2, ¶ms->getBegin()); | ||
44 | ret->createChild("hollow", FALSE)->setFloatValue(1, ¶ms->getHollow()); | ||
45 | |||
46 | return ret; | ||
47 | } | ||
48 | |||
49 | |||
50 | LLXMLNode *LLVolumeXml::exportPathParams(const LLPathParams* params) | ||
51 | { | ||
52 | LLXMLNode *ret = new LLXMLNode("path", FALSE); | ||
53 | ret->createChild("curve_type", TRUE)->setByteValue(1, ¶ms->getCurveType()); | ||
54 | ret->createChild("interval", FALSE)->setFloatValue(2, ¶ms->getBegin()); | ||
55 | ret->createChild("scale", FALSE)->setFloatValue(2, params->getScale().mV); | ||
56 | ret->createChild("shear", FALSE)->setFloatValue(2, params->getShear().mV); | ||
57 | ret->createChild("twist_interval", FALSE)->setFloatValue(2, ¶ms->getTwistBegin()); | ||
58 | ret->createChild("radius_offset", FALSE)->setFloatValue(1, ¶ms->getRadiusOffset()); | ||
59 | ret->createChild("taper", FALSE)->setFloatValue(2, params->getTaper().mV); | ||
60 | ret->createChild("revolutions", FALSE)->setFloatValue(1, ¶ms->getRevolutions()); | ||
61 | ret->createChild("skew", FALSE)->setFloatValue(1, ¶ms->getSkew()); | ||
62 | |||
63 | return ret; | ||
64 | } | ||
65 | |||
66 | |||
67 | LLXMLNode *LLVolumeXml::exportVolumeParams(const LLVolumeParams* params) | ||
68 | { | ||
69 | LLXMLNode *ret = new LLXMLNode("shape", FALSE); | ||
70 | |||
71 | exportPathParams(¶ms->getPathParams())->setParent(ret); | ||
72 | exportProfileParams(¶ms->getProfileParams())->setParent(ret); | ||
73 | |||
74 | return ret; | ||
75 | } | ||
76 | |||
diff --git a/linden/indra/llprimitive/llvolumexml.h b/linden/indra/llprimitive/llvolumexml.h new file mode 100644 index 0000000..c6ae480 --- /dev/null +++ b/linden/indra/llprimitive/llvolumexml.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /** | ||
2 | * @file llvolumexml.h | ||
3 | * @brief LLVolumeXml 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 | #ifndef LL_LLVOLUMEXML_H | ||
29 | #define LL_LLVOLUMEXML_H | ||
30 | |||
31 | #include "llvolume.h" | ||
32 | #include "llxmlnode.h" | ||
33 | |||
34 | // wrapper class for some volume/message functions | ||
35 | class LLVolumeXml | ||
36 | { | ||
37 | public: | ||
38 | static LLXMLNode* exportProfileParams(const LLProfileParams* params); | ||
39 | |||
40 | static LLXMLNode* exportPathParams(const LLPathParams* params); | ||
41 | |||
42 | static LLXMLNode* exportVolumeParams(const LLVolumeParams* params); | ||
43 | }; | ||
44 | |||
45 | #endif // LL_LLVOLUMEXML_H | ||
46 | |||
diff --git a/linden/indra/llprimitive/material_codes.h b/linden/indra/llprimitive/material_codes.h new file mode 100644 index 0000000..fe55344 --- /dev/null +++ b/linden/indra/llprimitive/material_codes.h | |||
@@ -0,0 +1,54 @@ | |||
1 | /** | ||
2 | * @file material_codes.h | ||
3 | * @brief Material_codes definitions | ||
4 | * | ||
5 | * Copyright (c) 2000-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_MATERIAL_CODES_H | ||
29 | #define LL_MATERIAL_CODES_H | ||
30 | |||
31 | #include "lluuid.h" | ||
32 | |||
33 | // material types | ||
34 | const U8 LL_MCODE_STONE = 0; | ||
35 | const U8 LL_MCODE_METAL = 1; | ||
36 | const U8 LL_MCODE_GLASS = 2; | ||
37 | const U8 LL_MCODE_WOOD = 3; | ||
38 | const U8 LL_MCODE_FLESH = 4; | ||
39 | const U8 LL_MCODE_PLASTIC = 5; | ||
40 | const U8 LL_MCODE_RUBBER = 6; | ||
41 | const U8 LL_MCODE_LIGHT = 7; | ||
42 | const U8 LL_MCODE_END = 8; | ||
43 | const U8 LL_MCODE_MASK = 0x0F; | ||
44 | |||
45 | const LLUUID LL_DEFAULT_STONE_UUID("87c5765b-aa26-43eb-b8c6-c09a1ca6208e"); | ||
46 | const LLUUID LL_DEFAULT_METAL_UUID("6f3c53e9-ba60-4010-8f3e-30f51a762476"); | ||
47 | const LLUUID LL_DEFAULT_GLASS_UUID("b4ba225c-373f-446d-9f7e-6cb7b5cf9b3d"); | ||
48 | const LLUUID LL_DEFAULT_WOOD_UUID("89556747-24cb-43ed-920b-47caed15465f"); | ||
49 | const LLUUID LL_DEFAULT_FLESH_UUID("80736669-e4b9-450e-8890-d5169f988a50"); | ||
50 | const LLUUID LL_DEFAULT_PLASTIC_UUID("304fcb4e-7d33-4339-ba80-76d3d22dc11a"); | ||
51 | const LLUUID LL_DEFAULT_RUBBER_UUID("9fae0bc5-666d-477e-9f70-84e8556ec867"); | ||
52 | const LLUUID LL_DEFAULT_LIGHT_UUID("00000000-0000-0000-0000-000000000000"); | ||
53 | |||
54 | #endif | ||
diff --git a/linden/indra/llprimitive/object_flags.h b/linden/indra/llprimitive/object_flags.h new file mode 100644 index 0000000..7c8a66c --- /dev/null +++ b/linden/indra/llprimitive/object_flags.h | |||
@@ -0,0 +1,80 @@ | |||
1 | /** | ||
2 | * @file object_flags.h | ||
3 | * @brief Flags for object creation and transmission | ||
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_OBJECT_FLAGS_H | ||
29 | #define LL_OBJECT_FLAGS_H | ||
30 | |||
31 | // downstream flags from sim->viewer | ||
32 | const U32 FLAGS_USE_PHYSICS = 0x00000001; | ||
33 | const U32 FLAGS_CREATE_SELECTED = 0x00000002; | ||
34 | const U32 FLAGS_OBJECT_MODIFY = 0x00000004; | ||
35 | const U32 FLAGS_OBJECT_COPY = 0x00000008; | ||
36 | const U32 FLAGS_OBJECT_ANY_OWNER = 0x00000010; | ||
37 | const U32 FLAGS_OBJECT_YOU_OWNER = 0x00000020; | ||
38 | const U32 FLAGS_SCRIPTED = 0x00000040; | ||
39 | const U32 FLAGS_HANDLE_TOUCH = 0x00000080; | ||
40 | const U32 FLAGS_OBJECT_MOVE = 0x00000100; | ||
41 | const U32 FLAGS_TAKES_MONEY = 0x00000200; | ||
42 | const U32 FLAGS_PHANTOM = 0x00000400; | ||
43 | const U32 FLAGS_INVENTORY_EMPTY = 0x00000800; | ||
44 | |||
45 | const U32 FLAGS_JOINT_HINGE = 0x00001000; | ||
46 | const U32 FLAGS_JOINT_P2P = 0x00002000; | ||
47 | const U32 FLAGS_JOINT_LP2P = 0x00004000; | ||
48 | //const U32 FLAGS_JOINT_WHEEL = 0x00008000; | ||
49 | |||
50 | const U32 FLAGS_ALLOW_INVENTORY_DROP = 0x00010000; | ||
51 | const U32 FLAGS_OBJECT_TRANSFER = 0x00020000; | ||
52 | const U32 FLAGS_OBJECT_GROUP_OWNED = 0x00040000; | ||
53 | //const U32 FLAGS_OBJECT_YOU_OFFICER = 0x00080000; | ||
54 | |||
55 | const U32 FLAGS_CAMERA_DECOUPLED = 0x00100000; | ||
56 | const U32 FLAGS_ANIM_SOURCE = 0x00200000; | ||
57 | const U32 FLAGS_CAMERA_SOURCE = 0x00400000; | ||
58 | |||
59 | const U32 FLAGS_CAST_SHADOWS = 0x00800000; | ||
60 | |||
61 | const U32 FLAGS_OBJECT_OWNER_MODIFY = 0x10000000; | ||
62 | |||
63 | const U32 FLAGS_TEMPORARY_ON_REZ = 0x20000000; | ||
64 | const U32 FLAGS_TEMPORARY = 0x40000000; | ||
65 | const U32 FLAGS_ZLIB_COMPRESSED = 0x80000000; | ||
66 | |||
67 | const U32 FLAGS_LOCAL = FLAGS_ANIM_SOURCE | FLAGS_CAMERA_SOURCE; | ||
68 | |||
69 | typedef enum e_havok_joint_type | ||
70 | { | ||
71 | HJT_INVALID = 0, | ||
72 | HJT_HINGE = 1, | ||
73 | HJT_POINT = 2, | ||
74 | // HJT_LPOINT = 3, | ||
75 | // HJT_WHEEL = 4, | ||
76 | HJT_EOF = 3 | ||
77 | } EHavokJointType; | ||
78 | |||
79 | #endif | ||
80 | |||