diff options
Diffstat (limited to 'indra/llprimitive/llmaterialtable.cpp')
-rw-r--r-- | indra/llprimitive/llmaterialtable.cpp | 126 |
1 files changed, 92 insertions, 34 deletions
diff --git a/indra/llprimitive/llmaterialtable.cpp b/indra/llprimitive/llmaterialtable.cpp index 40cf97099c..99f32e4109 100644 --- a/indra/llprimitive/llmaterialtable.cpp +++ b/indra/llprimitive/llmaterialtable.cpp @@ -2,30 +2,25 @@ * @file llmaterialtable.cpp * @brief Table of material names and IDs for viewer * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2007, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlife.com/developers/opensource/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at http://secondlife.com/developers/opensource/flossexception + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -39,10 +34,61 @@ LLMaterialTable LLMaterialTable::basic(1); +/* + Old Havok 1 constants + +// these are the approximately correct friction values for various materials +// however Havok1's friction dynamics are not very correct, so the effective +// friction coefficients that result from these numbers are approximately +// 25-50% too low, more incorrect for the lower values. +F32 const LLMaterialTable::FRICTION_MIN = 0.2f; +F32 const LLMaterialTable::FRICTION_GLASS = 0.2f; // borosilicate glass +F32 const LLMaterialTable::FRICTION_LIGHT = 0.2f; // +F32 const LLMaterialTable::FRICTION_METAL = 0.3f; // steel +F32 const LLMaterialTable::FRICTION_PLASTIC = 0.4f; // HDPE +F32 const LLMaterialTable::FRICTION_WOOD = 0.6f; // southern pine +F32 const LLMaterialTable::FRICTION_FLESH = 0.60f; // saltwater +F32 const LLMaterialTable::FRICTION_LAND = 0.78f; // dirt +F32 const LLMaterialTable::FRICTION_STONE = 0.8f; // concrete +F32 const LLMaterialTable::FRICTION_RUBBER = 0.9f; // +F32 const LLMaterialTable::FRICTION_MAX = 0.95f; // +*/ + +// #if LL_CURRENT_HAVOK_VERSION == LL_HAVOK_VERSION_460 +// Havok4 has more correct friction dynamics, however here we have to use +// the "incorrect" equivalents for the legacy Havok1 behavior +F32 const LLMaterialTable::FRICTION_MIN = 0.15f; +F32 const LLMaterialTable::FRICTION_GLASS = 0.13f; // borosilicate glass +F32 const LLMaterialTable::FRICTION_LIGHT = 0.14f; // +F32 const LLMaterialTable::FRICTION_METAL = 0.22f; // steel +F32 const LLMaterialTable::FRICTION_PLASTIC = 0.3f; // HDPE +F32 const LLMaterialTable::FRICTION_WOOD = 0.44f; // southern pine +F32 const LLMaterialTable::FRICTION_FLESH = 0.46f; // saltwater +F32 const LLMaterialTable::FRICTION_LAND = 0.58f; // dirt +F32 const LLMaterialTable::FRICTION_STONE = 0.6f; // concrete +F32 const LLMaterialTable::FRICTION_RUBBER = 0.67f; // +F32 const LLMaterialTable::FRICTION_MAX = 0.71f; // +// #endif + +F32 const LLMaterialTable::RESTITUTION_MIN = 0.02f; +F32 const LLMaterialTable::RESTITUTION_LAND = LLMaterialTable::RESTITUTION_MIN; +F32 const LLMaterialTable::RESTITUTION_FLESH = 0.2f; // saltwater +F32 const LLMaterialTable::RESTITUTION_STONE = 0.4f; // concrete +F32 const LLMaterialTable::RESTITUTION_METAL = 0.4f; // steel +F32 const LLMaterialTable::RESTITUTION_WOOD = 0.5f; // southern pine +F32 const LLMaterialTable::RESTITUTION_GLASS = 0.7f; // borosilicate glass +F32 const LLMaterialTable::RESTITUTION_PLASTIC = 0.7f; // HDPE +F32 const LLMaterialTable::RESTITUTION_LIGHT = 0.7f; // +F32 const LLMaterialTable::RESTITUTION_RUBBER = 0.9f; // +F32 const LLMaterialTable::RESTITUTION_MAX = 0.95f; + F32 const LLMaterialTable::DEFAULT_FRICTION = 0.5f; F32 const LLMaterialTable::DEFAULT_RESTITUTION = 0.4f; LLMaterialTable::LLMaterialTable() + : mCollisionSoundMatrix(NULL), + mSlidingSoundMatrix(NULL), + mRollingSoundMatrix(NULL) { } @@ -75,16 +121,28 @@ LLMaterialTable::~LLMaterialTable() mMaterialInfoList.clear(); } +void LLMaterialTable::initTableTransNames(std::map<std::string, std::string> namemap) +{ + for (info_list_t::iterator iter = mMaterialInfoList.begin(); + iter != mMaterialInfoList.end(); ++iter) + { + LLMaterialInfo *infop = *iter; + std::string name = infop->mName; + infop->mName = namemap[name]; + } +} + void LLMaterialTable::initBasicTable() { - add(LL_MCODE_STONE,"Stone", LL_DEFAULT_STONE_UUID); - add(LL_MCODE_METAL,"Metal", LL_DEFAULT_METAL_UUID); - add(LL_MCODE_GLASS,"Glass", LL_DEFAULT_GLASS_UUID); - add(LL_MCODE_WOOD,"Wood", LL_DEFAULT_WOOD_UUID); - add(LL_MCODE_FLESH,"Flesh", LL_DEFAULT_FLESH_UUID); - add(LL_MCODE_PLASTIC,"Plastic", LL_DEFAULT_PLASTIC_UUID); - add(LL_MCODE_RUBBER,"Rubber", LL_DEFAULT_RUBBER_UUID); - add(LL_MCODE_LIGHT,"Light", LL_DEFAULT_LIGHT_UUID); + // *TODO: Translate + add(LL_MCODE_STONE,std::string("Stone"), LL_DEFAULT_STONE_UUID); + add(LL_MCODE_METAL,std::string("Metal"), LL_DEFAULT_METAL_UUID); + add(LL_MCODE_GLASS,std::string("Glass"), LL_DEFAULT_GLASS_UUID); + add(LL_MCODE_WOOD,std::string("Wood"), LL_DEFAULT_WOOD_UUID); + add(LL_MCODE_FLESH,std::string("Flesh"), LL_DEFAULT_FLESH_UUID); + add(LL_MCODE_PLASTIC,std::string("Plastic"), LL_DEFAULT_PLASTIC_UUID); + add(LL_MCODE_RUBBER,std::string("Rubber"), LL_DEFAULT_RUBBER_UUID); + add(LL_MCODE_LIGHT,std::string("Light"), LL_DEFAULT_LIGHT_UUID); // specify densities for these materials. . . // these were taken from http://www.mcelwee.net/html/densities_of_various_materials.html @@ -283,7 +341,7 @@ void LLMaterialTable::initBasicTable() } } -BOOL LLMaterialTable::add(U8 mcode, char* name, const LLUUID &uuid) +BOOL LLMaterialTable::add(U8 mcode, const std::string& name, const LLUUID &uuid) { LLMaterialInfo *infop; @@ -418,13 +476,13 @@ BOOL LLMaterialTable::addDamageAndEnergy(U8 mcode, const F32 &hp_mod, const F32 return FALSE; } -LLUUID LLMaterialTable::getDefaultTextureID(char* name) +LLUUID LLMaterialTable::getDefaultTextureID(const std::string& name) { for (info_list_t::iterator iter = mMaterialInfoList.begin(); iter != mMaterialInfoList.end(); ++iter) { LLMaterialInfo *infop = *iter; - if (!strcmp(name, infop->mName)) + if (name == infop->mName) { return infop->mDefaultTextureID; } @@ -451,13 +509,13 @@ LLUUID LLMaterialTable::getDefaultTextureID(U8 mcode) } -U8 LLMaterialTable::getMCode(const char* name) +U8 LLMaterialTable::getMCode(const std::string& name) { for (info_list_t::iterator iter = mMaterialInfoList.begin(); iter != mMaterialInfoList.end(); ++iter) { LLMaterialInfo *infop = *iter; - if (!strcmp(name, infop->mName)) + if (name == infop->mName) { return infop->mMCode; } @@ -467,7 +525,7 @@ U8 LLMaterialTable::getMCode(const char* name) } -char* LLMaterialTable::getName(U8 mcode) +std::string LLMaterialTable::getName(U8 mcode) { mcode &= LL_MCODE_MASK; for (info_list_t::iterator iter = mMaterialInfoList.begin(); |