PageRenderTime 66ms CodeModel.GetById 8ms app.highlight 52ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/llprimitive/llmaterialtable.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 738 lines | 569 code | 100 blank | 69 comment | 97 complexity | 5dd8a5762e91eff8886ae61bb57797e3 MD5 | raw file
  1/** 
  2 * @file llmaterialtable.cpp
  3 * @brief Table of material names and IDs for viewer
  4 *
  5 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#include "linden_common.h"
 28
 29#include "llmaterialtable.h"
 30#include "llstl.h"
 31#include "material_codes.h"
 32#include "sound_ids.h"
 33#include "imageids.h"
 34
 35LLMaterialTable LLMaterialTable::basic(1);
 36
 37/* 
 38	Old Havok 1 constants
 39
 40// these are the approximately correct friction values for various materials
 41// however Havok1's friction dynamics are not very correct, so the effective
 42// friction coefficients that result from these numbers are approximately
 43// 25-50% too low, more incorrect for the lower values.
 44F32 const LLMaterialTable::FRICTION_MIN 	= 0.2f; 	
 45F32 const LLMaterialTable::FRICTION_GLASS 	= 0.2f; 	// borosilicate glass
 46F32 const LLMaterialTable::FRICTION_LIGHT 	= 0.2f; 	//
 47F32 const LLMaterialTable::FRICTION_METAL 	= 0.3f; 	// steel
 48F32 const LLMaterialTable::FRICTION_PLASTIC	= 0.4f; 	// HDPE
 49F32 const LLMaterialTable::FRICTION_WOOD 	= 0.6f; 	// southern pine
 50F32 const LLMaterialTable::FRICTION_FLESH 	= 0.60f; 	// saltwater
 51F32 const LLMaterialTable::FRICTION_LAND 	= 0.78f; 	// dirt
 52F32 const LLMaterialTable::FRICTION_STONE 	= 0.8f; 	// concrete
 53F32 const LLMaterialTable::FRICTION_RUBBER 	= 0.9f; 	//
 54F32 const LLMaterialTable::FRICTION_MAX 	= 0.95f; 	//
 55*/
 56
 57// #if LL_CURRENT_HAVOK_VERSION == LL_HAVOK_VERSION_460
 58// Havok4 has more correct friction dynamics, however here we have to use
 59// the "incorrect" equivalents for the legacy Havok1 behavior
 60F32 const LLMaterialTable::FRICTION_MIN 	= 0.15f; 	
 61F32 const LLMaterialTable::FRICTION_GLASS 	= 0.13f; 	// borosilicate glass
 62F32 const LLMaterialTable::FRICTION_LIGHT 	= 0.14f; 	//
 63F32 const LLMaterialTable::FRICTION_METAL 	= 0.22f; 	// steel
 64F32 const LLMaterialTable::FRICTION_PLASTIC	= 0.3f; 	// HDPE
 65F32 const LLMaterialTable::FRICTION_WOOD 	= 0.44f; 	// southern pine
 66F32 const LLMaterialTable::FRICTION_FLESH 	= 0.46f; 	// saltwater
 67F32 const LLMaterialTable::FRICTION_LAND 	= 0.58f; 	// dirt
 68F32 const LLMaterialTable::FRICTION_STONE 	= 0.6f; 	// concrete
 69F32 const LLMaterialTable::FRICTION_RUBBER 	= 0.67f; 	//
 70F32 const LLMaterialTable::FRICTION_MAX 	= 0.71f; 	//
 71// #endif
 72
 73F32 const LLMaterialTable::RESTITUTION_MIN 		= 0.02f; 	
 74F32 const LLMaterialTable::RESTITUTION_LAND 	= LLMaterialTable::RESTITUTION_MIN;
 75F32 const LLMaterialTable::RESTITUTION_FLESH 	= 0.2f; 	// saltwater
 76F32 const LLMaterialTable::RESTITUTION_STONE 	= 0.4f; 	// concrete
 77F32 const LLMaterialTable::RESTITUTION_METAL 	= 0.4f; 	// steel
 78F32 const LLMaterialTable::RESTITUTION_WOOD 	= 0.5f; 	// southern pine
 79F32 const LLMaterialTable::RESTITUTION_GLASS 	= 0.7f; 	// borosilicate glass
 80F32 const LLMaterialTable::RESTITUTION_PLASTIC	= 0.7f; 	// HDPE
 81F32 const LLMaterialTable::RESTITUTION_LIGHT 	= 0.7f; 	//
 82F32 const LLMaterialTable::RESTITUTION_RUBBER 	= 0.9f; 	//
 83F32 const LLMaterialTable::RESTITUTION_MAX		= 0.95f;
 84
 85F32 const LLMaterialTable::DEFAULT_FRICTION = 0.5f;
 86F32 const LLMaterialTable::DEFAULT_RESTITUTION = 0.4f;
 87
 88LLMaterialTable::LLMaterialTable()
 89	: mCollisionSoundMatrix(NULL),
 90	  mSlidingSoundMatrix(NULL),
 91	  mRollingSoundMatrix(NULL)
 92{
 93}
 94
 95LLMaterialTable::LLMaterialTable(U8 isBasic)
 96{
 97	initBasicTable();
 98}
 99
