From ae10e78d978360871556b1cee615cd79ef381184 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Fri, 14 Sep 2012 17:56:42 -0700 Subject: Added some initial basic decoding of the material value per face. --- indra/llprimitive/llprimitive.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 6dee192783..40e6bedd49 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1357,6 +1357,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) U8 bump[MAX_TES]; U8 media_flags[MAX_TES]; U8 glow[MAX_TES]; + unsigned char material_id[MAX_TES*16]; const U32 MAX_TE_BUFFER = 4096; U8 packed_buffer[MAX_TE_BUFFER]; @@ -1399,6 +1400,25 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8); cur_ptr++; cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)glow, 1, face_count, MVT_U8); + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_id, 16, face_count, MVT_LLUUID); + + for (U32 curFace = 0U; curFace < face_count; ++curFace) + { + std::string materialID(reinterpret_cast(&material_id[curFace * 16]), 16); + std::string materialIDString; + for (unsigned int i = 0U; i < 4U; ++i) + { + if (i != 0U) + { + materialIDString += "-"; + } + const U32 *value = reinterpret_cast(&materialID.c_str()[i * 4]); + materialIDString += llformat("%08x", *value); + } + + llinfos << "STINSON DEBUG: found material ID for face #" << curFace << " => " << materialIDString << llendl; + } for (i = 0; i < face_count; i++) { -- cgit v1.2.3 From dbe0a577ae09f500373c104e038a7d64dd9e3002 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Wed, 3 Oct 2012 18:31:33 -0700 Subject: Removing overly verbose debug outputs. --- indra/llprimitive/llprimitive.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 40e6bedd49..c6e229ae8e 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1403,6 +1403,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) cur_ptr++; cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_id, 16, face_count, MVT_LLUUID); +#if 0 for (U32 curFace = 0U; curFace < face_count; ++curFace) { std::string materialID(reinterpret_cast(&material_id[curFace * 16]), 16); @@ -1419,6 +1420,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) llinfos << "STINSON DEBUG: found material ID for face #" << curFace << " => " << materialIDString << llendl; } +#endif for (i = 0; i < face_count; i++) { -- cgit v1.2.3 From 38a565f71a54aaa66300a0ab593e366731aac769 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Tue, 9 Oct 2012 12:30:38 -0700 Subject: Initial pass at getting a list of viewer objects with non-null material IDs. --- indra/llprimitive/CMakeLists.txt | 2 + indra/llprimitive/llmaterialid.cpp | 112 ++++++++++++++++++++++++++++++++ indra/llprimitive/llmaterialid.h | 62 ++++++++++++++++++ indra/llprimitive/llprimitive.cpp | 54 +++++++++------ indra/llprimitive/llprimitive.h | 2 + indra/llprimitive/llprimtexturelist.cpp | 10 +++ indra/llprimitive/llprimtexturelist.h | 2 + indra/llprimitive/lltextureentry.cpp | 17 +++++ indra/llprimitive/lltextureentry.h | 4 ++ 9 files changed, 244 insertions(+), 21 deletions(-) create mode 100644 indra/llprimitive/llmaterialid.cpp create mode 100644 indra/llprimitive/llmaterialid.h (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index e4d9de7eb6..82d0f892f2 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -20,6 +20,7 @@ include_directories( ) set(llprimitive_SOURCE_FILES + llmaterialid.cpp llmaterialtable.cpp llmediaentry.cpp llmodel.cpp @@ -37,6 +38,7 @@ set(llprimitive_HEADER_FILES CMakeLists.txt legacy_object_types.h + llmaterialid.h llmaterialtable.h llmediaentry.h llmodel.h diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp new file mode 100644 index 0000000000..4355a8ea3f --- /dev/null +++ b/indra/llprimitive/llmaterialid.cpp @@ -0,0 +1,112 @@ +/** +* @file llmaterialid.cpp +* @brief Implementation of llmaterialid +* @author Stinson@lindenlab.com +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, 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. +* +* 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. +* +* 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 +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "linden_common.h" + +#include "llmaterialid.h" + +const LLMaterialID LLMaterialID::null; + +LLMaterialID::LLMaterialID() +{ + clear(); +} + +LLMaterialID::LLMaterialID(const LLSD& pMaterialID) +{ + llassert(pMaterialID.isBinary()); + parseFromBinary(pMaterialID.asBinary()); +} + +LLMaterialID::LLMaterialID(const LLSD::Binary& pMaterialID) +{ + parseFromBinary(pMaterialID); +} + +LLMaterialID::LLMaterialID(const LLMaterialID& pOtherMaterialID) +{ + copyFromOtherMaterialID(pOtherMaterialID); +} + +LLMaterialID::~LLMaterialID() +{ +} + +bool LLMaterialID::operator == (const LLMaterialID& pOtherMaterialID) const +{ + return (compareToOtherMaterialID(pOtherMaterialID) == 0); +} + +bool LLMaterialID::operator != (const LLMaterialID& pOtherMaterialID) const +{ + return (compareToOtherMaterialID(pOtherMaterialID) != 0); +} + +LLMaterialID& LLMaterialID::operator = (const LLMaterialID& pOtherMaterialID) +{ + copyFromOtherMaterialID(pOtherMaterialID); + return (*this); +} + +bool LLMaterialID::isNull() const +{ + return (compareToOtherMaterialID(LLMaterialID::null) == 0); +} + +const U8* LLMaterialID::get() const +{ + return mID; +} + +void LLMaterialID::set(const void* pMemory) +{ + llassert(pMemory != NULL); + + // assumes that the required size of memory is available + memcpy(mID, pMemory, MATERIAL_ID_SIZE * sizeof(U8)); +} + +void LLMaterialID::clear() +{ + memset(mID, 0, MATERIAL_ID_SIZE * sizeof(U8)); +} + +void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID) +{ + llassert(pMaterialID.size() == (MATERIAL_ID_SIZE * sizeof(U8))); + memcpy(mID, &pMaterialID[0], MATERIAL_ID_SIZE * sizeof(U8)); +} + +void LLMaterialID::copyFromOtherMaterialID(const LLMaterialID& pOtherMaterialID) +{ + memcpy(mID, pOtherMaterialID.mID, MATERIAL_ID_SIZE * sizeof(U8)); +} + +int LLMaterialID::compareToOtherMaterialID(const LLMaterialID& pOtherMaterialID) const +{ + return memcmp(mID, pOtherMaterialID.mID, MATERIAL_ID_SIZE * sizeof(U8)); +} diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h new file mode 100644 index 0000000000..4551550db5 --- /dev/null +++ b/indra/llprimitive/llmaterialid.h @@ -0,0 +1,62 @@ +/** +* @file llmaterialid.h +* @brief Header file for llmaterialid +* @author Stinson@lindenlab.com +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, 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. +* +* 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. +* +* 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 +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ +#ifndef LL_LLMATERIALID_H +#define LL_LLMATERIALID_H + +#define MATERIAL_ID_SIZE 16 + +class LLMaterialID +{ +public: + LLMaterialID(); + LLMaterialID(const LLSD& pMaterialID); + LLMaterialID(const LLSD::Binary& pMaterialID); + LLMaterialID(const LLMaterialID& pOtherMaterialID); + ~LLMaterialID(); + + bool operator == (const LLMaterialID& pOtherMaterialID) const; + bool operator != (const LLMaterialID& pOtherMaterialID) const; + LLMaterialID& operator = (const LLMaterialID& pOtherMaterialID); + + bool isNull() const; + + const U8* get() const; + void set(const void* pMemory); + void clear(); + + static const LLMaterialID null; + +private: + void parseFromBinary(const LLSD::Binary& pMaterialID); + void copyFromOtherMaterialID(const LLMaterialID& pOtherMaterialID); + int compareToOtherMaterialID(const LLMaterialID& pOtherMaterialID) const; + + U8 mID[MATERIAL_ID_SIZE]; +} ; + +#endif // LL_LLMATERIALID_H + diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index c6e229ae8e..86aa371368 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -39,6 +39,7 @@ #include "lldatapacker.h" #include "llsdutil_math.h" #include "llprimtexturelist.h" +#include "llmaterialid.h" /** * exported constants @@ -366,6 +367,11 @@ S32 LLPrimitive::setTEGlow(const U8 index, const F32 glow) return mTextureList.setGlow(index, glow); } +S32 LLPrimitive::setTEMaterialID(const U8 index, const LLMaterialID& pMaterialID) +{ + return mTextureList.setMaterialID(index, pMaterialID); +} + LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { @@ -1091,6 +1097,7 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const U8 bump[MAX_TES]; U8 media_flags[MAX_TES]; U8 glow[MAX_TES]; + U8 material_data[MAX_TES*16]; const U32 MAX_TE_BUFFER = 4096; U8 packed_buffer[MAX_TE_BUFFER]; @@ -1128,6 +1135,9 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const bump[face_index] = te->getBumpShinyFullbright(); media_flags[face_index] = te->getMediaTexGen(); glow[face_index] = (U8) llround((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF)); + + // Directly sending material_ids is not safe! + memcpy(&material_data[face_index*16],getTE(face_index)->getMaterialID().get(),16); /* Flawfinder: ignore */ } cur_ptr += packTEField(cur_ptr, (U8 *)image_ids, sizeof(LLUUID),last_face_index, MVT_LLUUID); @@ -1149,6 +1159,8 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const cur_ptr += packTEField(cur_ptr, (U8 *)media_flags, 1 ,last_face_index, MVT_U8); *cur_ptr++ = 0; cur_ptr += packTEField(cur_ptr, (U8 *)glow, 1 ,last_face_index, MVT_U8); + *cur_ptr++ = 0; + cur_ptr += packTEField(cur_ptr, (U8 *)material_data, 16, last_face_index, MVT_LLUUID); } mesgsys->addBinaryDataFast(_PREHASH_TextureEntry, packed_buffer, (S32)(cur_ptr - packed_buffer)); @@ -1170,6 +1182,7 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const U8 bump[MAX_TES]; U8 media_flags[MAX_TES]; U8 glow[MAX_TES]; + U8 material_data[MAX_TES*16]; const U32 MAX_TE_BUFFER = 4096; U8 packed_buffer[MAX_TE_BUFFER]; @@ -1207,6 +1220,9 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const bump[face_index] = te->getBumpShinyFullbright(); media_flags[face_index] = te->getMediaTexGen(); glow[face_index] = (U8) llround((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF)); + + // Directly sending material_ids is not safe! + memcpy(&material_data[face_index*16],getTE(face_index)->getMaterialID().get(),16); /* Flawfinder: ignore */ } cur_ptr += packTEField(cur_ptr, (U8 *)image_ids, sizeof(LLUUID),last_face_index, MVT_LLUUID); @@ -1228,6 +1244,8 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const cur_ptr += packTEField(cur_ptr, (U8 *)media_flags, 1 ,last_face_index, MVT_U8); *cur_ptr++ = 0; cur_ptr += packTEField(cur_ptr, (U8 *)glow, 1 ,last_face_index, MVT_U8); + *cur_ptr++ = 0; + cur_ptr += packTEField(cur_ptr, (U8 *)material_data, 16, last_face_index, MVT_LLUUID); } dp.packBinaryData(packed_buffer, (S32)(cur_ptr - packed_buffer), "TextureEntry"); @@ -1246,6 +1264,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam const U32 MAX_TES = 32; // Avoid construction of 32 UUIDs per call. JC + static LLMaterialID material_ids[MAX_TES]; U8 image_data[MAX_TES*16]; U8 colors[MAX_TES*4]; @@ -1257,6 +1276,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam U8 bump[MAX_TES]; U8 media_flags[MAX_TES]; U8 glow[MAX_TES]; + U8 material_data[MAX_TES*16]; const U32 MAX_TE_BUFFER = 4096; U8 packed_buffer[MAX_TE_BUFFER]; @@ -1309,6 +1329,13 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8); cur_ptr++; cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)glow, 1, face_count, MVT_U8); + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_data, 16, face_count, MVT_LLUUID); + + for (U32 i = 0; i < face_count; i++) + { + material_ids[i].set(&material_data[i * 16]); + } LLColor4 color; LLColor4U coloru; @@ -1321,6 +1348,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam retval |= setTEBumpShinyFullbright(i, bump[i]); retval |= setTEMediaTexGen(i, media_flags[i]); retval |= setTEGlow(i, (F32)glow[i] / (F32)0xFF); + retval |= setTEMaterialID(i, material_ids[i]); coloru = LLColor4U(colors + 4*i); // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) @@ -1346,6 +1374,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) // Avoid construction of 32 UUIDs per call static LLUUID image_ids[MAX_TES]; + static LLMaterialID material_ids[MAX_TES]; U8 image_data[MAX_TES*16]; U8 colors[MAX_TES*4]; @@ -1357,7 +1386,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) U8 bump[MAX_TES]; U8 media_flags[MAX_TES]; U8 glow[MAX_TES]; - unsigned char material_id[MAX_TES*16]; + U8 material_data[MAX_TES*16]; const U32 MAX_TE_BUFFER = 4096; U8 packed_buffer[MAX_TE_BUFFER]; @@ -1401,30 +1430,12 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) cur_ptr++; cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)glow, 1, face_count, MVT_U8); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_id, 16, face_count, MVT_LLUUID); - -#if 0 - for (U32 curFace = 0U; curFace < face_count; ++curFace) - { - std::string materialID(reinterpret_cast(&material_id[curFace * 16]), 16); - std::string materialIDString; - for (unsigned int i = 0U; i < 4U; ++i) - { - if (i != 0U) - { - materialIDString += "-"; - } - const U32 *value = reinterpret_cast(&materialID.c_str()[i * 4]); - materialIDString += llformat("%08x", *value); - } - - llinfos << "STINSON DEBUG: found material ID for face #" << curFace << " => " << materialIDString << llendl; - } -#endif + cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_data, 16, face_count, MVT_LLUUID); for (i = 0; i < face_count; i++) { memcpy(image_ids[i].mData,&image_data[i*16],16); /* Flawfinder: ignore */ + material_ids[i].set(&material_data[i * 16]); } LLColor4 color; @@ -1438,6 +1449,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) retval |= setTEBumpShinyFullbright(i, bump[i]); retval |= setTEMediaTexGen(i, media_flags[i]); retval |= setTEGlow(i, (F32)glow[i] / (F32)0xFF); + retval |= setTEMaterialID(i, material_ids[i]); coloru = LLColor4U(colors + 4*i); // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 8dcaa8c740..e1635740ef 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -42,6 +42,7 @@ class LLMessageSystem; class LLVolumeParams; class LLColor4; class LLColor3; +class LLMaterialID; class LLTextureEntry; class LLDataPacker; class LLVolumeMgr; @@ -353,6 +354,7 @@ public: virtual S32 setTEFullbright(const U8 te, const U8 fullbright); virtual S32 setTEMediaFlags(const U8 te, const U8 flags); virtual S32 setTEGlow(const U8 te, const F32 glow); + virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed void copyTEs(const LLPrimitive *primitive); diff --git a/indra/llprimitive/llprimtexturelist.cpp b/indra/llprimitive/llprimtexturelist.cpp index 36e04df7b7..20438578b3 100644 --- a/indra/llprimitive/llprimtexturelist.cpp +++ b/indra/llprimitive/llprimtexturelist.cpp @@ -27,6 +27,7 @@ #include "linden_common.h" #include "llprimtexturelist.h" +#include "llmaterialid.h" #include "lltextureentry.h" #include "llmemtype.h" @@ -359,6 +360,15 @@ S32 LLPrimTextureList::setGlow(const U8 index, const F32 glow) return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setMaterialID(const U8 index, const LLMaterialID& pMaterialID) +{ + if (index < mEntryList.size()) + { + return mEntryList[index]->setMaterialID(pMaterialID); + } + return TEM_CHANGE_NONE; +} + S32 LLPrimTextureList::size() const { return mEntryList.size(); diff --git a/indra/llprimitive/llprimtexturelist.h b/indra/llprimitive/llprimtexturelist.h index 3cfa52f1d5..691df44c18 100644 --- a/indra/llprimitive/llprimtexturelist.h +++ b/indra/llprimitive/llprimtexturelist.h @@ -34,6 +34,7 @@ class LLTextureEntry; +class LLMaterialID; // this is a list of LLTextureEntry*'s because in practice the list's elements // are of some derived class: LLFooTextureEntry @@ -102,6 +103,7 @@ public: S32 setFullbright(const U8 index, const U8 t); S32 setMediaFlags(const U8 index, const U8 media_flags); S32 setGlow(const U8 index, const F32 glow); + S32 setMaterialID(const U8 index, const LLMaterialID& pMaterialID); S32 size() const; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 34eff17519..b04fa809d2 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -29,6 +29,7 @@ #include "lluuid.h" #include "llmediaentry.h" #include "lltextureentry.h" +#include "llmaterialid.h" #include "llsdutil_math.h" #include "v4color.h" @@ -83,6 +84,8 @@ LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) mBump = rhs.mBump; mMediaFlags = rhs.mMediaFlags; mGlow = rhs.mGlow; + mMaterialID = rhs.mMaterialID; + if (rhs.mMediaEntry != NULL) { // Make a copy mMediaEntry = new LLMediaEntry(*rhs.mMediaEntry); @@ -103,6 +106,7 @@ LLTextureEntry &LLTextureEntry::operator=(const LLTextureEntry &rhs) mBump = rhs.mBump; mMediaFlags = rhs.mMediaFlags; mGlow = rhs.mGlow; + mMaterialID = rhs.mMaterialID; if (mMediaEntry != NULL) { delete mMediaEntry; } @@ -130,6 +134,7 @@ void LLTextureEntry::init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 of mBump = bump; mMediaFlags = 0x0; mGlow = 0; + mMaterialID.clear(); setColor(LLColor4(1.f, 1.f, 1.f, 1.f)); if (mMediaEntry != NULL) { @@ -159,6 +164,7 @@ bool LLTextureEntry::operator!=(const LLTextureEntry &rhs) const if (mBump != rhs.mBump) return (true); if (mMediaFlags != rhs.mMediaFlags) return (true); if (mGlow != rhs.mGlow) return (true); + if (mMaterialID != rhs.mMaterialID) return (true); return(false); } @@ -174,6 +180,7 @@ bool LLTextureEntry::operator==(const LLTextureEntry &rhs) const if (mBump != rhs.mBump) return (false); if (mMediaFlags != rhs.mMediaFlags) return false; if (mGlow != rhs.mGlow) return false; + if (mMaterialID != rhs.mMaterialID) return (false); return(true); } @@ -523,6 +530,16 @@ S32 LLTextureEntry::setGlow(F32 glow) return TEM_CHANGE_NONE; } +S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) +{ + if (mMaterialID != pMaterialID) + { + mMaterialID = pMaterialID; + return TEM_CHANGE_TEXTURE; + } + return TEM_CHANGE_NONE; +} + void LLTextureEntry::setMediaData(const LLMediaEntry &media_entry) { mMediaFlags |= MF_HAS_MEDIA; diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 437b85e03f..b681ce8ca7 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -30,6 +30,7 @@ #include "lluuid.h" #include "v4color.h" #include "llsd.h" +#include "llmaterialid.h" // These bits are used while unpacking TEM messages to tell which aspects of // the texture entry changed. @@ -121,6 +122,7 @@ public: S32 setTexGen(U8 texGen); S32 setMediaTexGen(U8 media); S32 setGlow(F32 glow); + S32 setMaterialID(const LLMaterialID& pMaterialID); virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } @@ -139,6 +141,7 @@ public: U8 getTexGen() const { return mMediaFlags & TEM_TEX_GEN_MASK; } U8 getMediaTexGen() const { return mMediaFlags; } F32 getGlow() const { return mGlow; } + const LLMaterialID& getMaterialID() const { return mMaterialID; }; // *NOTE: it is possible for hasMedia() to return true, but getMediaData() to return NULL. // CONVERSELY, it is also possible for hasMedia() to return false, but getMediaData() @@ -193,6 +196,7 @@ protected: U8 mBump; // Bump map, shiny, and fullbright U8 mMediaFlags; // replace with web page, movie, etc. F32 mGlow; + LLMaterialID mMaterialID; // Note the media data is not sent via the same message structure as the rest of the TE LLMediaEntry* mMediaEntry; // The media data for the face -- cgit v1.2.3 From 4174e9be5ea6262d7ad27ab64805990fd13670ee Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Thu, 11 Oct 2012 11:51:16 -0700 Subject: Adding an additional conversion constructor. --- indra/llprimitive/llmaterialid.cpp | 5 +++++ indra/llprimitive/llmaterialid.h | 1 + 2 files changed, 6 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 4355a8ea3f..8122b70c2d 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -47,6 +47,11 @@ LLMaterialID::LLMaterialID(const LLSD::Binary& pMaterialID) parseFromBinary(pMaterialID); } +LLMaterialID::LLMaterialID(const void* pMemory) +{ + set(pMemory); +} + LLMaterialID::LLMaterialID(const LLMaterialID& pOtherMaterialID) { copyFromOtherMaterialID(pOtherMaterialID); diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index 4551550db5..71c6e72478 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -35,6 +35,7 @@ public: LLMaterialID(); LLMaterialID(const LLSD& pMaterialID); LLMaterialID(const LLSD::Binary& pMaterialID); + LLMaterialID(const void* pMemory); LLMaterialID(const LLMaterialID& pOtherMaterialID); ~LLMaterialID(); -- cgit v1.2.3 From e2ce144129e53ca7c6f5309cab833d48cdb30b11 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Tue, 27 Nov 2012 16:56:53 -0800 Subject: First pass at re-implementing the POST functionality to query values for selected visible objects. --- indra/llprimitive/llmaterialid.cpp | 11 +++++++++++ indra/llprimitive/llmaterialid.h | 2 ++ 2 files changed, 13 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 8122b70c2d..7df23e5ee0 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -100,6 +100,17 @@ void LLMaterialID::clear() memset(mID, 0, MATERIAL_ID_SIZE * sizeof(U8)); } +LLSD LLMaterialID::asLLSD() const +{ + LLSD::Binary materialIDBinary; + + materialIDBinary.resize(MATERIAL_ID_SIZE * sizeof(U8)); + memcpy(materialIDBinary.data(), mID, MATERIAL_ID_SIZE * sizeof(U8)); + + LLSD materialID = materialIDBinary; + return materialID; +} + void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID) { llassert(pMaterialID.size() == (MATERIAL_ID_SIZE * sizeof(U8))); diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index 71c6e72478..1578172aec 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -49,6 +49,8 @@ public: void set(const void* pMemory); void clear(); + LLSD asLLSD() const; + static const LLMaterialID null; private: -- cgit v1.2.3 From 6618cff96c75bd0183b173c30ec818404038c2dd Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Thu, 29 Nov 2012 00:00:18 +0100 Subject: Encapsulate material definitions in LLMaterial and refactor LLFloaterDebugMaterials to use the new class --- indra/llprimitive/CMakeLists.txt | 2 + indra/llprimitive/llmaterial.cpp | 147 +++++++++++++++++++++++++++++++++++++++ indra/llprimitive/llmaterial.h | 94 +++++++++++++++++++++++++ 3 files changed, 243 insertions(+) create mode 100644 indra/llprimitive/llmaterial.cpp create mode 100644 indra/llprimitive/llmaterial.h (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index 82d0f892f2..4eef1673f4 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -21,6 +21,7 @@ include_directories( set(llprimitive_SOURCE_FILES llmaterialid.cpp + llmaterial.cpp llmaterialtable.cpp llmediaentry.cpp llmodel.cpp @@ -38,6 +39,7 @@ set(llprimitive_HEADER_FILES CMakeLists.txt legacy_object_types.h + llmaterial.h llmaterialid.h llmaterialtable.h llmediaentry.h diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp new file mode 100644 index 0000000000..36d958ede5 --- /dev/null +++ b/indra/llprimitive/llmaterial.cpp @@ -0,0 +1,147 @@ +/** + * @file llmaterial.cpp + * @brief Material definition + * + * $LicenseInfo:firstyear=2006&license=viewerlgpl$ + * Second Life Viewer Source Code + * 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. + * + * 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. + * + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llmaterial.h" + +/** + * Materials cap parameters + */ +#define MATERIALS_CAP_NORMAL_MAP_FIELD "NormMap" +#define MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD "NormOffsetX" +#define MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD "NormOffsetY" +#define MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD "NormRepeatX" +#define MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD "NormRepeatY" +#define MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD "NormRotation" + +#define MATERIALS_CAP_SPECULAR_MAP_FIELD "SpecMap" +#define MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD "SpecOffsetX" +#define MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD "SpecOffsetY" +#define MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD "SpecRepeatX" +#define MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD "SpecRepeatY" +#define MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD "SpecRotation" + +#define MATERIALS_CAP_SPECULAR_COLOR_FIELD "SpecColor" +#define MATERIALS_CAP_SPECULAR_EXP_FIELD "SpecExp" +#define MATERIALS_CAP_ENV_INTENSITY_FIELD "EnvIntensity" +#define MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD "AlphaMaskCutoff" +#define MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD "DiffuseAlphaMode" + +/** + * Materials constants + */ + +const LLColor4U MATERIALS_DEFAULT_SPECULAR_COLOR = LLColor4U(255, 255, 255, 255); +const U8 MATERIALS_DEFAULT_SPECULAR_EXP = 128; +const U8 MATERIALS_DEFAULT_ENV_INTENSITY = 128; +const U8 MATERIALS_DEFAULT_DIFFUSE_ALPHA_MODE = 0; +const U8 MATERIALS_DEFAULT_ALPHA_MASK_CUTOFF = 128; + +const F32 MATERIALS_MULT_OFFSETREPEAT = 10000.f; +const F32 MATERIALS_MULT_ROTATION = 1000.f; + +/** + * Helper functions + */ + +template T getMaterialField(const LLSD& data, const std::string& field, const LLSD::Type field_type) +{ + if ( (data.has(field)) && (field_type == data[field].type()) ) + { + return (T)data[field]; + } + llerrs << "Missing or mistyped field '" << field << "' in material definition" << llendl; + return (T)LLSD(); +} + +/** + * LLMaterial class + */ + +LLMaterial::LLMaterial() + : mSpecularLightColor(MATERIALS_DEFAULT_SPECULAR_COLOR) + , mSpecularLightExponent(MATERIALS_DEFAULT_SPECULAR_EXP) + , mEnvironmentIntensity(MATERIALS_DEFAULT_ENV_INTENSITY) + , mDiffuseAlphaMode(MATERIALS_DEFAULT_DIFFUSE_ALPHA_MODE) + , mAlphaMaskCutoff(MATERIALS_DEFAULT_ALPHA_MASK_CUTOFF) +{ +} + +LLMaterial::LLMaterial(const LLSD& material_data) +{ + fromLLSD(material_data); +} + +LLSD LLMaterial::asLLSD() const +{ + LLSD material_data; + + material_data[MATERIALS_CAP_NORMAL_MAP_FIELD] = mNormalID; + material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD] = llround(mNormalOffsetX * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD] = llround(mNormalOffsetY * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD] = llround(mNormalRepeatX * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD] = llround(mNormalRepeatY * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD] = llround(mNormalRotation * MATERIALS_MULT_ROTATION); + + material_data[MATERIALS_CAP_SPECULAR_MAP_FIELD] = mSpecularID; + material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD] = llround(mSpecularOffsetX * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD] = llround(mSpecularOffsetY * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD] = llround(mSpecularRepeatX * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD] = llround(mSpecularRepeatY * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD] = llround(mSpecularRotation * MATERIALS_MULT_ROTATION); + + material_data[MATERIALS_CAP_SPECULAR_COLOR_FIELD] = mSpecularLightColor.getValue(); + material_data[MATERIALS_CAP_SPECULAR_EXP_FIELD] = mSpecularLightExponent; + material_data[MATERIALS_CAP_ENV_INTENSITY_FIELD] = mEnvironmentIntensity; + material_data[MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD] = mDiffuseAlphaMode; + material_data[MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD] = mAlphaMaskCutoff; + + return material_data; +} + +void LLMaterial::fromLLSD(const LLSD& material_data) +{ + mNormalID = getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_FIELD, LLSD::TypeUUID); + mNormalOffsetX = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mNormalOffsetY = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mNormalRepeatX = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mNormalRepeatY = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mNormalRotation = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_ROTATION; + + mSpecularID = getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_FIELD, LLSD::TypeUUID); + mSpecularOffsetX = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mSpecularOffsetY = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mSpecularRepeatX = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mSpecularRepeatY = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mSpecularRotation = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_ROTATION; + + mSpecularLightColor.setValue(getMaterialField(material_data, MATERIALS_CAP_SPECULAR_COLOR_FIELD, LLSD::TypeArray)); + mSpecularLightExponent = (U8)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_EXP_FIELD, LLSD::TypeInteger); + mEnvironmentIntensity = (U8)getMaterialField(material_data, MATERIALS_CAP_ENV_INTENSITY_FIELD, LLSD::TypeInteger); + mDiffuseAlphaMode = (U8)getMaterialField(material_data, MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD, LLSD::TypeInteger); + mAlphaMaskCutoff = (U8)getMaterialField(material_data, MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD, LLSD::TypeInteger); +} diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h new file mode 100644 index 0000000000..d50ab30195 --- /dev/null +++ b/indra/llprimitive/llmaterial.h @@ -0,0 +1,94 @@ +/** + * @file llmaterial.h + * @brief Material definition + * + * $LicenseInfo:firstyear=2006&license=viewerlgpl$ + * Second Life Viewer Source Code + * 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. + * + * 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. + * + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLMATERIAL_H +#define LL_LLMATERIAL_H + +#include "llmaterialid.h" +#include "llsd.h" +#include "v4coloru.h" + +class LLMaterial +{ +public: + LLMaterial(); + LLMaterial(const LLSD& material_data); + + LLSD asLLSD() const; + void fromLLSD(const LLSD& material_data); + + const LLUUID& getNormalID() const { return mNormalID; } + void setNormalID(const LLUUID& normal_id) { mNormalID = normal_id; } + void getNormalOffset(F32& offset_x, F32& offset_y) const { offset_x = mNormalOffsetX; offset_y = mNormalOffsetY; } + void setNormalOffset(F32 offset_x, F32 offset_y) { mNormalOffsetX = offset_x; mNormalOffsetY = offset_y; } + void getNormalRepeat(F32& repeat_x, F32& repeat_y) const { repeat_x = mNormalRepeatX; repeat_y = mNormalRepeatY; } + void setNormalRepeat(F32 repeat_x, F32 repeat_y) { mNormalRepeatX = repeat_x; mNormalRepeatY = repeat_y; } + F32 getNormalRotation() const { return mNormalRotation; } + void setNormalRotation(F32 rot) { mNormalRotation = rot; } + + const LLUUID& getSpecularID() const { return mSpecularID; } + void setSpecularID(const LLUUID& specular_id) { mSpecularID = specular_id; } + void getSpecularOffset(F32& offset_x, F32& offset_y) const { offset_x = mSpecularOffsetX; offset_y = mSpecularOffsetY; } + void setSpecularOffset(F32 offset_x, F32 offset_y) { mSpecularOffsetX = offset_x; mSpecularOffsetY = offset_y; } + void getSpecularRepeat(F32& repeat_x, F32& repeat_y) const { repeat_x = mSpecularRepeatX; repeat_y = mSpecularRepeatY; } + void setSpecularRepeat(F32 repeat_x, F32 repeat_y) { mSpecularRepeatX = repeat_x; mSpecularRepeatY = repeat_y; } + F32 getSpecularRotation() const { return mSpecularRotation; } + void setSpecularRotation(F32 rot) { mSpecularRotation = rot; } + + const LLColor4U& getSpecularLightColor() const { return mSpecularLightColor; } + void setSpecularLightColor(const LLColor4U& color) { mSpecularLightColor = color; } + U8 getSpecularLightExponent() const { return mSpecularLightExponent; } + void setSpecularLightExponent(U8 exponent) { mSpecularLightExponent = exponent; } + U8 getEnvironmentIntensity() const { return mEnvironmentIntensity; } + void setEnvironmentIntensity(U8 intensity) { mEnvironmentIntensity = intensity; } + U8 getDiffuseAlphaMode() const { return mDiffuseAlphaMode; } + void setDiffuseAlphaMode(U8 alpha_mode) { mDiffuseAlphaMode = alpha_mode; } + U8 getAlphaMaskCutoff() const { return mAlphaMaskCutoff; } + void setAlphaMaskCutoff(U8 cutoff) { mAlphaMaskCutoff = cutoff; } + +protected: + LLUUID mNormalID; + F32 mNormalOffsetX; + F32 mNormalOffsetY; + F32 mNormalRepeatX; + F32 mNormalRepeatY; + F32 mNormalRotation; + + LLUUID mSpecularID; + F32 mSpecularOffsetX; + F32 mSpecularOffsetY; + F32 mSpecularRepeatX; + F32 mSpecularRepeatY; + F32 mSpecularRotation; + + LLColor4U mSpecularLightColor; + U8 mSpecularLightExponent; + U8 mEnvironmentIntensity; + U8 mDiffuseAlphaMode; + U8 mAlphaMaskCutoff; +}; + +#endif // LL_LLMATERIAL_H -- cgit v1.2.3 From 2feac960904b0b94d05253e4c345f1853ed3bbbf Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 2 Dec 2012 01:04:56 +0100 Subject: Fixed two minor issues (mDiffuseAlphaMode and mAlphaMaskCutoff were reversed; specular rotation had wrong format specifier) --- indra/llprimitive/llmaterial.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index 36d958ede5..b07b4ce72d 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -142,6 +142,6 @@ void LLMaterial::fromLLSD(const LLSD& material_data) mSpecularLightColor.setValue(getMaterialField(material_data, MATERIALS_CAP_SPECULAR_COLOR_FIELD, LLSD::TypeArray)); mSpecularLightExponent = (U8)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_EXP_FIELD, LLSD::TypeInteger); mEnvironmentIntensity = (U8)getMaterialField(material_data, MATERIALS_CAP_ENV_INTENSITY_FIELD, LLSD::TypeInteger); - mDiffuseAlphaMode = (U8)getMaterialField(material_data, MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD, LLSD::TypeInteger); - mAlphaMaskCutoff = (U8)getMaterialField(material_data, MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD, LLSD::TypeInteger); + mDiffuseAlphaMode = (U8)getMaterialField(material_data, MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD, LLSD::TypeInteger); + mAlphaMaskCutoff = (U8)getMaterialField(material_data, MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD, LLSD::TypeInteger); } -- cgit v1.2.3 From a0392ec5ec5703bd54bc4e091820d1c1423bbad4 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 2 Dec 2012 21:29:43 +0100 Subject: Refactor LLFloaterDebugMaterials::convertToPrintableMaterialID() as LLMaterialID::asString() so it can be used everywhere --- indra/llprimitive/llmaterialid.cpp | 15 +++++++++++++++ indra/llprimitive/llmaterialid.h | 1 + 2 files changed, 16 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 7df23e5ee0..73a61f9c54 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -111,6 +111,21 @@ LLSD LLMaterialID::asLLSD() const return materialID; } +std::string LLMaterialID::asString() const +{ + std::string materialIDString; + for (unsigned int i = 0U; i < 4; ++i) + { + if (i != 0U) + { + materialIDString += "-"; + } + const U32 *value = reinterpret_cast(&mID[i * 4]); + materialIDString += llformat("%08x", *value); + } + return materialIDString; +} + void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID) { llassert(pMaterialID.size() == (MATERIAL_ID_SIZE * sizeof(U8))); diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index 1578172aec..a474703f79 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -50,6 +50,7 @@ public: void clear(); LLSD asLLSD() const; + std::string asString() const; static const LLMaterialID null; -- cgit v1.2.3 From 1e26dbdcd27a1f29fe249cc7e074e5ede284bac8 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 3 Dec 2012 01:46:26 +0100 Subject: Started LLMaterialMgr to handle viewer<->region materials communication * refactored LLFloaterDebugMaterials::requestPutMaterials() to use LLMaterialMgr instead * replaced "Object editing" results list with information about the active selection instead --- indra/llprimitive/llmaterial.cpp | 18 ++++++++++++++---- indra/llprimitive/llmaterial.h | 3 +++ 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index b07b4ce72d..da518b6916 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -82,6 +82,8 @@ template T getMaterialField(const LLSD& data, const std::string& fie * LLMaterial class */ +const LLMaterial LLMaterial::null; + LLMaterial::LLMaterial() : mSpecularLightColor(MATERIALS_DEFAULT_SPECULAR_COLOR) , mSpecularLightExponent(MATERIALS_DEFAULT_SPECULAR_EXP) @@ -117,8 +119,8 @@ LLSD LLMaterial::asLLSD() const material_data[MATERIALS_CAP_SPECULAR_COLOR_FIELD] = mSpecularLightColor.getValue(); material_data[MATERIALS_CAP_SPECULAR_EXP_FIELD] = mSpecularLightExponent; material_data[MATERIALS_CAP_ENV_INTENSITY_FIELD] = mEnvironmentIntensity; - material_data[MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD] = mDiffuseAlphaMode; - material_data[MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD] = mAlphaMaskCutoff; + material_data[MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD] = mDiffuseAlphaMode; + material_data[MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD] = mAlphaMaskCutoff; return material_data; } @@ -142,6 +144,14 @@ void LLMaterial::fromLLSD(const LLSD& material_data) mSpecularLightColor.setValue(getMaterialField(material_data, MATERIALS_CAP_SPECULAR_COLOR_FIELD, LLSD::TypeArray)); mSpecularLightExponent = (U8)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_EXP_FIELD, LLSD::TypeInteger); mEnvironmentIntensity = (U8)getMaterialField(material_data, MATERIALS_CAP_ENV_INTENSITY_FIELD, LLSD::TypeInteger); - mDiffuseAlphaMode = (U8)getMaterialField(material_data, MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD, LLSD::TypeInteger); - mAlphaMaskCutoff = (U8)getMaterialField(material_data, MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD, LLSD::TypeInteger); + mDiffuseAlphaMode = (U8)getMaterialField(material_data, MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD, LLSD::TypeInteger); + mAlphaMaskCutoff = (U8)getMaterialField(material_data, MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD, LLSD::TypeInteger); +} + +bool LLMaterial::isNull() const +{ + // *TODO: find a better way of defining a 'null' material? + return + (mNormalID.isNull()) && (.0f == mNormalOffsetX) && (.0f == mNormalOffsetY) && (.0f == mNormalRepeatX) && (.0f == mNormalRepeatY) && + (mSpecularID.isNull()) && (.0f == mSpecularOffsetX) && (.0f == mSpecularOffsetY) && (.0f == mSpecularRepeatX) && (.0f == mSpecularRepeatY); } diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index d50ab30195..42e3dd04b9 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -69,6 +69,9 @@ public: U8 getAlphaMaskCutoff() const { return mAlphaMaskCutoff; } void setAlphaMaskCutoff(U8 cutoff) { mAlphaMaskCutoff = cutoff; } + bool isNull() const; + static const LLMaterial null; + protected: LLUUID mNormalID; F32 mNormalOffsetX; -- cgit v1.2.3 From 25bffc3d43ec7696c0a9fab43514affbfe006fb9 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 3 Dec 2012 15:20:11 +0100 Subject: Added LLMaterialMgr::get() to retrieve individual materials (with optional callback) --- indra/llprimitive/llmaterial.h | 4 ++++ indra/llprimitive/llmaterialid.cpp | 5 +++++ indra/llprimitive/llmaterialid.h | 1 + 3 files changed, 10 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index 42e3dd04b9..da364e548c 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -27,6 +27,8 @@ #ifndef LL_LLMATERIAL_H #define LL_LLMATERIAL_H +#include + #include "llmaterialid.h" #include "llsd.h" #include "v4coloru.h" @@ -94,4 +96,6 @@ protected: U8 mAlphaMaskCutoff; }; +typedef boost::shared_ptr LLMaterialPtr; + #endif // LL_LLMATERIAL_H diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 73a61f9c54..bbbbf0ced3 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -77,6 +77,11 @@ LLMaterialID& LLMaterialID::operator = (const LLMaterialID& pOtherMaterialID) return (*this); } +bool LLMaterialID::operator < (const LLMaterialID& pOtherMaterialID) const +{ + return (compareToOtherMaterialID(pOtherMaterialID) < 0); +} + bool LLMaterialID::isNull() const { return (compareToOtherMaterialID(LLMaterialID::null) == 0); diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index a474703f79..ffefc9f11c 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -42,6 +42,7 @@ public: bool operator == (const LLMaterialID& pOtherMaterialID) const; bool operator != (const LLMaterialID& pOtherMaterialID) const; LLMaterialID& operator = (const LLMaterialID& pOtherMaterialID); + bool operator < (const LLMaterialID& pOtherMaterialID) const; bool isNull() const; -- cgit v1.2.3 From e2b5e11820cf234d035bdb07f4b145c397fdf67b Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Tue, 4 Dec 2012 15:46:10 -0800 Subject: Implementing string conversion and comparison operator overrides for the LLMaterialID class. --- indra/llprimitive/llmaterialid.cpp | 40 ++++++++++++++++++++++++++++++++++++++ indra/llprimitive/llmaterialid.h | 9 +++++++++ 2 files changed, 49 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 7df23e5ee0..5c810ddf12 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -29,6 +29,10 @@ #include "llmaterialid.h" +#include + +#include "llformat.h" + const LLMaterialID LLMaterialID::null; LLMaterialID::LLMaterialID() @@ -71,6 +75,26 @@ bool LLMaterialID::operator != (const LLMaterialID& pOtherMaterialID) const return (compareToOtherMaterialID(pOtherMaterialID) != 0); } +bool LLMaterialID::operator < (const LLMaterialID& pOtherMaterialID) const +{ + return (compareToOtherMaterialID(pOtherMaterialID) < 0); +} + +bool LLMaterialID::operator <= (const LLMaterialID& pOtherMaterialID) const +{ + return (compareToOtherMaterialID(pOtherMaterialID) <= 0); +} + +bool LLMaterialID::operator > (const LLMaterialID& pOtherMaterialID) const +{ + return (compareToOtherMaterialID(pOtherMaterialID) > 0); +} + +bool LLMaterialID::operator >= (const LLMaterialID& pOtherMaterialID) const +{ + return (compareToOtherMaterialID(pOtherMaterialID) >= 0); +} + LLMaterialID& LLMaterialID::operator = (const LLMaterialID& pOtherMaterialID) { copyFromOtherMaterialID(pOtherMaterialID); @@ -111,6 +135,22 @@ LLSD LLMaterialID::asLLSD() const return materialID; } +std::string LLMaterialID::asString() const +{ + std::string materialID(reinterpret_cast(get()), MATERIAL_ID_SIZE); + std::string materialIDString; + for (unsigned int i = 0U; i < static_cast(MATERIAL_ID_SIZE / sizeof(U32)); ++i) + { + if (i != 0U) + { + materialIDString += "-"; + } + const U32 *value = reinterpret_cast(&materialID.c_str()[i * sizeof(U32)]); + materialIDString += llformat("%08x", *value); + } + return materialIDString; +} + void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID) { llassert(pMaterialID.size() == (MATERIAL_ID_SIZE * sizeof(U8))); diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index 1578172aec..9db4065302 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -29,6 +29,8 @@ #define MATERIAL_ID_SIZE 16 +#include + class LLMaterialID { public: @@ -41,6 +43,12 @@ public: bool operator == (const LLMaterialID& pOtherMaterialID) const; bool operator != (const LLMaterialID& pOtherMaterialID) const; + + bool operator < (const LLMaterialID& pOtherMaterialID) const; + bool operator <= (const LLMaterialID& pOtherMaterialID) const; + bool operator > (const LLMaterialID& pOtherMaterialID) const; + bool operator >= (const LLMaterialID& pOtherMaterialID) const; + LLMaterialID& operator = (const LLMaterialID& pOtherMaterialID); bool isNull() const; @@ -50,6 +58,7 @@ public: void clear(); LLSD asLLSD() const; + std::string asString() const; static const LLMaterialID null; -- cgit v1.2.3 From a5b6142f6b53608769cfb3c33dbbbf3710b86d1b Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Tue, 4 Dec 2012 16:51:03 -0800 Subject: Updating the comparison function to not use ascii-character comparison. This will give better sorting when the operator overriden comparators are used. --- indra/llprimitive/llmaterialid.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 5c810ddf12..590f5cd91f 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -137,7 +137,6 @@ LLSD LLMaterialID::asLLSD() const std::string LLMaterialID::asString() const { - std::string materialID(reinterpret_cast(get()), MATERIAL_ID_SIZE); std::string materialIDString; for (unsigned int i = 0U; i < static_cast(MATERIAL_ID_SIZE / sizeof(U32)); ++i) { @@ -145,7 +144,7 @@ std::string LLMaterialID::asString() const { materialIDString += "-"; } - const U32 *value = reinterpret_cast(&materialID.c_str()[i * sizeof(U32)]); + const U32 *value = reinterpret_cast(&get()[i * sizeof(U32)]); materialIDString += llformat("%08x", *value); } return materialIDString; @@ -159,10 +158,19 @@ void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID) void LLMaterialID::copyFromOtherMaterialID(const LLMaterialID& pOtherMaterialID) { - memcpy(mID, pOtherMaterialID.mID, MATERIAL_ID_SIZE * sizeof(U8)); + memcpy(mID, pOtherMaterialID.get(), MATERIAL_ID_SIZE * sizeof(U8)); } int LLMaterialID::compareToOtherMaterialID(const LLMaterialID& pOtherMaterialID) const { - return memcmp(mID, pOtherMaterialID.mID, MATERIAL_ID_SIZE * sizeof(U8)); + int retVal = 0; + + for (unsigned int i = 0U; (retVal == 0) && (i < static_cast(MATERIAL_ID_SIZE / sizeof(U32))); ++i) + { + const U32 *thisValue = reinterpret_cast(&get()[i * sizeof(U32)]); + const U32 *otherValue = reinterpret_cast(&pOtherMaterialID.get()[i * sizeof(U32)]); + retVal = ((*thisValue < *otherValue) ? -1 : ((*thisValue > *otherValue) ? 1 : 0)); + } + + return retVal; } -- cgit v1.2.3 From a17f3e41ff960b7b486c5dd94860d484b4ceb177 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Fri, 7 Dec 2012 17:04:21 +0100 Subject: Use a single multiplier value for all material fields --- indra/llprimitive/llmaterial.cpp | 44 +++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 23 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index da518b6916..982136128e 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -60,9 +60,7 @@ const U8 MATERIALS_DEFAULT_SPECULAR_EXP = 128; const U8 MATERIALS_DEFAULT_ENV_INTENSITY = 128; const U8 MATERIALS_DEFAULT_DIFFUSE_ALPHA_MODE = 0; const U8 MATERIALS_DEFAULT_ALPHA_MASK_CUTOFF = 128; - -const F32 MATERIALS_MULT_OFFSETREPEAT = 10000.f; -const F32 MATERIALS_MULT_ROTATION = 1000.f; +const F32 MATERIALS_MULTIPLIER = 10000.f; /** * Helper functions @@ -103,18 +101,18 @@ LLSD LLMaterial::asLLSD() const LLSD material_data; material_data[MATERIALS_CAP_NORMAL_MAP_FIELD] = mNormalID; - material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD] = llround(mNormalOffsetX * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD] = llround(mNormalOffsetY * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD] = llround(mNormalRepeatX * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD] = llround(mNormalRepeatY * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD] = llround(mNormalRotation * MATERIALS_MULT_ROTATION); + material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD] = llround(mNormalOffsetX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD] = llround(mNormalOffsetY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD] = llround(mNormalRepeatX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD] = llround(mNormalRepeatY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD] = llround(mNormalRotation * MATERIALS_MULTIPLIER); material_data[MATERIALS_CAP_SPECULAR_MAP_FIELD] = mSpecularID; - material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD] = llround(mSpecularOffsetX * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD] = llround(mSpecularOffsetY * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD] = llround(mSpecularRepeatX * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD] = llround(mSpecularRepeatY * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD] = llround(mSpecularRotation * MATERIALS_MULT_ROTATION); + material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD] = llround(mSpecularOffsetX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD] = llround(mSpecularOffsetY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD] = llround(mSpecularRepeatX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD] = llround(mSpecularRepeatY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD] = llround(mSpecularRotation * MATERIALS_MULTIPLIER); material_data[MATERIALS_CAP_SPECULAR_COLOR_FIELD] = mSpecularLightColor.getValue(); material_data[MATERIALS_CAP_SPECULAR_EXP_FIELD] = mSpecularLightExponent; @@ -128,18 +126,18 @@ LLSD LLMaterial::asLLSD() const void LLMaterial::fromLLSD(const LLSD& material_data) { mNormalID = getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_FIELD, LLSD::TypeUUID); - mNormalOffsetX = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mNormalOffsetY = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mNormalRepeatX = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mNormalRepeatY = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mNormalRotation = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_ROTATION; + mNormalOffsetX = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mNormalOffsetY = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mNormalRepeatX = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mNormalRepeatY = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mNormalRotation = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; mSpecularID = getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_FIELD, LLSD::TypeUUID); - mSpecularOffsetX = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mSpecularOffsetY = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mSpecularRepeatX = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mSpecularRepeatY = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mSpecularRotation = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_ROTATION; + mSpecularOffsetX = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mSpecularOffsetY = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mSpecularRepeatX = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mSpecularRepeatY = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mSpecularRotation = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; mSpecularLightColor.setValue(getMaterialField(material_data, MATERIALS_CAP_SPECULAR_COLOR_FIELD, LLSD::TypeArray)); mSpecularLightExponent = (U8)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_EXP_FIELD, LLSD::TypeInteger); -- cgit v1.2.3 From ca790f7320c9fc6c43e8c6022c9e511a85fd1c9d Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Tue, 18 Dec 2012 21:52:41 +0100 Subject: Bypass GCC template stumble by specializing getMaterialField for LLUUID --- indra/llprimitive/llmaterial.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index 982136128e..645fcf7b46 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -76,6 +76,17 @@ template T getMaterialField(const LLSD& data, const std::string& fie return (T)LLSD(); } +// GCC didn't like the generic form above for some reason +template<> LLUUID getMaterialField(const LLSD& data, const std::string& field, const LLSD::Type field_type) +{ + if ( (data.has(field)) && (field_type == data[field].type()) ) + { + return data[field].asUUID(); + } + llerrs << "Missing or mistyped field '" << field << "' in material definition" << llendl; + return LLUUID::null; +} + /** * LLMaterial class */ -- cgit v1.2.3 From eda11a25a465dd87b187f63da661f2ce02925deb Mon Sep 17 00:00:00 2001 From: Geenz Date: Fri, 11 Jan 2013 06:37:21 -0500 Subject: Initial (largely complete) gamma correct rendering implementation. --- indra/llprimitive/lltextureentry.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index b681ce8ca7..ff1cc65bba 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -31,6 +31,7 @@ #include "v4color.h" #include "llsd.h" #include "llmaterialid.h" +#include "llmaterial.h" // These bits are used while unpacking TEM messages to tell which aspects of // the texture entry changed. @@ -197,6 +198,7 @@ protected: U8 mMediaFlags; // replace with web page, movie, etc. F32 mGlow; LLMaterialID mMaterialID; + LLMaterialPtr mMaterial; // Note the media data is not sent via the same message structure as the rest of the TE LLMediaEntry* mMediaEntry; // The media data for the face -- cgit v1.2.3 From 5f03e197f4cfb43de93dc42b16b54beafccd376a Mon Sep 17 00:00:00 2001 From: Geenz Date: Fri, 25 Jan 2013 17:54:38 -0500 Subject: Trying to set materials up for rendering! Yay! --- indra/llprimitive/llmaterial.h | 2 +- indra/llprimitive/llprimitive.cpp | 6 +++++- indra/llprimitive/llprimitive.h | 1 + indra/llprimitive/llprimtexturelist.cpp | 9 +++++++++ indra/llprimitive/llprimtexturelist.h | 2 ++ indra/llprimitive/lltextureentry.cpp | 10 ++++++++++ indra/llprimitive/lltextureentry.h | 2 ++ 7 files changed, 30 insertions(+), 2 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index da364e548c..6f94cfda17 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -60,7 +60,7 @@ public: F32 getSpecularRotation() const { return mSpecularRotation; } void setSpecularRotation(F32 rot) { mSpecularRotation = rot; } - const LLColor4U& getSpecularLightColor() const { return mSpecularLightColor; } + const LLColor4U getSpecularLightColor() const { return mSpecularLightColor; } void setSpecularLightColor(const LLColor4U& color) { mSpecularLightColor = color; } U8 getSpecularLightExponent() const { return mSpecularLightExponent; } void setSpecularLightExponent(U8 exponent) { mSpecularLightExponent = exponent; } diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 86aa371368..94df529b25 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -271,7 +271,6 @@ S32 LLPrimitive::setTEScale(const U8 index, const F32 s, const F32 t) return mTextureList.setScale(index, s, t); } - // BUG: slow - done this way because texture entries have some // voodoo related to texture coords S32 LLPrimitive::setTEScaleS(const U8 index, const F32 s) @@ -372,6 +371,10 @@ S32 LLPrimitive::setTEMaterialID(const U8 index, const LLMaterialID& pMaterialID return mTextureList.setMaterialID(index, pMaterialID); } +S32 LLPrimitive::setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams) +{ + return mTextureList.setMaterialParams(index, pMaterialParams); +} LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { @@ -1349,6 +1352,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam retval |= setTEMediaTexGen(i, media_flags[i]); retval |= setTEGlow(i, (F32)glow[i] / (F32)0xFF); retval |= setTEMaterialID(i, material_ids[i]); + coloru = LLColor4U(colors + 4*i); // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index e1635740ef..6a9c5e9639 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -355,6 +355,7 @@ public: virtual S32 setTEMediaFlags(const U8 te, const U8 flags); virtual S32 setTEGlow(const U8 te, const F32 glow); virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); + virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed void copyTEs(const LLPrimitive *primitive); diff --git a/indra/llprimitive/llprimtexturelist.cpp b/indra/llprimitive/llprimtexturelist.cpp index 20438578b3..c0923315cb 100644 --- a/indra/llprimitive/llprimtexturelist.cpp +++ b/indra/llprimitive/llprimtexturelist.cpp @@ -369,6 +369,15 @@ S32 LLPrimTextureList::setMaterialID(const U8 index, const LLMaterialID& pMateri return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams) +{ + if (index < mEntryList.size()) + { + return mEntryList[index]->setMaterialParams(pMaterialParams); + } + return TEM_CHANGE_NONE; +} + S32 LLPrimTextureList::size() const { return mEntryList.size(); diff --git a/indra/llprimitive/llprimtexturelist.h b/indra/llprimitive/llprimtexturelist.h index 691df44c18..d7fabbbb79 100644 --- a/indra/llprimitive/llprimtexturelist.h +++ b/indra/llprimitive/llprimtexturelist.h @@ -31,6 +31,7 @@ #include "lluuid.h" #include "v3color.h" #include "v4color.h" +#include "llmaterial.h" class LLTextureEntry; @@ -104,6 +105,7 @@ public: S32 setMediaFlags(const U8 index, const U8 media_flags); S32 setGlow(const U8 index, const F32 glow); S32 setMaterialID(const U8 index, const LLMaterialID& pMaterialID); + S32 setMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); S32 size() const; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index b04fa809d2..23b15b697c 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -540,6 +540,16 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) return TEM_CHANGE_NONE; } +S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) +{ + if (mMaterial != pMaterialParams) + { + mMaterial = pMaterialParams; + return TEM_CHANGE_TEXTURE; + } + return TEM_CHANGE_NONE; +} + void LLTextureEntry::setMediaData(const LLMediaEntry &media_entry) { mMediaFlags |= MF_HAS_MEDIA; diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index ff1cc65bba..c443ebcb30 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -124,6 +124,7 @@ public: S32 setMediaTexGen(U8 media); S32 setGlow(F32 glow); S32 setMaterialID(const LLMaterialID& pMaterialID); + S32 setMaterialParams(const LLMaterialPtr pMaterialParams); virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } @@ -143,6 +144,7 @@ public: U8 getMediaTexGen() const { return mMediaFlags; } F32 getGlow() const { return mGlow; } const LLMaterialID& getMaterialID() const { return mMaterialID; }; + const LLMaterialPtr getMaterialParams() const { return mMaterial; }; // *NOTE: it is possible for hasMedia() to return true, but getMediaData() to return NULL. // CONVERSELY, it is also possible for hasMedia() to return false, but getMediaData() -- cgit v1.2.3 From 90bf22ef24fbb8ff3497dd271abc7f7555a4f758 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 1 Feb 2013 10:20:44 -0500 Subject: add debug logging, ostream support for material ids, and some minor cleanup --- indra/llprimitive/llmaterialid.cpp | 7 +++++++ indra/llprimitive/llmaterialid.h | 2 ++ 2 files changed, 9 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 590f5cd91f..820f62c43c 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -150,6 +150,13 @@ std::string LLMaterialID::asString() const return materialIDString; } +std::ostream& operator<<(std::ostream& s, const LLMaterialID &material_id) +{ + s << material_id.asString(); + return s; +} + + void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID) { llassert(pMaterialID.size() == (MATERIAL_ID_SIZE * sizeof(U8))); diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index 9db4065302..0a95204085 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -60,6 +60,8 @@ public: LLSD asLLSD() const; std::string asString() const; + friend std::ostream& operator<<(std::ostream& s, const LLMaterialID &material_id); + static const LLMaterialID null; private: -- cgit v1.2.3 From a6e8e60f5051ae27cb771e0404f1d5579ab85ebb Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Tue, 19 Feb 2013 21:21:41 +0100 Subject: Don't overrun the message buffer extracting materials ids when the region isn't sending them --- indra/llprimitive/llprimitive.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index d28cd89a1b..1a177f1c14 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1075,6 +1075,7 @@ S32 LLPrimitive::unpackTEField(U8 *cur_ptr, U8 *buffer_end, U8 *data_ptr, U8 dat } cur_ptr += data_size; } + llassert(cur_ptr <= buffer_end); return (S32)(cur_ptr - start_loc); } @@ -1328,8 +1329,15 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8); cur_ptr++; cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)glow, 1, face_count, MVT_U8); - cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_data, 16, face_count, MVT_LLUUID); + if (cur_ptr < packed_buffer + size) + { + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_data, 16, face_count, MVT_LLUUID); + } + else + { + memset(material_data, 0, sizeof(material_data)); + } for (U32 i = 0; i < face_count; i++) { @@ -1429,8 +1437,15 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8); cur_ptr++; cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)glow, 1, face_count, MVT_U8); - cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_data, 16, face_count, MVT_LLUUID); + if (cur_ptr < packed_buffer + size) + { + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_data, 16, face_count, MVT_LLUUID); + } + else + { + memset(material_data, 0, sizeof(material_data)); + } for (i = 0; i < face_count; i++) { -- cgit v1.2.3 From 5711bda96abdb9da57ddc5d5fe9c26e72dc09b28 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Wed, 20 Feb 2013 12:03:29 -0500 Subject: clean up some debug logging, add comment on llassert --- indra/llprimitive/llprimitive.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 1a177f1c14..0578f0b192 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1052,7 +1052,7 @@ S32 LLPrimitive::unpackTEField(U8 *cur_ptr, U8 *buffer_end, U8 *data_ptr, U8 dat while ((cur_ptr < buffer_end) && (*cur_ptr != 0)) { -// llinfos << "TE exception" << llendl; + LL_DEBUGS("TEFieldDecode") << "TE exception" << LL_ENDL; i = 0; while (*cur_ptr & 0x80) { @@ -1067,15 +1067,16 @@ S32 LLPrimitive::unpackTEField(U8 *cur_ptr, U8 *buffer_end, U8 *data_ptr, U8 dat if (i & 0x01) { htonmemcpy(data_ptr+(j*data_size),cur_ptr,type,data_size); -// char foo[64]; -// sprintf(foo,"%x %x",*(data_ptr+(j*data_size)), *(data_ptr+(j*data_size)+1)); -// llinfos << "Assigning " << foo << " to face " << j << llendl; + LL_DEBUGS("TEFieldDecode") << "Assigning " ; + char foo[64]; + sprintf(foo,"%x %x",*(data_ptr+(j*data_size)), *(data_ptr+(j*data_size)+1)); + LL_CONT << foo << " to face " << j << LL_ENDL; } i = i >> 1; } cur_ptr += data_size; } - llassert(cur_ptr <= buffer_end); + llassert(cur_ptr <= buffer_end); // buffer underrun return (S32)(cur_ptr - start_loc); } -- cgit v1.2.3 From fbf8e51c6059791b12f60602b4dda0d72dc2d847 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 25 Feb 2013 00:16:14 +0100 Subject: Added LLMaterialMgr::remove() to remove material information from a face --- indra/llprimitive/llmaterial.cpp | 43 ++++++++++++++++++++++++++++------------ indra/llprimitive/llmaterial.h | 3 +++ 2 files changed, 33 insertions(+), 13 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index 645fcf7b46..f6fd8e557a 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -55,11 +55,6 @@ * Materials constants */ -const LLColor4U MATERIALS_DEFAULT_SPECULAR_COLOR = LLColor4U(255, 255, 255, 255); -const U8 MATERIALS_DEFAULT_SPECULAR_EXP = 128; -const U8 MATERIALS_DEFAULT_ENV_INTENSITY = 128; -const U8 MATERIALS_DEFAULT_DIFFUSE_ALPHA_MODE = 0; -const U8 MATERIALS_DEFAULT_ALPHA_MASK_CUTOFF = 128; const F32 MATERIALS_MULTIPLIER = 10000.f; /** @@ -94,11 +89,20 @@ template<> LLUUID getMaterialField(const LLSD& data, const std::string& field, c const LLMaterial LLMaterial::null; LLMaterial::LLMaterial() - : mSpecularLightColor(MATERIALS_DEFAULT_SPECULAR_COLOR) - , mSpecularLightExponent(MATERIALS_DEFAULT_SPECULAR_EXP) - , mEnvironmentIntensity(MATERIALS_DEFAULT_ENV_INTENSITY) - , mDiffuseAlphaMode(MATERIALS_DEFAULT_DIFFUSE_ALPHA_MODE) - , mAlphaMaskCutoff(MATERIALS_DEFAULT_ALPHA_MASK_CUTOFF) + : mNormalOffsetX(.0f) + , mNormalOffsetY(.0f) + , mNormalRepeatX(.0f) + , mNormalRepeatY(.0f) + , mNormalRotation(.0f) + , mSpecularOffsetX(.0f) + , mSpecularOffsetY(.0f) + , mSpecularRepeatX(.0f) + , mSpecularRepeatY(.0f) + , mSpecularRotation(.0f) + , mSpecularLightExponent(0) + , mEnvironmentIntensity(0) + , mDiffuseAlphaMode(0) + , mAlphaMaskCutoff(0) { } @@ -159,8 +163,21 @@ void LLMaterial::fromLLSD(const LLSD& material_data) bool LLMaterial::isNull() const { - // *TODO: find a better way of defining a 'null' material? + return (*this == null); +} + +bool LLMaterial::operator == (const LLMaterial& rhs) const +{ return - (mNormalID.isNull()) && (.0f == mNormalOffsetX) && (.0f == mNormalOffsetY) && (.0f == mNormalRepeatX) && (.0f == mNormalRepeatY) && - (mSpecularID.isNull()) && (.0f == mSpecularOffsetX) && (.0f == mSpecularOffsetY) && (.0f == mSpecularRepeatX) && (.0f == mSpecularRepeatY); + (mNormalID == rhs.mNormalID) && (mNormalOffsetX == rhs.mNormalOffsetX) && (mNormalOffsetY == rhs.mNormalOffsetY) && + (mNormalRepeatX == rhs.mNormalRepeatX) && (mNormalRepeatY == rhs.mNormalRepeatY) && (mNormalRotation == rhs.mNormalRotation) && + (mSpecularID == rhs.mSpecularID) && (mSpecularOffsetX == rhs.mSpecularOffsetX) && (mSpecularOffsetY == rhs.mSpecularOffsetY) && + (mSpecularRepeatX == rhs.mSpecularRepeatX) && (mSpecularRepeatY == rhs.mSpecularRepeatY) && (mSpecularRotation == rhs.mSpecularRotation) && + (mSpecularLightColor == rhs.mSpecularLightColor) && (mSpecularLightExponent == rhs.mSpecularLightExponent) && + (mEnvironmentIntensity == rhs.mEnvironmentIntensity) && (mDiffuseAlphaMode == rhs.mDiffuseAlphaMode) && (mAlphaMaskCutoff == rhs.mAlphaMaskCutoff); +} + +bool LLMaterial::operator != (const LLMaterial& rhs) const +{ + return !(*this == rhs); } diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index 6f94cfda17..5b56d11cd2 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -74,6 +74,9 @@ public: bool isNull() const; static const LLMaterial null; + bool operator == (const LLMaterial& rhs) const; + bool operator != (const LLMaterial& rhs) const; + protected: LLUUID mNormalID; F32 mNormalOffsetX; -- cgit v1.2.3 From 6300f4f768de13823a754831797cb34022f87b60 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 27 Mar 2013 21:59:14 -0500 Subject: NORSPEC-61 Hook up material parameters to shaders. --- indra/llprimitive/llmaterial.cpp | 33 +++++++++++++++++++++++++++++++++ indra/llprimitive/llmaterial.h | 16 ++++++++++++++++ 2 files changed, 49 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index f6fd8e557a..7d1ce4ab86 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -181,3 +181,36 @@ bool LLMaterial::operator != (const LLMaterial& rhs) const { return !(*this == rhs); } + + +U32 LLMaterial::getShaderMask() +{ //NEVER incorporate this value into the message system -- this function will vary depending on viewer implementation + U32 ret = 0; + + //two least significant bits are "diffuse alpha mode" + ret = getDiffuseAlphaMode(); + + llassert(ret < SHADER_COUNT); + + //next bit is whether or not specular map is present + const U32 SPEC_BIT = 0x4; + + if (getSpecularID().notNull()) + { + ret |= SPEC_BIT; + } + + llassert(ret < SHADER_COUNT); + + //next bit is whether or not normal map is present + const U32 NORM_BIT = 0x8; + if (getNormalID().notNull()) + { + ret |= NORM_BIT; + } + + llassert(ret < SHADER_COUNT); + + return ret; +} + diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index 5b56d11cd2..fd35045e45 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -36,6 +36,20 @@ class LLMaterial { public: + + typedef enum + { + DIFFUSE_ALPHA_MODE_NONE = 0, + DIFFUSE_ALPHA_MODE_BLEND = 1, + DIFFUSE_ALPHA_MODE_MASK = 2, + DIFFUSE_ALPHA_MODE_EMISSIVE = 3 + } eDiffuseAlphaMode; + + typedef enum + { + SHADER_COUNT = 16 + } eShaderCount; + LLMaterial(); LLMaterial(const LLSD& material_data); @@ -77,6 +91,8 @@ public: bool operator == (const LLMaterial& rhs) const; bool operator != (const LLMaterial& rhs) const; + U32 getShaderMask(); + protected: LLUUID mNormalID; F32 mNormalOffsetX; -- cgit v1.2.3 From bf6182daa8b4d7cea79310547f71d7a3155e17b0 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 29 Mar 2013 07:50:08 -0700 Subject: Update Mac and Windows breakpad builds to latest --- indra/llprimitive/CMakeLists.txt | 0 indra/llprimitive/legacy_object_types.h | 0 indra/llprimitive/llmaterialtable.cpp | 0 indra/llprimitive/llmaterialtable.h | 0 indra/llprimitive/llmediaentry.cpp | 0 indra/llprimitive/llmediaentry.h | 0 indra/llprimitive/llmodel.cpp | 0 indra/llprimitive/llmodel.h | 0 indra/llprimitive/llprimitive.cpp | 0 indra/llprimitive/llprimitive.h | 0 indra/llprimitive/llprimlinkinfo.h | 0 indra/llprimitive/llprimtexturelist.cpp | 0 indra/llprimitive/llprimtexturelist.h | 0 indra/llprimitive/lltextureanim.cpp | 0 indra/llprimitive/lltextureanim.h | 0 indra/llprimitive/lltextureentry.cpp | 0 indra/llprimitive/lltextureentry.h | 0 indra/llprimitive/lltree_common.h | 0 indra/llprimitive/lltreeparams.cpp | 0 indra/llprimitive/lltreeparams.h | 0 indra/llprimitive/llvolumemessage.cpp | 0 indra/llprimitive/llvolumemessage.h | 0 indra/llprimitive/llvolumexml.cpp | 0 indra/llprimitive/llvolumexml.h | 0 indra/llprimitive/material_codes.cpp | 0 indra/llprimitive/material_codes.h | 0 indra/llprimitive/object_flags.h | 0 indra/llprimitive/tests/llmediaentry_test.cpp | 0 indra/llprimitive/tests/llmessagesystem_stub.cpp | 0 indra/llprimitive/tests/llprimitive_test.cpp | 0 30 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 indra/llprimitive/CMakeLists.txt mode change 100644 => 100755 indra/llprimitive/legacy_object_types.h mode change 100644 => 100755 indra/llprimitive/llmaterialtable.cpp mode change 100644 => 100755 indra/llprimitive/llmaterialtable.h mode change 100644 => 100755 indra/llprimitive/llmediaentry.cpp mode change 100644 => 100755 indra/llprimitive/llmediaentry.h mode change 100644 => 100755 indra/llprimitive/llmodel.cpp mode change 100644 => 100755 indra/llprimitive/llmodel.h mode change 100644 => 100755 indra/llprimitive/llprimitive.cpp mode change 100644 => 100755 indra/llprimitive/llprimitive.h mode change 100644 => 100755 indra/llprimitive/llprimlinkinfo.h mode change 100644 => 100755 indra/llprimitive/llprimtexturelist.cpp mode change 100644 => 100755 indra/llprimitive/llprimtexturelist.h mode change 100644 => 100755 indra/llprimitive/lltextureanim.cpp mode change 100644 => 100755 indra/llprimitive/lltextureanim.h mode change 100644 => 100755 indra/llprimitive/lltextureentry.cpp mode change 100644 => 100755 indra/llprimitive/lltextureentry.h mode change 100644 => 100755 indra/llprimitive/lltree_common.h mode change 100644 => 100755 indra/llprimitive/lltreeparams.cpp mode change 100644 => 100755 indra/llprimitive/lltreeparams.h mode change 100644 => 100755 indra/llprimitive/llvolumemessage.cpp mode change 100644 => 100755 indra/llprimitive/llvolumemessage.h mode change 100644 => 100755 indra/llprimitive/llvolumexml.cpp mode change 100644 => 100755 indra/llprimitive/llvolumexml.h mode change 100644 => 100755 indra/llprimitive/material_codes.cpp mode change 100644 => 100755 indra/llprimitive/material_codes.h mode change 100644 => 100755 indra/llprimitive/object_flags.h mode change 100644 => 100755 indra/llprimitive/tests/llmediaentry_test.cpp mode change 100644 => 100755 indra/llprimitive/tests/llmessagesystem_stub.cpp mode change 100644 => 100755 indra/llprimitive/tests/llprimitive_test.cpp (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/indra/llprimitive/legacy_object_types.h b/indra/llprimitive/legacy_object_types.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llmaterialtable.cpp b/indra/llprimitive/llmaterialtable.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llmaterialtable.h b/indra/llprimitive/llmaterialtable.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llmediaentry.cpp b/indra/llprimitive/llmediaentry.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llmediaentry.h b/indra/llprimitive/llmediaentry.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llprimlinkinfo.h b/indra/llprimitive/llprimlinkinfo.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llprimtexturelist.cpp b/indra/llprimitive/llprimtexturelist.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llprimtexturelist.h b/indra/llprimitive/llprimtexturelist.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/lltextureanim.cpp b/indra/llprimitive/lltextureanim.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/lltextureanim.h b/indra/llprimitive/lltextureanim.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/lltree_common.h b/indra/llprimitive/lltree_common.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/lltreeparams.cpp b/indra/llprimitive/lltreeparams.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/lltreeparams.h b/indra/llprimitive/lltreeparams.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llvolumemessage.cpp b/indra/llprimitive/llvolumemessage.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llvolumemessage.h b/indra/llprimitive/llvolumemessage.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llvolumexml.cpp b/indra/llprimitive/llvolumexml.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llvolumexml.h b/indra/llprimitive/llvolumexml.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/material_codes.cpp b/indra/llprimitive/material_codes.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/material_codes.h b/indra/llprimitive/material_codes.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/object_flags.h b/indra/llprimitive/object_flags.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/tests/llmediaentry_test.cpp b/indra/llprimitive/tests/llmediaentry_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/tests/llmessagesystem_stub.cpp b/indra/llprimitive/tests/llmessagesystem_stub.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/tests/llprimitive_test.cpp b/indra/llprimitive/tests/llprimitive_test.cpp old mode 100644 new mode 100755 -- cgit v1.2.3 From f189ba4a3d927fe0ecfb83b36b60a47c88525fdd Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 3 Apr 2013 16:56:59 -0500 Subject: NORSPEC-71 Lots more UI hookups Written with and Reviewed By Graham --- indra/llprimitive/llmaterial.h | 6 ++++-- indra/llprimitive/lltextureentry.cpp | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index fd35045e45..dc3484309c 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -32,8 +32,10 @@ #include "llmaterialid.h" #include "llsd.h" #include "v4coloru.h" +#include "llpointer.h" +#include "llrefcount.h" -class LLMaterial +class LLMaterial : public LLRefCount { public: @@ -115,6 +117,6 @@ protected: U8 mAlphaMaskCutoff; }; -typedef boost::shared_ptr LLMaterialPtr; +typedef LLPointer LLMaterialPtr; #endif // LL_LLMATERIAL_H diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 23b15b697c..691216e035 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -535,6 +535,10 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) if (mMaterialID != pMaterialID) { mMaterialID = pMaterialID; + if (mMaterialID.isNull()) + { + setMaterialParams(NULL); + } return TEM_CHANGE_TEXTURE; } return TEM_CHANGE_NONE; -- cgit v1.2.3 From 9e3155c368fba6cb877c55ad4e0c90258a6e9ba9 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Mon, 8 Apr 2013 11:40:10 -0700 Subject: NORSPEC-82 NORSPEC-85 More UI shenanigans --- indra/llprimitive/llmaterial.cpp | 6 +++++- indra/llprimitive/llmaterial.h | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index 7d1ce4ab86..1e92847b38 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -51,6 +51,8 @@ #define MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD "AlphaMaskCutoff" #define MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD "DiffuseAlphaMode" +const LLColor4U LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR = LLColor4U::white; + /** * Materials constants */ @@ -99,7 +101,8 @@ LLMaterial::LLMaterial() , mSpecularRepeatX(.0f) , mSpecularRepeatY(.0f) , mSpecularRotation(.0f) - , mSpecularLightExponent(0) + , mSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR) + , mSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT) , mEnvironmentIntensity(0) , mDiffuseAlphaMode(0) , mAlphaMaskCutoff(0) @@ -214,3 +217,4 @@ U32 LLMaterial::getShaderMask() return ret; } + diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index dc3484309c..bedfc8f8c2 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -52,6 +52,9 @@ public: SHADER_COUNT = 16 } eShaderCount; + static const U8 DEFAULT_SPECULAR_LIGHT_EXPONENT = ((U8)(0.2f * 255)); + static const LLColor4U DEFAULT_SPECULAR_LIGHT_COLOR; + LLMaterial(); LLMaterial(const LLSD& material_data); @@ -120,3 +123,4 @@ protected: typedef LLPointer LLMaterialPtr; #endif // LL_LLMATERIAL_H + -- cgit v1.2.3 From bd3716b7758ab27f929da1608260eafd4212c5d8 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Mon, 8 Apr 2013 11:40:10 -0700 Subject: NORSPEC-82 NORSPEC-85 More UI shenanigans --- indra/llprimitive/llmaterial.cpp | 6 +++++- indra/llprimitive/llmaterial.h | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index 7d1ce4ab86..1e92847b38 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -51,6 +51,8 @@ #define MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD "AlphaMaskCutoff" #define MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD "DiffuseAlphaMode" +const LLColor4U LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR = LLColor4U::white; + /** * Materials constants */ @@ -99,7 +101,8 @@ LLMaterial::LLMaterial() , mSpecularRepeatX(.0f) , mSpecularRepeatY(.0f) , mSpecularRotation(.0f) - , mSpecularLightExponent(0) + , mSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR) + , mSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT) , mEnvironmentIntensity(0) , mDiffuseAlphaMode(0) , mAlphaMaskCutoff(0) @@ -214,3 +217,4 @@ U32 LLMaterial::getShaderMask() return ret; } + diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index dc3484309c..bedfc8f8c2 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -52,6 +52,9 @@ public: SHADER_COUNT = 16 } eShaderCount; + static const U8 DEFAULT_SPECULAR_LIGHT_EXPONENT = ((U8)(0.2f * 255)); + static const LLColor4U DEFAULT_SPECULAR_LIGHT_COLOR; + LLMaterial(); LLMaterial(const LLSD& material_data); @@ -120,3 +123,4 @@ protected: typedef LLPointer LLMaterialPtr; #endif // LL_LLMATERIAL_H + -- cgit v1.2.3 From fafa21315f043ab51e3373e825c85646685778a6 Mon Sep 17 00:00:00 2001 From: g Date: Fri, 12 Apr 2013 15:21:35 -0700 Subject: Fix issue with alphaNonIndexedNoColorF shader and static init fail on default spec color (real source of NORSPEC-94, I think) --- indra/llprimitive/llmaterial.cpp | 6 +++--- indra/llprimitive/llmaterial.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index 1e92847b38..bd98aa040a 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -51,7 +51,7 @@ #define MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD "AlphaMaskCutoff" #define MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD "DiffuseAlphaMode" -const LLColor4U LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR = LLColor4U::white; +const LLColor4U LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR(255,255,255,255); /** * Materials constants @@ -103,8 +103,8 @@ LLMaterial::LLMaterial() , mSpecularRotation(.0f) , mSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR) , mSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT) - , mEnvironmentIntensity(0) - , mDiffuseAlphaMode(0) + , mEnvironmentIntensity(LLMaterial::DEFAULT_ENV_INTENSITY) + , mDiffuseAlphaMode(LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) , mAlphaMaskCutoff(0) { } diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index bedfc8f8c2..c2e49985a4 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -54,6 +54,7 @@ public: static const U8 DEFAULT_SPECULAR_LIGHT_EXPONENT = ((U8)(0.2f * 255)); static const LLColor4U DEFAULT_SPECULAR_LIGHT_COLOR; + static const U8 DEFAULT_ENV_INTENSITY = ((U8)(0.05f * 255)); LLMaterial(); LLMaterial(const LLSD& material_data); -- cgit v1.2.3 From 0b4d76ce7856b060d4682955548ff047326c0aee Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 16 Apr 2013 08:27:30 -0700 Subject: NORSPEC-123 et al...roll back NSPEC 91 fix to avoid knock-on and set correct default env intensity --- indra/llprimitive/llmaterial.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index c2e49985a4..df5a45cabd 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -54,7 +54,7 @@ public: static const U8 DEFAULT_SPECULAR_LIGHT_EXPONENT = ((U8)(0.2f * 255)); static const LLColor4U DEFAULT_SPECULAR_LIGHT_COLOR; - static const U8 DEFAULT_ENV_INTENSITY = ((U8)(0.05f * 255)); + static const U8 DEFAULT_ENV_INTENSITY = 0; LLMaterial(); LLMaterial(const LLSD& material_data); -- cgit v1.2.3 From 67af268b785e8a47d7db10aa3a566c269b0f16e3 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 17 Apr 2013 01:51:39 -0500 Subject: NORSPEC-90 Alpha pool hookups for materials. --- indra/llprimitive/llmaterial.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index c2e49985a4..3145891393 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -49,8 +49,11 @@ public: typedef enum { - SHADER_COUNT = 16 + SHADER_COUNT = 16, + ALPHA_SHADER_COUNT = 4 } eShaderCount; + + static const U8 DEFAULT_SPECULAR_LIGHT_EXPONENT = ((U8)(0.2f * 255)); static const LLColor4U DEFAULT_SPECULAR_LIGHT_COLOR; -- cgit v1.2.3 From 806d09b1143894ad66cea2c228f467e8c39a8adf Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 30 Apr 2013 19:50:05 -0700 Subject: Merge 3.5.1 into Materials --- indra/llprimitive/CMakeLists.txt | 15 ++++- indra/llprimitive/llprimitive.cpp | 138 +++++++++++++++++++------------------- indra/llprimitive/llprimitive.h | 31 +++++++++ 3 files changed, 113 insertions(+), 71 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index 4eef1673f4..0dd13916bf 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -14,10 +14,14 @@ include_directories( ${LLMATH_INCLUDE_DIRS} ${LLMESSAGE_INCLUDE_DIRS} ${LLXML_INCLUDE_DIRS} - ${LLPHYSICSEXTENSIONS_INCLUDE_DIRS} ${LIBS_PREBUILT_DIR}/include/collada ${LIBS_PREBUILT_DIR}/include/collada/1.4 ) +include_directories(SYSTEM + ${LLCOMMON_SYSTEM_INCLUDE_DIRS} + ${LLXML_SYSTEM_INCLUDE_DIRS} + ${LLPHYSICSEXTENSIONS_INCLUDE_DIRS} + ) set(llprimitive_SOURCE_FILES llmaterialid.cpp @@ -63,6 +67,15 @@ list(APPEND llprimitive_SOURCE_FILES ${llprimitive_HEADER_FILES}) add_library (llprimitive ${llprimitive_SOURCE_FILES}) +target_link_libraries(llprimitive + ${LLCOMMON_LIBRARIES} + ${LLMATH_LIBRARIES} + ${LLMESSAGE_LIBRARIES} + ${LLXML_LIBRARIES} + ${LLPHYSICSEXTENSIONS_LIBRARIES} + ) + + #add unit tests if (LL_TESTS) INCLUDE(LLAddBuildTest) diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 0578f0b192..4a3fd03242 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -38,6 +38,7 @@ #include "lldatapacker.h" #include "llsdutil_math.h" #include "llprimtexturelist.h" +#include "imageids.h" #include "llmaterialid.h" /** @@ -268,6 +269,7 @@ S32 LLPrimitive::setTEScale(const U8 index, const F32 s, const F32 t) return mTextureList.setScale(index, s, t); } + // BUG: slow - done this way because texture entries have some // voodoo related to texture coords S32 LLPrimitive::setTEScaleS(const U8 index, const F32 s) @@ -313,6 +315,15 @@ S32 LLPrimitive::setTERotation(const U8 index, const F32 r) return mTextureList.setRotation(index, r); } +S32 LLPrimitive::setTEMaterialID(const U8 index, const LLMaterialID& pMaterialID) +{ + return mTextureList.setMaterialID(index, pMaterialID); +} + +S32 LLPrimitive::setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams) +{ + return mTextureList.setMaterialParams(index, pMaterialParams); +} //=============================================================== S32 LLPrimitive::setTEBumpShinyFullbright(const U8 index, const U8 bump) @@ -363,16 +374,6 @@ S32 LLPrimitive::setTEGlow(const U8 index, const F32 glow) return mTextureList.setGlow(index, glow); } -S32 LLPrimitive::setTEMaterialID(const U8 index, const LLMaterialID& pMaterialID) -{ - return mTextureList.setMaterialID(index, pMaterialID); -} - -S32 LLPrimitive::setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams) -{ - return mTextureList.setMaterialParams(index, pMaterialParams); -} - LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { // TODO: Should this default to something valid? @@ -1253,112 +1254,100 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const return FALSE; } -S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name) +S32 LLPrimitive::parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, LLTEContents& tec) { - return(unpackTEMessage(mesgsys,block_name,-1)); -} - -S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num) -{ - // use a negative block_num to indicate a single-block read (a non-variable block) S32 retval = 0; - const U32 MAX_TES = 32; - - // Avoid construction of 32 UUIDs per call. JC - static LLMaterialID material_ids[MAX_TES]; - - U8 image_data[MAX_TES*16]; - U8 colors[MAX_TES*4]; - F32 scale_s[MAX_TES]; - F32 scale_t[MAX_TES]; - S16 offset_s[MAX_TES]; - S16 offset_t[MAX_TES]; - S16 image_rot[MAX_TES]; - U8 bump[MAX_TES]; - U8 media_flags[MAX_TES]; - U8 glow[MAX_TES]; - U8 material_data[MAX_TES*16]; - - const U32 MAX_TE_BUFFER = 4096; - U8 packed_buffer[MAX_TE_BUFFER]; - U8 *cur_ptr = packed_buffer; - U32 size; - U32 face_count = 0; + // temp buffer for material ID processing + // data will end up in tec.material_id[] + U8 material_data[LLTEContents::MAX_TES*16]; if (block_num < 0) { - size = mesgsys->getSizeFast(block_name, _PREHASH_TextureEntry); + tec.size = mesgsys->getSizeFast(block_name, _PREHASH_TextureEntry); } else { - size = mesgsys->getSizeFast(block_name, block_num, _PREHASH_TextureEntry); + tec.size = mesgsys->getSizeFast(block_name, block_num, _PREHASH_TextureEntry); } - if (size == 0) + if (tec.size == 0) { + tec.face_count = 0; return retval; } if (block_num < 0) { - mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, packed_buffer, 0, 0, MAX_TE_BUFFER); + mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, tec.packed_buffer, 0, 0, LLTEContents::MAX_TE_BUFFER); } else { - mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, packed_buffer, 0, block_num, MAX_TE_BUFFER); + mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, tec.packed_buffer, 0, block_num, LLTEContents::MAX_TE_BUFFER); } - face_count = getNumTEs(); + tec.face_count = llmin((U32)getNumTEs(),(U32)LLTEContents::MAX_TES); - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)image_data, 16, face_count, MVT_LLUUID); + U8 *cur_ptr = tec.packed_buffer; + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.image_data, 16, tec.face_count, MVT_LLUUID); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)colors, 4, face_count, MVT_U8); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.colors, 4, tec.face_count, MVT_U8); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_s, 4, face_count, MVT_F32); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.scale_s, 4, tec.face_count, MVT_F32); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_t, 4, face_count, MVT_F32); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.scale_t, 4, tec.face_count, MVT_F32); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)offset_s, 2, face_count, MVT_S16Array); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.offset_s, 2, tec.face_count, MVT_S16Array); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)offset_t, 2, face_count, MVT_S16Array); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.offset_t, 2, tec.face_count, MVT_S16Array); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)image_rot, 2, face_count, MVT_S16Array); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.image_rot, 2, tec.face_count, MVT_S16Array); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)bump, 1, face_count, MVT_U8); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.bump, 1, tec.face_count, MVT_U8); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.media_flags, 1, tec.face_count, MVT_U8); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)glow, 1, face_count, MVT_U8); - if (cur_ptr < packed_buffer + size) + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.glow, 1, tec.face_count, MVT_U8); + + if (cur_ptr < tec.packed_buffer + tec.size) { cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_data, 16, face_count, MVT_LLUUID); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)material_data, 16, tec.face_count, MVT_LLUUID); } else { memset(material_data, 0, sizeof(material_data)); } - for (U32 i = 0; i < face_count; i++) + for (U32 i = 0; i < tec.face_count; i++) { - material_ids[i].set(&material_data[i * 16]); + tec.material_ids[i].set(&material_data[i * 16]); } + retval = 1; + return retval; +} + +S32 LLPrimitive::applyParsedTEMessage(LLTEContents& tec) +{ + S32 retval = 0; + LLColor4 color; LLColor4U coloru; - for (U32 i = 0; i < face_count; i++) - { - retval |= setTETexture(i, ((LLUUID*)image_data)[i]); - retval |= setTEScale(i, scale_s[i], scale_t[i]); - retval |= setTEOffset(i, (F32)offset_s[i] / (F32)0x7FFF, (F32) offset_t[i] / (F32) 0x7FFF); - retval |= setTERotation(i, ((F32)image_rot[i] / TEXTURE_ROTATION_PACK_FACTOR) * F_TWO_PI); - retval |= setTEBumpShinyFullbright(i, bump[i]); - retval |= setTEMediaTexGen(i, media_flags[i]); - retval |= setTEGlow(i, (F32)glow[i] / (F32)0xFF); - retval |= setTEMaterialID(i, material_ids[i]); + for (U32 i = 0; i < tec.face_count; i++) + { + LLUUID& req_id = ((LLUUID*)tec.image_data)[i]; + retval |= setTETexture(i, req_id); + retval |= setTEScale(i, tec.scale_s[i], tec.scale_t[i]); + retval |= setTEOffset(i, (F32)tec.offset_s[i] / (F32)0x7FFF, (F32) tec.offset_t[i] / (F32) 0x7FFF); + retval |= setTERotation(i, ((F32)tec.image_rot[i] / TEXTURE_ROTATION_PACK_FACTOR) * F_TWO_PI); + retval |= setTEBumpShinyFullbright(i, tec.bump[i]); + retval |= setTEMediaTexGen(i, tec.media_flags[i]); + retval |= setTEGlow(i, (F32)tec.glow[i] / (F32)0xFF); - coloru = LLColor4U(colors + 4*i); + retval |= setTEMaterialID(i, tec.material_ids[i]); + + coloru = LLColor4U(tec.colors + 4*i); // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) // as all zeros. However, the subtraction and addition must be done in unsigned @@ -1375,6 +1364,15 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam return retval; } +S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num) +{ + LLTEContents tec; + S32 retval = parseTEMessage(mesgsys, block_name, block_num, tec); + if (!retval) + return retval; + return applyParsedTEMessage(tec); +} + S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) { // use a negative block_num to indicate a single-block read (a non-variable block) diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 6a9c5e9639..6f3657cd9b 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -290,6 +290,35 @@ public: }; +// This code is not naming-standards compliant. Leaving it like this for +// now to make the connection to code in +// BOOL packTEMessage(LLDataPacker &dp) const; +// more obvious. This should be refactored to remove the duplication, at which +// point we can fix the names as well. +// - Vir +struct LLTEContents +{ + static const U32 MAX_TES = 32; + + U8 image_data[MAX_TES*16]; + U8 colors[MAX_TES*4]; + F32 scale_s[MAX_TES]; + F32 scale_t[MAX_TES]; + S16 offset_s[MAX_TES]; + S16 offset_t[MAX_TES]; + S16 image_rot[MAX_TES]; + U8 bump[MAX_TES]; + U8 media_flags[MAX_TES]; + U8 glow[MAX_TES]; + LLMaterialID material_ids[MAX_TES]; + + static const U32 MAX_TE_BUFFER = 4096; + U8 packed_buffer[MAX_TE_BUFFER]; + + U32 size; + U32 face_count; +}; + class LLPrimitive : public LLXform { public: @@ -366,6 +395,8 @@ public: S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name); S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num); // Variable num of blocks BOOL unpackTEMessage(LLDataPacker &dp); + S32 parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, LLTEContents& tec); + S32 applyParsedTEMessage(LLTEContents& tec); #ifdef CHECK_FOR_FINITE inline void setPosition(const LLVector3& pos); -- cgit v1.2.3 From 18e3985120d53acdf07d43dce79312b78629e57a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 6 May 2013 15:44:44 -0500 Subject: NORSPEC-162 Fix for objects with materials set ignoring "tranparency %" value. --- indra/llprimitive/llmaterial.cpp | 11 +++++++++-- indra/llprimitive/llmaterial.h | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index bd98aa040a..ce443dea1d 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -186,12 +186,19 @@ bool LLMaterial::operator != (const LLMaterial& rhs) const } -U32 LLMaterial::getShaderMask() +U32 LLMaterial::getShaderMask(U32 alpha_mode) { //NEVER incorporate this value into the message system -- this function will vary depending on viewer implementation U32 ret = 0; //two least significant bits are "diffuse alpha mode" - ret = getDiffuseAlphaMode(); + if (alpha_mode != DIFFUSE_ALPHA_MODE_DEFAULT) + { + ret = alpha_mode; + } + else + { + ret = getDiffuseAlphaMode(); + } llassert(ret < SHADER_COUNT); diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index b294288c64..b265732adc 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -44,7 +44,8 @@ public: DIFFUSE_ALPHA_MODE_NONE = 0, DIFFUSE_ALPHA_MODE_BLEND = 1, DIFFUSE_ALPHA_MODE_MASK = 2, - DIFFUSE_ALPHA_MODE_EMISSIVE = 3 + DIFFUSE_ALPHA_MODE_EMISSIVE = 3, + DIFFUSE_ALPHA_MODE_DEFAULT = 4, } eDiffuseAlphaMode; typedef enum @@ -100,7 +101,7 @@ public: bool operator == (const LLMaterial& rhs) const; bool operator != (const LLMaterial& rhs) const; - U32 getShaderMask(); + U32 getShaderMask(U32 alpha_mode = DIFFUSE_ALPHA_MODE_DEFAULT); protected: LLUUID mNormalID; -- cgit v1.2.3 From 5aa3f3c808976c3b709bd8141d4338e910c49691 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Thu, 9 May 2013 15:41:07 -0700 Subject: NORSPEC-164 fix TE copy ctor and operator= to include material pointer in addition to ID --- indra/llprimitive/lltextureentry.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 691216e035..53816266eb 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -85,7 +85,7 @@ LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) mMediaFlags = rhs.mMediaFlags; mGlow = rhs.mGlow; mMaterialID = rhs.mMaterialID; - + mMaterial = rhs.mMaterial; if (rhs.mMediaEntry != NULL) { // Make a copy mMediaEntry = new LLMediaEntry(*rhs.mMediaEntry); @@ -107,6 +107,7 @@ LLTextureEntry &LLTextureEntry::operator=(const LLTextureEntry &rhs) mMediaFlags = rhs.mMediaFlags; mGlow = rhs.mGlow; mMaterialID = rhs.mMaterialID; + mMaterial = rhs.mMaterial; if (mMediaEntry != NULL) { delete mMediaEntry; } -- cgit v1.2.3 From 269b8b7de53f368791fbffde8a6f8d47d9cbbcdc Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Fri, 10 May 2013 10:50:50 +0200 Subject: NORSPEC-102 Rapid materials updates are not smooth to viewer which is editing the object --- indra/llprimitive/llprimitive.cpp | 18 ++++++++++++++++++ indra/llprimitive/llprimitive.h | 2 ++ indra/llprimitive/lltextureentry.cpp | 20 +++++++++++++++++++- indra/llprimitive/lltextureentry.h | 6 ++++++ 4 files changed, 45 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 0578f0b192..3f57dbe26d 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -373,6 +373,24 @@ S32 LLPrimitive::setTEMaterialParams(const U8 index, const LLMaterialPtr pMateri return mTextureList.setMaterialParams(index, pMaterialParams); } +void LLPrimitive::setAllTESelected(bool sel) +{ + for (int i = 0, cnt = getNumTEs(); i < cnt; i++) + { + setTESelected(i, sel); + } +} + +void LLPrimitive::setTESelected(const U8 te, bool sel) +{ + LLTextureEntry* tep = getTE(te); + if ( (tep) && (tep->setSelected(sel)) && (!sel) && (tep->hasPendingMaterialUpdate()) ) + { + LLMaterialID material_id = tep->getMaterialID(); + setTEMaterialID(te, material_id); + } +} + LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { // TODO: Should this default to something valid? diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 6a9c5e9639..dc21af2649 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -332,6 +332,7 @@ public: LLTextureEntry* getTE(const U8 te_num) const; virtual void setNumTEs(const U8 num_tes); + virtual void setAllTESelected(bool sel); virtual void setAllTETextures(const LLUUID &tex_id); virtual void setTE(const U8 index, const LLTextureEntry& te); virtual S32 setTEColor(const U8 te, const LLColor4 &color); @@ -357,6 +358,7 @@ public: virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed + virtual void setTESelected(const U8 te, bool sel); void copyTEs(const LLPrimitive *primitive); S32 packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 691216e035..6e5d27bb94 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -61,18 +61,24 @@ LLTextureEntry* LLTextureEntry::newTextureEntry() //=============================================================== LLTextureEntry::LLTextureEntry() : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { init(LLUUID::null,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE); } LLTextureEntry::LLTextureEntry(const LLUUID& tex_id) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { init(tex_id,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE); } LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { mID = rhs.mID; mScaleS = rhs.mScaleS; @@ -532,8 +538,16 @@ S32 LLTextureEntry::setGlow(F32 glow) S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) { - if (mMaterialID != pMaterialID) + if ( (mMaterialID != pMaterialID) || (mMaterialUpdatePending && !mSelected) ) { + if (mSelected) + { + mMaterialUpdatePending = true; + mMaterialID = pMaterialID; + return TEM_CHANGE_NONE; + } + + mMaterialUpdatePending = false; mMaterialID = pMaterialID; if (mMaterialID.isNull()) { @@ -548,6 +562,10 @@ S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { if (mMaterial != pMaterialParams) { + if (mSelected) + { + mMaterialUpdatePending = true; + } mMaterial = pMaterialParams; return TEM_CHANGE_TEXTURE; } diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index c443ebcb30..f867f45819 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -99,6 +99,10 @@ public: virtual LLTextureEntry* newCopy() const; void init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump); + + bool hasPendingMaterialUpdate() const { return mMaterialUpdatePending; } + bool isSelected() const { return mSelected; } + bool setSelected(bool sel) { bool prev_sel = mSelected; mSelected = sel; return prev_sel; } // These return a TEM_ flag from above to indicate if something changed. S32 setID (const LLUUID &tex_id); @@ -194,11 +198,13 @@ public: static const char* TEXTURE_MEDIA_DATA_KEY; protected: + bool mSelected; LLUUID mID; // Texture GUID LLColor4 mColor; U8 mBump; // Bump map, shiny, and fullbright U8 mMediaFlags; // replace with web page, movie, etc. F32 mGlow; + bool mMaterialUpdatePending; LLMaterialID mMaterialID; LLMaterialPtr mMaterial; -- cgit v1.2.3 From e413f4b335a2f4f5a1ca151c8ab67324a72ebaee Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 10 May 2013 15:13:07 -0700 Subject: Fixup merge diffs --- indra/llprimitive/llprimitive.cpp | 1 - indra/llprimitive/llprimitive.h | 1 - 2 files changed, 2 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 426666ff00..e5905c3a3b 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1257,7 +1257,6 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const S32 LLPrimitive::parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, LLTEContents& tec) { S32 retval = 0; - // temp buffer for material ID processing // data will end up in tec.material_id[] U8 material_data[LLTEContents::MAX_TES*16]; diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 6f3657cd9b..b1f8090416 100755 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -392,7 +392,6 @@ public: S32 unpackTEField(U8 *cur_ptr, U8 *buffer_end, U8 *data_ptr, U8 data_size, U8 face_count, EMsgVariableType type); BOOL packTEMessage(LLMessageSystem *mesgsys) const; BOOL packTEMessage(LLDataPacker &dp) const; - S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name); S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num); // Variable num of blocks BOOL unpackTEMessage(LLDataPacker &dp); S32 parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, LLTEContents& tec); -- cgit v1.2.3 From f356d7eb9fd730f5f6f5a29fb0706e20876ad3bd Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Sat, 11 May 2013 19:58:56 -0700 Subject: Fix many issues with selection misapplication and rendering not matching applied materials --- indra/llprimitive/llprimitive.cpp | 18 ++++++++++++++++++ indra/llprimitive/llprimitive.h | 2 ++ indra/llprimitive/lltextureentry.cpp | 25 +++++++++++++------------ indra/llprimitive/lltextureentry.h | 6 ++++++ 4 files changed, 39 insertions(+), 12 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index e5905c3a3b..2fa77177f5 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -374,6 +374,24 @@ S32 LLPrimitive::setTEGlow(const U8 index, const F32 glow) return mTextureList.setGlow(index, glow); } +void LLPrimitive::setAllTESelected(bool sel) +{ + for (int i = 0, cnt = getNumTEs(); i < cnt; i++) + { + setTESelected(i, sel); + } +} + +void LLPrimitive::setTESelected(const U8 te, bool sel) +{ + LLTextureEntry* tep = getTE(te); + if ( (tep) && (tep->setSelected(sel)) && (!sel) && (tep->hasPendingMaterialUpdate()) ) + { + LLMaterialID material_id = tep->getMaterialID(); + setTEMaterialID(te, material_id); + } +} + LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { // TODO: Should this default to something valid? diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index b1f8090416..47a21beaaf 100755 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -361,6 +361,7 @@ public: LLTextureEntry* getTE(const U8 te_num) const; virtual void setNumTEs(const U8 num_tes); + virtual void setAllTESelected(bool sel); virtual void setAllTETextures(const LLUUID &tex_id); virtual void setTE(const U8 index, const LLTextureEntry& te); virtual S32 setTEColor(const U8 te, const LLColor4 &color); @@ -386,6 +387,7 @@ public: virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed + virtual void setTESelected(const U8 te, bool sel); void copyTEs(const LLPrimitive *primitive); S32 packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 53816266eb..1d581da897 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -67,12 +67,16 @@ LLTextureEntry::LLTextureEntry() LLTextureEntry::LLTextureEntry(const LLUUID& tex_id) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { init(tex_id,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE); } LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { mID = rhs.mID; mScaleS = rhs.mScaleS; @@ -536,23 +540,20 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) if (mMaterialID != pMaterialID) { mMaterialID = pMaterialID; - if (mMaterialID.isNull()) - { - setMaterialParams(NULL); - } - return TEM_CHANGE_TEXTURE; + } - return TEM_CHANGE_NONE; + if (mMaterialID.isNull()) + { + setMaterialParams(NULL); + } + return TEM_CHANGE_TEXTURE; } S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - if (mMaterial != pMaterialParams) - { - mMaterial = pMaterialParams; - return TEM_CHANGE_TEXTURE; - } - return TEM_CHANGE_NONE; + + mMaterial = pMaterialParams; + return TEM_CHANGE_TEXTURE; } void LLTextureEntry::setMediaData(const LLMediaEntry &media_entry) diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index c443ebcb30..5cc76cfe82 100755 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -100,6 +100,10 @@ public: void init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump); + bool hasPendingMaterialUpdate() const { return mMaterialUpdatePending; } + bool isSelected() const { return mSelected; } + bool setSelected(bool sel) { bool prev_sel = mSelected; mSelected = sel; return prev_sel; } + // These return a TEM_ flag from above to indicate if something changed. S32 setID (const LLUUID &tex_id); S32 setColor(const LLColor4 &color); @@ -194,11 +198,13 @@ public: static const char* TEXTURE_MEDIA_DATA_KEY; protected: + bool mSelected; LLUUID mID; // Texture GUID LLColor4 mColor; U8 mBump; // Bump map, shiny, and fullbright U8 mMediaFlags; // replace with web page, movie, etc. F32 mGlow; + bool mMaterialUpdatePending; LLMaterialID mMaterialID; LLMaterialPtr mMaterial; -- cgit v1.2.3 From 5ac9d9cb05f22099bea8c9312f5e0b234430022a Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 12 May 2013 16:10:31 +0200 Subject: LLMaterialMgr::get() doesn't handle a callback request for LLMaterialID::null --- indra/llprimitive/lltextureentry.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 8365c9d7b6..597f078490 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -550,12 +550,9 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) mMaterialUpdatePending = false; mMaterialID = pMaterialID; + return TEM_CHANGE_TEXTURE; } - if (mMaterialID.isNull()) - { - setMaterialParams(NULL); - } - return TEM_CHANGE_TEXTURE; + return TEM_CHANGE_NONE; } S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) -- cgit v1.2.3 From d9e8ee7cfd323872145c23e4032989f9b7770f55 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Mon, 13 May 2013 13:02:53 -0700 Subject: NORSPEC-178 NORSPEC-179 NORSPEC-180 made enable/disable handling more consistent and increased max range on repeats per meter --- indra/llprimitive/lltextureentry.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 597f078490..ca57f1edbd 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -539,28 +539,21 @@ S32 LLTextureEntry::setGlow(F32 glow) S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) { - if ( (mMaterialID != pMaterialID) || (mMaterialUpdatePending && !mSelected) ) + if (mMaterialID != pMaterialID) { - if (mSelected) + mMaterialID = pMaterialID; + + } + if (mMaterialID.isNull()) { - mMaterialUpdatePending = true; - mMaterialID = pMaterialID; - return TEM_CHANGE_NONE; + setMaterialParams(NULL); } - - mMaterialUpdatePending = false; - mMaterialID = pMaterialID; return TEM_CHANGE_TEXTURE; } - return TEM_CHANGE_NONE; -} S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - if (mSelected) - { - mMaterialUpdatePending = true; - } + mMaterial = pMaterialParams; return TEM_CHANGE_TEXTURE; } -- cgit v1.2.3 From ad09e2111cd980117ae937b79155ef6c24e4567c Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Tue, 14 May 2013 21:14:46 +0200 Subject: NORSPEC-102 & Co Reloaded --- indra/llprimitive/lltextureentry.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index ca57f1edbd..597f078490 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -539,21 +539,28 @@ S32 LLTextureEntry::setGlow(F32 glow) S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) { - if (mMaterialID != pMaterialID) + if ( (mMaterialID != pMaterialID) || (mMaterialUpdatePending && !mSelected) ) { - mMaterialID = pMaterialID; - - } - if (mMaterialID.isNull()) + if (mSelected) { - setMaterialParams(NULL); + mMaterialUpdatePending = true; + mMaterialID = pMaterialID; + return TEM_CHANGE_NONE; } + + mMaterialUpdatePending = false; + mMaterialID = pMaterialID; return TEM_CHANGE_TEXTURE; } + return TEM_CHANGE_NONE; +} S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - + if (mSelected) + { + mMaterialUpdatePending = true; + } mMaterial = pMaterialParams; return TEM_CHANGE_TEXTURE; } -- cgit v1.2.3 From 7e4e59470f36ae7a0e01b8d2613af4c8fb6b0101 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 7 Jun 2013 08:58:15 -0700 Subject: NORSPEC-233 WIP for individual material param edits across hetero object selections --- indra/llprimitive/llmaterial.h | 28 ++++++++++++++++++++++++++-- indra/llprimitive/lltextureentry.h | 8 +++++++- 2 files changed, 33 insertions(+), 3 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index b265732adc..9f52a3f6c1 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -69,19 +69,43 @@ public: const LLUUID& getNormalID() const { return mNormalID; } void setNormalID(const LLUUID& normal_id) { mNormalID = normal_id; } void getNormalOffset(F32& offset_x, F32& offset_y) const { offset_x = mNormalOffsetX; offset_y = mNormalOffsetY; } + F32 getNormalOffsetX() const { return mNormalOffsetX; } + F32 getNormalOffsetY() const { return mNormalOffsetY; } + void setNormalOffset(F32 offset_x, F32 offset_y) { mNormalOffsetX = offset_x; mNormalOffsetY = offset_y; } + void setNormalOffsetX(F32 offset_x) { mNormalOffsetX = offset_x; } + void setNormalOffsetY(F32 offset_y) { mNormalOffsetY = offset_y; } + void getNormalRepeat(F32& repeat_x, F32& repeat_y) const { repeat_x = mNormalRepeatX; repeat_y = mNormalRepeatY; } + F32 getNormalRepeatX() const { return mNormalRepeatX; } + F32 getNormalRepeatY() const { return mNormalRepeatY; } + void setNormalRepeat(F32 repeat_x, F32 repeat_y) { mNormalRepeatX = repeat_x; mNormalRepeatY = repeat_y; } - F32 getNormalRotation() const { return mNormalRotation; } + void setNormalRepeatX(F32 repeat_x) { mNormalRepeatX = repeat_x; } + void setNormalRepeatY(F32 repeat_y) { mNormalRepeatY = repeat_y; } + + F32 getNormalRotation() const { return mNormalRotation; } void setNormalRotation(F32 rot) { mNormalRotation = rot; } const LLUUID& getSpecularID() const { return mSpecularID; } void setSpecularID(const LLUUID& specular_id) { mSpecularID = specular_id; } void getSpecularOffset(F32& offset_x, F32& offset_y) const { offset_x = mSpecularOffsetX; offset_y = mSpecularOffsetY; } + F32 getSpecularOffsetX() const { return mSpecularOffsetX; } + F32 getSpecularOffsetY() const { return mSpecularOffsetY; } + void setSpecularOffset(F32 offset_x, F32 offset_y) { mSpecularOffsetX = offset_x; mSpecularOffsetY = offset_y; } + void setSpecularOffsetX(F32 offset_x) { mSpecularOffsetX = offset_x; } + void setSpecularOffsetY(F32 offset_y) { mSpecularOffsetY = offset_y; } + void getSpecularRepeat(F32& repeat_x, F32& repeat_y) const { repeat_x = mSpecularRepeatX; repeat_y = mSpecularRepeatY; } + F32 getSpecularRepeatX() const { return mSpecularRepeatX; } + F32 getSpecularRepeatY() const { return mSpecularRepeatY; } + void setSpecularRepeat(F32 repeat_x, F32 repeat_y) { mSpecularRepeatX = repeat_x; mSpecularRepeatY = repeat_y; } - F32 getSpecularRotation() const { return mSpecularRotation; } + void setSpecularRepeatX(F32 repeat_x) { mSpecularRepeatX = repeat_x; } + void setSpecularRepeatY(F32 repeat_y) { mSpecularRepeatY = repeat_y; } + + F32 getSpecularRotation() const { return mSpecularRotation; } void setSpecularRotation(F32 rot) { mSpecularRotation = rot; } const LLColor4U getSpecularLightColor() const { return mSpecularLightColor; } diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 5cc76cfe82..59364cb913 100755 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -133,7 +133,13 @@ public: virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } void getScale(F32 *s, F32 *t) const { *s = mScaleS; *t = mScaleT; } + void getScaleS(F32 *s) const { *s = mScaleS; } + void getScaleT(F32 *t) const { *t = mScaleT; } + void getOffset(F32 *s, F32 *t) const { *s = mOffsetS; *t = mOffsetT; } + F32 getOffsetS() const { return mOffsetS; } + F32 getOffsetT() const { return mOffsetT; } + F32 getRotation() const { return mRotation; } void getRotation(F32 *theta) const { *theta = mRotation; } @@ -144,7 +150,7 @@ public: U8 getBumpShinyFullbright() const { return mBump; } U8 getMediaFlags() const { return mMediaFlags & TEM_MEDIA_MASK; } - U8 getTexGen() const { return mMediaFlags & TEM_TEX_GEN_MASK; } + LLTextureEntry::e_texgen getTexGen() const { return LLTextureEntry::e_texgen(mMediaFlags & TEM_TEX_GEN_MASK); } U8 getMediaTexGen() const { return mMediaFlags; } F32 getGlow() const { return mGlow; } const LLMaterialID& getMaterialID() const { return mMaterialID; }; -- cgit v1.2.3 From c78cd1aae63a7c7c0bf6a9c21380818aa9cd47b7 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 7 Jun 2013 14:37:39 -0700 Subject: NORSPEC-233 WIP fix completely bogus substitution of offsets for scales and make scale accessors get with the program --- indra/llprimitive/lltextureentry.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 59364cb913..19edcaa27d 100755 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -133,8 +133,8 @@ public: virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } void getScale(F32 *s, F32 *t) const { *s = mScaleS; *t = mScaleT; } - void getScaleS(F32 *s) const { *s = mScaleS; } - void getScaleT(F32 *t) const { *t = mScaleT; } + F32 getScaleS() const { return mScaleS; } + F32 getScaleT() const { return mScaleT; } void getOffset(F32 *s, F32 *t) const { *s = mOffsetS; *t = mOffsetT; } F32 getOffsetS() const { return mOffsetS; } -- cgit v1.2.3 From eba7eb2d062c43cd83cb6972e4e05dc54d409582 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Sat, 8 Jun 2013 06:28:48 -0700 Subject: NORSPEC-233 fix default value and material apply logic errors --- indra/llprimitive/llmaterial.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index ce443dea1d..cf4c645cfd 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -91,16 +91,16 @@ template<> LLUUID getMaterialField(const LLSD& data, const std::string& field, c const LLMaterial LLMaterial::null; LLMaterial::LLMaterial() - : mNormalOffsetX(.0f) - , mNormalOffsetY(.0f) - , mNormalRepeatX(.0f) - , mNormalRepeatY(.0f) - , mNormalRotation(.0f) - , mSpecularOffsetX(.0f) - , mSpecularOffsetY(.0f) - , mSpecularRepeatX(.0f) - , mSpecularRepeatY(.0f) - , mSpecularRotation(.0f) + : mNormalOffsetX(0.0f) + , mNormalOffsetY(0.0f) + , mNormalRepeatX(1.0f) + , mNormalRepeatY(1.0f) + , mNormalRotation(0.0f) + , mSpecularOffsetX(0.0f) + , mSpecularOffsetY(0.0f) + , mSpecularRepeatX(1.0f) + , mSpecularRepeatY(1.0f) + , mSpecularRotation(0.0f) , mSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR) , mSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT) , mEnvironmentIntensity(LLMaterial::DEFAULT_ENV_INTENSITY) -- cgit v1.2.3