100LLMaterialTable::~LLMaterialTable()
101{
102	if (mCollisionSoundMatrix)
103	{
104		delete [] mCollisionSoundMatrix;
105		mCollisionSoundMatrix = NULL;
106	}
107
108	if (mSlidingSoundMatrix)
109	{
110		delete [] mSlidingSoundMatrix;
111		mSlidingSoundMatrix = NULL;
112	}
113
114	if (mRollingSoundMatrix)
115	{
116		delete [] mRollingSoundMatrix;
117		mRollingSoundMatrix = NULL;
118	}
119
120	for_each(mMaterialInfoList.begin(), mMaterialInfoList.end(), DeletePointer());
121	mMaterialInfoList.clear();
122}
123
124void LLMaterialTable::initTableTransNames(std::map<std::string, std::string> namemap)
125{
126	for (info_list_t::iterator iter = mMaterialInfoList.begin();
127		 iter != mMaterialInfoList.end(); ++iter)
128	{
129		LLMaterialInfo *infop = *iter;
130		std::string name = infop->mName;
131		infop->mName = namemap[name];
132	}
133}
134
135void LLMaterialTable::initBasicTable()
136{
137	// *TODO: Translate
138	add(LL_MCODE_STONE,std::string("Stone"), LL_DEFAULT_STONE_UUID);	
139	add(LL_MCODE_METAL,std::string("Metal"), LL_DEFAULT_METAL_UUID);
140	add(LL_MCODE_GLASS,std::string("Glass"), LL_DEFAULT_GLASS_UUID);
141	add(LL_MCODE_WOOD,std::string("Wood"), LL_DEFAULT_WOOD_UUID);
142	add(LL_MCODE_FLESH,std::string("Flesh"), LL_DEFAULT_FLESH_UUID);
143	add(LL_MCODE_PLASTIC,std::string("Plastic"), LL_DEFAULT_PLASTIC_UUID);
144	add(LL_MCODE_RUBBER,std::string("Rubber"), LL_DEFAULT_RUBBER_UUID);
145	add(LL_MCODE_LIGHT,std::string("Light"), LL_DEFAULT_LIGHT_UUID);
146
147	// specify densities for these materials. . . 
148    // these were taken from http://www.mcelwee.net/html/densities_of_various_materials.html
149
150	addDensity(LL_MCODE_STONE,30.f);
151	addDensity(LL_MCODE_METAL,50.f);
152	addDensity(LL_MCODE_GLASS,20.f);
153	addDensity(LL_MCODE_WOOD,10.f); 
154	addDensity(LL_MCODE_FLESH,10.f);
155	addDensity(LL_MCODE_PLASTIC,5.f);
156	addDensity(LL_MCODE_RUBBER,0.5f); //
157	addDensity(LL_MCODE_LIGHT,20.f); //
158
159	// add damage and energy values
160	addDamageAndEnergy(LL_MCODE_STONE, 1.f, 1.f, 1.f);	// concrete
161	addDamageAndEnergy(LL_MCODE_METAL, 1.f, 1.f, 1.f);  // steel
162	addDamageAndEnergy(LL_MCODE_GLASS, 1.f, 1.f, 1.f);  // borosilicate glass
163	addDamageAndEnergy(LL_MCODE_WOOD, 1.f, 1.f, 1.f);    // southern pine
164	addDamageAndEnergy(LL_MCODE_FLESH, 1.f, 1.f, 1.f);  // saltwater
165	addDamageAndEnergy(LL_MCODE_PLASTIC, 1.f, 1.f, 1.f); // HDPE
166	addDamageAndEnergy(LL_MCODE_RUBBER, 1.f, 1.f, 1.f); //
167	addDamageAndEnergy(LL_MCODE_LIGHT, 1.f, 1.f, 1.f); //
168
169	addFriction(LL_MCODE_STONE,0.8f);	// concrete
170	addFriction(LL_MCODE_METAL,0.3f);  // steel
171	addFriction(LL_MCODE_GLASS,0.2f);  // borosilicate glass
172	addFriction(LL_MCODE_WOOD,0.6f);    // southern pine
173	addFriction(LL_MCODE_FLESH,0.9f);  // saltwater
174	addFriction(LL_MCODE_PLASTIC,0.4f); // HDPE
175	addFriction(LL_MCODE_RUBBER,0.9f); //
176	addFriction(LL_MCODE_LIGHT,0.2f); //
177
178	addRestitution(LL_MCODE_STONE,0.4f);	// concrete
179	addRestitution(LL_MCODE_METAL,0.4f);  // steel
180	addRestitution(LL_MCODE_GLASS,0.7f);  // borosilicate glass
181	addRestitution(LL_MCODE_WOOD,0.5f);    // southern pine
182	addRestitution(LL_MCODE_FLESH,0.3f);  // saltwater
183	addRestitution(LL_MCODE_PLASTIC,0.7f); // HDPE
184	addRestitution(LL_MCODE_RUBBER,0.9f); //
185	addRestitution(LL_MCODE_LIGHT,0.7f); //
186
187	addShatterSound(LL_MCODE_STONE,LLUUID("ea296329-0f09-4993-af1b-e6784bab1dc9"));
188	addShatterSound(LL_MCODE_METAL,LLUUID("d1375446-1c4d-470b-9135-30132433b678"));
189	addShatterSound(LL_MCODE_GLASS,LLUUID("85cda060-b393-48e6-81c8-2cfdfb275351"));
190	addShatterSound(LL_MCODE_WOOD,LLUUID("6f00669f-15e0-4793-a63e-c03f62fee43a"));
191	addShatterSound(LL_MCODE_FLESH,LLUUID("2d8c6f51-149e-4e23-8413-93a379b42b67"));
192	addShatterSound(LL_MCODE_PLASTIC,LLUUID("d55c7f3c-e1c3-4ddc-9eff-9ef805d9190e"));
193	addShatterSound(LL_MCODE_RUBBER,LLUUID("212b6d1e-8d9c-4986-b3aa-f3c6df8d987d"));
194	addShatterSound(LL_MCODE_LIGHT,LLUUID("d55c7f3c-e1c3-4ddc-9eff-9ef805d9190e"));
195
196	//  CollisionSounds
197	mCollisionSoundMatrix = new LLUUID[LL_MCODE_END*LL_MCODE_END];
198	if (mCollisionSoundMatrix)
199	{
200		addCollisionSound(LL_MCODE_STONE, LL_MCODE_STONE, SND_STONE_STONE);
201		addCollisionSound(LL_MCODE_STONE, LL_MCODE_METAL, SND_STONE_METAL);
202		addCollisionSound(LL_MCODE_STONE, LL_MCODE_GLASS, SND_STONE_GLASS);
203		addCollisionSound(LL_MCODE_STONE, LL_MCODE_WOOD, SND_STONE_WOOD);
204		addCollisionSound(LL_MCODE_STONE, LL_MCODE_FLESH, SND_STONE_FLESH);
205		addCollisionSound(LL_MCODE_STONE, LL_MCODE_PLASTIC, SND_STONE_PLASTIC);
206		addCollisionSound(LL_MCODE_STONE, LL_MCODE_RUBBER, SND_STONE_RUBBER);
207		addCollisionSound(LL_MCODE_STONE, LL_MCODE_LIGHT, SND_STONE_PLASTIC);
208
209		addCollisionSound(LL_MCODE_METAL, LL_MCODE_METAL, SND_METAL_METAL);
210		addCollisionSound(LL_MCODE_METAL, LL_MCODE_GLASS, SND_METAL_GLASS);
211		addCollisionSound(LL_MCODE_METAL, LL_MCODE_WOOD, SND_METAL_WOOD);
212		addCollisionSound(LL_MCODE_METAL, LL_MCODE_FLESH, SND_METAL_FLESH);
213		addCollisionSound(LL_MCODE_METAL, LL_MCODE_PLASTIC, SND_METAL_PLASTIC);
214		addCollisionSound(LL_MCODE_METAL, LL_MCODE_LIGHT, SND_METAL_PLASTIC);
215		addCollisionSound(LL_MCODE_METAL, LL_MCODE_RUBBER, SND_METAL_RUBBER);
216
217		addCollisionSound(LL_MCODE_GLASS, LL_MCODE_GLASS, SND_GLASS_GLASS);
218		addCollisionSound(LL_MCODE_GLASS, LL_MCODE_WOOD, SND_GLASS_WOOD);
219		addCollisionSound(LL_MCODE_GLASS, LL_MCODE_FLESH, SND_GLASS_FLESH);
220		addCollisionSound(LL_MCODE_GLASS, LL_MCODE_PLASTIC, SND_GLASS_PLASTIC);
221		addCollisionSound(LL_MCODE_GLASS, LL_MCODE_RUBBER, SND_GLASS_RUBBER);
222		addCollisionSound(LL_MCODE_GLASS, LL_MCODE_LIGHT, SND_GLASS_PLASTIC);
223
224		addCollisionSound(LL_MCODE_WOOD, LL_MCODE_WOOD, SND_WOOD_WOOD);
225		addCollisionSound(LL_MCODE_WOOD, LL_MCODE_FLESH, SND_WOOD_FLESH);
226		addCollisionSound(LL_MCODE_WOOD, LL_MCODE_PLASTIC, SND_WOOD_PLASTIC);
227		addCollisionSound(LL_MCODE_WOOD, LL_MCODE_RUBBER, SND_WOOD_RUBBER);
228		addCollisionSound(LL_MCODE_WOOD, LL_MCODE_LIGHT, SND_WOOD_PLASTIC);
229
230		addCollisionSound(LL_MCODE_FLESH, LL_MCODE_FLESH, SND_FLESH_FLESH);
231		addCollisionSound(LL_MCODE_FLESH, LL_MCODE_PLASTIC, SND_FLESH_PLASTIC);
232		addCollisionSound(LL_MCODE_FLESH, LL_MCODE_RUBBER, SND_FLESH_RUBBER);
233		addCollisionSound(LL_MCODE_FLESH, LL_MCODE_LIGHT, SND_FLESH_PLASTIC);
234
235		addCollisionSound(LL_MCODE_RUBBER, LL_MCODE_RUBBER, SND_RUBBER_RUBBER);
236		addCollisionSound(LL_MCODE_RUBBER, LL_MCODE_PLASTIC, SND_RUBBER_PLASTIC);
237		addCollisionSound(LL_MCODE_RUBBER, LL_MCODE_LIGHT, SND_RUBBER_PLASTIC);
238
239		addCollisionSound(LL_MCODE_PLASTIC, LL_MCODE_PLASTIC, SND_PLASTIC_PLASTIC);
240		addCollisionSound(LL_MCODE_PLASTIC, LL_MCODE_LIGHT, SND_PLASTIC_PLASTIC);
241
242		addCollisionSound(LL_MCODE_LIGHT, LL_MCODE_LIGHT, SND_PLASTIC_PLASTIC);
243	}
244	
245	//  Sliding Sounds
246	mSlidingSoundMatrix = new LLUUID[LL_MCODE_END*LL_MCODE_END];
247	if (mSlidingSoundMatrix)
248	{
249		addSlidingSound(LL_MCODE_STONE, LL_MCODE_STONE, SND_SLIDE_STONE_STONE);
250		addSlidingSound(LL_MCODE_STONE, LL_MCODE_METAL, SND_SLIDE_STONE_STONE_01);
251		addSlidingSound(LL_MCODE_STONE, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01);
252		addSlidingSound(LL_MCODE_STONE, LL_MCODE_WOOD, SND_SLIDE_STONE_WOOD);
253		addSlidingSound(LL_MCODE_STONE, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
254		addSlidingSound(LL_MCODE_STONE, LL_MCODE_PLASTIC, SND_SLIDE_STONE_PLASTIC);
255		addSlidingSound(LL_MCODE_STONE, LL_MCODE_RUBBER, SND_SLIDE_STONE_RUBBER);
256		addSlidingSound(LL_MCODE_STONE, LL_MCODE_LIGHT, SND_SLIDE_STONE_PLASTIC);
257
258		addSlidingSound(LL_MCODE_METAL, LL_MCODE_METAL, SND_SLIDE_METAL_METAL);
259		addSlidingSound(LL_MCODE_METAL, LL_MCODE_GLASS, SND_SLIDE_METAL_GLASS);
260		addSlidingSound(LL_MCODE_METAL, LL_MCODE_WOOD, SND_SLIDE_METAL_WOOD);
261		addSlidingSound(LL_MCODE_METAL, LL_MCODE_FLESH, SND_SLIDE_METAL_FLESH);
262		addSlidingSound(LL_MCODE_METAL, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
263		addSlidingSound(LL_MCODE_METAL, LL_MCODE_RUBBER, SND_SLIDE_METAL_RUBBER);
264		addSlidingSound(LL_MCODE_METAL, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
265
266		addSlidingSound(LL_MCODE_GLASS, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01);
267		addSlidingSound(LL_MCODE_GLASS, LL_MCODE_WOOD, SND_SLIDE_STONE_STONE_01);
268		addSlidingSound(LL_MCODE_GLASS, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
269		addSlidingSound(LL_MCODE_GLASS, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
270		addSlidingSound(LL_MCODE_GLASS, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
271		addSlidingSound(LL_MCODE_GLASS, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
272
273		addSlidingSound(LL_MCODE_WOOD, LL_MCODE_WOOD, SND_SLIDE_WOOD_WOOD);
274		addSlidingSound(LL_MCODE_WOOD, LL_MCODE_FLESH, SND_SLIDE_WOOD_FLESH);
275		addSlidingSound(LL_MCODE_WOOD, LL_MCODE_PLASTIC, SND_SLIDE_WOOD_PLASTIC);
276		addSlidingSound(LL_MCODE_WOOD, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
277		addSlidingSound(LL_MCODE_WOOD, LL_MCODE_LIGHT, SND_SLIDE_WOOD_PLASTIC);
278
279		addSlidingSound(LL_MCODE_FLESH, LL_MCODE_FLESH, SND_SLIDE_FLESH_FLESH);
280		addSlidingSound(LL_MCODE_FLESH, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
281		addSlidingSound(LL_MCODE_FLESH, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
282		addSlidingSound(LL_MCODE_FLESH, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
283
284		addSlidingSound(LL_MCODE_RUBBER, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
285		addSlidingSound(LL_MCODE_RUBBER, LL_MCODE_PLASTIC, SND_SLIDE_RUBBER_PLASTIC);
286		addSlidingSound(LL_MCODE_RUBBER, LL_MCODE_LIGHT, SND_SLIDE_RUBBER_PLASTIC);
287
288		addSlidingSound(LL_MCODE_PLASTIC, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
289		addSlidingSound(LL_MCODE_PLASTIC, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
290
291		addSlidingSound(LL_MCODE_LIGHT, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
292	}
293
294	//  Rolling Sounds
295	mRollingSoundMatrix = new LLUUID[LL_MCODE_END*LL_MCODE_END];
296	if (mRollingSoundMatrix)
297	{
298		addRollingSound(LL_MCODE_STONE, LL_MCODE_STONE, SND_ROLL_STONE_STONE);
299		addRollingSound(LL_MCODE_STONE, LL_MCODE_METAL, SND_SLIDE_STONE_STONE_01);
300		addRollingSound(LL_MCODE_STONE, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01);
301		addRollingSound(LL_MCODE_STONE, LL_MCODE_WOOD, SND_ROLL_STONE_WOOD);
302		addRollingSound(LL_MCODE_STONE, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
303		addRollingSound(LL_MCODE_STONE, LL_MCODE_PLASTIC, SND_ROLL_STONE_PLASTIC);
304		addRollingSound(LL_MCODE_STONE, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
305		addRollingSound(LL_MCODE_STONE, LL_MCODE_LIGHT, SND_ROLL_STONE_PLASTIC);
306
307		addRollingSound(LL_MCODE_METAL, LL_MCODE_METAL, SND_SLIDE_STONE_STONE_01);
308		addRollingSound(LL_MCODE_METAL, LL_MCODE_GLASS, SND_ROLL_METAL_GLASS);
309		addRollingSound(LL_MCODE_METAL, LL_MCODE_WOOD, SND_ROLL_METAL_WOOD);
310		addRollingSound(LL_MCODE_METAL, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
311		addRollingSound(LL_MCODE_METAL, LL_MCODE_PLASTIC, SND_ROLL_METAL_WOOD);
312		addRollingSound(LL_MCODE_METAL, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
313		addRollingSound(LL_MCODE_METAL, LL_MCODE_LIGHT, SND_ROLL_METAL_WOOD);
314
315		addRollingSound(LL_MCODE_GLASS, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01);
316		addRollingSound(LL_MCODE_GLASS, LL_MCODE_WOOD, SND_ROLL_GLASS_WOOD);
317		addRollingSound(LL_MCODE_GLASS, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
318		addRollingSound(LL_MCODE_GLASS, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
319		addRollingSound(LL_MCODE_GLASS, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
320		addRollingSound(LL_MCODE_GLASS, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
321
322		addRollingSound(LL_MCODE_WOOD, LL_MCODE_WOOD, SND_ROLL_WOOD_WOOD);
323		addRollingSound(LL_MCODE_WOOD, LL_MCODE_FLESH, SND_ROLL_WOOD_FLESH);
324		addRollingSound(LL_MCODE_WOOD, LL_MCODE_PLASTIC, SND_ROLL_WOOD_PLASTIC);
325		addRollingSound(LL_MCODE_WOOD, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
326		addRollingSound(LL_MCODE_WOOD, LL_MCODE_LIGHT, SND_ROLL_WOOD_PLASTIC);
327
328		addRollingSound(LL_MCODE_FLESH, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
329		addRollingSound(LL_MCODE_FLESH, LL_MCODE_PLASTIC, SND_ROLL_FLESH_PLASTIC);
330		addRollingSound(LL_MCODE_FLESH, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
331		addRollingSound(LL_MCODE_FLESH, LL_MCODE_LIGHT, SND_ROLL_FLESH_PLASTIC);
332
333		addRollingSound(LL_MCODE_RUBBER, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
334		addRollingSound(LL_MCODE_RUBBER, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
335		addRollingSound(LL_MCODE_RUBBER, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
336
337		addRollingSound(LL_MCODE_PLASTIC, LL_MCODE_PLASTIC, SND_ROLL_PLASTIC_PLASTIC);
338		addRollingSound(LL_MCODE_PLASTIC, LL_MCODE_LIGHT, SND_ROLL_PLASTIC_PLASTIC);
339
340		addRollingSound(LL_MCODE_LIGHT, LL_MCODE_LIGHT, SND_ROLL_PLASTIC_PLASTIC);
341	}
342}
343
344BOOL LLMaterialTable::add(U8 mcode, const std::string& name, const LLUUID &uuid)
345{
346	LLMaterialInfo *infop;
347
348	infop = new LLMaterialInfo(mcode,name,uuid);
349	if (!infop) return FALSE;
350
351	// Add at the end so the order in menus matches the order in this
352	// file.  JNC 11.30.01
353	mMaterialInfoList.push_back(infop);
354
355	return TRUE;
356}
357
358BOOL LLMaterialTable::addCollisionSound(U8 mcode, U8 mcode2, const LLUUID &uuid)
359{
360	if (mCollisionSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
361	{
362		mCollisionSoundMatrix[mcode * LL_MCODE_END + mcode2] = uuid;		
363		if (mcode != mcode2)
364		{
365			mCollisionSoundMatrix[mcode2 * LL_MCODE_END + mcode] = uuid;		
366		}
367	}
368	return TRUE;
369}
370
371BOOL LLMaterialTable::addSlidingSound(U8 mcode, U8 mcode2, const LLUUID &uuid)
372{
373	if (mSlidingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
374	{
375		mSlidingSoundMatrix[mcode * LL_MCODE_END + mcode2] = uuid;		
376		if (mcode != mcode2)
377		{
378			mSlidingSoundMatrix[mcode2 * LL_MCODE_END + mcode] = uuid;		
379		}
380	}
381	return TRUE;
382}
383
384BOOL LLMaterialTable::addRollingSound(U8 mcode, U8 mcode2, const LLUUID &uuid)
385{
386	if (mRollingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
387	{
388		mRollingSoundMatrix[mcode * LL_MCODE_END + mcode2] = uuid;		
389		if (mcode != mcode2)
390		{
391			mRollingSoundMatrix[mcode2 * LL_MCODE_END + mcode] = uuid;		
392		}
393	}
394	return TRUE;
395}
396
397BOOL LLMaterialTable::addShatterSound(U8 mcode, const LLUUID &uuid)
398{
399	for (info_list_t::iterator iter = mMaterialInfoList.begin();
400		 iter != mMaterialInfoList.end(); ++iter)
401	{
402		LLMaterialInfo *infop = *iter;
403		if (mcode == infop->mMCode)
404		{
405			infop->mShatterSoundID = uuid;
406			return TRUE;
407		}
408	}
409
410	return FALSE;
411}
412
413BOOL LLMaterialTable::addDensity(U8 mcode, const F32 &density)
414{
415	for (info_list_t::iterator iter = mMaterialInfoList.begin();
416		 iter != mMaterialInfoList.end(); ++iter)
417	{
418		LLMaterialInfo *infop = *iter;
419		if (mcode == infop->mMCode)
420		{
421			infop->mDensity = density;
422			return TRUE;
423		}
424	}
425
426	return FALSE;
427}
428
429BOOL LLMaterialTable::addRestitution(U8 mcode, const F32 &restitution)
430{
431	for (info_list_t::iterator iter = mMaterialInfoList.begin();
432		 iter != mMaterialInfoList.end(); ++iter)
433	{
434		LLMaterialInfo *infop = *iter;
435		if (mcode == infop->mMCode)
436		{
437			infop->mRestitution = restitution;
438			return TRUE;
439		}
440	}
441
442	return FALSE;
443}
444
445BOOL LLMaterialTable::addFriction(U8 mcode, const F32 &friction)
446{
447	for (info_list_t::iterator iter = mMaterialInfoList.begin();
448		 iter != mMaterialInfoList.end(); ++iter)
449	{
450		LLMaterialInfo *infop = *iter;
451		if (mcode == infop->mMCode)
452		{
453			infop->mFriction = friction;
454			return TRUE;
455		}
456	}
457
458	return FALSE;
459}
460
461BOOL LLMaterialTable::addDamageAndEnergy(U8 mcode, const F32 &hp_mod, const F32 &damage_mod, const F32 &ep_mod)
462{
463	for (info_list_t::iterator iter = mMaterialInfoList.begin();
464		 iter != mMaterialInfoList.end(); ++iter)
465	{
466		LLMaterialInfo *infop = *iter;
467		if (mcode == infop->mMCode)
468		{
469			infop->mHPModifier = hp_mod;
470			infop->mDamageModifier = damage_mod;
471			infop->mEPModifier = ep_mod;
472			return TRUE;
473		}
474	}
475
476	return FALSE;
477}
478
479LLUUID LLMaterialTable::getDefaultTextureID(const std::string& name)
480{
481	for (info_list_t::iterator iter = mMaterialInfoList.begin();
482		 iter != mMaterialInfoList.end(); ++iter)
483	{
484		LLMaterialInfo *infop = *iter;
485		if (name == infop->mName)
486		{
487			return infop->mDefaultTextureID;
488		}
489	}
490
491	return LLUUID::null;
492}
493
494
495LLUUID LLMaterialTable::getDefaultTextureID(U8 mcode)
496{
497	mcode &= LL_MCODE_MASK;
498	for (info_list_t::iterator iter = mMaterialInfoList.begin();
499		 iter != mMaterialInfoList.end(); ++iter)
500	{
501		LLMaterialInfo *infop = *iter;
502		if (mcode == infop->mMCode)
503		{
504			return infop->mDefaultTextureID;
505		}
506	}
507
508	return LLUUID::null;
509}
510
511
512U8 LLMaterialTable::getMCode(const std::string& name)
513{
514	for (info_list_t::iterator iter = mMaterialInfoList.begin();
515		 iter != mMaterialInfoList.end(); ++iter)
516	{
517		LLMaterialInfo *infop = *iter;
518		if (name == infop->mName)
519		{
520			return infop->mMCode;
521		}
522	}
523
524	return 0;
525}
526
527
528std::string LLMaterialTable::getName(U8 mcode)
529{
530	mcode &= LL_MCODE_MASK;
531	for (info_list_t::iterator iter = mMaterialInfoList.begin();
532		 iter != mMaterialInfoList.end(); ++iter)
533	{
534		LLMaterialInfo *infop = *iter;
535		if (mcode == infop->mMCode)
536		{
537			return infop->mName;
538		}
539	}
540
541	return std::string();
542}
543
544
545LLUUID LLMaterialTable::getCollisionSoundUUID(U8 mcode, U8 mcode2)
546{
547	mcode &= LL_MCODE_MASK;
548	mcode2 &= LL_MCODE_MASK;
549	
550	//llinfos << "code 1: " << ((U32) mcode) << " code 2:" << ((U32) mcode2) << llendl;
551	if (mCollisionSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
552	{
553		return(mCollisionSoundMatrix[mcode * LL_MCODE_END + mcode2]);
554	}
555	else
556	{
557		//llinfos << "Null Sound" << llendl;
558		return(SND_NULL);
559	}
560}
561
562LLUUID LLMaterialTable::getSlidingSoundUUID(U8 mcode, U8 mcode2)
563{	
564	mcode &= LL_MCODE_MASK;
565	mcode2 &= LL_MCODE_MASK;
566	
567	if (mSlidingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
568	{
569		return(mSlidingSoundMatrix[mcode * LL_MCODE_END + mcode2]);
570	}
571	else
572	{
573		return(SND_NULL);
574	}
575}
576
577LLUUID LLMaterialTable::getRollingSoundUUID(U8 mcode, U8 mcode2)
578{	
579	mcode &= LL_MCODE_MASK;
580	mcode2 &= LL_MCODE_MASK;
581	
582	if (mRollingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
583	{
584		return(mRollingSoundMatrix[mcode * LL_MCODE_END + mcode2]);
585	}
586	else
587	{
588		return(SND_NULL);
589	}
590}
591
592LLUUID LLMaterialTable::getGroundCollisionSoundUUID(U8 mcode)
593{	
594	//  Create material appropriate sounds for collisions with the ground 
595	//  For now, simply return a single sound for all materials 
596	return SND_STONE_DIRT_02;
597}
598
599LLUUID LLMaterialTable::getGroundSlidingSoundUUID(U8 mcode)
600{	
601	//  Create material-specific sound for sliding on ground
602	//  For now, just return a single sound 
603	return SND_SLIDE_STONE_STONE_01;
604}
605
606LLUUID LLMaterialTable::getGroundRollingSoundUUID(U8 mcode)
607{	
608	//  Create material-specific sound for rolling on ground
609	//  For now, just return a single sound 
610	return SND_SLIDE_STONE_STONE_01;
611}
612
613LLUUID LLMaterialTable::getCollisionParticleUUID(U8 mcode, U8 mcode2)
614{	
615	//  Returns an appropriate UUID to use as sprite at collision betweeen objects  
616	//  For now, just return a single image 
617	return IMG_SHOT;
618}
619
620LLUUID LLMaterialTable::getGroundCollisionParticleUUID(U8 mcode)
621{	
622	//  Returns an appropriate 
623	//  For now, just return a single sound 
624	return IMG_SMOKE_POOF;
625}
626
627
628F32 LLMaterialTable::getDensity(U8 mcode)
629{	
630	mcode &= LL_MCODE_MASK;
631	for (info_list_t::iterator iter = mMaterialInfoList.begin();
632		 iter != mMaterialInfoList.end(); ++iter)
633	{
634		LLMaterialInfo *infop = *iter;
635		if (mcode == infop->mMCode)
636		{
637			return infop->mDensity;
638		}
639	}
640
641	return 0.f;
642}
643
644F32 LLMaterialTable::getRestitution(U8 mcode)
645{	
646	mcode &= LL_MCODE_MASK;
647	for (info_list_t::iterator iter = mMaterialInfoList.begin();
648		 iter != mMaterialInfoList.end(); ++iter)
649	{
650		LLMaterialInfo *infop = *iter;
651		if (mcode == infop->mMCode)
652		{
653			return infop->mRestitution;
654		}
655	}
656
657	return LLMaterialTable::DEFAULT_RESTITUTION;
658}
659
660F32 LLMaterialTable::getFriction(U8 mcode)
661{	
662	mcode &= LL_MCODE_MASK;
663	for (info_list_t::iterator iter = mMaterialInfoList.begin();
664		 iter != mMaterialInfoList.end(); ++iter)
665	{
666		LLMaterialInfo *infop = *iter;
667		if (mcode == infop->mMCode)
668		{
669			return infop->mFriction;
670		}
671	}
672
673	return LLMaterialTable::DEFAULT_FRICTION;
674}
675
676F32 LLMaterialTable::getHPMod(U8 mcode)
677{	
678	mcode &= LL_MCODE_MASK;
679	for (info_list_t::iterator iter = mMaterialInfoList.begin();
680		 iter != mMaterialInfoList.end(); ++iter)
681	{
682		LLMaterialInfo *infop = *iter;
683		if (mcode == infop->mMCode)
684		{
685			return infop->mHPModifier;
686		}
687	}
688
689	return 1.f;
690}
691
692F32 LLMaterialTable::getDamageMod(U8 mcode)
693{	
694	mcode &= LL_MCODE_MASK;
695	for (info_list_t::iterator iter = mMaterialInfoList.begin();
696		 iter != mMaterialInfoList.end(); ++iter)
697	{
698		LLMaterialInfo *infop = *iter;
699		if (mcode == infop->mMCode)
700		{
701			return infop->mDamageModifier;
702		}
703	}
704
705	return 1.f;
706}
707
708F32 LLMaterialTable::getEPMod(U8 mcode)
709{	
710	mcode &= LL_MCODE_MASK;
711	for (info_list_t::iterator iter = mMaterialInfoList.begin();
712		 iter != mMaterialInfoList.end(); ++iter)
713	{
714		LLMaterialInfo *infop = *iter;
715		if (mcode == infop->mMCode)
716		{
717			return infop->mEPModifier;
718		}
719	}
720
721	return 1.f;
722}
723
724LLUUID LLMaterialTable::getShatterSoundUUID(U8 mcode)
725{	
726	mcode &= LL_MCODE_MASK;
727	for (info_list_t::iterator iter = mMaterialInfoList.begin();
728		 iter != mMaterialInfoList.end(); ++iter)
729	{
730		LLMaterialInfo *infop = *iter;
731		if (mcode == infop->mMCode)
732		{
733			return infop->mShatterSoundID;
734		}
735	}
736
737	return SND_NULL;
738}