diff --git a/indra/cmake/LLCommon.cmake b/indra/cmake/LLCommon.cmake index 222d1fac8..beac1d012 100644 --- a/indra/cmake/LLCommon.cmake +++ b/indra/cmake/LLCommon.cmake @@ -19,3 +19,8 @@ set(LLCOMMON_INCLUDE_DIRS ) set(LLCOMMON_LIBRARIES llcommon) + +set(LLCOMMON_LINK_SHARED ON CACHE BOOL "Build the llcommon target as a shared library.") +if(LLCOMMON_LINK_SHARED) + add_definitions(-DLL_COMMON_LINK_SHARED=1) +endif(LLCOMMON_LINK_SHARED) diff --git a/indra/cmake/OpenGL.cmake b/indra/cmake/OpenGL.cmake index 3dcd396c5..f8a113f65 100644 --- a/indra/cmake/OpenGL.cmake +++ b/indra/cmake/OpenGL.cmake @@ -2,9 +2,9 @@ include(Prebuilt) if (NOT STANDALONE) - use_prebuilt_binary(GL) + use_prebuilt_binary(glext) # possible glh_linear should have its own .cmake file instead #use_prebuilt_binary(glh_linear) # actually... not any longer, it's now in git -SG - set(GLEXT_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) + set(GLEXT_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include) endif (NOT STANDALONE) diff --git a/indra/llaudio/llvorbisencode.cpp b/indra/llaudio/llvorbisencode.cpp index 443b57698..2fcaf97a8 100644 --- a/indra/llaudio/llvorbisencode.cpp +++ b/indra/llaudio/llvorbisencode.cpp @@ -89,7 +89,7 @@ S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& erro //******************************** LLAPRFile infile ; - infile.open(in_fname,LL_APR_RB, LLAPRFile::global); + infile.open(in_fname,LL_APR_RB); //******************************** if (!infile.getFileHandle()) { @@ -240,7 +240,7 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname S32 data_left = 0; LLAPRFile infile ; - infile.open(in_fname,LL_APR_RB, LLAPRFile::global); + infile.open(in_fname,LL_APR_RB); if (!infile.getFileHandle()) { llwarns << "Couldn't open temporary ogg file for writing: " << in_fname @@ -249,7 +249,7 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname } LLAPRFile outfile ; - outfile.open(out_fname,LL_APR_WPB, LLAPRFile::global); + outfile.open(out_fname,LL_APR_WPB); if (!outfile.getFileHandle()) { llwarns << "Couldn't open upload sound file for reading: " << in_fname diff --git a/indra/llcharacter/llbvhloader.cpp b/indra/llcharacter/llbvhloader.cpp index 12bcffac2..8c7878936 100644 --- a/indra/llcharacter/llbvhloader.cpp +++ b/indra/llcharacter/llbvhloader.cpp @@ -226,7 +226,7 @@ ELoadStatus LLBVHLoader::loadTranslationTable(const char *fileName) std::string path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,fileName); LLAPRFile infile ; - infile.open(path, LL_APR_R, LLAPRFile::global); + infile.open(path, LL_APR_R); apr_file_t *fp = infile.getFileHandle(); if (!fp) return E_ST_NO_XLT_FILE; diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h index 7d30b006d..d435a4cca 100644 --- a/indra/llcharacter/llcharacter.h +++ b/indra/llcharacter/llcharacter.h @@ -42,7 +42,7 @@ #include "llmotioncontroller.h" #include "llvisualparam.h" #include "string_table.h" -#include "llmemory.h" +#include "llpointer.h" #include "llthread.h" class LLPolyMesh; diff --git a/indra/llcharacter/lljointstate.h b/indra/llcharacter/lljointstate.h index 16ad0e120..e40cf2673 100644 --- a/indra/llcharacter/lljointstate.h +++ b/indra/llcharacter/lljointstate.h @@ -37,7 +37,7 @@ // Header Files //----------------------------------------------------------------------------- #include "lljoint.h" -#include "llmemory.h" +#include "llrefcount.h" //----------------------------------------------------------------------------- // class LLJointState diff --git a/indra/llcharacter/llpose.cpp b/indra/llcharacter/llpose.cpp index b770b05a7..7f08f3e58 100644 --- a/indra/llcharacter/llpose.cpp +++ b/indra/llcharacter/llpose.cpp @@ -163,8 +163,6 @@ void LLPose::setWeight(F32 weight) // there was a crash here // llassert_always(iter->second.notNull()); - if(!iter->second) //uhoh... - continue; iter->second->setWeight(weight); } mWeight = weight; diff --git a/indra/llcharacter/llpose.h b/indra/llcharacter/llpose.h index 80487bd12..2b976b219 100644 --- a/indra/llcharacter/llpose.h +++ b/indra/llcharacter/llpose.h @@ -40,6 +40,8 @@ #include "lljointstate.h" #include "lljoint.h" #include "llmap.h" +#include "llpointer.h" + #include #include diff --git a/indra/llcharacter/llstatemachine.cpp b/indra/llcharacter/llstatemachine.cpp index cc74d9ccf..e6fa4d798 100644 --- a/indra/llcharacter/llstatemachine.cpp +++ b/indra/llcharacter/llstatemachine.cpp @@ -211,7 +211,7 @@ LLFSMState* LLStateDiagram::getState(U32 state_id) BOOL LLStateDiagram::saveDotFile(const std::string& filename) { LLAPRFile outfile ; - outfile.open(filename, LL_APR_W, LLAPRFile::global); + outfile.open(filename, LL_APR_W); apr_file_t* dot_file = outfile.getFileHandle() ; if (!dot_file) diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index c72b4d277..99f00a2c5 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -196,6 +196,7 @@ set(llcommon_HEADER_FILES llsys.h llthread.h lltimer.h + lltreeiterators.h lluri.h lluuid.h lluuidhashmap.h @@ -232,6 +233,7 @@ target_link_libraries( ${EXPAT_LIBRARIES} ${ZLIB_LIBRARIES} ${WINDOWS_LIBRARIES} + ${BOOST_REGEX_LIBRARY} ${CWDEBUG_LIBRARIES} ${CORESERVICES_LIBRARY} ) diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index d2169d65e..fb07621cb 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -191,6 +191,10 @@ apr_status_t LLAPRFile::open(std::string const& filename, apr_int32_t flags, acc return status; } +apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, BOOL use_global_pool) +{ + return open(filename, flags, use_global_pool ? LLAPRFile::global : LLAPRFile::local); +} // File I/O S32 LLAPRFile::read(void *buf, S32 nbytes) { diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index ded15f531..a9c0543c2 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -150,10 +150,11 @@ public: }; LLAPRFile() ; - LLAPRFile(const std::string& filename, apr_int32_t flags, access_t access_type); + LLAPRFile(const std::string& filename, apr_int32_t flags, access_t access_type = LLAPRFile::global); ~LLAPRFile() ; - apr_status_t open(const std::string& filename, apr_int32_t flags, access_t access_type, S32* sizep = NULL); + apr_status_t open(const std::string& filename, apr_int32_t flags, access_t access_type = LLAPRFile::global, S32* sizep = NULL); + apr_status_t open(const std::string& filename, apr_int32_t flags, BOOL use_global_pool); //use global pool. apr_status_t close() ; // Returns actual offset, -1 if seek fails diff --git a/indra/llcommon/llassettype.cpp b/indra/llcommon/llassettype.cpp index c2b3779db..6aea07fd0 100644 --- a/indra/llcommon/llassettype.cpp +++ b/indra/llcommon/llassettype.cpp @@ -35,6 +35,7 @@ #include "llassettype.h" #include "lldictionary.h" #include "llmemory.h" +#include "llsingleton.h" ///---------------------------------------------------------------------------- /// Class LLAssetType diff --git a/indra/llcommon/lleventtimer.cpp b/indra/llcommon/lleventtimer.cpp index 2720b93ab..a29a837a8 100644 --- a/indra/llcommon/lleventtimer.cpp +++ b/indra/llcommon/lleventtimer.cpp @@ -44,63 +44,40 @@ // ////////////////////////////////////////////////////////////////////////////// -//std::list LLEventTimer::sActiveList; - LLEventTimer::LLEventTimer(F32 period) : mEventTimer() { mPeriod = period; - //sActiveList.push_back(this); } LLEventTimer::LLEventTimer(const LLDate& time) : mEventTimer() { mPeriod = (F32)(time.secondsSinceEpoch() - LLDate::now().secondsSinceEpoch()); - //sActiveList.push_back(this); } -LLEventTimer::~LLEventTimer() +LLEventTimer::~LLEventTimer() { - //sActiveList.remove(this); } //static void LLEventTimer::updateClass() { std::list completed_timers; - - /*{ - for (std::list::iterator iter = sActiveList.begin(); iter != sActiveList.end(); ) - { - LLEventTimer* timer = *iter++; - F32 et = timer->mEventTimer.getElapsedTimeF32(); - if (timer->mEventTimer.getStarted() && et > timer->mPeriod) { - timer->mEventTimer.reset(); - if ( timer->tick() ) - { - completed_timers.push_back( timer ); - } - } - } - }*/ + for (instance_iter iter = beginInstances(); iter != endInstances(); ) { - LLInstanceTrackerScopedGuard guard; - for (instance_iter iter = guard.beginInstances(); iter != guard.endInstances(); ) - { - LLEventTimer& timer = *iter++; - F32 et = timer.mEventTimer.getElapsedTimeF32(); - if (timer.mEventTimer.getStarted() && et > timer.mPeriod) { - timer.mEventTimer.reset(); - if ( timer.tick() ) - { - completed_timers.push_back( &timer ); - } + LLEventTimer& timer = *iter++; + F32 et = timer.mEventTimer.getElapsedTimeF32(); + if (timer.mEventTimer.getStarted() && et > timer.mPeriod) { + timer.mEventTimer.reset(); + if ( timer.tick() ) + { + completed_timers.push_back( &timer ); } } } - + if ( completed_timers.size() > 0 ) { for (std::list::iterator completed_iter = completed_timers.begin(); diff --git a/indra/llcommon/lleventtimer.h b/indra/llcommon/lleventtimer.h index 1521b507a..9e003119d 100644 --- a/indra/llcommon/lleventtimer.h +++ b/indra/llcommon/lleventtimer.h @@ -56,11 +56,6 @@ public: protected: LLTimer mEventTimer; F32 mPeriod; - -//private: - //list of active timers -// static std::list sActiveList; // TODO should this be a vector }; - #endif //LL_EVENTTIMER_H diff --git a/indra/llcommon/llfoldertype.cpp b/indra/llcommon/llfoldertype.cpp index 76e0d2bc9..280606b4f 100644 --- a/indra/llcommon/llfoldertype.cpp +++ b/indra/llcommon/llfoldertype.cpp @@ -36,6 +36,7 @@ #include "llfoldertype.h" #include "lldictionary.h" #include "llmemory.h" +#include "llsingleton.h" ///---------------------------------------------------------------------------- /// Class LLFolderType @@ -95,7 +96,12 @@ LLFolderDictionary::LLFolderDictionary() addEntry(LLFolderType::FT_CURRENT_OUTFIT, new FolderEntry("current", TRUE)); addEntry(LLFolderType::FT_OUTFIT, new FolderEntry("outfit", FALSE)); addEntry(LLFolderType::FT_MY_OUTFITS, new FolderEntry("my_otfts", TRUE)); + + addEntry(LLFolderType::FT_MESH, new FolderEntry("mesh", TRUE)); + addEntry(LLFolderType::FT_INBOX, new FolderEntry("inbox", TRUE)); + addEntry(LLFolderType::FT_OUTBOX, new FolderEntry("outbox", TRUE)); + addEntry(LLFolderType::FT_BASIC_ROOT, new FolderEntry("basic_rt", TRUE)); addEntry(LLFolderType::FT_NONE, new FolderEntry("-1", FALSE)); }; diff --git a/indra/llcommon/llfoldertype.h b/indra/llcommon/llfoldertype.h index e0ce9fa3f..7e7cfa2b9 100644 --- a/indra/llcommon/llfoldertype.h +++ b/indra/llcommon/llfoldertype.h @@ -87,9 +87,14 @@ public: FT_OUTFIT = 47, FT_MY_OUTFITS = 48, - FT_INBOX = 49, + FT_MESH = 49, - FT_COUNT = 50, + FT_INBOX = 50, + FT_OUTBOX = 51, + + FT_BASIC_ROOT = 52, + + FT_COUNT, FT_NONE = -1 }; diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index e4e535222..46c72455a 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -49,6 +49,7 @@ class LL_COMMON_API LLInstanceTrackerBase : public boost::noncopyable protected: static void * & getInstances(std::type_info const & info); }; + /// This mix-in class adds support for tracking all instances of the specified class parameter T /// The (optional) key associates a value of type KEY with a given instance of T, for quick lookup /// If KEY is not provided, then instances are stored in a simple set @@ -58,13 +59,80 @@ class LLInstanceTracker : public LLInstanceTrackerBase { typedef typename std::map InstanceMap; typedef LLInstanceTracker MyT; - typedef boost::function KeyGetter; - typedef boost::function InstancePtrGetter; public: - /// Dereferencing key_iter gives you a const KEY& - typedef boost::transform_iterator key_iter; - /// Dereferencing instance_iter gives you a T& - typedef boost::indirect_iterator< boost::transform_iterator > instance_iter; + class instance_iter : public boost::iterator_facade + { + public: + typedef boost::iterator_facade super_t; + + instance_iter(const typename InstanceMap::iterator& it) + : mIterator(it) + { + ++sIterationNestDepth; + } + + ~instance_iter() + { + --sIterationNestDepth; + } + + + private: + friend class boost::iterator_core_access; + + void increment() { mIterator++; } + bool equal(instance_iter const& other) const + { + return mIterator == other.mIterator; + } + + T& dereference() const + { + return *(mIterator->second); + } + + typename InstanceMap::iterator mIterator; + }; + + class key_iter : public boost::iterator_facade + { + public: + typedef boost::iterator_facade super_t; + + key_iter(typename InstanceMap::iterator it) + : mIterator(it) + { + ++sIterationNestDepth; + } + + key_iter(const key_iter& other) + : mIterator(other.mIterator) + { + ++sIterationNestDepth; + } + + ~key_iter() + { + --sIterationNestDepth; + } + + + private: + friend class boost::iterator_core_access; + + void increment() { mIterator++; } + bool equal(key_iter const& other) const + { + return mIterator == other.mIterator; + } + + KEY& dereference() const + { + return const_cast(mIterator->first); + } + + typename InstanceMap::iterator mIterator; + }; static T* getInstance(const KEY& k) { @@ -72,42 +140,47 @@ public: return (found == getMap_().end()) ? NULL : found->second; } + static instance_iter beginInstances() + { + return instance_iter(getMap_().begin()); + } + + static instance_iter endInstances() + { + return instance_iter(getMap_().end()); + } + + static S32 instanceCount() { return getMap_().size(); } + static key_iter beginKeys() { - return boost::make_transform_iterator(getMap_().begin(), - boost::bind(&InstanceMap::value_type::first, _1)); + return key_iter(getMap_().begin()); } static key_iter endKeys() { - return boost::make_transform_iterator(getMap_().end(), - boost::bind(&InstanceMap::value_type::first, _1)); + return key_iter(getMap_().end()); } - static instance_iter beginInstances() - { - return instance_iter(boost::make_transform_iterator(getMap_().begin(), - boost::bind(&InstanceMap::value_type::second, _1))); - } - static instance_iter endInstances() - { - return instance_iter(boost::make_transform_iterator(getMap_().end(), - boost::bind(&InstanceMap::value_type::second, _1))); - } - static S32 instanceCount() { return getMap_().size(); } + protected: LLInstanceTracker(KEY key) { add_(key); } - virtual ~LLInstanceTracker() { remove_(); } + virtual ~LLInstanceTracker() + { + // it's unsafe to delete instances of this type while all instances are being iterated over. + llassert(sIterationNestDepth == 0); + remove_(); + } virtual void setKey(KEY key) { remove_(); add_(key); } - virtual const KEY& getKey() const { return mKey; } + virtual const KEY& getKey() const { return mInstanceKey; } private: void add_(KEY key) { - mKey = key; + mInstanceKey = key; getMap_()[key] = static_cast(this); } void remove_() { - getMap_().erase(mKey); + getMap_().erase(mInstanceKey); } static InstanceMap& getMap_() @@ -122,9 +195,12 @@ private: private: - KEY mKey; + KEY mInstanceKey; + static S32 sIterationNestDepth; }; +template S32 LLInstanceTracker::sIterationNestDepth = 0; + /// explicit specialization for default case where KEY is T* /// use a simple std::set template @@ -133,42 +209,55 @@ class LLInstanceTracker : public LLInstanceTrackerBase typedef typename std::set InstanceSet; typedef LLInstanceTracker MyT; public: - /// Dereferencing key_iter gives you a T* (since T* is the key) - typedef typename InstanceSet::iterator key_iter; - /// Dereferencing instance_iter gives you a T& - typedef boost::indirect_iterator instance_iter; /// for completeness of analogy with the generic implementation static T* getInstance(T* k) { return k; } static S32 instanceCount() { return getSet_().size(); } - // Instantiate this to get access to iterators for this type. It's a 'guard' in the sense - // that it treats deletes of this type as errors as long as there is an instance of - // this class alive in scope somewhere (i.e. deleting while iterating is bad). - class LLInstanceTrackerScopedGuard + class instance_iter : public boost::iterator_facade { public: - LLInstanceTrackerScopedGuard() + instance_iter(const typename InstanceSet::iterator& it) + : mIterator(it) { ++sIterationNestDepth; } - ~LLInstanceTrackerScopedGuard() + instance_iter(const instance_iter& other) + : mIterator(other.mIterator) + { + ++sIterationNestDepth; + } + + ~instance_iter() { --sIterationNestDepth; } - static instance_iter beginInstances() { return instance_iter(getSet_().begin()); } - static instance_iter endInstances() { return instance_iter(getSet_().end()); } - static key_iter beginKeys() { return getSet_().begin(); } - static key_iter endKeys() { return getSet_().end(); } + private: + friend class boost::iterator_core_access; + + void increment() { mIterator++; } + bool equal(instance_iter const& other) const + { + return mIterator == other.mIterator; + } + + T& dereference() const + { + return **mIterator; + } + + typename InstanceSet::iterator mIterator; }; + static instance_iter beginInstances() { return instance_iter(getSet_().begin()); } + static instance_iter endInstances() { return instance_iter(getSet_().end()); } + protected: LLInstanceTracker() { // it's safe but unpredictable to create instances of this type while all instances are being iterated over. I hate unpredictable. This assert will probably be turned on early in the next development cycle. - //llassert(sIterationNestDepth == 0); getSet_().insert(static_cast(this)); } virtual ~LLInstanceTracker() @@ -180,7 +269,6 @@ protected: LLInstanceTracker(const LLInstanceTracker& other) { - //llassert(sIterationNestDepth == 0); getSet_().insert(static_cast(this)); } diff --git a/indra/llcommon/llkeythrottle.h b/indra/llcommon/llkeythrottle.h index 873f50a65..4ac689163 100644 --- a/indra/llcommon/llkeythrottle.h +++ b/indra/llcommon/llkeythrottle.h @@ -118,6 +118,62 @@ public: THROTTLE_BLOCKED, // rate exceed, block key }; + F64 getActionCount(const T& id) + { + U64 now = 0; + if ( mIsRealtime ) + { + now = LLKeyThrottleImpl::getTime(); + } + else + { + now = LLKeyThrottleImpl::getFrame(); + } + + if (now >= (m.startTime + m.intervalLength)) + { + if (now < (m.startTime + 2 * m.intervalLength)) + { + // prune old data + delete m.prevMap; + m.prevMap = m.currMap; + m.currMap = new typename LLKeyThrottleImpl::EntryMap; + + m.startTime += m.intervalLength; + } + else + { + // lots of time has passed, all data is stale + delete m.prevMap; + delete m.currMap; + m.prevMap = new typename LLKeyThrottleImpl::EntryMap; + m.currMap = new typename LLKeyThrottleImpl::EntryMap; + + m.startTime = now; + } + } + + U32 prevCount = 0; + + typename LLKeyThrottleImpl::EntryMap::const_iterator prev = m.prevMap->find(id); + if (prev != m.prevMap->end()) + { + prevCount = prev->second.count; + } + + typename LLKeyThrottleImpl::Entry& curr = (*m.currMap)[id]; + + // curr.count is the number of keys in + // this current 'time slice' from the beginning of it until now + // prevCount is the number of keys in the previous + // time slice scaled to be one full time slice back from the current + // (now) time. + + // compute current, windowed rate + F64 timeInCurrent = ((F64)(now - m.startTime) / m.intervalLength); + F64 averageCount = curr.count + prevCount * (1.0 - timeInCurrent); + return averageCount; + } // call each time the key wants use State noteAction(const T& id, S32 weight = 1) { diff --git a/indra/llcommon/lllslconstants.h b/indra/llcommon/lllslconstants.h index b7c8356ee..06af6dd29 100644 --- a/indra/llcommon/lllslconstants.h +++ b/indra/llcommon/lllslconstants.h @@ -48,6 +48,7 @@ const U32 AGENT_TYPING = 0x0200; const U32 AGENT_CROUCHING = 0x0400; const U32 AGENT_BUSY = 0x0800; const U32 AGENT_ALWAYS_RUN = 0x1000; +const U32 AGENT_AUTOPILOT = 0x2000; const S32 LSL_REMOTE_DATA_CHANNEL = 1; const S32 LSL_REMOTE_DATA_REQUEST = 2; @@ -184,6 +185,10 @@ const S32 OBJECT_VELOCITY = 5; const S32 OBJECT_OWNER = 6; const S32 OBJECT_GROUP = 7; const S32 OBJECT_CREATOR = 8; +const S32 OBJECT_RUNNING_SCRIPT_COUNT = 9; +const S32 OBJECT_TOTAL_SCRIPT_COUNT = 10; +const S32 OBJECT_SCRIPT_MEMORY = 11; +const S32 OBJECT_SCRIPT_TIME = 12; // changed() event flags const U32 CHANGED_NONE = 0x0; @@ -198,5 +203,17 @@ const U32 CHANGED_OWNER = 0x80; const U32 CHANGED_REGION = 0x100; const U32 CHANGED_TELEPORT = 0x200; const U32 CHANGED_REGION_START = 0x400; +const U32 CHANGED_MEDIA = 0x800; +// Possible error results +const U32 LSL_STATUS_OK = 0; +const U32 LSL_STATUS_MALFORMED_PARAMS = 1000; +const U32 LSL_STATUS_TYPE_MISMATCH = 1001; +const U32 LSL_STATUS_BOUNDS_ERROR = 1002; +const U32 LSL_STATUS_NOT_FOUND = 1003; +const U32 LSL_STATUS_NOT_SUPPORTED = 1004; +const U32 LSL_STATUS_INTERNAL_ERROR = 1999; + +// Start per-function errors below, starting at 2000: +const U32 LSL_STATUS_WHITELIST_FAILED = 2001; #endif diff --git a/indra/llcommon/llmortician.cpp b/indra/llcommon/llmortician.cpp index 2909f4514..c800b654b 100644 --- a/indra/llcommon/llmortician.cpp +++ b/indra/llcommon/llmortician.cpp @@ -74,9 +74,3 @@ void LLMortician::setZealous(BOOL b) { sDestroyImmediate = b; } - -// static -BOOL LLMortician::getZealous() -{ - return sDestroyImmediate; -} diff --git a/indra/llcommon/llmortician.h b/indra/llcommon/llmortician.h index 55a101a97..59d284182 100644 --- a/indra/llcommon/llmortician.h +++ b/indra/llcommon/llmortician.h @@ -46,7 +46,6 @@ public: // sets destroy immediate true static void setZealous(BOOL b); - static BOOL getZealous(); private: static BOOL sDestroyImmediate; diff --git a/indra/llcommon/llpreprocessor.h b/indra/llcommon/llpreprocessor.h index df49757a6..a956718e6 100644 --- a/indra/llcommon/llpreprocessor.h +++ b/indra/llcommon/llpreprocessor.h @@ -107,7 +107,17 @@ #endif -// Deal with the differences on Windows + +// Static linking with apr on windows needs to be declared. +#if LL_WINDOWS && !LL_COMMON_LINK_SHARED +#ifndef APR_DECLARE_STATIC +#define APR_DECLARE_STATIC // For APR on Windows +#endif +#ifndef APU_DECLARE_STATIC +#define APU_DECLARE_STATIC // For APR util on Windows +#endif +#endif + #if defined(LL_WINDOWS) #define BOOST_REGEX_NO_LIB 1 #define CURL_STATICLIB 1 @@ -159,12 +169,19 @@ #define LL_DLLIMPORT #endif // LL_WINDOWS -#ifdef llcommon_EXPORTS -// Compiling llcommon (shared) -#define LL_COMMON_API LL_DLLEXPORT -#else // llcommon_EXPORTS -// Using llcommon (shared) -#define LL_COMMON_API LL_DLLIMPORT -#endif // llcommon_EXPORTS +#if LL_COMMON_LINK_SHARED +// CMake automagically defines llcommon_EXPORTS only when building llcommon +// sources, and only when llcommon is a shared library (i.e. when +// LL_COMMON_LINK_SHARED). We must still test LL_COMMON_LINK_SHARED because +// otherwise we can't distinguish between (non-llcommon source) and (llcommon +// not shared). +# if defined(llcommon_EXPORTS) +# define LL_COMMON_API LL_DLLEXPORT +# else //llcommon_EXPORTS +# define LL_COMMON_API LL_DLLIMPORT +# endif //llcommon_EXPORTS +#else // LL_COMMON_LINK_SHARED +# define LL_COMMON_API +#endif // LL_COMMON_LINK_SHARED #endif // not LL_LINDEN_PREPROCESSOR_H diff --git a/indra/llcommon/llprocesslauncher.cpp b/indra/llcommon/llprocesslauncher.cpp index b6d410da9..6a6854aa6 100644 --- a/indra/llcommon/llprocesslauncher.cpp +++ b/indra/llcommon/llprocesslauncher.cpp @@ -102,7 +102,7 @@ int LLProcessLauncher::launch(void) STARTUPINFOA sinfo; memset(&sinfo, 0, sizeof(sinfo)); - std::string args = "\"" + mExecutable + "\""; + std::string args = mExecutable; for(int i = 0; i < (int)mLaunchArguments.size(); i++) { args += " "; @@ -114,10 +114,30 @@ int LLProcessLauncher::launch(void) char *args2 = new char[args.size() + 1]; strcpy(args2, args.c_str()); - if( ! CreateProcessA( NULL, args2, NULL, NULL, FALSE, 0, NULL, NULL, &sinfo, &pinfo ) ) + const char * working_directory = 0; + if(!mWorkingDir.empty()) working_directory = mWorkingDir.c_str(); + if( ! CreateProcessA( NULL, args2, NULL, NULL, FALSE, 0, NULL, working_directory, &sinfo, &pinfo ) ) { - // TODO: do better than returning the OS-specific error code on failure... result = GetLastError(); + + LPTSTR error_str = 0; + if( + FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + result, + 0, + (LPTSTR)&error_str, + 0, + NULL) + != 0) + { + char message[256]; + wcstombs(message, error_str, 256); + message[255] = 0; + llwarns << "CreateProcessA failed: " << message << llendl; + LocalFree(error_str); + } + if(result == 0) { // Make absolutely certain we return a non-zero value on failure. diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index c88909eb2..2325efc38 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -31,8 +31,9 @@ #include "linden_common.h" #include "llqueuedthread.h" + #include "llstl.h" -#include "lltimer.h" +#include "lltimer.h" // ms_sleep() //============================================================================ diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index ba7901cdb..7086e4248 100644 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -754,11 +754,7 @@ void LLSD::insert(const String& k, const LLSD& v) { makeMap(impl).insert(k, v); LLSD& LLSD::with(const String& k, const LLSD& v) { makeMap(impl).insert(k, v); - #ifdef LL_MSVC7 - return *dynamic_cast(this); - #else - return *this; - #endif + return *this; } void LLSD::erase(const String& k) { makeMap(impl).erase(k); } @@ -784,11 +780,7 @@ void LLSD::insert(Integer i, const LLSD& v) { makeArray(impl).insert(i, v); } LLSD& LLSD::with(Integer i, const LLSD& v) { makeArray(impl).insert(i, v); - #ifdef LL_MSVC7 - return *dynamic_cast(this); - #else - return *this; - #endif + return *this; } void LLSD::append(const LLSD& v) { makeArray(impl).append(v); } void LLSD::erase(Integer i) { makeArray(impl).erase(i); } diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp index cc0307a7a..28700faae 100644 --- a/indra/llcommon/llsdserialize.cpp +++ b/indra/llcommon/llsdserialize.cpp @@ -34,7 +34,7 @@ #include "linden_common.h" #include "llsdserialize.h" -#include "llmemory.h" +#include "llpointer.h" #include "llstreamtools.h" // for fullread #include diff --git a/indra/llcommon/llsdserialize.h b/indra/llcommon/llsdserialize.h index aed844fee..6f657b464 100644 --- a/indra/llcommon/llsdserialize.h +++ b/indra/llcommon/llsdserialize.h @@ -36,8 +36,9 @@ #define LL_LLSDSERIALIZE_H #include +#include "llpointer.h" +#include "llrefcount.h" #include "llsd.h" -#include "llmemory.h" /** * @class LLSDParser diff --git a/indra/llcommon/llsdserialize_xml.cpp b/indra/llcommon/llsdserialize_xml.cpp index 33206b46d..9bc17e0aa 100644 --- a/indra/llcommon/llsdserialize_xml.cpp +++ b/indra/llcommon/llsdserialize_xml.cpp @@ -37,6 +37,7 @@ #include #include "apr_base64.h" +#include extern "C" { @@ -734,6 +735,7 @@ void LLSDXMLParser::Impl::endElementHandler(const XML_Char* name) case ELEMENT_INTEGER: { S32 i; + // sscanf okay here with different locales - ints don't change for different locale settings like floats do. if ( sscanf(mCurrentContent.c_str(), "%d", &i ) == 1 ) { // See if sscanf works - it's faster value = i; @@ -747,15 +749,19 @@ void LLSDXMLParser::Impl::endElementHandler(const XML_Char* name) case ELEMENT_REAL: { - F64 r; - if ( sscanf(mCurrentContent.c_str(), "%lf", &r ) == 1 ) - { // See if sscanf works - it's faster - value = r; - } - else - { - value = LLSD(mCurrentContent).asReal(); - } + value = LLSD(mCurrentContent).asReal(); + // removed since this breaks when locale has decimal separator that isn't '.' + // investigated changing local to something compatible each time but deemed higher + // risk that just using LLSD.asReal() each time. + //F64 r; + //if ( sscanf(mCurrentContent.c_str(), "%lf", &r ) == 1 ) + //{ // See if sscanf works - it's faster + // value = r; + //} + //else + //{ + // value = LLSD(mCurrentContent).asReal(); + //} } break; @@ -777,10 +783,17 @@ void LLSDXMLParser::Impl::endElementHandler(const XML_Char* name) case ELEMENT_BINARY: { - S32 len = apr_base64_decode_len(mCurrentContent.c_str()); + // Regex is expensive, but only fix for whitespace in base64, + // created by python and other non-linden systems - DEV-39358 + // Fortunately we have very little binary passing now, + // so performance impact shold be negligible. + poppy 2009-09-04 + boost::regex r; + r.assign("\\s"); + std::string stripped = boost::regex_replace(mCurrentContent, r, ""); + S32 len = apr_base64_decode_len(stripped.c_str()); std::vector data; data.resize(len); - len = apr_base64_decode_binary(&data[0], mCurrentContent.c_str()); + len = apr_base64_decode_binary(&data[0], stripped.c_str()); data.resize(len); value = data; break; diff --git a/indra/llcommon/llsdutil.cpp b/indra/llcommon/llsdutil.cpp index aa0e0f369..2c91b68ef 100644 --- a/indra/llcommon/llsdutil.cpp +++ b/indra/llcommon/llsdutil.cpp @@ -46,6 +46,12 @@ #endif #include "llsdserialize.h" +#include "stringize.h" +#include "is_approx_equal_fraction.h" + +#include +#include +#include // U32 LLSD ll_sd_from_U32(const U32 val) @@ -171,6 +177,15 @@ char* ll_print_sd(const LLSD& sd) return buffer; } +char* ll_pretty_print_sd_ptr(const LLSD* sd) +{ + if (sd) + { + return ll_pretty_print_sd(*sd); + } + return NULL; +} + char* ll_pretty_print_sd(const LLSD& sd) { const U32 bufferSize = 10 * 1024; @@ -304,3 +319,363 @@ BOOL compare_llsd_with_template( return TRUE; } + +/***************************************************************************** +* Helpers for llsd_matches() +*****************************************************************************/ +// raw data used for LLSD::Type lookup +struct Data +{ + LLSD::Type type; + const char* name; +} typedata[] = +{ +#define def(type) { LLSD::type, #type + 4 } + def(TypeUndefined), + def(TypeBoolean), + def(TypeInteger), + def(TypeReal), + def(TypeString), + def(TypeUUID), + def(TypeDate), + def(TypeURI), + def(TypeBinary), + def(TypeMap), + def(TypeArray) +#undef def +}; + +// LLSD::Type lookup class into which we load the above static data +class TypeLookup +{ + typedef std::map MapType; + +public: + TypeLookup() + { + for (const Data *di(boost::begin(typedata)), *dend(boost::end(typedata)); di != dend; ++di) + { + mMap[di->type] = di->name; + } + } + + std::string lookup(LLSD::Type type) const + { + MapType::const_iterator found = mMap.find(type); + if (found != mMap.end()) + { + return found->second; + } + return STRINGIZE(""); + } + +private: + MapType mMap; +}; + +// static instance of the lookup class +static const TypeLookup sTypes; + +// describe a mismatch; phrasing may want tweaking +const std::string op(" required instead of "); + +// llsd_matches() wants to identify specifically where in a complex prototype +// structure the mismatch occurred. This entails passing a prefix string, +// empty for the top-level call. If the prototype contains an array of maps, +// and the mismatch occurs in the second map in a key 'foo', we want to +// decorate the returned string with: "[1]['foo']: etc." On the other hand, we +// want to omit the entire prefix -- including colon -- if the mismatch is at +// top level. This helper accepts the (possibly empty) recursively-accumulated +// prefix string, returning either empty or the original string with colon +// appended. +static std::string colon(const std::string& pfx) +{ + if (pfx.empty()) + return pfx; + return pfx + ": "; +} + +// param type for match_types +typedef std::vector TypeVector; + +// The scalar cases in llsd_matches() use this helper. In most cases, we can +// accept not only the exact type specified in the prototype, but also other +// types convertible to the expected type. That implies looping over an array +// of such types. If the actual type doesn't match any of them, we want to +// provide a list of acceptable conversions as well as the exact type, e.g.: +// "Integer (or Boolean, Real, String) required instead of UUID". Both the +// implementation and the calling logic are simplified by separating out the +// expected type from the convertible types. +static std::string match_types(LLSD::Type expect, // prototype.type() + const TypeVector& accept, // types convertible to that type + LLSD::Type actual, // type we're checking + const std::string& pfx) // as for llsd_matches +{ + // Trivial case: if the actual type is exactly what we expect, we're good. + if (actual == expect) + return ""; + + // For the rest of the logic, build up a suitable error string as we go so + // we only have to make a single pass over the list of acceptable types. + // If we detect success along the way, we'll simply discard the partial + // error string. + std::ostringstream out; + out << colon(pfx) << sTypes.lookup(expect); + + // If there are any convertible types, append that list. + if (! accept.empty()) + { + out << " ("; + const char* sep = "or "; + for (TypeVector::const_iterator ai(accept.begin()), aend(accept.end()); + ai != aend; ++ai, sep = ", ") + { + // Don't forget to return success if we match any of those types... + if (actual == *ai) + return ""; + out << sep << sTypes.lookup(*ai); + } + out << ')'; + } + // If we got this far, it's because 'actual' was not one of the acceptable + // types, so we must return an error. 'out' already contains colon(pfx) + // and the formatted list of acceptable types, so just append the mismatch + // phrase and the actual type. + out << op << sTypes.lookup(actual); + return out.str(); +} + +// see docstring in .h file +std::string llsd_matches(const LLSD& prototype, const LLSD& data, const std::string& pfx) +{ + // An undefined prototype means that any data is valid. + // An undefined slot in an array or map prototype means that any data + // may fill that slot. + if (prototype.isUndefined()) + return ""; + // A prototype array must match a data array with at least as many + // entries. Moreover, every prototype entry must match the + // corresponding data entry. + if (prototype.isArray()) + { + if (! data.isArray()) + { + return STRINGIZE(colon(pfx) << "Array" << op << sTypes.lookup(data.type())); + } + if (data.size() < prototype.size()) + { + return STRINGIZE(colon(pfx) << "Array size " << prototype.size() << op + << "Array size " << data.size()); + } + for (LLSD::Integer i = 0; i < prototype.size(); ++i) + { + std::string match(llsd_matches(prototype[i], data[i], STRINGIZE('[' << i << ']'))); + if (! match.empty()) + { + return match; + } + } + return ""; + } + // A prototype map must match a data map. Every key in the prototype + // must have a corresponding key in the data map; every value in the + // prototype must match the corresponding key's value in the data. + if (prototype.isMap()) + { + if (! data.isMap()) + { + return STRINGIZE(colon(pfx) << "Map" << op << sTypes.lookup(data.type())); + } + // If there are a number of keys missing from the data, it would be + // frustrating to a coder to discover them one at a time, with a big + // build each time. Enumerate all missing keys. + std::ostringstream out; + out << colon(pfx); + const char* init = "Map missing keys: "; + const char* sep = init; + for (LLSD::map_const_iterator mi = prototype.beginMap(); mi != prototype.endMap(); ++mi) + { + if (! data.has(mi->first)) + { + out << sep << mi->first; + sep = ", "; + } + } + // So... are we missing any keys? + if (sep != init) + { + return out.str(); + } + // Good, the data block contains all the keys required by the + // prototype. Now match the prototype entries. + for (LLSD::map_const_iterator mi2 = prototype.beginMap(); mi2 != prototype.endMap(); ++mi2) + { + std::string match(llsd_matches(mi2->second, data[mi2->first], + STRINGIZE("['" << mi2->first << "']"))); + if (! match.empty()) + { + return match; + } + } + return ""; + } + // A String prototype can match String, Boolean, Integer, Real, UUID, + // Date and URI, because any of these can be converted to String. + if (prototype.isString()) + { + static LLSD::Type accept[] = + { + LLSD::TypeBoolean, + LLSD::TypeInteger, + LLSD::TypeReal, + LLSD::TypeUUID, + LLSD::TypeDate, + LLSD::TypeURI + }; + return match_types(prototype.type(), + TypeVector(boost::begin(accept), boost::end(accept)), + data.type(), + pfx); + } + // Boolean, Integer, Real match each other or String. TBD: ensure that + // a String value is numeric. + if (prototype.isBoolean() || prototype.isInteger() || prototype.isReal()) + { + static LLSD::Type all[] = + { + LLSD::TypeBoolean, + LLSD::TypeInteger, + LLSD::TypeReal, + LLSD::TypeString + }; + // Funny business: shuffle the set of acceptable types to include all + // but the prototype's type. Get the acceptable types in a set. + std::set rest(boost::begin(all), boost::end(all)); + // Remove the prototype's type because we pass that separately. + rest.erase(prototype.type()); + return match_types(prototype.type(), + TypeVector(rest.begin(), rest.end()), + data.type(), + pfx); + } + // UUID, Date and URI match themselves or String. + if (prototype.isUUID() || prototype.isDate() || prototype.isURI()) + { + static LLSD::Type accept[] = + { + LLSD::TypeString + }; + return match_types(prototype.type(), + TypeVector(boost::begin(accept), boost::end(accept)), + data.type(), + pfx); + } + // We don't yet know the conversion semantics associated with any new LLSD + // data type that might be added, so until we've been extended to handle + // them, assume it's strict: the new type matches only itself. (This is + // true of Binary, which is why we don't handle that case separately.) Too + // bad LLSD doesn't define isConvertible(Type to, Type from). + return match_types(prototype.type(), TypeVector(), data.type(), pfx); +} + +bool llsd_equals(const LLSD& lhs, const LLSD& rhs, unsigned bits) +{ + // We're comparing strict equality of LLSD representation rather than + // performing any conversions. So if the types aren't equal, the LLSD + // values aren't equal. + if (lhs.type() != rhs.type()) + { + return false; + } + + // Here we know both types are equal. Now compare values. + switch (lhs.type()) + { + case LLSD::TypeUndefined: + // Both are TypeUndefined. There's nothing more to know. + return true; + + case LLSD::TypeReal: + // This is where the 'bits' argument comes in handy. If passed + // explicitly, it means to use is_approx_equal_fraction() to compare. + if (bits >= 0) + { + return is_approx_equal_fraction(lhs.asReal(), rhs.asReal(), bits); + } + // Otherwise we compare bit representations, and the usual caveats + // about comparing floating-point numbers apply. Omitting 'bits' when + // comparing Real values is only useful when we expect identical bit + // representation for a given Real value, e.g. for integer-valued + // Reals. + return (lhs.asReal() == rhs.asReal()); + +#define COMPARE_SCALAR(type) \ + case LLSD::Type##type: \ + /* LLSD::URI has operator!=() but not operator==() */ \ + /* rely on the optimizer for all others */ \ + return (! (lhs.as##type() != rhs.as##type())) + + COMPARE_SCALAR(Boolean); + COMPARE_SCALAR(Integer); + COMPARE_SCALAR(String); + COMPARE_SCALAR(UUID); + COMPARE_SCALAR(Date); + COMPARE_SCALAR(URI); + COMPARE_SCALAR(Binary); + +#undef COMPARE_SCALAR + + case LLSD::TypeArray: + { + LLSD::array_const_iterator + lai(lhs.beginArray()), laend(lhs.endArray()), + rai(rhs.beginArray()), raend(rhs.endArray()); + // Compare array elements, walking the two arrays in parallel. + for ( ; lai != laend && rai != raend; ++lai, ++rai) + { + // If any one array element is unequal, the arrays are unequal. + if (! llsd_equals(*lai, *rai, bits)) + return false; + } + // Here we've reached the end of one or the other array. They're equal + // only if they're BOTH at end: that is, if they have equal length too. + return (lai == laend && rai == raend); + } + + case LLSD::TypeMap: + { + // Build a set of all rhs keys. + std::set rhskeys; + for (LLSD::map_const_iterator rmi(rhs.beginMap()), rmend(rhs.endMap()); + rmi != rmend; ++rmi) + { + rhskeys.insert(rmi->first); + } + // Now walk all the lhs keys. + for (LLSD::map_const_iterator lmi(lhs.beginMap()), lmend(lhs.endMap()); + lmi != lmend; ++lmi) + { + // Try to erase this lhs key from the set of rhs keys. If rhs has + // no such key, the maps are unequal. erase(key) returns count of + // items erased. + if (rhskeys.erase(lmi->first) != 1) + return false; + // Both maps have the current key. Compare values. + if (! llsd_equals(lmi->second, rhs[lmi->first], bits)) + return false; + } + // We've now established that all the lhs keys have equal values in + // both maps. The maps are equal unless rhs contains a superset of + // those keys. + return rhskeys.empty(); + } + + default: + // We expect that every possible type() value is specifically handled + // above. Failing to extend this switch to support a new LLSD type is + // an error that must be brought to the coder's attention. + LL_ERRS("llsd_equals") << "llsd_equals(" << lhs << ", " << rhs << ", " << bits << "): " + "unknown type " << lhs.type() << LL_ENDL; + return false; // pacify the compiler + } +} diff --git a/indra/llcommon/llsdutil.h b/indra/llcommon/llsdutil.h index bb5765539..f57cab3e0 100644 --- a/indra/llcommon/llsdutil.h +++ b/indra/llcommon/llsdutil.h @@ -35,7 +35,7 @@ #ifndef LL_LLSDUTIL_H #define LL_LLSDUTIL_H -#include "llsd.h" +class LLSD; // U32 LL_COMMON_API LLSD ll_sd_from_U32(const U32); @@ -59,6 +59,7 @@ LL_COMMON_API LLSD ll_binary_from_string(const LLSD& sd); LL_COMMON_API char* ll_print_sd(const LLSD& sd); // Serializes sd to static buffer and returns pointer, using "pretty printing" mode. +LL_COMMON_API char* ll_pretty_print_sd_ptr(const LLSD* sd); LL_COMMON_API char* ll_pretty_print_sd(const LLSD& sd); //compares the structure of an LLSD to a template LLSD and stores the @@ -73,6 +74,66 @@ LL_COMMON_API BOOL compare_llsd_with_template( const LLSD& template_llsd, LLSD& resultant_llsd); +/** + * Recursively determine whether a given LLSD data block "matches" another + * LLSD prototype. The returned string is empty() on success, non-empty() on + * mismatch. + * + * This function tests structure (types) rather than data values. It is + * intended for when a consumer expects an LLSD block with a particular + * structure, and must succinctly detect whether the arriving block is + * well-formed. For instance, a test of the form: + * @code + * if (! (data.has("request") && data.has("target") && data.has("modifier") ...)) + * @endcode + * could instead be expressed by initializing a prototype LLSD map with the + * required keys and writing: + * @code + * if (! llsd_matches(prototype, data).empty()) + * @endcode + * + * A non-empty return value is an error-message fragment intended to indicate + * to (English-speaking) developers where in the prototype structure the + * mismatch occurred. + * + * * If a slot in the prototype isUndefined(), then anything is valid at that + * place in the real object. (Passing prototype == LLSD() matches anything + * at all.) + * * An array in the prototype must match a data array at least that large. + * (Additional entries in the data array are ignored.) Every isDefined() + * entry in the prototype array must match the corresponding entry in the + * data array. + * * A map in the prototype must match a map in the data. Every key in the + * prototype map must match a corresponding key in the data map. (Additional + * keys in the data map are ignored.) Every isDefined() value in the + * prototype map must match the corresponding key's value in the data map. + * * Scalar values in the prototype are tested for @em type rather than value. + * For instance, a String in the prototype matches any String at all. In + * effect, storing an Integer at a particular place in the prototype asserts + * that the caller intends to apply asInteger() to the corresponding slot in + * the data. + * * A String in the prototype matches String, Boolean, Integer, Real, UUID, + * Date and URI, because asString() applied to any of these produces a + * meaningful result. + * * Similarly, a Boolean, Integer or Real in the prototype can match any of + * Boolean, Integer or Real in the data -- or even String. + * * UUID matches UUID or String. + * * Date matches Date or String. + * * URI matches URI or String. + * * Binary in the prototype matches only Binary in the data. + * + * @TODO: when a Boolean, Integer or Real in the prototype matches a String in + * the data, we should examine the String @em value to ensure it can be + * meaningfully converted to the requested type. The same goes for UUID, Date + * and URI. + */ +LL_COMMON_API std::string llsd_matches(const LLSD& prototype, const LLSD& data, const std::string& pfx=""); + +/// Deep equality. If you want to compare LLSD::Real values for approximate +/// equality rather than bitwise equality, pass @a bits as for +/// is_approx_equal_fraction(). +LL_COMMON_API bool llsd_equals(const LLSD& lhs, const LLSD& rhs, unsigned bits=-1); + // Simple function to copy data out of input & output iterators if // there is no need for casting. template LLSD llsd_copy_array(Input iter, Input end) @@ -85,4 +146,283 @@ template LLSD llsd_copy_array(Input iter, Input end) return dest; } +/***************************************************************************** +* LLSDArray +*****************************************************************************/ +/** + * Construct an LLSD::Array inline, with implicit conversion to LLSD. Usage: + * + * @code + * void somefunc(const LLSD&); + * ... + * somefunc(LLSDArray("text")(17)(3.14)); + * @endcode + * + * For completeness, LLSDArray() with no args constructs an empty array, so + * LLSDArray()("text")(17)(3.14) produces an array equivalent to the + * above. But for most purposes, LLSD() is already equivalent to an empty + * array, and if you explicitly want an empty isArray(), there's + * LLSD::emptyArray(). However, supporting a no-args LLSDArray() constructor + * follows the principle of least astonishment. + */ +class LLSDArray +{ +public: + LLSDArray(): + _data(LLSD::emptyArray()) + {} + + /** + * Need an explicit copy constructor. Consider the following: + * + * @code + * LLSD array_of_arrays(LLSDArray(LLSDArray(17)(34)) + * (LLSDArray("x")("y"))); + * @endcode + * + * The coder intends to construct [[17, 34], ["x", "y"]]. + * + * With the compiler's implicit copy constructor, s/he gets instead + * [17, 34, ["x", "y"]]. + * + * The expression LLSDArray(17)(34) constructs an LLSDArray with those two + * values. The reader assumes it should be converted to LLSD, as we always + * want with LLSDArray, before passing it to the @em outer LLSDArray + * constructor! This copy constructor makes that happen. + */ + LLSDArray(const LLSDArray& inner): + _data(LLSD::emptyArray()) + { + _data.append(inner); + } + + LLSDArray(const LLSD& value): + _data(LLSD::emptyArray()) + { + _data.append(value); + } + + LLSDArray& operator()(const LLSD& value) + { + _data.append(value); + return *this; + } + + operator LLSD() const { return _data; } + LLSD get() const { return _data; } + +private: + LLSD _data; +}; + +/***************************************************************************** +* LLSDMap +*****************************************************************************/ +/** + * Construct an LLSD::Map inline, with implicit conversion to LLSD. Usage: + * + * @code + * void somefunc(const LLSD&); + * ... + * somefunc(LLSDMap("alpha", "abc")("number", 17)("pi", 3.14)); + * @endcode + * + * For completeness, LLSDMap() with no args constructs an empty map, so + * LLSDMap()("alpha", "abc")("number", 17)("pi", 3.14) produces a map + * equivalent to the above. But for most purposes, LLSD() is already + * equivalent to an empty map, and if you explicitly want an empty isMap(), + * there's LLSD::emptyMap(). However, supporting a no-args LLSDMap() + * constructor follows the principle of least astonishment. + */ +class LLSDMap +{ +public: + LLSDMap(): + _data(LLSD::emptyMap()) + {} + LLSDMap(const LLSD::String& key, const LLSD& value): + _data(LLSD::emptyMap()) + { + _data[key] = value; + } + + LLSDMap& operator()(const LLSD::String& key, const LLSD& value) + { + _data[key] = value; + return *this; + } + + operator LLSD() const { return _data; } + LLSD get() const { return _data; } + +private: + LLSD _data; +}; + +/***************************************************************************** +* LLSDParam +*****************************************************************************/ +/** + * LLSDParam is a customization point for passing LLSD values to function + * parameters of more or less arbitrary type. LLSD provides a small set of + * native conversions; but if a generic algorithm explicitly constructs an + * LLSDParam object in the function's argument list, a consumer can provide + * LLSDParam specializations to support more different parameter types than + * LLSD's native conversions. + * + * Usage: + * + * @code + * void somefunc(const paramtype&); + * ... + * somefunc(..., LLSDParam(someLLSD), ...); + * @endcode + */ +template +class LLSDParam +{ +public: + /** + * Default implementation converts to T on construction, saves converted + * value for later retrieval + */ + LLSDParam(const LLSD& value): + _value(value) + {} + + operator T() const { return _value; } + +private: + T _value; +}; + +/** + * Turns out that several target types could accept an LLSD param using any of + * a few different conversions, e.g. LLUUID's constructor can accept LLUUID or + * std::string. Therefore, the compiler can't decide which LLSD conversion + * operator to choose, even though to us it seems obvious. But that's okay, we + * can specialize LLSDParam for such target types, explicitly specifying the + * desired conversion -- that's part of what LLSDParam is all about. Turns out + * we have to do that enough to make it worthwhile generalizing. Use a macro + * because I need to specify one of the asReal, etc., explicit conversion + * methods as well as a type. If I'm overlooking a clever way to implement + * that using a template instead, feel free to reimplement. + */ +#define LLSDParam_for(T, AS) \ +template <> \ +class LLSDParam \ +{ \ +public: \ + LLSDParam(const LLSD& value): \ + _value(value.AS()) \ + {} \ + \ + operator T() const { return _value; } \ + \ +private: \ + T _value; \ +} + +LLSDParam_for(float, asReal); +LLSDParam_for(LLUUID, asUUID); +LLSDParam_for(LLDate, asDate); +LLSDParam_for(LLURI, asURI); +LLSDParam_for(LLSD::Binary, asBinary); + +/** + * LLSDParam is an example of the kind of conversion you can + * support with LLSDParam beyond native LLSD conversions. Normally you can't + * pass an LLSD object to a function accepting const char* -- but you can + * safely pass an LLSDParam(yourLLSD). + */ +template <> +class LLSDParam +{ +private: + // The difference here is that we store a std::string rather than a const + // char*. It's important that the LLSDParam object own the std::string. + std::string _value; + // We don't bother storing the incoming LLSD object, but we do have to + // distinguish whether _value is an empty string because the LLSD object + // contains an empty string or because it's isUndefined(). + bool _undefined; + +public: + LLSDParam(const LLSD& value): + _value(value), + _undefined(value.isUndefined()) + {} + + // The const char* we retrieve is for storage owned by our _value member. + // That's how we guarantee that the const char* is valid for the lifetime + // of this LLSDParam object. Constructing your LLSDParam in the argument + // list should ensure that the LLSDParam object will persist for the + // duration of the function call. + operator const char*() const + { + if (_undefined) + { + // By default, an isUndefined() LLSD object's asString() method + // will produce an empty string. But for a function accepting + // const char*, it's often important to be able to pass NULL, and + // isUndefined() seems like the best way. If you want to pass an + // empty string, you can still pass LLSD(""). Without this special + // case, though, no LLSD value could pass NULL. + return NULL; + } + return _value.c_str(); + } +}; + +namespace llsd +{ + +/***************************************************************************** +* BOOST_FOREACH() helpers for LLSD +*****************************************************************************/ +/// Usage: BOOST_FOREACH(LLSD item, inArray(someLLSDarray)) { ... } +class inArray +{ +public: + inArray(const LLSD& array): + _array(array) + {} + + typedef LLSD::array_const_iterator const_iterator; + typedef LLSD::array_iterator iterator; + + iterator begin() { return _array.beginArray(); } + iterator end() { return _array.endArray(); } + const_iterator begin() const { return _array.beginArray(); } + const_iterator end() const { return _array.endArray(); } + +private: + LLSD _array; +}; + +/// MapEntry is what you get from dereferencing an LLSD::map_[const_]iterator. +typedef std::map::value_type MapEntry; + +/// Usage: BOOST_FOREACH([const] MapEntry& e, inMap(someLLSDmap)) { ... } +class inMap +{ +public: + inMap(const LLSD& map): + _map(map) + {} + + typedef LLSD::map_const_iterator const_iterator; + typedef LLSD::map_iterator iterator; + + iterator begin() { return _map.beginMap(); } + iterator end() { return _map.endMap(); } + const_iterator begin() const { return _map.beginMap(); } + const_iterator end() const { return _map.endMap(); } + +private: + LLSD _map; +}; + +} // namespace llsd + #endif // LL_LLSDUTIL_H diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 7aee1bb85..00757be27 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -100,12 +100,6 @@ private: DELETED } EInitState; - static void deleteSingleton() - { - delete getData().mSingletonInstance; - getData().mSingletonInstance = NULL; - } - // stores pointer to singleton instance // and tracks initialization state of singleton struct SingletonInstanceData @@ -120,7 +114,11 @@ private: ~SingletonInstanceData() { - deleteSingleton(); + SingletonInstanceData& data = getData(); + if (data.mInitState != DELETED) + { + deleteSingleton(); + } } }; @@ -132,6 +130,14 @@ public: data.mInitState = DELETED; } + // Can be used to control when the singleton is deleted. Not normally needed. + static void deleteSingleton() + { + delete getData().mSingletonInstance; + getData().mSingletonInstance = NULL; + getData().mInitState = DELETED; + } + static SingletonInstanceData& getData() { // this is static to cache the lookup results diff --git a/indra/llcommon/llstat.cpp b/indra/llcommon/llstat.cpp index 0583a0539..40ae67c51 100644 --- a/indra/llcommon/llstat.cpp +++ b/indra/llcommon/llstat.cpp @@ -43,9 +43,10 @@ // statics -BOOL LLPerfBlock::sStatsEnabled = FALSE; // Flag for detailed information +S32 LLPerfBlock::sStatsFlags = LLPerfBlock::LLSTATS_NO_OPTIONAL_STATS; // Control what is being recorded LLPerfBlock::stat_map_t LLPerfBlock::sStatMap; // Map full path string to LLStatTime objects, tracks all active objects std::string LLPerfBlock::sCurrentStatPath = ""; // Something like "/total_time/physics/physics step" +LLStat::stat_map_t LLStat::sStatList; //------------------------------------------------------------------------ // Live config file to trigger stats logging @@ -129,6 +130,7 @@ bool LLStatsConfigFile::loadFile() F32 duration = 0.f; F32 interval = 0.f; + S32 flags = LLPerfBlock::LLSTATS_BASIC_STATS; const char * w = "duration"; if (stats_config.has(w)) @@ -140,8 +142,18 @@ bool LLStatsConfigFile::loadFile() { interval = (F32)stats_config[w].asReal(); } + w = "flags"; + if (stats_config.has(w)) + { + flags = (S32)stats_config[w].asInteger(); + if (flags == LLPerfBlock::LLSTATS_NO_OPTIONAL_STATS && + duration > 0) + { // No flags passed in, but have a duration, so reset to basic stats + flags = LLPerfBlock::LLSTATS_BASIC_STATS; + } + } - mStatsp->setReportPerformanceDuration( duration ); + mStatsp->setReportPerformanceDuration( duration, flags ); mStatsp->setReportPerformanceInterval( interval ); if ( duration > 0 ) @@ -253,13 +265,14 @@ void LLPerfStats::dumpIntervalPerformanceStats() } } -// Set length of performance stat recording -void LLPerfStats::setReportPerformanceDuration( F32 seconds ) +// Set length of performance stat recording. +// If turning stats on, caller must provide flags +void LLPerfStats::setReportPerformanceDuration( F32 seconds, S32 flags /* = LLSTATS_NO_OPTIONAL_STATS */ ) { if ( seconds <= 0.f ) { mReportPerformanceStatEnd = 0.0; - LLPerfBlock::setStatsEnabled( FALSE ); + LLPerfBlock::setStatsFlags(LLPerfBlock::LLSTATS_NO_OPTIONAL_STATS); // Make sure all recording is off mFrameStatsFile.close(); LLPerfBlock::clearDynamicStats(); } @@ -268,8 +281,8 @@ void LLPerfStats::setReportPerformanceDuration( F32 seconds ) mReportPerformanceStatEnd = LLFrameTimer::getElapsedSeconds() + ((F64) seconds); // Clear failure flag to try and create the log file once mFrameStatsFileFailure = FALSE; - LLPerfBlock::setStatsEnabled( TRUE ); mSkipFirstFrameStats = TRUE; // Skip the first report (at the end of this frame) + LLPerfBlock::setStatsFlags(flags); } } @@ -611,11 +624,26 @@ LLPerfBlock::LLPerfBlock(LLStatTime* stat ) : mPredefinedStat(stat), mDynamicSta } } -// Use this constructor for dynamically created LLStatTime objects (not pre-defined) with a multi-part key. -// These are also turned on or off via the switch passed in -LLPerfBlock::LLPerfBlock( const char* key1, const char* key2 ) : mPredefinedStat(NULL), mDynamicStat(NULL) +// Use this constructor for normal, optional LLPerfBlock time slices +LLPerfBlock::LLPerfBlock( const char* key ) : mPredefinedStat(NULL), mDynamicStat(NULL) { - if (!sStatsEnabled) return; + if ((sStatsFlags & LLSTATS_BASIC_STATS) == 0) + { // These are off unless the base set is enabled + return; + } + + initDynamicStat(key); +} + + +// Use this constructor for dynamically created LLPerfBlock time slices +// that are only enabled by specific control flags +LLPerfBlock::LLPerfBlock( const char* key1, const char* key2, S32 flags ) : mPredefinedStat(NULL), mDynamicStat(NULL) +{ + if ((sStatsFlags & flags) == 0) + { + return; + } if (NULL == key2 || strlen(key2) == 0) { @@ -629,10 +657,12 @@ LLPerfBlock::LLPerfBlock( const char* key1, const char* key2 ) : mPredefinedStat } } +// Set up the result data map if dynamic stats are enabled void LLPerfBlock::initDynamicStat(const std::string& key) { // Early exit if dynamic stats aren't enabled. - if (!sStatsEnabled) return; + if (sStatsFlags == LLSTATS_NO_OPTIONAL_STATS) + return; mLastPath = sCurrentStatPath; // Save and restore current path sCurrentStatPath += "/" + key; // Add key to current path @@ -713,7 +743,7 @@ void LLPerfBlock::addStatsToLLSDandReset( LLSD & stats, } } else - { // WTF? Shouldn't have a NULL pointer in the map. + { // Shouldn't have a NULL pointer in the map. llwarns << "Unexpected NULL dynamic stat at '" << stats_full_path << "'" << llendl; } } @@ -725,14 +755,12 @@ void LLPerfBlock::addStatsToLLSDandReset( LLSD & stats, LLTimer LLStat::sTimer; LLFrameTimer LLStat::sFrameTimer; -LLStat::LLStat(const U32 num_bins, const BOOL use_frame_timer) +void LLStat::init() { - llassert(num_bins > 0); - mUseFrameTimer = use_frame_timer; + llassert(mNumBins > 0); mNumValues = 0; mLastValue = 0.f; mLastTime = 0.f; - mNumBins = num_bins; mCurBin = (mNumBins-1); mNextBin = 0; mBins = new F32[mNumBins]; @@ -746,6 +774,29 @@ LLStat::LLStat(const U32 num_bins, const BOOL use_frame_timer) mTime[i] = 0.0; mDT[i] = 0.f; } + + if (!mName.empty()) + { + stat_map_t::iterator iter = sStatList.find(mName); + if (iter != sStatList.end()) + llwarns << "LLStat with duplicate name: " << mName << llendl; + sStatList.insert(std::make_pair(mName, this)); + } +} + +LLStat::LLStat(const U32 num_bins, const BOOL use_frame_timer) + : mUseFrameTimer(use_frame_timer), + mNumBins(num_bins) +{ + init(); +} + +LLStat::LLStat(std::string name, U32 num_bins, BOOL use_frame_timer) + : mUseFrameTimer(use_frame_timer), + mNumBins(num_bins), + mName(name) +{ + init(); } LLStat::~LLStat() @@ -754,6 +805,15 @@ LLStat::~LLStat() delete[] mBeginTime; delete[] mTime; delete[] mDT; + + if (!mName.empty()) + { + // handle multiple entries with the same name + stat_map_t::iterator iter = sStatList.find(mName); + while (iter != sStatList.end() && iter->second != this) + ++iter; + sStatList.erase(iter); + } } void LLStat::reset() diff --git a/indra/llcommon/llstat.h b/indra/llcommon/llstat.h index 797e82b9e..bd73c9a6b 100644 --- a/indra/llcommon/llstat.h +++ b/indra/llcommon/llstat.h @@ -192,14 +192,23 @@ public: // Use this constructor for pre-defined LLStatTime objects LLPerfBlock(LLStatTime* stat); - // Use this constructor for dynamically created LLStatTime objects (not pre-defined) with a multi-part key - LLPerfBlock( const char* key1, const char* key2 = NULL); + // Use this constructor for normal, optional LLPerfBlock time slices + LLPerfBlock( const char* key ); + // Use this constructor for dynamically created LLPerfBlock time slices + // that are only enabled by specific control flags + LLPerfBlock( const char* key1, const char* key2, S32 flags = LLSTATS_BASIC_STATS ); ~LLPerfBlock(); - static void setStatsEnabled( BOOL enable ) { sStatsEnabled = enable; }; - static S32 getStatsEnabled() { return sStatsEnabled; }; + enum + { // Stats bitfield flags + LLSTATS_NO_OPTIONAL_STATS = 0x00, // No optional stats gathering, just pre-defined LLStatTime objects + LLSTATS_BASIC_STATS = 0x01, // Gather basic optional runtime stats + LLSTATS_SCRIPT_FUNCTIONS = 0x02, // Include LSL function calls + }; + static void setStatsFlags( S32 flags ) { sStatsFlags = flags; }; + static S32 getStatsFlags() { return sStatsFlags; }; static void clearDynamicStats(); // Reset maps to clear out dynamic objects static void addStatsToLLSDandReset( LLSD & stats, // Get current information and clear time bin @@ -213,7 +222,7 @@ private: LLStatTime * mPredefinedStat; // LLStatTime object to get data StatEntry * mDynamicStat; // StatEntryobject to get data - static BOOL sStatsEnabled; // Normally FALSE + static S32 sStatsFlags; // Control what is being recorded static stat_map_t sStatMap; // Map full path string to LLStatTime objects static std::string sCurrentStatPath; // Something like "frame/physics/physics step" }; @@ -236,7 +245,7 @@ public: BOOL frameStatsIsRunning() { return (mReportPerformanceStatEnd > 0.); }; F32 getReportPerformanceInterval() const { return mReportPerformanceStatInterval; }; void setReportPerformanceInterval( F32 interval ) { mReportPerformanceStatInterval = interval; }; - void setReportPerformanceDuration( F32 seconds ); + void setReportPerformanceDuration( F32 seconds, S32 flags = LLPerfBlock::LLSTATS_NO_OPTIONAL_STATS ); void setProcessName(const std::string& process_name) { mProcessName = process_name; } void setProcessPID(S32 process_pid) { mProcessPID = process_pid; } @@ -258,8 +267,15 @@ private: // ---------------------------------------------------------------------------- class LL_COMMON_API LLStat { +private: + typedef std::multimap stat_map_t; + static stat_map_t sStatList; + + void init(); + public: - LLStat(const U32 num_bins = 32, BOOL use_frame_timer = FALSE); + LLStat(U32 num_bins = 32, BOOL use_frame_timer = FALSE); + LLStat(std::string name, U32 num_bins = 32, BOOL use_frame_timer = FALSE); ~LLStat(); void reset(); @@ -322,8 +338,22 @@ private: F32 *mDT; S32 mCurBin; S32 mNextBin; + + std::string mName; + static LLTimer sTimer; static LLFrameTimer sFrameTimer; + +public: + static LLStat* getStat(const std::string& name) + { + // return the first stat that matches 'name' + stat_map_t::iterator iter = sStatList.find(name); + if (iter != sStatList.end()) + return iter->second; + else + return NULL; + } }; - + #endif // LL_STAT_ diff --git a/indra/llcommon/llstreamtools.cpp b/indra/llcommon/llstreamtools.cpp index b60220830..4ed2df58e 100644 --- a/indra/llcommon/llstreamtools.cpp +++ b/indra/llcommon/llstreamtools.cpp @@ -45,7 +45,7 @@ // skips spaces and tabs bool skip_whitespace(std::istream& input_stream) { - char c = input_stream.peek(); + int c = input_stream.peek(); while (('\t' == c || ' ' == c) && input_stream.good()) { input_stream.get(); @@ -57,7 +57,7 @@ bool skip_whitespace(std::istream& input_stream) // skips whitespace, newlines, and carriage returns bool skip_emptyspace(std::istream& input_stream) { - char c = input_stream.peek(); + int c = input_stream.peek(); while ( input_stream.good() && ('\t' == c || ' ' == c || '\n' == c || '\r' == c) ) { @@ -72,7 +72,7 @@ bool skip_comments_and_emptyspace(std::istream& input_stream) { while (skip_emptyspace(input_stream)) { - char c = input_stream.peek(); + int c = input_stream.peek(); if ('#' == c ) { while ('\n' != c && input_stream.good()) @@ -90,7 +90,7 @@ bool skip_comments_and_emptyspace(std::istream& input_stream) bool skip_line(std::istream& input_stream) { - char c; + int c; do { c = input_stream.get(); @@ -100,7 +100,7 @@ bool skip_line(std::istream& input_stream) bool skip_to_next_word(std::istream& input_stream) { - char c = input_stream.peek(); + int c = input_stream.peek(); while ( input_stream.good() && ( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') @@ -132,7 +132,7 @@ bool skip_to_end_of_next_keyword(const char* keyword, std::istream& input_stream while (input_stream.good()) { skip_emptyspace(input_stream); - char c = input_stream.get(); + int c = input_stream.get(); if (keyword[0] != c) { skip_line(input_stream); @@ -181,7 +181,7 @@ bool skip_to_start_of_next_keyword(const char* keyword, std::istream& input_stre while (input_stream.good()) { skip_emptyspace(input_stream); - char c = input_stream.get(); + int c = input_stream.get(); if (keyword[0] != c) { skip_line(input_stream); @@ -229,7 +229,7 @@ bool skip_to_start_of_next_keyword(const char* keyword, std::istream& input_stre bool get_word(std::string& output_string, std::istream& input_stream) { skip_emptyspace(input_stream); - char c = input_stream.peek(); + int c = input_stream.peek(); while ( !isspace(c) && '\n' != c && '\r' != c @@ -246,7 +246,7 @@ bool get_word(std::string& output_string, std::istream& input_stream, int n) { skip_emptyspace(input_stream); int char_count = 0; - char c = input_stream.peek(); + int c = input_stream.peek(); while (!isspace(c) && '\n' != c && '\r' != c @@ -265,7 +265,7 @@ bool get_word(std::string& output_string, std::istream& input_stream, int n) bool get_line(std::string& output_string, std::istream& input_stream) { output_string.clear(); - char c = input_stream.get(); + int c = input_stream.get(); while (input_stream.good()) { output_string += c; @@ -285,7 +285,7 @@ bool get_line(std::string& output_string, std::istream& input_stream, int n) { output_string.clear(); int char_count = 0; - char c = input_stream.get(); + int c = input_stream.get(); while (input_stream.good() && char_count < n) { char_count++; diff --git a/indra/llcommon/llstrider.h b/indra/llcommon/llstrider.h index 2afaacf3b..b9f0da206 100644 --- a/indra/llcommon/llstrider.h +++ b/indra/llcommon/llstrider.h @@ -52,6 +52,7 @@ public: void setStride (S32 skipBytes) { mSkip = (skipBytes ? skipBytes : sizeof(Object));} void setTypeSize (S32 typeBytes){ mTypeSize = (typeBytes ? typeBytes : sizeof(Object)); } + bool isStrided() const { return mTypeSize != mSkip; } void skip(const U32 index) { mBytep += mSkip*index;} U32 getSkip() const { return mSkip; } Object* get() { return mObjectp; } @@ -70,7 +71,7 @@ public: //stride == sizeof(element) implies entire buffer is unstrided and thus memcpy-able, provided source buffer elements match in size. //Because LLStrider is often passed an LLVector3 even if the reprensentation is LLVector4 in the vertex buffer, mTypeSize is set to //the TRUE vbo datatype size via VertexBufferStrider::get - if(mTypeSize == mSkip && mTypeSize == elem_size) + if(!isStrided() && mTypeSize == elem_size) { if(bytes >= sizeof(LLVector4) * 4) //Should be able to pull at least 3 16byte blocks from this. Smaller isn't really beneficial. { diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 34e19f83f..1762b3b00 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -36,6 +36,8 @@ #include "u64.h" +#include "lldate.h" + #if LL_WINDOWS # define WIN32_LEAN_AND_MEAN # include diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h index 68f06fdce..478585e54 100644 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -39,8 +39,6 @@ #include #include "stdtypes.h" -#include "llpreprocessor.h" -#include "lldate.h" #include #include @@ -55,8 +53,6 @@ const U32 USEC_PER_HOUR = USEC_PER_MIN * MIN_PER_HOUR; const U32 SEC_PER_HOUR = SEC_PER_MIN * MIN_PER_HOUR; const F64 SEC_PER_USEC = 1.0 / (F64) USEC_PER_SEC; -LL_COMMON_API U64 totalTime(); // Returns current system time in microseconds - class LL_COMMON_API LLTimer { public: @@ -175,4 +171,5 @@ LL_COMMON_API void secondsToTimecodeString(F32 current_time, std::string& tcstri LL_COMMON_API void timeToFormattedString(time_t time, std::string format, std::string ×tr); LL_COMMON_API void timeStructToFormattedString(struct tm * time, std::string format, std::string ×tr); +U64 LL_COMMON_API totalTime(); // Returns current system time in microseconds #endif diff --git a/indra/llcommon/lltreeiterators.h b/indra/llcommon/lltreeiterators.h new file mode 100644 index 000000000..ba861ae70 --- /dev/null +++ b/indra/llcommon/lltreeiterators.h @@ -0,0 +1,705 @@ +/** + * @file lltreeiterators.h + * @author Nat Goodspeed + * @date 2008-08-19 + * @brief This file defines iterators useful for traversing arbitrary node + * classes, potentially polymorphic, linked into strict tree + * structures. + * + * Dereferencing any one of these iterators actually yields a @em + * pointer to the node in question. For example, given an + * LLLinkedIter li, *li gets you a pointer + * to MyNode, and **li gets you the MyNode instance itself. + * More commonly, instead of writing li->member, you write + * (*li)->member -- as you would if you were traversing an + * STL container of MyNode pointers. + * + * It would certainly be possible to build these iterators so that + * *iterator would return a reference to the node itself + * rather than a pointer to the node, and for many purposes it would + * even be more convenient. However, that would be insufficiently + * flexible. If you want to use an iterator range to (e.g.) initialize + * a std::vector collecting results -- you rarely want to actually @em + * copy the nodes in question. You're much more likely to want to copy + * pointers to the traversed nodes. Hence these iterators + * produce pointers. + * + * Though you specify the actual NODE class as the template parameter, + * these iterators internally use LLPtrTo<> to discover whether to + * store and return an LLPointer or a simple NODE*. + * + * By strict tree structures, we mean that each child must have + * exactly one parent. This forbids a child claiming any ancestor as a + * child of its own. Child nodes with multiple parents will be visited + * once for each parent. Cycles in the graph will result in either an + * infinite loop or an out-of-memory crash. You Have Been Warned. + * + * $LicenseInfo:firstyear=2008&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$ + */ + +#if ! defined(LL_LLTREEITERATORS_H) +#define LL_LLTREEITERATORS_H + +#include "llptrto.h" +#include +#include +#include +#include +#include + +namespace LLTreeIter +{ + /// Discriminator between LLTreeUpIter and LLTreeDownIter + enum RootIter { UP, DOWN }; + /// Discriminator between LLTreeDFSIter, LLTreeDFSPostIter and LLTreeBFSIter + enum WalkIter { DFS_PRE, DFS_POST, BFS }; +} + +/** + * LLBaseIter defines some machinery common to all these iterators. We use + * boost::iterator_facade to define the iterator boilerplate: the conventional + * operators and methods necessary to implement a standards-conforming + * iterator. That allows us to specify the actual iterator semantics in terms + * of equal(), dereference() and increment() methods. + */ +template +class LLBaseIter: public boost::iterator_facade::type, + boost::forward_traversal_tag> +{ +protected: + /// LLPtrTo::type is either NODE* or LLPointer, as appropriate + typedef typename LLPtrTo::type ptr_type; + /// function that advances from this node to next accepts a node pointer + /// and returns another + typedef boost::function func_type; + typedef SELFTYPE self_type; +}; + +/// Functor returning NULL, suitable for an end-iterator's 'next' functor +template +typename LLPtrTo::type LLNullNextFunctor(const typename LLPtrTo::type&) +{ + return typename LLPtrTo::type(); +} + +/** + * LLLinkedIter is an iterator over an intrusive singly-linked list. The + * beginning of the list is represented by LLLinkedIter(list head); the end is + * represented by LLLinkedIter(). + * + * The begin LLLinkedIter must be instantiated with a functor to extract the + * 'next' pointer from the current node. Supposing that the link pointer is @c + * public, something like: + * + * @code + * NODE* mNext; + * @endcode + * + * you can use (e.g.) boost::bind(&NODE::mNext, _1) for the purpose. + * Alternatively, you can bind whatever accessor method is normally used to + * advance to the next node, e.g. for: + * + * @code + * NODE* next() const; + * @endcode + * + * you can use boost::bind(&NODE::next, _1). + */ +template +class LLLinkedIter: public LLBaseIter, NODE> +{ + typedef LLBaseIter, NODE> super; +protected: + /// some methods need to return a reference to self + typedef typename super::self_type self_type; + typedef typename super::ptr_type ptr_type; + typedef typename super::func_type func_type; +public: + /// Instantiate an LLLinkedIter to start a range, or to end a range before + /// a particular list entry. Pass a functor to extract the 'next' pointer + /// from the current node. + LLLinkedIter(const ptr_type& entry, const func_type& nextfunc): + mCurrent(entry), + mNextFunc(nextfunc) + {} + /// Instantiate an LLLinkedIter to end a range at the end of the list + LLLinkedIter(): + mCurrent(), + mNextFunc(LLNullNextFunctor) + {} + +private: + /// leverage boost::iterator_facade + friend class boost::iterator_core_access; + + /// advance + void increment() + { + mCurrent = mNextFunc(mCurrent); + } + /// equality + bool equal(const self_type& that) const { return this->mCurrent == that.mCurrent; } + /// dereference + ptr_type& dereference() const { return const_cast(mCurrent); } + + ptr_type mCurrent; + func_type mNextFunc; +}; + +/** + * LLTreeUpIter walks from the node in hand to the root of the tree. The term + * "up" is applied to a tree visualized with the root at the top. + * + * LLTreeUpIter is an alias for LLLinkedIter, since any linked tree that you + * can navigate that way at all contains parent pointers. + */ +template +class LLTreeUpIter: public LLLinkedIter +{ + typedef LLLinkedIter super; +public: + /// Instantiate an LLTreeUpIter to start from a particular tree node, or + /// to end a parent traversal before reaching a particular ancestor. Pass + /// a functor to extract the 'parent' pointer from the current node. + LLTreeUpIter(const typename super::ptr_type& node, + const typename super::func_type& parentfunc): + super(node, parentfunc) + {} + /// Instantiate an LLTreeUpIter to end a range at the root of the tree + LLTreeUpIter(): + super() + {} +}; + +/** + * LLTreeDownIter walks from the root of the tree to the node in hand. The + * term "down" is applied to a tree visualized with the root at the top. + * + * Though you instantiate the begin() LLTreeDownIter with a pointer to some + * node at an arbitrary location in the tree, the root will be the first node + * you dereference and the passed node will be the last node you dereference. + * + * On construction, LLTreeDownIter walks from the current node to the root, + * capturing the path. Then in use, it replays that walk in reverse. As with + * all traversals of interesting data structures, it is actively dangerous to + * modify the tree during an LLTreeDownIter walk. + */ +template +class LLTreeDownIter: public LLBaseIter, NODE> +{ + typedef LLBaseIter, NODE> super; + typedef typename super::self_type self_type; +protected: + typedef typename super::ptr_type ptr_type; + typedef typename super::func_type func_type; +private: + typedef std::vector list_type; +public: + /// Instantiate an LLTreeDownIter to end at a particular tree node. Pass a + /// functor to extract the 'parent' pointer from the current node. + LLTreeDownIter(const ptr_type& node, + const func_type& parentfunc) + { + for (ptr_type n = node; n; n = parentfunc(n)) + mParents.push_back(n); + } + /// Instantiate an LLTreeDownIter representing "here", the end of the loop + LLTreeDownIter() {} + +private: + /// leverage boost::iterator_facade + friend class boost::iterator_core_access; + + /// advance + void increment() + { + mParents.pop_back(); + } + /// equality + bool equal(const self_type& that) const { return this->mParents == that.mParents; } + /// implement dereference/indirection operators + ptr_type& dereference() const { return const_cast(mParents.back()); } + + list_type mParents; +}; + +/** + * When you want to select between LLTreeUpIter and LLTreeDownIter with a + * compile-time discriminator, use LLTreeRootIter with an LLTreeIter::RootIter + * template arg. + */ +template +class LLTreeRootIter +{ + enum { use_a_valid_LLTreeIter_RootIter_value = false }; +public: + /// Bogus constructors for default (unrecognized discriminator) case + template + LLTreeRootIter(TYPE1, TYPE2) + { + BOOST_STATIC_ASSERT(use_a_valid_LLTreeIter_RootIter_value); + } + LLTreeRootIter() + { + BOOST_STATIC_ASSERT(use_a_valid_LLTreeIter_RootIter_value); + } +}; + +/// Specialize for LLTreeIter::UP +template +class LLTreeRootIter: public LLTreeUpIter +{ + typedef LLTreeUpIter super; +public: + /// forward begin ctor + LLTreeRootIter(const typename super::ptr_type& node, + const typename super::func_type& parentfunc): + super(node, parentfunc) + {} + /// forward end ctor + LLTreeRootIter(): + super() + {} +}; + +/// Specialize for LLTreeIter::DOWN +template +class LLTreeRootIter: public LLTreeDownIter +{ + typedef LLTreeDownIter super; +public: + /// forward begin ctor + LLTreeRootIter(const typename super::ptr_type& node, + const typename super::func_type& parentfunc): + super(node, parentfunc) + {} + /// forward end ctor + LLTreeRootIter(): + super() + {} +}; + +/** + * Instantiated with a tree node, typically the root, LLTreeDFSIter "flattens" + * a depth-first tree walk through that node and all its descendants. + * + * The begin() LLTreeDFSIter must be instantiated with functors to obtain from + * a given node begin() and end() iterators for that node's children. For this + * reason, you must specify the type of the node's child iterator as an + * additional template parameter. + * + * Specifically, the begin functor must return an iterator whose dereferenced + * value is a @em pointer to a child tree node. For instance, if each node + * tracks its children in an STL container of node* pointers, you can simply + * return that container's begin() iterator. + * + * Alternatively, if a node tracks its children with a classic linked list, + * write a functor returning LLLinkedIter. + * + * The end() LLTreeDFSIter must, of course, match the begin() iterator's + * template parameters, but is constructed without runtime parameters. + */ +template +class LLTreeDFSIter: public LLBaseIter, NODE> +{ + typedef LLBaseIter, NODE> super; + typedef typename super::self_type self_type; +protected: + typedef typename super::ptr_type ptr_type; + // The func_type is different for this: from a NODE pointer, we must + // obtain a CHILDITER. + typedef boost::function func_type; +private: + typedef std::vector list_type; +public: + /// Instantiate an LLTreeDFSIter to start a depth-first walk. Pass + /// functors to extract the 'child begin' and 'child end' iterators from + /// each node. + LLTreeDFSIter(const ptr_type& node, const func_type& beginfunc, const func_type& endfunc) + : mBeginFunc(beginfunc), + mEndFunc(endfunc), + mSkipChildren(false) + { + // Only push back this node if it's non-NULL! + if (node) + mPending.push_back(node); + } + /// Instantiate an LLTreeDFSIter to mark the end of the walk + LLTreeDFSIter() : mSkipChildren(false) {} + + /// flags iterator logic to skip traversing children of current node on next increment + void skipDescendants(bool skip = true) { mSkipChildren = skip; } + +private: + /// leverage boost::iterator_facade + friend class boost::iterator_core_access; + + /// advance + /// This implementation is due to http://en.wikipedia.org/wiki/Depth-first_search + void increment() + { + // Capture the node we were just looking at + ptr_type current = mPending.back(); + // Remove it from mPending so we don't process it again later + mPending.pop_back(); + if (!mSkipChildren) + { + // Add all its children to mPending + addChildren(current); + } + // reset flag after each step + mSkipChildren = false; + } + /// equality + bool equal(const self_type& that) const { return this->mPending == that.mPending; } + /// implement dereference/indirection operators + ptr_type& dereference() const { return const_cast(mPending.back()); } + + /// Add the direct children of the specified node to mPending + void addChildren(const ptr_type& node) + { + // If we just use push_back() for each child in turn, we'll end up + // processing children in reverse order. We don't want to assume + // CHILDITER is reversible: some of the linked trees we'll be + // processing manage their children using singly-linked lists. So + // figure out how many children there are, grow mPending by that size + // and reverse-copy the children into the new space. + CHILDITER chi = mBeginFunc(node), chend = mEndFunc(node); + // grow mPending by the number of children + mPending.resize(mPending.size() + std::distance(chi, chend)); + // reverse-copy the children into the newly-expanded space + std::copy(chi, chend, mPending.rbegin()); + } + + /// list of the nodes yet to be processed + list_type mPending; + /// functor to extract begin() child iterator + func_type mBeginFunc; + /// functor to extract end() child iterator + func_type mEndFunc; + /// flag which controls traversal of children (skip children of current node if true) + bool mSkipChildren; +}; + +/** + * Instantiated with a tree node, typically the root, LLTreeDFSPostIter + * "flattens" a depth-first tree walk through that node and all its + * descendants. Whereas LLTreeDFSIter visits each node before visiting any of + * its children, LLTreeDFSPostIter visits all of a node's children before + * visiting the node itself. + * + * The begin() LLTreeDFSPostIter must be instantiated with functors to obtain + * from a given node begin() and end() iterators for that node's children. For + * this reason, you must specify the type of the node's child iterator as an + * additional template parameter. + * + * Specifically, the begin functor must return an iterator whose dereferenced + * value is a @em pointer to a child tree node. For instance, if each node + * tracks its children in an STL container of node* pointers, you can simply + * return that container's begin() iterator. + * + * Alternatively, if a node tracks its children with a classic linked list, + * write a functor returning LLLinkedIter. + * + * The end() LLTreeDFSPostIter must, of course, match the begin() iterator's + * template parameters, but is constructed without runtime parameters. + */ +template +class LLTreeDFSPostIter: public LLBaseIter, NODE> +{ + typedef LLBaseIter, NODE> super; + typedef typename super::self_type self_type; +protected: + typedef typename super::ptr_type ptr_type; + // The func_type is different for this: from a NODE pointer, we must + // obtain a CHILDITER. + typedef boost::function func_type; +private: + // Upon reaching a given node in our pending list, we need to know whether + // we've already pushed that node's children, so we must associate a bool + // with each node pointer. + typedef std::vector< std::pair > list_type; +public: + /// Instantiate an LLTreeDFSPostIter to start a depth-first walk. Pass + /// functors to extract the 'child begin' and 'child end' iterators from + /// each node. + LLTreeDFSPostIter(const ptr_type& node, const func_type& beginfunc, const func_type& endfunc) + : mBeginFunc(beginfunc), + mEndFunc(endfunc), + mSkipAncestors(false) + { + if (! node) + return; + mPending.push_back(typename list_type::value_type(node, false)); + makeCurrent(); + } + /// Instantiate an LLTreeDFSPostIter to mark the end of the walk + LLTreeDFSPostIter() : mSkipAncestors(false) {} + + /// flags iterator logic to skip traversing ancestors of current node on next increment + void skipAncestors(bool skip = true) { mSkipAncestors = skip; } + +private: + /// leverage boost::iterator_facade + friend class boost::iterator_core_access; + + /// advance + /// This implementation is due to http://en.wikipedia.org/wiki/Depth-first_search + void increment() + { + // Pop the previous current node + mPending.pop_back(); + makeCurrent(); + } + /// equality + bool equal(const self_type& that) const { return this->mPending == that.mPending; } + /// implement dereference/indirection operators + ptr_type& dereference() const { return const_cast(mPending.back().first); } + + struct isOpen + { + bool operator()(const typename list_type::value_type& item) + { + return item.second; + } + }; + + /// Call this each time we change mPending.back() -- that is, every time + /// we're about to change the value returned by dereference(). If we + /// haven't yet pushed the new node's children, do so now. + void makeCurrent() + { + if (mSkipAncestors) + { + mPending.erase(std::remove_if(mPending.begin(), mPending.end(), isOpen()), mPending.end()); + mSkipAncestors = false; + } + + // Once we've popped the last node, this becomes a no-op. + if (mPending.empty()) + return; + // Here mPending.back() holds the node pointer we're proposing to + // dereference next. Have we pushed that node's children yet? + if (mPending.back().second) + return; // if so, it's okay to visit this node now + // We haven't yet pushed this node's children. Do so now. Remember + // that we did -- while the node in question is still back(). + mPending.back().second = true; + addChildren(mPending.back().first); + // Now, because we've just changed mPending.back(), make that new node + // current. + makeCurrent(); + } + + /// Add the direct children of the specified node to mPending + void addChildren(const ptr_type& node) + { + // If we just use push_back() for each child in turn, we'll end up + // processing children in reverse order. We don't want to assume + // CHILDITER is reversible: some of the linked trees we'll be + // processing manage their children using singly-linked lists. So + // figure out how many children there are, grow mPending by that size + // and reverse-copy the children into the new space. + CHILDITER chi = mBeginFunc(node), chend = mEndFunc(node); + // grow mPending by the number of children + mPending.resize(mPending.size() + std::distance(chi, chend)); + // Reverse-copy the children into the newly-expanded space. We can't + // just use std::copy() because the source is a ptr_type, whereas the + // dest is a pair of (ptr_type, bool). + for (typename list_type::reverse_iterator pi = mPending.rbegin(); chi != chend; ++chi, ++pi) + { + pi->first = *chi; // copy the child pointer + pi->second = false; // we haven't yet pushed this child's chldren + } + } + + /// list of the nodes yet to be processed + list_type mPending; + /// functor to extract begin() child iterator + func_type mBeginFunc; + /// functor to extract end() child iterator + func_type mEndFunc; + /// flags logic to skip traversal of ancestors of current node + bool mSkipAncestors; +}; + +/** + * Instantiated with a tree node, typically the root, LLTreeBFSIter "flattens" + * a breadth-first tree walk through that node and all its descendants. + * + * The begin() LLTreeBFSIter must be instantiated with functors to obtain from + * a given node the begin() and end() iterators of that node's children. For + * this reason, you must specify the type of the node's child iterator as an + * additional template parameter. + * + * Specifically, the begin functor must return an iterator whose dereferenced + * value is a @em pointer to a child tree node. For instance, if each node + * tracks its children in an STL container of node* pointers, you can simply + * return that container's begin() iterator. + * + * Alternatively, if a node tracks its children with a classic linked list, + * write a functor returning LLLinkedIter. + * + * The end() LLTreeBFSIter must, of course, match the begin() iterator's + * template parameters, but is constructed without runtime parameters. + */ +template +class LLTreeBFSIter: public LLBaseIter, NODE> +{ + typedef LLBaseIter, NODE> super; + typedef typename super::self_type self_type; +protected: + typedef typename super::ptr_type ptr_type; + // The func_type is different for this: from a NODE pointer, we must + // obtain a CHILDITER. + typedef boost::function func_type; +private: + // We need a FIFO queue rather than a LIFO stack. Use a deque rather than + // a vector, since vector can't implement pop_front() efficiently. + typedef std::deque list_type; +public: + /// Instantiate an LLTreeBFSIter to start a depth-first walk. Pass + /// functors to extract the 'child begin' and 'child end' iterators from + /// each node. + LLTreeBFSIter(const ptr_type& node, const func_type& beginfunc, const func_type& endfunc): + mBeginFunc(beginfunc), + mEndFunc(endfunc) + { + if (node) + mPending.push_back(node); + } + /// Instantiate an LLTreeBFSIter to mark the end of the walk + LLTreeBFSIter() {} + +private: + /// leverage boost::iterator_facade + friend class boost::iterator_core_access; + + /// advance + /// This implementation is due to http://en.wikipedia.org/wiki/Breadth-first_search + void increment() + { + // Capture the node we were just looking at + ptr_type current = mPending.front(); + // Remove it from mPending so we don't process it again later + mPending.pop_front(); + // Add all its children to mPending + CHILDITER chend = mEndFunc(current); + for (CHILDITER chi = mBeginFunc(current); chi != chend; ++chi) + mPending.push_back(*chi); + } + /// equality + bool equal(const self_type& that) const { return this->mPending == that.mPending; } + /// implement dereference/indirection operators + ptr_type& dereference() const { return const_cast(mPending.front()); } + + /// list of the nodes yet to be processed + list_type mPending; + /// functor to extract begin() child iterator + func_type mBeginFunc; + /// functor to extract end() child iterator + func_type mEndFunc; +}; + +/** + * When you want to select between LLTreeDFSIter, LLTreeDFSPostIter and + * LLTreeBFSIter with a compile-time discriminator, use LLTreeWalkIter with an + * LLTreeIter::WalkIter template arg. + */ +template +class LLTreeWalkIter +{ + enum { use_a_valid_LLTreeIter_WalkIter_value = false }; +public: + /// Bogus constructors for default (unrecognized discriminator) case + template + LLTreeWalkIter(TYPE1, TYPE2) + { + BOOST_STATIC_ASSERT(use_a_valid_LLTreeIter_WalkIter_value); + } + LLTreeWalkIter() + { + BOOST_STATIC_ASSERT(use_a_valid_LLTreeIter_WalkIter_value); + } +}; + +/// Specialize for LLTreeIter::DFS_PRE +template +class LLTreeWalkIter: + public LLTreeDFSIter +{ + typedef LLTreeDFSIter super; +public: + /// forward begin ctor + LLTreeWalkIter(const typename super::ptr_type& node, + const typename super::func_type& beginfunc, + const typename super::func_type& endfunc): + super(node, beginfunc, endfunc) + {} + /// forward end ctor + LLTreeWalkIter(): + super() + {} +}; + +/// Specialize for LLTreeIter::DFS_POST +template +class LLTreeWalkIter: + public LLTreeDFSPostIter +{ + typedef LLTreeDFSPostIter super; +public: + /// forward begin ctor + LLTreeWalkIter(const typename super::ptr_type& node, + const typename super::func_type& beginfunc, + const typename super::func_type& endfunc): + super(node, beginfunc, endfunc) + {} + /// forward end ctor + LLTreeWalkIter(): + super() + {} +}; + +/// Specialize for LLTreeIter::BFS +template +class LLTreeWalkIter: + public LLTreeBFSIter +{ + typedef LLTreeBFSIter super; +public: + /// forward begin ctor + LLTreeWalkIter(const typename super::ptr_type& node, + const typename super::func_type& beginfunc, + const typename super::func_type& endfunc): + super(node, beginfunc, endfunc) + {} + /// forward end ctor + LLTreeWalkIter(): + super() + {} +}; + +#endif /* ! defined(LL_LLTREEITERATORS_H) */ diff --git a/indra/llinventory/lleconomy.h b/indra/llinventory/lleconomy.h index 2e2adc4d4..e48008545 100644 --- a/indra/llinventory/lleconomy.h +++ b/indra/llinventory/lleconomy.h @@ -32,7 +32,7 @@ #ifndef LL_LLECONOMY_H #define LL_LLECONOMY_H -#include "llmemory.h" +#include "llsingleton.h" class LLMessageSystem; class LLVector3; diff --git a/indra/llinventory/llinventory.h b/indra/llinventory/llinventory.h index e28c046bf..479c7d397 100644 --- a/indra/llinventory/llinventory.h +++ b/indra/llinventory/llinventory.h @@ -36,10 +36,9 @@ #include "lldarray.h" #include "llfoldertype.h" #include "llinventorytype.h" -#include "llinventorydefines.h" #include "llmemtype.h" #include "llpermissions.h" -#include "llmemory.h" +#include "llrefcount.h" #include "llsaleinfo.h" #include "llsd.h" #include "lluuid.h" @@ -304,84 +303,11 @@ protected: //----------------------------------------------------------------------------- -// Useful bits +// Convertors +// +// These functions convert between structured data and an inventory +// item, appropriate for serialization. //----------------------------------------------------------------------------- - -// This functor tests if an item is transferrable and returns true if -// it is. Derived from unary_function<> so that the object can be used -// in stl-compliant adaptable predicates (eg, not1<>). You might want -// to use this in std::partition() or similar logic. -struct IsItemTransferable : public std::unary_function -{ - LLUUID mDestID; - IsItemTransferable(const LLUUID& dest_id) : mDestID(dest_id) {} - bool operator()(const LLInventoryItem* item) const - { - return (item->getPermissions().allowTransferTo(mDestID)) ? true:false; - } -}; - -// This functor is used to set the owner and group of inventory items, -// for example, in a simple std::for_each() loop. Note that the call -// to setOwnerAndGroup can fail if authority_id != LLUUID::null. -struct SetItemOwnerAndGroup -{ - LLUUID mAuthorityID; - LLUUID mOwnerID; - LLUUID mGroupID; - SetItemOwnerAndGroup(const LLUUID& authority_id, - const LLUUID& owner_id, - const LLUUID& group_id) : - mAuthorityID(authority_id), mOwnerID(owner_id), mGroupID(group_id) {} - void operator()(LLInventoryItem* item) const - { - LLPermissions perm = item->getPermissions(); - bool is_atomic = (LLAssetType::AT_OBJECT == item->getType()) ? false : true; - perm.setOwnerAndGroup(mAuthorityID, mOwnerID, mGroupID, is_atomic); - // If no owner id is set, this is equivalent to a deed action. - // Clear 'share with group'. - if (mOwnerID.isNull()) - { - perm.setMaskGroup(PERM_NONE); - } - item->setPermissions(perm); - } -}; - -// This functor is used to unset the share with group, everyone perms, and -// for sale info for objects being sold through contents. -struct SetNotForSale -{ - LLUUID mAgentID; - LLUUID mGroupID; - SetNotForSale(const LLUUID& agent_id, - const LLUUID& group_id) : - mAgentID(agent_id), mGroupID(group_id) {} - void operator()(LLInventoryItem* item) const - { - // Clear group & everyone permissions. - LLPermissions perm = item->getPermissions(); - perm.setGroupBits(mAgentID, mGroupID, FALSE, PERM_MODIFY | PERM_MOVE | PERM_COPY); - perm.setEveryoneBits(mAgentID, mGroupID, FALSE, PERM_MOVE | PERM_COPY); - item->setPermissions(perm); - - // Mark group & everyone permissions for overwrite on the next - // rez if it is an object. - if(LLAssetType::AT_OBJECT == item->getType()) - { - U32 flags = item->getFlags(); - flags |= LLInventoryItemFlags::II_FLAGS_OBJECT_PERM_OVERWRITE_GROUP; - flags |= LLInventoryItemFlags::II_FLAGS_OBJECT_PERM_OVERWRITE_EVERYONE; - item->setFlags(flags); - } - - // Clear for sale info. - item->setSaleInfo(LLSaleInfo::DEFAULT); - } -}; - -// These functions convert between structured data and an inventroy -// item, appropriate for serialization. LLSD ll_create_sd_from_inventory_item(LLPointer item); LLPointer ll_create_item_from_sd(const LLSD& sd_item); LLSD ll_create_sd_from_inventory_category(LLPointer cat); diff --git a/indra/llinventory/llinventorytype.cpp b/indra/llinventory/llinventorytype.cpp index 35b5bde05..1dc7a7f2c 100644 --- a/indra/llinventory/llinventorytype.cpp +++ b/indra/llinventory/llinventorytype.cpp @@ -35,6 +35,7 @@ #include "llinventorytype.h" #include "lldictionary.h" #include "llmemory.h" +#include "llsingleton.h" static const std::string empty_string; diff --git a/indra/llinventory/llnotecard.h b/indra/llinventory/llnotecard.h index b903f1fdb..092ab2ce3 100644 --- a/indra/llinventory/llnotecard.h +++ b/indra/llinventory/llnotecard.h @@ -33,7 +33,7 @@ #ifndef LL_NOTECARD_H #define LL_NOTECARD_H -#include "llmemory.h" +#include "llpointer.h" #include "llinventory.h" class LLNotecard diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp index c167ef194..070437ee4 100644 --- a/indra/llinventory/llparcel.cpp +++ b/indra/llinventory/llparcel.cpp @@ -177,7 +177,7 @@ void LLParcel::init(const LLUUID &owner_id, mSaleTimerExpires.stop(); mGraceExtension = 0; //mExpireAction = STEA_REVERT; - mRecordTransaction = FALSE; + //mRecordTransaction = FALSE; mAuctionID = 0; mInEscrow = false; diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h index d55d09e3a..401fb0040 100644 --- a/indra/llinventory/llparcel.h +++ b/indra/llinventory/llparcel.h @@ -433,13 +433,10 @@ public: void completeSale(U32& type, U8& flags, LLUUID& to_id); void clearSale(); - // this function returns TRUE if the parcel needs conversion to a - // lease from a non-owned-status state. - BOOL getRecordTransaction() const { return mRecordTransaction; } - void setRecordTransaction(BOOL record) { mRecordTransaction = record; } BOOL isMediaResetTimerExpired(const U64& time); + // more accessors U32 getParcelFlags() const { return mParcelFlags; } @@ -474,7 +471,9 @@ public: { return (mParcelFlags & PF_ALLOW_FLY) ? TRUE : FALSE; } BOOL getAllowLandmark() const - { return (mParcelFlags & PF_ALLOW_LANDMARK) ? TRUE : FALSE; } + { return TRUE; } + //Perhaps revert for opensim? + //{ return (mParcelFlags & PF_ALLOW_LANDMARK) ? TRUE : FALSE; } BOOL getAllowGroupScripts() const { return (mParcelFlags & PF_ALLOW_GROUP_SCRIPTS) ? TRUE : FALSE; } @@ -620,8 +619,6 @@ protected: LLTimer mMediaResetTimer; S32 mGraceExtension; - BOOL mRecordTransaction; - // This value is non-zero if there is an auction associated with // the parcel. diff --git a/indra/llinventory/llparcelflags.h b/indra/llinventory/llparcelflags.h index a1bd85f50..122468e91 100644 --- a/indra/llinventory/llparcelflags.h +++ b/indra/llinventory/llparcelflags.h @@ -132,5 +132,7 @@ const S32 PARCEL_DETAILS_DESC = 1; const S32 PARCEL_DETAILS_OWNER = 2; const S32 PARCEL_DETAILS_GROUP = 3; const S32 PARCEL_DETAILS_AREA = 4; +const S32 PARCEL_DETAILS_ID = 5; +const S32 PARCEL_DETAILS_SEE_AVATARS = 6; #endif diff --git a/indra/llinventory/llsaleinfo.cpp b/indra/llinventory/llsaleinfo.cpp index e51e35e6e..b7afb28ad 100644 --- a/indra/llinventory/llsaleinfo.cpp +++ b/indra/llinventory/llsaleinfo.cpp @@ -30,8 +30,8 @@ * $/LicenseInfo$ */ -#include "linden_common.h" #include +#include "linden_common.h" #include "llsaleinfo.h" diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h index 5853c9430..89ef7d616 100644 --- a/indra/llmath/llmath.h +++ b/indra/llmath/llmath.h @@ -37,8 +37,8 @@ #include #include #include "lldefs.h" -#include "llstl.h" // *TODO: Remove when LLString is gone -#include "llstring.h" // *TODO: Remove when LLString is gone +//#include "llstl.h" // *TODO: Remove when LLString is gone +//#include "llstring.h" // *TODO: Remove when LLString is gone // lltut.h uses is_approx_equal_fraction(). This was moved to its own header // file in llcommon so we can use lltut.h for llcommon tests without making // llcommon depend on llmath. @@ -516,6 +516,12 @@ inline void ll_remove_outliers(std::vector& data, F32 k) VEC_TYPE Q1 = data[data.size()/4]; VEC_TYPE Q3 = data[data.size()-data.size()/4-1]; + if ((F32)(Q3-Q1) < 1.f) + { + // not enough variation to detect outliers + return; + } + VEC_TYPE min = (VEC_TYPE) ((F32) Q1-k * (F32) (Q3-Q1)); VEC_TYPE max = (VEC_TYPE) ((F32) Q3+k * (F32) (Q3-Q1)); diff --git a/indra/llmath/lltreenode.h b/indra/llmath/lltreenode.h index 6c23cdff9..ada1f0075 100644 --- a/indra/llmath/lltreenode.h +++ b/indra/llmath/lltreenode.h @@ -34,7 +34,8 @@ #include "stdtypes.h" #include "xform.h" -#include "llmemory.h" +#include "llpointer.h" +#include "llrefcount.h" #include template class LLTreeNode; diff --git a/indra/llmath/llv4math.h b/indra/llmath/llv4math.h index 9a493b267..5b180b3d7 100644 --- a/indra/llmath/llv4math.h +++ b/indra/llmath/llv4math.h @@ -52,8 +52,6 @@ // // Sorry the code is such a mess. JC -#include "llpreprocessor.h" - //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // LLV4MATH - GNUC diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index d7a0d77a3..abe1cd402 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -2080,7 +2080,7 @@ LLVolume::LLVolume(const LLVolumeParams ¶ms, const F32 detail, const BOOL ge mDetail = detail; mSculptLevel = -2; #if MESH_ENABLED - mIsTetrahedron = FALSE; + mIsMeshAssetLoaded = FALSE; mLODScaleBias.setVec(1,1,1); mHullPoints = NULL; mHullIndices = NULL; @@ -2103,7 +2103,7 @@ LLVolume::LLVolume(const LLVolumeParams ¶ms, const F32 detail, const BOOL ge generate(); - if (mParams.getSculptID().isNull() && mParams.getSculptType() == LL_SCULPT_TYPE_NONE) + if (mParams.getSculptID().isNull() && mParams.getSculptType() == LL_SCULPT_TYPE_NONE || mParams.getSculptType() == LL_SCULPT_TYPE_MESH) { createVolumeFaces(); } @@ -2414,7 +2414,7 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size) LLSD mdl; if (!unzip_llsd(mdl, is, size)) { - llwarns << "not a valid mesh asset!" << llendl; + LL_DEBUGS("MeshStreaming") << "Failed to unzip LLSD blob for LoD, will probably fetch from sim again." << llendl; return false; } @@ -2712,173 +2712,21 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size) return true; } -void tetrahedron_set_normal(LLVolumeFace::VertexData* cv) + +BOOL LLVolume::isMeshAssetLoaded() { - LLVector4a v0; - v0.setSub(cv[1].getPosition(), cv[0].getNormal()); - LLVector4a v1; - v1.setSub(cv[2].getNormal(), cv[0].getPosition()); - - cv[0].getNormal().setCross3(v0,v1); - cv[0].getNormal().normalize3fast(); - cv[1].setNormal(cv[0].getNormal()); - cv[2].setNormal(cv[1].getNormal()); + return mIsMeshAssetLoaded; } -BOOL LLVolume::isTetrahedron() +void LLVolume::setMeshAssetLoaded(BOOL loaded) { - return mIsTetrahedron; -} - -void LLVolume::makeTetrahedron() -{ - mVolumeFaces.clear(); - - LLVolumeFace face; - - F32 x = 0.25f; - LLVector4a p[] = - { //unit tetrahedron corners - LLVector4a(x,x,x), - LLVector4a(-x,-x,x), - LLVector4a(-x,x,-x), - LLVector4a(x,-x,-x) - }; - - face.mExtents[0].splat(-x); - face.mExtents[1].splat(x); - - LLVolumeFace::VertexData cv[3]; - - //set texture coordinates - cv[0].mTexCoord = LLVector2(0,0); - cv[1].mTexCoord = LLVector2(1,0); - cv[2].mTexCoord = LLVector2(0.5f, 0.5f*F_SQRT3); - - - //side 1 - cv[0].setPosition(p[1]); - cv[1].setPosition(p[0]); - cv[2].setPosition(p[2]); - - tetrahedron_set_normal(cv); - - face.resizeVertices(12); - face.resizeIndices(12); - - LLVector4a* v = (LLVector4a*) face.mPositions; - LLVector4a* n = (LLVector4a*) face.mNormals; - LLVector2* tc = (LLVector2*) face.mTexCoords; - - v[0] = cv[0].getPosition(); - v[1] = cv[1].getPosition(); - v[2] = cv[2].getPosition(); - v += 3; - - n[0] = cv[0].getNormal(); - n[1] = cv[1].getNormal(); - n[2] = cv[2].getNormal(); - n += 3; - - if(tc) - { - tc[0] = cv[0].mTexCoord; - tc[1] = cv[1].mTexCoord; - tc[2] = cv[2].mTexCoord; - tc += 3; - } - - //side 2 - cv[0].setPosition(p[3]); - cv[1].setPosition(p[0]); - cv[2].setPosition(p[1]); - - tetrahedron_set_normal(cv); - - v[0] = cv[0].getPosition(); - v[1] = cv[1].getPosition(); - v[2] = cv[2].getPosition(); - v += 3; - - n[0] = cv[0].getNormal(); - n[1] = cv[1].getNormal(); - n[2] = cv[2].getNormal(); - n += 3; - - if(tc) - { - tc[0] = cv[0].mTexCoord; - tc[1] = cv[1].mTexCoord; - tc[2] = cv[2].mTexCoord; - tc += 3; - } - - //side 3 - cv[0].setPosition(p[3]); - cv[1].setPosition(p[1]); - cv[2].setPosition(p[2]); - - tetrahedron_set_normal(cv); - - v[0] = cv[0].getPosition(); - v[1] = cv[1].getPosition(); - v[2] = cv[2].getPosition(); - v += 3; - - n[0] = cv[0].getNormal(); - n[1] = cv[1].getNormal(); - n[2] = cv[2].getNormal(); - n += 3; - - if(tc) - { - tc[0] = cv[0].mTexCoord; - tc[1] = cv[1].mTexCoord; - tc[2] = cv[2].mTexCoord; - tc += 3; - } - - //side 4 - cv[0].setPosition(p[2]); - cv[1].setPosition(p[0]); - cv[2].setPosition(p[3]); - - tetrahedron_set_normal(cv); - - v[0] = cv[0].getPosition(); - v[1] = cv[1].getPosition(); - v[2] = cv[2].getPosition(); - v += 3; - - n[0] = cv[0].getNormal(); - n[1] = cv[1].getNormal(); - n[2] = cv[2].getNormal(); - n += 3; - - if(tc) - { - tc[0] = cv[0].mTexCoord; - tc[1] = cv[1].mTexCoord; - tc[2] = cv[2].mTexCoord; - tc += 3; - } - - //set index buffer - for (U16 i = 0; i < 12; i++) - { - face.mIndices[i] = i; - } - - mVolumeFaces.push_back(face); - mSculptLevel = 0; - mIsTetrahedron = TRUE; + mIsMeshAssetLoaded = loaded; } void LLVolume::copyVolumeFaces(const LLVolume* volume) { mVolumeFaces = volume->mVolumeFaces; mSculptLevel = 0; - mIsTetrahedron = FALSE; } void LLVolume::cacheOptimize() @@ -2889,17 +2737,10 @@ void LLVolume::cacheOptimize() } } #endif //MESH_ENABLED + S32 LLVolume::getNumFaces() const { -#if MESH_ENABLED - U8 sculpt_type = (mParams.getSculptType() & LL_SCULPT_TYPE_MASK); - - if (sculpt_type == LL_SCULPT_TYPE_MESH) - { - return LL_SCULPT_MESH_MAX_FACES; - } -#endif //MESH_ENABLED - return (S32)mProfilep->mFaces.size(); + return mIsMeshAssetLoaded ? getNumVolumeFaces() : (S32)mProfilep->mFaces.size(); } @@ -7301,7 +7142,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) resizeVertices(num_vertices); resizeIndices(num_indices); #if MESH_ENABLED - if ((volume->getParams().getSculptType() & LL_SCULPT_TYPE_MASK) != LL_SCULPT_TYPE_MESH) + if (!volume->isMeshAssetLoaded()) #endif //MESH_ENABLED { mEdge.resize(num_indices); diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index c85e43e1f..a20e9a5c9 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -59,7 +59,7 @@ class LLVolumeTriangle; #include "llquaternion.h" #include "llstrider.h" #include "v4coloru.h" -#include "llmemory.h" +#include "llrefcount.h" #include "llfile.h" //============================================================================ @@ -1085,15 +1085,15 @@ protected: public: virtual bool unpackVolumeFaces(std::istream& is, S32 size); - virtual void makeTetrahedron(); - virtual BOOL isTetrahedron(); + virtual void setMeshAssetLoaded(BOOL loaded); + virtual BOOL isMeshAssetLoaded(); #endif //MESH_ENABLED protected: BOOL mUnique; F32 mDetail; S32 mSculptLevel; #if MESH_ENABLED - BOOL mIsTetrahedron; + BOOL mIsMeshAssetLoaded; #endif //MESH_ENABLED LLVolumeParams mParams; diff --git a/indra/llmath/llvolumemgr.h b/indra/llmath/llvolumemgr.h index 28276e46f..f5dc4cd74 100644 --- a/indra/llmath/llvolumemgr.h +++ b/indra/llmath/llvolumemgr.h @@ -36,7 +36,7 @@ #include #include "llvolume.h" -#include "llmemory.h" +#include "llpointer.h" #include "llthread.h" class LLVolumeParams; diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp index 8192b97a9..16ddce622 100644 --- a/indra/llmessage/llcurl.cpp +++ b/indra/llmessage/llcurl.cpp @@ -771,6 +771,8 @@ void LLCurl::Multi::run() void LLCurl::Multi::doPerform() { S32 q = 0; + if (mThreaded) + mSignal->unlock(); for (S32 call_count = 0; call_count < MULTI_PERFORM_CALL_REPEAT; call_count += 1) @@ -783,6 +785,8 @@ void LLCurl::Multi::doPerform() } } + if (mThreaded) + mSignal->lock(); mQueued = q; mPerformState = PERFORM_STATE_COMPLETED; } diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h index 988205921..73516803f 100644 --- a/indra/llmessage/llcurl.h +++ b/indra/llmessage/llcurl.h @@ -47,6 +47,7 @@ #include "llbuffer.h" #include "lliopipe.h" #include "llsd.h" +#include "llthread.h" class LLMutex; diff --git a/indra/llmessage/llhttpnode.h b/indra/llmessage/llhttpnode.h index 7b7e18762..2c0fe8655 100644 --- a/indra/llmessage/llhttpnode.h +++ b/indra/llmessage/llhttpnode.h @@ -33,7 +33,8 @@ #ifndef LL_LLHTTPNODE_H #define LL_LLHTTPNODE_H -#include "llmemory.h" +#include "llpointer.h" +#include "llrefcount.h" #include "llsd.h" class LLChainIOFactory; diff --git a/indra/llmessage/llinstantmessage.cpp b/indra/llmessage/llinstantmessage.cpp index 018b649a6..57e8a2254 100644 --- a/indra/llmessage/llinstantmessage.cpp +++ b/indra/llmessage/llinstantmessage.cpp @@ -41,7 +41,7 @@ #include "llsd.h" #include "llsdserialize.h" #include "llsdutil_math.h" -#include "llmemory.h" +#include "llpointer.h" #include "message.h" #include "message.h" diff --git a/indra/llmessage/llinstantmessage.h b/indra/llmessage/llinstantmessage.h index df8e0bebf..dfc193301 100644 --- a/indra/llmessage/llinstantmessage.h +++ b/indra/llmessage/llinstantmessage.h @@ -36,7 +36,8 @@ #include "llhost.h" #include "lluuid.h" #include "llsd.h" -#include "llmemory.h" +#include "llrefcount.h" +#include "llpointer.h" #include "v3math.h" class LLMessageSystem; diff --git a/indra/llmessage/lltemplatemessagereader.cpp b/indra/llmessage/lltemplatemessagereader.cpp index 93de1b13d..3bcbb070e 100644 --- a/indra/llmessage/lltemplatemessagereader.cpp +++ b/indra/llmessage/lltemplatemessagereader.cpp @@ -434,10 +434,9 @@ inline void LLTemplateMessageReader::getString(const char *block, const char *va inline void LLTemplateMessageReader::getString(const char *block, const char *var, std::string& outstr, S32 blocknum ) { - char s[MTUBYTES]; - s[0] = '\0'; + char s[MTUBYTES + 1]= {0}; // every element is initialized with 0 getData(block, var, s, 0, blocknum, MTUBYTES); - s[MTUBYTES - 1] = '\0'; + s[MTUBYTES] = '\0'; outstr = s; } diff --git a/indra/llmessage/sound_ids.cpp b/indra/llmessage/sound_ids.cpp index 9262a33b3..7e0fec493 100644 --- a/indra/llmessage/sound_ids.cpp +++ b/indra/llmessage/sound_ids.cpp @@ -29,6 +29,7 @@ * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ +#include "linden_common.h" #include "sound_ids.h" diff --git a/indra/llplugin/llpluginprocesschild.cpp b/indra/llplugin/llpluginprocesschild.cpp index fdcb4f6a8..d014cf9bb 100644 --- a/indra/llplugin/llpluginprocesschild.cpp +++ b/indra/llplugin/llpluginprocesschild.cpp @@ -433,7 +433,7 @@ void LLPluginProcessChild::receiveMessageRaw(const std::string &message) } else if(message_name == "sleep_time") { - mSleepTime = parsed.getValueReal("time"); + mSleepTime = llmax(parsed.getValueReal("time"), 1.0 / 100.0); // clamp to maximum of 100Hz } else if(message_name == "crash") { diff --git a/indra/llplugin/llpluginprocessparent.cpp b/indra/llplugin/llpluginprocessparent.cpp index 0d361324e..dd10d73f2 100644 --- a/indra/llplugin/llpluginprocessparent.cpp +++ b/indra/llplugin/llpluginprocessparent.cpp @@ -993,6 +993,7 @@ void LLPluginProcessParent::receiveMessage(const LLPluginMessage &message) } // Send initial sleep time + llassert_always(mSleepTime != 0.f); setSleepTime(mSleepTime, true); setState(STATE_RUNNING); diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index 2f385d944..52171c6bc 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -33,6 +33,7 @@ set(llprimitive_HEADER_FILES legacy_object_types.h llmaterialtable.h + llmediaentry.h llmodel.h llprimitive.h llprimtexturelist.h diff --git a/indra/llprimitive/llmediaentry.h b/indra/llprimitive/llmediaentry.h new file mode 100644 index 000000000..33855b3fb --- /dev/null +++ b/indra/llprimitive/llmediaentry.h @@ -0,0 +1,222 @@ +/** + * @file llmediaentry.h + * @brief This is a single instance of media data related to the face of a prim + * + * $LicenseInfo:firstyear=2001&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_LLMEDIAENTRY_H +#define LL_LLMEDIAENTRY_H + +#include "llsd.h" +#include "llstring.h" + +// For return values of set* +#include "lllslconstants.h" + +class LLMediaEntry +{ +public: + enum MediaControls { + STANDARD = 0, + MINI + }; + + // Constructors + LLMediaEntry(); + LLMediaEntry(const LLMediaEntry &rhs); + + LLMediaEntry &operator=(const LLMediaEntry &rhs); + virtual ~LLMediaEntry(); + + bool operator==(const LLMediaEntry &rhs) const; + bool operator!=(const LLMediaEntry &rhs) const; + + // Render as LLSD + LLSD asLLSD() const; + void asLLSD(LLSD& sd) const; + operator LLSD() const { return asLLSD(); } + // Returns false iff the given LLSD contains fields that violate any bounds + // limits. + static bool checkLLSD(const LLSD& sd); + // This doesn't merge, it overwrites the data, so will use + // LLSD defaults if need be. Note: does not check limits! + // Use checkLLSD() above first to ensure the LLSD is valid. + void fromLLSD(const LLSD& sd); + // This merges data from the incoming LLSD into our fields. + // Note that it also does NOT check limits! Use checkLLSD() above first. + void mergeFromLLSD(const LLSD& sd); + + // "general" fields + bool getAltImageEnable() const { return mAltImageEnable; } + MediaControls getControls() const { return mControls; } + std::string getCurrentURL() const { return mCurrentURL; } + std::string getHomeURL() const { return mHomeURL; } + bool getAutoLoop() const { return mAutoLoop; } + bool getAutoPlay() const { return mAutoPlay; } + bool getAutoScale() const { return mAutoScale; } + bool getAutoZoom() const { return mAutoZoom; } + bool getFirstClickInteract() const { return mFirstClickInteract; } + U16 getWidthPixels() const { return mWidthPixels; } + U16 getHeightPixels() const { return mHeightPixels; } + + // "security" fields + bool getWhiteListEnable() const { return mWhiteListEnable; } + const std::vector &getWhiteList() const { return mWhiteList; } + + // "permissions" fields + U8 getPermsInteract() const { return mPermsInteract; } + U8 getPermsControl() const { return mPermsControl; } + + // Setters. Those that return a U32 return a status error code + // See lllslconstants.h + + // "general" fields + U32 setAltImageEnable(bool alt_image_enable) { mAltImageEnable = alt_image_enable; return LSL_STATUS_OK; } + U32 setControls(MediaControls controls); + U32 setCurrentURL(const std::string& current_url); + U32 setHomeURL(const std::string& home_url); + U32 setAutoLoop(bool auto_loop) { mAutoLoop = auto_loop; return LSL_STATUS_OK; } + U32 setAutoPlay(bool auto_play) { mAutoPlay = auto_play; return LSL_STATUS_OK; } + U32 setAutoScale(bool auto_scale) { mAutoScale = auto_scale; return LSL_STATUS_OK; } + U32 setAutoZoom(bool auto_zoom) { mAutoZoom = auto_zoom; return LSL_STATUS_OK; } + U32 setFirstClickInteract(bool first_click) { mFirstClickInteract = first_click; return LSL_STATUS_OK; } + U32 setWidthPixels(U16 width); + U32 setHeightPixels(U16 height); + + // "security" fields + U32 setWhiteListEnable( bool whitelist_enable ) { mWhiteListEnable = whitelist_enable; return LSL_STATUS_OK; } + U32 setWhiteList( const std::vector &whitelist ); + U32 setWhiteList( const LLSD &whitelist ); // takes an LLSD array + + // "permissions" fields + U32 setPermsInteract( U8 val ); + U32 setPermsControl( U8 val ); + + const LLUUID& getMediaID() const; + + // Helper function to check a candidate URL against the whitelist + // Returns true iff candidate URL passes (or if there is no whitelist), false otherwise + bool checkCandidateUrl(const std::string& url) const; + +public: + // Static function to check a URL against a whitelist + // Returns true iff url passes the given whitelist + static bool checkUrlAgainstWhitelist(const std::string &url, + const std::vector &whitelist); + +public: + // LLSD key defines + // "general" fields + static const char* ALT_IMAGE_ENABLE_KEY; + static const char* CONTROLS_KEY; + static const char* CURRENT_URL_KEY; + static const char* HOME_URL_KEY; + static const char* AUTO_LOOP_KEY; + static const char* AUTO_PLAY_KEY; + static const char* AUTO_SCALE_KEY; + static const char* AUTO_ZOOM_KEY; + static const char* FIRST_CLICK_INTERACT_KEY; + static const char* WIDTH_PIXELS_KEY; + static const char* HEIGHT_PIXELS_KEY; + + // "security" fields + static const char* WHITELIST_ENABLE_KEY; + static const char* WHITELIST_KEY; + + // "permissions" fields + static const char* PERMS_INTERACT_KEY; + static const char* PERMS_CONTROL_KEY; + + // Field enumerations & constants + + // *NOTE: DO NOT change the order of these, and do not insert values + // in the middle! + // Add values to the end, and make sure to change PARAM_MAX_ID! + enum Fields { + ALT_IMAGE_ENABLE_ID = 0, + CONTROLS_ID = 1, + CURRENT_URL_ID = 2, + HOME_URL_ID = 3, + AUTO_LOOP_ID = 4, + AUTO_PLAY_ID = 5, + AUTO_SCALE_ID = 6, + AUTO_ZOOM_ID = 7, + FIRST_CLICK_INTERACT_ID = 8, + WIDTH_PIXELS_ID = 9, + HEIGHT_PIXELS_ID = 10, + WHITELIST_ENABLE_ID = 11, + WHITELIST_ID = 12, + PERMS_INTERACT_ID = 13, + PERMS_CONTROL_ID = 14, + PARAM_MAX_ID = PERMS_CONTROL_ID + }; + + // "permissions" values + // (e.g. (PERM_OWNER | PERM_GROUP) sets permissions on for OWNER and GROUP + static const U8 PERM_NONE = 0x0; + static const U8 PERM_OWNER = 0x1; + static const U8 PERM_GROUP = 0x2; + static const U8 PERM_ANYONE = 0x4; + static const U8 PERM_ALL = PERM_OWNER|PERM_GROUP|PERM_ANYONE; + static const U8 PERM_MASK = PERM_OWNER|PERM_GROUP|PERM_ANYONE; + + // Limits (in bytes) + static const U32 MAX_URL_LENGTH = 1024; + static const U32 MAX_WHITELIST_SIZE = 1024; + static const U32 MAX_WHITELIST_COUNT = 64; + static const U16 MAX_WIDTH_PIXELS = 2048; + static const U16 MAX_HEIGHT_PIXELS = 2048; + +private: + + U32 setStringFieldWithLimit( std::string &field, const std::string &value, U32 limit ); + U32 setCurrentURLInternal( const std::string &url, bool check_whitelist); + bool fromLLSDInternal(const LLSD &sd, bool overwrite); + +private: + // "general" fields + bool mAltImageEnable; + MediaControls mControls; + std::string mCurrentURL; + std::string mHomeURL; + bool mAutoLoop; + bool mAutoPlay; + bool mAutoScale; + bool mAutoZoom; + bool mFirstClickInteract; + U16 mWidthPixels; + U16 mHeightPixels; + + // "security" fields + bool mWhiteListEnable; + std::vector mWhiteList; + + // "permissions" fields + U8 mPermsInteract; + U8 mPermsControl; + + mutable LLUUID *mMediaIDp; // temporary id assigned to media on the viewer +}; + +#endif + diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 1574c2422..37b3d27d1 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -28,6 +28,7 @@ #if MESH_ENABLED #include "llmodel.h" +#include "llmemory.h" #if MESH_IMPORT #include "llconvexdecomposition.h" #endif //MESH_IMPORT @@ -1019,10 +1020,16 @@ void LLModel::setVolumeFaceData( face.resizeVertices(num_verts); face.resizeIndices(num_indices); - LLVector4a::memcpyNonAliased16((F32*) face.mPositions, (F32*) pos.get(), num_verts*4*sizeof(F32)); + if(!pos.isStrided()) + LLVector4a::memcpyNonAliased16((F32*) face.mPositions, (F32*) pos.get(), num_verts*4*sizeof(F32)); + else + for(U32 i=0;i 0) + //if (stage > 0) { gGL.getTexUnit(stage)->activate(); } @@ -284,17 +284,17 @@ void LLCubeMap::setMatrix(S32 stage) glLoadMatrixf((F32 *)trans.mMatrix); glMatrixMode(GL_MODELVIEW); - if (stage > 0) + /*if (stage > 0) { gGL.getTexUnit(0)->activate(); - } + }*/ } void LLCubeMap::restoreMatrix() { if (mMatrixStage < 0) return; - if (mMatrixStage > 0) + //if (mMatrixStage > 0) { gGL.getTexUnit(mMatrixStage)->activate(); } @@ -302,10 +302,10 @@ void LLCubeMap::restoreMatrix() glPopMatrix(); glMatrixMode(GL_MODELVIEW); - if (mMatrixStage > 0) + /*if (mMatrixStage > 0) { gGL.getTexUnit(0)->activate(); - } + }*/ } void LLCubeMap::setReflection (void) diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index d5560b5eb..40baf7b33 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -53,6 +53,7 @@ #include "llstacktrace.h" #include "llglheaders.h" +#include "llglslshader.h" #ifdef _DEBUG //#define GL_STATE_VERIFY @@ -127,6 +128,23 @@ PFNGLUNMAPBUFFERARBPROC glUnmapBufferARB = NULL; PFNGLGETBUFFERPARAMETERIVARBPROC glGetBufferParameterivARB = NULL; PFNGLGETBUFFERPOINTERVARBPROC glGetBufferPointervARB = NULL; +// GL_ARB_map_buffer_range +PFNGLMAPBUFFERRANGEPROC glMapBufferRange = NULL; +PFNGLFLUSHMAPPEDBUFFERRANGEPROC glFlushMappedBufferRange = NULL; + +// GL_ARB_sync +PFNGLFENCESYNCPROC glFenceSync = NULL; +PFNGLISSYNCPROC glIsSync = NULL; +PFNGLDELETESYNCPROC glDeleteSync = NULL; +PFNGLCLIENTWAITSYNCPROC glClientWaitSync = NULL; +PFNGLWAITSYNCPROC glWaitSync = NULL; +PFNGLGETINTEGER64VPROC glGetInteger64v = NULL; +PFNGLGETSYNCIVPROC glGetSynciv = NULL; + +// GL_APPLE_flush_buffer_range +PFNGLBUFFERPARAMETERIAPPLEPROC glBufferParameteriAPPLE = NULL; +PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC glFlushMappedBufferRangeAPPLE = NULL; + // vertex object prototypes PFNGLNEWOBJECTBUFFERATIPROC glNewObjectBufferATI = NULL; PFNGLISOBJECTBUFFERATIPROC glIsObjectBufferATI = NULL; @@ -156,27 +174,33 @@ PFNGLGETQUERYOBJECTUIVARBPROC glGetQueryObjectuivARB = NULL; PFNGLPOINTPARAMETERFARBPROC glPointParameterfARB = NULL; PFNGLPOINTPARAMETERFVARBPROC glPointParameterfvARB = NULL; -// GL_EXT_framebuffer_object -PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT = NULL; -PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT = NULL; -PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT = NULL; -PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT = NULL; -PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT = NULL; -PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glGetRenderbufferParameterivEXT = NULL; -PFNGLISFRAMEBUFFEREXTPROC glIsFramebufferEXT = NULL; -PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT = NULL; -PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT = NULL; -PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT = NULL; -PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT = NULL; -PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glFramebufferTexture1DEXT = NULL; -PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT = NULL; -PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT = NULL; -PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT = NULL; -PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT = NULL; -PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT = NULL; -PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT = NULL; -PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT = NULL; -PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC glFramebufferTextureLayerEXT = NULL; +// GL_ARB_framebuffer_object +PFNGLISRENDERBUFFERPROC glIsRenderbuffer = NULL; +PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer = NULL; +PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers = NULL; +PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers = NULL; +PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage = NULL; +PFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv = NULL; +PFNGLISFRAMEBUFFERPROC glIsFramebuffer = NULL; +PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = NULL; +PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = NULL; +PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers = NULL; +PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus = NULL; +PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D = NULL; +PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D = NULL; +PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D = NULL; +PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer = NULL; +PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv = NULL; +PFNGLGENERATEMIPMAPPROC glGenerateMipmap = NULL; +PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer = NULL; +PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample = NULL; +PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer = NULL; + +//GL_ARB_texture_multisample +PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample; +PFNGLTEXIMAGE3DMULTISAMPLEPROC glTexImage3DMultisample; +PFNGLGETMULTISAMPLEFVPROC glGetMultisamplefv; +PFNGLSAMPLEMASKIPROC glSampleMaski; // GL_EXT_blend_func_separate PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT = NULL; @@ -321,10 +345,13 @@ LLGLManager::LLGLManager() : mHasMipMapGeneration(FALSE), mHasCompressedTextures(FALSE), mHasFramebufferObject(FALSE), + mMaxSamples(0), mHasFramebufferMultisample(FALSE), mHasBlendFuncSeparate(FALSE), - + mHasSync(FALSE), mHasVertexBufferObject(FALSE), + mHasMapBufferRange(FALSE), + mHasFlushBufferRange(FALSE), mHasPBuffer(FALSE), mHasShaderObjects(FALSE), mHasVertexShader(FALSE), @@ -335,6 +362,11 @@ LLGLManager::LLGLManager() : mHasPointParameters(FALSE), mHasDrawBuffers(FALSE), mHasTextureRectangle(FALSE), + mHasTextureMultisample(FALSE), + mMaxSampleMaskWords(0), + mMaxColorTextureSamples(0), + mMaxDepthTextureSamples(0), + mMaxIntegerSamples(0), mHasAnisotropic(FALSE), mHasARBEnvCombine(FALSE), @@ -353,6 +385,8 @@ LLGLManager::LLGLManager() : mHasSeparateSpecularColor(FALSE), + mDebugGPU(FALSE), + mDriverVersionMajor(1), mDriverVersionMinor(0), mDriverVersionRelease(0), @@ -538,13 +572,46 @@ bool LLGLManager::initGL() { GLint num_tex_image_units; glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &num_tex_image_units); - mNumTextureImageUnits = num_tex_image_units; + mNumTextureImageUnits = llmin(num_tex_image_units, 32); } + if (mHasTextureMultisample) + { + glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &mMaxColorTextureSamples); + glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &mMaxDepthTextureSamples); + glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &mMaxIntegerSamples); + glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &mMaxSampleMaskWords); + } + +#if LL_WINDOWS + if (mIsATI) + { //using multisample textures on ATI results in black screen for some reason + mHasTextureMultisample = FALSE; + } +#endif + + if (mHasFramebufferObject) + { + glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples); + } + + setToDebugGPU(); + initGLStates(); return true; } +void LLGLManager::setToDebugGPU() +{ + //"MOBILE INTEL(R) 965 EXPRESS CHIP", + if (mGLRenderer.find("INTEL") != std::string::npos && mGLRenderer.find("965") != std::string::npos) + { + mDebugGPU = TRUE ; + } + + return ; +} + void LLGLManager::getGLInfo(LLSD& info) { info["GLInfo"]["GLVendor"] = std::string((const char *)glGetString(GL_VENDOR)); @@ -601,6 +668,14 @@ std::string LLGLManager::getRawGLString() return gl_string; } +U32 LLGLManager::getNumFBOFSAASamples(U32 samples) +{ + samples = llmin(samples, (U32) mMaxColorTextureSamples); + samples = llmin(samples, (U32) mMaxDepthTextureSamples); + samples = llmin(samples, (U32) 4); + return samples; +} + void LLGLManager::shutdownGL() { if (mInited) @@ -686,6 +761,9 @@ void LLGLManager::initExtensions() mHasOcclusionQuery = ExtensionExists("GL_ARB_occlusion_query", gGLHExts.mSysExts); mHasOcclusionQuery2 = ExtensionExists("GL_ARB_occlusion_query2", gGLHExts.mSysExts); mHasVertexBufferObject = ExtensionExists("GL_ARB_vertex_buffer_object", gGLHExts.mSysExts); + mHasSync = ExtensionExists("GL_ARB_sync", gGLHExts.mSysExts); + mHasMapBufferRange = ExtensionExists("GL_ARB_map_buffer_range", gGLHExts.mSysExts); + mHasFlushBufferRange = ExtensionExists("GL_APPLE_flush_buffer_range", gGLHExts.mSysExts); mHasDepthClamp = ExtensionExists("GL_ARB_depth_clamp", gGLHExts.mSysExts) || ExtensionExists("GL_NV_depth_clamp", gGLHExts.mSysExts); // mask out FBO support when packed_depth_stencil isn't there 'cause we need it for LLRenderTarget -Brad #ifdef GL_ARB_framebuffer_object @@ -700,7 +778,10 @@ void LLGLManager::initExtensions() mHasDrawBuffers = ExtensionExists("GL_ARB_draw_buffers", gGLHExts.mSysExts); mHasBlendFuncSeparate = ExtensionExists("GL_EXT_blend_func_separate", gGLHExts.mSysExts); mHasTextureRectangle = ExtensionExists("GL_ARB_texture_rectangle", gGLHExts.mSysExts); + mHasTextureMultisample = ExtensionExists("GL_ARB_texture_multisample", gGLHExts.mSysExts); +#if !LL_DARWIN mHasPointParameters = !mIsATI && ExtensionExists("GL_ARB_point_parameters", gGLHExts.mSysExts); +#endif mHasShaderObjects = ExtensionExists("GL_ARB_shader_objects", gGLHExts.mSysExts) && ExtensionExists("GL_ARB_shading_language_100", gGLHExts.mSysExts); mHasVertexShader = ExtensionExists("GL_ARB_vertex_program", gGLHExts.mSysExts) && ExtensionExists("GL_ARB_vertex_shader", gGLHExts.mSysExts) && ExtensionExists("GL_ARB_shading_language_100", gGLHExts.mSysExts); @@ -879,29 +960,44 @@ void LLGLManager::initExtensions() mHasVertexBufferObject = FALSE; } } + if (mHasSync) + { + glFenceSync = (PFNGLFENCESYNCPROC) GLH_EXT_GET_PROC_ADDRESS("glFenceSync"); + glIsSync = (PFNGLISSYNCPROC) GLH_EXT_GET_PROC_ADDRESS("glIsSync"); + glDeleteSync = (PFNGLDELETESYNCPROC) GLH_EXT_GET_PROC_ADDRESS("glDeleteSync"); + glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC) GLH_EXT_GET_PROC_ADDRESS("glClientWaitSync"); + glWaitSync = (PFNGLWAITSYNCPROC) GLH_EXT_GET_PROC_ADDRESS("glWaitSync"); + glGetInteger64v = (PFNGLGETINTEGER64VPROC) GLH_EXT_GET_PROC_ADDRESS("glGetInteger64v"); + glGetSynciv = (PFNGLGETSYNCIVPROC) GLH_EXT_GET_PROC_ADDRESS("glGetSynciv"); + } + if (mHasMapBufferRange) + { + glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC) GLH_EXT_GET_PROC_ADDRESS("glMapBufferRange"); + glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC) GLH_EXT_GET_PROC_ADDRESS("glFlushMappedBufferRange"); + } if (mHasFramebufferObject) { llinfos << "initExtensions() FramebufferObject-related procs..." << llendl; - glIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC) GLH_EXT_GET_PROC_ADDRESS("glIsRenderbufferEXT"); - glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) GLH_EXT_GET_PROC_ADDRESS("glBindRenderbufferEXT"); - glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glDeleteRenderbuffersEXT"); - glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glGenRenderbuffersEXT"); - glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glRenderbufferStorageEXT"); - glGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glGetRenderbufferParameterivEXT"); - glIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC) GLH_EXT_GET_PROC_ADDRESS("glIsFramebufferEXT"); - glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) GLH_EXT_GET_PROC_ADDRESS("glBindFramebufferEXT"); - glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glDeleteFramebuffersEXT"); - glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glGenFramebuffersEXT"); - glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glCheckFramebufferStatusEXT"); - glFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glFramebufferTexture1DEXT"); - glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glFramebufferTexture2DEXT"); - glFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glFramebufferTexture3DEXT"); - glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) GLH_EXT_GET_PROC_ADDRESS("glFramebufferRenderbufferEXT"); - glGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glGetFramebufferAttachmentParameterivEXT"); - glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glGenerateMipmapEXT"); - glBlitFramebufferEXT = (PFNGLBLITFRAMEBUFFEREXTPROC) GLH_EXT_GET_PROC_ADDRESS("glBlitFramebufferEXT"); - glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glRenderbufferStorageMultisampleEXT"); - glFramebufferTextureLayerEXT = (PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) GLH_EXT_GET_PROC_ADDRESS("glFramebufferTextureLayerEXT"); + glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) GLH_EXT_GET_PROC_ADDRESS("glIsRenderbuffer"); + glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) GLH_EXT_GET_PROC_ADDRESS("glBindRenderbuffer"); + glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) GLH_EXT_GET_PROC_ADDRESS("glDeleteRenderbuffers"); + glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) GLH_EXT_GET_PROC_ADDRESS("glGenRenderbuffers"); + glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) GLH_EXT_GET_PROC_ADDRESS("glRenderbufferStorage"); + glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) GLH_EXT_GET_PROC_ADDRESS("glGetRenderbufferParameteriv"); + glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) GLH_EXT_GET_PROC_ADDRESS("glIsFramebuffer"); + glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) GLH_EXT_GET_PROC_ADDRESS("glBindFramebuffer"); + glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) GLH_EXT_GET_PROC_ADDRESS("glDeleteFramebuffers"); + glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) GLH_EXT_GET_PROC_ADDRESS("glGenFramebuffers"); + glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) GLH_EXT_GET_PROC_ADDRESS("glCheckFramebufferStatus"); + glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) GLH_EXT_GET_PROC_ADDRESS("glFramebufferTexture1D"); + glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) GLH_EXT_GET_PROC_ADDRESS("glFramebufferTexture2D"); + glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) GLH_EXT_GET_PROC_ADDRESS("glFramebufferTexture3D"); + glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) GLH_EXT_GET_PROC_ADDRESS("glFramebufferRenderbuffer"); + glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) GLH_EXT_GET_PROC_ADDRESS("glGetFramebufferAttachmentParameteriv"); + glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) GLH_EXT_GET_PROC_ADDRESS("glGenerateMipmap"); + glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC) GLH_EXT_GET_PROC_ADDRESS("glBlitFramebuffer"); + glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) GLH_EXT_GET_PROC_ADDRESS("glRenderbufferStorageMultisample"); + glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC) GLH_EXT_GET_PROC_ADDRESS("glFramebufferTextureLayer"); } if (mHasDrawBuffers) { @@ -911,6 +1007,13 @@ void LLGLManager::initExtensions() { glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glBlendFuncSeparateEXT"); } + if (mHasTextureMultisample) + { + glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC) GLH_EXT_GET_PROC_ADDRESS("glTexImage2DMultisample"); + glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC) GLH_EXT_GET_PROC_ADDRESS("glTexImage3DMultisample"); + glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC) GLH_EXT_GET_PROC_ADDRESS("glGetMultisamplefv"); + glSampleMaski = (PFNGLSAMPLEMASKIPROC) GLH_EXT_GET_PROC_ADDRESS("glSampleMaski"); + } #if (!LL_LINUX && !LL_SOLARIS) || LL_LINUX_NV_GL_HEADERS // This is expected to be a static symbol on Linux GL implementations, except if we use the nvidia headers - bah glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)GLH_EXT_GET_PROC_ADDRESS("glDrawRangeElements"); @@ -1299,6 +1402,7 @@ void LLGLState::checkStates(const std::string& msg) void LLGLState::checkTextureChannels(const std::string& msg) { +#if 0 if (!gDebugGL) { return; @@ -1458,11 +1562,12 @@ void LLGLState::checkTextureChannels(const std::string& msg) LL_GL_ERRS << "GL texture state corruption detected. " << msg << LL_ENDL; } } +#endif } void LLGLState::checkClientArrays(const std::string& msg, U32 data_mask) { - if (!gDebugGL) + if (!gDebugGL || LLGLSLShader::sNoFixedFunction) { return; } @@ -1574,7 +1679,7 @@ void LLGLState::checkClientArrays(const std::string& msg, U32 data_mask) } } - if (glIsEnabled(GL_TEXTURE_2D)) + /*if (glIsEnabled(GL_TEXTURE_2D)) { if (!(data_mask & 0x0008)) { @@ -1597,7 +1702,7 @@ void LLGLState::checkClientArrays(const std::string& msg, U32 data_mask) gFailLog << "GL does not have GL_TEXTURE_2D enabled on channel 1." << std::endl; } } - } + }*/ glClientActiveTextureARB(GL_TEXTURE0_ARB); gGL.getTexUnit(0)->activate(); @@ -1640,6 +1745,16 @@ void LLGLState::checkClientArrays(const std::string& msg, U32 data_mask) LLGLState::LLGLState(LLGLenum state, S32 enabled) : mState(state), mWasEnabled(FALSE), mIsEnabled(FALSE) { + if (LLGLSLShader::sNoFixedFunction) + { //always disable state that's deprecated post GL 3.0 + switch (state) + { + case GL_ALPHA_TEST: + enabled = 0; + break; + } + } + stop_glerror(); if (state) { @@ -1998,8 +2113,7 @@ void LLGLNamePool::release(GLuint name) //static void LLGLNamePool::upkeepPools() { - tracker_t::LLInstanceTrackerScopedGuard guard; - for (tracker_t::instance_iter iter = guard.beginInstances(); iter != guard.endInstances(); ++iter) + for (tracker_t::instance_iter iter = beginInstances(); iter != endInstances(); ++iter) { LLGLNamePool & pool = *iter; pool.upkeep(); @@ -2009,8 +2123,7 @@ void LLGLNamePool::upkeepPools() //static void LLGLNamePool::cleanupPools() { - tracker_t::LLInstanceTrackerScopedGuard guard; - for (tracker_t::instance_iter iter = guard.beginInstances(); iter != guard.endInstances(); ++iter) + for (tracker_t::instance_iter iter = beginInstances(); iter != endInstances(); ++iter) { LLGLNamePool & pool = *iter; pool.cleanup(); diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index 2e0ca22e5..736cc1b0d 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -89,11 +89,15 @@ public: BOOL mHasMipMapGeneration; BOOL mHasCompressedTextures; BOOL mHasFramebufferObject; + S32 mMaxSamples; BOOL mHasFramebufferMultisample; BOOL mHasBlendFuncSeparate; // ARB Extensions BOOL mHasVertexBufferObject; + BOOL mHasSync; + BOOL mHasMapBufferRange; + BOOL mHasFlushBufferRange; BOOL mHasPBuffer; BOOL mHasShaderObjects; BOOL mHasVertexShader; @@ -105,6 +109,11 @@ public: BOOL mHasDrawBuffers; BOOL mHasDepthClamp; BOOL mHasTextureRectangle; + BOOL mHasTextureMultisample; + S32 mMaxSampleMaskWords; + S32 mMaxColorTextureSamples; + S32 mMaxDepthTextureSamples; + S32 mMaxIntegerSamples; // Other extensions. BOOL mHasAnisotropic; @@ -126,6 +135,9 @@ public: // Misc extensions BOOL mHasSeparateSpecularColor; + + //whether this GPU is in the debug list. + BOOL mDebugGPU; S32 mDriverVersionMajor; S32 mDriverVersionMinor; @@ -143,6 +155,7 @@ public: void printGLInfoString(); void getGLInfo(LLSD& info); + U32 getNumFBOFSAASamples(U32 desired_samples = 32); // In ALL CAPS std::string mGLVendor; std::string mGLVendorShort; @@ -154,6 +167,7 @@ private: void initExtensions(); void initGLStates(); void initGLImages(); + void setToDebugGPU(); }; extern LLGLManager gGLManager; diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h index 9efe16432..f18c6dbb3 100644 --- a/indra/llrender/llglheaders.h +++ b/indra/llrender/llglheaders.h @@ -76,6 +76,23 @@ extern PFNGLUNMAPBUFFERARBPROC glUnmapBufferARB; extern PFNGLGETBUFFERPARAMETERIVARBPROC glGetBufferParameterivARB; extern PFNGLGETBUFFERPOINTERVARBPROC glGetBufferPointervARB; +// GL_ARB_sync +extern PFNGLFENCESYNCPROC glFenceSync; +extern PFNGLISSYNCPROC glIsSync; +extern PFNGLDELETESYNCPROC glDeleteSync; +extern PFNGLCLIENTWAITSYNCPROC glClientWaitSync; +extern PFNGLWAITSYNCPROC glWaitSync; +extern PFNGLGETINTEGER64VPROC glGetInteger64v; +extern PFNGLGETSYNCIVPROC glGetSynciv; + +// GL_APPLE_flush_buffer_range +extern PFNGLBUFFERPARAMETERIAPPLEPROC glBufferParameteriAPPLE; +extern PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC glFlushMappedBufferRangeAPPLE; + +// GL_ARB_map_buffer_range +extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange; +extern PFNGLFLUSHMAPPEDBUFFERRANGEPROC glFlushMappedBufferRange; + // GL_ATI_vertex_array_object extern PFNGLNEWOBJECTBUFFERATIPROC glNewObjectBufferATI; extern PFNGLISOBJECTBUFFERATIPROC glIsObjectBufferATI; @@ -312,6 +329,23 @@ extern PFNGLUNMAPBUFFERARBPROC glUnmapBufferARB; extern PFNGLGETBUFFERPARAMETERIVARBPROC glGetBufferParameterivARB; extern PFNGLGETBUFFERPOINTERVARBPROC glGetBufferPointervARB; +// GL_ARB_sync +extern PFNGLFENCESYNCPROC glFenceSync; +extern PFNGLISSYNCPROC glIsSync; +extern PFNGLDELETESYNCPROC glDeleteSync; +extern PFNGLCLIENTWAITSYNCPROC glClientWaitSync; +extern PFNGLWAITSYNCPROC glWaitSync; +extern PFNGLGETINTEGER64VPROC glGetInteger64v; +extern PFNGLGETSYNCIVPROC glGetSynciv; + +// GL_APPLE_flush_buffer_range +extern PFNGLBUFFERPARAMETERIAPPLEPROC glBufferParameteriAPPLE; +extern PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC glFlushMappedBufferRangeAPPLE; + +// GL_ARB_map_buffer_range +extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange; +extern PFNGLFLUSHMAPPEDBUFFERRANGEPROC glFlushMappedBufferRange; + // GL_ATI_vertex_array_object extern PFNGLNEWOBJECTBUFFERATIPROC glNewObjectBufferATI; extern PFNGLISOBJECTBUFFERATIPROC glIsObjectBufferATI; @@ -455,31 +489,36 @@ extern PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glGetCompressedTexImageARB; //GL_EXT_blend_func_separate extern PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT; -//GL_EXT_framebuffer_object -extern PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT; -extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT; -extern PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT; -extern PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT; -extern PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT; -extern PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glGetRenderbufferParameterivEXT; -extern PFNGLISFRAMEBUFFEREXTPROC glIsFramebufferEXT; -extern PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT; -extern PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT; -extern PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT; -extern PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT; -extern PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glFramebufferTexture1DEXT; -extern PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT; -extern PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT; -extern PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT; -extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT; -extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT; -extern PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT; -extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT; -extern PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC glFramebufferTextureLayerEXT; +//GL_ARB_framebuffer_object +extern PFNGLISRENDERBUFFERPROC glIsRenderbuffer; +extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; +extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; +extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; +extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; +extern PFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv; +extern PFNGLISFRAMEBUFFERPROC glIsFramebuffer; +extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; +extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; +extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; +extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; +extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D; +extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; +extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D; +extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; +extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv; +extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap; +extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; +extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample; +extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer; //GL_ARB_draw_buffers extern PFNGLDRAWBUFFERSARBPROC glDrawBuffersARB; +//GL_ARB_texture_multisample +extern PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample; +extern PFNGLTEXIMAGE3DMULTISAMPLEPROC glTexImage3DMultisample; +extern PFNGLGETMULTISAMPLEFVPROC glGetMultisamplefv; +extern PFNGLSAMPLEMASKIPROC glSampleMaski; #elif LL_WINDOWS //---------------------------------------------------------------------------- @@ -512,6 +551,23 @@ extern PFNGLUNMAPBUFFERARBPROC glUnmapBufferARB; extern PFNGLGETBUFFERPARAMETERIVARBPROC glGetBufferParameterivARB; extern PFNGLGETBUFFERPOINTERVARBPROC glGetBufferPointervARB; +// GL_ARB_sync +extern PFNGLFENCESYNCPROC glFenceSync; +extern PFNGLISSYNCPROC glIsSync; +extern PFNGLDELETESYNCPROC glDeleteSync; +extern PFNGLCLIENTWAITSYNCPROC glClientWaitSync; +extern PFNGLWAITSYNCPROC glWaitSync; +extern PFNGLGETINTEGER64VPROC glGetInteger64v; +extern PFNGLGETSYNCIVPROC glGetSynciv; + +// GL_APPLE_flush_buffer_range +extern PFNGLBUFFERPARAMETERIAPPLEPROC glBufferParameteriAPPLE; +extern PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC glFlushMappedBufferRangeAPPLE; + +// GL_ARB_map_buffer_range +extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange; +extern PFNGLFLUSHMAPPEDBUFFERRANGEPROC glFlushMappedBufferRange; + // GL_ATI_vertex_array_object extern PFNGLNEWOBJECTBUFFERATIPROC glNewObjectBufferATI; extern PFNGLISOBJECTBUFFERATIPROC glIsObjectBufferATI; @@ -654,31 +710,37 @@ extern PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB; //GL_EXT_blend_func_separate extern PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT; -//GL_EXT_framebuffer_object -extern PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT; -extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT; -extern PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT; -extern PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT; -extern PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT; -extern PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glGetRenderbufferParameterivEXT; -extern PFNGLISFRAMEBUFFEREXTPROC glIsFramebufferEXT; -extern PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT; -extern PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT; -extern PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT; -extern PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT; -extern PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glFramebufferTexture1DEXT; -extern PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT; -extern PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT; -extern PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT; -extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT; -extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT; -extern PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT; -extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT; -extern PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC glFramebufferTextureLayerEXT; +//GL_ARB_framebuffer_object +extern PFNGLISRENDERBUFFERPROC glIsRenderbuffer; +extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; +extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; +extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; +extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; +extern PFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv; +extern PFNGLISFRAMEBUFFERPROC glIsFramebuffer; +extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; +extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; +extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; +extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; +extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D; +extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; +extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D; +extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; +extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv; +extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap; +extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; +extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample; +extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer; //GL_ARB_draw_buffers extern PFNGLDRAWBUFFERSARBPROC glDrawBuffersARB; +//GL_ARB_texture_multisample +extern PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample; +extern PFNGLTEXIMAGE3DMULTISAMPLEPROC glTexImage3DMultisample; +extern PFNGLGETMULTISAMPLEFVPROC glGetMultisamplefv; +extern PFNGLSAMPLEMASKIPROC glSampleMaski; + #elif LL_DARWIN //---------------------------------------------------------------------------- // LL_DARWIN @@ -696,7 +758,7 @@ extern PFNGLDRAWBUFFERSARBPROC glDrawBuffersARB; #include //GL_EXT_blend_func_separate -extern void glBlendFuncSeparateEXT(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; +extern void glBlendFuncSeparateEXT(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) ; // GL_EXT_framebuffer_object extern GLboolean glIsRenderbufferEXT(GLuint renderbuffer) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; @@ -719,6 +781,7 @@ extern void glGenerateMipmapEXT(GLenum target) AVAILABLE_MAC_OS_X_VERSION_10_4_A #ifndef GL_ARB_framebuffer_object #define glGenerateMipmap glGenerateMipmapEXT +#define GL_MAX_SAMPLES 0x8D57 #endif // GL_ARB_draw_buffers extern void glDrawBuffersARB(GLsizei n, const GLenum* bufs) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; @@ -726,6 +789,46 @@ extern void glDrawBuffersARB(GLsizei n, const GLenum* bufs) AVAILABLE_MAC_OS_X_V #ifdef __cplusplus extern "C" { #endif + +// +// Define map buffer range headers on Mac +// +#ifndef GL_ARB_map_buffer_range +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#endif + +// +// Define multisample headers on Mac +// +#ifndef GL_ARB_texture_multisample +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +#endif + // // Define vertex buffer object headers on Mac // diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index ec306ba26..d84158342 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -37,6 +37,7 @@ #include "llshadermgr.h" #include "llfile.h" #include "llrender.h" +#include "llcontrol.h" #if LL_DARWIN #include "OpenGL/OpenGL.h" @@ -54,6 +55,16 @@ using std::pair; using std::make_pair; using std::string; +GLhandleARB LLGLSLShader::sCurBoundShader = 0; +LLGLSLShader* LLGLSLShader::sCurBoundShaderPtr = NULL; +bool LLGLSLShader::sNoFixedFunction = false; + +//UI shader -- declared here so llui_libtest will link properly +//Singu note: Not using llui_libtest... and LLViewerShaderMgr is a part of newview. So, +// these are declared in newview/llviewershadermanager.cpp just like every other shader. +//LLGLSLShader gUIProgram(LLViewerShaderMgr::SHADER_INTERFACE); +//LLGLSLShader gSolidColorProgram(LLViewerShaderMgr::SHADER_INTERFACE); + BOOL shouldChange(const LLVector4& v1, const LLVector4& v2) { return v1 != v2; @@ -63,6 +74,7 @@ LLShaderFeatures::LLShaderFeatures() : calculatesLighting(false), isShiny(false), isFullbright(false), hasWaterFog(false), hasTransport(false), hasSkinning(false), hasAtmospherics(false), isSpecular(false), hasGamma(false), hasLighting(false), calculatesAtmospherics(false) +, mIndexedTextureChannels(0), disableTextureIndex(false), hasAlphaMask(false) #if MESH_ENABLED , hasObjectSkinning(false) #endif //MESH_ENABLED @@ -119,6 +131,28 @@ BOOL LLGLSLShader::createShader(vector * attributes, glDeleteObjectARB(mProgramObject); // Create program mProgramObject = glCreateProgramObjectARB(); + + static const LLCachedControl no_texture_indexing("ShyotlUseLegacyTextureBatching",false); + if (gGLManager.mGLVersion < 3.1f || no_texture_indexing) + { //force indexed texture channels to 1 if GL version is old (performance improvement for drivers with poor branching shader model support) + mFeatures.mIndexedTextureChannels = llmin(mFeatures.mIndexedTextureChannels, 1); + } + + //compile new source + vector< pair >::iterator fileIter = mShaderFiles.begin(); + for ( ; fileIter != mShaderFiles.end(); fileIter++ ) + { + GLhandleARB shaderhandle = LLShaderMgr::instance()->loadShaderFile((*fileIter).first, mShaderLevel, (*fileIter).second, mFeatures.mIndexedTextureChannels); + LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << LL_ENDL; + if (shaderhandle > 0) + { + attachObject(shaderhandle); + } + else + { + success = FALSE; + } + } // Attach existing objects if (!LLShaderMgr::instance()->attachShaderFeatures(this)) @@ -129,19 +163,9 @@ BOOL LLGLSLShader::createShader(vector * attributes, return FALSE; } - vector< pair >::iterator fileIter = mShaderFiles.begin(); - for ( ; fileIter != mShaderFiles.end(); fileIter++ ) - { - GLhandleARB shaderhandle = LLShaderMgr::instance()->loadShaderFile((*fileIter).first, mShaderLevel, (*fileIter).second); - LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << LL_ENDL; - if (mShaderLevel > 0) - { - attachObject(shaderhandle); - } - else - { - success = FALSE; - } + if (gGLManager.mGLVersion < 3.1f || no_texture_indexing) + { //attachShaderFeatures may have set the number of indexed texture channels, so set to 1 again + mFeatures.mIndexedTextureChannels = llmin(mFeatures.mIndexedTextureChannels, 1); } // Map attributes and uniforms @@ -169,6 +193,28 @@ BOOL LLGLSLShader::createShader(vector * attributes, return createShader(attributes,uniforms); } } + else if (mFeatures.mIndexedTextureChannels > 0) + { //override texture channels for indexed texture rendering + bind(); + S32 channel_count = mFeatures.mIndexedTextureChannels; + + for (S32 i = 0; i < channel_count; i++) + { + uniform1i(llformat("tex%d", i), i); + } + + S32 cur_tex = channel_count; //adjust any texture channels that might have been overwritten + for (U32 i = 0; i < mTexture.size(); i++) + { + if (mTexture[i] > -1 && mTexture[i] < channel_count) + { + llassert(cur_tex < gGLManager.mNumTextureImageUnits); + uniform1i(i, cur_tex); + mTexture[i] = cur_tex++; + } + } + unbind(); + } return success; } @@ -314,7 +360,8 @@ void LLGLSLShader::mapUniform(GLint index, const vector * uniforms) GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type) { - if (type >= GL_SAMPLER_1D_ARB && type <= GL_SAMPLER_2D_RECT_SHADOW_ARB) + if (type >= GL_SAMPLER_1D_ARB && type <= GL_SAMPLER_2D_RECT_SHADOW_ARB /*|| + type == GL_SAMPLER_2D_MULTISAMPLE*/) { //this here is a texture glUniform1iARB(location, mActiveTextureChannels); LL_DEBUGS("ShaderLoading") << "Assigned to texture channel " << mActiveTextureChannels << LL_ENDL; @@ -360,10 +407,12 @@ BOOL LLGLSLShader::link(BOOL suppress_errors) void LLGLSLShader::bind() { + gGL.flush(); if (gGLManager.mHasShaderObjects) { glUseProgramObjectARB(mProgramObject); - + sCurBoundShader = mProgramObject; + sCurBoundShaderPtr = this; if (mUniformsDirty) { LLShaderMgr::instance()->updateShaderUniforms(this); @@ -374,6 +423,7 @@ void LLGLSLShader::bind() void LLGLSLShader::unbind() { + gGL.flush(); if (gGLManager.mHasShaderObjects) { stop_glerror(); @@ -386,6 +436,8 @@ void LLGLSLShader::unbind() } } glUseProgramObjectARB(0); + sCurBoundShader = 0; + sCurBoundShaderPtr = NULL; stop_glerror(); } } @@ -393,6 +445,8 @@ void LLGLSLShader::unbind() void LLGLSLShader::bindNoShader(void) { glUseProgramObjectARB(0); + sCurBoundShader = 0; + sCurBoundShaderPtr = NULL; } S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode) @@ -938,6 +992,12 @@ void LLGLSLShader::uniformMatrix4fv(const string& uniform, U32 count, GLboolean } } + +void LLGLSLShader::setAlphaRange(F32 minimum, F32 maximum) +{ + uniform1f("minimum_alpha", minimum); + uniform1f("maximum_alpha", maximum); +} void LLGLSLShader::vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 3f8a6cb96..f05176fd5 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -53,6 +53,9 @@ public: #endif //MESH_ENABLED bool hasAtmospherics; bool hasGamma; + S32 mIndexedTextureChannels; + bool disableTextureIndex; + bool hasAlphaMask; // char numLights; @@ -72,6 +75,10 @@ public: LLGLSLShader(S32 shader_class); + static GLhandleARB sCurBoundShader; + static LLGLSLShader* sCurBoundShaderPtr; + static bool sNoFixedFunction; + void unload(); BOOL createShader(std::vector * attributes, std::vector * uniforms); @@ -108,6 +115,8 @@ public: void uniformMatrix3fv(const std::string& uniform, U32 count, GLboolean transpose, const GLfloat *v); void uniformMatrix4fv(const std::string& uniform, U32 count, GLboolean transpose, const GLfloat *v); + void setAlphaRange(F32 minimum, F32 maximum); + void vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); void vertexAttrib4fv(U32 index, GLfloat* v); @@ -146,4 +155,9 @@ public: std::string mName; }; +//UI shader (declared here so llui_libtest will link properly) +extern LLGLSLShader gUIProgram; +//output vec4(color.rgb,color.a*tex0[tc0].a) +extern LLGLSLShader gSolidColorProgram; + #endif diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index a439d954c..e5a782f3f 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1400,22 +1400,36 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre void LLImageGL::deleteDeadTextures() { + bool reset = false; + while (!sDeadTextureList.empty()) { GLuint tex = sDeadTextureList.front(); sDeadTextureList.pop_front(); - for (int i = 0; i < gGLManager.mNumTextureUnits; i++) + for (int i = 0; i < gGLManager.mNumTextureImageUnits; i++) { - if (sCurrentBoundTextures[i] == tex) + LLTexUnit* tex_unit = gGL.getTexUnit(i); + + if (tex_unit->getCurrTexture() == tex) { - gGL.getTexUnit(i)->unbind(LLTexUnit::TT_TEXTURE); + tex_unit->unbind(tex_unit->getCurrType()); stop_glerror(); + + if (i > 0) + { + reset = true; + } } } glDeleteTextures(1, &tex); stop_glerror(); } + + if (reset) + { + gGL.getTexUnit(0)->activate(); + } } void LLImageGL::destroyGLTexture() diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 60e2682a9..a88d1dca6 100644 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -37,7 +37,8 @@ #include "llimage.h" #include "llgltypes.h" -#include "llmemory.h" +#include "llpointer.h" +#include "llrefcount.h" #include "v2math.h" #include "llrender.h" diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 64f92ae73..5cd77af36 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -36,6 +36,7 @@ #include "llvertexbuffer.h" #include "llcubemap.h" +#include "llglslshader.h" #include "llimagegl.h" #include "llrendertarget.h" #include "lltexture.h" @@ -49,7 +50,9 @@ F64 gGLLastProjection[16]; F64 gGLProjection[16]; S32 gGLViewport[4]; -static const U32 LL_NUM_TEXTURE_LAYERS = 8; +U32 LLTexUnit::sWhiteTexture = 0; + +static const U32 LL_NUM_TEXTURE_LAYERS = 32; static const U32 LL_NUM_LIGHT_UNITS = 8; static GLenum sGLTextureType[] = @@ -57,6 +60,7 @@ static GLenum sGLTextureType[] = GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_CUBE_MAP_ARB + //,GL_TEXTURE_2D_MULTISAMPLE Don't use. }; static GLint sGLAddressMode[] = @@ -127,7 +131,8 @@ void LLTexUnit::refreshState(void) // Per apple spec, don't call glEnable/glDisable when index exceeds max texture units // http://www.mailinglistarchive.com/html/mac-opengl@lists.apple.com/2008-07/msg00653.html // - bool enableDisable = (mIndex < gGLManager.mNumTextureUnits); + bool enableDisable = !LLGLSLShader::sNoFixedFunction && + (mIndex < gGLManager.mNumTextureUnits) /*&& mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE*/; if (mCurrTexType != TT_NONE) { @@ -183,8 +188,11 @@ void LLTexUnit::enable(eTextureType type) disable(); // Force a disable of a previous texture type if it's enabled. } mCurrTexType = type; + gGL.flush(); - if (mIndex < gGLManager.mNumTextureUnits) + if (!LLGLSLShader::sNoFixedFunction && + //type != LLTexUnit::TT_MULTISAMPLE_TEXTURE && + mIndex < gGLManager.mNumTextureUnits) { glEnable(sGLTextureType[type]); } @@ -200,7 +208,9 @@ void LLTexUnit::disable(void) activate(); unbind(mCurrTexType); gGL.flush(); - if (mIndex < gGLManager.mNumTextureUnits) + if (!LLGLSLShader::sNoFixedFunction && + //mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE && + mIndex < gGLManager.mNumTextureUnits) { glDisable(sGLTextureType[mCurrTexType]); } @@ -404,7 +414,15 @@ void LLTexUnit::unbind(eTextureType type) activate(); mCurrTexture = 0; - glBindTexture(sGLTextureType[type], 0); + if (LLGLSLShader::sNoFixedFunction && type == LLTexUnit::TT_TEXTURE) + { + glBindTexture(sGLTextureType[type], sWhiteTexture); + } + else + { + glBindTexture(sGLTextureType[type], 0); + } + stop_glerror(); } } @@ -426,7 +444,7 @@ void LLTexUnit::setTextureAddressMode(eTextureAddressMode mode) void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions option) { - if (mIndex < 0 || mCurrTexture == 0) return; + if (mIndex < 0 || mCurrTexture == 0 /*|| mCurrTexType == LLTexUnit::TT_MULTISAMPLE_TEXTURE*/) return; gGL.flush(); @@ -474,6 +492,11 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio void LLTexUnit::setTextureBlendType(eTextureBlendType type) { + if (LLGLSLShader::sNoFixedFunction) + { //texture blend type means nothing when using shaders + return; + } + if (mIndex < 0) return; // Do nothing if it's already correctly set. @@ -594,6 +617,11 @@ GLint LLTexUnit::getTextureSourceType(eTextureBlendSrc src, bool isAlpha) void LLTexUnit::setTextureCombiner(eTextureBlendOp op, eTextureBlendSrc src1, eTextureBlendSrc src2, bool isAlpha) { + if (LLGLSLShader::sNoFixedFunction) + { //register combiners do nothing when not using fixed function + return; + } + if (mIndex < 0) return; activate(); @@ -1064,6 +1092,10 @@ void LLRender::setSceneBlendType(eBlendType type) void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value) { flush(); + if (LLGLSLShader::sNoFixedFunction) + { //glAlphaFunc is deprecated in OpenGL 3.3 + return; + } if (mCurrAlphaFunc != func || mCurrAlphaFuncVal != value) @@ -1079,6 +1111,30 @@ void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value) glAlphaFunc(sGLCompareFunc[func], value); } } + + if (gDebugGL) + { //make sure cached state is correct + GLint cur_func = 0; + glGetIntegerv(GL_ALPHA_TEST_FUNC, &cur_func); + + if (func == CF_DEFAULT) + { + func = CF_GREATER; + } + + if (cur_func != sGLCompareFunc[func]) + { + llerrs << "Alpha test function corrupted!" << llendl; + } + + F32 ref = 0.f; + glGetFloatv(GL_ALPHA_TEST_REF, &ref); + + if (ref != value) + { + llerrs << "Alpha test value corrupted!" << llendl; + } + } } void LLRender::blendFunc(eBlendFactor sfactor, eBlendFactor dfactor) diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 6dd4db9e5..0c6cc4589 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -58,11 +58,13 @@ class LLTexUnit { friend class LLRender; public: + static U32 sWhiteTexture; typedef enum { TT_TEXTURE = 0, // Standard 2D Texture TT_RECT_TEXTURE, // Non power of 2 texture TT_CUBE_MAP, // 6-sided cube map texture + //TT_MULTISAMPLE_TEXTURE, // see GL_ARB_texture_multisample Do not use TT_NONE // No texture type is currently enabled } eTextureType; diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index 4b9a897bb..145b02631 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -44,13 +44,14 @@ void check_framebuffer_status() { if (gDebugGL) { - GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + GLenum status = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER); switch (status) { - case GL_FRAMEBUFFER_COMPLETE_EXT: + case GL_FRAMEBUFFER_COMPLETE: break; default: - llerrs <<"check_framebuffer_status failed" << llendl; + llwarns << "check_framebuffer_status failed -- " << std::hex << status << llendl; + ll_fail("check_framebuffer_status failed"); break; } } @@ -84,9 +85,12 @@ void LLRenderTarget::setSampleBuffer(LLMultisampleBuffer* buffer) mSampleBuffer = buffer; } -void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo) +bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo) { stop_glerror(); + release(); + stop_glerror(); + mResX = resx; mResY = resy; @@ -94,48 +98,49 @@ void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, boo mUsage = usage; mUseDepth = depth; - release(); if ((sUseFBO || use_fbo) && gGLManager.mHasFramebufferObject) { if (depth) { - stop_glerror(); - allocateDepth(); - stop_glerror(); + if (!allocateDepth()) + { + llwarns << "Failed to allocate depth buffer for render target." << llendl; + return false; + } } - glGenFramebuffersEXT(1, (GLuint *) &mFBO); + glGenFramebuffers(1, (GLuint *) &mFBO); if (mDepth) { - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO); + glBindFramebuffer(GL_FRAMEBUFFER, mFBO); if (mStencil) { - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mDepth); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mDepth); stop_glerror(); - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mDepth); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mDepth); stop_glerror(); } else { - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, LLTexUnit::getInternalType(mUsage), mDepth, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, LLTexUnit::getInternalType(mUsage), mDepth, 0); stop_glerror(); } - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); } stop_glerror(); } - addColorAttachment(color_fmt); + return addColorAttachment(color_fmt); } -void LLRenderTarget::addColorAttachment(U32 color_fmt) +bool LLRenderTarget::addColorAttachment(U32 color_fmt) { if (color_fmt == 0) { - return; + return true; } U32 offset = mTex.size(); @@ -151,52 +156,78 @@ void LLRenderTarget::addColorAttachment(U32 color_fmt) stop_glerror(); - LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + { + clear_glerror(); + LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + if (glGetError() != GL_NO_ERROR) + { + llwarns << "Could not allocate color buffer for render target." << llendl; + return false; + } + } stop_glerror(); - if (offset == 0) { - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); - } - else - { //don't filter data attachments - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - } - if (mUsage != LLTexUnit::TT_RECT_TEXTURE) - { - gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_MIRROR); - } - else - { - // ATI doesn't support mirrored repeat for rectangular textures. - gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + if (offset == 0) + { //use bilinear filtering on single texture render targets that aren't multisampled + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); + stop_glerror(); + } + else + { //don't filter data attachments + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + stop_glerror(); + } + + if (mUsage != LLTexUnit::TT_RECT_TEXTURE) + { + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_MIRROR); + stop_glerror(); + } + else + { + // ATI doesn't support mirrored repeat for rectangular textures. + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + stop_glerror(); + } } + if (mFBO) { - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO); - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT+offset, + stop_glerror(); + glBindFramebuffer(GL_FRAMEBUFFER, mFBO); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+offset, LLTexUnit::getInternalType(mUsage), tex, 0); stop_glerror(); check_framebuffer_status(); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); } mTex.push_back(tex); + if (gDebugGL) + { //bind and unbind to validate target + bindTarget(); + flush(); + } + + return true; } -void LLRenderTarget::allocateDepth() +bool LLRenderTarget::allocateDepth() { if (mStencil) { //use render buffers where stencil buffers are in play - glGenRenderbuffersEXT(1, (GLuint *) &mDepth); - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, mDepth); - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, mResX, mResY); - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); + glGenRenderbuffers(1, (GLuint *) &mDepth); + glBindRenderbuffer(GL_RENDERBUFFER, mDepth); + stop_glerror(); + clear_glerror(); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, mResX, mResY); + glBindRenderbuffer(GL_RENDERBUFFER, 0); } else { @@ -204,8 +235,18 @@ void LLRenderTarget::allocateDepth() gGL.getTexUnit(0)->bindManual(mUsage, mDepth); U32 internal_type = LLTexUnit::getInternalType(mUsage); gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - LLImageGL::setManualImage(internal_type, 0, GL_DEPTH_COMPONENT32_ARB, mResX, mResY, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); + stop_glerror(); + clear_glerror(); + LLImageGL::setManualImage(internal_type, 0, GL_DEPTH_COMPONENT32, mResX, mResY, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); } + + if (glGetError() != GL_NO_ERROR) + { + llwarns << "Unable to allocate depth buffer for render target." << llendl; + return false; + } + + return true; } void LLRenderTarget::shareDepthBuffer(LLRenderTarget& target) @@ -228,25 +269,28 @@ void LLRenderTarget::shareDepthBuffer(LLRenderTarget& target) if (mDepth) { stop_glerror(); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, target.mFBO); + glBindFramebuffer(GL_FRAMEBUFFER, target.mFBO); stop_glerror(); if (mStencil) { - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mDepth); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mDepth); stop_glerror(); - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mDepth); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mDepth); stop_glerror(); target.mStencil = true; } else { - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, LLTexUnit::getInternalType(mUsage), mDepth, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, LLTexUnit::getInternalType(mUsage), mDepth, 0); stop_glerror(); } - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - target.mUseDepth = TRUE; + check_framebuffer_status(); + + glBindFramebuffer(GL_FRAMEBUFFER, 0); + + target.mUseDepth = true; } } @@ -256,7 +300,7 @@ void LLRenderTarget::release() { if (mStencil) { - glDeleteRenderbuffersEXT(1, (GLuint*) &mDepth); + glDeleteRenderbuffers(1, (GLuint*) &mDepth); stop_glerror(); } else @@ -268,23 +312,23 @@ void LLRenderTarget::release() } else if (mUseDepth && mFBO) { //detach shared depth buffer - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO); + glBindFramebuffer(GL_FRAMEBUFFER, mFBO); if (mStencil) { //attached as a renderbuffer - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0); - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0); mStencil = false; } else { //attached as a texture - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, LLTexUnit::getInternalType(mUsage), 0, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, LLTexUnit::getInternalType(mUsage), 0, 0); } mUseDepth = false; } if (mFBO) { - glDeleteFramebuffersEXT(1, (GLuint *) &mFBO); + glDeleteFramebuffers(1, (GLuint *) &mFBO); mFBO = 0; } @@ -294,6 +338,8 @@ void LLRenderTarget::release() mTex.clear(); } + mResX = mResY = 0; + mSampleBuffer = NULL; sBoundTarget = NULL; } @@ -310,14 +356,14 @@ void LLRenderTarget::bindTarget() } else { - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO); + glBindFramebuffer(GL_FRAMEBUFFER, mFBO); stop_glerror(); if (gGLManager.mHasDrawBuffers) { //setup multiple render targets - GLenum drawbuffers[] = {GL_COLOR_ATTACHMENT0_EXT, - GL_COLOR_ATTACHMENT1_EXT, - GL_COLOR_ATTACHMENT2_EXT, - GL_COLOR_ATTACHMENT3_EXT}; + GLenum drawbuffers[] = {GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1, + GL_COLOR_ATTACHMENT2, + GL_COLOR_ATTACHMENT3}; glDrawBuffersARB(mTex.size(), drawbuffers); } @@ -342,7 +388,7 @@ void LLRenderTarget::unbindTarget() { if (gGLManager.mHasFramebufferObject) { - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); } sBoundTarget = NULL; } @@ -404,7 +450,7 @@ void LLRenderTarget::flush(bool fetch_depth) } gGL.getTexUnit(0)->bind(this); - glCopyTexImage2D(LLTexUnit::getInternalType(mUsage), 0, GL_DEPTH24_STENCIL8_EXT, 0, 0, mResX, mResY, 0); + glCopyTexImage2D(LLTexUnit::getInternalType(mUsage), 0, GL_DEPTH24_STENCIL8, 0, 0, mResX, mResY, 0); } gGL.getTexUnit(0)->disable(); @@ -412,56 +458,55 @@ void LLRenderTarget::flush(bool fetch_depth) else { stop_glerror(); - - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - + glBindFramebuffer(GL_FRAMEBUFFER, 0); stop_glerror(); if (mSampleBuffer) { - LLGLEnable multisample(GL_MULTISAMPLE_ARB); + LLGLEnable multisample(GL_MULTISAMPLE); stop_glerror(); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO); + glBindFramebuffer(GL_FRAMEBUFFER, mFBO); stop_glerror(); check_framebuffer_status(); - glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, mSampleBuffer->mFBO); + glBindFramebuffer(GL_READ_FRAMEBUFFER, mSampleBuffer->mFBO); check_framebuffer_status(); stop_glerror(); if(gGLManager.mIsATI) { - glBlitFramebufferEXT(0, 0, mResX, mResY, 0, 0, mResX, mResY, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); - glBlitFramebufferEXT(0, 0, mResX, mResY, 0, 0, mResX, mResY, GL_STENCIL_BUFFER_BIT, GL_NEAREST); + glBlitFramebuffer(0, 0, mResX, mResY, 0, 0, mResX, mResY, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); + glBlitFramebuffer(0, 0, mResX, mResY, 0, 0, mResX, mResY, GL_STENCIL_BUFFER_BIT, GL_NEAREST); } else - glBlitFramebufferEXT(0, 0, mResX, mResY, 0, 0, mResX, mResY, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); + { + glBlitFramebuffer(0, 0, mResX, mResY, 0, 0, mResX, mResY, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); + } stop_glerror(); if (mTex.size() > 1) { for (U32 i = 1; i < mTex.size(); ++i) { - glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, LLTexUnit::getInternalType(mUsage), mTex[i], 0); stop_glerror(); - glFramebufferRenderbufferEXT(GL_READ_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, mSampleBuffer->mTex[i]); + glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, mSampleBuffer->mTex[i]); stop_glerror(); - glBlitFramebufferEXT(0, 0, mResX, mResY, 0, 0, mResX, mResY, GL_COLOR_BUFFER_BIT, GL_NEAREST); + glBlitFramebuffer(0, 0, mResX, mResY, 0, 0, mResX, mResY, GL_COLOR_BUFFER_BIT, GL_NEAREST); stop_glerror(); } for (U32 i = 0; i < mTex.size(); ++i) { - glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT+i, + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+i, LLTexUnit::getInternalType(mUsage), mTex[i], 0); stop_glerror(); - glFramebufferRenderbufferEXT(GL_READ_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT+i, GL_RENDERBUFFER_EXT, mSampleBuffer->mTex[i]); + glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+i, GL_RENDERBUFFER, mSampleBuffer->mTex[i]); stop_glerror(); } } + glBindFramebuffer(GL_FRAMEBUFFER, 0); } - - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); } } @@ -488,31 +533,36 @@ void LLRenderTarget::copyContents(LLRenderTarget& source, S32 srcX0, S32 srcY0, { stop_glerror(); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, source.mFBO); + glBindFramebuffer(GL_FRAMEBUFFER, source.mFBO); + check_framebuffer_status(); gGL.getTexUnit(0)->bind(this, true); stop_glerror(); glCopyTexSubImage2D(LLTexUnit::getInternalType(mUsage), 0, srcX0, srcY0, dstX0, dstY0, dstX1, dstY1); stop_glerror(); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); stop_glerror(); } else { - glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, source.mFBO); + glBindFramebuffer(GL_READ_FRAMEBUFFER, source.mFBO); stop_glerror(); - glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, mFBO); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mFBO); stop_glerror(); check_framebuffer_status(); stop_glerror(); if(gGLManager.mIsATI && mask & GL_STENCIL_BUFFER_BIT) { mask &= ~GL_STENCIL_BUFFER_BIT; - glBlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, GL_STENCIL_BUFFER_BIT, filter); + glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, GL_STENCIL_BUFFER_BIT, filter); } if(mask) - glBlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); + glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); stop_glerror(); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + stop_glerror(); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + stop_glerror(); + glBindFramebuffer(GL_FRAMEBUFFER, 0); stop_glerror(); } } @@ -531,21 +581,21 @@ void LLRenderTarget::copyContentsToFramebuffer(LLRenderTarget& source, S32 srcX0 LLGLDepthTest depth(write_depth, write_depth); - glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, source.mSampleBuffer ? source.mSampleBuffer->mFBO : source.mFBO); + glBindFramebuffer(GL_READ_FRAMEBUFFER, source.mSampleBuffer ? source.mSampleBuffer->mFBO : source.mFBO); stop_glerror(); - glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); stop_glerror(); check_framebuffer_status(); stop_glerror(); if(gGLManager.mIsATI && mask & GL_STENCIL_BUFFER_BIT) { mask &= ~GL_STENCIL_BUFFER_BIT; - glBlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, GL_STENCIL_BUFFER_BIT, filter); + glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, GL_STENCIL_BUFFER_BIT, filter); } if(mask) - glBlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); + glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); stop_glerror(); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); stop_glerror(); } } @@ -580,19 +630,19 @@ void LLMultisampleBuffer::release() { if (mFBO) { - glDeleteFramebuffersEXT(1, (GLuint *) &mFBO); + glDeleteFramebuffers(1, (GLuint *) &mFBO); mFBO = 0; } if (mTex.size() > 0) { - glDeleteRenderbuffersEXT(mTex.size(), (GLuint *) &mTex[0]); + glDeleteRenderbuffers(mTex.size(), (GLuint *) &mTex[0]); mTex.clear(); } if (mDepth) { - glDeleteRenderbuffersEXT(1, (GLuint *) &mDepth); + glDeleteRenderbuffers(1, (GLuint *) &mDepth); mDepth = 0; } } @@ -609,13 +659,13 @@ void LLMultisampleBuffer::bindTarget(LLRenderTarget* ref) ref = this; } - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO); + glBindFramebuffer(GL_FRAMEBUFFER, mFBO); if (gGLManager.mHasDrawBuffers) { //setup multiple render targets - GLenum drawbuffers[] = {GL_COLOR_ATTACHMENT0_EXT, - GL_COLOR_ATTACHMENT1_EXT, - GL_COLOR_ATTACHMENT2_EXT, - GL_COLOR_ATTACHMENT3_EXT}; + GLenum drawbuffers[] = {GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1, + GL_COLOR_ATTACHMENT2, + GL_COLOR_ATTACHMENT3}; glDrawBuffersARB(ref->mTex.size(), drawbuffers); } @@ -626,14 +676,16 @@ void LLMultisampleBuffer::bindTarget(LLRenderTarget* ref) sBoundTarget = this; } -void LLMultisampleBuffer::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo ) +bool LLMultisampleBuffer::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo ) { - allocate(resx,resy,color_fmt,depth,stencil,usage,use_fbo,2); + return allocate(resx,resy,color_fmt,depth,stencil,usage,use_fbo,2); } -void LLMultisampleBuffer::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo, U32 samples ) +bool LLMultisampleBuffer::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo, U32 samples ) { + release(); stop_glerror(); + mResX = resx; mResY = resy; @@ -641,18 +693,18 @@ void LLMultisampleBuffer::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth mUseDepth = depth; mStencil = stencil; - release(); - if (!gGLManager.mHasFramebufferMultisample) { llerrs << "Attempting to allocate unsupported render target type!" << llendl; + return false; } - mSamples = samples; + mSamples = gGLManager.getNumFBOFSAASamples(samples); if (mSamples <= 1) { llerrs << "Cannot create a multisample buffer with less than 2 samples." << llendl; + return false; } stop_glerror(); @@ -663,36 +715,37 @@ void LLMultisampleBuffer::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth if (depth) { stop_glerror(); - allocateDepth(); + if(!allocateDepth()) + return false; stop_glerror(); } - - glGenFramebuffersEXT(1, (GLuint *) &mFBO); - - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO); - + glGenFramebuffers(1, (GLuint *) &mFBO); + glBindFramebuffer(GL_FRAMEBUFFER, mFBO); + stop_glerror(); + clear_glerror(); if (mDepth) { - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mDepth); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mDepth); if (mStencil) { - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mDepth); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mDepth); } + check_framebuffer_status(); } stop_glerror(); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); stop_glerror(); } - addColorAttachment(color_fmt); + return addColorAttachment(color_fmt); } -void LLMultisampleBuffer::addColorAttachment(U32 color_fmt) +bool LLMultisampleBuffer::addColorAttachment(U32 color_fmt) { if (color_fmt == 0) { - return; + return true; } U32 offset = mTex.size(); @@ -703,44 +756,47 @@ void LLMultisampleBuffer::addColorAttachment(U32 color_fmt) } U32 tex; - glGenRenderbuffersEXT(1, &tex); - - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, tex); - glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, mSamples, color_fmt, mResX, mResY); + glGenRenderbuffers(1, &tex); + glBindRenderbuffer(GL_RENDERBUFFER, tex); stop_glerror(); - + clear_glerror(); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, mSamples, color_fmt, mResX, mResY); + if (glGetError() != GL_NO_ERROR) + { + llwarns << "Unable to allocate color buffer for multisample render target." << llendl; + return false; + } if (mFBO) { - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO); - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT+offset, GL_RENDERBUFFER_EXT, tex); - stop_glerror(); - GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); - switch (status) - { - case GL_FRAMEBUFFER_COMPLETE_EXT: - break; - default: - llerrs << "WTF? " << std::hex << status << llendl; - break; - } - - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glBindFramebuffer(GL_FRAMEBUFFER, mFBO); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+offset, GL_RENDERBUFFER, tex); + check_framebuffer_status(); + glBindFramebuffer(GL_FRAMEBUFFER, 0); } mTex.push_back(tex); + return true; } -void LLMultisampleBuffer::allocateDepth() +bool LLMultisampleBuffer::allocateDepth() { - glGenRenderbuffersEXT(1, (GLuint* ) &mDepth); - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, mDepth); + glGenRenderbuffers(1, (GLuint* ) &mDepth); + glBindRenderbuffer(GL_RENDERBUFFER, mDepth); + stop_glerror(); + clear_glerror(); if (mStencil) { - glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, mSamples, GL_DEPTH24_STENCIL8_EXT, mResX, mResY); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, mSamples, GL_DEPTH24_STENCIL8, mResX, mResY); } else { - glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, mSamples, GL_DEPTH_COMPONENT16_ARB, mResX, mResY); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, mSamples, GL_DEPTH_COMPONENT16_ARB, mResX, mResY); } + if (glGetError() != GL_NO_ERROR) + { + llwarns << "Unable to allocate depth buffer for multisample render target." << llendl; + return false; + } + return true; } diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h index fe5cf9072..685da79a6 100644 --- a/indra/llrender/llrendertarget.h +++ b/indra/llrender/llrendertarget.h @@ -77,17 +77,17 @@ public: //allocate resources for rendering //must be called before use //multiple calls will release previously allocated resources - void allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage = LLTexUnit::TT_TEXTURE, bool use_fbo = FALSE); + bool allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage = LLTexUnit::TT_TEXTURE, bool use_fbo = FALSE); //provide this render target with a multisample resource. void setSampleBuffer(LLMultisampleBuffer* buffer); //add color buffer attachment //limit of 4 color attachments per render target - virtual void addColorAttachment(U32 color_fmt); + virtual bool addColorAttachment(U32 color_fmt); //allocate a depth texture - virtual void allocateDepth(); + virtual bool allocateDepth(); //share depth buffer with provided render target virtual void shareDepthBuffer(LLRenderTarget& target); @@ -174,10 +174,10 @@ public: virtual void bindTarget(); void bindTarget(LLRenderTarget* ref); - virtual void allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo); - void allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo, U32 samples); - virtual void addColorAttachment(U32 color_fmt); - virtual void allocateDepth(); + virtual bool allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo); + bool allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo, U32 samples); + virtual bool addColorAttachment(U32 color_fmt); + virtual bool allocateDepth(); }; #endif //!LL_MESA_HEADLESS diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 255643dc8..dc81d8e85 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -217,17 +217,79 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->hasWaterFog) { - if (!shader->attachObject("lighting/lightWaterF.glsl")) + if (features->disableTextureIndex) { - return FALSE; + if (features->hasAlphaMask) + { + if (!shader->attachObject("lighting/lightWaterAlphaMaskNonIndexedF.glsl")) + { + return FALSE; + } + } + else + { + if (!shader->attachObject("lighting/lightWaterNonIndexedF.glsl")) + { + return FALSE; + } + } + } + else + { + if (features->hasAlphaMask) + { + if (!shader->attachObject("lighting/lightWaterAlphaMaskF.glsl")) + { + return FALSE; + } + } + else + { + if (!shader->attachObject("lighting/lightWaterF.glsl")) + { + return FALSE; + } + } + shader->mFeatures.mIndexedTextureChannels = gGLManager.mNumTextureImageUnits-1; } } else { - if (!shader->attachObject("lighting/lightF.glsl")) + if (features->disableTextureIndex) { - return FALSE; + if (features->hasAlphaMask) + { + if (!shader->attachObject("lighting/lightAlphaMaskNonIndexedF.glsl")) + { + return FALSE; + } + } + else + { + if (!shader->attachObject("lighting/lightNonIndexedF.glsl")) + { + return FALSE; + } + } + } + else + { + if (features->hasAlphaMask) + { + if (!shader->attachObject("lighting/lightAlphaMaskF.glsl")) + { + return FALSE; + } + } + else + { + if (!shader->attachObject("lighting/lightF.glsl")) + { + return FALSE; + } + } + shader->mFeatures.mIndexedTextureChannels = gGLManager.mNumTextureImageUnits-1; } } } @@ -238,32 +300,111 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->isShiny && features->hasWaterFog) { - if (!shader->attachObject("lighting/lightFullbrightShinyWaterF.glsl")) + if (features->disableTextureIndex) { - return FALSE; + if (!shader->attachObject("lighting/lightFullbrightShinyWaterNonIndexedF.glsl")) + { + return FALSE; + } + } + else + { + if (!shader->attachObject("lighting/lightFullbrightShinyWaterF.glsl")) + { + return FALSE; + } + shader->mFeatures.mIndexedTextureChannels = gGLManager.mNumTextureImageUnits-1; } } else if (features->hasWaterFog) { - if (!shader->attachObject("lighting/lightFullbrightWaterF.glsl")) + if (features->disableTextureIndex) { - return FALSE; + if (features->hasAlphaMask) + { + if (!shader->attachObject("lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl")) + { + return FALSE; + } + } + else if (!shader->attachObject("lighting/lightFullbrightWaterNonIndexedF.glsl")) + { + return FALSE; + } + } + else + { + if (features->hasAlphaMask) + { + if (!shader->attachObject("lighting/lightFullbrightWaterAlphaMaskF.glsl")) + { + return FALSE; + } + } + else if (!shader->attachObject("lighting/lightFullbrightWaterF.glsl")) + { + return FALSE; + } + shader->mFeatures.mIndexedTextureChannels = gGLManager.mNumTextureImageUnits-1; } } else if (features->isShiny) { - if (!shader->attachObject("lighting/lightFullbrightShinyF.glsl")) + if (features->disableTextureIndex) { - return FALSE; + if (!shader->attachObject("lighting/lightFullbrightShinyNonIndexedF.glsl")) + { + return FALSE; + } + } + else + { + if (!shader->attachObject("lighting/lightFullbrightShinyF.glsl")) + { + return FALSE; + } + shader->mFeatures.mIndexedTextureChannels = gGLManager.mNumTextureImageUnits-1; } } else { - if (!shader->attachObject("lighting/lightFullbrightF.glsl")) + if (features->disableTextureIndex) { - return FALSE; + + if (features->hasAlphaMask) + { + if (!shader->attachObject("lighting/lightFullbrightNonIndexedAlphaMaskF.glsl")) + { + return FALSE; + } + } + else + { + if (!shader->attachObject("lighting/lightFullbrightNonIndexedF.glsl")) + { + return FALSE; + } + } + } + else + { + if (features->hasAlphaMask) + { + if (!shader->attachObject("lighting/lightFullbrightAlphaMaskF.glsl")) + { + return FALSE; + } + } + else + { + if (!shader->attachObject("lighting/lightFullbrightF.glsl")) + { + return FALSE; + } + } + shader->mFeatures.mIndexedTextureChannels = gGLManager.mNumTextureImageUnits-1; } } } @@ -274,17 +415,39 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->hasWaterFog) { - if (!shader->attachObject("lighting/lightShinyWaterF.glsl")) + if (features->disableTextureIndex) { - return FALSE; + if (!shader->attachObject("lighting/lightShinyWaterNonIndexedF.glsl")) + { + return FALSE; + } + } + else + { + if (!shader->attachObject("lighting/lightShinyWaterF.glsl")) + { + return FALSE; + } + shader->mFeatures.mIndexedTextureChannels = gGLManager.mNumTextureImageUnits-1; } } else { - if (!shader->attachObject("lighting/lightShinyF.glsl")) + if (features->disableTextureIndex) { - return FALSE; + if (!shader->attachObject("lighting/lightShinyNonIndexedF.glsl")) + { + return FALSE; + } + } + else + { + if (!shader->attachObject("lighting/lightShinyF.glsl")) + { + return FALSE; + } + shader->mFeatures.mIndexedTextureChannels = gGLManager.mNumTextureImageUnits-1; } } } @@ -328,13 +491,16 @@ void LLShaderMgr::dumpObjectLog(GLhandleARB ret, BOOL warns) } } -GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type) +GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, S32 texture_index_channels) { - GLenum error; - error = glGetError(); - if (error != GL_NO_ERROR) + GLenum error = GL_NO_ERROR; + if (gDebugGL) { - LL_WARNS("ShaderLoading") << "GL ERROR entering loadShaderFile(): " << error << LL_ENDL; + error = glGetError(); + if (error != GL_NO_ERROR) + { + LL_WARNS("ShaderLoading") << "GL ERROR entering loadShaderFile(): " << error << LL_ENDL; + } } LL_DEBUGS("ShaderLoading") << "Loading shader file: " << filename << " class " << shader_level << LL_ENDL; @@ -375,11 +541,121 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade //we can't have any lines longer than 1024 characters //or any shaders longer than 1024 lines... deal - DaveP - GLcharARB buff[1024]; - GLcharARB* text[1024]; + GLcharARB buff[1024] = {0}; + GLcharARB* text[1024] = {0}; GLuint count = 0; + if (gGLManager.mGLVersion < 2.1f) + { + text[count++] = strdup("#version 110\n"); + } + else if (gGLManager.mGLVersion < 3.f) + { + //set version to 1.20 + text[count++] = strdup("#version 120\n"); + } + else + { //set version to 1.30 + text[count++] = strdup("#version 130\n"); + } + //copy preprocessor definitions into buffer + for (std::map::iterator iter = mDefinitions.begin(); iter != mDefinitions.end(); ++iter) + { + std::string define = "#define " + iter->first + " " + iter->second + "\n"; + text[count++] = (GLcharARB *) strdup(define.c_str()); + } + + if (texture_index_channels > 0 && type == GL_FRAGMENT_SHADER_ARB) + { + //use specified number of texture channels for indexed texture rendering + + /* prepend shader code that looks like this: + + uniform sampler2D tex0; + uniform sampler2D tex1; + uniform sampler2D tex2; + . + . + . + uniform sampler2D texN; + + varying float vary_texture_index; + + vec4 diffuseLookup(vec2 texcoord) + { + switch (int(vary_texture_index+0.25)) + { + case 0: return texture2D(tex0, texcoord); + case 1: return texture2D(tex1, texcoord); + case 2: return texture2D(tex2, texcoord); + . + . + . + case N: return texture2D(texN, texcoord); + } + + return vec4(0,0,0,0); + } + */ + + //uniform declartion + for (S32 i = 0; i < texture_index_channels; ++i) + { + std::string decl = llformat("uniform sampler2D tex%d;\n", i); + text[count++] = strdup(decl.c_str()); + } + + text[count++] = strdup("varying float vary_texture_index;\n"); + text[count++] = strdup("vec4 diffuseLookup(vec2 texcoord)\n"); + text[count++] = strdup("{\n"); + + + if (texture_index_channels == 1) + { //don't use flow control, that's silly + text[count++] = strdup("return texture2D(tex0, texcoord);\n"); + text[count++] = strdup("}\n"); + } + else if (gGLManager.mGLVersion >= 3.f) + { + text[count++] = strdup("\tswitch (int(vary_texture_index+0.25))\n"); + text[count++] = strdup("\t{\n"); + + //switch body + for (S32 i = 0; i < texture_index_channels; ++i) + { + std::string case_str = llformat("\t\tcase %d: return texture2D(tex%d, texcoord);\n", i, i); + text[count++] = strdup(case_str.c_str()); + } + + text[count++] = strdup("\t}\n"); + text[count++] = strdup("\treturn vec4(0,0,0,0);\n"); + text[count++] = strdup("}\n"); + } + else + { + //switches aren't supported, make block that looks like: + /* + int ti = int(vary_texture_index+0.25); + if (ti == 0) return texture2D(tex0, texcoord); + if (ti == 1) return texture2D(tex1, texcoord); + . + . + . + if (ti == N) return texture2D(texN, texcoord); + */ + + text[count++] = strdup("int ti = int(vary_texture_index+0.25);\n"); + for (S32 i = 0; i < texture_index_channels; ++i) + { + std::string if_str = llformat("if (ti == %d) return texture2D(tex%d, texcoord);\n", i, i); + text[count++] = strdup(if_str.c_str()); + } + + text[count++] = strdup("\treturn vec4(0,0,0,0);\n"); + text[count++] = strdup("}\n"); + } + } //copy file into memory while( fgets((char *)buff, 1024, file) != NULL && count < LL_ARRAY_SIZE(buff) ) { @@ -389,51 +665,67 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade //create shader object GLhandleARB ret = glCreateShaderObjectARB(type); - error = glGetError(); - if (error != GL_NO_ERROR) + if (gDebugGL) { - LL_WARNS("ShaderLoading") << "GL ERROR in glCreateShaderObjectARB: " << error << LL_ENDL; + error = glGetError(); + if (error != GL_NO_ERROR) + { + LL_WARNS("ShaderLoading") << "GL ERROR in glCreateShaderObjectARB: " << error << LL_ENDL; + glDeleteObjectARB(ret); //no longer need handle + } } - else + + //load source + glShaderSourceARB(ret, count, (const GLcharARB**) text, NULL); + + if (gDebugGL) { - //load source - glShaderSourceARB(ret, count, (const GLcharARB**) text, NULL); error = glGetError(); if (error != GL_NO_ERROR) { LL_WARNS("ShaderLoading") << "GL ERROR in glShaderSourceARB: " << error << LL_ENDL; glDeleteObjectARB(ret); //no longer need handle } - else + } + + //compile source + glCompileShaderARB(ret); + + if (gDebugGL) + { + error = glGetError(); + if (error != GL_NO_ERROR) { - //compile source - glCompileShaderARB(ret); - error = glGetError(); - if (error != GL_NO_ERROR) - { - LL_WARNS("ShaderLoading") << "GL ERROR in glCompileShaderARB: " << error << LL_ENDL; - glDeleteObjectARB(ret); //no longer need handle - } + LL_WARNS("ShaderLoading") << "GL ERROR in glCompileShaderARB: " << error << LL_ENDL; + glDeleteObjectARB(ret); //no longer need handle } } - //free memory - for (GLuint i = 0; i < count; i++) - { - free(text[i]); - } + if (error == GL_NO_ERROR) { //check for errors GLint success = GL_TRUE; glGetObjectParameterivARB(ret, GL_OBJECT_COMPILE_STATUS_ARB, &success); - error = glGetError(); - if (error != GL_NO_ERROR || success == GL_FALSE) + if (gDebugGL || success == GL_FALSE) { - //an error occured, print log - LL_WARNS("ShaderLoading") << "GLSL Compilation Error: (" << error << ") in " << filename << LL_ENDL; - dumpObjectLog(ret); - glDeleteObjectARB(ret); //no longer need handle - ret = 0; + error = glGetError(); + if (error != GL_NO_ERROR || success == GL_FALSE) + { + //an error occured, print log + LL_WARNS("ShaderLoading") << "GLSL Compilation Error: (" << error << ") in " << filename << LL_ENDL; + dumpObjectLog(ret); + + std::stringstream ostr; + //dump shader source for debugging + for (GLuint i = 0; i < count; i++) + { + ostr << i << ": " << text[i]; + } + + LL_WARNS("ShaderLoading") << "\n" << ostr.str() << llendl; + glDeleteObjectARB(ret); //no longer need handle + ret = 0; + } } } else @@ -442,6 +734,12 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade } stop_glerror(); + //free memory + for (GLuint i = 0; i < count; i++) + { + free(text[i]); + } + //successfully loaded, save results if (ret) { @@ -454,7 +752,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade if (shader_level > 1) { shader_level--; - return loadShaderFile(filename,shader_level,type); + return loadShaderFile(filename,shader_level,type,texture_index_channels); } LL_WARNS("ShaderLoading") << "Failed to load " << filename << LL_ENDL; } diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 02f5842a1..fdc13043f 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -49,7 +49,7 @@ public: void dumpObjectLog(GLhandleARB ret, BOOL warns = TRUE); BOOL linkProgramObject(GLhandleARB obj, BOOL suppress_errors = FALSE); BOOL validateProgramObject(GLhandleARB obj); - GLhandleARB loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type); + GLhandleARB loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, S32 texture_index_channels = -1); // Implemented in the application to actually point to the shader directory. virtual std::string getShaderDirPrefix(void) = 0; // Pure Virtual @@ -66,6 +66,9 @@ public: std::vector mReservedUniforms; + //preprocessor definitions (name/value) + std::map mDefinitions; + protected: // our parameter manager singleton instance diff --git a/indra/llrender/lltexture.h b/indra/llrender/lltexture.h index 8745b5059..6a08c5b2a 100644 --- a/indra/llrender/lltexture.h +++ b/indra/llrender/lltexture.h @@ -39,7 +39,7 @@ #ifndef LL_TEXTURE_H #define LL_TEXTURE_H -#include "llmemory.h" +#include "llrefcount.h" class LLImageGL ; class LLTexUnit ; class LLFontGL ; diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 2837cd6af..aa632b094 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -42,6 +42,7 @@ #include "llrender.h" #include "llvector4a.h" #include "llcontrol.h" +#include "llglslshader.h" //============================================================================ @@ -88,6 +89,59 @@ void LLVBOPool::releaseName(GLuint name) LLVertexBuffer::sGLCount--; } +const U32 FENCE_WAIT_TIME_NANOSECONDS = 10000; //1 ms + +class LLGLSyncFence : public LLGLFence +{ +public: +#ifdef GL_ARB_sync + GLsync mSync; +#endif + + LLGLSyncFence() + { +#ifdef GL_ARB_sync + mSync = 0; +#endif + } + + virtual ~LLGLSyncFence() + { +#ifdef GL_ARB_sync + if (mSync) + { + glDeleteSync(mSync); + } +#endif + } + + void placeFence() + { +#ifdef GL_ARB_sync + if (mSync) + { + glDeleteSync(mSync); + } + mSync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); +#endif + } + + void wait() + { +#ifdef GL_ARB_sync + if (mSync) + { + while (glClientWaitSync(mSync, 0, FENCE_WAIT_TIME_NANOSECONDS) == GL_TIMEOUT_EXPIRED) + { //track the number of times we've waited here + static S32 waits = 0; + waits++; + } + } +#endif + } + + +}; S32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] = { @@ -334,6 +388,7 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, idx); stop_glerror(); + placeFence(); } void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const @@ -365,6 +420,7 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const glDrawElements(sGLMode[mode], count, GL_UNSIGNED_SHORT, ((U16*) getIndicesPointer()) + indices_offset); stop_glerror(); + placeFence(); } void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const @@ -390,6 +446,7 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const stop_glerror(); glDrawArrays(sGLMode[mode], first, count); stop_glerror(); + placeFence(); } //static @@ -470,7 +527,8 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage, bool strided) : mResized(FALSE), mDynamicSize(FALSE), mIsStrided(strided), - mStride(0) + mStride(0), + mFence(NULL) { LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); if (!sEnableVBOs) @@ -570,9 +628,40 @@ LLVertexBuffer::~LLVertexBuffer() destroyGLIndices(); sCount--; + if (mFence) + { + delete mFence; + } + + mFence = NULL; + llassert_always(!mMappedData && !mMappedIndexData) ; }; +void LLVertexBuffer::placeFence() const +{ + /*if (!mFence && useVBOs()) + { + if (gGLManager.mHasSync) + { + mFence = new LLGLSyncFence(); + } + } + + if (mFence) + { + mFence->placeFence(); + }*/ +} + +void LLVertexBuffer::waitFence() const +{ + /*if (mFence) + { + mFence->wait(); + }*/ +} + //---------------------------------------------------------------------------- void LLVertexBuffer::genBuffer() @@ -1152,7 +1241,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index) void LLVertexBuffer::unmapBuffer(S32 type) { LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); - if (!useVBOs()) + if (!useVBOs() || type == -2) { return ; //nothing to unmap } @@ -1605,7 +1694,14 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const } if (data_mask & MAP_VERTEX) { - glVertexPointer(3,GL_FLOAT, getStride(TYPE_VERTEX), (void*)(base + 0)); + if (data_mask & MAP_TEXTURE_INDEX) + { + glVertexPointer(4,GL_FLOAT, getStride(TYPE_VERTEX), (void*)(base + 0)); + } + else + { + glVertexPointer(3,GL_FLOAT, getStride(TYPE_VERTEX), (void*)(base + 0)); + } } llglassertok(); diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 8d098a1f1..2aa8f5313 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -64,6 +64,12 @@ protected: virtual void releaseName(GLuint name); }; +class LLGLFence +{ +public: + virtual void placeFence() = 0; + virtual void wait() = 0; +}; //============================================================================ // base class @@ -127,6 +133,9 @@ public: TYPE_CLOTHWEIGHT, TYPE_MAX, TYPE_INDEX, + + //no actual additional data, but indicates position.w is texture index + TYPE_TEXTURE_INDEX, }; enum { MAP_VERTEX = (1< #include "llsd.h" -#include "llmemory.h" +#include "llsingleton.h" /** * @class LLFunctorRegistry diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 21c216c8c..cf9af9b32 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -77,11 +77,6 @@ S32 MENU_BAR_WIDTH = 0; /// Local function declarations, constants, enums, and typedefs ///============================================================================ -const std::string SEPARATOR_NAME("separator"); -const std::string TEAROFF_SEPARATOR_LABEL( "~~~~~~~~~~~" ); -const std::string SEPARATOR_LABEL( "-----------" ); -const std::string VERTICAL_SEPARATOR_LABEL( "|" ); - const S32 LABEL_BOTTOM_PAD_PIXELS = 2; const U32 LEFT_PAD_PIXELS = 3; @@ -101,7 +96,12 @@ const U32 SEPARATOR_HEIGHT_PIXELS = 8; const S32 TEAROFF_SEPARATOR_HEIGHT_PIXELS = 10; const S32 MENU_ITEM_PADDING = 4; -const std::string BOOLEAN_TRUE_PREFIX( "\xe2\x9c\x93" ); // U+2714 -- MC +const std::string SEPARATOR_NAME("separator"); +const std::string SEPARATOR_LABEL( "-----------" ); +const std::string VERTICAL_SEPARATOR_LABEL( "|" ); +const std::string TEAROFF_SEPARATOR_LABEL( "~~~~~~~~~~~" ); + +const std::string BOOLEAN_TRUE_PREFIX( "\xE2\x9C\x94" ); // U+2714 HEAVY CHECK MARK const std::string BRANCH_SUFFIX( "\xE2\x96\xB6" ); // U+25B6 BLACK RIGHT-POINTING TRIANGLE const std::string ARROW_UP ("^^^^^^^"); const std::string ARROW_DOWN("vvvvvvv"); diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index 06903d742..810cb0a25 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -88,8 +88,9 @@ LLMultiSlider::LLMultiSlider( mThumbCenterSelectedColor( LLUI::sColorsGroup->getColor( "MultiSliderThumbCenterSelectedColor" ) ), mDisabledThumbColor(LLUI::sColorsGroup->getColor( "MultiSliderDisabledThumbColor" ) ), mTriangleColor(LLUI::sColorsGroup->getColor( "MultiSliderTriangleColor" ) ), - mMouseDownCallback( NULL ), - mMouseUpCallback( NULL ) + mMouseDownSignal( NULL ), + mMouseUpSignal( NULL ), + mThumbWidth(MULTI_THUMB_WIDTH) { mValue.emptyMap(); mCurSlider = LLStringUtil::null; @@ -101,6 +102,13 @@ LLMultiSlider::LLMultiSlider( setValue(getValue()); } +LLMultiSlider::~LLMultiSlider() +{ + delete mMouseDownSignal; + delete mMouseUpSignal; +} + + void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from_event) { // exit if not there @@ -152,12 +160,12 @@ void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from F32 t = (newValue - mMinValue) / (mMaxValue - mMinValue); - S32 left_edge = MULTI_THUMB_WIDTH/2; - S32 right_edge = getRect().getWidth() - (MULTI_THUMB_WIDTH/2); + S32 left_edge = mThumbWidth/2; + S32 right_edge = getRect().getWidth() - (mThumbWidth/2); S32 x = left_edge + S32( t * (right_edge - left_edge) ); - mThumbRects[name].mLeft = x - (MULTI_THUMB_WIDTH/2); - mThumbRects[name].mRight = x + (MULTI_THUMB_WIDTH/2); + mThumbRects[name].mLeft = x - (mThumbWidth/2); + mThumbRects[name].mRight = x + (mThumbWidth/2); } void LLMultiSlider::setValue(const LLSD& value) @@ -211,7 +219,7 @@ const std::string& LLMultiSlider::addSlider(F32 val) } // add a new thumb rect - mThumbRects[newName.str()] = LLRect( 0, getRect().getHeight(), MULTI_THUMB_WIDTH, 0 ); + mThumbRects[newName.str()] = LLRect( 0, getRect().getHeight(), mThumbWidth, 0 ); // add the value and set the current slider to this one mValue.insert(newName.str(), initVal); @@ -223,6 +231,30 @@ const std::string& LLMultiSlider::addSlider(F32 val) return mCurSlider; } +void LLMultiSlider::addSlider(F32 val, const std::string& name) +{ + F32 initVal = val; + + if(mValue.size() >= mMaxNumSliders) { + return; + } + + bool foundOne = findUnusedValue(initVal); + if(!foundOne) { + return; + } + + // add a new thumb rect + mThumbRects[name] = LLRect( 0, getRect().getHeight(), mThumbWidth, 0 ); + + // add the value and set the current slider to this one + mValue.insert(name, initVal); + mCurSlider = name; + + // move the slider + setSliderValue(mCurSlider, initVal, TRUE); +} + bool LLMultiSlider::findUnusedValue(F32& initVal) { bool firstTry = true; @@ -302,8 +334,8 @@ BOOL LLMultiSlider::handleHover(S32 x, S32 y, MASK mask) { if( gFocusMgr.getMouseCapture() == this ) { - S32 left_edge = MULTI_THUMB_WIDTH/2; - S32 right_edge = getRect().getWidth() - (MULTI_THUMB_WIDTH/2); + S32 left_edge = mThumbWidth/2; + S32 right_edge = getRect().getWidth() - (mThumbWidth/2); x += mMouseOffset; x = llclamp( x, left_edge, right_edge ); @@ -331,10 +363,9 @@ BOOL LLMultiSlider::handleMouseUp(S32 x, S32 y, MASK mask) { gFocusMgr.setMouseCapture( NULL ); - if( mMouseUpCallback ) - { - mMouseUpCallback( this, mCallbackUserData ); - } + if (mMouseUpSignal) + (*mMouseUpSignal)( this, LLSD() ); + handled = TRUE; make_ui_sound("UISndClickRelease"); } @@ -353,10 +384,8 @@ BOOL LLMultiSlider::handleMouseDown(S32 x, S32 y, MASK mask) { setFocus(TRUE); } - if( mMouseDownCallback ) - { - mMouseDownCallback( this, mCallbackUserData ); - } + if (mMouseDownSignal) + (*mMouseDownSignal)( this, LLSD() ); if (MASK_CONTROL & mask) // if CTRL is modifying { @@ -379,7 +408,7 @@ BOOL LLMultiSlider::handleMouseDown(S32 x, S32 y, MASK mask) // Find the offset of the actual mouse location from the center of the thumb. if (mThumbRects[mCurSlider].pointInRect(x,y)) { - mMouseOffset = (mThumbRects[mCurSlider].mLeft + MULTI_THUMB_WIDTH/2) - x; + mMouseOffset = (mThumbRects[mCurSlider].mLeft + mThumbWidth/2) - x; } else { @@ -566,6 +595,18 @@ void LLMultiSlider::draw() LLUICtrl::draw(); } +boost::signals2::connection LLMultiSlider::setMouseDownCallback( const commit_signal_t::slot_type& cb ) +{ + if (!mMouseDownSignal) mMouseDownSignal = new commit_signal_t(); + return mMouseDownSignal->connect(cb); +} + +boost::signals2::connection LLMultiSlider::setMouseUpCallback( const commit_signal_t::slot_type& cb ) +{ + if (!mMouseUpSignal) mMouseUpSignal = new commit_signal_t(); + return mMouseUpSignal->connect(cb); +} + // virtual LLXMLNodePtr LLMultiSlider::getXML(bool save_children) const { diff --git a/indra/llui/llmultislider.h b/indra/llui/llmultislider.h index cdbdb597f..f8363fd97 100644 --- a/indra/llui/llmultislider.h +++ b/indra/llui/llmultislider.h @@ -59,6 +59,7 @@ public: virtual LLXMLNodePtr getXML(bool save_children = true) const; static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); + virtual ~LLMultiSlider(); void setSliderValue(const std::string& name, F32 value, BOOL from_event = FALSE); F32 getSliderValue(const std::string& name) const; @@ -80,15 +81,17 @@ public: void setMinValue(F32 min_value) { mMinValue = min_value; } void setMaxValue(F32 max_value) { mMaxValue = max_value; } void setIncrement(F32 increment) { mIncrement = increment; } - void setMouseDownCallback( void (*cb)(LLUICtrl* ctrl, void* userdata) ) { mMouseDownCallback = cb; } - void setMouseUpCallback( void (*cb)(LLUICtrl* ctrl, void* userdata) ) { mMouseUpCallback = cb; } + + boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb ); + boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb ); bool findUnusedValue(F32& initVal); const std::string& addSlider(); const std::string& addSlider(F32 val); - void deleteSlider(const std::string& name); - void deleteCurSlider() { deleteSlider(mCurSlider); } - void clear(); + void addSlider(F32 val, const std::string& name); + void deleteSlider(const std::string& name); + void deleteCurSlider() { deleteSlider(mCurSlider); } + void clear(); virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); @@ -112,6 +115,7 @@ protected: S32 mMouseOffset; LLRect mDragStartThumbRect; + S32 mThumbWidth; std::map mThumbRects; LLColor4 mTrackColor; @@ -121,8 +125,8 @@ protected: LLColor4 mDisabledThumbColor; LLColor4 mTriangleColor; - void (*mMouseDownCallback)(LLUICtrl* ctrl, void* userdata); - void (*mMouseUpCallback)(LLUICtrl* ctrl, void* userdata); + commit_signal_t* mMouseDownSignal; + commit_signal_t* mMouseUpSignal; }; #endif // LL_LLSLIDER_H diff --git a/indra/llui/llmultisliderctrl.cpp b/indra/llui/llmultisliderctrl.cpp index acf928f01..f4970b792 100644 --- a/indra/llui/llmultisliderctrl.cpp +++ b/indra/llui/llmultisliderctrl.cpp @@ -78,9 +78,7 @@ LLMultiSliderCtrl::LLMultiSliderCtrl(const std::string& name, const LLRect& rect mEditor( NULL ), mTextBox( NULL ), mTextEnabledColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ), - mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) ), - mSliderMouseUpCallback( NULL ), - mSliderMouseDownCallback( NULL ) + mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) ) { S32 top = getRect().getHeight(); S32 bottom = 0; @@ -421,37 +419,14 @@ void LLMultiSliderCtrl::setPrecision(S32 precision) updateText(); } -void LLMultiSliderCtrl::setSliderMouseDownCallback( void (*slider_mousedown_callback)(LLUICtrl* caller, void* userdata) ) +boost::signals2::connection LLMultiSliderCtrl::setSliderMouseDownCallback( const commit_signal_t::slot_type& cb ) { - mSliderMouseDownCallback = slider_mousedown_callback; - mMultiSlider->setMouseDownCallback( LLMultiSliderCtrl::onSliderMouseDown ); + return mMultiSlider->setMouseDownCallback( cb ); } -// static -void LLMultiSliderCtrl::onSliderMouseDown(LLUICtrl* caller, void* userdata) +boost::signals2::connection LLMultiSliderCtrl::setSliderMouseUpCallback( const commit_signal_t::slot_type& cb ) { - LLMultiSliderCtrl* self = (LLMultiSliderCtrl*) userdata; - if( self->mSliderMouseDownCallback ) - { - self->mSliderMouseDownCallback( self, self->mCallbackUserData ); - } -} - - -void LLMultiSliderCtrl::setSliderMouseUpCallback( void (*slider_mouseup_callback)(LLUICtrl* caller, void* userdata) ) -{ - mSliderMouseUpCallback = slider_mouseup_callback; - mMultiSlider->setMouseUpCallback( LLMultiSliderCtrl::onSliderMouseUp ); -} - -// static -void LLMultiSliderCtrl::onSliderMouseUp(LLUICtrl* caller, void* userdata) -{ - LLMultiSliderCtrl* self = (LLMultiSliderCtrl*) userdata; - if( self->mSliderMouseUpCallback ) - { - self->mSliderMouseUpCallback( self, self->mCallbackUserData ); - } + return mMultiSlider->setMouseUpCallback( cb ); } void LLMultiSliderCtrl::onTabInto() diff --git a/indra/llui/llmultisliderctrl.h b/indra/llui/llmultisliderctrl.h index b62b5ec32..47b1d1fb1 100644 --- a/indra/llui/llmultisliderctrl.h +++ b/indra/llui/llmultisliderctrl.h @@ -112,8 +112,8 @@ public: void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; } void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; } - void setSliderMouseDownCallback( void (*slider_mousedown_callback)(LLUICtrl* caller, void* userdata) ); - void setSliderMouseUpCallback( void (*slider_mouseup_callback)(LLUICtrl* caller, void* userdata) ); + boost::signals2::connection setSliderMouseDownCallback( const commit_signal_t::slot_type& cb ); + boost::signals2::connection setSliderMouseUpCallback( const commit_signal_t::slot_type& cb ); virtual void onTabInto(); @@ -124,10 +124,8 @@ public: virtual std::string getControlName() const; static void onSliderCommit(LLUICtrl* caller, void* userdata); - static void onSliderMouseDown(LLUICtrl* caller,void* userdata); - static void onSliderMouseUp(LLUICtrl* caller,void* userdata); - - static void onEditorCommit(LLUICtrl* caller, void* userdata); + + static void onEditorCommit(LLUICtrl* ctrl, void* userdata); static void onEditorGainFocus(LLFocusableElement* caller, void *userdata); static void onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata); @@ -151,9 +149,6 @@ private: LLColor4 mTextEnabledColor; LLColor4 mTextDisabledColor; - - void (*mSliderMouseUpCallback)( LLUICtrl* ctrl, void* userdata ); - void (*mSliderMouseDownCallback)( LLUICtrl* ctrl, void* userdata ); }; #endif // LL_MULTI_SLIDERCTRL_H diff --git a/indra/llui/llnotificationptr.h b/indra/llui/llnotificationptr.h new file mode 100644 index 000000000..acc047527 --- /dev/null +++ b/indra/llui/llnotificationptr.h @@ -0,0 +1,35 @@ +/** + * @file llnotificationptr.h + * + * $LicenseInfo:firstyear=2008&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 LLNOTIFICATIONPTR_H +#define LLNOTIFICATIONPTR_H + +// Many classes just store a single LLNotificationPtr +// and llnotifications.h is very large, so define this ligher header. +#include + +class LLNotification; +typedef boost::shared_ptr LLNotificationPtr; + +#endif diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 509a443e5..999f664a0 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -91,8 +91,9 @@ #include #include -#include #include +#include +#include // we want to minimize external dependencies, but this one is important #include "llsd.h" @@ -101,9 +102,9 @@ // and we need this to manage the notification callbacks #include "llfunctorregistry.h" #include "llui.h" +#include "llxmlnode.h" +#include "llnotificationptr.h" -class LLNotification; -typedef boost::shared_ptr LLNotificationPtr; /***************************************************************************** * Signal and handler declarations diff --git a/indra/llui/llnotificationsutil.cpp b/indra/llui/llnotificationsutil.cpp new file mode 100644 index 000000000..4abc9ca69 --- /dev/null +++ b/indra/llui/llnotificationsutil.cpp @@ -0,0 +1,85 @@ +/** + * @file llnotificationsutil.cpp + * + * $LicenseInfo:firstyear=2008&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 "llnotificationsutil.h" + +#include "llnotifications.h" +#include "llsd.h" +#include "llxmlnode.h" // apparently needed to call LLNotifications::instance() + +LLNotificationPtr LLNotificationsUtil::add(const std::string& name) +{ + return LLNotifications::instance().add( + LLNotification::Params(name).substitutions(LLSD()).payload(LLSD())); +} + +LLNotificationPtr LLNotificationsUtil::add(const std::string& name, + const LLSD& substitutions) +{ + return LLNotifications::instance().add( + LLNotification::Params(name).substitutions(substitutions).payload(LLSD())); +} + +LLNotificationPtr LLNotificationsUtil::add(const std::string& name, + const LLSD& substitutions, + const LLSD& payload) +{ + return LLNotifications::instance().add( + LLNotification::Params(name).substitutions(substitutions).payload(payload)); +} + +LLNotificationPtr LLNotificationsUtil::add(const std::string& name, + const LLSD& substitutions, + const LLSD& payload, + const std::string& functor_name) +{ + return LLNotifications::instance().add( + LLNotification::Params(name).substitutions(substitutions).payload(payload).functor_name(functor_name)); +} + +LLNotificationPtr LLNotificationsUtil::add(const std::string& name, + const LLSD& substitutions, + const LLSD& payload, + boost::function functor) +{ + return LLNotifications::instance().add( + LLNotification::Params(name).substitutions(substitutions).payload(payload).functor(functor)); +} + +S32 LLNotificationsUtil::getSelectedOption(const LLSD& notification, const LLSD& response) +{ + return LLNotification::getSelectedOption(notification, response); +} + +void LLNotificationsUtil::cancel(LLNotificationPtr pNotif) +{ + LLNotifications::instance().cancel(pNotif); +} + +LLNotificationPtr LLNotificationsUtil::find(LLUUID uuid) +{ + return LLNotifications::instance().find(uuid); +} diff --git a/indra/llui/llnotificationsutil.h b/indra/llui/llnotificationsutil.h new file mode 100644 index 000000000..4093324d0 --- /dev/null +++ b/indra/llui/llnotificationsutil.h @@ -0,0 +1,66 @@ +/** + * @file llnotificationsutil.h + * + * $LicenseInfo:firstyear=2008&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 LLNOTIFICATIONSUTIL_H +#define LLNOTIFICATIONSUTIL_H + +// The vast majority of clients of the notifications system just want to add +// a notification to the screen, so define this lightweight public interface +// to avoid including the heavyweight llnotifications.h + +#include "llnotificationptr.h" + +#include + +class LLSD; + +namespace LLNotificationsUtil +{ + LLNotificationPtr add(const std::string& name); + + LLNotificationPtr add(const std::string& name, + const LLSD& substitutions); + + LLNotificationPtr add(const std::string& name, + const LLSD& substitutions, + const LLSD& payload); + + LLNotificationPtr add(const std::string& name, + const LLSD& substitutions, + const LLSD& payload, + const std::string& functor_name); + + LLNotificationPtr add(const std::string& name, + const LLSD& substitutions, + const LLSD& payload, + boost::function functor); + + S32 getSelectedOption(const LLSD& notification, const LLSD& response); + + void cancel(LLNotificationPtr pNotif); + + LLNotificationPtr find(LLUUID uuid); +} + +#endif diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 9edc6451a..cc7f7bdcc 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -54,6 +54,7 @@ #include "lluictrlfactory.h" #include "llviewborder.h" #include "llbutton.h" +#include "llnotificationsutil.h" // LLLayoutStack #include "llresizebar.h" @@ -1049,7 +1050,7 @@ void LLPanel::childDisplayNotFound() mNewExpectedMembers.clear(); LLSD args; args["CONTROLS"] = msg; - LLNotifications::instance().add("FloaterNotFound", args); + LLNotificationsUtil::add("FloaterNotFound", args); } void LLPanel::storeRectControl() diff --git a/indra/llui/llslider.cpp b/indra/llui/llslider.cpp index 28b30cccb..145901681 100644 --- a/indra/llui/llslider.cpp +++ b/indra/llui/llslider.cpp @@ -70,8 +70,8 @@ LLSlider::LLSlider( mTrackColor( LLUI::sColorsGroup->getColor( "SliderTrackColor" ) ), mThumbOutlineColor( LLUI::sColorsGroup->getColor( "SliderThumbOutlineColor" ) ), mThumbCenterColor( LLUI::sColorsGroup->getColor( "SliderThumbCenterColor" ) ), - mMouseDownCallback( NULL ), - mMouseUpCallback( NULL ) + mMouseDownSignal( NULL ), + mMouseUpSignal( NULL ) { mThumbImage = LLUI::getUIImage("icn_slide-thumb_dark.tga"); mTrackImage = LLUI::getUIImage("icn_slide-groove_dark.tga"); @@ -87,6 +87,11 @@ LLSlider::LLSlider( mDragStartThumbRect = mThumbRect; } +LLSlider::~LLSlider() +{ + delete mMouseDownSignal; + delete mMouseUpSignal; +} void LLSlider::setValue(F32 value, BOOL from_event) { @@ -109,10 +114,11 @@ void LLSlider::setValue(F32 value, BOOL from_event) void LLSlider::updateThumbRect() { + const S32 DEFAULT_THUMB_SIZE = 16; F32 t = (mValue - mMinValue) / (mMaxValue - mMinValue); - S32 thumb_width = mThumbImage->getWidth(); - S32 thumb_height = mThumbImage->getHeight(); + S32 thumb_width = mThumbImage ? mThumbImage->getWidth() : DEFAULT_THUMB_SIZE; + S32 thumb_height = mThumbImage ? mThumbImage->getHeight() : DEFAULT_THUMB_SIZE; S32 left_edge = (thumb_width / 2); S32 right_edge = getRect().getWidth() - (thumb_width / 2); @@ -169,10 +175,9 @@ BOOL LLSlider::handleMouseUp(S32 x, S32 y, MASK mask) { gFocusMgr.setMouseCapture( NULL ); - if( mMouseUpCallback ) - { - mMouseUpCallback( this, mCallbackUserData ); - } + if (mMouseUpSignal) + (*mMouseUpSignal)( this, getValueF32() ); + handled = TRUE; make_ui_sound("UISndClickRelease"); } @@ -191,10 +196,8 @@ BOOL LLSlider::handleMouseDown(S32 x, S32 y, MASK mask) { setFocus(TRUE); } - if( mMouseDownCallback ) - { - mMouseDownCallback( this, mCallbackUserData ); - } + if (mMouseDownSignal) + (*mMouseDownSignal)( this, getValueF32() ); if (MASK_CONTROL & mask) // if CTRL is modifying { @@ -309,6 +312,17 @@ LLXMLNodePtr LLSlider::getXML(bool save_children) const return node; } +boost::signals2::connection LLSlider::setMouseDownCallback( const commit_signal_t::slot_type& cb ) +{ + if (!mMouseDownSignal) mMouseDownSignal = new commit_signal_t(); + return mMouseDownSignal->connect(cb); +} + +boost::signals2::connection LLSlider::setMouseUpCallback( const commit_signal_t::slot_type& cb ) +{ + if (!mMouseUpSignal) mMouseUpSignal = new commit_signal_t(); + return mMouseUpSignal->connect(cb); +} //static LLView* LLSlider::fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory) diff --git a/indra/llui/llslider.h b/indra/llui/llslider.h index 253b72803..e09f537dd 100644 --- a/indra/llui/llslider.h +++ b/indra/llui/llslider.h @@ -55,6 +55,7 @@ public: virtual LLXMLNodePtr getXML(bool save_children = true) const; static LLView* fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory); + virtual ~LLSlider(); void setValue( F32 value, BOOL from_event = FALSE ); F32 getValueF32() const { return mValue; } @@ -71,8 +72,10 @@ public: void setMinValue(F32 min_value) {mMinValue = min_value; updateThumbRect(); } void setMaxValue(F32 max_value) {mMaxValue = max_value; updateThumbRect(); } void setIncrement(F32 increment) {mIncrement = increment;} - void setMouseDownCallback( void (*cb)(LLUICtrl* ctrl, void* userdata) ) { mMouseDownCallback = cb; } - void setMouseUpCallback( void (*cb)(LLUICtrl* ctrl, void* userdata) ) { mMouseUpCallback = cb; } + + boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb ); + boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb ); + virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); @@ -103,8 +106,8 @@ private: LLColor4 mThumbOutlineColor; LLColor4 mThumbCenterColor; - void (*mMouseDownCallback)(LLUICtrl* ctrl, void* userdata); - void (*mMouseUpCallback)(LLUICtrl* ctrl, void* userdata); + commit_signal_t* mMouseDownSignal; + commit_signal_t* mMouseUpSignal; }; #endif // LL_LLSLIDER_H diff --git a/indra/llui/llsliderctrl.cpp b/indra/llui/llsliderctrl.cpp index 590d3cf2e..ad6382729 100644 --- a/indra/llui/llsliderctrl.cpp +++ b/indra/llui/llsliderctrl.cpp @@ -76,9 +76,7 @@ LLSliderCtrl::LLSliderCtrl(const std::string& name, const LLRect& rect, mEditor( NULL ), mTextBox( NULL ), mTextEnabledColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ), - mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) ), - mSliderMouseUpCallback( NULL ), - mSliderMouseDownCallback( NULL ) + mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) ) { S32 top = getRect().getHeight(); S32 bottom = 0; @@ -352,37 +350,14 @@ void LLSliderCtrl::setPrecision(S32 precision) updateText(); } -void LLSliderCtrl::setSliderMouseDownCallback( void (*slider_mousedown_callback)(LLUICtrl* caller, void* userdata) ) +boost::signals2::connection LLSliderCtrl::setSliderMouseDownCallback( const commit_signal_t::slot_type& cb ) { - mSliderMouseDownCallback = slider_mousedown_callback; - mSlider->setMouseDownCallback( LLSliderCtrl::onSliderMouseDown ); + return mSlider->setMouseDownCallback( cb ); } -// static -void LLSliderCtrl::onSliderMouseDown(LLUICtrl* caller, void* userdata) +boost::signals2::connection LLSliderCtrl::setSliderMouseUpCallback( const commit_signal_t::slot_type& cb ) { - LLSliderCtrl* self = (LLSliderCtrl*) userdata; - if( self->mSliderMouseDownCallback ) - { - self->mSliderMouseDownCallback( self, self->mCallbackUserData ); - } -} - - -void LLSliderCtrl::setSliderMouseUpCallback( void (*slider_mouseup_callback)(LLUICtrl* caller, void* userdata) ) -{ - mSliderMouseUpCallback = slider_mouseup_callback; - mSlider->setMouseUpCallback( LLSliderCtrl::onSliderMouseUp ); -} - -// static -void LLSliderCtrl::onSliderMouseUp(LLUICtrl* caller, void* userdata) -{ - LLSliderCtrl* self = (LLSliderCtrl*) userdata; - if( self->mSliderMouseUpCallback ) - { - self->mSliderMouseUpCallback( self, self->mCallbackUserData ); - } + return mSlider->setMouseUpCallback( cb ); } void LLSliderCtrl::onTabInto() diff --git a/indra/llui/llsliderctrl.h b/indra/llui/llsliderctrl.h index 272dd7ffd..68748eb4d 100644 --- a/indra/llui/llsliderctrl.h +++ b/indra/llui/llsliderctrl.h @@ -75,14 +75,18 @@ public: virtual LLSD getValue() const { return LLSD(getValueF32()); } virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); - virtual void setMinValue(LLSD min_value) { setMinValue((F32)min_value.asReal()); } - virtual void setMaxValue(LLSD max_value) { setMaxValue((F32)max_value.asReal()); } + BOOL isMouseHeldDown() const { return mSlider->hasMouseCapture(); } + + virtual void setPrecision(S32 precision); + virtual void setEnabled( BOOL b ); virtual void clear(); - virtual void setPrecision(S32 precision); + + virtual void setMinValue(LLSD min_value) { setMinValue((F32)min_value.asReal()); } + virtual void setMaxValue(LLSD max_value) { setMaxValue((F32)max_value.asReal()); } void setMinValue(F32 min_value) { mSlider->setMinValue(min_value); updateText(); } void setMaxValue(F32 max_value) { mSlider->setMaxValue(max_value); updateText(); } void setIncrement(F32 increment) { mSlider->setIncrement(increment);} @@ -94,8 +98,8 @@ public: void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; } void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; } - void setSliderMouseDownCallback( void (*slider_mousedown_callback)(LLUICtrl* caller, void* userdata) ); - void setSliderMouseUpCallback( void (*slider_mouseup_callback)(LLUICtrl* caller, void* userdata) ); + boost::signals2::connection setSliderMouseDownCallback( const commit_signal_t::slot_type& cb ); + boost::signals2::connection setSliderMouseUpCallback( const commit_signal_t::slot_type& cb ); virtual void onTabInto(); @@ -111,8 +115,6 @@ public: virtual std::string getControlName() const { return mSlider->getControlName(); } static void onSliderCommit(LLUICtrl* caller, void* userdata); - static void onSliderMouseDown(LLUICtrl* caller,void* userdata); - static void onSliderMouseUp(LLUICtrl* caller,void* userdata); static void onEditorCommit(LLUICtrl* caller, void* userdata); static void onEditorGainFocus(LLFocusableElement* caller, void *userdata); @@ -138,9 +140,6 @@ private: LLColor4 mTextEnabledColor; LLColor4 mTextDisabledColor; - - void (*mSliderMouseUpCallback)( LLUICtrl* ctrl, void* userdata ); - void (*mSliderMouseDownCallback)( LLUICtrl* ctrl, void* userdata ); }; #endif // LL_LLSLIDERCTRL_H diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index a947c434d..dae598e8c 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -487,8 +487,15 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex if (solid_color) { - gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); - gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_VERT_ALPHA); + if (LLGLSLShader::sNoFixedFunction) + { + gSolidColorProgram.bind(); + } + else + { + gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); + gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_VERT_ALPHA); + } } gGL.pushMatrix(); @@ -624,7 +631,14 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex if (solid_color) { - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } + else + { + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + } } } diff --git a/indra/llui/llui.h b/indra/llui/llui.h index a77ffa32e..541811852 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -39,6 +39,7 @@ #include "llcontrol.h" #include "llrect.h" #include "llcoord.h" +#include "llglslshader.h" //#include "llhtmlhelp.h" #include "llgl.h" // *TODO: break this dependency #include diff --git a/indra/llui/lluitrans.cpp b/indra/llui/lluitrans.cpp index 920fe6ad0..a60ff370d 100644 --- a/indra/llui/lluitrans.cpp +++ b/indra/llui/lluitrans.cpp @@ -36,6 +36,7 @@ #include "llxmlnode.h" #include "lluictrlfactory.h" #include "llalertdialog.h" +#include "llnotificationsutil.h" #include @@ -93,7 +94,7 @@ std::string LLUITrans::getString(const std::string &xml_desc, const LLStringUtil LLSD args; args["STRING_NAME"] = xml_desc; LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - LLNotifications::instance().add("MissingString", args); + LLNotificationsUtil::add("MissingString", args); return xml_desc; } diff --git a/indra/llui/llviewquery.h b/indra/llui/llviewquery.h index e87795f9a..98d9bf879 100644 --- a/indra/llui/llviewquery.h +++ b/indra/llui/llviewquery.h @@ -35,7 +35,7 @@ #include -#include "llmemory.h" +#include "llsingleton.h" #include "llui.h" class LLView; diff --git a/indra/llvfs/lldiriterator.cpp b/indra/llvfs/lldiriterator.cpp index 8afbb63ae..a0f319a90 100644 --- a/indra/llvfs/lldiriterator.cpp +++ b/indra/llvfs/lldiriterator.cpp @@ -51,8 +51,24 @@ LLDirIterator::Impl::Impl(const std::string &dirname, const std::string &mask) { fs::path dir_path(dirname); - // Check if path exists. - if (!fs::exists(dir_path)) + bool is_dir = false; + + // Check if path is a directory. + try + { + is_dir = fs::is_directory(dir_path); + } +#if BOOST_FILESYSTEM_VERSION >= 3 + catch (fs::filesystem_error& e) +#else + catch (fs::basic_filesystem_error& e) +#endif + { + llwarns << e.what() << llendl; + return; + } + + if (!is_dir) { llwarns << "Invalid path: \"" << dir_path.string() << "\"" << llendl; return; diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 710789fc4..8d927f7e9 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -33,14 +33,18 @@ include_directories( set(llwindow_SOURCE_FILES llkeyboard.cpp + llkeyboardheadless.cpp llwindowheadless.cpp + llwindowcallbacks.cpp ) -set(llwindows_HEADER_FILES +set(llwindow_HEADER_FILES CMakeLists.txt llkeyboard.h + llkeyboardheadless.h llwindowheadless.h + llwindowcallbacks.h ) set(viewer_SOURCE_FILES @@ -55,10 +59,13 @@ set(viewer_HEADER_FILES # Libraries on which this library depends, needed for Linux builds # Sort by high-level to low-level -set(llwindow_LINK_LIBRARIES - ${UI_LIBRARIES} # for GTK - ${SDL_LIBRARY} - ) +if (LINUX AND VIEWER) + set(llwindow_LINK_LIBRARIES + ${UI_LIBRARIES} # for GTK + ${SDL_LIBRARY} + fontconfig # For FCInit and other FC* functions. + ) +endif (LINUX AND VIEWER) if (DARWIN) list(APPEND llwindow_SOURCE_FILES @@ -81,7 +88,7 @@ if (DARWIN) ) endif (DARWIN) -if (LINUX) +if (LINUX AND VIEWER) list(APPEND viewer_SOURCE_FILES llkeyboardsdl.cpp llwindowsdl.cpp @@ -90,21 +97,24 @@ if (LINUX) llkeyboardsdl.h llwindowsdl.h ) -endif (LINUX) +endif (LINUX AND VIEWER) if (WINDOWS) list(APPEND llwindow_SOURCE_FILES llwindowwin32.cpp lldxhardware.cpp llkeyboardwin32.cpp + lldragdropwin32.cpp ) list(APPEND llwindow_HEADER_FILES llwindowwin32.h lldxhardware.h llkeyboardwin32.h + lldragdropwin32.h ) list(APPEND llwindow_LINK_LIBRARIES comdlg32 # Common Dialogs for ChooseColor + ole32 ) endif (WINDOWS) @@ -141,8 +151,7 @@ if (SERVER AND NOT WINDOWS AND NOT DARWIN) ${llwindow_SOURCE_FILES} ${server_SOURCE_FILES} ) - add_dependencies(llwindowheadless prepare) - # *TODO: This should probably have target_link_libraries + target_link_libraries (llwindowheadless ${llwindow_LINK_LIBRARIES}) endif (SERVER AND NOT WINDOWS AND NOT DARWIN) if (llwindow_HEADER_FILES) diff --git a/indra/llwindow/lldragdropwin32.cpp b/indra/llwindow/lldragdropwin32.cpp new file mode 100644 index 000000000..d4d444eb2 --- /dev/null +++ b/indra/llwindow/lldragdropwin32.cpp @@ -0,0 +1,365 @@ +/** + * @file lldragdrop32.cpp + * @brief Handler for Windows specific drag and drop (OS to client) code + * + * $LicenseInfo:firstyear=2001&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$ + */ + +#if LL_WINDOWS + +#if LL_OS_DRAGDROP_ENABLED + +#include "linden_common.h" + +#include "llwindowwin32.h" +#include "llkeyboardwin32.h" +#include "llwindowcallbacks.h" +#include "lldragdropwin32.h" + +class LLDragDropWin32Target: + public IDropTarget +{ + public: + //////////////////////////////////////////////////////////////////////////////// + // + LLDragDropWin32Target( HWND hWnd ) : + mRefCount( 1 ), + mAppWindowHandle( hWnd ), + mAllowDrop(false), + mIsSlurl(false) + { + }; + + virtual ~LLDragDropWin32Target() + { + }; + + //////////////////////////////////////////////////////////////////////////////// + // + ULONG __stdcall AddRef( void ) + { + return InterlockedIncrement( &mRefCount ); + }; + + //////////////////////////////////////////////////////////////////////////////// + // + ULONG __stdcall Release( void ) + { + LONG count = InterlockedDecrement( &mRefCount ); + + if ( count == 0 ) + { + delete this; + return 0; + } + else + { + return count; + }; + }; + + //////////////////////////////////////////////////////////////////////////////// + // + HRESULT __stdcall QueryInterface( REFIID iid, void** ppvObject ) + { + if ( iid == IID_IUnknown || iid == IID_IDropTarget ) + { + AddRef(); + *ppvObject = this; + return S_OK; + } + else + { + *ppvObject = 0; + return E_NOINTERFACE; + }; + }; + + //////////////////////////////////////////////////////////////////////////////// + // + HRESULT __stdcall DragEnter( IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect ) + { + FORMATETC fmtetc = { CF_TEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; + + // support CF_TEXT using a HGLOBAL? + if ( S_OK == pDataObject->QueryGetData( &fmtetc ) ) + { + mAllowDrop = true; + mDropUrl = std::string(); + mIsSlurl = false; + + STGMEDIUM stgmed; + if( S_OK == pDataObject->GetData( &fmtetc, &stgmed ) ) + { + PVOID data = GlobalLock( stgmed.hGlobal ); + mDropUrl = std::string( (char*)data ); + // XXX MAJOR MAJOR HACK! + LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(mAppWindowHandle, GWL_USERDATA); + if (NULL != window_imp) + { + LLCoordGL gl_coord( 0, 0 ); + + POINT pt2; + pt2.x = pt.x; + pt2.y = pt.y; + ScreenToClient( mAppWindowHandle, &pt2 ); + + LLCoordWindow cursor_coord_window( pt2.x, pt2.y ); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + MASK mask = gKeyboard->currentMask(TRUE); + + LLWindowCallbacks::DragNDropResult result = window_imp->completeDragNDropRequest( gl_coord, mask, + LLWindowCallbacks::DNDA_START_TRACKING, mDropUrl ); + + switch (result) + { + case LLWindowCallbacks::DND_COPY: + *pdwEffect = DROPEFFECT_COPY; + break; + case LLWindowCallbacks::DND_LINK: + *pdwEffect = DROPEFFECT_LINK; + break; + case LLWindowCallbacks::DND_MOVE: + *pdwEffect = DROPEFFECT_MOVE; + break; + case LLWindowCallbacks::DND_NONE: + default: + *pdwEffect = DROPEFFECT_NONE; + break; + } + }; + + GlobalUnlock( stgmed.hGlobal ); + ReleaseStgMedium( &stgmed ); + }; + SetFocus( mAppWindowHandle ); + } + else + { + mAllowDrop = false; + *pdwEffect = DROPEFFECT_NONE; + }; + + return S_OK; + }; + + //////////////////////////////////////////////////////////////////////////////// + // + HRESULT __stdcall DragOver( DWORD grfKeyState, POINTL pt, DWORD* pdwEffect ) + { + if ( mAllowDrop ) + { + // XXX MAJOR MAJOR HACK! + LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(mAppWindowHandle, GWL_USERDATA); + if (NULL != window_imp) + { + LLCoordGL gl_coord( 0, 0 ); + + POINT pt2; + pt2.x = pt.x; + pt2.y = pt.y; + ScreenToClient( mAppWindowHandle, &pt2 ); + + LLCoordWindow cursor_coord_window( pt2.x, pt2.y ); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + MASK mask = gKeyboard->currentMask(TRUE); + + LLWindowCallbacks::DragNDropResult result = window_imp->completeDragNDropRequest( gl_coord, mask, + LLWindowCallbacks::DNDA_TRACK, mDropUrl ); + + switch (result) + { + case LLWindowCallbacks::DND_COPY: + *pdwEffect = DROPEFFECT_COPY; + break; + case LLWindowCallbacks::DND_LINK: + *pdwEffect = DROPEFFECT_LINK; + break; + case LLWindowCallbacks::DND_MOVE: + *pdwEffect = DROPEFFECT_MOVE; + break; + case LLWindowCallbacks::DND_NONE: + default: + *pdwEffect = DROPEFFECT_NONE; + break; + } + }; + } + else + { + *pdwEffect = DROPEFFECT_NONE; + }; + + return S_OK; + }; + + //////////////////////////////////////////////////////////////////////////////// + // + HRESULT __stdcall DragLeave( void ) + { + // XXX MAJOR MAJOR HACK! + LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(mAppWindowHandle, GWL_USERDATA); + if (NULL != window_imp) + { + LLCoordGL gl_coord( 0, 0 ); + MASK mask = gKeyboard->currentMask(TRUE); + window_imp->completeDragNDropRequest( gl_coord, mask, LLWindowCallbacks::DNDA_STOP_TRACKING, mDropUrl ); + }; + return S_OK; + }; + + //////////////////////////////////////////////////////////////////////////////// + // + HRESULT __stdcall Drop( IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect ) + { + if ( mAllowDrop ) + { + // window impl stored in Window data (neat!) + LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong( mAppWindowHandle, GWL_USERDATA ); + if ( NULL != window_imp ) + { + LLCoordGL gl_coord( 0, 0 ); + + POINT pt_client; + pt_client.x = pt.x; + pt_client.y = pt.y; + ScreenToClient( mAppWindowHandle, &pt_client ); + + LLCoordWindow cursor_coord_window( pt_client.x, pt_client.y ); + window_imp->convertCoords(cursor_coord_window, &gl_coord); + llinfos << "### (Drop) URL is: " << mDropUrl << llendl; + llinfos << "### raw coords are: " << pt.x << " x " << pt.y << llendl; + llinfos << "### client coords are: " << pt_client.x << " x " << pt_client.y << llendl; + llinfos << "### GL coords are: " << gl_coord.mX << " x " << gl_coord.mY << llendl; + llinfos << llendl; + + // no keyboard modifier option yet but we could one day + MASK mask = gKeyboard->currentMask( TRUE ); + + // actually do the drop + LLWindowCallbacks::DragNDropResult result = window_imp->completeDragNDropRequest( gl_coord, mask, + LLWindowCallbacks::DNDA_DROPPED, mDropUrl ); + + switch (result) + { + case LLWindowCallbacks::DND_COPY: + *pdwEffect = DROPEFFECT_COPY; + break; + case LLWindowCallbacks::DND_LINK: + *pdwEffect = DROPEFFECT_LINK; + break; + case LLWindowCallbacks::DND_MOVE: + *pdwEffect = DROPEFFECT_MOVE; + break; + case LLWindowCallbacks::DND_NONE: + default: + *pdwEffect = DROPEFFECT_NONE; + break; + } + }; + } + else + { + *pdwEffect = DROPEFFECT_NONE; + }; + + return S_OK; + }; + + //////////////////////////////////////////////////////////////////////////////// + // + private: + LONG mRefCount; + HWND mAppWindowHandle; + bool mAllowDrop; + std::string mDropUrl; + bool mIsSlurl; + friend class LLWindowWin32; +}; + +//////////////////////////////////////////////////////////////////////////////// +// +LLDragDropWin32::LLDragDropWin32() : + mDropTarget( NULL ), + mDropWindowHandle( NULL ) + +{ +} + +//////////////////////////////////////////////////////////////////////////////// +// +LLDragDropWin32::~LLDragDropWin32() +{ +} + +//////////////////////////////////////////////////////////////////////////////// +// +bool LLDragDropWin32::init( HWND hWnd ) +{ + if ( NOERROR != OleInitialize( NULL ) ) + return FALSE; + + mDropTarget = new LLDragDropWin32Target( hWnd ); + if ( mDropTarget ) + { + HRESULT result = CoLockObjectExternal( mDropTarget, TRUE, FALSE ); + if ( S_OK == result ) + { + result = RegisterDragDrop( hWnd, mDropTarget ); + if ( S_OK != result ) + { + // RegisterDragDrop failed + return false; + }; + + // all ok + mDropWindowHandle = hWnd; + } + else + { + // Unable to lock OLE object + return false; + }; + }; + + // success + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +// +void LLDragDropWin32::reset() +{ + if ( mDropTarget ) + { + RevokeDragDrop( mDropWindowHandle ); + CoLockObjectExternal( mDropTarget, FALSE, TRUE ); + mDropTarget->Release(); + }; + + OleUninitialize(); +} + +#endif // LL_OS_DRAGDROP_ENABLED + +#endif // LL_WINDOWS + diff --git a/indra/llwindow/lldragdropwin32.h b/indra/llwindow/lldragdropwin32.h new file mode 100644 index 000000000..929e7f9e3 --- /dev/null +++ b/indra/llwindow/lldragdropwin32.h @@ -0,0 +1,74 @@ +/** + * @file lldragdrop32.cpp + * @brief Handler for Windows specific drag and drop (OS to client) code + * + * $LicenseInfo:firstyear=2004&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$ + */ + +#if LL_WINDOWS + +#if LL_OS_DRAGDROP_ENABLED + +#ifndef LL_LLDRAGDROP32_H +#define LL_LLDRAGDROP32_H + +#include +#include + +class LLDragDropWin32 +{ + public: + LLDragDropWin32(); + ~LLDragDropWin32(); + + bool init( HWND hWnd ); + void reset(); + + private: + IDropTarget* mDropTarget; + HWND mDropWindowHandle; +}; +#endif // LL_LLDRAGDROP32_H + +#else // LL_OS_DRAGDROP_ENABLED + +#ifndef LL_LLDRAGDROP32_H +#define LL_LLDRAGDROP32_H + +#include +#include + +// imposter class that does nothing +class LLDragDropWin32 +{ + public: + LLDragDropWin32() {}; + ~LLDragDropWin32() {}; + + bool init( HWND hWnd ) { return false; }; + void reset() { }; +}; +#endif // LL_LLDRAGDROP32_H + +#endif // LL_OS_DRAGDROP_ENABLED + +#endif // LL_WINDOWS diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp index 02b4ed17c..f0f618aef 100644 --- a/indra/llwindow/llkeyboard.cpp +++ b/indra/llwindow/llkeyboard.cpp @@ -34,7 +34,7 @@ #include "indra_constants.h" #include "llkeyboard.h" -#include "llwindow.h" +#include "llwindowcallbacks.h" // diff --git a/indra/llwindow/llkeyboardheadless.cpp b/indra/llwindow/llkeyboardheadless.cpp new file mode 100644 index 000000000..c87617c9f --- /dev/null +++ b/indra/llwindow/llkeyboardheadless.cpp @@ -0,0 +1,73 @@ +/** + * @file llkeyboardheadless.cpp + * @brief Handler for assignable key bindings + * + * $LicenseInfo:firstyear=2001&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 "llkeyboardheadless.h" +#include "llwindowcallbacks.h" + +LLKeyboardHeadless::LLKeyboardHeadless() +{ } + +void LLKeyboardHeadless::resetMaskKeys() +{ } + + +BOOL LLKeyboardHeadless::handleKeyDown(const U16 key, const U32 mask) +{ return FALSE; } + + +BOOL LLKeyboardHeadless::handleKeyUp(const U16 key, const U32 mask) +{ return FALSE; } + +MASK LLKeyboardHeadless::currentMask(BOOL for_mouse_event) +{ return MASK_NONE; } + +void LLKeyboardHeadless::scanKeyboard() +{ + for (S32 key = 0; key < KEY_COUNT; key++) + { + // Generate callback if any event has occurred on this key this frame. + // Can't just test mKeyLevel, because this could be a slow frame and + // key might have gone down then up. JC + if (mKeyLevel[key] || mKeyDown[key] || mKeyUp[key]) + { + mCurScanKey = key; + mCallbacks->handleScanKey(key, mKeyDown[key], mKeyUp[key], mKeyLevel[key]); + } + } + + // Reset edges for next frame + for (S32 key = 0; key < KEY_COUNT; key++) + { + mKeyUp[key] = FALSE; + mKeyDown[key] = FALSE; + if (mKeyLevel[key]) + { + mKeyLevelFrameCount[key]++; + } + } +} + diff --git a/indra/llwindow/llkeyboardheadless.h b/indra/llwindow/llkeyboardheadless.h new file mode 100644 index 000000000..4e666f8ce --- /dev/null +++ b/indra/llwindow/llkeyboardheadless.h @@ -0,0 +1,45 @@ +/** + * @file llkeyboardheadless.h + * @brief Handler for assignable key bindings + * + * $LicenseInfo:firstyear=2004&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_LLKEYBOARDHEADLESS_H +#define LL_LLKEYBOARDHEADLESS_H + +#include "llkeyboard.h" + +class LLKeyboardHeadless : public LLKeyboard +{ +public: + LLKeyboardHeadless(); + /*virtual*/ ~LLKeyboardHeadless() {}; + + /*virtual*/ BOOL handleKeyUp(const U16 key, MASK mask); + /*virtual*/ BOOL handleKeyDown(const U16 key, MASK mask); + /*virtual*/ void resetMaskKeys(); + /*virtual*/ MASK currentMask(BOOL for_mouse_event); + /*virtual*/ void scanKeyboard(); +}; + +#endif diff --git a/indra/llwindow/llkeyboardmacosx.cpp b/indra/llwindow/llkeyboardmacosx.cpp index ec8203216..f53773c39 100644 --- a/indra/llwindow/llkeyboardmacosx.cpp +++ b/indra/llwindow/llkeyboardmacosx.cpp @@ -34,7 +34,7 @@ #include "linden_common.h" #include "llkeyboardmacosx.h" -#include "llwindow.h" +#include "llwindowcallbacks.h" #include diff --git a/indra/llwindow/llkeyboardsdl.cpp b/indra/llwindow/llkeyboardsdl.cpp index 8a6b6d629..8a0b1de98 100644 --- a/indra/llwindow/llkeyboardsdl.cpp +++ b/indra/llwindow/llkeyboardsdl.cpp @@ -34,7 +34,7 @@ #include "linden_common.h" #include "llkeyboardsdl.h" -#include "llwindow.h" +#include "llwindowcallbacks.h" #include "SDL/SDL.h" LLKeyboardSDL::LLKeyboardSDL() diff --git a/indra/llwindow/llkeyboardwin32.cpp b/indra/llwindow/llkeyboardwin32.cpp index a06f19149..1d3fa0fc6 100644 --- a/indra/llwindow/llkeyboardwin32.cpp +++ b/indra/llwindow/llkeyboardwin32.cpp @@ -34,14 +34,15 @@ #include "linden_common.h" -#include "llkeyboardwin32.h" - -#include "llwindow.h" - #define WIN32_LEAN_AND_MEAN #include #include +#include "llkeyboardwin32.h" + +#include "llwindowcallbacks.h" + + LLKeyboardWin32::LLKeyboardWin32() { // Set up key mapping for windows - eventually can read this from a file? @@ -63,7 +64,7 @@ LLKeyboardWin32::LLKeyboardWin32() // numpad number keys for (cur_char = 0x60; cur_char <= 0x69; cur_char++) { - mTranslateKeyMap[cur_char] = (KEY)('0' + (0x60 - cur_char)); + mTranslateKeyMap[cur_char] = (KEY)('0' + (cur_char - 0x60)); } @@ -78,7 +79,7 @@ LLKeyboardWin32::LLKeyboardWin32() mTranslateKeyMap[VK_OEM_COMMA] = ','; mTranslateKeyMap[VK_OEM_MINUS] = '-'; mTranslateKeyMap[VK_OEM_PERIOD] = '.'; - mTranslateKeyMap[VK_OEM_2] = KEY_PAD_DIVIDE; + mTranslateKeyMap[VK_OEM_2] = '/';//This used to be KEY_PAD_DIVIDE, but that breaks typing into text fields in media prims mTranslateKeyMap[VK_OEM_3] = '`'; mTranslateKeyMap[VK_OEM_4] = '['; mTranslateKeyMap[VK_OEM_5] = '\\'; diff --git a/indra/llwindow/llpreeditor.h b/indra/llwindow/llpreeditor.h index 370f76cb8..623406f30 100644 --- a/indra/llwindow/llpreeditor.h +++ b/indra/llwindow/llpreeditor.h @@ -95,7 +95,7 @@ public: // the returned LLWString contains it. virtual const LLWString & getWText() const = 0; - + const LLWString & getPreeditString() const {return getWText();} // Handle a UTF-32 char on this preeditor, i.e., add the character // to the contents. // This is a back door of the method of same name of LLWindowCallback. diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index 7e412a14d..615247893 100644 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -46,14 +46,11 @@ #include "llerror.h" #include "llkeyboard.h" #include "linked_lists.h" - -//static instance for default callbacks -LLWindowCallbacks LLWindow::sDefaultCallbacks; +#include "llwindowcallbacks.h" // // LLWindowCallbacks // - LLSplashScreen *gSplashScreenp = NULL; BOOL gDebugClicks = FALSE; BOOL gDebugWindowProc = FALSE; @@ -67,158 +64,6 @@ const std::string gURLProtocolWhitelist[] = { "file:", "http:", "https:" }; // Important - these lists should match - protocol to handler const std::string gURLProtocolWhitelistHandler[] = { "http", "http", "https" }; -BOOL LLWindowCallbacks::handleTranslatedKeyDown(const KEY key, const MASK mask, BOOL repeated) -{ - return FALSE; -} - - -BOOL LLWindowCallbacks::handleTranslatedKeyUp(const KEY key, const MASK mask) -{ - return FALSE; -} - -void LLWindowCallbacks::handleScanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level) -{ -} - -BOOL LLWindowCallbacks::handleUnicodeChar(llwchar uni_char, MASK mask) -{ - return FALSE; -} - - -BOOL LLWindowCallbacks::handleMouseDown(LLWindow *window, const LLCoordGL pos, MASK mask) -{ - return FALSE; -} - -BOOL LLWindowCallbacks::handleMouseUp(LLWindow *window, const LLCoordGL pos, MASK mask) -{ - return FALSE; -} - -void LLWindowCallbacks::handleMouseLeave(LLWindow *window) -{ - return; -} - -BOOL LLWindowCallbacks::handleCloseRequest(LLWindow *window) -{ - //allow the window to close - return TRUE; -} - -void LLWindowCallbacks::handleQuit(LLWindow *window) -{ - if(LLWindowManager::destroyWindow(window) == FALSE) - { - llerrs << "LLWindowCallbacks::handleQuit() : Couldn't destroy window" << llendl; - } -} - -BOOL LLWindowCallbacks::handleRightMouseDown(LLWindow *window, const LLCoordGL pos, MASK mask) -{ - return FALSE; -} - -BOOL LLWindowCallbacks::handleRightMouseUp(LLWindow *window, const LLCoordGL pos, MASK mask) -{ - return FALSE; -} - -BOOL LLWindowCallbacks::handleMiddleMouseDown(LLWindow *window, const LLCoordGL pos, MASK mask) -{ - return FALSE; -} - -BOOL LLWindowCallbacks::handleMiddleMouseUp(LLWindow *window, const LLCoordGL pos, MASK mask) -{ - return FALSE; -} - -BOOL LLWindowCallbacks::handleActivate(LLWindow *window, BOOL activated) -{ - return FALSE; -} - -BOOL LLWindowCallbacks::handleActivateApp(LLWindow *window, BOOL activating) -{ - return FALSE; -} - -void LLWindowCallbacks::handleMouseMove(LLWindow *window, const LLCoordGL pos, MASK mask) -{ -} - -void LLWindowCallbacks::handleScrollWheel(LLWindow *window, S32 clicks) -{ -} - -void LLWindowCallbacks::handleResize(LLWindow *window, const S32 width, const S32 height) -{ -} - -void LLWindowCallbacks::handleFocus(LLWindow *window) -{ -} - -void LLWindowCallbacks::handleFocusLost(LLWindow *window) -{ -} - -void LLWindowCallbacks::handleMenuSelect(LLWindow *window, const S32 menu_item) -{ -} - -BOOL LLWindowCallbacks::handlePaint(LLWindow *window, const S32 x, const S32 y, - const S32 width, const S32 height) -{ - return FALSE; -} - -BOOL LLWindowCallbacks::handleDoubleClick(LLWindow *window, const LLCoordGL pos, MASK mask) -{ - return FALSE; -} - -void LLWindowCallbacks::handleWindowBlock(LLWindow *window) -{ -} - -void LLWindowCallbacks::handleWindowUnblock(LLWindow *window) -{ -} - -void LLWindowCallbacks::handleDataCopy(LLWindow *window, S32 data_type, void *data) -{ -} - -BOOL LLWindowCallbacks::handleTimerEvent(LLWindow *window) -{ - return FALSE; -} - -BOOL LLWindowCallbacks::handleDeviceChange(LLWindow *window) -{ - return FALSE; -} - -void LLWindowCallbacks::handlePingWatchdog(LLWindow *window, const char * msg) -{ - -} - -void LLWindowCallbacks::handlePauseWatchdog(LLWindow *window) -{ - -} - -void LLWindowCallbacks::handleResumeWatchdog(LLWindow *window) -{ - -} - S32 OSMessageBox(const std::string& text, const std::string& caption, U32 type) { @@ -257,8 +102,8 @@ S32 OSMessageBox(const std::string& text, const std::string& caption, U32 type) // LLWindow // -LLWindow::LLWindow(BOOL fullscreen, U32 flags) - : mCallbacks(&sDefaultCallbacks), +LLWindow::LLWindow(LLWindowCallbacks* callbacks, BOOL fullscreen, U32 flags) + : mCallbacks(callbacks), mPostQuit(TRUE), mFullscreen(fullscreen), mFullscreenWidth(0), @@ -277,7 +122,23 @@ LLWindow::LLWindow(BOOL fullscreen, U32 flags) mHighSurrogate(0) { } - + +LLWindow::~LLWindow() +{ + +} + +//virtual +BOOL LLWindow::isValid() +{ + return TRUE; +} + +//virtual +BOOL LLWindow::canDelete() +{ + return TRUE; +} // virtual void LLWindow::incBusyCount() { @@ -293,13 +154,28 @@ void LLWindow::decBusyCount() } } -void LLWindow::setCallbacks(LLWindowCallbacks *callbacks) +//virtual +void LLWindow::resetBusyCount() { - mCallbacks = callbacks; - if (gKeyboard) - { - gKeyboard->setCallbacks(callbacks); - } + mBusyCount = 0; +} + +//virtual +S32 LLWindow::getBusyCount() const +{ + return mBusyCount; +} + +//virtual +ECursorType LLWindow::getCursor() const +{ + return mCurrentCursor; +} + +//virtual +BOOL LLWindow::dialogColorPicker(F32 *r, F32 *g, F32 *b) +{ + return FALSE; } void *LLWindow::getMediaWindow() @@ -462,23 +338,7 @@ void LLSplashScreen::hide() static std::set sWindowList; LLWindow* LLWindowManager::createWindow( - const std::string& title, - const std::string& name, - LLCoordScreen upper_left, - LLCoordScreen size, - U32 flags, - BOOL fullscreen, - BOOL clearBg, - BOOL disable_vsync, - BOOL use_gl, - BOOL ignore_pixel_depth) -{ - return createWindow( - title, name, upper_left.mX, upper_left.mY, size.mX, size.mY, flags, - fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth); -} - -LLWindow* LLWindowManager::createWindow( + LLWindowCallbacks* callbacks, const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, @@ -492,26 +352,26 @@ LLWindow* LLWindowManager::createWindow( if (use_gl) { #if LL_MESA_HEADLESS - new_window = new LLWindowMesaHeadless( + new_window = new LLWindowMesaHeadless(callbacks, title, name, x, y, width, height, flags, fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth); #elif LL_SDL - new_window = new LLWindowSDL( + new_window = new LLWindowSDL(callbacks, title, x, y, width, height, flags, fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); #elif LL_WINDOWS - new_window = new LLWindowWin32( + new_window = new LLWindowWin32(callbacks, title, name, x, y, width, height, flags, fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); #elif LL_DARWIN - new_window = new LLWindowMacOSX( + new_window = new LLWindowMacOSX(callbacks, title, name, x, y, width, height, flags, fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); #endif } else { - new_window = new LLWindowHeadless( + new_window = new LLWindowHeadless(callbacks, title, name, x, y, width, height, flags, fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth); } diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index 4d1d4a808..a15332e2f 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -37,54 +37,15 @@ #include "llcoord.h" #include "llstring.h" #include "llcursortypes.h" +#include "llsd.h" class LLSplashScreen; class LLWindow; class LLPreeditor; +class LLWindowCallbacks; -class LLWindowCallbacks -{ -public: - virtual ~LLWindowCallbacks() {} - virtual BOOL handleTranslatedKeyDown(KEY key, MASK mask, BOOL repeated); - virtual BOOL handleTranslatedKeyUp(KEY key, MASK mask); - virtual void handleScanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level); - virtual BOOL handleUnicodeChar(llwchar uni_char, MASK mask); - - virtual BOOL handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask); - virtual BOOL handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); - virtual void handleMouseLeave(LLWindow *window); - // return TRUE to allow window to close, which will then cause handleQuit to be called - virtual BOOL handleCloseRequest(LLWindow *window); - // window is about to be destroyed, clean up your business - virtual void handleQuit(LLWindow *window); - virtual BOOL handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK mask); - virtual BOOL handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); - virtual BOOL handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask); - virtual BOOL handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); - virtual BOOL handleActivate(LLWindow *window, BOOL activated); - virtual BOOL handleActivateApp(LLWindow *window, BOOL activating); - virtual void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask); - virtual void handleScrollWheel(LLWindow *window, S32 clicks); - virtual void handleResize(LLWindow *window, S32 width, S32 height); - virtual void handleFocus(LLWindow *window); - virtual void handleFocusLost(LLWindow *window); - virtual void handleMenuSelect(LLWindow *window, S32 menu_item); - virtual BOOL handlePaint(LLWindow *window, S32 x, S32 y, S32 width, S32 height); - virtual BOOL handleDoubleClick(LLWindow *window, LLCoordGL pos, MASK mask); // double-click of left mouse button - virtual void handleWindowBlock(LLWindow *window); // window is taking over CPU for a while - virtual void handleWindowUnblock(LLWindow *window); // window coming back after taking over CPU for a while - virtual void handleDataCopy(LLWindow *window, S32 data_type, void *data); - virtual BOOL handleTimerEvent(LLWindow *window); - virtual BOOL handleDeviceChange(LLWindow *window); - - virtual void handlePingWatchdog(LLWindow *window, const char * msg); - virtual void handlePauseWatchdog(LLWindow *window); - virtual void handleResumeWatchdog(LLWindow *window); - -}; // Refer to llwindow_test in test/common/llwindow for usage example @@ -114,6 +75,8 @@ public: virtual BOOL getMinimized() = 0; virtual BOOL getMaximized() = 0; virtual BOOL maximize() = 0; + virtual void minimize() = 0; + virtual void restore() = 0; BOOL getFullscreen() { return mFullscreen; }; virtual BOOL getPosition(LLCoordScreen *position) = 0; virtual BOOL getSize(LLCoordScreen *size) = 0; @@ -134,12 +97,12 @@ public: // arrow/hour if busycount > 0. virtual void incBusyCount(); virtual void decBusyCount(); - virtual void resetBusyCount() { mBusyCount = 0; } - virtual S32 getBusyCount() const { return mBusyCount; } + virtual void resetBusyCount(); + virtual S32 getBusyCount() const; // Sets cursor, may set to arrow+hourglass virtual void setCursor(ECursorType cursor) = 0; - virtual ECursorType getCursor() const { return mCurrentCursor; } + virtual ECursorType getCursor() const; virtual void captureMouse() = 0; virtual void releaseMouse() = 0; @@ -182,13 +145,12 @@ public: virtual F32 getPixelAspectRatio() = 0; virtual void setNativeAspectRatio(F32 aspect) = 0; - void setCallbacks(LLWindowCallbacks *callbacks); - virtual void beforeDialog() {}; // prepare to put up an OS dialog (if special measures are required, such as in fullscreen mode) virtual void afterDialog() {}; // undo whatever was done in beforeDialog() -// opens system default color picker - virtual BOOL dialog_color_picker (F32 *r, F32 *g, F32 *b) { return FALSE; }; + // opens system default color picker, modally + // Returns TRUE if valid color selected + virtual BOOL dialogColorPicker(F32 *r, F32 *g, F32 *b); // return a platform-specific window reference (HWND on Windows, WindowRef on the Mac, Gtk window on Linux) virtual void *getPlatformWindow() = 0; @@ -201,18 +163,21 @@ public: virtual void setLanguageTextInput( const LLCoordGL & pos ) {}; virtual void updateLanguageTextInputArea() {} virtual void interruptLanguageTextInput() {} - virtual void spawnWebBrowser(const std::string& escaped_url) {}; + virtual void spawnWebBrowser(const std::string& escaped_url, bool async) {}; virtual void ShellEx(const std::string& command) {}; static std::vector getDynamicFallbackFontList(); + + // Provide native key event data + virtual LLSD getNativeKeyData() { return LLSD::emptyMap(); } protected: - LLWindow(BOOL fullscreen, U32 flags); - virtual ~LLWindow() {} - virtual BOOL isValid() {return TRUE;} - virtual BOOL canDelete() {return TRUE;} -protected: - static LLWindowCallbacks sDefaultCallbacks; +LLWindow(LLWindowCallbacks* callbacks, BOOL fullscreen, U32 flags); + virtual ~LLWindow(); + // Defaults to true + virtual BOOL isValid(); + // Defaults to true + virtual BOOL canDelete(); protected: LLWindowCallbacks* mCallbacks; @@ -294,18 +259,8 @@ const S32 OSBTN_CANCEL = 3; class LLWindowManager { public: - static LLWindow* createWindow( - const std::string& title, - const std::string& name, - LLCoordScreen upper_left = LLCoordScreen(10, 10), - LLCoordScreen size = LLCoordScreen(320, 240), - U32 flags = 0, - BOOL fullscreen = FALSE, - BOOL clearBg = FALSE, - BOOL disable_vsync = TRUE, - BOOL use_gl = TRUE, - BOOL ignore_pixel_depth = FALSE); static LLWindow *createWindow( + LLWindowCallbacks* callbacks, const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags = 0, BOOL fullscreen = FALSE, diff --git a/indra/llwindow/llwindowcallbacks.cpp b/indra/llwindow/llwindowcallbacks.cpp new file mode 100644 index 000000000..09689d087 --- /dev/null +++ b/indra/llwindow/llwindowcallbacks.cpp @@ -0,0 +1,189 @@ +/** + * @file llwindowcallbacks.cpp + * @brief OS event callback class + * + * $LicenseInfo:firstyear=2001&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 "llwindowcallbacks.h" + +#include "llcoord.h" + +// +// LLWindowCallbacks +// + +BOOL LLWindowCallbacks::handleTranslatedKeyDown(const KEY key, const MASK mask, BOOL repeated) +{ + return FALSE; +} + + +BOOL LLWindowCallbacks::handleTranslatedKeyUp(const KEY key, const MASK mask) +{ + return FALSE; +} + +void LLWindowCallbacks::handleScanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level) +{ +} + +BOOL LLWindowCallbacks::handleUnicodeChar(llwchar uni_char, MASK mask) +{ + return FALSE; +} + + +BOOL LLWindowCallbacks::handleMouseDown(LLWindow *window, const LLCoordGL pos, MASK mask) +{ + return FALSE; +} + +BOOL LLWindowCallbacks::handleMouseUp(LLWindow *window, const LLCoordGL pos, MASK mask) +{ + return FALSE; +} + +void LLWindowCallbacks::handleMouseLeave(LLWindow *window) +{ + return; +} + +BOOL LLWindowCallbacks::handleCloseRequest(LLWindow *window) +{ + //allow the window to close + return TRUE; +} + +void LLWindowCallbacks::handleQuit(LLWindow *window) +{ +} + +BOOL LLWindowCallbacks::handleRightMouseDown(LLWindow *window, const LLCoordGL pos, MASK mask) +{ + return FALSE; +} + +BOOL LLWindowCallbacks::handleRightMouseUp(LLWindow *window, const LLCoordGL pos, MASK mask) +{ + return FALSE; +} + +BOOL LLWindowCallbacks::handleMiddleMouseDown(LLWindow *window, const LLCoordGL pos, MASK mask) +{ + return FALSE; +} + +BOOL LLWindowCallbacks::handleMiddleMouseUp(LLWindow *window, const LLCoordGL pos, MASK mask) +{ + return FALSE; +} + +BOOL LLWindowCallbacks::handleActivate(LLWindow *window, BOOL activated) +{ + return FALSE; +} + +BOOL LLWindowCallbacks::handleActivateApp(LLWindow *window, BOOL activating) +{ + return FALSE; +} + +void LLWindowCallbacks::handleMouseMove(LLWindow *window, const LLCoordGL pos, MASK mask) +{ +} + +void LLWindowCallbacks::handleScrollWheel(LLWindow *window, S32 clicks) +{ +} + +void LLWindowCallbacks::handleResize(LLWindow *window, const S32 width, const S32 height) +{ +} + +void LLWindowCallbacks::handleFocus(LLWindow *window) +{ +} + +void LLWindowCallbacks::handleFocusLost(LLWindow *window) +{ +} + +void LLWindowCallbacks::handleMenuSelect(LLWindow *window, const S32 menu_item) +{ +} + +BOOL LLWindowCallbacks::handlePaint(LLWindow *window, const S32 x, const S32 y, + const S32 width, const S32 height) +{ + return FALSE; +} + +BOOL LLWindowCallbacks::handleDoubleClick(LLWindow *window, const LLCoordGL pos, MASK mask) +{ + return FALSE; +} + +void LLWindowCallbacks::handleWindowBlock(LLWindow *window) +{ +} + +void LLWindowCallbacks::handleWindowUnblock(LLWindow *window) +{ +} + +void LLWindowCallbacks::handleDataCopy(LLWindow *window, S32 data_type, void *data) +{ +} + +LLWindowCallbacks::DragNDropResult LLWindowCallbacks::handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, DragNDropAction action, std::string data ) +{ + return LLWindowCallbacks::DND_NONE; +} + +BOOL LLWindowCallbacks::handleTimerEvent(LLWindow *window) +{ + return FALSE; +} + +BOOL LLWindowCallbacks::handleDeviceChange(LLWindow *window) +{ + return FALSE; +} + +void LLWindowCallbacks::handlePingWatchdog(LLWindow *window, const char * msg) +{ + +} + +void LLWindowCallbacks::handlePauseWatchdog(LLWindow *window) +{ + +} + +void LLWindowCallbacks::handleResumeWatchdog(LLWindow *window) +{ + +} + diff --git a/indra/llwindow/llwindowcallbacks.h b/indra/llwindow/llwindowcallbacks.h new file mode 100644 index 000000000..5ba442ed4 --- /dev/null +++ b/indra/llwindow/llwindowcallbacks.h @@ -0,0 +1,91 @@ +/** + * @file llwindowcallbacks.h + * @brief OS event callback class + * + * $LicenseInfo:firstyear=2001&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 LLWINDOWCALLBACKS_H +#define LLWINDOWCALLBACKS_H + +class LLCoordGL; +class LLWindow; + +class LLWindowCallbacks +{ +public: + virtual ~LLWindowCallbacks() {} + virtual BOOL handleTranslatedKeyDown(KEY key, MASK mask, BOOL repeated); + virtual BOOL handleTranslatedKeyUp(KEY key, MASK mask); + virtual void handleScanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level); + virtual BOOL handleUnicodeChar(llwchar uni_char, MASK mask); + + virtual BOOL handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask); + virtual BOOL handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); + virtual void handleMouseLeave(LLWindow *window); + // return TRUE to allow window to close, which will then cause handleQuit to be called + virtual BOOL handleCloseRequest(LLWindow *window); + // window is about to be destroyed, clean up your business + virtual void handleQuit(LLWindow *window); + virtual BOOL handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK mask); + virtual BOOL handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); + virtual BOOL handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask); + virtual BOOL handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); + virtual BOOL handleActivate(LLWindow *window, BOOL activated); + virtual BOOL handleActivateApp(LLWindow *window, BOOL activating); + virtual void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask); + virtual void handleScrollWheel(LLWindow *window, S32 clicks); + virtual void handleResize(LLWindow *window, S32 width, S32 height); + virtual void handleFocus(LLWindow *window); + virtual void handleFocusLost(LLWindow *window); + virtual void handleMenuSelect(LLWindow *window, S32 menu_item); + virtual BOOL handlePaint(LLWindow *window, S32 x, S32 y, S32 width, S32 height); + virtual BOOL handleDoubleClick(LLWindow *window, LLCoordGL pos, MASK mask); // double-click of left mouse button + virtual void handleWindowBlock(LLWindow *window); // window is taking over CPU for a while + virtual void handleWindowUnblock(LLWindow *window); // window coming back after taking over CPU for a while + virtual void handleDataCopy(LLWindow *window, S32 data_type, void *data); + virtual BOOL handleTimerEvent(LLWindow *window); + virtual BOOL handleDeviceChange(LLWindow *window); + + enum DragNDropAction { + DNDA_START_TRACKING = 0,// Start tracking an incoming drag + DNDA_TRACK, // User is dragging an incoming drag around the window + DNDA_STOP_TRACKING, // User is no longer dragging an incoming drag around the window (may have either cancelled or dropped on the window) + DNDA_DROPPED // User dropped an incoming drag on the window (this is the "commit" event) + }; + + enum DragNDropResult { + DND_NONE = 0, // No drop allowed + DND_MOVE, // Drop accepted would result in a "move" operation + DND_COPY, // Drop accepted would result in a "copy" operation + DND_LINK // Drop accepted would result in a "link" operation + }; + virtual DragNDropResult handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, DragNDropAction action, std::string data); + + virtual void handlePingWatchdog(LLWindow *window, const char * msg); + virtual void handlePauseWatchdog(LLWindow *window); + virtual void handleResumeWatchdog(LLWindow *window); + +}; + + + +#endif diff --git a/indra/llwindow/llwindowheadless.cpp b/indra/llwindow/llwindowheadless.cpp index 374284644..6486b0a36 100644 --- a/indra/llwindow/llwindowheadless.cpp +++ b/indra/llwindow/llwindowheadless.cpp @@ -34,15 +34,19 @@ #include "indra_constants.h" #include "llwindowheadless.h" +#include "llkeyboardheadless.h" // // LLWindowHeadless // -LLWindowHeadless::LLWindowHeadless(const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, - U32 flags, BOOL fullscreen, BOOL clearBg, +LLWindowHeadless::LLWindowHeadless(LLWindowCallbacks* callbacks, const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, + U32 flags, BOOL fullscreen, BOOL clear_background, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth) - : LLWindow(fullscreen, flags) + : LLWindow(callbacks, fullscreen, flags) { + // Initialize a headless keyboard. + gKeyboard = new LLKeyboardHeadless(); + gKeyboard->setCallbacks(callbacks); } diff --git a/indra/llwindow/llwindowheadless.h b/indra/llwindow/llwindowheadless.h index 4353d157b..59fc2ec65 100644 --- a/indra/llwindow/llwindowheadless.h +++ b/indra/llwindow/llwindowheadless.h @@ -45,6 +45,8 @@ public: /*virtual*/ BOOL getMinimized() {return FALSE;}; /*virtual*/ BOOL getMaximized() {return FALSE;}; /*virtual*/ BOOL maximize() {return FALSE;}; + /*virtual*/ void minimize() {}; + /*virtual*/ void restore() {}; /*virtual*/ BOOL getFullscreen() {return FALSE;}; /*virtual*/ BOOL getPosition(LLCoordScreen *position) {return FALSE;}; /*virtual*/ BOOL getSize(LLCoordScreen *size) {return FALSE;}; @@ -94,9 +96,12 @@ public: /*virtual*/ void *getPlatformWindow() { return 0; }; /*virtual*/ void bringToFront() {}; - LLWindowHeadless(const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, - U32 flags, BOOL fullscreen, BOOL clearBg, - BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth); + LLWindowHeadless(LLWindowCallbacks* callbacks, + const std::string& title, const std::string& name, + S32 x, S32 y, + S32 width, S32 height, + U32 flags, BOOL fullscreen, BOOL clear_background, + BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth); virtual ~LLWindowHeadless(); private: diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 21921057f..5020b65b7 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -32,19 +32,21 @@ #include "linden_common.h" -#include -#include - #include "llwindowmacosx.h" + #include "llkeyboardmacosx.h" +#include "llwindowcallbacks.h" +#include "llwindowmacosx-objc.h" +#include "llpreeditor.h" + #include "llerror.h" #include "llgl.h" #include "llstring.h" #include "lldir.h" #include "indra_constants.h" -#include "llwindowmacosx-objc.h" -#include "llpreeditor.h" +#include +#include extern BOOL gDebugWindowProc; @@ -112,9 +114,6 @@ static long getDictLong (CFDictionaryRef refDict, CFStringRef key); static EventTypeSpec WindowHandlerEventList[] = { // Window-related events - // { kEventClassWindow, kEventWindowCollapsing }, - // { kEventClassWindow, kEventWindowCollapsed }, - // { kEventClassWindow, kEventWindowShown }, { kEventClassWindow, kEventWindowActivated }, { kEventClassWindow, kEventWindowDeactivated }, { kEventClassWindow, kEventWindowShown }, @@ -125,8 +124,7 @@ static EventTypeSpec WindowHandlerEventList[] = { kEventClassWindow, kEventWindowClose }, { kEventClassWindow, kEventWindowBoundsChanging }, { kEventClassWindow, kEventWindowBoundsChanged }, - // { kEventClassWindow, kEventWindowZoomed }, - // { kEventClassWindow, kEventWindowDrawContent }, + { kEventClassWindow, kEventWindowGetIdealSize }, // Mouse events { kEventClassMouse, kEventMouseDown }, @@ -214,19 +212,27 @@ static LLWindowMacOSX *gWindowImplementation = NULL; -LLWindowMacOSX::LLWindowMacOSX(const std::string& title, const std::string& name, S32 x, S32 y, S32 width, +LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks, + const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth, U32 fsaa_samples) - : LLWindow(fullscreen, flags) + : LLWindow(NULL, fullscreen, flags) { + // *HACK: During window construction we get lots of OS events for window + // reshape, activate, etc. that the viewer isn't ready to handle. + // Route them to a dummy callback structure until the end of constructor. + LLWindowCallbacks null_callbacks; + mCallbacks = &null_callbacks; + // Voodoo for calling cocoa from carbon (see llwindowmacosx-objc.mm). setupCocoa(); // Initialize the keyboard gKeyboard = new LLKeyboardMacOSX(); + gKeyboard->setCallbacks(callbacks); // Ignore use_gl for now, only used for drones on PC mWindow = NULL; @@ -244,12 +250,14 @@ LLWindowMacOSX::LLWindowMacOSX(const std::string& title, const std::string& name mCursorIgnoreNextDelta = FALSE; mNeedsResize = FALSE; mOverrideAspectRatio = 0.f; + mMaximized = FALSE; mMinimized = FALSE; mTSMDocument = NULL; // Just in case. mLanguageTextInputAllowed = FALSE; mTSMScriptCode = 0; mTSMLangCode = 0; mPreeditor = NULL; + mRawKeyEvent = NULL; mFSAASamples = fsaa_samples; mForceRebuild = FALSE; @@ -268,6 +276,8 @@ LLWindowMacOSX::LLWindowMacOSX(const std::string& title, const std::string& name mMoveEventCampartorUPP = NewEventComparatorUPP(staticMoveEventComparator); mGlobalHandlerRef = NULL; mWindowHandlerRef = NULL; + + mDragOverrideCursor = -1; // We're not clipping yet SetRect( &mOldMouseClip, 0, 0, 0, 0 ); @@ -315,6 +325,7 @@ LLWindowMacOSX::LLWindowMacOSX(const std::string& title, const std::string& name setCursor( UI_CURSOR_ARROW ); } + mCallbacks = callbacks; stop_glerror(); } @@ -447,24 +458,23 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits if(!mFullscreen && (mWindow == NULL)) { - Rect window_rect; //int displayWidth = CGDisplayPixelsWide(mDisplay); //int displayHeight = CGDisplayPixelsHigh(mDisplay); //const int menuBarPlusTitleBar = 44; // Ugly magic number. LL_DEBUGS("Window") << "createContext: creating window" << LL_ENDL; - window_rect.left = (long) x; - window_rect.right = (long) x + width; - window_rect.top = (long) y; - window_rect.bottom = (long) y + height; + mPreviousWindowRect.left = (long) x; + mPreviousWindowRect.right = (long) x + width; + mPreviousWindowRect.top = (long) y; + mPreviousWindowRect.bottom = (long) y + height; //----------------------------------------------------------------------- // Create the window //----------------------------------------------------------------------- mWindow = NewCWindow( NULL, - &window_rect, + &mPreviousWindowRect, mWindowTitle, false, // Create the window invisible. Whoever calls createContext() should show it after any moving/resizing. // noGrowDocProc, // Window with no grow box and no zoom box @@ -488,8 +498,11 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits // Set up window event handlers (some window-related events ONLY go to window handlers.) InstallStandardEventHandler(GetWindowEventTarget(mWindow)); - InstallWindowEventHandler (mWindow, mEventHandlerUPP, GetEventTypeCount (WindowHandlerEventList), WindowHandlerEventList, (void*)this, &mWindowHandlerRef); // add event handler - + InstallWindowEventHandler(mWindow, mEventHandlerUPP, GetEventTypeCount (WindowHandlerEventList), WindowHandlerEventList, (void*)this, &mWindowHandlerRef); // add event handler +#if LL_OS_DRAGDROP_ENABLED + InstallTrackingHandler( dragTrackingHandler, mWindow, (void*)this ); + InstallReceiveHandler( dragReceiveHandler, mWindow, (void*)this ); +#endif // LL_OS_DRAGDROP_ENABLED } { @@ -511,7 +524,6 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits if (mTSMDocument) { ActivateTSMDocument(mTSMDocument); - UseInputWindow(mTSMDocument, FALSE); allowLanguageTextInput(NULL, FALSE); } } @@ -531,20 +543,20 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits GLint fullscreenAttrib[] = { AGL_RGBA, - AGL_FULLSCREEN, - // AGL_NO_RECOVERY, // MBW -- XXX -- Not sure if we want this attribute - AGL_SAMPLE_BUFFERS_ARB, mFSAASamples > 0 ? 1 : 0, - AGL_SAMPLES_ARB, mFSAASamples, - AGL_DOUBLEBUFFER, - AGL_CLOSEST_POLICY, - AGL_ACCELERATED, - AGL_RED_SIZE, 8, - AGL_GREEN_SIZE, 8, - AGL_BLUE_SIZE, 8, - AGL_ALPHA_SIZE, 8, - AGL_DEPTH_SIZE, 24, - AGL_STENCIL_SIZE, 8, - AGL_NONE + AGL_FULLSCREEN, + AGL_NO_RECOVERY, + AGL_SAMPLE_BUFFERS_ARB, mFSAASamples > 0 ? 1 : 0, + AGL_SAMPLES_ARB, mFSAASamples, + AGL_DOUBLEBUFFER, + AGL_CLOSEST_POLICY, + AGL_ACCELERATED, + AGL_RED_SIZE, 8, + AGL_GREEN_SIZE, 8, + AGL_BLUE_SIZE, 8, + AGL_ALPHA_SIZE, 8, + AGL_DEPTH_SIZE, 24, + AGL_STENCIL_SIZE, 8, + AGL_NONE }; LL_DEBUGS("Window") << "createContext: creating fullscreen pixelformat" << LL_ENDL; @@ -557,11 +569,18 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits } else { + // NOTE from Leslie: + // + // AGL_NO_RECOVERY, when combined with AGL_ACCELERATED prevents software rendering + // fallback which means we won't hvae shaders that compile and link but then don't + // work. The drawback is that our shader compilation will be a bit more finicky though. + GLint windowedAttrib[] = { AGL_RGBA, - AGL_DOUBLEBUFFER, - AGL_CLOSEST_POLICY, + AGL_NO_RECOVERY, + AGL_DOUBLEBUFFER, + AGL_CLOSEST_POLICY, AGL_ACCELERATED, AGL_SAMPLE_BUFFERS_ARB, mFSAASamples > 0 ? 1 : 0, AGL_SAMPLES_ARB, mFSAASamples, @@ -1081,31 +1100,22 @@ BOOL LLWindowMacOSX::getVisible() BOOL LLWindowMacOSX::getMinimized() { - BOOL result = FALSE; - - // Since the set of states where we want to act "minimized" is non-trivial, it's easier to - // track things locally than to try and retrieve the state from the window manager. - result = mMinimized; - - return(result); + return mMinimized; } BOOL LLWindowMacOSX::getMaximized() { - BOOL result = FALSE; - - if (mWindow) - { - // TODO - } - - return(result); + return mMaximized; } BOOL LLWindowMacOSX::maximize() { - // TODO - return FALSE; + if (mWindow && !mMaximized) + { + ZoomWindow(mWindow, inContent, true); + } + + return mMaximized; } BOOL LLWindowMacOSX::getFullscreen() @@ -1261,6 +1271,7 @@ BOOL LLWindowMacOSX::setSize(const LLCoordScreen size) void LLWindowMacOSX::swapBuffers() { + glFinish(); aglSwapBuffers(mContext); } @@ -2005,7 +2016,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e // Although the spec. is unclear, replace range should // not present when there is an active preedit. We just // ignore the case. markAsPreedit will detect the case and warn it. - const LLWString & text = mPreeditor->getWText(); + const LLWString & text = mPreeditor->getPreeditString(); const S32 location = wstring_wstring_length_from_utf16_length(text, 0, range.location); const S32 length = wstring_wstring_length_from_utf16_length(text, location, range.length); mPreeditor->markAsPreedit(location, length); @@ -2125,8 +2136,8 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e // First, process the raw event. { - EventRef rawEvent; - + EventRef rawEvent = NULL; + // Get the original event and extract the modifier keys, so we can ignore command-key events. if (GetEventParameter(event, kEventParamTextInputSendKeyboardEvent, typeEventRef, NULL, sizeof(rawEvent), NULL, &rawEvent) == noErr) { @@ -2135,6 +2146,9 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e // and call this function recursively to handle the raw key event. eventHandler (myHandler, rawEvent); + + // save the raw event until we're done processing the unicode input as well. + mRawKeyEvent = rawEvent; } } @@ -2162,11 +2176,8 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e } else { - MASK mask = 0; - if(modifiers & shiftKey) { mask |= MASK_SHIFT; } - if(modifiers & (cmdKey | controlKey)) { mask |= MASK_CONTROL; } - if(modifiers & optionKey) { mask |= MASK_ALT; } - + MASK mask = LLWindowMacOSX::modifiersToMask(modifiers); + llassert( actualType == typeUnicodeText ); // The result is a UTF16 buffer. Pass the characters in turn to handleUnicodeChar. @@ -2188,6 +2199,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e delete[] buffer; } + mRawKeyEvent = NULL; result = err; } break; @@ -2203,7 +2215,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e { S32 preedit, preedit_length; mPreeditor->getPreeditRange(&preedit, &preedit_length); - const LLWString & text = mPreeditor->getWText(); + const LLWString & text = mPreeditor->getPreeditString(); LLCoordGL caret_coord; LLRect preedit_bounds; @@ -2240,7 +2252,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e mPreeditor->getSelectionRange(&selection, &selection_length); if (selection_length) { - const LLWString text = mPreeditor->getWText().substr(selection, selection_length); + const LLWString text = mPreeditor->getPreeditString().substr(selection, selection_length); const llutf16string text_utf16 = wstring_to_utf16str(text); result = SetEventParameter(event, kEventParamTextInputReplyText, typeUnicodeText, text_utf16.length() * sizeof(U16), text_utf16.c_str()); @@ -2262,6 +2274,9 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e GetEventParameter (event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode); GetEventParameter (event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); + // save the raw event so getNativeKeyData can use it. + mRawKeyEvent = event; + // printf("key event, key code = 0x%08x, char code = 0x%02x (%c), modifiers = 0x%08x\n", keyCode, charCode, (char)charCode, modifiers); // fflush(stdout); @@ -2357,6 +2372,8 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e result = eventNotHandledErr; break; } + + mRawKeyEvent = NULL; } break; @@ -2527,31 +2544,92 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e } mCallbacks->handleFocusLost(this); break; + case kEventWindowBoundsChanging: { + // This is where we would constrain move/resize to a particular screen + + const S32 MIN_WIDTH = 320; + const S32 MIN_HEIGHT = 240; + Rect currentBounds; Rect previousBounds; GetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, ¤tBounds); GetEventParameter(event, kEventParamPreviousBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &previousBounds); - - // This is where we would constrain move/resize to a particular screen - if(0) + + // Put an offset into window un-maximize operation since the kEventWindowGetIdealSize + // event only allows the specification of size and not position. + if (mMaximized) { - SetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, sizeof(Rect), ¤tBounds); + short leftOffset = mPreviousWindowRect.left - currentBounds.left; + currentBounds.left += leftOffset; + currentBounds.right += leftOffset; + + short topOffset = mPreviousWindowRect.top - currentBounds.top; + currentBounds.top += topOffset; + currentBounds.bottom += topOffset; } + else + { + // Store off the size for future un-maximize operations + mPreviousWindowRect = previousBounds; + } + + if ((currentBounds.right - currentBounds.left) < MIN_WIDTH) + { + currentBounds.right = currentBounds.left + MIN_WIDTH; + } + + if ((currentBounds.bottom - currentBounds.top) < MIN_HEIGHT) + { + currentBounds.bottom = currentBounds.top + MIN_HEIGHT; + } + + SetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, sizeof(Rect), ¤tBounds); + result = noErr; } break; case kEventWindowBoundsChanged: { + // Get new window bounds Rect newBounds; - GetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &newBounds); + + // Get previous window bounds + Rect oldBounds; + GetEventParameter(event, kEventParamPreviousBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &oldBounds); + + // Determine if the new size is larger than the old + bool newBoundsLarger = ((newBounds.right - newBounds.left) >= (oldBounds.right - oldBounds.left)); + newBoundsLarger &= ((newBounds.bottom - newBounds.top) >= (oldBounds.bottom - oldBounds.top)); + + // Check to see if this is a zoom event (+ button on window pane) + unsigned int eventParams; + GetEventParameter(event, kEventParamAttributes, typeUInt32, NULL, sizeof(int), NULL, &eventParams); + bool isZoomEvent = ((eventParams & kWindowBoundsChangeZoom) != 0); + + // Maximized flag is if zoom event and increasing window size + mMaximized = (isZoomEvent && newBoundsLarger); + aglUpdateContext(mContext); + mCallbacks->handleResize(this, newBounds.right - newBounds.left, newBounds.bottom - newBounds.top); - - + } + break; + + case kEventWindowGetIdealSize: + // Only recommend a new ideal size when un-maximizing + if (mMaximized == TRUE) + { + Point nonMaximizedSize; + + nonMaximizedSize.v = mPreviousWindowRect.bottom - mPreviousWindowRect.top; + nonMaximizedSize.h = mPreviousWindowRect.right - mPreviousWindowRect.left; + + SetEventParameter(event, kEventParamDimensions, typeQDPoint, sizeof(Point), &nonMaximizedSize); + result = noErr; } break; @@ -2597,7 +2675,6 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e // BringToFront(mWindow); // result = noErr; break; - } break; @@ -2613,7 +2690,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e S32 preedit, preedit_length; mPreeditor->getPreeditRange(&preedit, &preedit_length); - const LLWString & text = mPreeditor->getWText(); + const LLWString & text = mPreeditor->getPreeditString(); const CFIndex length = wstring_utf16_length(text, 0, preedit) + wstring_utf16_length(text, preedit + preedit_length, text.length()); result = SetEventParameter(event, kEventParamTSMDocAccessCharacterCount, typeCFIndex, sizeof(length), &length); @@ -2630,7 +2707,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e S32 preedit, preedit_length; mPreeditor->getPreeditRange(&preedit, &preedit_length); - const LLWString & text = mPreeditor->getWText(); + const LLWString & text = mPreeditor->getPreeditString(); CFRange range; if (preedit_length) @@ -2664,7 +2741,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e { S32 preedit, preedit_length; mPreeditor->getPreeditRange(&preedit, &preedit_length); - const LLWString & text = mPreeditor->getWText(); + const LLWString & text = mPreeditor->getPreeditString(); // The GetCharacters event of TSMDA has a fundamental flaw; // An input method need to decide the starting offset and length @@ -2739,14 +2816,14 @@ const char* cursorIDToName(int id) case UI_CURSOR_TOOLPAN: return "UI_CURSOR_TOOLPAN"; case UI_CURSOR_TOOLZOOMIN: return "UI_CURSOR_TOOLZOOMIN"; case UI_CURSOR_TOOLPICKOBJECT3: return "UI_CURSOR_TOOLPICKOBJECT3"; - case UI_CURSOR_TOOLSIT: return "UI_CURSOR_TOOLSIT"; - case UI_CURSOR_TOOLBUY: return "UI_CURSOR_TOOLBUY"; - case UI_CURSOR_TOOLPAY: return "UI_CURSOR_TOOLPAY"; - case UI_CURSOR_TOOLOPEN: return "UI_CURSOR_TOOLOPEN"; case UI_CURSOR_TOOLPLAY: return "UI_CURSOR_TOOLPLAY"; case UI_CURSOR_TOOLPAUSE: return "UI_CURSOR_TOOLPAUSE"; case UI_CURSOR_TOOLMEDIAOPEN: return "UI_CURSOR_TOOLMEDIAOPEN"; case UI_CURSOR_PIPETTE: return "UI_CURSOR_PIPETTE"; + case UI_CURSOR_TOOLSIT: return "UI_CURSOR_TOOLSIT"; + case UI_CURSOR_TOOLBUY: return "UI_CURSOR_TOOLBUY"; + case UI_CURSOR_TOOLOPEN: return "UI_CURSOR_TOOLOPEN"; + case UI_CURSOR_TOOLPAY: return "UI_CURSOR_TOOLPAY"; } llerrs << "cursorIDToName: unknown cursor id" << id << llendl; @@ -2774,6 +2851,14 @@ void LLWindowMacOSX::setCursor(ECursorType cursor) { OSStatus result = noErr; + if (mDragOverrideCursor != -1) + { + // A drag is in progress...remember the requested cursor and we'll + // restore it when it is done + mCurrentCursor = cursor; + return; + } + if (cursor == UI_CURSOR_ARROW && mBusyCount > 0) { @@ -2838,13 +2923,13 @@ void LLWindowMacOSX::setCursor(ECursorType cursor) case UI_CURSOR_TOOLPAN: case UI_CURSOR_TOOLZOOMIN: case UI_CURSOR_TOOLPICKOBJECT3: - case UI_CURSOR_TOOLSIT: - case UI_CURSOR_TOOLBUY: - case UI_CURSOR_TOOLPAY: - case UI_CURSOR_TOOLOPEN: case UI_CURSOR_TOOLPLAY: case UI_CURSOR_TOOLPAUSE: case UI_CURSOR_TOOLMEDIAOPEN: + case UI_CURSOR_TOOLSIT: + case UI_CURSOR_TOOLBUY: + case UI_CURSOR_TOOLOPEN: + case UI_CURSOR_TOOLPAY: result = setImageCursor(gCursors[cursor]); break; @@ -2883,13 +2968,13 @@ void LLWindowMacOSX::initCursors() initPixmapCursor(UI_CURSOR_TOOLPAN, 7, 6); initPixmapCursor(UI_CURSOR_TOOLZOOMIN, 7, 6); initPixmapCursor(UI_CURSOR_TOOLPICKOBJECT3, 1, 1); - initPixmapCursor(UI_CURSOR_TOOLSIT, 1, 1); - initPixmapCursor(UI_CURSOR_TOOLBUY, 1, 1); - initPixmapCursor(UI_CURSOR_TOOLPAY, 1, 1); - initPixmapCursor(UI_CURSOR_TOOLOPEN, 1, 1); initPixmapCursor(UI_CURSOR_TOOLPLAY, 1, 1); initPixmapCursor(UI_CURSOR_TOOLPAUSE, 1, 1); initPixmapCursor(UI_CURSOR_TOOLMEDIAOPEN, 1, 1); + initPixmapCursor(UI_CURSOR_TOOLSIT, 1, 1); + initPixmapCursor(UI_CURSOR_TOOLBUY, 1, 1); + initPixmapCursor(UI_CURSOR_TOOLOPEN, 1, 1); + initPixmapCursor(UI_CURSOR_TOOLPAY, 1, 1); initPixmapCursor(UI_CURSOR_SIZENWSE, 10, 10); initPixmapCursor(UI_CURSOR_SIZENESW, 10, 10); @@ -3135,7 +3220,7 @@ S32 OSMessageBoxMacOSX(const std::string& text, const std::string& caption, U32 // Open a URL with the user's default web browser. // Must begin with protocol identifier. -void LLWindowMacOSX::spawnWebBrowser(const std::string& escaped_url) +void LLWindowMacOSX::spawnWebBrowser(const std::string& escaped_url, bool async) { bool found = false; S32 i; @@ -3188,8 +3273,62 @@ void LLWindowMacOSX::spawnWebBrowser(const std::string& escaped_url) } } +LLSD LLWindowMacOSX::getNativeKeyData() +{ + LLSD result = LLSD::emptyMap(); + + if(mRawKeyEvent) + { + char char_code = 0; + UInt32 key_code = 0; + UInt32 modifiers = 0; + UInt32 keyboard_type = 0; + + GetEventParameter (mRawKeyEvent, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &char_code); + GetEventParameter (mRawKeyEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &key_code); + GetEventParameter (mRawKeyEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); + GetEventParameter (mRawKeyEvent, kEventParamKeyboardType, typeUInt32, NULL, sizeof(UInt32), NULL, &keyboard_type); -BOOL LLWindowMacOSX::dialog_color_picker ( F32 *r, F32 *g, F32 *b) + result["char_code"] = (S32)char_code; + result["key_code"] = (S32)key_code; + result["modifiers"] = (S32)modifiers; + result["keyboard_type"] = (S32)keyboard_type; + +#if 0 + // This causes trouble for control characters -- apparently character codes less than 32 (escape, control-A, etc) + // cause llsd serialization to create XML that the llsd deserializer won't parse! + std::string unicode; + OSStatus err = noErr; + EventParamType actualType = typeUTF8Text; + UInt32 actualSize = 0; + char *buffer = NULL; + + err = GetEventParameter (mRawKeyEvent, kEventParamKeyUnicodes, typeUTF8Text, &actualType, 0, &actualSize, NULL); + if(err == noErr) + { + // allocate a buffer and get the actual data. + buffer = new char[actualSize]; + err = GetEventParameter (mRawKeyEvent, kEventParamKeyUnicodes, typeUTF8Text, &actualType, actualSize, &actualSize, buffer); + if(err == noErr) + { + unicode.assign(buffer, actualSize); + } + delete[] buffer; + } + + result["unicode"] = unicode; +#endif + + } + + + lldebugs << "native key data is: " << result << llendl; + + return result; +} + + +BOOL LLWindowMacOSX::dialogColorPicker( F32 *r, F32 *g, F32 *b) { BOOL retval = FALSE; OSErr error = noErr; @@ -3305,6 +3444,8 @@ void LLWindowMacOSX::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b) return; } + UseInputWindow(mTSMDocument, !b); + // Take care of old and new preeditors. if (preeditor != mPreeditor || !b) { @@ -3364,3 +3505,174 @@ std::vector LLWindowMacOSX::getDynamicFallbackFontList() return std::vector(); } +// static +MASK LLWindowMacOSX::modifiersToMask(SInt16 modifiers) +{ + MASK mask = 0; + if(modifiers & shiftKey) { mask |= MASK_SHIFT; } + if(modifiers & (cmdKey | controlKey)) { mask |= MASK_CONTROL; } + if(modifiers & optionKey) { mask |= MASK_ALT; } + return mask; +} + +#if LL_OS_DRAGDROP_ENABLED + +OSErr LLWindowMacOSX::dragTrackingHandler(DragTrackingMessage message, WindowRef theWindow, + void * handlerRefCon, DragRef drag) +{ + OSErr result = noErr; + LLWindowMacOSX *self = (LLWindowMacOSX*)handlerRefCon; + + lldebugs << "drag tracking handler, message = " << message << llendl; + + switch(message) + { + case kDragTrackingInWindow: + result = self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_TRACK); + break; + + case kDragTrackingEnterHandler: + result = self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_START_TRACKING); + break; + + case kDragTrackingLeaveHandler: + result = self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_STOP_TRACKING); + break; + + default: + break; + } + + return result; +} + +OSErr LLWindowMacOSX::dragReceiveHandler(WindowRef theWindow, void * handlerRefCon, + DragRef drag) +{ + LLWindowMacOSX *self = (LLWindowMacOSX*)handlerRefCon; + return self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_DROPPED); + +} + +OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, LLWindowCallbacks::DragNDropAction action) +{ + OSErr result = dragNotAcceptedErr; // overall function result + OSErr err = noErr; // for local error handling + + // Get the mouse position and modifiers of this drag. + SInt16 modifiers, mouseDownModifiers, mouseUpModifiers; + ::GetDragModifiers(drag, &modifiers, &mouseDownModifiers, &mouseUpModifiers); + MASK mask = LLWindowMacOSX::modifiersToMask(modifiers); + + Point mouse_point; + // This will return the mouse point in global screen coords + ::GetDragMouse(drag, &mouse_point, NULL); + LLCoordScreen screen_coords(mouse_point.h, mouse_point.v); + LLCoordGL gl_pos; + convertCoords(screen_coords, &gl_pos); + + // Look at the pasteboard and try to extract an URL from it + PasteboardRef pasteboard; + if(GetDragPasteboard(drag, &pasteboard) == noErr) + { + ItemCount num_items = 0; + // Treat an error here as an item count of 0 + (void)PasteboardGetItemCount(pasteboard, &num_items); + + // Only deal with single-item drags. + if(num_items == 1) + { + PasteboardItemID item_id = NULL; + CFArrayRef flavors = NULL; + CFDataRef data = NULL; + + err = PasteboardGetItemIdentifier(pasteboard, 1, &item_id); // Yes, this really is 1-based. + + // Try to extract an URL from the pasteboard + if(err == noErr) + { + err = PasteboardCopyItemFlavors( pasteboard, item_id, &flavors); + } + + if(err == noErr) + { + if(CFArrayContainsValue(flavors, CFRangeMake(0, CFArrayGetCount(flavors)), kUTTypeURL)) + { + // This is an URL. + err = PasteboardCopyItemFlavorData(pasteboard, item_id, kUTTypeURL, &data); + } + else if(CFArrayContainsValue(flavors, CFRangeMake(0, CFArrayGetCount(flavors)), kUTTypeUTF8PlainText)) + { + // This is a string that might be an URL. + err = PasteboardCopyItemFlavorData(pasteboard, item_id, kUTTypeUTF8PlainText, &data); + } + + } + + if(flavors != NULL) + { + CFRelease(flavors); + } + + if(data != NULL) + { + std::string url; + url.assign((char*)CFDataGetBytePtr(data), CFDataGetLength(data)); + CFRelease(data); + + if(!url.empty()) + { + LLWindowCallbacks::DragNDropResult res = + mCallbacks->handleDragNDrop(this, gl_pos, mask, action, url); + + switch (res) { + case LLWindowCallbacks::DND_NONE: // No drop allowed + if (action == LLWindowCallbacks::DNDA_TRACK) + { + mDragOverrideCursor = kThemeNotAllowedCursor; + } + else { + mDragOverrideCursor = -1; + } + break; + case LLWindowCallbacks::DND_MOVE: // Drop accepted would result in a "move" operation + mDragOverrideCursor = kThemePointingHandCursor; + result = noErr; + break; + case LLWindowCallbacks::DND_COPY: // Drop accepted would result in a "copy" operation + mDragOverrideCursor = kThemeCopyArrowCursor; + result = noErr; + break; + case LLWindowCallbacks::DND_LINK: // Drop accepted would result in a "link" operation: + mDragOverrideCursor = kThemeAliasArrowCursor; + result = noErr; + break; + default: + mDragOverrideCursor = -1; + break; + } + // This overrides the cursor being set by setCursor. + // This is a bit of a hack workaround because lots of areas + // within the viewer just blindly set the cursor. + if (mDragOverrideCursor == -1) + { + // Restore the cursor + ECursorType temp_cursor = mCurrentCursor; + // get around the "setting the same cursor" code in setCursor() + mCurrentCursor = UI_CURSOR_COUNT; + setCursor(temp_cursor); + } + else { + // Override the cursor + SetThemeCursor(mDragOverrideCursor); + } + + } + } + } + } + + return result; +} + +#endif // LL_OS_DRAGDROP_ENABLED diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 10ddc9ebc..504b446d1 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -34,6 +34,8 @@ #define LL_LLWINDOWMACOSX_H #include "llwindow.h" +#include "llwindowcallbacks.h" + #include "lltimer.h" #include @@ -55,6 +57,8 @@ public: /*virtual*/ BOOL getMinimized(); /*virtual*/ BOOL getMaximized(); /*virtual*/ BOOL maximize(); + /*virtual*/ void minimize(); + /*virtual*/ void restore(); /*virtual*/ BOOL getFullscreen(); /*virtual*/ BOOL getPosition(LLCoordScreen *position); /*virtual*/ BOOL getSize(LLCoordScreen *size); @@ -104,7 +108,7 @@ public: /*virtual*/ void beforeDialog(); /*virtual*/ void afterDialog(); - /*virtual*/ BOOL dialog_color_picker(F32 *r, F32 *g, F32 *b); + /*virtual*/ BOOL dialogColorPicker(F32 *r, F32 *g, F32 *b); /*virtual*/ void *getPlatformWindow(); /*virtual*/ void *getMediaWindow(); @@ -112,12 +116,16 @@ public: /*virtual*/ void allowLanguageTextInput(LLPreeditor *preeditor, BOOL b); /*virtual*/ void interruptLanguageTextInput(); - /*virtual*/ void spawnWebBrowser(const std::string& escaped_url); + /*virtual*/ void spawnWebBrowser(const std::string& escaped_url, bool async); static std::vector getDynamicFallbackFontList(); + // Provide native key event data + /*virtual*/ LLSD getNativeKeyData(); + + protected: - LLWindowMacOSX( + LLWindowMacOSX(LLWindowCallbacks* callbacks, const std::string& title, const std::string& name, int x, int y, int width, int height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth, @@ -138,9 +146,6 @@ protected: // Restore the display resolution to its value before we ran the app. BOOL resetDisplayResolution(); - void minimize(); - void restore(); - BOOL shouldPostQuit() { return mPostQuit; } @@ -157,10 +162,16 @@ protected: static pascal Boolean staticMoveEventComparator( EventRef event, void* data); OSStatus eventHandler (EventHandlerCallRef myHandler, EventRef event); void adjustCursorDecouple(bool warpingMouse = false); - void fixWindowSize(void); void stopDockTileBounce(); - - + static MASK modifiersToMask(SInt16 modifiers); + +#if LL_OS_DRAGDROP_ENABLED + static OSErr dragTrackingHandler(DragTrackingMessage message, WindowRef theWindow, + void * handlerRefCon, DragRef theDrag); + static OSErr dragReceiveHandler(WindowRef theWindow, void * handlerRefCon, DragRef theDrag); + OSErr handleDragNDrop(DragRef theDrag, LLWindowCallbacks::DragNDropAction action); +#endif // LL_OS_DRAGDROP_ENABLED + // // Platform specific variables // @@ -176,6 +187,7 @@ protected: EventComparatorUPP mMoveEventCampartorUPP; Rect mOldMouseClip; // Screen rect to which the mouse cursor was globally constrained before we changed it in clipMouse() + Rect mPreviousWindowRect; // Save previous window for un-maximize event Str255 mWindowTitle; double mOriginalAspectRatio; BOOL mSimulatedRightClick; @@ -189,15 +201,18 @@ protected: BOOL mNeedsResize; // Constructor figured out the window is too big, it needs a resize. LLCoordScreen mNeedsResizeSize; F32 mOverrideAspectRatio; + BOOL mMaximized; BOOL mMinimized; U32 mFSAASamples; BOOL mForceRebuild; + S32 mDragOverrideCursor; + F32 mBounceTime; NMRec mBounceRec; LLTimer mBounceTimer; - // Imput method management through Text Service Manager. + // Input method management through Text Service Manager. TSMDocumentID mTSMDocument; BOOL mLanguageTextInputAllowed; ScriptCode mTSMScriptCode; @@ -208,6 +223,7 @@ protected: friend class LLWindowManager; static WindowRef sMediaWindow; + EventRef mRawKeyEvent; }; diff --git a/indra/llwindow/llwindowmesaheadless.cpp b/indra/llwindow/llwindowmesaheadless.cpp index c1f9d2095..48736d920 100644 --- a/indra/llwindow/llwindowmesaheadless.cpp +++ b/indra/llwindow/llwindowmesaheadless.cpp @@ -44,10 +44,11 @@ U16 *gMesaBuffer = NULL; // // LLWindowMesaHeadless // -LLWindowMesaHeadless::LLWindowMesaHeadless(const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, +LLWindowMesaHeadless::LLWindowMesaHeadless(LLWindowCallbacks* callbacks, + const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth) - : LLWindow(fullscreen, flags) + : LLWindow(callbacks, fullscreen, flags) { if (use_gl) { diff --git a/indra/llwindow/llwindowmesaheadless.h b/indra/llwindow/llwindowmesaheadless.h index ab562d9ff..06146afde 100644 --- a/indra/llwindow/llwindowmesaheadless.h +++ b/indra/llwindow/llwindowmesaheadless.h @@ -49,6 +49,8 @@ public: /*virtual*/ BOOL getMinimized() {return FALSE;}; /*virtual*/ BOOL getMaximized() {return FALSE;}; /*virtual*/ BOOL maximize() {return FALSE;}; + /*virtual*/ void minimize() {}; + /*virtual*/ void restore() {}; /*virtual*/ BOOL getFullscreen() {return FALSE;}; /*virtual*/ BOOL getPosition(LLCoordScreen *position) {return FALSE;}; /*virtual*/ BOOL getSize(LLCoordScreen *size) {return FALSE;}; @@ -98,7 +100,8 @@ public: /*virtual*/ void *getPlatformWindow() { return 0; }; /*virtual*/ void bringToFront() {}; - LLWindowMesaHeadless(const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, + LLWindowMesaHeadless(LLWindowCallbacks* callbacks, + const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth); ~LLWindowMesaHeadless(); diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 94177e6d5..2023beaf0 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -36,6 +36,8 @@ #include "linden_common.h" #include "llwindowsdl.h" + +#include "llwindowcallbacks.h" #include "llkeyboardsdl.h" #include "llerror.h" #include "llgl.h" @@ -188,16 +190,19 @@ Display* LLWindowSDL::get_SDL_Display(void) #endif // LL_X11 -LLWindowSDL::LLWindowSDL(const std::string& title, S32 x, S32 y, S32 width, +LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks, + const std::string& title, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth, U32 fsaa_samples) - : LLWindow(fullscreen, flags), Lock_Display(NULL), + : LLWindow(callbacks, fullscreen, flags), + Lock_Display(NULL), Unlock_Display(NULL), mGamma(1.0f) { // Initialize the keyboard gKeyboard = new LLKeyboardSDL(); + gKeyboard->setCallbacks(callbacks); // Note that we can't set up key-repeat until after SDL has init'd video // Ignore use_gl for now, only used for drones on PC @@ -249,6 +254,10 @@ LLWindowSDL::LLWindowSDL(const std::string& title, S32 x, S32 y, S32 width, #if LL_X11 mFlashing = FALSE; #endif // LL_X11 + + mKeyScanCode = 0; + mKeyVirtualKey = 0; + mKeyModifiers = KMOD_NONE; } static SDL_Surface *Load_BMP_Resource(const char *basename) @@ -445,14 +454,20 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B << int(r_sdl_version->minor) << "." << int(r_sdl_version->patch) << llendl; - const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo( ); - if (!videoInfo) + const SDL_VideoInfo *video_info = SDL_GetVideoInfo( ); + if (!video_info) { llinfos << "SDL_GetVideoInfo() failed! " << SDL_GetError() << llendl; setupFailure("SDL_GetVideoInfo() failed, Window creation error", "Error", OSMB_OK); return FALSE; } + if (video_info->current_h > 0) + { + mOriginalAspectRatio = (float)video_info->current_w / (float)video_info->current_h; + llinfos << "Original aspect ratio was " << video_info->current_w << ":" << video_info->current_h << "=" << mOriginalAspectRatio << llendl; + } + SDL_EnableUNICODE(1); SDL_WM_SetCaption(mWindowTitle.c_str(), mWindowTitle.c_str()); @@ -653,7 +668,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B // fallback to letting SDL detect VRAM. // note: I've not seen SDL's detection ever actually find // VRAM != 0, but if SDL *does* detect it then that's a bonus. - gGLManager.mVRAM = videoInfo->video_mem / 1024; + gGLManager.mVRAM = video_info->video_mem / 1024; if (gGLManager.mVRAM != 0) { llinfos << "SDL detected " << gGLManager.mVRAM << "MB VRAM." << llendl; @@ -986,7 +1001,10 @@ BOOL LLWindowSDL::setSize(const LLCoordScreen size) void LLWindowSDL::swapBuffers() { if (mWindow) + { + glFinish(); SDL_GL_SwapBuffers(); + } } U32 LLWindowSDL::getFSAASamples() @@ -1282,6 +1300,49 @@ BOOL LLWindowSDL::copyTextToClipboard(const LLWString &text) return FALSE; // failure } + +BOOL LLWindowSDL::isPrimaryTextAvailable() +{ + if (ll_try_gtk_init()) + { + GtkClipboard * const clipboard = + gtk_clipboard_get(GDK_SELECTION_PRIMARY); + return gtk_clipboard_wait_is_text_available(clipboard) ? + TRUE : FALSE; + } + return FALSE; // failure +} + +BOOL LLWindowSDL::pasteTextFromPrimary(LLWString &text) +{ + if (ll_try_gtk_init()) + { + GtkClipboard * const clipboard = + gtk_clipboard_get(GDK_SELECTION_PRIMARY); + gchar * const data = gtk_clipboard_wait_for_text(clipboard); + if (data) + { + text = LLWString(utf8str_to_wstring(data)); + g_free(data); + return TRUE; + } + } + return FALSE; // failure +} + +BOOL LLWindowSDL::copyTextToPrimary(const LLWString &text) +{ + if (ll_try_gtk_init()) + { + const std::string utf8 = wstring_to_utf8str(text); + GtkClipboard * const clipboard = + gtk_clipboard_get(GDK_SELECTION_PRIMARY); + gtk_clipboard_set_text(clipboard, utf8.c_str(), utf8.length()); + return TRUE; + } + return FALSE; // failure +} + #else BOOL LLWindowSDL::isClipboardTextAvailable() @@ -1298,6 +1359,22 @@ BOOL LLWindowSDL::copyTextToClipboard(const LLWString &s) { return FALSE; // unsupported } + +BOOL LLWindowSDL::isPrimaryTextAvailable() +{ + return FALSE; // unsupported +} + +BOOL LLWindowSDL::pasteTextFromPrimary(LLWString &dst) +{ + return FALSE; // unsupported +} + +BOOL LLWindowSDL::copyTextToPrimary(const LLWString &s) +{ + return FALSE; // unsupported +} + #endif // LL_GTK LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_resolutions) @@ -1534,6 +1611,76 @@ U32 LLWindowSDL::SDLCheckGrabbyKeys(SDLKey keysym, BOOL gain) return mGrabbyKeyFlags; } + +void check_vm_bloat() +{ +#if LL_LINUX + // watch our own VM and RSS sizes, warn if we bloated rapidly + FILE *fp = fopen("/proc/self/stat", "r"); + if (fp) + { + static long long last_vm_size = 0; + static long long last_rss_size = 0; + const long long significant_vm_difference = 250 * 1024*1024; + const long long significant_rss_difference = 50 * 1024*1024; + + ssize_t res; + size_t dummy; + char *ptr; + for (int i=0; i<22; ++i) // parse past the values we don't want + { + ptr = NULL; + res = getdelim(&ptr, &dummy, ' ', fp); + free(ptr); + } + // 23rd space-delimited entry is vsize + ptr = NULL; + res = getdelim(&ptr, &dummy, ' ', fp); + llassert(ptr); + long long this_vm_size = atoll(ptr); + free(ptr); + // 24th space-delimited entry is RSS + ptr = NULL; + res = getdelim(&ptr, &dummy, ' ', fp); + llassert(ptr); + long long this_rss_size = getpagesize() * atoll(ptr); + free(ptr); + + llinfos << "VM SIZE IS NOW " << (this_vm_size/(1024*1024)) << " MB, RSS SIZE IS NOW " << (this_rss_size/(1024*1024)) << " MB" << llendl; + + if (llabs(last_vm_size - this_vm_size) > + significant_vm_difference) + { + if (this_vm_size > last_vm_size) + { + llwarns << "VM size grew by " << (this_vm_size - last_vm_size)/(1024*1024) << " MB in last frame" << llendl; + } + else + { + llinfos << "VM size shrank by " << (last_vm_size - this_vm_size)/(1024*1024) << " MB in last frame" << llendl; + } + } + + if (llabs(last_rss_size - this_rss_size) > + significant_rss_difference) + { + if (this_rss_size > last_rss_size) + { + llwarns << "RSS size grew by " << (this_rss_size - last_rss_size)/(1024*1024) << " MB in last frame" << llendl; + } + else + { + llinfos << "RSS size shrank by " << (last_rss_size - this_rss_size)/(1024*1024) << " MB in last frame" << llendl; + } + } + + last_rss_size = this_rss_size; + last_vm_size = this_vm_size; + + fclose(fp); + } +#endif // LL_LINUX +} // virtual void LLWindowSDL::processMiscNativeEvents() { @@ -1558,13 +1705,19 @@ void LLWindowSDL::processMiscNativeEvents() pump_timer.setTimerExpirySec(1.0f / 15.0f); do { // Always do at least one non-blocking pump - gtk_main_iteration_do(0); + gtk_main_iteration_do(FALSE); } while (gtk_events_pending() && !pump_timer.hasExpired()); setlocale(LC_ALL, saved_locale.c_str() ); } #endif // LL_GTK + + // hack - doesn't belong here - but this is just for debugging + if (getenv("LL_DEBUG_BLOAT")) + { + check_vm_bloat(); + } } void LLWindowSDL::gatherInput() @@ -1592,6 +1745,9 @@ void LLWindowSDL::gatherInput() } case SDL_KEYDOWN: + mKeyScanCode = event.key.keysym.scancode; + mKeyVirtualKey = event.key.keysym.unicode; + mKeyModifiers = event.key.keysym.mod; gKeyboard->handleKeyDown(event.key.keysym.sym, event.key.keysym.mod); // part of the fix for SL-13243 if (SDLCheckGrabbyKeys(event.key.keysym.sym, TRUE) != 0) @@ -1605,8 +1761,12 @@ void LLWindowSDL::gatherInput() break; case SDL_KEYUP: - if (SDLCheckGrabbyKeys(event.key.keysym.sym, FALSE) == 0) - SDLReallyCaptureInput(FALSE); // part of the fix for SL-13243 + mKeyScanCode = event.key.keysym.scancode; + mKeyVirtualKey = event.key.keysym.unicode; + mKeyModifiers = event.key.keysym.mod; + + if (SDLCheckGrabbyKeys(event.key.keysym.sym, FALSE) == 0) + SDLReallyCaptureInput(FALSE); // part of the fix for SL-13243 gKeyboard->handleKeyUp(event.key.keysym.sym, event.key.keysym.mod); break; @@ -1922,14 +2082,14 @@ void LLWindowSDL::initCursors() mSDLCursors[UI_CURSOR_TOOLPAN] = makeSDLCursorFromBMP("lltoolpan.BMP",7,5); mSDLCursors[UI_CURSOR_TOOLZOOMIN] = makeSDLCursorFromBMP("lltoolzoomin.BMP",7,5); mSDLCursors[UI_CURSOR_TOOLPICKOBJECT3] = makeSDLCursorFromBMP("toolpickobject3.BMP",0,0); - mSDLCursors[UI_CURSOR_TOOLSIT] = makeSDLCursorFromBMP("toolsit.BMP",0,0); - mSDLCursors[UI_CURSOR_TOOLBUY] = makeSDLCursorFromBMP("toolbuy.BMP",0,0); - mSDLCursors[UI_CURSOR_TOOLPAY] = makeSDLCursorFromBMP("toolpay.BMP",0,0); - mSDLCursors[UI_CURSOR_TOOLOPEN] = makeSDLCursorFromBMP("toolopen.BMP",0,0); mSDLCursors[UI_CURSOR_TOOLPLAY] = makeSDLCursorFromBMP("toolplay.BMP",0,0); mSDLCursors[UI_CURSOR_TOOLPAUSE] = makeSDLCursorFromBMP("toolpause.BMP",0,0); mSDLCursors[UI_CURSOR_TOOLMEDIAOPEN] = makeSDLCursorFromBMP("toolmediaopen.BMP",0,0); mSDLCursors[UI_CURSOR_PIPETTE] = makeSDLCursorFromBMP("lltoolpipette.BMP",2,28); + mSDLCursors[UI_CURSOR_TOOLSIT] = makeSDLCursorFromBMP("toolsit.BMP",0,0); + mSDLCursors[UI_CURSOR_TOOLBUY] = makeSDLCursorFromBMP("toolbuy.BMP",0,0); + mSDLCursors[UI_CURSOR_TOOLOPEN] = makeSDLCursorFromBMP("toolopen.BMP",0,0); + mSDLCursors[UI_CURSOR_TOOLPAY] = makeSDLCursorFromBMP("toolpay.BMP",0,0); if (getenv("LL_ATI_MOUSE_CURSOR_BUG") != NULL) { llinfos << "Disabling cursor updating due to LL_ATI_MOUSE_CURSOR_BUG" << llendl; @@ -2169,7 +2329,40 @@ static void color_changed_callback(GtkWidget *widget, gtk_color_selection_get_current_color(colorsel, colorp); } -BOOL LLWindowSDL::dialog_color_picker ( F32 *r, F32 *g, F32 *b) + +/* + Make the raw keyboard data available - used to poke through to LLQtWebKit so + that Qt/Webkit has access to the virtual keycodes etc. that it needs +*/ +LLSD LLWindowSDL::getNativeKeyData() +{ + LLSD result = LLSD::emptyMap(); + + U32 modifiers = 0; // pretend-native modifiers... oh what a tangled web we weave! + + // we go through so many levels of device abstraction that I can't really guess + // what a plugin under GDK under Qt under SL under SDL under X11 considers + // a 'native' modifier mask. this has been sort of reverse-engineered... they *appear* + // to match GDK consts, but that may be co-incidence. + modifiers |= (mKeyModifiers & KMOD_LSHIFT) ? 0x0001 : 0; + modifiers |= (mKeyModifiers & KMOD_RSHIFT) ? 0x0001 : 0;// munge these into the same shift + modifiers |= (mKeyModifiers & KMOD_CAPS) ? 0x0002 : 0; + modifiers |= (mKeyModifiers & KMOD_LCTRL) ? 0x0004 : 0; + modifiers |= (mKeyModifiers & KMOD_RCTRL) ? 0x0004 : 0;// munge these into the same ctrl + modifiers |= (mKeyModifiers & KMOD_LALT) ? 0x0008 : 0;// untested + modifiers |= (mKeyModifiers & KMOD_RALT) ? 0x0008 : 0;// untested + // *todo: test ALTs - I don't have a case for testing these. Do you? + // *todo: NUM? - I don't care enough right now (and it's not a GDK modifier). + + result["scan_code"] = (S32)mKeyScanCode; + result["virtual_key"] = (S32)mKeyVirtualKey; + result["modifiers"] = (S32)modifiers; + + return result; +} + + +BOOL LLWindowSDL::dialogColorPicker( F32 *r, F32 *g, F32 *b) { BOOL rtn = FALSE; @@ -2247,7 +2440,7 @@ S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 typ return 0; } -BOOL LLWindowSDL::dialog_color_picker ( F32 *r, F32 *g, F32 *b) +BOOL LLWindowSDL::dialogColorPicker( F32 *r, F32 *g, F32 *b) { return (FALSE); } @@ -2288,7 +2481,7 @@ void exec_cmd(const std::string& cmd, const std::string& arg) // Open a URL with the user's default web browser. // Must begin with protocol identifier. -void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url) +void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async) { llinfos << "spawn_web_browser: " << escaped_url << llendl; @@ -2304,8 +2497,10 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url) # endif // LL_X11 std::string cmd, arg; - cmd = gDirUtilp->getAppRODataDir().c_str(); - cmd += gDirUtilp->getDirDelimiter().c_str(); + cmd = gDirUtilp->getAppRODataDir(); + cmd += gDirUtilp->getDirDelimiter(); + cmd += "etc"; + cmd += gDirUtilp->getDirDelimiter(); cmd += "launch_url.sh"; arg = escaped_url; exec_cmd(cmd, arg); @@ -2364,6 +2559,7 @@ std::vector LLWindowSDL::getDynamicFallbackFontList() // Use libfontconfig to find us a nice ordered list of fallback fonts // specific to this system. std::string final_fallback("/usr/share/fonts/truetype/kochi/kochi-gothic.ttf"); + const int max_font_count_cutoff = 40; // fonts are expensive in the current system, don't enumerate an arbitrary number of them // Our 'ideal' font properties which define the sorting results. // slant=0 means Roman, index=0 means the first face in a font file // (the one we actually use), weight=80 means medium weight, @@ -2379,7 +2575,6 @@ std::vector LLWindowSDL::getDynamicFallbackFontList() std::vector rtns; FcFontSet *fs = NULL; FcPattern *sortpat = NULL; - int font_count = 0; llinfos << "Getting system font list from FontConfig..." << llendl; @@ -2423,12 +2618,13 @@ std::vector LLWindowSDL::getDynamicFallbackFontList() FcPatternDestroy(sortpat); } + int found_font_count = 0; if (fs) { // Get the full pathnames to the fonts, where available, // which is what we really want. - int i; - for (i=0; infont; ++i) + found_font_count = fs->nfont; + for (int i=0; infont; ++i) { FcChar8 *filename; if (FcResultMatch == FcPatternGetString(fs->fonts[i], @@ -2437,7 +2633,8 @@ std::vector LLWindowSDL::getDynamicFallbackFontList() && filename) { rtns.push_back(std::string((const char*)filename)); - ++font_count; + if (rtns.size() >= max_font_count_cutoff) + break; // hit limit } } FcFontSetDestroy (fs); @@ -2450,7 +2647,7 @@ std::vector LLWindowSDL::getDynamicFallbackFontList() { lldebugs << " file: " << *it << llendl; } - llinfos << "Using " << font_count << " system font(s)." << llendl; + llinfos << "Using " << rtns.size() << "/" << found_font_count << " system fonts." << llendl; rtns.push_back(final_fallback); return rtns; diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h index 2363c510d..d46ffcdd9 100644 --- a/indra/llwindow/llwindowsdl.h +++ b/indra/llwindow/llwindowsdl.h @@ -62,6 +62,8 @@ public: /*virtual*/ BOOL getMinimized(); /*virtual*/ BOOL getMaximized(); /*virtual*/ BOOL maximize(); + /*virtual*/ void minimize(); + /*virtual*/ void restore(); /*virtual*/ BOOL getFullscreen(); /*virtual*/ BOOL getPosition(LLCoordScreen *position); /*virtual*/ BOOL getSize(LLCoordScreen *size); @@ -83,6 +85,11 @@ public: /*virtual*/ BOOL isClipboardTextAvailable(); /*virtual*/ BOOL pasteTextFromClipboard(LLWString &dst); /*virtual*/ BOOL copyTextToClipboard(const LLWString & src); + + /*virtual*/ BOOL isPrimaryTextAvailable(); + /*virtual*/ BOOL pasteTextFromPrimary(LLWString &dst); + /*virtual*/ BOOL copyTextToPrimary(const LLWString & src); + /*virtual*/ void flashIcon(F32 seconds); /*virtual*/ F32 getGamma(); /*virtual*/ BOOL setGamma(const F32 gamma); // Set the gamma @@ -112,12 +119,12 @@ public: /*virtual*/ void beforeDialog(); /*virtual*/ void afterDialog(); - /*virtual*/ BOOL dialog_color_picker(F32 *r, F32 *g, F32 *b); + /*virtual*/ BOOL dialogColorPicker(F32 *r, F32 *g, F32 *b); /*virtual*/ void *getPlatformWindow(); /*virtual*/ void bringToFront(); - /*virtual*/ void spawnWebBrowser(const std::string& escaped_url); + /*virtual*/ void spawnWebBrowser(const std::string& escaped_url, bool async); static std::vector getDynamicFallbackFontList(); @@ -141,27 +148,25 @@ public: #endif // LL_X11 protected: - LLWindowSDL( + LLWindowSDL(LLWindowCallbacks* callbacks, const std::string& title, int x, int y, int width, int height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth, U32 fsaa_samples); ~LLWindowSDL(); + /*virtual*/ BOOL isValid(); + /*virtual*/ LLSD getNativeKeyData(); + void initCursors(); void quitCursors(); - BOOL isValid(); void moveWindow(const LLCoordScreen& position,const LLCoordScreen& size); - // Changes display resolution. Returns true if successful BOOL setDisplayResolution(S32 width, S32 height, S32 bits, S32 refresh); // Go back to last fullscreen display resolution. BOOL setFullscreenResolution(); - void minimize(); - void restore(); - BOOL shouldPostQuit() { return mPostQuit; } protected: @@ -199,12 +204,16 @@ protected: friend class LLWindowManager; -#if LL_X11 private: +#if LL_X11 void x11_set_urgent(BOOL urgent); BOOL mFlashing; LLTimer mFlashTimer; #endif //LL_X11 + + U32 mKeyScanCode; + U32 mKeyVirtualKey; + SDLMod mKeyModifiers; }; diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 8abbb9018..68162447f 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -36,11 +36,25 @@ #include "llwindowwin32.h" +// LLWindow library includes +#include "llkeyboardwin32.h" +#include "lldragdropwin32.h" +#include "llpreeditor.h" +#include "llwindowcallbacks.h" + +// Linden library includes +#include "llerror.h" +#include "llgl.h" +#include "llstring.h" +#include "lldir.h" + +// System includes #include #include #include #include // for _spawn #include +#include #include // Require DirectInput version 8 @@ -49,16 +63,6 @@ #include #include -#include "llkeyboardwin32.h" -#include "llerror.h" -#include "llgl.h" -#include "llstring.h" -#include "lldir.h" - -#include "indra_constants.h" - -#include "llpreeditor.h" - #include "llfasttimer.h" // culled from winuser.h @@ -360,13 +364,14 @@ LLWinImm::~LLWinImm() } -LLWindowWin32::LLWindowWin32(const std::string& title, const std::string& name, S32 x, S32 y, S32 width, +LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks, + const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth, U32 fsaa_samples) - : LLWindow(fullscreen, flags) + : LLWindow(callbacks, fullscreen, flags) { mFSAASamples = fsaa_samples; mIconResource = gIconResource; @@ -375,11 +380,18 @@ LLWindowWin32::LLWindowWin32(const std::string& title, const std::string& name, mMousePositionModified = FALSE; mInputProcessingPaused = FALSE; mPreeditor = NULL; + mKeyCharCode = 0; + mKeyScanCode = 0; + mKeyVirtualKey = 0; mhDC = NULL; mhRC = NULL; // Initialize the keyboard gKeyboard = new LLKeyboardWin32(); + gKeyboard->setCallbacks(callbacks); + + // Initialize the Drag and Drop functionality + mDragDrop = new LLDragDropWin32; // Initialize (boot strap) the Language text input management, // based on the system's (user's) default settings. @@ -494,6 +506,8 @@ LLWindowWin32::LLWindowWin32(const std::string& title, const std::string& name, //----------------------------------------------------------------------- DEVMODE dev_mode; + ::ZeroMemory(&dev_mode, sizeof(DEVMODE)); + dev_mode.dmSize = sizeof(DEVMODE); DWORD current_refresh; if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode)) { @@ -538,7 +552,26 @@ LLWindowWin32::LLWindowWin32(const std::string& title, const std::string& name, if (closest_refresh == 0) { LL_WARNS("Window") << "Couldn't find display mode " << width << " by " << height << " at " << BITS_PER_PIXEL << " bits per pixel" << LL_ENDL; - success = FALSE; + + if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode)) + { + success = FALSE; + } + else + { + if (dev_mode.dmBitsPerPel == BITS_PER_PIXEL) + { + LL_WARNS("Window") << "Current BBP is OK falling back to that" << LL_ENDL; + window_rect.right=width=dev_mode.dmPelsWidth; + window_rect.bottom=height=dev_mode.dmPelsHeight; + success = TRUE; + } + else + { + LL_WARNS("Window") << "Current BBP is BAD" << LL_ENDL; + success = FALSE; + } + } } // If we found a good resolution, use it. @@ -614,6 +647,8 @@ LLWindowWin32::LLWindowWin32(const std::string& title, const std::string& name, LLWindowWin32::~LLWindowWin32() { + delete mDragDrop; + delete [] mWindowTitle; mWindowTitle = NULL; @@ -664,6 +699,8 @@ void LLWindowWin32::close() return; } + mDragDrop->reset(); + // Make sure cursor is visible and we haven't mangled the clipping state. setMouseClipping(FALSE); showCursor(); @@ -842,6 +879,8 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO { GLuint pixel_format; DEVMODE dev_mode; + ::ZeroMemory(&dev_mode, sizeof(DEVMODE)); + dev_mode.dmSize = sizeof(DEVMODE); DWORD current_refresh; DWORD dw_ex_style; DWORD dw_style; @@ -1139,8 +1178,39 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO // First we try and get a 32 bit depth pixel format BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats); + + while(!result && mFSAASamples > 0) + { + llwarns << "FSAASamples: " << mFSAASamples << " not supported." << llendl ; + + mFSAASamples /= 2 ; //try to decrease sample pixel number until to disable anti-aliasing + if(mFSAASamples < 2) + { + mFSAASamples = 0 ; + } + + if (mFSAASamples > 0) + { + attrib_list[end_attrib + 3] = mFSAASamples; + } + else + { + cur_attrib = end_attrib ; + end_attrib = 0 ; + attrib_list[cur_attrib++] = 0 ; //end + } + result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats); + + if(result) + { + llwarns << "Only support FSAASamples: " << mFSAASamples << llendl ; + } + } + if (!result) { + llwarns << "mFSAASamples: " << mFSAASamples << llendl ; + close(); show_window_creation_error("Error after wglChoosePixelFormatARB 32-bit"); return FALSE; @@ -1368,6 +1438,11 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO } SetWindowLong(mWindowHandle, GWL_USERDATA, (U32)this); + + // register this window as handling drag/drop events from the OS + DragAcceptFiles( mWindowHandle, TRUE ); + + mDragDrop->init( mWindowHandle ); //register joystick timer callback SetTimer( mWindowHandle, 0, 1000 / 30, NULL ); // 30 fps timer @@ -1876,6 +1951,10 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ // allow system keys, such as ALT-F4 to be processed by Windows eat_keystroke = FALSE; case WM_KEYDOWN: + window_imp->mKeyCharCode = 0; // don't know until wm_char comes in next + window_imp->mKeyScanCode = ( l_param >> 16 ) & 0xff; + window_imp->mKeyVirtualKey = w_param; + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_KEYDOWN"); { if (gDebugWindowProc) @@ -1895,6 +1974,9 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ eat_keystroke = FALSE; case WM_KEYUP: { + window_imp->mKeyScanCode = ( l_param >> 16 ) & 0xff; + window_imp->mKeyVirtualKey = w_param; + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_KEYUP"); LLFastTimer t2(LLFastTimer::FTM_KEYHANDLER); @@ -1980,6 +2062,8 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ break; case WM_CHAR: + window_imp->mKeyCharCode = w_param; + // Should really use WM_UNICHAR eventually, but it requires a specific Windows version and I need // to figure out how that works. - Doug // @@ -2232,7 +2316,27 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_MOUSEWHEEL"); static short z_delta = 0; - z_delta += HIWORD(w_param); + RECT client_rect; + + // eat scroll events that occur outside our window, since we use mouse position to direct scroll + // instead of keyboard focus + // NOTE: mouse_coord is in *window* coordinates for scroll events + POINT mouse_coord = {(S32)(S16)LOWORD(l_param), (S32)(S16)HIWORD(l_param)}; + + if (ScreenToClient(window_imp->mWindowHandle, &mouse_coord) + && GetClientRect(window_imp->mWindowHandle, &client_rect)) + { + // we have a valid mouse point and client rect + if (mouse_coord.x < client_rect.left || client_rect.right < mouse_coord.x + || mouse_coord.y < client_rect.top || client_rect.bottom < mouse_coord.y) + { + // mouse is outside of client rect, so don't do anything + return 0; + } + } + + S16 incoming_z_delta = HIWORD(w_param); + z_delta += incoming_z_delta; // cout << "z_delta " << z_delta << endl; // current mouse wheels report changes in increments of zDelta (+120, -120) @@ -2352,11 +2456,15 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ return 0; case WM_COPYDATA: - window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_COPYDATA"); - // received a URL - PCOPYDATASTRUCT myCDS = (PCOPYDATASTRUCT) l_param; - window_imp->mCallbacks->handleDataCopy(window_imp, myCDS->dwData, myCDS->lpData); + { + window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_COPYDATA"); + // received a URL + PCOPYDATASTRUCT myCDS = (PCOPYDATASTRUCT) l_param; + window_imp->mCallbacks->handleDataCopy(window_imp, myCDS->dwData, myCDS->lpData); + }; return 0; + + break; } window_imp->mCallbacks->handlePauseWatchdog(window_imp); @@ -2661,6 +2769,8 @@ LLWindow::LLWindowResolution* LLWindowWin32::getSupportedResolutions(S32 &num_re { mSupportedResolutions = new LLWindowResolution[MAX_NUM_RESOLUTIONS]; DEVMODE dev_mode; + ::ZeroMemory(&dev_mode, sizeof(DEVMODE)); + dev_mode.dmSize = sizeof(DEVMODE); mNumSupportedResolutions = 0; for (S32 mode_num = 0; mNumSupportedResolutions < MAX_NUM_RESOLUTIONS; mode_num++) @@ -2736,7 +2846,8 @@ F32 LLWindowWin32::getPixelAspectRatio() BOOL LLWindowWin32::setDisplayResolution(S32 width, S32 height, S32 bits, S32 refresh) { DEVMODE dev_mode; - dev_mode.dmSize = sizeof(dev_mode); + ::ZeroMemory(&dev_mode, sizeof(DEVMODE)); + dev_mode.dmSize = sizeof(DEVMODE); BOOL success = FALSE; // Don't change anything if we don't have to @@ -2808,6 +2919,7 @@ BOOL LLWindowWin32::resetDisplayResolution() void LLWindowWin32::swapBuffers() { + glFinish(); SwapBuffers(mhDC); } @@ -2942,7 +3054,7 @@ void LLWindowWin32::ShellEx(const std::string& command ) } -void LLWindowWin32::spawnWebBrowser(const std::string& escaped_url ) +void LLWindowWin32::spawnWebBrowser(const std::string& escaped_url, bool async) { bool found = false; S32 i; @@ -2972,16 +3084,36 @@ void LLWindowWin32::spawnWebBrowser(const std::string& escaped_url ) // let the OS decide what to use to open the URL SHELLEXECUTEINFO sei = { sizeof( sei ) }; - sei.fMask = SEE_MASK_FLAG_DDEWAIT; + if (async) + { + sei.fMask = SEE_MASK_ASYNCOK; + } + + else + { + sei.fMask = SEE_MASK_FLAG_DDEWAIT; + } sei.nShow = SW_SHOWNORMAL; sei.lpVerb = L"open"; sei.lpFile = url_utf16.c_str(); ShellExecuteEx( &sei ); - } +/* + Make the raw keyboard data available - used to poke through to LLQtWebKit so + that Qt/Webkit has access to the virtual keycodes etc. that it needs +*/ +LLSD LLWindowWin32::getNativeKeyData() +{ + LLSD result = LLSD::emptyMap(); -BOOL LLWindowWin32::dialog_color_picker ( F32 *r, F32 *g, F32 *b ) + result["scan_code"] = (S32)mKeyScanCode; + result["virtual_key"] = (S32)mKeyVirtualKey; + + return result; +} + +BOOL LLWindowWin32::dialogColorPicker( F32 *r, F32 *g, F32 *b ) { BOOL retval = FALSE; @@ -3475,6 +3607,13 @@ static LLWString find_context(const LLWString & wtext, S32 focus, S32 focus_leng return wtext.substr(start, end - start); } +// final stage of handling drop requests - both from WM_DROPFILES message +// for files and via IDropTarget interface requests. +LLWindowCallbacks::DragNDropResult LLWindowWin32::completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, LLWindowCallbacks::DragNDropAction action, const std::string url ) +{ + return mCallbacks->handleDragNDrop( this, gl_coord, mask, action, url ); +} + // Handle WM_IME_REQUEST message. // If it handled the message, returns TRUE. Otherwise, FALSE. // When it handled the message, the value to be returned from @@ -3508,7 +3647,7 @@ BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result) // WCHARs, i.e., UTF-16 encoding units, so we can't simply pass the // number to getPreeditLocation. - const LLWString & wtext = mPreeditor->getWText(); + const LLWString & wtext = mPreeditor->getPreeditString(); S32 preedit, preedit_length; mPreeditor->getPreeditRange(&preedit, &preedit_length); LLCoordGL caret_coord; @@ -3535,7 +3674,7 @@ BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result) case IMR_RECONVERTSTRING: { mPreeditor->resetPreedit(); - const LLWString & wtext = mPreeditor->getWText(); + const LLWString & wtext = mPreeditor->getPreeditString(); S32 select, select_length; mPreeditor->getSelectionRange(&select, &select_length); @@ -3577,7 +3716,7 @@ BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result) } case IMR_DOCUMENTFEED: { - const LLWString & wtext = mPreeditor->getWText(); + const LLWString & wtext = mPreeditor->getPreeditString(); S32 preedit, preedit_length; mPreeditor->getPreeditRange(&preedit, &preedit_length); diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index d3ae3250f..9343593f6 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -39,6 +39,8 @@ #include #include "llwindow.h" +#include "llwindowcallbacks.h" +#include "lldragdropwin32.h" // Hack for async host by name #define LL_WM_HOST_RESOLVED (WM_APP + 1) @@ -54,6 +56,8 @@ public: /*virtual*/ BOOL getMinimized(); /*virtual*/ BOOL getMaximized(); /*virtual*/ BOOL maximize(); + /*virtual*/ void minimize(); + /*virtual*/ void restore(); /*virtual*/ BOOL getFullscreen(); /*virtual*/ BOOL getPosition(LLCoordScreen *position); /*virtual*/ BOOL getSize(LLCoordScreen *size); @@ -100,7 +104,7 @@ public: /*virtual*/ F32 getPixelAspectRatio(); /*virtual*/ void setNativeAspectRatio(F32 ratio) { mOverrideAspectRatio = ratio; } - /*virtual*/ BOOL dialog_color_picker (F32 *r, F32 *g, F32 *b ); + /*virtual*/ BOOL dialogColorPicker(F32 *r, F32 *g, F32 *b ); /*virtual*/ void *getPlatformWindow(); /*virtual*/ void bringToFront(); @@ -110,13 +114,15 @@ public: /*virtual*/ void setLanguageTextInput( const LLCoordGL & pos ); /*virtual*/ void updateLanguageTextInputArea(); /*virtual*/ void interruptLanguageTextInput(); - /*virtual*/ void spawnWebBrowser(const std::string& escaped_url); - /*virtual*/ void ShellEx(const std::string& command); + void ShellEx(const std::string& command); + /*virtual*/ void spawnWebBrowser(const std::string& escaped_url, bool async); + + LLWindowCallbacks::DragNDropResult completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, LLWindowCallbacks::DragNDropAction action, const std::string url ); static std::vector getDynamicFallbackFontList(); protected: - LLWindowWin32( + LLWindowWin32(LLWindowCallbacks* callbacks, const std::string& title, const std::string& name, int x, int y, int width, int height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth, U32 fsaa_samples); @@ -127,7 +133,7 @@ protected: HCURSOR loadColorCursor(LPCTSTR name); BOOL isValid(); void moveWindow(const LLCoordScreen& position,const LLCoordScreen& size); - + LLSD getNativeKeyData(); // Changes display resolution. Returns true if successful BOOL setDisplayResolution(S32 width, S32 height, S32 bits, S32 refresh); @@ -138,9 +144,6 @@ protected: // Restore the display resolution to its value before we ran the app. BOOL resetDisplayResolution(); - void minimize(); - void restore(); - BOOL shouldPostQuit() { return mPostQuit; } void fillCompositionForm(const LLRect& bounds, COMPOSITIONFORM *form); @@ -207,6 +210,12 @@ protected: LLPreeditor *mPreeditor; + LLDragDropWin32* mDragDrop; + + U32 mKeyCharCode; + U32 mKeyScanCode; + U32 mKeyVirtualKey; + friend class LLWindowManager; }; diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index 806660a38..c750351ed 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -407,7 +407,8 @@ private: // Add a listener to the controls signal... // and store the connection... mConnection = controlp->getSignal()->connect( - boost::bind(&LLControlCache::handleValueChange, this, _2) + boost::bind(&LLControlCache::handleValueChange, this, _2), + boost::signals2::at_front //make sure cachedctrl slots are inserted before anything else. ); mType = controlp->type(); mControl = controlp; diff --git a/indra/lscript/lscript_compile/CMakeLists.txt b/indra/lscript/lscript_compile/CMakeLists.txt index d6faba060..fc002a612 100644 --- a/indra/lscript/lscript_compile/CMakeLists.txt +++ b/indra/lscript/lscript_compile/CMakeLists.txt @@ -5,6 +5,7 @@ include(LLCommon) include(LLMath) include(LLMessage) include(LLInventory) +include(LLPrimitive) include(LScript) include(FindCygwin) @@ -41,6 +42,7 @@ include_directories( ${LLMATH_INCLUDE_DIRS} ${LLMESSAGE_INCLUDE_DIRS} ${LLINVENTORY_INCLUDE_DIRS} + ${LLPRIMITIVE_INCLUDE_DIRS} ${LSCRIPT_INCLUDE_DIRS} ) diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l index 4ce149e52..2235dc134 100644 --- a/indra/lscript/lscript_compile/indra.l +++ b/indra/lscript/lscript_compile/indra.l @@ -7,14 +7,11 @@ FS (f|F) %n 4000 %p 5000 +%top { + #include "linden_common.h" +} + %{ -// We maintain a pre-generated lexer source file to simplify user builds. -// Before committing changes to this file, manually run -// -// flex -o indra_generated.l.cpp indra.l -// -// to update the pre-generated lexer. Then commit all files simultaneously. -#include "linden_common.h" // Deal with the fact that lex/yacc generates unreachable code #ifdef LL_WINDOWS #pragma warning (disable : 4018) // warning C4018: signed/unsigned mismatch @@ -39,6 +36,7 @@ FS (f|F) #include "llregionflags.h" #include "lscript_http.h" #include "llclickaction.h" +#include "llmediaentry.h" void count(); void line_comment(); @@ -155,6 +153,7 @@ extern "C" { int yyerror(const char *fmt, ...); } "AGENT_CROUCHING" { count(); yylval.ival = AGENT_CROUCHING; return(INTEGER_CONSTANT); } "AGENT_BUSY" { count(); yylval.ival = AGENT_BUSY; return(INTEGER_CONSTANT); } "AGENT_ALWAYS_RUN" { count(); yylval.ival = AGENT_ALWAYS_RUN; return(INTEGER_CONSTANT); } +"AGENT_AUTOPILOT" { count(); yylval.ival = AGENT_AUTOPILOT; return(INTEGER_CONSTANT); } "CAMERA_PITCH" { count(); yylval.ival = FOLLOWCAM_PITCH; return(INTEGER_CONSTANT); } "CAMERA_FOCUS_OFFSET" { count(); yylval.ival = FOLLOWCAM_FOCUS_OFFSET; return (INTEGER_CONSTANT); } @@ -237,7 +236,8 @@ extern "C" { int yyerror(const char *fmt, ...); } "CHANGED_OWNER" { count(); yylval.ival = CHANGED_OWNER; return(INTEGER_CONSTANT); } "CHANGED_REGION" { count(); yylval.ival = CHANGED_REGION; return(INTEGER_CONSTANT); } "CHANGED_TELEPORT" { count(); yylval.ival = CHANGED_TELEPORT; return(INTEGER_CONSTANT); } -"CHANGED_REGION_START" { count(); yylval.ival = CHANGED_REGION_START; return(INTEGER_CONSTANT); } +"CHANGED_REGION_START" { count(); yylval.ival = CHANGED_REGION_START; return(INTEGER_CONSTANT); } +"CHANGED_MEDIA" { count(); yylval.ival = CHANGED_MEDIA; return(INTEGER_CONSTANT); } "OBJECT_UNKNOWN_DETAIL" { count(); yylval.ival = OBJECT_UNKNOWN_DETAIL; return(INTEGER_CONSTANT); } "OBJECT_NAME" { count(); yylval.ival = OBJECT_NAME; return(INTEGER_CONSTANT); } @@ -248,6 +248,10 @@ extern "C" { int yyerror(const char *fmt, ...); } "OBJECT_OWNER" { count(); yylval.ival = OBJECT_OWNER; return(INTEGER_CONSTANT); } "OBJECT_GROUP" { count(); yylval.ival = OBJECT_GROUP; return(INTEGER_CONSTANT); } "OBJECT_CREATOR" { count(); yylval.ival = OBJECT_CREATOR; return(INTEGER_CONSTANT); } +"OBJECT_RUNNING_SCRIPT_COUNT" { count(); yylval.ival = OBJECT_RUNNING_SCRIPT_COUNT; return(INTEGER_CONSTANT); } +"OBJECT_TOTAL_SCRIPT_COUNT" { count(); yylval.ival = OBJECT_TOTAL_SCRIPT_COUNT; return(INTEGER_CONSTANT); } +"OBJECT_SCRIPT_MEMORY" { count(); yylval.ival = OBJECT_SCRIPT_MEMORY; return(INTEGER_CONSTANT); } +"OBJECT_SCRIPT_TIME" { count(); yylval.ival = OBJECT_SCRIPT_TIME; return(INTEGER_CONSTANT); } "TYPE_INTEGER" { count(); yylval.ival = LST_INTEGER; return(INTEGER_CONSTANT); } "TYPE_FLOAT" { count(); yylval.ival = LST_FLOATINGPOINT; return(INTEGER_CONSTANT); } @@ -602,6 +606,8 @@ extern "C" { int yyerror(const char *fmt, ...); } "PARCEL_DETAILS_OWNER" { count(); yylval.ival = PARCEL_DETAILS_OWNER; return(INTEGER_CONSTANT); } "PARCEL_DETAILS_GROUP" { count(); yylval.ival = PARCEL_DETAILS_GROUP; return(INTEGER_CONSTANT); } "PARCEL_DETAILS_AREA" { count(); yylval.ival = PARCEL_DETAILS_AREA; return(INTEGER_CONSTANT); } +"PARCEL_DETAILS_ID" { count(); yylval.ival = PARCEL_DETAILS_ID; return(INTEGER_CONSTANT); } +"PARCEL_DETAILS_SEE_AVATARS" { count(); yylval.ival = PARCEL_DETAILS_SEE_AVATARS; return(INTEGER_CONSTANT); } "STRING_TRIM_HEAD" { count(); yylval.ival = STRING_TRIM_HEAD; return(INTEGER_CONSTANT); } "STRING_TRIM_TAIL" { count(); yylval.ival = STRING_TRIM_TAIL; return(INTEGER_CONSTANT); } @@ -615,6 +621,7 @@ extern "C" { int yyerror(const char *fmt, ...); } "CLICK_ACTION_OPEN" { count(); yylval.ival = CLICK_ACTION_OPEN; return(INTEGER_CONSTANT); } "CLICK_ACTION_PLAY" { count(); yylval.ival = CLICK_ACTION_PLAY; return(INTEGER_CONSTANT); } "CLICK_ACTION_OPEN_MEDIA" { count(); yylval.ival = CLICK_ACTION_OPEN_MEDIA; return(INTEGER_CONSTANT); } +"CLICK_ACTION_ZOOM" { count(); yylval.ival = CLICK_ACTION_ZOOM; return(INTEGER_CONSTANT); } "TEXTURE_BLANK" { yylval.sval = new char[UUID_STR_LENGTH]; strcpy(yylval.sval, "5748decc-f629-461c-9a36-a35a221fe21f"); return(STRING_CONSTANT); } "TEXTURE_DEFAULT" { yylval.sval = new char[UUID_STR_LENGTH]; strcpy(yylval.sval, "89556747-24cb-43ed-920b-47caed15465f"); return(STRING_CONSTANT); } @@ -626,6 +633,45 @@ extern "C" { int yyerror(const char *fmt, ...); } "TOUCH_INVALID_VECTOR" { count(); return(TOUCH_INVALID_VECTOR); } "TOUCH_INVALID_TEXCOORD" { count(); return(TOUCH_INVALID_TEXCOORD); } +"PRIM_MEDIA_ALT_IMAGE_ENABLE" { count(); yylval.ival = LLMediaEntry::ALT_IMAGE_ENABLE_ID; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_CONTROLS" { count(); yylval.ival = LLMediaEntry::CONTROLS_ID; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_CURRENT_URL" { count(); yylval.ival = LLMediaEntry::CURRENT_URL_ID; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_HOME_URL" { count(); yylval.ival = LLMediaEntry::HOME_URL_ID; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_AUTO_LOOP" { count(); yylval.ival = LLMediaEntry::AUTO_LOOP_ID; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_AUTO_PLAY" { count(); yylval.ival = LLMediaEntry::AUTO_PLAY_ID; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_AUTO_SCALE" { count(); yylval.ival = LLMediaEntry::AUTO_SCALE_ID; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_AUTO_ZOOM" { count(); yylval.ival = LLMediaEntry::AUTO_ZOOM_ID; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_FIRST_CLICK_INTERACT" { count(); yylval.ival = LLMediaEntry::FIRST_CLICK_INTERACT_ID; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_WIDTH_PIXELS" { count(); yylval.ival = LLMediaEntry::WIDTH_PIXELS_ID; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_HEIGHT_PIXELS" { count(); yylval.ival = LLMediaEntry::HEIGHT_PIXELS_ID; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_WHITELIST_ENABLE" { count(); yylval.ival = LLMediaEntry::WHITELIST_ENABLE_ID; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_WHITELIST" { count(); yylval.ival = LLMediaEntry::WHITELIST_ID; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_PERMS_INTERACT" { count(); yylval.ival = LLMediaEntry::PERMS_INTERACT_ID; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_PERMS_CONTROL" { count(); yylval.ival = LLMediaEntry::PERMS_CONTROL_ID; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_PARAM_MAX" { count(); yylval.ival = LLMediaEntry::PARAM_MAX_ID; return(INTEGER_CONSTANT); } + +"PRIM_MEDIA_CONTROLS_STANDARD" { count(); yylval.ival = LLMediaEntry::STANDARD; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_CONTROLS_MINI" { count(); yylval.ival = LLMediaEntry::MINI; return(INTEGER_CONSTANT); } + +"PRIM_MEDIA_PERM_NONE" { count(); yylval.ival = LLMediaEntry::PERM_NONE; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_PERM_OWNER" { count(); yylval.ival = LLMediaEntry::PERM_OWNER; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_PERM_GROUP" { count(); yylval.ival = LLMediaEntry::PERM_GROUP; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_PERM_ANYONE" { count(); yylval.ival = LLMediaEntry::PERM_ANYONE; return(INTEGER_CONSTANT); } + +"PRIM_MEDIA_MAX_URL_LENGTH" { count(); yylval.ival = LLMediaEntry::MAX_URL_LENGTH; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_MAX_WHITELIST_SIZE" { count(); yylval.ival = LLMediaEntry::MAX_WHITELIST_SIZE; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_MAX_WHITELIST_COUNT" { count(); yylval.ival = LLMediaEntry::MAX_WHITELIST_COUNT; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_MAX_WIDTH_PIXELS" { count(); yylval.ival = LLMediaEntry::MAX_WIDTH_PIXELS; return(INTEGER_CONSTANT); } +"PRIM_MEDIA_MAX_HEIGHT_PIXELS" { count(); yylval.ival = LLMediaEntry::MAX_HEIGHT_PIXELS; return(INTEGER_CONSTANT); } + +"STATUS_OK" { count(); yylval.ival = LSL_STATUS_OK; return(INTEGER_CONSTANT); } +"STATUS_MALFORMED_PARAMS" { count(); yylval.ival = LSL_STATUS_MALFORMED_PARAMS; return(INTEGER_CONSTANT); } +"STATUS_TYPE_MISMATCH" { count(); yylval.ival = LSL_STATUS_TYPE_MISMATCH; return(INTEGER_CONSTANT); } +"STATUS_BOUNDS_ERROR" { count(); yylval.ival = LSL_STATUS_BOUNDS_ERROR; return(INTEGER_CONSTANT); } +"STATUS_NOT_FOUND" { count(); yylval.ival = LSL_STATUS_NOT_FOUND; return(INTEGER_CONSTANT); } +"STATUS_NOT_SUPPORTED" { count(); yylval.ival = LSL_STATUS_NOT_SUPPORTED; return(INTEGER_CONSTANT); } +"STATUS_INTERNAL_ERROR" { count(); yylval.ival = LSL_STATUS_INTERNAL_ERROR; return(INTEGER_CONSTANT); } +"STATUS_WHITELIST_FAILED" { count(); yylval.ival = LSL_STATUS_WHITELIST_FAILED; return(INTEGER_CONSTANT); } {L}({L}|{N})* { count(); yylval.sval = new char[strlen(yytext) + 1]; strcpy(yylval.sval, yytext); return(IDENTIFIER); } diff --git a/indra/lscript/lscript_compile/indra.y b/indra/lscript/lscript_compile/indra.y index 8834ce9b9..e4b10ffdd 100644 --- a/indra/lscript/lscript_compile/indra.y +++ b/indra/lscript/lscript_compile/indra.y @@ -1,13 +1,4 @@ %{ -// We maintain a pre-generated parser source file to simplify user builds. -// Before committing changes to this file, manually run -// -// bison -d -o indra_generated.y.cpp indra.y -// -// to update the pre-generated parser. Note that some versions of -// bison use a different default file name for the parser token -// header. Make sure the file is called 'indra_generated.y.hpp'. -// Then commit all files simultaneously. #include "linden_common.h" #include "lscript_tree.h" diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index e3dd2b851..f274020ef 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -116,7 +116,6 @@ set(viewer_SOURCE_FILES llassetuploadqueue.cpp llattachmentsmgr.cpp llaudiosourcevo.cpp - llbbox.cpp llbox.cpp llbuildnewviewsscheduler.cpp llcallbacklist.cpp @@ -597,7 +596,6 @@ set(viewer_HEADER_FILES llassetuploadqueue.h llattachmentsmgr.h llaudiosourcevo.h - llbbox.h llbox.h llbuildnewviewsscheduler.h llcallbacklist.h diff --git a/indra/newview/app_settings/dictionaries/en_sl.dic b/indra/newview/app_settings/dictionaries/en_sl.dic index 09076f788..0f25bd233 100644 --- a/indra/newview/app_settings/dictionaries/en_sl.dic +++ b/indra/newview/app_settings/dictionaries/en_sl.dic @@ -1182,6 +1182,10 @@ OBJECT_VELOCITY OBJECT_OWNER OBJECT_GROUP OBJECT_CREATOR +OBJECT_RUNNING_SCRIPT_COUNT +OBJECT_TOTAL_SCRIPT_COUNT +OBJECT_SCRIPT_MEMORY +OBJECT_SCRIPT_TIME VEHICLE_TYPE_NONE VEHICLE_TYPE_SLED VEHICLE_TYPE_CAR @@ -1478,6 +1482,8 @@ PARCEL_DETAILS_DESC PARCEL_DETAILS_OWNER PARCEL_DETAILS_GROUP PARCEL_DETAILS_AREA +PARCEL_DETAILS_ID +PARCEL_DETAILS_SEE_AVATARS STRING_TRIM_HEAD STRING_TRIM_TAIL STRING_TRIM diff --git a/indra/newview/app_settings/keywords.ini b/indra/newview/app_settings/keywords.ini index 75c1740aa..455dc9e88 100644 --- a/indra/newview/app_settings/keywords.ini +++ b/indra/newview/app_settings/keywords.ini @@ -162,6 +162,10 @@ OBJECT_VELOCITY Used with llGetObjectDetails to get an object's velocity. OBJECT_OWNER Used with llGetObjectDetails to get an object's owner's key. Will be NULL_KEY if group owned. OBJECT_GROUP Used with llGetObjectDetails to get an object's group's key. OBJECT_CREATOR Used with llGetObjectDetails to get an object's creator's key. +OBJECT_RUNNING_SCRIPT_COUNT Used with llGetObjectDetails to get an object's velocity. +OBJECT_TOTAL_SCRIPT_COUNT Used with llGetObjectDetails to get an object's owner's key. Will be NULL_KEY if group owned. +OBJECT_SCRIPT_MEMORY Used with llGetObjectDetails to get an object's group's key. +OBJECT_SCRIPT_TIME Used with llGetObjectDetails to get an object's creator's key. # some vehicle params VEHICLE_TYPE_NONE @@ -502,6 +506,8 @@ PARCEL_DETAILS_DESC Used with llGetParcelDetails to get the parcel description. PARCEL_DETAILS_OWNER Used with llGetParcelDetails to get the parcel owner id. PARCEL_DETAILS_GROUP Used with llGetParcelDetails to get the parcel group id. PARCEL_DETAILS_AREA Used with llGetParcelDetails to get the parcel area in square meters. +PARCEL_DETAILS_ID Used with llGetParcelDetails to get the parcel id. +PARCEL_DETAILS_SEE_AVATARS Used with llGetParcelDetails to get the avatars visibility setting. STRING_TRIM_HEAD Used with llStringTrim to trim leading spaces from a string. STRING_TRIM_TAIL Used with llStringTrim to trim trailing spaces from a string. diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 2fa47eaea..ae3059556 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -488,7 +488,28 @@ Value 0 - + ShyotlUseLegacyRenderPath + + Comment + Use deprecated pre-3.x OpenGL api calls. + Persist + 1 + Type + Boolean + Value + 0 + + ShyotlUseLegacyTextureBatching + + Comment + Disable usage of extra samplers in shaders. Decreases batch sizes, however also reduces branching in shaders drastcially. + Persist + 1 + Type + Boolean + Value + 0 + ResetFocusOnSelfClick Comment @@ -500,7 +521,6 @@ Value 1 - MoyFastMiniMap Comment @@ -7213,7 +7233,40 @@ F32 Value 0.25 - + + Jpeg2000AdvancedCompression + + Comment + Use advanced Jpeg2000 compression options (precincts, blocks, ordering, markers) + Persist + 1 + Type + Boolean + Value + 0 + + Jpeg2000PrecinctsSize + + Comment + Size of image precincts. Assumed square and same for all levels. Must be power of 2. + Persist + 1 + Type + S32 + Value + 256 + + Jpeg2000BlocksSize + + Comment + Size of encoding blocks. Assumed square and same for all levels. Must be power of 2. Max 64, Min 4. + Persist + 1 + Type + S32 + Value + 64 + KeepAspectForSnapshot Comment @@ -7593,7 +7646,7 @@ Value 0 - LogMessages + LogMessages Comment Log network traffic @@ -7604,6 +7657,17 @@ Value 0 + LogTextureNetworkTraffic + + Comment + Log network traffic for textures + Persist + 1 + Type + Boolean + Value + 0 + LoginAsGod Comment @@ -9546,17 +9610,28 @@ Value 0 - RenderDebugPipeline + RenderDebugPipeline Comment Enable strict pipeline debugging. Persist 1 Type - Boolean + Boolean Value 0 + RenderMaxTextureIndex + + Comment + Maximum texture index to use for indexed texture rendering. + Persist + 1 + Type + U32 + Value + 6 + RenderDebugTextureBind Comment @@ -9859,6 +9934,18 @@ Value 0 + + RenderDepthOfField + + Comment + Whether to use depth of field effect when lighting and shadows are enabled + Persist + 1 + Type + Boolean + Value + 0 + RenderSpotLightsInNondeferred @@ -9881,7 +9968,7 @@ Type F32 Value - 0.0 + -0.001 RenderSpotShadowOffset @@ -11153,28 +11240,51 @@ Value 1.0 - MeshStreamingCostScaler + MeshTriangleBudget Comment - DEBUG - Persist - 1 - Type - F32 - Value - 2.0 - - MeshThreadCount - - Comment - Number of threads to use for loading meshes. + Target visible triangle budget to use when estimating streaming cost. Persist 1 Type U32 Value - 8 + 250000 + MeshMetaDataDiscount + + Comment + Number of bytes to deduct for metadata when determining streaming cost. + Persist + 1 + Type + U32 + Value + 384 + + MeshMinimumByteSize + + Comment + Minimum number of bytes per LoD block when determining streaming cost. + Persist + 1 + Type + U32 + Value + 16 + + MeshBytesPerTriangle + + Comment + Approximation of bytes per triangle to use for determining mesh streaming cost. + Persist + 1 + Type + U32 + Value + 16 + + MeshMaxConcurrentRequests Comment @@ -12677,6 +12787,28 @@ Value 0 + TextureDisable + + Comment + If TRUE, do not load textures for in-world content + Persist + 1 + Type + Boolean + Value + 0 + + TextureDiscardLevel + + Comment + Specify texture resolution (0 = highest, 5 = lowest) + Persist + 1 + Type + U32 + Value + 0 + TextureLoadFullRes Comment @@ -13352,6 +13484,28 @@ Value 1 + InterpolationTime + + Comment + How long to extrapolate object motion after last packet received + Persist + 1 + Type + F32 + Value + 3 + + InterpolationPhaseOut + + Comment + Seconds to phase out interpolated motion + Persist + 1 + Type + F32 + Value + 1 + VerboseLogs Comment diff --git a/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl b/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl index 431c7f8e1..8a9c1f64c 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl @@ -5,7 +5,6 @@ * $License$ */ -#version 120 void default_lighting(); diff --git a/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl b/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl index 9057560e6..d11fd8d49 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + attribute vec4 weight; //1 diff --git a/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl b/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl index 7b36d03c3..1f69de175 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl @@ -5,7 +5,6 @@ * $License$ */ -#version 120 vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); mat4 getSkinnedTransform(); diff --git a/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl b/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl index cc49fe9f7..601e6cc5d 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl @@ -5,7 +5,6 @@ * $License$ */ -#version 120 void default_lighting(); diff --git a/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl b/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl index af9c28a6e..6f497acb7 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol); void calcAtmospherics(vec3 inPositionEye); diff --git a/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl b/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl index ef823c28b..7613e50dc 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + attribute vec4 object_weight; diff --git a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl index 0b9943479..0f5d17d7d 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl index 801a8e06d..fcea1baba 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + mat4 getSkinnedTransform(); diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 22cae7a34..bd07c51ca 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -1,17 +1,18 @@ /** * @file alphaF.glsl * - * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. - * $License$ + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable -uniform sampler2D diffuseMap; uniform sampler2DRect depthMap; +vec4 diffuseLookup(vec2 texcoord); + uniform mat4 shadow_matrix[6]; uniform vec4 shadow_clip; uniform vec2 screen_res; @@ -47,7 +48,7 @@ void main() vec4 pos = vec4(vary_position, 1.0); - vec4 diff= texture2D(diffuseMap, gl_TexCoord[0].xy); + vec4 diff= diffuseLookup(gl_TexCoord[0].xy); vec4 col = vec4(vary_ambient + vary_directional.rgb, gl_Color.a); vec4 color = diff * col; diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl new file mode 100644 index 000000000..b0d029dbf --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl @@ -0,0 +1,67 @@ +/** + * @file alphaF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +#extension GL_ARB_texture_rectangle : enable + +uniform sampler2DRect depthMap; +uniform sampler2D diffuseMap; + + +uniform mat4 shadow_matrix[6]; +uniform vec4 shadow_clip; +uniform vec2 screen_res; + +vec3 atmosLighting(vec3 light); +vec3 scaleSoftClip(vec3 light); + +varying vec3 vary_ambient; +varying vec3 vary_directional; +varying vec3 vary_fragcoord; +varying vec3 vary_position; +varying vec3 vary_pointlight_col; + +uniform mat4 inv_proj; + +vec4 getPosition(vec2 pos_screen) +{ + float depth = texture2DRect(depthMap, pos_screen.xy).a; + vec2 sc = pos_screen.xy*2.0; + sc /= screen_res; + sc -= vec2(1.0,1.0); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos /= pos.w; + pos.w = 1.0; + return pos; +} + +void main() +{ + vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; + frag *= screen_res; + + vec4 pos = vec4(vary_position, 1.0); + + vec4 diff= texture2D(diffuseMap,gl_TexCoord[0].xy); + + vec4 col = vec4(vary_ambient + vary_directional.rgb, gl_Color.a); + vec4 color = diff * col; + + color.rgb = atmosLighting(color.rgb); + + color.rgb = scaleSoftClip(color.rgb); + + color.rgb += diff.rgb * vary_pointlight_col.rgb; + + gl_FragColor = color; + //gl_FragColor = vec4(1,0,1,1); + //gl_FragColor = vec4(1,0,1,1)*shadow; + +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl index 65d920998..ac3f7189c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); mat4 getObjectSkinnedTransform(); diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl index d1c678f30..cb6414deb 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); void calcAtmospherics(vec3 inPositionEye); @@ -23,6 +23,7 @@ varying vec3 vary_fragcoord; varying vec3 vary_position; varying vec3 vary_light; varying vec3 vary_pointlight_col; +varying float vary_texture_index; uniform float near_clip; uniform float shadow_offset; @@ -35,20 +36,25 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa //get distance float d = length(lv); - - //normalize light vector - lv *= 1.0/d; - - //distance attenuation - float dist2 = d*d/(la*la); - float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - //angular attenuation - da *= calcDirectionalLight(n, lv); + float da = 0.0; + + if (d > 0.0 && la > 0.0 && fa > 0.0) + { + //normalize light vector + lv *= 1.0/d; + + //distance attenuation + float dist2 = d*d/(la*la); + da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); + + // spotlight coefficient. + float spot = max(dot(-ln, lv), is_pointlight); + da *= spot*spot; // GL_SPOT_EXPONENT=2 + + //angular attenuation + da *= calcDirectionalLight(n, lv); + } return da; } @@ -56,34 +62,35 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa void main() { //transform vertex - gl_Position = ftransform(); + vec4 vert = vec4(gl_Vertex.xyz, 1.0); + vary_texture_index = gl_Vertex.w; + gl_Position = gl_ModelViewProjectionMatrix * vert; gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; - vec4 pos = (gl_ModelViewMatrix * gl_Vertex); + vec4 pos = (gl_ModelViewMatrix * vert); vec3 norm = normalize(gl_NormalMatrix * gl_Normal); float dp_directional_light = max(0.0, dot(norm, gl_LightSource[0].position.xyz)); vary_position = pos.xyz + gl_LightSource[0].position.xyz * (1.0-dp_directional_light)*shadow_offset; - + calcAtmospherics(pos.xyz); //vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.)); - vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a); // Collect normal lights col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].quadraticAttenuation, gl_LightSource[2].specular.a); - col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].quadraticAttenuation, gl_LightSource[3].specular.a); + col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].quadraticAttenuation ,gl_LightSource[3].specular.a); col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].quadraticAttenuation, gl_LightSource[4].specular.a); col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].spotDirection.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].quadraticAttenuation, gl_LightSource[5].specular.a); col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].quadraticAttenuation, gl_LightSource[6].specular.a); col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].quadraticAttenuation, gl_LightSource[7].specular.a); - + vary_pointlight_col = col.rgb*gl_Color.rgb; - + col.rgb = vec3(0,0,0); - + // Add windlight lights col.rgb = atmosAmbient(vec3(0.)); @@ -98,7 +105,7 @@ void main() gl_FogFragCoord = pos.z; - pos = gl_ModelViewProjectionMatrix * gl_Vertex; + pos = gl_ModelViewProjectionMatrix * vert; vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl index 164322c3a..870d59331 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl index 5ae41cb73..c7a4f8672 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + mat4 getObjectSkinnedTransform(); diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl index 616990560..68e4055cf 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl @@ -1,11 +1,11 @@ /** * @file avatarAlphaV.glsl * - * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. - * $License$ + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ */ -#version 120 + vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); mat4 getSkinnedTransform(); @@ -35,19 +35,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa //get distance float d = length(lv); - //normalize light vector - lv *= 1.0/d; + float da = 0.0; + + if (d > 0.0 && la > 0.0 && fa > 0.0) + { + //normalize light vector + lv *= 1.0/d; - //distance attenuation - float dist2 = d*d/(la*la); - float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); + //distance attenuation + float dist2 = d*d/(la*la); + da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 + // spotlight coefficient. + float spot = max(dot(-ln, lv), is_pointlight); + da *= spot*spot; // GL_SPOT_EXPONENT=2 - //angular attenuation - da *= calcDirectionalLight(n, lv); + //angular attenuation + da *= calcDirectionalLight(n, lv); + } return da; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl index e2a36719c..b580a8f12 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl index 61574d0be..78986ab12 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl @@ -1,18 +1,21 @@ /** * @file avatarShadowF.glsl * - * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. - * $License$ + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ */ -#version 120 + uniform sampler2D diffuseMap; +varying vec4 post_pos; void main() { //gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy).a); gl_FragColor = vec4(1,1,1,1); + + gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl index 49ddd2b19..f177fcd8f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl @@ -1,16 +1,18 @@ /** * @file avatarShadowV.glsl * - * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. - * $License$ + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ */ -#version 120 + mat4 getSkinnedTransform(); attribute vec4 weight; +varying vec4 post_pos; + void main() { gl_TexCoord[0] = gl_MultiTexCoord0; @@ -30,8 +32,9 @@ void main() norm = normalize(norm); pos = gl_ProjectionMatrix * pos; - pos.z = max(pos.z, -pos.w+0.01); - gl_Position = pos; + post_pos = pos; + + gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); gl_FrontColor = gl_Color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl index 3465cef2b..d7b9418f8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + mat4 getSkinnedTransform(); diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl index d04bfb3ad..8c75c8045 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl @@ -1,11 +1,11 @@ /** * @file blurLightF.glsl * - * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. - * $License$ + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable @@ -26,7 +26,7 @@ uniform vec2 screen_res; vec4 getPosition(vec2 pos_screen) { - float depth = texture2DRect(depthMap, pos_screen.xy).a; + float depth = texture2DRect(depthMap, pos_screen.xy).r; vec2 sc = pos_screen.xy*2.0; sc /= screen_res; sc -= vec2(1.0,1.0); @@ -39,7 +39,7 @@ vec4 getPosition(vec2 pos_screen) void main() { - vec2 tc = vary_fragcoord.xy; + vec2 tc = vary_fragcoord.xy; vec3 norm = texture2DRect(normalMap, tc).xyz; norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm vec3 pos = getPosition(tc).xyz; @@ -55,8 +55,7 @@ void main() float pointplanedist_tolerance_pow2 = pos.z*pos.z*0.00005; // perturb sampling origin slightly in screen-space to hide edge-ghosting artifacts where smoothing radius is quite large - //This causes some pretty nasty artifacting, so disabling for now. - //tc += ( (mod(tc.x+tc.y,2) - 0.5) * kern[1].z * dlt * 0.5 ); + tc += ( (mod(tc.x+tc.y,2) - 0.5) * kern[1].z * dlt * 0.5 ); for (int i = 1; i < 4; i++) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl index 3f2d7d7b1..3999869f2 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + varying vec2 vary_fragcoord; uniform vec2 screen_res; diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl index 7a423f394..479976e55 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; uniform sampler2D bumpMap; diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl index d884f2e4a..dc69519a8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + varying vec3 vary_mat0; varying vec3 vary_mat1; diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl index c83f781e2..65ff4cbad 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + varying vec3 vary_mat0; varying vec3 vary_mat1; diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl new file mode 100644 index 000000000..ef300d563 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -0,0 +1,79 @@ +/** + * @file WLCloudsF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +///////////////////////////////////////////////////////////////////////// +// The fragment shader for the sky +///////////////////////////////////////////////////////////////////////// + +varying vec4 vary_CloudColorSun; +varying vec4 vary_CloudColorAmbient; +varying float vary_CloudDensity; + +uniform sampler2D cloud_noise_texture; +uniform vec4 cloud_pos_density1; +uniform vec4 cloud_pos_density2; +uniform vec4 gamma; + +/// Soft clips the light with a gamma correction +vec3 scaleSoftClip(vec3 light) { + //soft clip effect: + light = 1. - clamp(light, vec3(0.), vec3(1.)); + light = 1. - pow(light, gamma.xxx); + + return light; +} + +void main() +{ + // Set variables + vec2 uv1 = gl_TexCoord[0].xy; + vec2 uv2 = gl_TexCoord[1].xy; + + vec4 cloudColorSun = vary_CloudColorSun; + vec4 cloudColorAmbient = vary_CloudColorAmbient; + float cloudDensity = vary_CloudDensity; + vec2 uv3 = gl_TexCoord[2].xy; + vec2 uv4 = gl_TexCoord[3].xy; + + // Offset texture coords + uv1 += cloud_pos_density1.xy; //large texture, visible density + uv2 += cloud_pos_density1.xy; //large texture, self shadow + uv3 += cloud_pos_density2.xy; //small texture, visible density + uv4 += cloud_pos_density2.xy; //small texture, self shadow + + + // Compute alpha1, the main cloud opacity + float alpha1 = (texture2D(cloud_noise_texture, uv1).x - 0.5) + (texture2D(cloud_noise_texture, uv3).x - 0.5) * cloud_pos_density2.z; + alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10. * cloud_pos_density1.z, 1.); + + // And smooth + alpha1 = 1. - alpha1 * alpha1; + alpha1 = 1. - alpha1 * alpha1; + + + // Compute alpha2, for self shadowing effect + // (1 - alpha2) will later be used as percentage of incoming sunlight + float alpha2 = (texture2D(cloud_noise_texture, uv2).x - 0.5); + alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.); + + // And smooth + alpha2 = 1. - alpha2; + alpha2 = 1. - alpha2 * alpha2; + + // Combine + vec4 color; + color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient); + color *= 2.; + + /// Gamma correct for WL (soft clip effect). + gl_FragData[0] = vec4(scaleSoftClip(color.rgb), alpha1); + gl_FragData[1] = vec4(0.0,0.0,0.0,0.0); + gl_FragData[2] = vec4(0,0,1,0); +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl new file mode 100644 index 000000000..3eac63076 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl @@ -0,0 +1,165 @@ +/** + * @file WLCloudsV.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +////////////////////////////////////////////////////////////////////////// +// The vertex shader for creating the atmospheric sky +/////////////////////////////////////////////////////////////////////////////// + +// Output parameters +varying vec4 vary_CloudColorSun; +varying vec4 vary_CloudColorAmbient; +varying float vary_CloudDensity; + +// Inputs +uniform vec3 camPosLocal; + +uniform vec4 lightnorm; +uniform vec4 sunlight_color; +uniform vec4 ambient; +uniform vec4 blue_horizon; +uniform vec4 blue_density; +uniform vec4 haze_horizon; +uniform vec4 haze_density; + +uniform vec4 cloud_shadow; +uniform vec4 density_multiplier; +uniform vec4 max_y; + +uniform vec4 glow; + +uniform vec4 cloud_color; + +uniform vec4 cloud_scale; + +void main() +{ + + // World / view / projection + gl_Position = ftransform(); + + gl_TexCoord[0] = gl_MultiTexCoord0; + + // Get relative position + vec3 P = gl_Vertex.xyz - camPosLocal.xyz + vec3(0,50,0); + + // Set altitude + if (P.y > 0.) + { + P *= (max_y.x / P.y); + } + else + { + P *= (-32000. / P.y); + } + + // Can normalize then + vec3 Pn = normalize(P); + float Plen = length(P); + + // Initialize temp variables + vec4 temp1 = vec4(0.); + vec4 temp2 = vec4(0.); + vec4 blue_weight; + vec4 haze_weight; + vec4 sunlight = sunlight_color; + vec4 light_atten; + + + // Sunlight attenuation effect (hue and brightness) due to atmosphere + // this is used later for sunlight modulation at various altitudes + light_atten = (blue_density * 1.0 + haze_density.x * 0.25) * (density_multiplier.x * max_y.x); + + // Calculate relative weights + temp1 = blue_density + haze_density.x; + blue_weight = blue_density / temp1; + haze_weight = haze_density.x / temp1; + + // Compute sunlight from P & lightnorm (for long rays like sky) + temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y ); + temp2.y = 1. / temp2.y; + sunlight *= exp( - light_atten * temp2.y); + + // Distance + temp2.z = Plen * density_multiplier.x; + + // Transparency (-> temp1) + // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z); + + + // Compute haze glow + temp2.x = dot(Pn, lightnorm.xyz); + temp2.x = 1. - temp2.x; + // temp2.x is 0 at the sun and increases away from sun + temp2.x = max(temp2.x, .001); + // Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.x *= glow.x; + // Higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.x = pow(temp2.x, glow.z); + // glow.z should be negative, so we're doing a sort of (1 / "angle") function + + // Add "minimum anti-solar illumination" + temp2.x += .25; + + // Increase ambient when there are more clouds + vec4 tmpAmbient = ambient; + tmpAmbient += (1. - tmpAmbient) * cloud_shadow.x * 0.5; + + // Dim sunlight by cloud shadow percentage + sunlight *= (1. - cloud_shadow.x); + + // Haze color below cloud + vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient) + + (haze_horizon.r * haze_weight) * (sunlight * temp2.x + tmpAmbient) + ); + + // CLOUDS + + sunlight = sunlight_color; + temp2.y = max(0., lightnorm.y * 2.); + temp2.y = 1. / temp2.y; + sunlight *= exp( - light_atten * temp2.y); + + // Cloud color out + vary_CloudColorSun = (sunlight * temp2.x) * cloud_color; + vary_CloudColorAmbient = tmpAmbient * cloud_color; + + // Attenuate cloud color by atmosphere + temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds + vary_CloudColorSun *= temp1; + vary_CloudColorAmbient *= temp1; + vec4 oHazeColorBelowCloud = additiveColorBelowCloud * (1. - temp1); + + // Make a nice cloud density based on the cloud_shadow value that was passed in. + vary_CloudDensity = 2. * (cloud_shadow.x - 0.25); + + + // Texture coords + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_TexCoord[0].xy -= 0.5; + gl_TexCoord[0].xy /= cloud_scale.x; + gl_TexCoord[0].xy += 0.5; + + gl_TexCoord[1] = gl_TexCoord[0]; + gl_TexCoord[1].x += lightnorm.x * 0.0125; + gl_TexCoord[1].y += lightnorm.z * 0.0125; + + gl_TexCoord[2] = gl_TexCoord[0] * 16.; + gl_TexCoord[3] = gl_TexCoord[1] * 16.; + + // Combine these to minimize register use + vary_CloudColorAmbient += oHazeColorBelowCloud; + + // needs this to compile on mac + //vary_AtmosAttenuation = vec3(0.0,0.0,0.0); + + // END CLOUDS +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl new file mode 100644 index 000000000..338d0ebb2 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl @@ -0,0 +1,30 @@ +/** + * @file diffuseF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + +uniform float minimum_alpha; +uniform float maximum_alpha; + +uniform sampler2D diffuseMap; + +varying vec3 vary_normal; + +void main() +{ + vec4 col = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy) * gl_Color; + + if (col.a < minimum_alpha || col.a > maximum_alpha) + { + discard; + } + + gl_FragData[0] = vec4(col.rgb, 0.0); + gl_FragData[1] = vec4(0,0,0,0); // spec + vec3 nvn = normalize(vary_normal); + gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0); +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl new file mode 100644 index 000000000..0671cb94b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl @@ -0,0 +1,26 @@ +/** + * @file diffuseAlphaMaskIndexedF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +varying vec3 vary_normal; + +uniform float minimum_alpha; +uniform float maximum_alpha; + +void main() +{ + vec4 col = diffuseLookup(gl_TexCoord[0].xy) * gl_Color; + + if (col.a < minimum_alpha || col.a > maximum_alpha) + { + discard; + } + + gl_FragData[0] = vec4(col.rgb, 0.0); + gl_FragData[1] = vec4(0,0,0,0); + vec3 nvn = normalize(vary_normal); + gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0); +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl index 451195f97..e1d5d5062 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl new file mode 100644 index 000000000..e7b5dcce7 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl @@ -0,0 +1,19 @@ +/** + * @file diffuseIndexedF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +varying vec3 vary_normal; + +void main() +{ + vec3 col = gl_Color.rgb * diffuseLookup(gl_TexCoord[0].xy).rgb; + + gl_FragData[0] = vec4(col, 0.0); + gl_FragData[1] = gl_Color.aaaa; // spec + //gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a); // spec - from former class3 - maybe better, but not so well tested + vec3 nvn = normalize(vary_normal); + gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0); +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl index 9a45c0323..2c4caea10 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + varying vec3 vary_normal; diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl index af0314a75..3154b5431 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl @@ -5,16 +5,18 @@ * $/LicenseInfo$ */ -#version 120 + varying vec3 vary_normal; +varying float vary_texture_index; void main() { //transform vertex - gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xyz, 1.0); gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + vary_texture_index = gl_Vertex.w; vary_normal = normalize(gl_NormalMatrix * gl_Normal); gl_FrontColor = gl_Color; diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 342987739..d781e0854 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -5,60 +5,24 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable -uniform sampler2D diffuseMap; -uniform sampler2DRect depthMap; -uniform sampler2D noiseMap; - -uniform vec4 shadow_clip; -uniform vec2 screen_res; - vec3 fullbrightAtmosTransport(vec3 light); vec3 fullbrightScaleSoftClip(vec3 light); -varying vec3 vary_ambient; -varying vec3 vary_directional; -varying vec4 vary_position; -varying vec3 vary_normal; -varying vec3 vary_fragcoord; - -uniform mat4 inv_proj; - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).a; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} void main() { - vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; - frag *= screen_res; - - vec3 samp_pos = getPosition(frag).xyz; - float shadow = 1.0; - vec4 pos = vary_position; - vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy)*gl_Color; + vec4 color = diffuseLookup(gl_TexCoord[0].xy)*gl_Color; color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = fullbrightScaleSoftClip(color.rgb); - //gl_FragColor = gl_Color; gl_FragColor = color; - //gl_FragColor = vec4(1,0,1,1); - } diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl index 94f653541..800cfed64 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void calcAtmospherics(vec3 inPositionEye); @@ -14,30 +14,23 @@ vec3 atmosAffectDirectionalLight(float lightIntensity); vec3 scaleDownLight(vec3 light); vec3 scaleUpLight(vec3 light); -varying vec3 vary_ambient; -varying vec3 vary_directional; -varying vec3 vary_normal; -varying vec3 vary_fragcoord; -uniform float near_clip; -varying vec4 vary_position; +varying float vary_texture_index; void main() { //transform vertex - gl_Position = ftransform(); + vec4 vert = vec4(gl_Vertex.xyz, 1.0); + vary_texture_index = gl_Vertex.w; + + gl_Position = gl_ModelViewProjectionMatrix*vert; gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; - vec4 pos = (gl_ModelViewMatrix * gl_Vertex); - vary_position = pos; - + vec4 pos = (gl_ModelViewMatrix * vert); + calcAtmospherics(pos.xyz); gl_FrontColor = gl_Color; gl_FogFragCoord = pos.z; - - pos = gl_ModelViewProjectionMatrix * gl_Vertex; - vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); - } diff --git a/indra/newview/app_settings/shaders/class1/deferred/giF.glsl b/indra/newview/app_settings/shaders/class1/deferred/giF.glsl index 75b555e8a..41c149e77 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/giF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/giF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable diff --git a/indra/newview/app_settings/shaders/class1/deferred/giV.glsl b/indra/newview/app_settings/shaders/class1/deferred/giV.glsl index 8dc1410ea..e86f2896d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/giV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/giV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + varying vec2 vary_fragcoord; diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl index 6b3bfcf2a..d60333893 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl @@ -5,7 +5,8 @@ * $License$ */ -#version 120 +uniform float minimum_alpha; +uniform float maximum_alpha; uniform sampler2D diffuseMap; uniform sampler2D normalMap; @@ -14,6 +15,10 @@ uniform sampler2D specularMap; void main() { vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy); + if (col.a < minimum_alpha || col.a > maximum_alpha) + { + discard; + } gl_FragData[0] = vec4(col.rgb, col.a * 0.005); gl_FragData[1] = texture2D(specularMap, gl_TexCoord[0].xy); gl_FragData[2] = vec4(texture2D(normalMap, gl_TexCoord[0].xy).xyz, 0.0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl index d90c4478c..a209f95f5 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void main() { diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl index 78df54d5d..25e93ae26 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + uniform sampler2DRect diffuseMap; diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl index 0c820bfc6..4baf1fc65 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + varying vec2 vary_fragcoord; diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl index 89e258887..3c5c780d9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl @@ -1,11 +1,11 @@ /** * @file multiPointLightF.glsl * - * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. - * $License$ + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable @@ -36,7 +36,7 @@ uniform mat4 inv_proj; vec4 getPosition(vec2 pos_screen) { - float depth = texture2DRect(depthMap, pos_screen.xy).a; + float depth = texture2DRect(depthMap, pos_screen.xy).r; vec2 sc = pos_screen.xy*2.0; sc /= screen_res; sc -= vec2(1.0,1.0); @@ -123,4 +123,6 @@ void main() gl_FragColor.rgb = out_col; gl_FragColor.a = 0.0; + + //gl_FragColor = vec4(0.1, 0.025, 0.025/4.0, 0.0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl index 2e3e84dd1..434fb6f53 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + varying vec4 vary_fragcoord; diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl index a9f03f761..0d25d7792 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + //class 1 -- no shadows diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 22ed9dcd4..5efa3200d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ - #version 120 + #extension GL_ARB_texture_rectangle : enable @@ -30,7 +30,7 @@ uniform vec4 viewport; vec4 getPosition(vec2 pos_screen) { - float depth = texture2DRect(depthMap, pos_screen.xy).a; + float depth = texture2DRect(depthMap, pos_screen.xy).r; vec2 sc = (pos_screen.xy-viewport.xy)*2.0; sc /= viewport.zw; sc -= vec2(1.0,1.0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl index 1a426dddf..756843b8b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl @@ -5,19 +5,14 @@ * $License$ */ -#version 120 + varying vec4 vary_light; varying vec4 vary_fragcoord; -uniform vec2 screen_res; -uniform float near_clip; - void main() { //transform vertex - gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; - vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; vary_fragcoord = pos; @@ -25,6 +20,8 @@ void main() tex.w = 1.0; vary_light = gl_MultiTexCoord0; + + gl_Position = pos; gl_FrontColor = gl_Color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl index 77f1b2224..f6b0402bb 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable @@ -29,7 +29,7 @@ varying vec2 vary_fragcoord; float getDepth(vec2 pos_screen) { - float z = texture2DRect(depthMap, pos_screen.xy).a; + float z = texture2DRect(depthMap, pos_screen.xy).r; z = z*2.0-1.0; vec4 ndc = vec4(0.0, 0.0, z, 1.0); vec4 p = inv_proj*ndc; diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl index ab48d08bb..bf829bfc5 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl index 12983baa9..876f65ee3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + varying vec2 vary_fragcoord; uniform vec2 screen_res; diff --git a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl index 63b3c9f20..fa3f04bcc 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + uniform sampler2DRect depthMap; uniform sampler2DRect normalMap; diff --git a/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl index ae57227fe..eebe93066 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + varying vec2 vary_fragcoord; uniform vec2 screen_res; diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl new file mode 100644 index 000000000..e24d0b666 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl @@ -0,0 +1,27 @@ +/** + * @file shadowAlphaMaskF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform float minimum_alpha; +uniform float maximum_alpha; + +uniform sampler2D diffuseMap; + +varying vec4 post_pos; + +void main() +{ + float alpha = texture2D(diffuseMap, gl_TexCoord[0].xy).a * gl_Color.a; + + if (alpha < minimum_alpha || alpha > maximum_alpha) + { + discard; + } + + gl_FragColor = vec4(1,1,1,1); + + gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl new file mode 100644 index 000000000..58e9bcec5 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl @@ -0,0 +1,23 @@ +/** + * @file shadowAlphaMaskV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +varying vec4 post_pos; + +void main() +{ + //transform vertex + vec4 pos = gl_ModelViewProjectionMatrix*gl_Vertex; + + post_pos = pos; + + gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); + + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + gl_FrontColor = gl_Color; +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl index 4d85bbf62..9d1122080 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl @@ -5,15 +5,13 @@ * $License$ */ -#version 120 -uniform sampler2D diffuseMap; varying vec4 post_pos; void main() { - gl_FragColor = vec4(1,1,1,texture2D(diffuseMap, gl_TexCoord[0].xy).a * gl_Color.a); + gl_FragColor = vec4(1,1,1,1); gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl index 9baa39814..a5d4f91c1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + varying vec4 post_pos; @@ -17,7 +17,4 @@ void main() post_pos = pos; gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); - - gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; - gl_FrontColor = gl_Color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl new file mode 100644 index 000000000..820c82ffd --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl @@ -0,0 +1,44 @@ +/** + * @file WLSkyF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +///////////////////////////////////////////////////////////////////////// +// The fragment shader for the sky +///////////////////////////////////////////////////////////////////////// + +varying vec4 vary_HazeColor; + +uniform sampler2D cloud_noise_texture; +uniform vec4 gamma; + +/// Soft clips the light with a gamma correction +vec3 scaleSoftClip(vec3 light) { + //soft clip effect: + light = 1. - clamp(light, vec3(0.), vec3(1.)); + light = 1. - pow(light, gamma.xxx); + + return light; +} + +void main() +{ + // Potential Fill-rate optimization. Add cloud calculation + // back in and output alpha of 0 (so that alpha culling kills + // the fragment) if the sky wouldn't show up because the clouds + // are fully opaque. + + vec4 color; + color = vary_HazeColor; + color *= 2.; + + /// Gamma correct for WL (soft clip effect). + gl_FragData[0] = vec4(scaleSoftClip(color.rgb), 1.0); + gl_FragData[1] = vec4(0.0,0.0,0.0,0.0); + gl_FragData[2] = vec4(0,0,1,0); +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl new file mode 100644 index 000000000..1ea00f723 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -0,0 +1,140 @@ +/** + * @file WLSkyV.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +// SKY //////////////////////////////////////////////////////////////////////// +// The vertex shader for creating the atmospheric sky +/////////////////////////////////////////////////////////////////////////////// + +// Output parameters +varying vec4 vary_HazeColor; + +// Inputs +uniform vec3 camPosLocal; + +uniform vec4 lightnorm; +uniform vec4 sunlight_color; +uniform vec4 ambient; +uniform vec4 blue_horizon; +uniform vec4 blue_density; +uniform vec4 haze_horizon; +uniform vec4 haze_density; + +uniform vec4 cloud_shadow; +uniform vec4 density_multiplier; +uniform vec4 max_y; + +uniform vec4 glow; + +uniform vec4 cloud_color; + +uniform vec4 cloud_scale; + +void main() +{ + + // World / view / projection + gl_Position = ftransform(); + gl_TexCoord[0] = gl_MultiTexCoord0; + + // Get relative position + vec3 P = gl_Vertex.xyz - camPosLocal.xyz + vec3(0,50,0); + //vec3 P = gl_Vertex.xyz + vec3(0,50,0); + + // Set altitude + if (P.y > 0.) + { + P *= (max_y.x / P.y); + } + else + { + P *= (-32000. / P.y); + } + + // Can normalize then + vec3 Pn = normalize(P); + float Plen = length(P); + + // Initialize temp variables + vec4 temp1 = vec4(0.); + vec4 temp2 = vec4(0.); + vec4 blue_weight; + vec4 haze_weight; + vec4 sunlight = sunlight_color; + vec4 light_atten; + + + // Sunlight attenuation effect (hue and brightness) due to atmosphere + // this is used later for sunlight modulation at various altitudes + light_atten = (blue_density * 1.0 + haze_density.x * 0.25) * (density_multiplier.x * max_y.x); + + // Calculate relative weights + temp1 = blue_density + haze_density.x; + blue_weight = blue_density / temp1; + haze_weight = haze_density.x / temp1; + + // Compute sunlight from P & lightnorm (for long rays like sky) + temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y ); + temp2.y = 1. / temp2.y; + sunlight *= exp( - light_atten * temp2.y); + + // Distance + temp2.z = Plen * density_multiplier.x; + + // Transparency (-> temp1) + // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z); + + + // Compute haze glow + temp2.x = dot(Pn, lightnorm.xyz); + temp2.x = 1. - temp2.x; + // temp2.x is 0 at the sun and increases away from sun + temp2.x = max(temp2.x, .001); + // Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.x *= glow.x; + // Higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.x = pow(temp2.x, glow.z); + // glow.z should be negative, so we're doing a sort of (1 / "angle") function + + // Add "minimum anti-solar illumination" + temp2.x += .25; + + + // Haze color above cloud + vary_HazeColor = ( blue_horizon * blue_weight * (sunlight + ambient) + + (haze_horizon.r * haze_weight) * (sunlight * temp2.x + ambient) + ); + + + // Increase ambient when there are more clouds + vec4 tmpAmbient = ambient; + tmpAmbient += (1. - tmpAmbient) * cloud_shadow.x * 0.5; + + // Dim sunlight by cloud shadow percentage + sunlight *= (1. - cloud_shadow.x); + + // Haze color below cloud + vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient) + + (haze_horizon.r * haze_weight) * (sunlight * temp2.x + tmpAmbient) + ); + + // Final atmosphere additive + vary_HazeColor *= (1. - temp1); + + // Attenuate cloud color by atmosphere + temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds + + // At horizon, blend high altitude sky color towards the darker color below the clouds + vary_HazeColor += (additiveColorBelowCloud - vary_HazeColor) * (1. - sqrt(temp1)); + + // won't compile on mac without this being set + //vary_AtmosAttenuation = vec3(0.0,0.0,0.0); +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index cffab338d..d327216a0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -1,19 +1,22 @@ /** * @file softenLightF.glsl * - * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. - * $License$ + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable uniform sampler2DRect diffuseRect; uniform sampler2DRect specularRect; +uniform sampler2DRect positionMap; uniform sampler2DRect normalMap; uniform sampler2DRect lightMap; uniform sampler2DRect depthMap; +uniform sampler2D noiseMap; +uniform samplerCube environmentMap; uniform sampler2D lightFunc; uniform float blur_size; @@ -256,7 +259,7 @@ vec3 scaleSoftClip(vec3 light) void main() { vec2 tc = vary_fragcoord.xy; - float depth = texture2DRect(depthMap, tc.xy).a; + float depth = texture2DRect(depthMap, tc.xy).r; vec3 pos = getPosition_d(tc, depth).xyz; vec3 norm = texture2DRect(normalMap, tc).xyz; norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm @@ -267,74 +270,41 @@ void main() vec4 diffuse = texture2DRect(diffuseRect, tc); vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); - vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; - float scol = max(scol_ambocc.r, diffuse.a); - float ambocc = scol_ambocc.g; - - calcAtmospherics(pos.xyz, ambocc); - - vec3 col = atmosAmbient(vec3(0)); - col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a)); - col *= diffuse.rgb; - - if (spec.a > 0.0) // specular reflection + vec3 col; + float bloom = 0.0; + if (diffuse.a < 0.9) { - // the old infinite-sky shiny reflection - // - vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - float sa = dot(refnormpersp, vary_light.xyz); - vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a; - /* - // screen-space cheap fakey reflection map - // - vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz)); - depth -= 0.5; // unbias depth - // first figure out where we'll make our 2D guess from - vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth; - // Offset the guess source a little according to a trivial - // checkerboard dither function and spec.a. - // This is meant to be similar to sampling a blurred version - // of the diffuse map. LOD would be better in that regard. - // The goal of the blur is to soften reflections in surfaces - // with low shinyness, and also to disguise our lameness. - float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0 - float checkoffset = (3.0 + (7.0*(1.0-spec.a)))*(checkerboard-0.5); - ref2d += vec2(checkoffset, checkoffset); - ref2d += tc.xy; // use as offset from destination - // Get attributes from the 2D guess point. - // We average two samples of diffuse (not of anything else) per - // pixel to try to reduce aliasing some more. - vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d + vec2(0.0, -checkoffset)).rgb + - texture2DRect(diffuseRect, ref2d + vec2(-checkoffset, 0.0)).rgb); - float refdepth = texture2DRect(depthMap, ref2d).a; - vec3 refpos = getPosition_d(ref2d, refdepth).xyz; - vec3 refn = texture2DRect(normalMap, ref2d).rgb; - refn = normalize(vec3((refn.xy-0.5)*2.0,refn.z)); // unpack norm - // figure out how appropriate our guess actually was - float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos))); - // darken reflections from points which face away from the reflected ray - our guess was a back-face - //refapprop *= step(dot(refnorm, refn), 0.0); - refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant - // get appropriate light strength for guess-point. - // reflect light direction to increase the illusion that - // these are reflections. - vec3 reflight = reflect(lightnorm.xyz, norm.xyz); - float reflit = max(dot(refn, reflight.xyz), 0.0); - // apply sun color to guess-point, dampen according to inappropriateness of guess - float refmod = min(refapprop, reflit); - vec3 refprod = vary_SunlitColor * refcol.rgb * refmod; - vec3 ssshiny = (refprod * spec.a); - ssshiny *= 0.3; // dampen it even more - */ - vec3 ssshiny = vec3(0,0,0); - - // add the two types of shiny together - col += (ssshiny + dumbshiny) * spec.rgb; - } + calcAtmospherics(pos.xyz, 1.0); - col = atmosLighting(col); - col = scaleSoftClip(col); - + col = atmosAmbient(vec3(0)); + col += atmosAffectDirectionalLight(max(min(da, 1.0), diffuse.a)); + + col *= diffuse.rgb; + + if (spec.a > 0.0) // specular reflection + { + // the old infinite-sky shiny reflection + // + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); + float sa = dot(refnormpersp, vary_light.xyz); + vec3 dumbshiny = vary_SunlitColor*texture2D(lightFunc, vec2(sa, spec.a)).a; + + // add the two types of shiny together + vec3 spec_contrib = dumbshiny * spec.rgb; + bloom = dot(spec_contrib, spec_contrib); + col += spec_contrib; + } + + col = atmosLighting(col); + col = scaleSoftClip(col); + + col = mix(col.rgb, diffuse.rgb, diffuse.a); + } + else + { + col = diffuse.rgb; + } + gl_FragColor.rgb = col; - gl_FragColor.a = 0.0; + gl_FragColor.a = bloom; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightNoSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightNoSSAOF.glsl index bca692cab..c438fd3d9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightNoSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightNoSSAOF.glsl @@ -5,7 +5,6 @@ * $License$ */ -#version 120 #extension GL_ARB_texture_rectangle : enable diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl index 3bc94e70d..1abdc943b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform vec2 screen_res; diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl index 29fac46bf..9aaffc15b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl new file mode 100644 index 000000000..2cf7d194c --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -0,0 +1,19 @@ +/** + * @file starsF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +uniform sampler2D diffuseMap; + +void main() +{ + vec4 col = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy); + + gl_FragData[0] = col; + gl_FragData[1] = vec4(0,0,0,0); + gl_FragData[2] = vec4(0,0,1,0); +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl new file mode 100644 index 000000000..c43125dad --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl @@ -0,0 +1,17 @@ +/** + * @file starsV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + + +void main() +{ + //transform vertex + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + gl_FrontColor = gl_Color; +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl index 5db627ab1..686b6eb3d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + //class 1, no shadow, no SSAO, should never be called diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl index cd91351ad..665d8126a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable @@ -35,7 +35,7 @@ uniform float shadow_offset; vec4 getPosition(vec2 pos_screen) { - float depth = texture2DRect(depthMap, pos_screen.xy).a; + float depth = texture2DRect(depthMap, pos_screen.xy).r; vec2 sc = pos_screen.xy*2.0; sc /= screen_res; sc -= vec2(1.0,1.0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl index 9aef0a6bb..703a5ee4c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + varying vec4 vary_light; varying vec2 vary_fragcoord; diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl index 0a3fae592..eba9eb651 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D detail_0; uniform sampler2D detail_1; diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl index 06507f456..4b3f81bfb 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + varying vec3 vary_normal; diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl index 123520190..3b869efd4 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl index d1500393b..448dccdf6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + varying vec3 vary_normal; diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index 606e44eae..9271160fd 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl index 2be8d4286..31c7710df 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void calcAtmospherics(vec3 inPositionEye); diff --git a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl index 61e5ba0d9..76c3cb7f8 100644 --- a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl +++ b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable diff --git a/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl b/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl index fd5300a1f..9e74df765 100644 --- a/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl +++ b/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void main() { diff --git a/indra/newview/app_settings/shaders/class1/effects/glowF.glsl b/indra/newview/app_settings/shaders/class1/effects/glowF.glsl index 85e5675ac..b27434d5b 100644 --- a/indra/newview/app_settings/shaders/class1/effects/glowF.glsl +++ b/indra/newview/app_settings/shaders/class1/effects/glowF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; uniform float glowStrength; diff --git a/indra/newview/app_settings/shaders/class1/effects/glowV.glsl b/indra/newview/app_settings/shaders/class1/effects/glowV.glsl index 744eff196..71ef6666e 100644 --- a/indra/newview/app_settings/shaders/class1/effects/glowV.glsl +++ b/indra/newview/app_settings/shaders/class1/effects/glowV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform vec2 glowDelta; diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl index 51b3cdd99..276cfe06c 100644 --- a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D detail0; uniform sampler2D detail1; diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl index fc4cb14c4..6f7e9c65b 100644 --- a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl index 7db3133f6..c4f132a2e 100644 --- a/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + // this class1 shader is just a copy of terrainF diff --git a/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl index 6f65b0179..46cf6669a 100644 --- a/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; uniform sampler2D bumpMap; diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl index 89217484f..30f43cb84 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + vec3 scaleSoftClip(vec3 inColor); vec3 atmosTransport(vec3 inColor); diff --git a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl index 94296e0ba..35265edac 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + vec4 applyWaterFog(vec4 color) { diff --git a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl index 4dae985a7..293efc106 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void calcAtmospherics(vec3 inPositionEye); diff --git a/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl b/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl new file mode 100644 index 000000000..3827c72f4 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl @@ -0,0 +1,17 @@ +/** + * @file customalphaF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform sampler2D diffuseMap; + +uniform float custom_alpha; + +void main() +{ + vec4 color = gl_Color*texture2D(diffuseMap, gl_TexCoord[0].xy); + color.a *= custom_alpha; + gl_FragColor = color; +} diff --git a/indra/newview/app_settings/shaders/class1/interface/customalphaV.glsl b/indra/newview/app_settings/shaders/class1/interface/customalphaV.glsl new file mode 100644 index 000000000..04bfff22c --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/customalphaV.glsl @@ -0,0 +1,16 @@ +/** + * @file customalphaV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_FrontColor = gl_Color; +} + diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl new file mode 100644 index 000000000..a60fb1eaa --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl @@ -0,0 +1,17 @@ +/** + * @file glowcombineF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +#extension GL_ARB_texture_rectangle : enable + +uniform sampler2D glowMap; +uniform sampler2DRect screenMap; + +void main() +{ + gl_FragColor = texture2D(glowMap, gl_TexCoord[0].xy) + + texture2DRect(screenMap, gl_TexCoord[1].xy); +} diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl new file mode 100644 index 000000000..ce183ec15 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl @@ -0,0 +1,15 @@ +/** + * @file glowcombineV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_TexCoord[1] = gl_MultiTexCoord1; +} + diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl index 5e4c123a8..bf2996a32 100644 --- a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl index 4c052a35a..75cc00b12 100644 --- a/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void main() { diff --git a/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl b/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl new file mode 100644 index 000000000..b140712f1 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl @@ -0,0 +1,11 @@ +/** + * @file occlusionF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +void main() +{ + gl_FragColor = vec4(1,1,1,1); +} diff --git a/indra/newview/app_settings/shaders/class1/interface/occlusionV.glsl b/indra/newview/app_settings/shaders/class1/interface/occlusionV.glsl new file mode 100644 index 000000000..5a5d0ec50 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/occlusionV.glsl @@ -0,0 +1,12 @@ +/** + * @file uiV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; +} + diff --git a/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl b/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl new file mode 100644 index 000000000..5b7cc5757 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl @@ -0,0 +1,15 @@ +/** + * @file twotextureaddF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform sampler2D tex0; + +void main() +{ + float alpha = texture2D(tex0, gl_TexCoord[0].xy).a * gl_Color.a; + + gl_FragColor = vec4(gl_Color.rgb, alpha); +} diff --git a/indra/newview/app_settings/shaders/class1/interface/solidcolorV.glsl b/indra/newview/app_settings/shaders/class1/interface/solidcolorV.glsl new file mode 100644 index 000000000..8401208e2 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/solidcolorV.glsl @@ -0,0 +1,16 @@ +/** + * @file solidcolorV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_FrontColor = gl_Color; + gl_TexCoord[0] = gl_MultiTexCoord0; +} + diff --git a/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl b/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl new file mode 100644 index 000000000..d81b56fdb --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl @@ -0,0 +1,14 @@ +/** + * @file twotextureaddF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform sampler2D tex0; +uniform sampler2D tex1; + +void main() +{ + gl_FragColor = texture2D(tex0, gl_TexCoord[0].xy)+texture2D(tex1, gl_TexCoord[1].xy); +} diff --git a/indra/newview/app_settings/shaders/class1/interface/twotextureaddV.glsl b/indra/newview/app_settings/shaders/class1/interface/twotextureaddV.glsl new file mode 100644 index 000000000..f685b112b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/twotextureaddV.glsl @@ -0,0 +1,16 @@ +/** + * @file twotextureaddV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_TexCoord[1] = gl_MultiTexCoord1; +} + diff --git a/indra/newview/app_settings/shaders/class1/interface/uiF.glsl b/indra/newview/app_settings/shaders/class1/interface/uiF.glsl new file mode 100644 index 000000000..9dec7a56b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/uiF.glsl @@ -0,0 +1,13 @@ +/** + * @file uiF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform sampler2D diffuseMap; + +void main() +{ + gl_FragColor = gl_Color*texture2D(diffuseMap, gl_TexCoord[0].xy); +} diff --git a/indra/newview/app_settings/shaders/class1/interface/uiV.glsl b/indra/newview/app_settings/shaders/class1/interface/uiV.glsl new file mode 100644 index 000000000..9ca6cae5c --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/uiV.glsl @@ -0,0 +1,16 @@ +/** + * @file uiV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_FrontColor = gl_Color; +} + diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl index 65a87b5f6..a524bacfb 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl index 7bfea160e..a913504fa 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl index 32f52fbe8..2e43117f6 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl index 1bdaccf9b..19072cd05 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl @@ -6,7 +6,7 @@ */ -#version 120 + uniform sampler2D diffuseMap; uniform samplerCube environmentMap; diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl index 89afa0ab2..a45b19a28 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl @@ -6,7 +6,7 @@ */ -#version 120 + uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncSpecularV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncSpecularV.glsl index 4ce4bc0cb..c248a9a69 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncSpecularV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncSpecularV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + float calcDirectionalLight(vec3 n, vec3 l) { diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl index a437d075a..542161032 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + float calcDirectionalLight(vec3 n, vec3 l) diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl index 28dabb494..2410dbd2c 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl index 7985c17e0..501534f04 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightSpecularV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightSpecularV.glsl index fddba5cff..42cbcbcef 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightSpecularV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightSpecularV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + float calcDirectionalLight(vec3 n, vec3 l); diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl index 8c01f3dd5..ba90c4277 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + float calcDirectionalLight(vec3 n, vec3 l); diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl index 97506312a..3c5b82128 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class1/lighting/sumLightsSpecularV.glsl b/indra/newview/app_settings/shaders/class1/lighting/sumLightsSpecularV.glsl index 4146b8121..c97db7393 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/sumLightsSpecularV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/sumLightsSpecularV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + float calcDirectionalLightSpecular(inout vec4 specular, vec3 view, vec3 n, vec3 l, vec3 lightCol, float da); vec3 atmosAmbient(vec3 light); diff --git a/indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl index df198eafc..30741d6f7 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + float calcDirectionalLight(vec3 n, vec3 l); diff --git a/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl b/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl new file mode 100644 index 000000000..587ab93a8 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl @@ -0,0 +1,17 @@ +/** + * @file bumpF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform sampler2D texture0; +uniform sampler2D texture1; + +void main() +{ + float tex0 = texture2D(texture0, gl_TexCoord[0].xy).a; + float tex1 = texture2D(texture1, gl_TexCoord[1].xy).a; + + gl_FragColor = vec4(tex0+(1.0-tex1)-0.5); +} diff --git a/indra/newview/app_settings/shaders/class1/objects/bumpV.glsl b/indra/newview/app_settings/shaders/class1/objects/bumpV.glsl new file mode 100644 index 000000000..056d1a958 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/bumpV.glsl @@ -0,0 +1,16 @@ +/** + * @file bumpV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + +void main() +{ + //transform vertex + gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex; + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + gl_TexCoord[1] = gl_TextureMatrix[1] * gl_MultiTexCoord1; + gl_FrontColor = gl_Color; +} diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl index 028b51cbb..77029c2d3 100755 --- a/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void fullbright_lighting(); diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyF.glsl index b474ac55d..ede6b5041 100644 --- a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void fullbright_shiny_lighting(); diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinySkinnedV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinySkinnedV.glsl index f0baeeeee..5283e8040 100644 --- a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinySkinnedV.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinySkinnedV.glsl @@ -5,13 +5,11 @@ * $License$ */ -#version 120 + void calcAtmospherics(vec3 inPositionEye); mat4 getObjectSkinnedTransform(); -attribute vec4 object_weight; - void main() { mat4 mat = getObjectSkinnedTransform(); diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyV.glsl index 75b841a5f..01020743e 100755 --- a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyV.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void calcAtmospherics(vec3 inPositionEye); diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyWaterF.glsl index 5daf66fb3..8ffb252f5 100644 --- a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyWaterF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void fullbright_shiny_lighting_water(); diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightSkinnedV.glsl index 02ff3cc2a..1db79791d 100644 --- a/indra/newview/app_settings/shaders/class1/objects/fullbrightSkinnedV.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightSkinnedV.glsl @@ -5,13 +5,11 @@ * $License$ */ -#version 120 + void calcAtmospherics(vec3 inPositionEye); mat4 getObjectSkinnedTransform(); -attribute vec4 object_weight; - void main() { //transform vertex diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl index 690a5d996..d87e5298d 100755 --- a/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void calcAtmospherics(vec3 inPositionEye); diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightWaterF.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightWaterF.glsl index 8645dc3a8..9e4825067 100755 --- a/indra/newview/app_settings/shaders/class1/objects/fullbrightWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightWaterF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void fullbright_lighting_water(); diff --git a/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl b/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl new file mode 100644 index 000000000..13597ee43 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl @@ -0,0 +1,26 @@ +/** + * @file impostorF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform float minimum_alpha; +uniform float maximum_alpha; + +vec3 fullbrightAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); + +uniform sampler2D diffuseMap; + +void main() +{ + vec4 color = texture2D(diffuseMap,gl_TexCoord[0].xy) * gl_Color; + + if (color.a < minimum_alpha || color.a > maximum_alpha) + { + discard; + } + + gl_FragColor = color; +} diff --git a/indra/newview/app_settings/shaders/class1/objects/impostorV.glsl b/indra/newview/app_settings/shaders/class1/objects/impostorV.glsl new file mode 100644 index 000000000..724b86a1b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/impostorV.glsl @@ -0,0 +1,16 @@ +/** + * @file impostorV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + +void main() +{ + //transform vertex + gl_Position = ftransform(); + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + + gl_FrontColor = gl_Color; +} diff --git a/indra/newview/app_settings/shaders/class1/objects/shinyF.glsl b/indra/newview/app_settings/shaders/class1/objects/shinyF.glsl index 1d83116b1..f2c86c064 100644 --- a/indra/newview/app_settings/shaders/class1/objects/shinyF.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/shinyF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void shiny_lighting(); diff --git a/indra/newview/app_settings/shaders/class1/objects/shinySimpleSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/objects/shinySimpleSkinnedV.glsl index 414664605..eea41bb4f 100644 --- a/indra/newview/app_settings/shaders/class1/objects/shinySimpleSkinnedV.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/shinySimpleSkinnedV.glsl @@ -5,14 +5,12 @@ * $License$ */ -#version 120 + vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); void calcAtmospherics(vec3 inPositionEye); mat4 getObjectSkinnedTransform(); -attribute vec4 object_weight; - void main() { mat4 mat = getObjectSkinnedTransform(); diff --git a/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl b/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl index 3fb9a298c..120ad7f0a 100644 --- a/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void calcAtmospherics(vec3 inPositionEye); diff --git a/indra/newview/app_settings/shaders/class1/objects/shinyWaterF.glsl b/indra/newview/app_settings/shaders/class1/objects/shinyWaterF.glsl index 1fc497e49..eba6f763c 100755 --- a/indra/newview/app_settings/shaders/class1/objects/shinyWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/shinyWaterF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void shiny_lighting_water(); diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl index 97f5741b3..8a2c76ead 100644 --- a/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void default_lighting(); diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleSkinnedV.glsl index be38a14d5..af92e5e00 100644 --- a/indra/newview/app_settings/shaders/class1/objects/simpleSkinnedV.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/simpleSkinnedV.glsl @@ -5,14 +5,12 @@ * $License$ */ -#version 120 + vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); void calcAtmospherics(vec3 inPositionEye); mat4 getObjectSkinnedTransform(); -attribute vec4 object_weight; - void main() { //transform vertex diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl index 03167cfc6..85219f041 100644 --- a/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); void calcAtmospherics(vec3 inPositionEye); diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleWaterF.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleWaterF.glsl index e133dcf41..dd8596704 100755 --- a/indra/newview/app_settings/shaders/class1/objects/simpleWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/simpleWaterF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void default_lighting_water(); diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl index 4c20ad758..2c6be7c9c 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + vec3 atmosLighting(vec3 light) { diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl index e83180714..45d2121b3 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + vec3 atmosAmbient(vec3 light) { diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl index c5adb50e4..37eb630a8 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void setPositionEye(vec3 v); diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl index f8405b4d5..db175c6f2 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + varying vec3 vary_PositionEye; diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl index 658767427..77d7b18c6 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + varying vec3 vary_PositionEye; diff --git a/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl b/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl index 76a072000..9c32d1a6a 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform vec4 gamma; diff --git a/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl index 77ed3ea2b..eef8dfbaa 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + vec3 atmosTransport(vec3 light) { diff --git a/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl b/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl index 4af024f17..263fbcc02 100644 --- a/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl +++ b/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol); void calcAtmospherics(vec3 inPositionEye); diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index f234f57d4..c0014d4cc 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -5,11 +5,10 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable -uniform sampler2D diffuseMap; uniform sampler2DRectShadow shadowMap0; uniform sampler2DRectShadow shadowMap1; uniform sampler2DRectShadow shadowMap2; @@ -105,7 +104,7 @@ void main() } } - vec4 diff= texture2D(diffuseMap, gl_TexCoord[0].xy); + vec4 diff = diffuseLookup(gl_TexCoord[0].xy); vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, gl_Color.a); vec4 color = diff * col; diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl new file mode 100644 index 000000000..5350359f7 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl @@ -0,0 +1,125 @@ +/** + * @file alphaF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +#extension GL_ARB_texture_rectangle : enable + +uniform sampler2DRectShadow shadowMap0; +uniform sampler2DRectShadow shadowMap1; +uniform sampler2DRectShadow shadowMap2; +uniform sampler2DRectShadow shadowMap3; +uniform sampler2DRect depthMap; +uniform sampler2D diffuseMap; + +uniform mat4 shadow_matrix[6]; +uniform vec4 shadow_clip; +uniform vec2 screen_res; +uniform vec2 shadow_res; + +vec3 atmosLighting(vec3 light); +vec3 scaleSoftClip(vec3 light); + +varying vec3 vary_ambient; +varying vec3 vary_directional; +varying vec3 vary_fragcoord; +varying vec3 vary_position; +varying vec3 vary_pointlight_col; + +uniform float shadow_bias; + +uniform mat4 inv_proj; + +vec4 getPosition(vec2 pos_screen) +{ + float depth = texture2DRect(depthMap, pos_screen.xy).a; + vec2 sc = pos_screen.xy*2.0; + sc /= screen_res; + sc -= vec2(1.0,1.0); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos.xyz /= pos.w; + pos.w = 1.0; + return pos; +} + +float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl) +{ + stc.xyz /= stc.w; + stc.z += shadow_bias; + + float cs = shadow2DRect(shadowMap, stc.xyz).x; + float shadow = cs; + + shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(scl, scl, 0.0)).x, cs); + shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(scl, -scl, 0.0)).x, cs); + shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-scl, scl, 0.0)).x, cs); + shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-scl, -scl, 0.0)).x, cs); + + return shadow/5.0; +} + + +void main() +{ + vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; + frag *= screen_res; + + float shadow = 1.0; + vec4 pos = vec4(vary_position, 1.0); + + vec4 spos = pos; + + if (spos.z > -shadow_clip.w) + { + vec4 lpos; + + if (spos.z < -shadow_clip.z) + { + lpos = shadow_matrix[3]*spos; + lpos.xy *= shadow_res; + shadow = pcfShadow(shadowMap3, lpos, 1.5); + shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); + } + else if (spos.z < -shadow_clip.y) + { + lpos = shadow_matrix[2]*spos; + lpos.xy *= shadow_res; + shadow = pcfShadow(shadowMap2, lpos, 1.5); + } + else if (spos.z < -shadow_clip.x) + { + lpos = shadow_matrix[1]*spos; + lpos.xy *= shadow_res; + shadow = pcfShadow(shadowMap1, lpos, 1.5); + } + else + { + lpos = shadow_matrix[0]*spos; + lpos.xy *= shadow_res; + shadow = pcfShadow(shadowMap0, lpos, 1.5); + } + } + + vec4 diff = texture2D(diffuseMap,gl_TexCoord[0].xy); + + vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, gl_Color.a); + vec4 color = diff * col; + + color.rgb = atmosLighting(color.rgb); + + color.rgb = scaleSoftClip(color.rgb); + + color.rgb += diff.rgb * vary_pointlight_col.rgb; + + //gl_FragColor = gl_Color; + gl_FragColor = color; + //gl_FragColor.r = 0.0; + //gl_FragColor = vec4(1,shadow,1,1); + +} + diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl index dfb36980b..948a52da5 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); void calcAtmospherics(vec3 inPositionEye); diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl index 7024025f7..f616ecc87 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); void calcAtmospherics(vec3 inPositionEye); @@ -22,6 +22,7 @@ varying vec3 vary_directional; varying vec3 vary_fragcoord; varying vec3 vary_position; varying vec3 vary_pointlight_col; +varying float vary_texture_index; uniform float near_clip; uniform float shadow_offset; @@ -34,32 +35,39 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa //get distance float d = length(lv); - - //normalize light vector - lv *= 1.0/d; - //distance attenuation - float dist2 = d*d/(la*la); - float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); + float da = 0.0; - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 + if (d > 0.0 && la > 0.0 && fa > 0.0) + { + //normalize light vector + lv *= 1.0/d; - //angular attenuation - da *= calcDirectionalLight(n, lv); + //distance attenuation + float dist2 = d*d/(la*la); + da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - return da; + // spotlight coefficient. + float spot = max(dot(-ln, lv), is_pointlight); + da *= spot*spot; // GL_SPOT_EXPONENT=2 + + //angular attenuation + da *= calcDirectionalLight(n, lv); + } + + return da; } void main() { //transform vertex - gl_Position = ftransform(); + vec4 vert = vec4(gl_Vertex.xyz, 1.0); + vary_texture_index = gl_Vertex.w; + gl_Position = gl_ModelViewProjectionMatrix * vert; gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; - vec4 pos = (gl_ModelViewMatrix * gl_Vertex); + vec4 pos = (gl_ModelViewMatrix * vert); vec3 norm = normalize(gl_NormalMatrix * gl_Normal); float dp_directional_light = max(0.0, dot(norm, gl_LightSource[0].position.xyz)); @@ -94,7 +102,7 @@ void main() gl_FogFragCoord = pos.z; - pos = gl_ModelViewProjectionMatrix * gl_Vertex; + pos = gl_ModelViewProjectionMatrix * vert; vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl index 495e86c8d..01e40afc4 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); mat4 getSkinnedTransform(); @@ -37,19 +37,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa //get distance float d = length(lv); - //normalize light vector - lv *= 1.0/d; + float da = 0.0; + + if (d > 0.0 && la > 0.0 && fa > 0.0) + { + //normalize light vector + lv *= 1.0/d; - //distance attenuation - float dist2 = d*d/(la*la); - float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); + //distance attenuation + float dist2 = d*d/(la*la); + da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 + // spotlight coefficient. + float spot = max(dot(-ln, lv), is_pointlight); + da *= spot*spot; // GL_SPOT_EXPONENT=2 - //angular attenuation - da *= calcDirectionalLight(n, lv); + //angular attenuation + da *= calcDirectionalLight(n, lv); + } return da; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/edgeF.glsl b/indra/newview/app_settings/shaders/class2/deferred/edgeF.glsl index 3155f3f92..729e4b554 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/edgeF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/edgeF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable @@ -22,7 +22,7 @@ uniform vec2 screen_res; float getDepth(vec2 pos_screen) { - float z = texture2DRect(depthMap, pos_screen.xy).a; + float z = texture2DRect(depthMap, pos_screen.xy).r; z = z*2.0-1.0; vec4 ndc = vec4(0.0, 0.0, z, 1.0); vec4 p = inv_proj*ndc; diff --git a/indra/newview/app_settings/shaders/class2/deferred/edgeV.glsl b/indra/newview/app_settings/shaders/class2/deferred/edgeV.glsl index b3413c301..393084a3d 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/edgeV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/edgeV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + varying vec2 vary_fragcoord; uniform vec2 screen_res; diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index d6cd984eb..f54186ffc 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable @@ -91,7 +91,7 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) vec4 getPosition(vec2 pos_screen) { - float depth = texture2DRect(depthMap, pos_screen.xy).a; + float depth = texture2DRect(depthMap, pos_screen.xy).r; vec2 sc = pos_screen.xy*2.0; sc /= screen_res; sc -= vec2(1.0,1.0); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 0160e8427..f0c9b0167 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable @@ -71,7 +71,7 @@ vec4 getPosition_d(vec2 pos_screen, float depth) vec4 getPosition(vec2 pos_screen) { //get position in screen space (world units) given window coordinate and depth map - float depth = texture2DRect(depthMap, pos_screen.xy).a; + float depth = texture2DRect(depthMap, pos_screen.xy).r; return getPosition_d(pos_screen, depth); } @@ -258,7 +258,7 @@ vec3 scaleSoftClip(vec3 light) void main() { vec2 tc = vary_fragcoord.xy; - float depth = texture2DRect(depthMap, tc.xy).a; + float depth = texture2DRect(depthMap, tc.xy).r; vec3 pos = getPosition_d(tc, depth).xyz; vec3 norm = texture2DRect(normalMap, tc).xyz; norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm @@ -267,80 +267,49 @@ void main() float da = max(dot(norm.xyz, vary_light.xyz), 0.0); vec4 diffuse = texture2DRect(diffuseRect, tc); - vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); - - vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; - float scol = max(scol_ambocc.r, diffuse.a); - float ambocc = scol_ambocc.g; - - calcAtmospherics(pos.xyz, ambocc); - - vec3 col = atmosAmbient(vec3(0)); - col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a)); - - col *= diffuse.rgb; - - if (spec.a > 0.0) // specular reflection + + vec3 col; + float bloom = 0.0; + + if (diffuse.a < 0.9) { - // the old infinite-sky shiny reflection - // - vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - float sa = dot(refnormpersp, vary_light.xyz); - vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a; - - /* - // screen-space cheap fakey reflection map - // - vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz)); - depth -= 0.5; // unbias depth - // first figure out where we'll make our 2D guess from - vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth; - // Offset the guess source a little according to a trivial - // checkerboard dither function and spec.a. - // This is meant to be similar to sampling a blurred version - // of the diffuse map. LOD would be better in that regard. - // The goal of the blur is to soften reflections in surfaces - // with low shinyness, and also to disguise our lameness. - float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0 - float checkoffset = (3.0 + (7.0*(1.0-spec.a)))*(checkerboard-0.5); - ref2d += vec2(checkoffset, checkoffset); - ref2d += tc.xy; // use as offset from destination - // Get attributes from the 2D guess point. - // We average two samples of diffuse (not of anything else) per - // pixel to try to reduce aliasing some more. - vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d + vec2(0.0, -checkoffset)).rgb + - texture2DRect(diffuseRect, ref2d + vec2(-checkoffset, 0.0)).rgb); - float refdepth = texture2DRect(depthMap, ref2d).a; - vec3 refpos = getPosition_d(ref2d, refdepth).xyz; - float refshad = texture2DRect(lightMap, ref2d).r; - vec3 refn = texture2DRect(normalMap, ref2d).rgb; - refn = vec3((refn.xy-0.5)*2.0,refn.z); // unpack norm - refn = normalize(refn); - // figure out how appropriate our guess actually was - float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos))); - // darken reflections from points which face away from the reflected ray - our guess was a back-face - //refapprop *= step(dot(refnorm, refn), 0.0); - refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant - // get appropriate light strength for guess-point - // reflect light direction to increase the illusion that - // these are reflections. - vec3 reflight = reflect(lightnorm.xyz, norm.xyz); - float reflit = min(max(dot(refn, reflight.xyz), 0.0), refshad); - // apply sun color to guess-point, dampen according to inappropriateness of guess - float refmod = min(refapprop, reflit); - vec3 refprod = vary_SunlitColor * refcol.rgb * refmod; - vec3 ssshiny = (refprod * spec.a); - ssshiny *= 0.3; // dampen it even more - */ - vec3 ssshiny = vec3(0,0,0); - - // add the two types of shiny together - col += (ssshiny + dumbshiny) * spec.rgb; - } + vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); + + vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; + float scol = max(scol_ambocc.r, diffuse.a); + float ambocc = scol_ambocc.g; - col = atmosLighting(col); - col = scaleSoftClip(col); + calcAtmospherics(pos.xyz, ambocc); + + col = atmosAmbient(vec3(0)); + col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a)); + + col *= diffuse.rgb; + + if (spec.a > 0.0) // specular reflection + { + // the old infinite-sky shiny reflection + // + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); + float sa = dot(refnormpersp, vary_light.xyz); + vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a; + + // add the two types of shiny together + vec3 spec_contrib = dumbshiny * spec.rgb; + bloom = dot(spec_contrib, spec_contrib); + col += spec_contrib; + } + + col = atmosLighting(col); + col = scaleSoftClip(col); + + col = mix(col, diffuse.rgb, diffuse.a); + } + else + { + col = diffuse.rgb; + } gl_FragColor.rgb = col; - gl_FragColor.a = 0.0; + gl_FragColor.a = bloom; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl index 8f0bcca76..745cc0199 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + uniform vec2 screen_res; diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index d0e242c2d..ccc2406b8 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl index 4369b3b34..315139b41 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable @@ -45,7 +45,7 @@ uniform float spot_shadow_offset; vec4 getPosition(vec2 pos_screen) { - float depth = texture2DRect(depthMap, pos_screen.xy).a; + float depth = texture2DRect(depthMap, pos_screen.xy).r; vec2 sc = pos_screen.xy*2.0; sc /= screen_res; sc -= vec2(1.0,1.0); diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl index fcea7aaf1..d53850b48 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable @@ -45,7 +45,7 @@ uniform float spot_shadow_offset; vec4 getPosition(vec2 pos_screen) { - float depth = texture2DRect(depthMap, pos_screen.xy).a; + float depth = texture2DRect(depthMap, pos_screen.xy).r; vec2 sc = pos_screen.xy*2.0; sc /= screen_res; sc -= vec2(1.0,1.0); @@ -60,9 +60,7 @@ vec4 getPosition(vec2 pos_screen) float calcAmbientOcclusion(vec4 pos, vec3 norm) { float ret = 1.0; - - float dist = dot(pos.xyz,pos.xyz); - + vec2 kern[8]; // exponentially (^2) distant occlusion samples spread around origin kern[0] = vec2(-1.0, 0.0) * 0.125*0.125; @@ -70,13 +68,13 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm) kern[2] = vec2(0.0, 1.0) * 0.375*0.375; kern[3] = vec2(0.0, -1.0) * 0.500*0.500; kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625; - kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750; - kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875; - kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000; + kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750; + kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875; + kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000; - vec2 pos_screen = vary_fragcoord.xy; - vec3 pos_world = pos.xyz; - vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy; + vec2 pos_screen = vary_fragcoord.xy; + vec3 pos_world = pos.xyz; + vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy; float angle_hidden = 0.0; int points = 0; @@ -106,7 +104,6 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm) angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0); ret = (1.0 - (float(points != 0) * angle_hidden)); - ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0); return min(ret, 1.0); } @@ -237,7 +234,7 @@ void main() gl_FragColor[0] = shadow; gl_FragColor[1] = calcAmbientOcclusion(pos, norm); - spos.xyz = shadow_pos+offset*spot_shadow_offset; + spos.xyz = shadow_pos+norm*spot_shadow_offset; //spotlight shadow 1 vec4 lpos = shadow_matrix[4]*spos; diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl index 9beb513ad..814deb367 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + varying vec4 vary_light; varying vec2 vary_fragcoord; diff --git a/indra/newview/app_settings/shaders/class2/effects/blurF.glsl b/indra/newview/app_settings/shaders/class2/effects/blurF.glsl index 43f37a80a..19641ac0c 100644 --- a/indra/newview/app_settings/shaders/class2/effects/blurF.glsl +++ b/indra/newview/app_settings/shaders/class2/effects/blurF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable uniform sampler2DRect RenderTexture; diff --git a/indra/newview/app_settings/shaders/class2/effects/blurV.glsl b/indra/newview/app_settings/shaders/class2/effects/blurV.glsl index cf4218bf7..9f57ab8a5 100644 --- a/indra/newview/app_settings/shaders/class2/effects/blurV.glsl +++ b/indra/newview/app_settings/shaders/class2/effects/blurV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform vec2 texelSize; uniform vec2 blurDirection; diff --git a/indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl b/indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl index f57633950..1347d957c 100644 --- a/indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl +++ b/indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable uniform sampler2DRect RenderTexture; diff --git a/indra/newview/app_settings/shaders/class2/effects/drawQuadV.glsl b/indra/newview/app_settings/shaders/class2/effects/drawQuadV.glsl index 229ede470..b4a6786ce 100644 --- a/indra/newview/app_settings/shaders/class2/effects/drawQuadV.glsl +++ b/indra/newview/app_settings/shaders/class2/effects/drawQuadV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void main(void) { diff --git a/indra/newview/app_settings/shaders/class2/effects/extractF.glsl b/indra/newview/app_settings/shaders/class2/effects/extractF.glsl index fdf547264..9ae4a0d8c 100644 --- a/indra/newview/app_settings/shaders/class2/effects/extractF.glsl +++ b/indra/newview/app_settings/shaders/class2/effects/extractF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable uniform sampler2DRect RenderTexture; diff --git a/indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl b/indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl index f6dfa52a9..5f6986e3f 100644 --- a/indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl +++ b/indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable uniform sampler2DRect RenderTexture; diff --git a/indra/newview/app_settings/shaders/class2/effects/simpleF.glsl b/indra/newview/app_settings/shaders/class2/effects/simpleF.glsl index 3dbed8e01..b905913d1 100644 --- a/indra/newview/app_settings/shaders/class2/effects/simpleF.glsl +++ b/indra/newview/app_settings/shaders/class2/effects/simpleF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable uniform sampler2DRect RenderTexture; diff --git a/indra/newview/app_settings/shaders/class2/environment/terrainF.glsl b/indra/newview/app_settings/shaders/class2/environment/terrainF.glsl index 9ccc776ad..57925fc72 100644 --- a/indra/newview/app_settings/shaders/class2/environment/terrainF.glsl +++ b/indra/newview/app_settings/shaders/class2/environment/terrainF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D detail_0; uniform sampler2D detail_1; diff --git a/indra/newview/app_settings/shaders/class2/environment/terrainV.glsl b/indra/newview/app_settings/shaders/class2/environment/terrainV.glsl index 19211b8e6..caec960e4 100644 --- a/indra/newview/app_settings/shaders/class2/environment/terrainV.glsl +++ b/indra/newview/app_settings/shaders/class2/environment/terrainV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + void calcAtmospherics(vec3 inPositionEye); diff --git a/indra/newview/app_settings/shaders/class2/environment/terrainWaterF.glsl b/indra/newview/app_settings/shaders/class2/environment/terrainWaterF.glsl index 6f2f560a9..fdbe4212e 100755 --- a/indra/newview/app_settings/shaders/class2/environment/terrainWaterF.glsl +++ b/indra/newview/app_settings/shaders/class2/environment/terrainWaterF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D detail_0; uniform sampler2D detail_1; diff --git a/indra/newview/app_settings/shaders/class2/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class2/environment/underWaterF.glsl index 246b55440..7f3685f1c 100644 --- a/indra/newview/app_settings/shaders/class2/environment/underWaterF.glsl +++ b/indra/newview/app_settings/shaders/class2/environment/underWaterF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform sampler2D diffuseMap; uniform sampler2D bumpMap; diff --git a/indra/newview/app_settings/shaders/class2/environment/waterF.glsl b/indra/newview/app_settings/shaders/class2/environment/waterF.glsl index 246377382..7df3aaf23 100644 --- a/indra/newview/app_settings/shaders/class2/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class2/environment/waterF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + vec3 scaleSoftClip(vec3 inColor); vec3 atmosTransport(vec3 inColor); diff --git a/indra/newview/app_settings/shaders/class2/environment/waterFogF.glsl b/indra/newview/app_settings/shaders/class2/environment/waterFogF.glsl index dd1c8ee64..f8cb7e1e2 100644 --- a/indra/newview/app_settings/shaders/class2/environment/waterFogF.glsl +++ b/indra/newview/app_settings/shaders/class2/environment/waterFogF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform vec4 lightnorm; uniform vec4 waterPlane; diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightAlphaMaskF.glsl new file mode 100644 index 000000000..1211ad7a8 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightAlphaMaskF.glsl @@ -0,0 +1,30 @@ +/** + * @file lightAlphaMaskF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + +uniform float minimum_alpha; +uniform float maximum_alpha; + +vec3 atmosLighting(vec3 light); +vec3 scaleSoftClip(vec3 light); + +void default_lighting() +{ + vec4 color = diffuseLookup(gl_TexCoord[0].xy) * gl_Color; + + if (color.a < minimum_alpha || color.a > maximum_alpha) + { + discard; + } + + color.rgb = atmosLighting(color.rgb); + + color.rgb = scaleSoftClip(color.rgb); + + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightAlphaMaskNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightAlphaMaskNonIndexedF.glsl new file mode 100644 index 000000000..1a7d67b94 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightAlphaMaskNonIndexedF.glsl @@ -0,0 +1,33 @@ +/** + * @file lightAlphaMaskNonIndexedF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + +uniform float minimum_alpha; +uniform float maximum_alpha; + + +uniform sampler2D diffuseMap; + +vec3 atmosLighting(vec3 light); +vec3 scaleSoftClip(vec3 light); + +void default_lighting() +{ + vec4 color = texture2D(diffuseMap,gl_TexCoord[0].xy) * gl_Color; + + if (color.a < minimum_alpha || color.a > maximum_alpha) + { + discard; + } + + color.rgb = atmosLighting(color.rgb); + + color.rgb = scaleSoftClip(color.rgb); + + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightF.glsl index e7779d357..22060bfcc 100644 --- a/indra/newview/app_settings/shaders/class2/lighting/lightF.glsl +++ b/indra/newview/app_settings/shaders/class2/lighting/lightF.glsl @@ -5,16 +5,14 @@ * $License$ */ -#version 120 -uniform sampler2D diffuseMap; vec3 atmosLighting(vec3 light); vec3 scaleSoftClip(vec3 light); void default_lighting() { - vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * gl_Color; + vec4 color = diffuseLookup(gl_TexCoord[0].xy) * gl_Color; color.rgb = atmosLighting(color.rgb); diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightAlphaMaskF.glsl new file mode 100644 index 000000000..73e885a7e --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightAlphaMaskF.glsl @@ -0,0 +1,29 @@ +/** + * @file lightFullbrightAlphaMaskF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform float minimum_alpha; +uniform float maximum_alpha; + +vec3 fullbrightAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); + +void fullbright_lighting() +{ + vec4 color = diffuseLookup(gl_TexCoord[0].xy) * gl_Color; + + if (color.a < minimum_alpha || color.a > maximum_alpha) + { + discard; + } + + color.rgb = fullbrightAtmosTransport(color.rgb); + + color.rgb = fullbrightScaleSoftClip(color.rgb); + + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightF.glsl index 509ac80b2..52ad40008 100644 --- a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightF.glsl @@ -5,16 +5,14 @@ * $License$ */ -#version 120 -uniform sampler2D diffuseMap; vec3 fullbrightAtmosTransport(vec3 light); vec3 fullbrightScaleSoftClip(vec3 light); void fullbright_lighting() { - vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * gl_Color; + vec4 color = diffuseLookup(gl_TexCoord[0].xy) * gl_Color; color.rgb = fullbrightAtmosTransport(color.rgb); diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl new file mode 100644 index 000000000..55dfe9b16 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl @@ -0,0 +1,31 @@ +/** + * @file lightFullbrightNonIndexedAlphaMaskF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform float minimum_alpha; +uniform float maximum_alpha; + +vec3 fullbrightAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); + +uniform sampler2D diffuseMap; + +void fullbright_lighting() +{ + vec4 color = texture2D(diffuseMap,gl_TexCoord[0].xy) * gl_Color; + + if (color.a < minimum_alpha || color.a > maximum_alpha) + { + discard; + } + + color.rgb = fullbrightAtmosTransport(color.rgb); + + color.rgb = fullbrightScaleSoftClip(color.rgb); + + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightNonIndexedF.glsl new file mode 100644 index 000000000..b1e61e1a3 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightNonIndexedF.glsl @@ -0,0 +1,25 @@ +/** + * @file lightFullbrightF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +vec3 fullbrightAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); + +uniform sampler2D diffuseMap; + +void fullbright_lighting() +{ + vec4 color = texture2D(diffuseMap,gl_TexCoord[0].xy) * gl_Color; + + color.rgb = fullbrightAtmosTransport(color.rgb); + + color.rgb = fullbrightScaleSoftClip(color.rgb); + + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyF.glsl index 17a4cb03f..a0050f887 100644 --- a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyF.glsl @@ -5,9 +5,8 @@ * $License$ */ -#version 120 -uniform sampler2D diffuseMap; + uniform samplerCube environmentMap; vec3 fullbrightShinyAtmosTransport(vec3 light); @@ -15,7 +14,7 @@ vec3 fullbrightScaleSoftClip(vec3 light); void fullbright_shiny_lighting() { - vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy); + vec4 color = diffuseLookup(gl_TexCoord[0].xy); color.rgb *= gl_Color.rgb; vec3 envColor = textureCube(environmentMap, gl_TexCoord[1].xyz).rgb; diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyNonIndexedF.glsl new file mode 100644 index 000000000..953298da0 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyNonIndexedF.glsl @@ -0,0 +1,32 @@ +/** + * @file lightFullbrightShinyF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +uniform samplerCube environmentMap; +uniform sampler2D diffuseMap; + +vec3 fullbrightShinyAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); + +void fullbright_shiny_lighting() +{ + vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy); + color.rgb *= gl_Color.rgb; + + vec3 envColor = textureCube(environmentMap, gl_TexCoord[1].xyz).rgb; + color.rgb = mix(color.rgb, envColor.rgb, gl_Color.a); + + color.rgb = fullbrightShinyAtmosTransport(color.rgb); + + color.rgb = fullbrightScaleSoftClip(color.rgb); + + color.a = max(color.a, gl_Color.a); + + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyWaterF.glsl index 9b4b58436..a6e10a249 100644 --- a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyWaterF.glsl +++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyWaterF.glsl @@ -5,9 +5,9 @@ * $License$ */ -#version 120 -uniform sampler2D diffuseMap; + + uniform samplerCube environmentMap; vec3 fullbrightShinyAtmosTransport(vec3 light); @@ -16,7 +16,7 @@ vec4 applyWaterFog(vec4 color); void fullbright_shiny_lighting_water() { - vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy); + vec4 color = diffuseLookup(gl_TexCoord[0].xy); color.rgb *= gl_Color.rgb; vec3 envColor = textureCube(environmentMap, gl_TexCoord[1].xyz).rgb; diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyWaterNonIndexedF.glsl new file mode 100644 index 000000000..b4bb665a2 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyWaterNonIndexedF.glsl @@ -0,0 +1,32 @@ +/** + * @file lightFullbrightShinyWaterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + + + + +uniform samplerCube environmentMap; +uniform sampler2D diffuseMap; + +vec3 fullbrightShinyAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); +vec4 applyWaterFog(vec4 color); + +void fullbright_shiny_lighting_water() +{ + vec4 color = texture2D(diffuseMap,gl_TexCoord[0].xy); + color.rgb *= gl_Color.rgb; + + vec3 envColor = textureCube(environmentMap, gl_TexCoord[1].xyz).rgb; + color.rgb = mix(color.rgb, envColor.rgb, gl_Color.a); + + color.rgb = fullbrightShinyAtmosTransport(color.rgb); + color.rgb = fullbrightScaleSoftClip(color.rgb); + color.a = max(color.a, gl_Color.a); + + gl_FragColor = applyWaterFog(color); +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterAlphaMaskF.glsl new file mode 100644 index 000000000..e4cea077f --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterAlphaMaskF.glsl @@ -0,0 +1,29 @@ +/** + * @file lightFullbrightWaterAlphaMaskF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform float minimum_alpha; +uniform float maximum_alpha; + +vec4 diffuseLookup(vec2 texcoord); + +vec3 fullbrightAtmosTransport(vec3 light); +vec4 applyWaterFog(vec4 color); + +void fullbright_lighting_water() +{ + vec4 color = diffuseLookup(gl_TexCoord[0].xy) * gl_Color; + + if (color.a < minimum_alpha || color.a > maximum_alpha) + { + discard; + } + + color.rgb = fullbrightAtmosTransport(color.rgb); + + gl_FragColor = applyWaterFog(color); +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterF.glsl index 548d1c9ee..667464a02 100644 --- a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterF.glsl +++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterF.glsl @@ -5,16 +5,16 @@ * $License$ */ -#version 120 -uniform sampler2D diffuseMap; + +vec4 diffuseLookup(vec2 texcoord); vec3 fullbrightAtmosTransport(vec3 light); vec4 applyWaterFog(vec4 color); void fullbright_lighting_water() { - vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * gl_Color; + vec4 color = diffuseLookup(gl_TexCoord[0].xy) * gl_Color; color.rgb = fullbrightAtmosTransport(color.rgb); diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl new file mode 100644 index 000000000..e8533f94a --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl @@ -0,0 +1,29 @@ +/** + * @file lightFullbrightWaterNonIndexedAlphaMaskF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform float minimum_alpha; +uniform float maximum_alpha; + +uniform sampler2D diffuseMap; + +vec3 fullbrightAtmosTransport(vec3 light); +vec4 applyWaterFog(vec4 color); + +void fullbright_lighting_water() +{ + vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * gl_Color; + + if (color.a < minimum_alpha || color.a > maximum_alpha) + { + discard; + } + + color.rgb = fullbrightAtmosTransport(color.rgb); + + gl_FragColor = applyWaterFog(color); +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterNonIndexedF.glsl new file mode 100644 index 000000000..1234682ae --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterNonIndexedF.glsl @@ -0,0 +1,23 @@ +/** + * @file lightFullbrightWaterF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +uniform sampler2D diffuseMap; + +vec3 fullbrightAtmosTransport(vec3 light); +vec4 applyWaterFog(vec4 color); + +void fullbright_lighting_water() +{ + vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * gl_Color; + + color.rgb = fullbrightAtmosTransport(color.rgb); + + gl_FragColor = applyWaterFog(color); +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightNonIndexedF.glsl new file mode 100644 index 000000000..149cf791f --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightNonIndexedF.glsl @@ -0,0 +1,25 @@ +/** + * @file lightF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +uniform sampler2D diffuseMap; + +vec3 atmosLighting(vec3 light); +vec3 scaleSoftClip(vec3 light); + +void default_lighting() +{ + vec4 color = texture2D(diffuseMap,gl_TexCoord[0].xy) * gl_Color; + + color.rgb = atmosLighting(color.rgb); + + color.rgb = scaleSoftClip(color.rgb); + + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightShinyF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightShinyF.glsl index 675fd4adf..ef8c2602d 100644 --- a/indra/newview/app_settings/shaders/class2/lighting/lightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class2/lighting/lightShinyF.glsl @@ -5,9 +5,9 @@ * $License$ */ -#version 120 -uniform sampler2D diffuseMap; + + uniform samplerCube environmentMap; vec3 scaleSoftClip(vec3 light); @@ -16,7 +16,7 @@ vec4 applyWaterFog(vec4 color); void shiny_lighting() { - vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy); + vec4 color = diffuseLookup(gl_TexCoord[0].xy); color.rgb *= gl_Color.rgb; vec3 envColor = textureCube(environmentMap, gl_TexCoord[1].xyz).rgb; diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightShinyNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightShinyNonIndexedF.glsl new file mode 100644 index 000000000..e877c0abb --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightShinyNonIndexedF.glsl @@ -0,0 +1,32 @@ +/** + * @file lightShinyF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + + +uniform samplerCube environmentMap; +uniform sampler2D diffuseMap; + +vec3 scaleSoftClip(vec3 light); +vec3 atmosLighting(vec3 light); +vec4 applyWaterFog(vec4 color); + +void shiny_lighting() +{ + vec4 color = texture2D(diffuseMap,gl_TexCoord[0].xy); + color.rgb *= gl_Color.rgb; + + vec3 envColor = textureCube(environmentMap, gl_TexCoord[1].xyz).rgb; + color.rgb = mix(color.rgb, envColor.rgb, gl_Color.a); + + color.rgb = atmosLighting(color.rgb); + + color.rgb = scaleSoftClip(color.rgb); + color.a = max(color.a, gl_Color.a); + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightShinyWaterF.glsl index 4e8a0d189..8885aae09 100644 --- a/indra/newview/app_settings/shaders/class2/lighting/lightShinyWaterF.glsl +++ b/indra/newview/app_settings/shaders/class2/lighting/lightShinyWaterF.glsl @@ -5,10 +5,9 @@ * $License$ */ -#version 120 -uniform sampler2D diffuseMap; + uniform samplerCube environmentMap; vec3 atmosLighting(vec3 light); @@ -16,7 +15,7 @@ vec4 applyWaterFog(vec4 color); void shiny_lighting_water() { - vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy); + vec4 color = diffuseLookup(gl_TexCoord[0].xy); color.rgb *= gl_Color.rgb; vec3 envColor = textureCube(environmentMap, gl_TexCoord[1].xyz).rgb; diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightShinyWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightShinyWaterNonIndexedF.glsl new file mode 100644 index 000000000..390417942 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightShinyWaterNonIndexedF.glsl @@ -0,0 +1,29 @@ +/** + * @file lightShinyWaterF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + + +uniform sampler2D diffuseMap; +uniform samplerCube environmentMap; + +vec3 atmosLighting(vec3 light); +vec4 applyWaterFog(vec4 color); + +void shiny_lighting_water() +{ + vec4 color = texture2D(diffuseMap,gl_TexCoord[0].xy); + color.rgb *= gl_Color.rgb; + + vec3 envColor = textureCube(environmentMap, gl_TexCoord[1].xyz).rgb; + color.rgb = mix(color.rgb, envColor.rgb, gl_Color.a); + + color.rgb = atmosLighting(color.rgb); + color.a = max(color.a, gl_Color.a); + gl_FragColor = applyWaterFog(color); +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightSpecularV.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightSpecularV.glsl index 4e9fa16a1..f324ae939 100644 --- a/indra/newview/app_settings/shaders/class2/lighting/lightSpecularV.glsl +++ b/indra/newview/app_settings/shaders/class2/lighting/lightSpecularV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + // All lights, no specular highlights diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightV.glsl index 75c0d7414..5971c22bc 100644 --- a/indra/newview/app_settings/shaders/class2/lighting/lightV.glsl +++ b/indra/newview/app_settings/shaders/class2/lighting/lightV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + // All lights, no specular highlights diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightWaterAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightWaterAlphaMaskF.glsl new file mode 100644 index 000000000..7b3c20f09 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightWaterAlphaMaskF.glsl @@ -0,0 +1,27 @@ +/** + * @file lightWaterAlphaMaskF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform float minimum_alpha; +uniform float maximum_alpha; + +vec3 atmosLighting(vec3 light); +vec4 applyWaterFog(vec4 color); + +void default_lighting_water() +{ + vec4 color = diffuseLookup(gl_TexCoord[0].xy) * gl_Color; + + if (color.a < minimum_alpha || color.a > maximum_alpha) + { + discard; + } + + color.rgb = atmosLighting(color.rgb); + + gl_FragColor = applyWaterFog(color); +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightWaterAlphaMaskNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightWaterAlphaMaskNonIndexedF.glsl new file mode 100644 index 000000000..907140eff --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightWaterAlphaMaskNonIndexedF.glsl @@ -0,0 +1,31 @@ +/** + * @file lightWaterAlphaMaskNonIndexedF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform float minimum_alpha; +uniform float maximum_alpha; + +uniform sampler2D diffuseMap; + +vec3 atmosLighting(vec3 light); +vec4 applyWaterFog(vec4 color); + +void default_lighting_water() +{ + vec4 color = texture2D(diffuseMap,gl_TexCoord[0].xy) * gl_Color; + + if (color.a < minimum_alpha || color.a > maximum_alpha) + { + discard; + } + + color.rgb = atmosLighting(color.rgb); + + color = applyWaterFog(color); + + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightWaterF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightWaterF.glsl index 64df7f0f9..9c5d07832 100644 --- a/indra/newview/app_settings/shaders/class2/lighting/lightWaterF.glsl +++ b/indra/newview/app_settings/shaders/class2/lighting/lightWaterF.glsl @@ -5,16 +5,14 @@ * $License$ */ -#version 120 -uniform sampler2D diffuseMap; vec3 atmosLighting(vec3 light); vec4 applyWaterFog(vec4 color); void default_lighting_water() { - vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * gl_Color; + vec4 color = diffuseLookup(gl_TexCoord[0].xy) * gl_Color; color.rgb = atmosLighting(color.rgb); diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightWaterNonIndexedF.glsl new file mode 100644 index 000000000..ba850b61d --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightWaterNonIndexedF.glsl @@ -0,0 +1,23 @@ +/** + * @file lightWaterF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +uniform sampler2D diffuseMap; + +vec3 atmosLighting(vec3 light); +vec4 applyWaterFog(vec4 color); + +void default_lighting_water() +{ + vec4 color = texture2D(diffuseMap,gl_TexCoord[0].xy) * gl_Color; + + color.rgb = atmosLighting(color.rgb); + + gl_FragColor = applyWaterFog(color); +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/sumLightsSpecularV.glsl b/indra/newview/app_settings/shaders/class2/lighting/sumLightsSpecularV.glsl index 2408e11d9..9b5c565de 100644 --- a/indra/newview/app_settings/shaders/class2/lighting/sumLightsSpecularV.glsl +++ b/indra/newview/app_settings/shaders/class2/lighting/sumLightsSpecularV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + float calcDirectionalLightSpecular(inout vec4 specular, vec3 view, vec3 n, vec3 l, vec3 lightCol, float da); vec3 calcPointLightSpecular(inout vec4 specular, vec3 view, vec3 v, vec3 n, vec3 l, float r, float pw, vec3 lightCol); diff --git a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl index 5f5b426da..dab7ba6d2 100644 --- a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl +++ b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + float calcDirectionalLight(vec3 n, vec3 l); float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight); diff --git a/indra/newview/app_settings/shaders/class2/objects/fullbrightShinyV.glsl b/indra/newview/app_settings/shaders/class2/objects/fullbrightShinyV.glsl new file mode 100644 index 000000000..f49e74406 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/objects/fullbrightShinyV.glsl @@ -0,0 +1,35 @@ +/** + * @file fullbrightShinyV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +void calcAtmospherics(vec3 inPositionEye); + +uniform vec4 origin; + +varying float vary_texture_index; + +void main() +{ + //transform vertex + vec4 vert = vec4(gl_Vertex.xyz,1.0); + vary_texture_index = gl_Vertex.w; + gl_Position = gl_ModelViewProjectionMatrix*vert; + + vec4 pos = (gl_ModelViewMatrix * vert); + vec3 norm = normalize(gl_NormalMatrix * gl_Normal); + vec3 ref = reflect(pos.xyz, -norm); + + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0); + + calcAtmospherics(pos.xyz); + + gl_FrontColor = gl_Color; + + gl_FogFragCoord = pos.z; +} diff --git a/indra/newview/app_settings/shaders/class2/objects/fullbrightV.glsl b/indra/newview/app_settings/shaders/class2/objects/fullbrightV.glsl new file mode 100644 index 000000000..3076fa326 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/objects/fullbrightV.glsl @@ -0,0 +1,29 @@ +/** + * @file fullbrightV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +void calcAtmospherics(vec3 inPositionEye); + +varying float vary_texture_index; + +void main() +{ + //transform vertex + vec4 vert = vec4(gl_Vertex.xyz,1.0); + vary_texture_index = gl_Vertex.w; + gl_Position = gl_ModelViewProjectionMatrix*vert; + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + + vec4 pos = (gl_ModelViewMatrix * vert); + + calcAtmospherics(pos.xyz); + + gl_FrontColor = gl_Color; + + gl_FogFragCoord = pos.z; +} diff --git a/indra/newview/app_settings/shaders/class2/objects/shinyV.glsl b/indra/newview/app_settings/shaders/class2/objects/shinyV.glsl index 76e96cb27..29d4a9a32 100755 --- a/indra/newview/app_settings/shaders/class2/objects/shinyV.glsl +++ b/indra/newview/app_settings/shaders/class2/objects/shinyV.glsl @@ -5,20 +5,24 @@ * $License$ */ -#version 120 + vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); void calcAtmospherics(vec3 inPositionEye); +varying float vary_texture_index; + uniform vec4 origin; void main() { //transform vertex - gl_Position = ftransform(); + vec4 vert = vec4(gl_Vertex.xyz,1.0); + vary_texture_index = gl_Vertex.w; + gl_Position = gl_ModelViewProjectionMatrix*vert; - vec4 pos = (gl_ModelViewMatrix * gl_Vertex); + vec4 pos = (gl_ModelViewMatrix * vert); vec3 norm = normalize(gl_NormalMatrix * gl_Normal); vec3 ref = reflect(pos.xyz, -norm); diff --git a/indra/newview/app_settings/shaders/class2/objects/simpleV.glsl b/indra/newview/app_settings/shaders/class2/objects/simpleV.glsl new file mode 100644 index 000000000..5e0239176 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/objects/simpleV.glsl @@ -0,0 +1,33 @@ +/** + * @file simpleV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); +void calcAtmospherics(vec3 inPositionEye); + +varying float vary_texture_index; + +void main() +{ + //transform vertex + vec4 vert = vec4(gl_Vertex.xyz,1.0); + vary_texture_index = gl_Vertex.w; + gl_Position = gl_ModelViewProjectionMatrix*vert; + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + + vec4 pos = (gl_ModelViewMatrix * vert); + + vec3 norm = normalize(gl_NormalMatrix * gl_Normal); + + calcAtmospherics(pos.xyz); + + vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.)); + gl_FrontColor = color; + + gl_FogFragCoord = pos.z; +} diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl index 80da3ee23..dabd34f08 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + ////////////////////////////////////////////////////////// // The fragment shader for the terrain atmospherics diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl index c806655dc..83cd447a5 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + // Output variables vec3 getSunlitColor(); diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl index 8b73c07ac..9c00c81f3 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + // varying param funcs void setSunlitColor(vec3 v); diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl index 3a5eeb853..f4378d6af 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + varying vec3 vary_PositionEye; diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl index aef449775..807812324 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + varying vec3 vary_PositionEye; diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index 69262ec7d..d3b742542 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + ///////////////////////////////////////////////////////////////////////// // The fragment shader for the sky diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl index 881bb90b8..16f9ec285 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + ////////////////////////////////////////////////////////////////////////// // The vertex shader for creating the atmospheric sky diff --git a/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl b/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl index 3ca7a962d..964fdef45 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + uniform vec4 gamma; diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl index 6737d2617..a1507b8cd 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + ///////////////////////////////////////////////////////////////////////// // The fragment shader for the sky diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl index e1a6844d2..a857a4cc7 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + // SKY //////////////////////////////////////////////////////////////////////// // The vertex shader for creating the atmospheric sky diff --git a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl index e1e385496..34f8dadac 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + ////////////////////////////////////////////////////////// // The fragment shader for the terrain atmospherics diff --git a/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl b/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl index 1b6e843c0..648ebef94 100644 --- a/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl +++ b/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); mat4 getSkinnedTransform(); diff --git a/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl b/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl index fc370ef36..498fee7c6 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + uniform sampler2DRect giLightMap; diff --git a/indra/newview/app_settings/shaders/class3/deferred/giDownsampleV.glsl b/indra/newview/app_settings/shaders/class3/deferred/giDownsampleV.glsl index ae57227fe..eebe93066 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/giDownsampleV.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/giDownsampleV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + varying vec2 vary_fragcoord; uniform vec2 screen_res; diff --git a/indra/newview/app_settings/shaders/class3/deferred/giF.glsl b/indra/newview/app_settings/shaders/class3/deferred/giF.glsl index 951e3e97a..9896f8daf 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/giF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/giF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable diff --git a/indra/newview/app_settings/shaders/class3/deferred/giFinalF.glsl b/indra/newview/app_settings/shaders/class3/deferred/giFinalF.glsl index b2f8b2c63..df4c6b3e0 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/giFinalF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/giFinalF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable diff --git a/indra/newview/app_settings/shaders/class3/deferred/giFinalV.glsl b/indra/newview/app_settings/shaders/class3/deferred/giFinalV.glsl index 19c4e07b8..7e20d7152 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/giFinalV.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/giFinalV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + varying vec2 vary_fragcoord; uniform vec2 screen_res; diff --git a/indra/newview/app_settings/shaders/class3/deferred/giV.glsl b/indra/newview/app_settings/shaders/class3/deferred/giV.glsl index 8dc1410ea..e86f2896d 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/giV.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/giV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + varying vec2 vary_fragcoord; diff --git a/indra/newview/app_settings/shaders/class3/deferred/luminanceF.glsl b/indra/newview/app_settings/shaders/class3/deferred/luminanceF.glsl index 5f3bf68b2..980def644 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/luminanceF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/luminanceF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable diff --git a/indra/newview/app_settings/shaders/class3/deferred/luminanceV.glsl b/indra/newview/app_settings/shaders/class3/deferred/luminanceV.glsl index a24eda35d..9afeac6dd 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/luminanceV.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/luminanceV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + varying vec2 vary_fragcoord; diff --git a/indra/newview/app_settings/shaders/class3/deferred/postDeferredF.glsl b/indra/newview/app_settings/shaders/class3/deferred/postDeferredF.glsl index ab99a8897..6d4c20f68 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/postDeferredF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/postDeferredF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable diff --git a/indra/newview/app_settings/shaders/class3/deferred/postDeferredV.glsl b/indra/newview/app_settings/shaders/class3/deferred/postDeferredV.glsl index 12983baa9..876f65ee3 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/postDeferredV.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/postDeferredV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + varying vec2 vary_fragcoord; uniform vec2 screen_res; diff --git a/indra/newview/app_settings/shaders/class3/deferred/postgiF.glsl b/indra/newview/app_settings/shaders/class3/deferred/postgiF.glsl index f03775470..fc6588168 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/postgiF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/postgiF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable diff --git a/indra/newview/app_settings/shaders/class3/deferred/postgiV.glsl b/indra/newview/app_settings/shaders/class3/deferred/postgiV.glsl index ae57227fe..eebe93066 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/postgiV.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/postgiV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + varying vec2 vary_fragcoord; uniform vec2 screen_res; diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 56f3f9697..69e79bd94 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + #extension GL_ARB_texture_rectangle : enable @@ -266,91 +266,50 @@ void main() float da = max(dot(norm.xyz, vary_light.xyz), 0.0); vec4 diffuse = texture2DRect(diffuseRect, tc); - vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); - - da = texture2D(lightFunc, vec2(da, 0.0)).a; - - vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; - float scol = max(scol_ambocc.r, diffuse.a); - float ambocc = scol_ambocc.g; - - calcAtmospherics(pos.xyz, ambocc); - - vec3 col = atmosAmbient(vec3(0)); - col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a)); - - col *= diffuse.rgb; - - if (spec.a > 0.0) // specular reflection + vec3 col; + float bloom = 0.0; + + if (diffuse.a < 0.9) { - // the old infinite-sky shiny reflection - // - vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - float sa = dot(refnormpersp, vary_light.xyz); - vec3 dumbshiny = vary_SunlitColor*scol*texture2D(lightFunc, vec2(sa, spec.a)).a; - - /* - // screen-space cheap fakey reflection map - // - vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz)); - depth -= 0.5; // unbias depth - // first figure out where we'll make our 2D guess from - vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth; - // Offset the guess source a little according to a trivial - // checkerboard dither function and spec.a. - // This is meant to be similar to sampling a blurred version - // of the diffuse map. LOD would be better in that regard. - // The goal of the blur is to soften reflections in surfaces - // with low shinyness, and also to disguise our lameness. - float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0 - float checkoffset = (3.0 + (7.0*(1.0-spec.a)))*(checkerboard-0.5); - - ref2d += vec2(checkoffset, checkoffset); - ref2d += tc.xy; // use as offset from destination - // Get attributes from the 2D guess point. - // We average two samples of diffuse (not of anything else) per - // pixel to try to reduce aliasing some more. - vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d + vec2(0.0, -checkoffset)).rgb + - texture2DRect(diffuseRect, ref2d + vec2(-checkoffset, 0.0)).rgb); - float refdepth = texture2DRect(depthMap, ref2d).a; - vec3 refpos = getPosition_d(ref2d, refdepth).xyz; - float refshad = texture2DRect(lightMap, ref2d).r; - vec3 refn = texture2DRect(normalMap, ref2d).rgb; - refn = vec3((refn.xy-0.5)*2.0,refn.z); // unpack norm - refn = normalize(refn); - // figure out how appropriate our guess actually was - float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos))); - // darken reflections from points which face away from the reflected ray - our guess was a back-face - //refapprop *= step(dot(refnorm, refn), 0.0); - refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant - // get appropriate light strength for guess-point. - // reflect light direction to increase the illusion that - // these are reflections. - vec3 reflight = reflect(lightnorm.xyz, norm.xyz); - float reflit = min(max(dot(refn, reflight.xyz), 0.0), refshad); - // apply sun color to guess-point, dampen according to inappropriateness of guess - float refmod = min(refapprop, reflit); - vec3 refprod = vary_SunlitColor * refcol.rgb * refmod; - vec3 ssshiny = (refprod * spec.a); - ssshiny *= 0.3; // dampen it even more - */ - vec3 ssshiny = vec3(0,0,0); - - // add the two types of shiny together - col += (ssshiny + dumbshiny) * spec.rgb; - } + vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); - col = atmosLighting(col); - col = scaleSoftClip(col); + da = texture2D(lightFunc, vec2(da, 0.0)).a; + + vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; + float scol = max(scol_ambocc.r, diffuse.a); + float ambocc = scol_ambocc.g; + + calcAtmospherics(pos.xyz, ambocc); + + col = atmosAmbient(vec3(0)); + col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a)); + + col *= diffuse.rgb; + + if (spec.a > 0.0) // specular reflection + { + // the old infinite-sky shiny reflection + // + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); + float sa = dot(refnormpersp, vary_light.xyz); + vec3 dumbshiny = vary_SunlitColor*scol*texture2D(lightFunc, vec2(sa, spec.a)).a; + + // add the two types of shiny together + vec3 spec_contrib = dumbshiny * spec.rgb; + bloom = dot(spec_contrib, spec_contrib); + col += spec_contrib; + } + + col = atmosLighting(col); + col = scaleSoftClip(col); + + col = mix(col, diffuse.rgb, diffuse.a); + } + else + { + col = diffuse.rgb; + } gl_FragColor.rgb = col; - - //gl_FragColor.rgb = gi_col.rgb; - gl_FragColor.a = 0.0; - - //gl_FragColor.rg = scol_ambocc.rg; - //gl_FragColor.rgb = texture2DRect(lightMap, vary_fragcoord.xy).rgb; - //gl_FragColor.rgb = norm.rgb*0.5+0.5; - //gl_FragColor.rgb = vec3(ambocc); - //gl_FragColor.rgb = vec3(scol); + gl_FragColor.a = bloom; } diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl index 8f0bcca76..745cc0199 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + uniform vec2 screen_res; diff --git a/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl index c54d9a1e3..de7e03840 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl @@ -5,7 +5,7 @@ * $/LicenseInfo$ */ -#version 120 + uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class3/lighting/sumLightsSpecularV.glsl b/indra/newview/app_settings/shaders/class3/lighting/sumLightsSpecularV.glsl index ee61162c0..f59175972 100644 --- a/indra/newview/app_settings/shaders/class3/lighting/sumLightsSpecularV.glsl +++ b/indra/newview/app_settings/shaders/class3/lighting/sumLightsSpecularV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + float calcDirectionalLightSpecular(inout vec4 specular, vec3 view, vec3 n, vec3 l, vec3 lightCol, float da); vec3 calcPointLightSpecular(inout vec4 specular, vec3 view, vec3 v, vec3 n, vec3 l, float r, float pw, vec3 lightCol); diff --git a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl index ae84fcb9c..b8d03284e 100644 --- a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl +++ b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl @@ -5,7 +5,7 @@ * $License$ */ -#version 120 + float calcDirectionalLight(vec3 n, vec3 l); float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight); diff --git a/indra/newview/dofloaterhex.cpp b/indra/newview/dofloaterhex.cpp index 90cc9b321..c74aff66e 100644 --- a/indra/newview/dofloaterhex.cpp +++ b/indra/newview/dofloaterhex.cpp @@ -23,6 +23,7 @@ #include "llinventorymodel.h" // gInventory.updateItem #include "llappviewer.h" // System Folders #include "llfloaterperms.h" //get default perms +#include "llnotificationsutil.h" std::list DOFloaterHex::sInstances; S32 DOFloaterHex::sUploadAmount = 10; @@ -291,7 +292,7 @@ void DOFloaterHex::onClickUpload(void* user_data) { LLSD args; args["ERROR_MESSAGE"] = "Couldn't write data to file"; - LLNotifications::instance().add("ErrorMessage", args); + LLNotificationsUtil::add("ErrorMessage", args); return; } delete[] buffer; @@ -366,7 +367,7 @@ void DOFloaterHex::onClickSave(void* user_data) { LLSD args; args["ERROR_MESSAGE"] = "Couldn't write data to file"; - LLNotifications::instance().add("ErrorMessage", args); + LLNotificationsUtil::add("ErrorMessage", args); return; } delete[] buffer; @@ -431,7 +432,7 @@ void DOFloaterHex::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 { LLSD args; args["ERROR_MESSAGE"] = llformat("Upload failed with status %d, also %d", status, ext_status); - LLNotifications::instance().add("ErrorMessage", args); + LLNotificationsUtil::add("ErrorMessage", args); } } diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index e3a8ca0de..9b91d32f8 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -1,4 +1,4 @@ -version 20 +version 32 // NOTE: This is mostly identical to featuretable_mac.txt with a few differences // Should be combined into one table @@ -23,9 +23,11 @@ version 20 // NOTE: All settings are set to the MIN of applied values, including 'all'! // list all -RenderAnisotropic 1 0 +RenderAnisotropic 1 1 RenderAvatarCloth 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarPhysicsLODFactor 1 1.0 +RenderAvatarMaxVisible 1 12 RenderAvatarVP 1 1 RenderCubeMap 1 1 RenderFarClip 1 256 @@ -34,12 +36,13 @@ RenderFogRatio 1 4.0 RenderGamma 1 0 RenderGlowResolutionPow 1 9 RenderGround 1 1 -RenderLocalLights 1 1 RenderMaxPartCount 1 8192 RenderObjectBump 1 1 +RenderLocalLights 1 1 RenderReflectionDetail 1 4 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 +RenderTransparentWater 1 1 RenderTreeLODFactor 1 1.0 RenderUseImpostors 1 1 RenderVBOEnable 1 1 @@ -51,14 +54,16 @@ WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 Disregard128DefaultDrawDistance 1 1 Disregard96DefaultDrawDistance 1 1 -RenderShaderLightingMaxLevel 1 3 RenderTextureMemoryMultiple 1 1.0 -RenderUseFBO 1 1 -RenderFastAlpha 1 1 +RenderShaderLightingMaxLevel 1 3 RenderDeferred 1 1 -RenderDeferredGI 1 1 +RenderDeferredSSAO 1 1 RenderShadowDetail 1 2 -RenderAvatarPhysicsLODFactor 1 1.0 +WatchdogDisabled 1 1 +ShyotlRenderUseStreamVBO 1 1 +RenderDeferredGI 1 0 +RenderFastAlpha 1 1 +RenderUseFBO 1 1 // // Low Graphics Settings @@ -66,29 +71,32 @@ RenderAvatarPhysicsLODFactor 1 1.0 list Low RenderAnisotropic 1 0 RenderAvatarCloth 1 0 -RenderAvatarLODFactor 1 0.25 +RenderAvatarLODFactor 1 0 +RenderAvatarPhysicsLODFactor 1 0 +RenderAvatarMaxVisible 1 3 RenderAvatarVP 1 0 RenderFarClip 1 64 -RenderFlexTimeFactor 1 0.1 +RenderFlexTimeFactor 1 0 RenderGlowResolutionPow 1 8 -RenderLocalLights 1 0 RenderMaxPartCount 1 1024 RenderObjectBump 1 0 +RenderLocalLights 1 0 RenderReflectionDetail 1 0 RenderTerrainDetail 1 0 RenderTerrainLODFactor 1 1 +RenderTransparentWater 1 0 RenderTreeLODFactor 1 0.25 RenderUseImpostors 1 1 RenderVolumeLODFactor 1 0.5 VertexShaderEnable 1 0 WindLightUseAtmosShaders 1 0 WLSkyDetail 1 48 -RenderUseFBO 0 0 -RenderFastAlpha 1 1 -RenderDeferred 0 0 +RenderDeferred 1 0 +RenderDeferredSSAO 1 0 +RenderShadowDetail 1 0 RenderDeferredGI 0 0 -RenderShadowDetail 0 0 -RenderAvatarPhysicsLODFactor 1 0.0 +RenderFastAlpha 1 1 +RenderUseFBO 1 0 // // Mid Graphics Settings @@ -97,28 +105,30 @@ list Mid RenderAnisotropic 1 0 RenderAvatarCloth 1 0 RenderAvatarLODFactor 1 0.5 +RenderAvatarPhysicsLODFactor 1 0.5 RenderAvatarVP 1 1 RenderFarClip 1 96 -RenderFlexTimeFactor 1 0.5 +RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 8 -RenderLocalLights 1 1 RenderMaxPartCount 1 2048 RenderObjectBump 1 1 +RenderLocalLights 1 1 RenderReflectionDetail 1 0 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 1.0 +RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 RenderUseImpostors 1 1 RenderVolumeLODFactor 1 1.125 VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 0 WLSkyDetail 1 48 -RenderUseFBO 1 0 -RenderFastAlpha 1 0 RenderDeferred 1 0 -RenderDeferredGI 1 0 +RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 -RenderAvatarPhysicsLODFactor 1 0.5 +RenderDeferredGI 1 0 +RenderFastAlpha 1 0 +RenderUseFBO 1 0 // @@ -128,29 +138,30 @@ list High RenderAnisotropic 1 1 RenderAvatarCloth 1 0 RenderAvatarLODFactor 1 1.0 +RenderAvatarPhysicsLODFactor 1 .75 RenderAvatarVP 1 1 RenderFarClip 1 128 RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 9 -RenderLocalLights 1 1 RenderMaxPartCount 1 4096 RenderObjectBump 1 1 +RenderLocalLights 1 1 RenderReflectionDetail 1 2 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 +RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 RenderUseImpostors 1 1 RenderVolumeLODFactor 1 1.125 VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 WLSkyDetail 1 48 -RenderUseFBO 1 0 -RenderFastAlpha 1 0 RenderDeferred 1 0 -RenderDeferredGI 1 0 +RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 -RenderAvatarPhysicsLODFactor 1 0.75 - +RenderDeferredGI 1 0 +RenderFastAlpha 1 0 +RenderUseFBO 1 0 // // Ultra graphics (REALLY PURTY!) @@ -163,24 +174,25 @@ RenderAvatarVP 1 1 RenderFarClip 1 256 RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 9 -RenderLocalLights 1 1 RenderMaxPartCount 1 8192 RenderObjectBump 1 1 +RenderLocalLights 1 1 RenderReflectionDetail 1 4 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 +RenderTransparentWater 1 1 RenderTreeLODFactor 1 1.0 RenderUseImpostors 1 1 RenderVolumeLODFactor 1 2.0 VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 -RenderUseFBO 1 1 -RenderFastAlpha 1 0 RenderDeferred 1 1 -RenderDeferredGI 1 0 +RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 -RenderAvatarPhysicsLODFactor 1 1.0 +RenderDeferredGI 1 0 +RenderFastAlpha 1 0 +RenderUseFBO 1 1 // // Class Unknown Hardware (unknown) @@ -222,6 +234,8 @@ RenderReflectionDetail 0 0 VertexShaderEnable 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 +RenderDeferredSSAO 0 0 +RenderShadowDetail 0 0 // // No Vertex Shaders available @@ -233,6 +247,8 @@ RenderReflectionDetail 0 0 VertexShaderEnable 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 +RenderDeferredSSAO 0 0 +RenderShadowDetail 0 0 // "Default" setups for safe, low, medium, high // @@ -240,16 +256,18 @@ list safe RenderAnisotropic 1 0 RenderAvatarCloth 0 0 RenderAvatarVP 0 0 -RenderLocalLights 1 0 RenderObjectBump 0 0 +RenderLocalLights 1 0 RenderMaxPartCount 1 1024 RenderTerrainDetail 1 0 RenderUseImpostors 0 0 RenderVBOEnable 1 0 RenderReflectionDetail 0 0 WindLightUseAtmosShaders 0 0 -RenderUseFBO 1 0 -RenderDeferred 1 0 +RenderUseFBO 0 0 +RenderDeferred 0 0 +RenderDeferredSSAO 0 0 +RenderShadowDetail 0 0 // // CPU based feature masks @@ -271,10 +289,12 @@ RenderObjectBump 0 0 list OpenGLPre15 RenderVBOEnable 1 0 +list OpenGLPre30 +RenderDeferred 0 0 list Intel RenderAnisotropic 1 0 +RenderVBOEnable 1 0 RenderLocalLights 1 0 -RenderUseImpostors 0 0 RenderDeferred 1 0 list GeForce2 @@ -291,30 +311,37 @@ UseOcclusion 0 0 list Intel_830M RenderTerrainDetail 1 0 RenderVBOEnable 1 0 +RenderUseImpostors 0 0 list Intel_845G RenderTerrainDetail 1 0 RenderVBOEnable 1 0 +RenderUseImpostors 0 0 list Intel_855GM RenderTerrainDetail 1 0 RenderVBOEnable 1 0 +RenderUseImpostors 0 0 list Intel_865G RenderTerrainDetail 1 0 RenderVBOEnable 1 0 +RenderUseImpostors 0 0 list Intel_900 RenderTerrainDetail 1 0 RenderVBOEnable 1 0 +RenderUseImpostors 0 0 list Intel_915GM RenderTerrainDetail 1 0 RenderVBOEnable 1 0 +RenderUseImpostors 0 0 list Intel_915G RenderTerrainDetail 1 0 RenderVBOEnable 1 0 +RenderUseImpostors 0 0 list Intel_945GM RenderTerrainDetail 1 0 @@ -449,6 +476,14 @@ list ATIOldDriver RenderAvatarVP 0 0 RenderAvatarCloth 0 0 +// ATI cards generally perform better when not using VBOs for streaming data + +list ATI +ShyotlRenderUseStreamVBO 1 0 + +// Disable vertex buffer objects by default for ATI cards with little video memory +list ATIVramLT256 +RenderVBOEnable 1 0 /// Tweaked NVIDIA diff --git a/indra/newview/featuretable_linux.txt b/indra/newview/featuretable_linux.txt index e64bfa3e3..97dda7be6 100644 --- a/indra/newview/featuretable_linux.txt +++ b/indra/newview/featuretable_linux.txt @@ -1,4 +1,4 @@ -version 20 +version 27 // NOTE: This is mostly identical to featuretable_mac.txt with a few differences // Should be combined into one table @@ -26,6 +26,8 @@ list all RenderAnisotropic 1 0 RenderAvatarCloth 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarPhysicsLODFactor 1 1.0 +RenderAvatarMaxVisible 1 12 RenderAvatarVP 1 1 RenderCubeMap 1 1 RenderFarClip 1 256 @@ -40,6 +42,7 @@ RenderObjectBump 1 1 RenderReflectionDetail 1 4 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 +RenderTransparentWater 1 1 RenderTreeLODFactor 1 1.0 RenderUseImpostors 1 1 RenderVBOEnable 1 1 @@ -51,14 +54,14 @@ WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 Disregard128DefaultDrawDistance 1 1 Disregard96DefaultDrawDistance 1 1 -RenderShaderLightingMaxLevel 1 3 RenderTextureMemoryMultiple 1 1.0 -RenderUseFBO 1 1 -RenderFastAlpha 1 1 +RenderShaderLightingMaxLevel 1 3 RenderDeferred 1 1 -RenderDeferredGI 1 1 +RenderDeferredSSAO 1 1 RenderShadowDetail 1 2 -RenderAvatarPhysicsLODFactor 1 1.0 +RenderDeferredGI 1 0 +RenderFastAlpha 1 1 +RenderUseFBO 1 1 // // Low Graphics Settings @@ -66,10 +69,12 @@ RenderAvatarPhysicsLODFactor 1 1.0 list Low RenderAnisotropic 1 0 RenderAvatarCloth 1 0 -RenderAvatarLODFactor 1 0.25 +RenderAvatarLODFactor 1 0 +RenderAvatarPhysicsLODFactor 1 0 +RenderAvatarMaxVisible 1 3 RenderAvatarVP 1 0 RenderFarClip 1 64 -RenderFlexTimeFactor 1 0.1 +RenderFlexTimeFactor 1 0 RenderGlowResolutionPow 1 8 RenderLocalLights 1 0 RenderMaxPartCount 1 1024 @@ -77,18 +82,19 @@ RenderObjectBump 1 0 RenderReflectionDetail 1 0 RenderTerrainDetail 1 0 RenderTerrainLODFactor 1 1 +RenderTransparentWater 1 0 RenderTreeLODFactor 1 0.25 RenderUseImpostors 1 1 RenderVolumeLODFactor 1 0.5 VertexShaderEnable 1 0 WindLightUseAtmosShaders 1 0 WLSkyDetail 1 48 -RenderUseFBO 0 0 +RenderDeferred 1 0 +RenderDeferredSSAO 1 0 +RenderShadowDetail 1 0 +RenderDeferredGI 1 0 RenderFastAlpha 1 1 -RenderDeferred 0 0 -RenderDeferredGI 0 0 -RenderShadowDetail 0 0 -RenderAvatarPhysicsLODFactor 1 0.0 +RenderUseFBO 1 0 // // Mid Graphics Settings @@ -97,9 +103,10 @@ list Mid RenderAnisotropic 1 0 RenderAvatarCloth 1 0 RenderAvatarLODFactor 1 0.5 +RenderAvatarPhysicsLODFactor 1 0.5 RenderAvatarVP 1 1 RenderFarClip 1 96 -RenderFlexTimeFactor 1 0.5 +RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 8 RenderLocalLights 1 1 RenderMaxPartCount 1 2048 @@ -107,19 +114,19 @@ RenderObjectBump 1 1 RenderReflectionDetail 1 0 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 1.0 +RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 RenderUseImpostors 1 1 RenderVolumeLODFactor 1 1.125 VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 0 WLSkyDetail 1 48 -RenderUseFBO 1 0 -RenderFastAlpha 1 0 RenderDeferred 1 0 -RenderDeferredGI 1 0 +RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 -RenderAvatarPhysicsLODFactor 1 0.5 - +RenderDeferredGI 1 0 +RenderFastAlpha 1 0 +RenderUseFBO 1 0 // // High Graphics Settings (purty) @@ -128,6 +135,7 @@ list High RenderAnisotropic 1 1 RenderAvatarCloth 1 0 RenderAvatarLODFactor 1 1.0 +RenderAvatarPhysicsLODFactor 1 0.75 RenderAvatarVP 1 1 RenderFarClip 1 128 RenderFlexTimeFactor 1 1.0 @@ -138,18 +146,19 @@ RenderObjectBump 1 1 RenderReflectionDetail 1 2 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 +RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 RenderUseImpostors 1 1 RenderVolumeLODFactor 1 1.125 VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 WLSkyDetail 1 48 -RenderUseFBO 1 0 -RenderFastAlpha 1 0 RenderDeferred 1 0 -RenderDeferredGI 1 0 +RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 -RenderAvatarPhysicsLODFactor 1 0.75 +RenderDeferredGI 1 0 +RenderFastAlpha 1 0 +RenderUseFBO 1 0 // @@ -159,6 +168,7 @@ list Ultra RenderAnisotropic 1 1 RenderAvatarCloth 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarPhysicsLODFactor 1 1.0 RenderAvatarVP 1 1 RenderFarClip 1 256 RenderFlexTimeFactor 1 1.0 @@ -169,18 +179,20 @@ RenderObjectBump 1 1 RenderReflectionDetail 1 4 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 +RenderTransparentWater 1 1 RenderTreeLODFactor 1 1.0 RenderUseImpostors 1 1 RenderVolumeLODFactor 1 2.0 VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 -RenderUseFBO 1 1 -RenderFastAlpha 1 0 RenderDeferred 1 1 -RenderDeferredGI 1 0 +RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 -RenderAvatarPhysicsLODFactor 1 1.0 +RenderDeferredGI 1 0 +RenderFastAlpha 1 0 +RenderUseFBO 1 1 + // @@ -223,6 +235,8 @@ RenderReflectionDetail 0 0 VertexShaderEnable 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 +RenderDeferredSSAO 0 0 +RenderShadowDetail 0 0 // // No Vertex Shaders available @@ -234,6 +248,8 @@ RenderReflectionDetail 0 0 VertexShaderEnable 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 +RenderDeferredSSAO 0 0 +RenderShadowDetail 0 0 // "Default" setups for safe, low, medium, high // @@ -249,9 +265,13 @@ RenderUseImpostors 0 0 RenderVBOEnable 1 0 RenderReflectionDetail 0 0 WindLightUseAtmosShaders 0 0 -RenderUseFBO 1 0 -RenderDeferred 1 0 - +RenderDeferred 0 0 +RenderDeferredSSAO 0 0 +RenderShadowDetail 0 0 +RenderShadowDetail 0 0 +RenderDeferredGI 0 0 +RenderFastAlpha 0 0 +RenderUseFBO 0 0 // // CPU based feature masks @@ -494,17 +514,47 @@ list NVIDIA_GeForce_Go_6 RenderVBOEnable 1 0 Disregard128DefaultDrawDistance 1 0 +list NVIDIA_GeForce_7000 +RenderShaderLightingMaxLevel 1 2 +list NVIDIA_GeForce_7100 +RenderShaderLightingMaxLevel 1 2 list NVIDIA_GeForce_7200 Disregard128DefaultDrawDistance 1 0 +RenderShaderLightingMaxLevel 1 2 list NVIDIA_GeForce_7300 Disregard128DefaultDrawDistance 1 0 +RenderShaderLightingMaxLevel 1 2 list NVIDIA_GeForce_7400 Disregard128DefaultDrawDistance 1 0 +RenderShaderLightingMaxLevel 1 2 +list NVIDIA_GeForce_7500 +RenderShaderLightingMaxLevel 1 2 +list NVIDIA_GeForce_7600 +RenderShaderLightingMaxLevel 1 2 +list NVIDIA_GeForce_7700 +RenderShaderLightingMaxLevel 1 2 +list NVIDIA_GeForce_7800 +RenderShaderLightingMaxLevel 1 2 +list NVIDIA_GeForce_7900 +RenderShaderLightingMaxLevel 1 2 list NVIDIA_GeForce_Go_7200 Disregard128DefaultDrawDistance 1 0 +RenderShaderLightingMaxLevel 1 2 list NVIDIA_GeForce_Go_7300 Disregard128DefaultDrawDistance 1 0 +RenderShaderLightingMaxLevel 1 2 +list NVIDIA_GeForce_Go_7300_LE +RenderShaderLightingMaxLevel 1 2 list NVIDIA_GeForce_Go_7400 Disregard128DefaultDrawDistance 1 0 +RenderShaderLightingMaxLevel 1 2 +list NVIDIA_GeForce_Go_7600 +RenderShaderLightingMaxLevel 1 2 +list NVIDIA_GeForce_Go_7700 +RenderShaderLightingMaxLevel 1 2 +list NVIDIA_GeForce_Go_7800 +RenderShaderLightingMaxLevel 1 2 +list NVIDIA_GeForce_Go_7900 +RenderShaderLightingMaxLevel 1 2 diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 16156fe42..61afc26ab 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 20 +version 30 // NOTE: This is mostly identical to featuretable_mac.txt with a few differences // Should be combined into one table @@ -25,8 +25,10 @@ version 20 list all RenderAnisotropic 1 0 RenderAvatarCloth 1 1 -RenderAvatarLODFactor 1 1.0 -RenderAvatarVP 1 1 +RenderAvatarLODFactor 1 1.0 +RenderAvatarPhysicsLODFactor 1 1.0 +RenderAvatarMaxVisible 1 12 +RenderAvatarVP 1 1 RenderCubeMap 1 1 RenderFarClip 1 256 RenderFlexTimeFactor 1 1.0 @@ -39,10 +41,11 @@ RenderMaxPartCount 1 8192 RenderObjectBump 1 1 RenderReflectionDetail 1 4 RenderTerrainDetail 1 1 -RenderTerrainLODFactor 1 2.0 +RenderTerrainLODFactor 1 2.0 +RenderTransparentWater 1 1 RenderTreeLODFactor 1 1.0 RenderUseImpostors 1 1 -RenderVBOEnable 1 1 +RenderVBOEnable 1 0 RenderVolumeLODFactor 1 2.0 UseStartScreen 1 1 UseOcclusion 1 1 @@ -51,14 +54,19 @@ WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 Disregard128DefaultDrawDistance 1 1 Disregard96DefaultDrawDistance 1 1 +RenderTextureMemoryMultiple 1 0.5 RenderShaderLightingMaxLevel 1 3 -RenderTextureMemoryMultiple 1 1.0 -RenderUseFBO 1 1 -RenderFastAlpha 1 1 + + RenderDeferred 1 1 -RenderDeferredGI 1 1 + RenderShadowDetail 1 2 -RenderAvatarPhysicsLODFactor 1 1.0 +WatchdogDisabled 1 1 +ShyotlRenderUseStreamVBO 1 0 +RenderDeferredGI 1 1 +RenderFastAlpha 1 1 +RenderUseFBO 1 1 + // // Low Graphics Settings @@ -66,10 +74,12 @@ RenderAvatarPhysicsLODFactor 1 1.0 list Low RenderAnisotropic 1 0 RenderAvatarCloth 1 0 -RenderAvatarLODFactor 1 0.25 +RenderAvatarLODFactor 1 0 +RenderAvatarPhysicsLODFactor 1 0 +RenderAvatarMaxVisible 1 3 RenderAvatarVP 1 0 RenderFarClip 1 64 -RenderFlexTimeFactor 1 0.1 +RenderFlexTimeFactor 1 0 RenderGlowResolutionPow 1 8 RenderLocalLights 1 0 RenderMaxPartCount 1 1024 @@ -77,18 +87,19 @@ RenderObjectBump 1 0 RenderReflectionDetail 1 0 RenderTerrainDetail 1 0 RenderTerrainLODFactor 1 1 +RenderTransparentWater 1 0 RenderTreeLODFactor 1 0.25 RenderUseImpostors 1 1 RenderVolumeLODFactor 1 0.5 VertexShaderEnable 1 0 WindLightUseAtmosShaders 1 0 WLSkyDetail 1 48 -RenderUseFBO 0 0 +RenderDeferred 1 0 +RenderDeferredSSAO 1 0 +RenderShadowDetail 1 0 +RenderDeferredGI 1 0 +RenderUseFBO 1 0 RenderFastAlpha 1 1 -RenderDeferred 0 0 -RenderDeferredGI 0 0 -RenderShadowDetail 0 0 -RenderAvatarPhysicsLODFactor 1 0.0 // // Mid Graphics Settings @@ -97,6 +108,7 @@ list Mid RenderAnisotropic 1 0 RenderAvatarCloth 1 0 RenderAvatarLODFactor 1 0.5 +RenderAvatarPhysicsLODFactor 1 0.5 RenderAvatarVP 1 1 RenderFarClip 1 96 RenderFlexTimeFactor 1 0.5 @@ -107,18 +119,19 @@ RenderObjectBump 1 1 RenderReflectionDetail 1 0 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 1.0 +RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 RenderUseImpostors 1 1 RenderVolumeLODFactor 1 1.125 VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 0 WLSkyDetail 1 48 -RenderUseFBO 1 0 -RenderFastAlpha 1 0 RenderDeferred 1 0 -RenderDeferredGI 1 0 +RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 -RenderAvatarPhysicsLODFactor 1 0.5 +RenderDeferredGI 1 0 +RenderFastAlpha 1 0 +RenderUseFBO 1 0 // @@ -128,6 +141,7 @@ list High RenderAnisotropic 1 1 RenderAvatarCloth 1 0 RenderAvatarLODFactor 1 1.0 +RenderAvatarPhysicsLODFactor 1 0.75 RenderAvatarVP 1 1 RenderFarClip 1 128 RenderFlexTimeFactor 1 1.0 @@ -138,18 +152,19 @@ RenderObjectBump 1 1 RenderReflectionDetail 1 2 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 +RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 RenderUseImpostors 1 1 RenderVolumeLODFactor 1 1.125 VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 WLSkyDetail 1 48 -RenderUseFBO 1 0 -RenderFastAlpha 1 0 RenderDeferred 1 0 -RenderDeferredGI 1 0 +RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 -RenderAvatarPhysicsLODFactor 1 0.75 +RenderDeferredGI 1 0 +RenderFastAlpha 1 0 +RenderUseFBO 1 0 // @@ -159,6 +174,7 @@ list Ultra RenderAnisotropic 1 1 RenderAvatarCloth 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarPhysicsLODFactor 1 1.0 RenderAvatarVP 1 1 RenderFarClip 1 256 RenderFlexTimeFactor 1 1.0 @@ -169,18 +185,19 @@ RenderObjectBump 1 1 RenderReflectionDetail 1 4 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 +RenderTransparentWater 1 1 RenderTreeLODFactor 1 1.0 RenderUseImpostors 1 1 RenderVolumeLODFactor 1 2.0 VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 -RenderUseFBO 1 1 -RenderFastAlpha 1 0 RenderDeferred 1 1 -RenderDeferredGI 1 0 +RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 -RenderAvatarPhysicsLODFactor 1 1.0 +RenderDeferredGI 1 0 +RenderFastAlpha 1 0 +RenderUseFBO 1 1 // // Class Unknown Hardware (unknown) @@ -222,6 +239,8 @@ RenderReflectionDetail 0 0 VertexShaderEnable 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 +RenderDeferredSSAO 0 0 +RenderShadowDetail 0 0 // // No Vertex Shaders available @@ -233,7 +252,10 @@ RenderReflectionDetail 0 0 VertexShaderEnable 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 +RenderDeferredSSAO 0 0 +RenderShadowDetail 0 0 +// // "Default" setups for safe, low, medium, high // list safe @@ -248,8 +270,10 @@ RenderUseImpostors 0 0 RenderVBOEnable 1 0 RenderReflectionDetail 0 0 WindLightUseAtmosShaders 0 0 -RenderUseFBO 1 0 -RenderDeferred 1 0 +RenderDeferred 0 0 +RenderDeferredSSAO 0 0 +RenderShadowDetail 0 0 +RenderUseFBO 0 0 // // CPU based feature masks @@ -271,10 +295,15 @@ RenderObjectBump 0 0 list OpenGLPre15 RenderVBOEnable 1 0 +list TexUnit8orLess +RenderDeferredSSAO 0 0 + +list ATI +RenderDeferredSSAO 1 0 + list Intel RenderAnisotropic 1 0 RenderLocalLights 1 0 -RenderDeferred 1 0 list GeForce2 RenderAnisotropic 1 0 @@ -407,23 +436,23 @@ Disregard128DefaultDrawDistance 1 0 // invisible avatars on HD 2600... so I masked // out other possible bad ones till it's fixed -list ATI_Radeon_HD_2300 -RenderAvatarVP 0 0 -RenderAvatarCloth 0 0 -Disregard128DefaultDrawDistance 1 0 -list ATI_Radeon_HD_2400 -RenderAvatarVP 0 0 -RenderAvatarCloth 0 0 -Disregard128DefaultDrawDistance 1 0 -list ATI_Radeon_HD_2600 -RenderAvatarVP 0 0 -RenderAvatarCloth 0 0 -list ATI_Radeon_HD_2900 -RenderAvatarVP 0 0 -RenderAvatarCloth 0 0 -list ATI_Radeon_HD_3800 -RenderAvatarVP 0 0 -RenderAvatarCloth 0 0 +//list ATI_Radeon_HD_2300 +//RenderAvatarVP 0 0 +//RenderAvatarCloth 0 0 +//Disregard128DefaultDrawDistance 1 0 +//list ATI_Radeon_HD_2400 +//RenderAvatarVP 0 0 +//RenderAvatarCloth 0 0 +//Disregard128DefaultDrawDistance 1 0 +//list ATI_Radeon_HD_2600 +//RenderAvatarVP 0 0 +//RenderAvatarCloth 0 0 +//list ATI_Radeon_HD_2900 +//RenderAvatarVP 0 0 +//RenderAvatarCloth 0 0 +//list ATI_Radeon_HD_3800 +//RenderAvatarVP 0 0 +//RenderAvatarCloth 0 0 /// Tweaked NVIDIA diff --git a/indra/newview/featuretable_solaris.txt b/indra/newview/featuretable_solaris.txt index f24cbde5e..7df75687f 100644 --- a/indra/newview/featuretable_solaris.txt +++ b/indra/newview/featuretable_solaris.txt @@ -37,6 +37,9 @@ VertexShaderEnable 1 1 RenderTextureMemoryMultiple 1 1.0 UseOcclusion 1 1 RenderCubeMap 1 1 +WatchdogDisabled 1 1 +RenderUseFBO 1 1 + // // Class 0 Hardware (Unknown or just old) @@ -50,6 +53,7 @@ RenderAvatarMode 1 0 RenderLighting 1 0 RenderObjectBump 1 0 RenderRippleWater 1 0 +RenderUseFBO 1 0 // // Class 1 Hardware @@ -63,6 +67,7 @@ RenderAvatarMode 1 0 RenderLighting 1 0 RenderObjectBump 1 0 RenderRippleWater 1 0 +RenderUseFBO 1 0 // // Class 2 Hardware (make it purty) @@ -74,6 +79,7 @@ RenderAvatarMode 1 1 RenderLighting 1 1 RenderObjectBump 1 1 RenderRippleWater 1 1 +RenderUseFBO 1 1 // // Class 3 Hardware (make it purty) @@ -85,6 +91,7 @@ RenderAvatarMode 1 1 RenderLighting 1 1 RenderObjectBump 1 1 RenderRippleWater 1 1 +RenderUseFBO 1 1 // // No Pixel Shaders available @@ -112,11 +119,13 @@ RenderParticleCount 1 1024 RenderTerrainDetail 1 0 RenderCubeMap 0 0 UseOcclusion 0 0 +RenderUseFBO 1 0 list low RenderVBO 1 0 RenderAniso 1 0 +RenderAvatarMaxVisible 1 3 RenderLighting 1 0 list medium diff --git a/indra/newview/floatersculptpreview.cpp b/indra/newview/floatersculptpreview.cpp index add283067..97d20083f 100644 --- a/indra/newview/floatersculptpreview.cpp +++ b/indra/newview/floatersculptpreview.cpp @@ -747,15 +747,13 @@ void LLPreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance) // build vertices and normals for (U32 i = 0; (S32)i < num_vertices; i++) { - (vertex_strider++)->set(vf.mPositions[i].getF32ptr()); - LLVector3 normal(vf.mNormals[i].getF32ptr()); - normal.normalize(); - *(normal_strider++) = normal; + LLVector4a normal = vf.mNormals[i]; + normal.normalize3(); + (normal_strider++)->set(normal.getF32ptr()); } //build vertices - vertex_strider.assignArray((U8*)vf.mPositions,sizeof(vf.mPositions[0]),num_indices); - + vertex_strider.assignArray((U8*)vf.mPositions,sizeof(vf.mPositions[0]),num_vertices); // build indices index_strider.assignArray((U8*)vf.mIndices,sizeof(vf.mIndices[0]),num_indices); } diff --git a/indra/newview/hgfloatertexteditor.cpp b/indra/newview/hgfloatertexteditor.cpp index acd7755ec..044c32040 100644 --- a/indra/newview/hgfloatertexteditor.cpp +++ b/indra/newview/hgfloatertexteditor.cpp @@ -24,6 +24,7 @@ #include "llappviewer.h" // System Folders #include "llfloaterperms.h" //get default perms #include "lllocalinventory.h" +#include "llnotificationsutil.h" std::list HGFloaterTextEditor::sInstances; S32 HGFloaterTextEditor::sUploadAmount = 10; @@ -255,7 +256,7 @@ void HGFloaterTextEditor::onClickUpload(void* user_data) { LLSD args; args["ERROR_MESSAGE"] = "Couldn't write data to file"; - LLNotifications::instance().add("ErrorMessage", args); + LLNotificationsUtil::add("ErrorMessage", args); return; } @@ -328,7 +329,7 @@ void HGFloaterTextEditor::onClickSave(void* user_data) { LLSD args; args["ERROR_MESSAGE"] = "Couldn't write data to file"; - LLNotifications::instance().add("ErrorMessage", args); + LLNotificationsUtil::add("ErrorMessage", args); return; } @@ -391,7 +392,7 @@ void HGFloaterTextEditor::onSaveComplete(const LLUUID& asset_uuid, void* user_da { LLSD args; args["ERROR_MESSAGE"] = llformat("Upload failed with status %d, also %d", status, ext_status); - LLNotifications::instance().add("ErrorMessage", args); + LLNotificationsUtil::add("ErrorMessage", args); } } diff --git a/indra/newview/hippopanelgrids.cpp b/indra/newview/hippopanelgrids.cpp index e6c363a66..f64a7466d 100644 --- a/indra/newview/hippopanelgrids.cpp +++ b/indra/newview/hippopanelgrids.cpp @@ -41,7 +41,7 @@ #include "llstartup.h" #include "lluictrlfactory.h" #include "llviewerwindow.h" - +#include "llnotificationsutil.h" // ******************************************************************** @@ -306,13 +306,13 @@ bool HippoPanelGridsImpl::saveCurGrid() if (gridname == "") gridname = ""; childSetValue("gridname", (gridname != "")? gridname: ""); if (gridname == "") { - LLNotifications::instance().add("GridsNoNick"); + LLNotificationsUtil::add("GridsNoNick"); return false; } if (gHippoGridManager->getGrid(gridname)) { LLSD args; args["NAME"] = gridname; - LLNotifications::instance().add("GridExists", args); + LLNotificationsUtil::add("GridExists", args); return false; } @@ -321,7 +321,7 @@ bool HippoPanelGridsImpl::saveCurGrid() if ((loginuri == "") || (loginuri == "")) { LLSD args; args["NAME"] = gridname; - LLNotifications::instance().add("GridsNoLoginUri", args); + LLNotificationsUtil::add("GridsNoLoginUri", args); return false; } @@ -374,7 +374,7 @@ void HippoPanelGridsImpl::retrieveGridInfo() { std::string loginuri = childGetValue("loginuri"); if ((loginuri == "") || (loginuri == "")) { - LLNotifications::instance().add("GridInfoNoLoginUri"); + LLNotificationsUtil::add("GridInfoNoLoginUri"); return; } @@ -409,7 +409,7 @@ void HippoPanelGridsImpl::retrieveGridInfo() if (grid->getSearchUrl() != "") childSetText("search", grid->getSearchUrl()); if (grid->getGridMessage() != "") childSetText("gridmessage", grid->getGridMessage()); } else { - LLNotifications::instance().add("GridInfoError"); + LLNotificationsUtil::add("GridInfoError"); } if (cleanupGrid) delete grid; @@ -537,5 +537,5 @@ void HippoPanelGridsImpl::onClickAdvanced(void *data) // static void HippoPanelGridsImpl::onClickHelpRenderCompat(void *data) { - LLNotifications::instance().add("HelpRenderCompat"); + LLNotificationsUtil::add("HelpRenderCompat"); } diff --git a/indra/newview/lgghunspell_wrapper.cpp b/indra/newview/lgghunspell_wrapper.cpp index 6eb1297f9..8c4f3c802 100644 --- a/indra/newview/lgghunspell_wrapper.cpp +++ b/indra/newview/lgghunspell_wrapper.cpp @@ -21,6 +21,7 @@ #include "llweb.h" #include "llviewercontrol.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "lldiriterator.h" #include "llfile.h" #include "llhttpclient.h" diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index 61a0b6932..bbf0c4205 100644 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -65,34 +65,25 @@ public: { llwarns << "Error on fetched data"<< llendl; clearPendingRequests(); - return; } - - bool containsSelection = content.has("selected"); - if ( containsSelection ) + else if (content.has("selected")) { - S32 dataCount = content["selected"].size(); + F32 physicsCost = 0.0f; + F32 networkCost = 0.0f; + F32 simulationCost = 0.0f; + + //LLTransactionID transactionID; - for(S32 i = 0; i < dataCount; i++) - { + //transactionID = content["selected"][i]["local_id"].asUUID(); + physicsCost = content["selected"]["physics"].asReal(); + networkCost = content["selected"]["streaming"].asReal(); + simulationCost = content["selected"]["simulation"].asReal(); - F32 physicsCost = 0.0f; - F32 networkCost = 0.0f; - F32 simulationCost = 0.0f; + SelectionCost selectionCost( /*transactionID,*/ physicsCost, networkCost, simulationCost ); - //LLTransactionID transactionID; - - //transactionID = content["selected"][i]["local_id"].asUUID(); - physicsCost = content["selected"][i]["physics"].asReal(); - networkCost = content["selected"][i]["streaming"].asReal(); - simulationCost = content["selected"][i]["simulation"].asReal(); - - SelectionCost selectionCost( /*transactionID,*/ physicsCost, networkCost, simulationCost ); - - //How do you want to handle the updating of the invoking object/ui element? - - } } + + clearPendingRequests(); } private: @@ -116,7 +107,7 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, const st // Check to see if a request for this object has already been made. if ( mPendingObjectQuota.find( *IDIter ) == mPendingObjectQuota.end() ) { - mObjectList.insert( *IDIter ); + mPendingObjectQuota.insert( *IDIter ); objectList[objectIndex++] = *IDIter; } } @@ -134,7 +125,7 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, const st else if ( selectionType == Prims ) { - keystr="prim_roots"; + keystr="selected_prims"; } else { diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index c41d70ca6..f241eeaec 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -54,6 +54,7 @@ #include "llmorphview.h" #include "llmoveview.h" #include "llchatbar.h" +#include "llnotificationsutil.h" #include "llnotify.h" #include "llparcel.h" #include "llrendersphere.h" @@ -248,7 +249,8 @@ LLAgent::LLAgent() : mFirstLogin(FALSE), mGenderChosen(FALSE), mAppearanceSerialNum(0), - + mMouselookModeInSignal(NULL), + mMouselookModeOutSignal(NULL), mPendingLure(NULL) { for (U32 i = 0; i < TOTAL_CONTROLS; i++) @@ -295,6 +297,11 @@ LLAgent::~LLAgent() { cleanup(); + delete mMouselookModeInSignal; + mMouselookModeInSignal = NULL; + delete mMouselookModeOutSignal; + mMouselookModeOutSignal = NULL; + delete mAgentAccess; mAgentAccess = NULL; delete mEffectColor; @@ -544,7 +551,7 @@ void LLAgent::setFlying(BOOL fly) { if (isAgentAvatarValid()) { - if(mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_STANDUP) != mAvatarObject->mSignaledAnimations.end()) + if(fly && mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_STANDUP) != mAvatarObject->mSignaledAnimations.end()) { return; } @@ -1438,11 +1445,11 @@ void LLAgent::stopAutoPilot(BOOL user_cancel) if (user_cancel && !mAutoPilotBehaviorName.empty()) { if (mAutoPilotBehaviorName == "Sit") - LLNotifications::instance().add("CancelledSit"); + LLNotificationsUtil::add("CancelledSit"); else if (mAutoPilotBehaviorName == "Attach") - LLNotifications::instance().add("CancelledAttach"); + LLNotificationsUtil::add("CancelledAttach"); else - LLNotifications::instance().add("Cancelled"); + LLNotificationsUtil::add("Cancelled"); } } } @@ -1846,6 +1853,11 @@ void LLAgent::endAnimationUpdateUI() LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); + + if (mMouselookModeOutSignal) + { + (*mMouselookModeOutSignal)(); + } // Only pop if we have pushed... if (TRUE == mViewsPushed) { @@ -1938,6 +1950,10 @@ void LLAgent::endAnimationUpdateUI() mViewsPushed = TRUE; + if (mMouselookModeInSignal) + { + (*mMouselookModeInSignal)(); + } gFloaterView->pushVisibleAll(FALSE, get_skip_list()); if( gMorphView ) @@ -2028,6 +2044,17 @@ void LLAgent::endAnimationUpdateUI() gAgentCamera.updateLastCamera(); } +boost::signals2::connection LLAgent::setMouselookModeInCallback( const camera_signal_t::slot_type& cb ) +{ + if (!mMouselookModeInSignal) mMouselookModeInSignal = new camera_signal_t(); + return mMouselookModeInSignal->connect(cb); +} + +boost::signals2::connection LLAgent::setMouselookModeOutCallback( const camera_signal_t::slot_type& cb ) +{ + if (!mMouselookModeOutSignal) mMouselookModeOutSignal = new camera_signal_t(); + return mMouselookModeOutSignal->connect(cb); +} //----------------------------------------------------------------------------- // heardChat() @@ -2198,6 +2225,11 @@ bool LLAgent::isGodlike() const return mAgentAccess->isGodlike(); } +bool LLAgent::isGodlikeWithoutAdminMenuFakery() const +{ + return mAgentAccess->isGodlikeWithoutAdminMenuFakery(); +} + U8 LLAgent::getGodLevel() const { return mAgentAccess->getGodLevel(); @@ -3202,7 +3234,7 @@ void LLAgent::processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void * { gAgentQueryManager.mNumPendingQueries--; - if (!isAgentAvatarValid()) + if (!isAgentAvatarValid() || gAgent.getAvatarObject()->isDead()) { llwarns << "No avatar for user in cached texture update!" << llendl; return; @@ -3604,14 +3636,29 @@ void LLAgent::setTeleportState(ETeleportState state) { LLFloaterSnapshot::hide(0); } - if (mTeleportState == TELEPORT_NONE) - { - mbTeleportKeepsLookAt = false; - } - if ((mTeleportState == TELEPORT_MOVING)) - { + + switch (mTeleportState) + + { + case TELEPORT_NONE: + mbTeleportKeepsLookAt = false; + break; + + case TELEPORT_MOVING: // We're outa here. Save "back" slurl. mTeleportSourceSLURL = getSLURL(); + break; + + case TELEPORT_ARRIVING: + // First two position updates after a teleport tend to be weird + LLViewerStats::getInstance()->mAgentPositionSnaps.mCountOfNextUpdatesToIgnore = 2; + + // Let the interested parties know we've teleported. + LLViewerParcelMgr::getInstance()->onTeleportFinished(false, getPositionGlobal()); + break; + + default: + break; } // [RLVa:KB] - Alternate: Snowglobe-1.2.4 | Version: 1.23.4 | Checked: 2009-07-07 (RLVa-1.0.0d) | Added: RLVa-0.2.0b if ( (rlv_handler_t::isEnabled()) && (TELEPORT_NONE == mTeleportState) ) @@ -3928,6 +3975,16 @@ void LLAgent::sendAgentDataUpdateRequest() sendReliableMessage(); } +void LLAgent::sendAgentUserInfoRequest() +{ + if(getID().isNull()) + return; // not logged in + gMessageSystem->newMessageFast(_PREHASH_UserInfoRequest); + gMessageSystem->nextBlockFast(_PREHASH_AgentData); + gMessageSystem->addUUIDFast(_PREHASH_AgentID, getID()); + gMessageSystem->addUUIDFast(_PREHASH_SessionID, getSessionID()); + sendReliableMessage(); +} void LLAgent::observeFriends() { @@ -3991,6 +4048,18 @@ void LLAgent::parseTeleportMessages(const std::string& xml_filename) }//end for (all message sets in xml file) } + +void LLAgent::sendAgentUpdateUserInfo(bool im_via_email, const std::string& directory_visibility ) +{ + gMessageSystem->newMessageFast(_PREHASH_UpdateUserInfo); + gMessageSystem->nextBlockFast(_PREHASH_AgentData); + gMessageSystem->addUUIDFast(_PREHASH_AgentID, getID()); + gMessageSystem->addUUIDFast(_PREHASH_SessionID, getSessionID()); + gMessageSystem->nextBlockFast(_PREHASH_UserData); + gMessageSystem->addBOOLFast(_PREHASH_IMViaEMail, im_via_email); + gMessageSystem->addString("DirectoryVisibility", directory_visibility); + gAgent.sendReliableMessage(); +} // Draw a representation of current autopilot target void LLAgent::renderAutoPilotTarget() { diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 2c593f027..6c36d5392 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -47,6 +47,8 @@ #include "llinventorymodel.h" #include "v3dmath.h" +#include + extern const BOOL ANIMATE; extern const U8 AGENT_STATE_TYPING; // Typing indication extern const U8 AGENT_STATE_EDITING; // Set when agent has objects selected @@ -108,8 +110,7 @@ public: //-------------------------------------------------------------------- public: LLAgent(); - ~LLAgent(); - + virtual ~LLAgent(); void init(); void cleanup(); @@ -453,6 +454,14 @@ public: void unpauseAnimation() { mPauseRequest = NULL; } BOOL getCustomAnim() const { return mCustomAnim; } void setCustomAnim(BOOL anim) { mCustomAnim = anim; } + + typedef boost::signals2::signal camera_signal_t; + boost::signals2::connection setMouselookModeInCallback( const camera_signal_t::slot_type& cb ); + boost::signals2::connection setMouselookModeOutCallback( const camera_signal_t::slot_type& cb ); + +private: + camera_signal_t* mMouselookModeInSignal; + camera_signal_t* mMouselookModeOutSignal; BOOL mCustomAnim; // Current animation is ANIM_AGENT_CUSTOMIZE ? LLPointer mPauseRequest; BOOL mViewsPushed; // Keep track of whether or not we have pushed views @@ -499,8 +508,16 @@ public: // Autopilot //-------------------------------------------------------------------- public: - BOOL getAutoPilot() const { return mAutoPilot; } - LLVector3d getAutoPilotTargetGlobal() const { return mAutoPilotTargetGlobal; } + BOOL getAutoPilot() const { return mAutoPilot; } + LLVector3d getAutoPilotTargetGlobal() const { return mAutoPilotTargetGlobal; } + LLUUID getAutoPilotLeaderID() const { return mLeaderID; } + F32 getAutoPilotStopDistance() const { return mAutoPilotStopDistance; } + F32 getAutoPilotTargetDist() const { return mAutoPilotTargetDist; } + BOOL getAutoPilotUseRotation() const { return mAutoPilotUseRotation; } + LLVector3 getAutoPilotTargetFacing() const { return mAutoPilotTargetFacing; } + F32 getAutoPilotRotationThreshold() const { return mAutoPilotRotationThreshold; } + std::string getAutoPilotBehaviorName() const { return mAutoPilotBehaviorName; } + void startAutoPilotGlobal(const LLVector3d &pos_global, const std::string& behavior_name = std::string(), const LLQuaternion *target_rotation = NULL, @@ -620,6 +637,7 @@ private: //-------------------------------------------------------------------- public: bool isGodlike() const; + bool isGodlikeWithoutAdminMenuFakery() const; U8 getGodLevel() const; void setAdminOverride(BOOL b); void setGodLevel(U8 god_level); @@ -773,7 +791,10 @@ public: void sendReliableMessage(); void sendAgentSetAppearance(); void sendAgentDataUpdateRequest(); - + void sendAgentUserInfoRequest(); + // IM to Email and Online visibility + void sendAgentUpdateUserInfo(bool im_to_email, const std::string& directory_visibility); + //-------------------------------------------------------------------- // Receive //-------------------------------------------------------------------- diff --git a/indra/newview/llagentaccess.cpp b/indra/newview/llagentaccess.cpp index bff32502f..a43f358e6 100644 --- a/indra/newview/llagentaccess.cpp +++ b/indra/newview/llagentaccess.cpp @@ -69,6 +69,15 @@ bool LLAgentAccess::isGodlike() const #endif } +bool LLAgentAccess::isGodlikeWithoutAdminMenuFakery() const +{ +#ifdef HACKED_GODLIKE_VIEWER + return true; +#else + return mGodLevel > GOD_NOT; +#endif +} + U8 LLAgentAccess::getGodLevel() const { #ifdef HACKED_GODLIKE_VIEWER @@ -163,6 +172,20 @@ int LLAgentAccess::convertTextToMaturity(char text) void LLAgentAccess::setMaturity(char text) { mAccess = LLAgentAccess::convertTextToMaturity(text); + U32 preferred_access = mSavedSettings.getU32("PreferredMaturity"); + while (!canSetMaturity(preferred_access)) + { + if (preferred_access == SIM_ACCESS_ADULT) + { + preferred_access = SIM_ACCESS_MATURE; + } + else + { + // Mature or invalid access gets set to PG + preferred_access = SIM_ACCESS_PG; + } + } + mSavedSettings.setU32("PreferredMaturity", preferred_access); } void LLAgentAccess::setTransition() @@ -175,3 +198,14 @@ bool LLAgentAccess::isInTransition() const return mAOTransition; } +bool LLAgentAccess::canSetMaturity(S32 maturity) +{ + if (isGodlike()) // Gods can always set their Maturity level + return true; + if (isAdult()) // Adults can always set their Maturity level + return true; + if (maturity == SIM_ACCESS_PG || (maturity == SIM_ACCESS_MATURE && isMature())) + return true; + else + return false; +} diff --git a/indra/newview/llagentaccess.h b/indra/newview/llagentaccess.h index dbd9bf8ea..49da5f44c 100644 --- a/indra/newview/llagentaccess.h +++ b/indra/newview/llagentaccess.h @@ -48,6 +48,7 @@ public: void setGodLevel(U8 god_level); bool isGodlike() const; + bool isGodlikeWithoutAdminMenuFakery() const; U8 getGodLevel() const; @@ -71,6 +72,7 @@ public: void setTransition(); // sets the transition bit, which defaults to false bool isInTransition() const; + bool canSetMaturity(S32 maturity); private: U8 mAccess; // SIM_ACCESS_MATURE etc diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index 852a58e4e..33a61ba3b 100644 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -42,7 +42,7 @@ #include "llinventorybridge.h" #include "llinventoryview.h" #include "llmd5.h" -#include "llnotifications.h" +#include "llnotificationsutil.h" #include "lltexlayer.h" #include "llviewerregion.h" #include "llvoavatar.h" @@ -724,7 +724,7 @@ void LLAgentWearables::onInitialWearableAssetArrived( LLWearable* wearable, void void LLAgentWearables::recoverMissingWearable( EWearableType type ) { // Try to recover by replacing missing wearable with a new one. - LLNotifications::instance().add("ReplacedMissingWearable"); + LLNotificationsUtil::add("ReplacedMissingWearable"); lldebugs << "Wearable " << LLWearable::typeToTypeLabel( type ) << " could not be downloaded. Replaced inventory item with default wearable." << llendl; LLWearable* new_wearable = gWearableList.createNewWearable(type); @@ -1104,7 +1104,7 @@ void LLAgentWearables::removeWearable( EWearableType type ) LLSD payload; payload["wearable_type"] = (S32)type; // Bring up view-modal dialog: Save changes? Yes, No, Cancel - LLNotifications::instance().add("WearableSave", LLSD(), payload, &LLAgentWearables::onRemoveWearableDialog); + LLNotificationsUtil::add("WearableSave", LLSD(), payload, &LLAgentWearables::onRemoveWearableDialog); return; } else @@ -1117,7 +1117,7 @@ void LLAgentWearables::removeWearable( EWearableType type ) // static bool LLAgentWearables::onRemoveWearableDialog(const LLSD& notification, const LLSD& response ) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); EWearableType type = (EWearableType)notification["payload"]["wearable_type"].asInteger(); switch( option ) { @@ -1220,7 +1220,7 @@ static bool isFirstPhysicsWearable(EWearableType type, LLInventoryItem *new_item } } }; - LLNotifications::instance().add("FirstPhysicsWearable",LLSD(),LLSD(),boost::bind(WearableDelayedCallback::setDelayedWearable, _1, _2, new_item->getUUID(),new_wearable)); + LLNotificationsUtil::add("FirstPhysicsWearable",LLSD(),LLSD(),boost::bind(WearableDelayedCallback::setDelayedWearable, _1, _2, new_item->getUUID(),new_wearable)); return true; } return false; @@ -1384,7 +1384,7 @@ void LLAgentWearables::setWearableItem( LLInventoryItem* new_item, LLWearable* n // Bring up modal dialog: Save changes? Yes, No, Cancel LLSD payload; payload["item_id"] = new_item->getUUID(); - LLNotifications::instance().add( "WearableSave", LLSD(), payload, boost::bind(LLAgentWearables::onSetWearableDialog, _1, _2, new_wearable)); + LLNotificationsUtil::add( "WearableSave", LLSD(), payload, boost::bind(LLAgentWearables::onSetWearableDialog, _1, _2, new_wearable)); return; } } @@ -1395,7 +1395,7 @@ void LLAgentWearables::setWearableItem( LLInventoryItem* new_item, LLWearable* n // static bool LLAgentWearables::onSetWearableDialog( const LLSD& notification, const LLSD& response, LLWearable* wearable ) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); LLInventoryItem* new_item = gInventory.getItem( notification["payload"]["item_id"].asUUID()); if( !new_item ) { diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 42aa24c78..41f91748b 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -93,6 +93,8 @@ #include "lldiriterator.h" #include "llimagej2c.h" #include "llprimitive.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include #if LL_WINDOWS @@ -867,7 +869,7 @@ bool LLAppViewer::init() if (LLFeatureManager::getInstance()->getGPUClass() == GPU_CLASS_UNKNOWN) { - LLNotifications::instance().add("UnknownGPU"); + LLNotificationsUtil::add("UnknownGPU"); } if(unsupported) @@ -876,7 +878,7 @@ bool LLAppViewer::init() || gSavedSettings.getBOOL("WarnUnsupportedHardware")) { args["MINSPECS"] = minSpecs; - LLNotifications::instance().add("UnsupportedHardware", args ); + LLNotificationsUtil::add("UnsupportedHardware", args ); } } @@ -1387,8 +1389,6 @@ bool LLAppViewer::cleanup() LLViewerObject::cleanupVOClasses(); - LLWaterParamManager::cleanupClass(); - LLWLParamManager::cleanupClass(); LLPostProcess::cleanupClass(); LLTracker::cleanupInstance(); @@ -2868,6 +2868,23 @@ void LLAppViewer::forceQuit() LLApp::setQuitting(); } +//TODO: remove +void LLAppViewer::fastQuit(S32 error_code) +{ + // finish pending transfers + flushVFSIO(); + // let sim know we're logging out + sendLogoutRequest(); + // flush network buffers by shutting down messaging system + end_messaging_system(); + // figure out the error code + S32 final_error_code = error_code ? error_code : (S32)isError(); + // this isn't a crash + removeMarkerFile(); + // get outta here + _exit(final_error_code); +} + void LLAppViewer::requestQuit() { llinfos << "requestQuit" << llendl; @@ -2910,7 +2927,7 @@ void LLAppViewer::requestQuit() static bool finish_quit(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option == 0) { @@ -2927,7 +2944,9 @@ void LLAppViewer::userQuit() requestQuit(); } else - LLNotifications::instance().add("ConfirmQuit"); + { + LLNotificationsUtil::add("ConfirmQuit"); + } } static bool finish_early_exit(const LLSD& notification, const LLSD& response) @@ -2940,16 +2959,9 @@ void LLAppViewer::earlyExit(const std::string& name, const LLSD& substitutions) { llwarns << "app_early_exit: " << name << llendl; gDoDisconnect = TRUE; - LLNotifications::instance().add(name, substitutions, LLSD(), finish_early_exit); + LLNotificationsUtil::add(name, substitutions, LLSD(), finish_early_exit); } -void LLAppViewer::forceExit(S32 arg) -{ - removeMarkerFile(); - - // *FIX:Mani - This kind of exit hardly seems appropriate. - exit(arg); -} void LLAppViewer::abortQuit() { @@ -3348,7 +3360,7 @@ const std::string& LLAppViewer::getWindowTitle() const // Callback from a dialog indicating user was logged out. bool finish_disconnect(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (1 == option) { @@ -3388,12 +3400,12 @@ void LLAppViewer::forceDisconnect(const std::string& mesg) { // Tell users what happened args["ERROR_MESSAGE"] = big_reason; - LLNotifications::instance().add("ErrorMessage", args, LLSD(), &finish_forced_disconnect); + LLNotificationsUtil::add("ErrorMessage", args, LLSD(), &finish_forced_disconnect); } else { args["MESSAGE"] = big_reason; - LLNotifications::instance().add("YouHaveBeenLoggedOut", args, LLSD(), &finish_disconnect ); + LLNotificationsUtil::add("YouHaveBeenLoggedOut", args, LLSD(), &finish_disconnect ); } } @@ -3747,7 +3759,7 @@ void LLAppViewer::idle() { // Handle pending gesture processing - gGestureManager.update(); + LLGestureMgr::instance().update(); gAgent.updateAgentPosition(gFrameDTClamped, yaw, current_mouse.mX, current_mouse.mY); } @@ -3992,6 +4004,44 @@ void LLAppViewer::idleShutdown() } } +void LLAppViewer::sendLogoutRequest() +{ + if(!mLogoutRequestSent && gMessageSystem) + { + + LLMessageSystem* msg = gMessageSystem; + msg->newMessageFast(_PREHASH_LogoutRequest); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + gAgent.sendReliableMessage(); + + gLogoutTimer.reset(); + gLogoutMaxTime = LOGOUT_REQUEST_TIME; + mLogoutRequestSent = TRUE; + + if(gVoiceClient) + gVoiceClient->leaveChannel(); + + //Set internal status variables and marker files + gLogoutInProgress = TRUE; + mLogoutMarkerFileName = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,LOGOUT_MARKER_FILE_NAME); + + LLAPRFile outfile ; + outfile.open(mLogoutMarkerFileName, LL_APR_W, LLAPRFile::global); + mLogoutMarkerFile = outfile.getFileHandle() ; + if (mLogoutMarkerFile) + { + llinfos << "Created logout marker file " << mLogoutMarkerFileName << llendl; + apr_file_close(mLogoutMarkerFile); + } + else + { + llwarns << "Cannot create logout marker file " << mLogoutMarkerFileName << llendl; + } + } +} + void LLAppViewer::idleNameCache() { // Neither old nor new name cache can function before agent has a region @@ -4046,43 +4096,6 @@ void LLAppViewer::idleNameCache() LLAvatarNameCache::idle(); } -void LLAppViewer::sendLogoutRequest() -{ - if(!mLogoutRequestSent) - { - - LLMessageSystem* msg = gMessageSystem; - msg->newMessageFast(_PREHASH_LogoutRequest); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - gAgent.sendReliableMessage(); - - gLogoutTimer.reset(); - gLogoutMaxTime = LOGOUT_REQUEST_TIME; - mLogoutRequestSent = TRUE; - - gVoiceClient->leaveChannel(); - - //Set internal status variables and marker files - gLogoutInProgress = TRUE; - mLogoutMarkerFileName = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,LOGOUT_MARKER_FILE_NAME); - - LLAPRFile outfile ; - outfile.open(mLogoutMarkerFileName, LL_APR_W, LLAPRFile::global); - mLogoutMarkerFile = outfile.getFileHandle() ; - if (mLogoutMarkerFile) - { - llinfos << "Created logout marker file " << mLogoutMarkerFileName << llendl; - apr_file_close(mLogoutMarkerFile); - } - else - { - llwarns << "Cannot create logout marker file " << mLogoutMarkerFileName << llendl; - } - } -} - // // Handle messages, and all message related stuff // @@ -4177,7 +4190,7 @@ void LLAppViewer::idleNetwork() } } llpushcallstacks ; - gObjectList.mNumNewObjectsStat.addValue(gObjectList.mNumNewObjects); + LLViewerStats::getInstance()->mNumNewObjectsStat.addValue(gObjectList.mNumNewObjects); // Retransmit unacknowledged packets. gXferManager->retransmitUnackedPackets(); diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index a1dde2646..71a84d589 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -66,11 +66,11 @@ public: // Application control void flushVFSIO(); // waits for vfs transfers to complete void forceQuit(); // Puts the viewer into 'shutting down without error' mode. + void fastQuit(S32 error_code = 0); // Shuts down the viewer immediately after sending a logout message void requestQuit(); // Request a quit. A kinder, gentler quit. void userQuit(); // The users asks to quit. Confirm, then requestQuit() void earlyExit(const std::string& name, const LLSD& substitutions = LLSD()); // Display an error dialog and forcibly quit. - void forceExit(S32 arg); // exit() immediately (after some cleanup). void abortQuit(); // Called to abort a quit request. bool quitRequested() { return mQuitRequested; } diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp index 435f67ebf..a121d5556 100644 --- a/indra/newview/llassetuploadresponders.cpp +++ b/indra/newview/llassetuploadresponders.cpp @@ -39,6 +39,7 @@ #include "llcompilequeue.h" #include "llfloaterbuycurrency.h" #include "llnotify.h" +#include "llinventorydefines.h" #include "llinventorymodel.h" #include "llinventoryview.h" #include "llpermissionsflags.h" @@ -59,6 +60,7 @@ // library includes #include "lleconomy.h" #include "llfocusmgr.h" +#include "llnotificationsutil.h" #include "llscrolllistctrl.h" #include "llsdserialize.h" @@ -117,14 +119,14 @@ void LLAssetUploadResponder::error(U32 statusNum, const std::string& reason) args["FILE"] = (mFileName.empty() ? mVFileID.asString() : mFileName); args["REASON"] = "Error in upload request. Please visit " "http://secondlife.com/support for help fixing this problem."; - LLNotifications::instance().add("CannotUploadReason", args); + LLNotificationsUtil::add("CannotUploadReason", args); break; case 500: default: args["FILE"] = (mFileName.empty() ? mVFileID.asString() : mFileName); args["REASON"] = "The server is experiencing unexpected " "difficulties."; - LLNotifications::instance().add("CannotUploadReason", args); + LLNotificationsUtil::add("CannotUploadReason", args); break; } LLUploadDialog::modalUploadFinished(); @@ -187,7 +189,7 @@ void LLAssetUploadResponder::uploadFailure(const LLSD& content) LLSD args; args["FILE"] = (mFileName.empty() ? mVFileID.asString() : mFileName); args["REASON"] = content["message"].asString(); - LLNotifications::instance().add("CannotUploadReason", args); + LLNotificationsUtil::add("CannotUploadReason", args); } } @@ -231,7 +233,7 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) LLSD args; args["AMOUNT"] = llformat("%d", expected_upload_cost); args["CURRENCY"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); - LLNotifications::instance().add("UploadPayment", args); + LLNotificationsUtil::add("UploadPayment", args); } // Actually add the upload to viewer inventory @@ -480,10 +482,10 @@ void LLUpdateAgentInventoryResponder::uploadComplete(const LLSD& content) { // If this gesture is active, then we need to update the in-memory // active map with the new pointer. - if (gGestureManager.isGestureActive(item_id)) + if (LLGestureMgr::instance().isGestureActive(item_id)) { LLUUID asset_id = new_item->getAssetUUID(); - gGestureManager.replaceGesture(item_id, asset_id); + LLGestureMgr::instance().replaceGesture(item_id, asset_id); gInventory.notifyObservers(); } diff --git a/indra/newview/llbbox.cpp b/indra/newview/llbbox.cpp deleted file mode 100644 index 7bc1213c5..000000000 --- a/indra/newview/llbbox.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/** - * @file llbbox.cpp - * @brief General purpose bounding box class (Not axis aligned) - * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * - * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 - * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception - * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. - * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -// self include -#include "llbbox.h" - -// library includes -#include "m4math.h" - -void LLBBox::addPointLocal(const LLVector3& p) -{ - if (mEmpty) - { - mMinLocal = p; - mMaxLocal = p; - mEmpty = FALSE; - } - else - { - mMinLocal.mV[VX] = llmin( p.mV[VX], mMinLocal.mV[VX] ); - mMinLocal.mV[VY] = llmin( p.mV[VY], mMinLocal.mV[VY] ); - mMinLocal.mV[VZ] = llmin( p.mV[VZ], mMinLocal.mV[VZ] ); - mMaxLocal.mV[VX] = llmax( p.mV[VX], mMaxLocal.mV[VX] ); - mMaxLocal.mV[VY] = llmax( p.mV[VY], mMaxLocal.mV[VY] ); - mMaxLocal.mV[VZ] = llmax( p.mV[VZ], mMaxLocal.mV[VZ] ); - } -} - -void LLBBox::addPointAgent( LLVector3 p) -{ - p -= mPosAgent; - p.rotVec( ~mRotation ); - addPointLocal( p ); -} - - -void LLBBox::addBBoxAgent(const LLBBox& b) -{ - if (mEmpty) - { - mPosAgent = b.mPosAgent; - mRotation = b.mRotation; - mMinLocal.clearVec(); - mMaxLocal.clearVec(); - } - LLVector3 vertex[8]; - vertex[0].setVec( b.mMinLocal.mV[VX], b.mMinLocal.mV[VY], b.mMinLocal.mV[VZ] ); - vertex[1].setVec( b.mMinLocal.mV[VX], b.mMinLocal.mV[VY], b.mMaxLocal.mV[VZ] ); - vertex[2].setVec( b.mMinLocal.mV[VX], b.mMaxLocal.mV[VY], b.mMinLocal.mV[VZ] ); - vertex[3].setVec( b.mMinLocal.mV[VX], b.mMaxLocal.mV[VY], b.mMaxLocal.mV[VZ] ); - vertex[4].setVec( b.mMaxLocal.mV[VX], b.mMinLocal.mV[VY], b.mMinLocal.mV[VZ] ); - vertex[5].setVec( b.mMaxLocal.mV[VX], b.mMinLocal.mV[VY], b.mMaxLocal.mV[VZ] ); - vertex[6].setVec( b.mMaxLocal.mV[VX], b.mMaxLocal.mV[VY], b.mMinLocal.mV[VZ] ); - vertex[7].setVec( b.mMaxLocal.mV[VX], b.mMaxLocal.mV[VY], b.mMaxLocal.mV[VZ] ); - - LLMatrix4 m( b.mRotation ); - m.translate( b.mPosAgent ); - m.translate( -mPosAgent ); - m.rotate( ~mRotation ); - - for( S32 i=0; i<8; i++ ) - { - addPointLocal( vertex[i] * m ); - } -} - - -void LLBBox::expand( F32 delta ) -{ - mMinLocal.mV[VX] -= delta; - mMinLocal.mV[VY] -= delta; - mMinLocal.mV[VZ] -= delta; - mMaxLocal.mV[VX] += delta; - mMaxLocal.mV[VY] += delta; - mMaxLocal.mV[VZ] += delta; -} - -LLVector3 LLBBox::localToAgent(const LLVector3& v) const -{ - LLMatrix4 m( mRotation ); - m.translate( mPosAgent ); - return v * m; -} - -LLVector3 LLBBox::agentToLocal(const LLVector3& v) const -{ - LLMatrix4 m; - m.translate( -mPosAgent ); - m.rotate( ~mRotation ); // inverse rotation - return v * m; -} - -LLVector3 LLBBox::localToAgentBasis(const LLVector3& v) const -{ - LLMatrix4 m( mRotation ); - return v * m; -} - -LLVector3 LLBBox::agentToLocalBasis(const LLVector3& v) const -{ - LLMatrix4 m( ~mRotation ); // inverse rotation - return v * m; -} - -BOOL LLBBox::containsPointLocal(const LLVector3& p) const -{ - if ( (p.mV[VX] < mMinLocal.mV[VX]) - ||(p.mV[VX] > mMaxLocal.mV[VX]) - ||(p.mV[VY] < mMinLocal.mV[VY]) - ||(p.mV[VY] > mMaxLocal.mV[VY]) - ||(p.mV[VZ] < mMinLocal.mV[VZ]) - ||(p.mV[VZ] > mMaxLocal.mV[VZ])) - { - return FALSE; - } - return TRUE; -} - -BOOL LLBBox::containsPointAgent(const LLVector3& p) const -{ - LLVector3 point_local = agentToLocal(p); - return containsPointLocal(point_local); -} - - -/* -LLBBox operator*(const LLBBox &a, const LLMatrix4 &b) -{ - return LLBBox( a.mMin * b, a.mMax * b ); -} -*/ diff --git a/indra/newview/llbbox.h b/indra/newview/llbbox.h deleted file mode 100644 index 1b4d2b4dd..000000000 --- a/indra/newview/llbbox.h +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @file llbbox.h - * @brief General purpose bounding box class - * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * - * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 - * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception - * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. - * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. - * $/LicenseInfo$ - */ - -#ifndef LL_BBOX_H -#define LL_BBOX_H - -#include "v3math.h" -#include "llquaternion.h" - -// Note: "local space" for an LLBBox is defined relative to agent space in terms of -// a translation followed by a rotation. There is no scale term since the LLBBox's min and -// max are not necessarily symetrical and define their own extents. - -class LLBBox -{ -public: - LLBBox() {mEmpty = TRUE;} - LLBBox( const LLVector3& pos_agent, - const LLQuaternion& rot, - const LLVector3& min_local, - const LLVector3& max_local ) - : - mMinLocal( min_local ), mMaxLocal( max_local ), mPosAgent(pos_agent), mRotation( rot), mEmpty( TRUE ) - {} - - // Default copy constructor is OK. - - const LLVector3& getPositionAgent() const { return mPosAgent; } - const LLQuaternion& getRotation() const { return mRotation; } - - const LLVector3& getMinLocal() const { return mMinLocal; } - void setMinLocal( const LLVector3& min ) { mMinLocal = min; } - - const LLVector3& getMaxLocal() const { return mMaxLocal; } - void setMaxLocal( const LLVector3& max ) { mMaxLocal = max; } - - LLVector3 getCenterLocal() const { return (mMaxLocal - mMinLocal) * 0.5f + mMinLocal; } - LLVector3 getCenterAgent() const { return localToAgent( getCenterLocal() ); } - - LLVector3 getExtentLocal() const { return mMaxLocal - mMinLocal; } - - BOOL containsPointLocal(const LLVector3& p) const; - BOOL containsPointAgent(const LLVector3& p) const; - - BOOL intersects(const LLBBox& b) const; - - void addPointAgent(LLVector3 p); - void addBBoxAgent(const LLBBox& b); - - void addPointLocal(const LLVector3& p); - void addBBoxLocal(const LLBBox& b) { addPointLocal( b.mMinLocal ); addPointLocal( b.mMaxLocal ); } - - void expand( F32 delta ); - - LLVector3 localToAgent( const LLVector3& v ) const; - LLVector3 agentToLocal( const LLVector3& v ) const; - - // Changes rotation but not position - LLVector3 localToAgentBasis(const LLVector3& v) const; - LLVector3 agentToLocalBasis(const LLVector3& v) const; - - -// friend LLBBox operator*(const LLBBox& a, const LLMatrix4& b); - -private: - LLVector3 mMinLocal; - LLVector3 mMaxLocal; - LLVector3 mPosAgent; // Position relative to Agent's Region - LLQuaternion mRotation; - BOOL mEmpty; // Nothing has been added to this bbox yet -}; - -//LLBBox operator*(const LLBBox &a, const LLMatrix4 &b); - - -#endif // LL_BBOX_H diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp index 0f591c968..97206d2c0 100644 --- a/indra/newview/llcallingcard.cpp +++ b/indra/newview/llcallingcard.cpp @@ -53,7 +53,8 @@ #include "llbutton.h" //#include "llinventory.h" #include "llinventorymodel.h" -#include "llnotify.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llresmgr.h" #include "llimview.h" #include "llviewercontrol.h" @@ -656,11 +657,11 @@ void LLAvatarTracker::processChange(LLMessageSystem* msg) payload["from_id"] = agent_id; if(LLRelationship::GRANT_MODIFY_OBJECTS & new_rights) { - LLNotifications::instance().add("GrantedModifyRights",args, payload); + LLNotificationsUtil::add("GrantedModifyRights",args, payload); } else { - LLNotifications::instance().add("RevokedModifyRights",args, payload); + LLNotificationsUtil::add("RevokedModifyRights",args, payload); } } (mBuddyInfo[agent_id])->setRightsFrom(new_rights); @@ -748,7 +749,7 @@ static void on_avatar_name_cache_notify(const LLUUID& agent_id, } // Popup a notify box with online status of this agent - LLNotificationPtr notification = LLNotifications::instance().add(online ? "FriendOnline" : "FriendOffline", args, payload); + LLNotificationPtr notification = LLNotificationsUtil::add(online ? "FriendOnline" : "FriendOffline", args, payload); // If there's an open IM session with this agent, send a notification there too. LLUUID session_id = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, agent_id); diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp index c3a02ce54..61d619f40 100644 --- a/indra/newview/llchatbar.cpp +++ b/indra/newview/llchatbar.cpp @@ -127,7 +127,7 @@ LLChatBar::LLChatBar() LLChatBar::~LLChatBar() { - gGestureManager.removeObserver(mObserver); + LLGestureMgr::instance().removeObserver(mObserver); delete mObserver; mObserver = NULL; // LLView destructor cleans up children @@ -247,8 +247,8 @@ void LLChatBar::refreshGestures() // collect list of unique gestures std::map unique; - LLGestureManager::item_map_t::iterator it; - for (it = gGestureManager.mActive.begin(); it != gGestureManager.mActive.end(); ++it) + LLGestureMgr::item_map_t::const_iterator it; + for (it = LLGestureMgr::instance().getActiveGestures().begin(); it != LLGestureMgr::instance().getActiveGestures().end(); ++it) { LLMultiGesture* gesture = (*it).second; if (gesture) @@ -334,7 +334,7 @@ void LLChatBar::setGestureCombo(LLComboBox* combo) // now register observer since we have a place to put the results mObserver = new LLChatBarGestureObserver(this); - gGestureManager.addObserver(mObserver); + LLGestureMgr::instance().addObserver(mObserver); // refresh list from current active gestures refreshGestures(); @@ -469,7 +469,7 @@ void LLChatBar::sendChat( EChatType type ) } } // discard returned "found" boolean - gGestureManager.triggerAndReviseString(utf8text, &utf8_revised_text); + LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text); } else { @@ -601,7 +601,7 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata ) std::string utf8_trigger = wstring_to_utf8str(raw_text); std::string utf8_out_str(utf8_trigger); - if (gGestureManager.matchPrefix(utf8_trigger, &utf8_out_str)) + if (LLGestureMgr::instance().matchPrefix(utf8_trigger, &utf8_out_str)) { if (self->mInputEditor) { @@ -826,7 +826,7 @@ void LLChatBar::onCommitGesture(LLUICtrl* ctrl, void* data) // substitution and logging. std::string text(trigger); std::string revised_text; - gGestureManager.triggerAndReviseString(text, &revised_text); + LLGestureMgr::instance().triggerAndReviseString(text, &revised_text); revised_text = utf8str_trim(revised_text); if (!revised_text.empty()) diff --git a/indra/newview/llcolorswatch.cpp b/indra/newview/llcolorswatch.cpp index 1d4ff5770..4504fb986 100644 --- a/indra/newview/llcolorswatch.cpp +++ b/indra/newview/llcolorswatch.cpp @@ -37,12 +37,12 @@ // Linden library includes #include "v4color.h" +#include "llwindow.h" // setCursor() // Project includes #include "llui.h" #include "llrender.h" #include "lluiconstants.h" -#include "llviewerwindow.h" #include "llviewercontrol.h" #include "llbutton.h" #include "lltextbox.h" @@ -330,7 +330,11 @@ void LLColorSwatchCtrl::showPicker(BOOL take_focus) if (!pickerp) { pickerp = new LLFloaterColorPicker(this, mCanApplyImmediately); - gFloaterView->getParentFloater(this)->addDependentFloater(pickerp); + LLFloater* parent = gFloaterView->getParentFloater(this); + if (parent) + { + parent->addDependentFloater(pickerp); + } mPickerHandle = pickerp->getHandle(); } diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp index 3d01eeff3..97831b4b2 100644 --- a/indra/newview/llcompilequeue.cpp +++ b/indra/newview/llcompilequeue.cpp @@ -57,6 +57,7 @@ #include "llresmgr.h" #include "llbutton.h" #include "lldir.h" +#include "llnotificationsutil.h" #include "llfloaterchat.h" #include "llviewerstats.h" #include "lluictrlfactory.h" @@ -527,7 +528,7 @@ void LLFloaterCompileQueue::onSaveTextComplete(const LLUUID& asset_id, void* use llwarns << "Unable to save text for script." << llendl; LLSD args; args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); - LLNotifications::instance().add("CompileQueueSaveText", args); + LLNotificationsUtil::add("CompileQueueSaveText", args); } } @@ -548,7 +549,7 @@ void LLFloaterCompileQueue::onSaveBytecodeComplete(const LLUUID& asset_id, void* llwarns << "Unable to save bytecode for script." << llendl; LLSD args; args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); - LLNotifications::instance().add("CompileQueueSaveBytecode", args); + LLNotificationsUtil::add("CompileQueueSaveBytecode", args); } delete data; data = NULL; diff --git a/indra/newview/llconfirmationmanager.cpp b/indra/newview/llconfirmationmanager.cpp index 00ffff79a..4b7333995 100644 --- a/indra/newview/llconfirmationmanager.cpp +++ b/indra/newview/llconfirmationmanager.cpp @@ -37,9 +37,9 @@ #include "lluictrlfactory.h" // viewer includes -#include "llviewerwindow.h" -#include "lllineeditor.h" +#include "llnotificationsutil.h" #include "llstring.h" +#include "llxmlnode.h" LLConfirmationManager::ListenerBase::~ListenerBase() { @@ -48,7 +48,7 @@ LLConfirmationManager::ListenerBase::~ListenerBase() static bool onConfirmAlert(const LLSD& notification, const LLSD& response, LLConfirmationManager::ListenerBase* listener) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option == 0) { listener->confirmed(""); @@ -61,7 +61,7 @@ static bool onConfirmAlert(const LLSD& notification, const LLSD& response, LLCon static bool onConfirmAlertPassword(const LLSD& notification, const LLSD& response, LLConfirmationManager::ListenerBase* listener) { std::string text = response["message"].asString(); - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option == 0) { @@ -83,11 +83,11 @@ void LLConfirmationManager::confirm(Type type, switch (type) { case TYPE_CLICK: - LLNotifications::instance().add("ConfirmPurchase", args, LLSD(), boost::bind(onConfirmAlert, _1, _2, listener)); + LLNotificationsUtil::add("ConfirmPurchase", args, LLSD(), boost::bind(onConfirmAlert, _1, _2, listener)); break; case TYPE_PASSWORD: - LLNotifications::instance().add("ConfirmPurchasePassword", args, LLSD(), boost::bind(onConfirmAlertPassword, _1, _2, listener)); + LLNotificationsUtil::add("ConfirmPurchasePassword", args, LLSD(), boost::bind(onConfirmAlertPassword, _1, _2, listener)); break; case TYPE_NONE: default: diff --git a/indra/newview/lldelayedgestureerror.cpp b/indra/newview/lldelayedgestureerror.cpp index 1af94b350..ead377deb 100644 --- a/indra/newview/lldelayedgestureerror.cpp +++ b/indra/newview/lldelayedgestureerror.cpp @@ -33,8 +33,9 @@ #include "llviewerprecompiledheaders.h" #include "lldelayedgestureerror.h" + #include -#include "llnotify.h" +#include "llnotificationsutil.h" #include "llcallbacklist.h" #include "llinventory.h" #include "llviewerinventory.h" @@ -119,7 +120,7 @@ bool LLDelayedGestureError::doDialog(const LLErrorEntry &ent, bool uuid_ok) } - LLNotifications::instance().add(ent.mNotifyName, args); + LLNotificationsUtil::add(ent.mNotifyName, args); return true; } diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 875ca3cff..f5754505d 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -87,7 +87,7 @@ LLDynamicArrayPtr > LLDrawable::sDeadList; void LLDrawable::incrementVisible() { sCurVisible++; - sCurPixelAngle = (F32) gViewerWindow->getWindowDisplayHeight()/LLViewerCamera::getInstance()->getView(); + sCurPixelAngle = (F32) gViewerWindow->getWindowHeightRaw()/LLViewerCamera::getInstance()->getView(); } void LLDrawable::init() { @@ -202,16 +202,22 @@ void LLDrawable::cleanupReferences() { LLFastTimer t(LLFastTimer::FTM_PIPELINE); - std::for_each(mFaces.begin(), mFaces.end(), DeletePointer()); - mFaces.clear(); + { + //LLFastTimer t(FTM_DELETE_FACES); + std::for_each(mFaces.begin(), mFaces.end(), DeletePointer()); + mFaces.clear(); + } gObjectList.removeDrawable(this); gPipeline.unlinkDrawable(this); - // Cleanup references to other objects - mVObjp = NULL; - mParent = NULL; + { + //LLFastTimer t(FTM_DEREF_DRAWABLE); + // Cleanup references to other objects + mVObjp = NULL; + mParent = NULL; + } } void LLDrawable::cleanupDeadDrawables() diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 89e46013f..e32d1b70d 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -197,6 +197,15 @@ void LLDrawPool::renderPostDeferred(S32 pass) //virtual void LLDrawPool::endRenderPass( S32 pass ) { + /*for (U32 i = 0; i < (U32)gGLManager.mNumTextureImageUnits; i++) + { //dummy cleanup of any currently bound textures + if (gGL.getTexUnit(i)->getCurrType() != LLTexUnit::TT_NONE) + { + gGL.getTexUnit(i)->unbind(gGL.getTexUnit(i)->getCurrType()); + gGL.getTexUnit(i)->disable(); + } + }*/ + gGL.getTexUnit(0)->activate(); } //virtual @@ -249,11 +258,6 @@ void LLFacePool::dirtyTextures(const std::set& textures { } -BOOL LLFacePool::moveFace(LLFace *face, LLDrawPool *poolp, BOOL copy_data) -{ - return TRUE; -} - // static S32 LLFacePool::drawLoop(face_array_t& face_list) { @@ -441,14 +445,14 @@ void LLRenderPass::renderTexture(U32 type, U32 mask) pushBatches(type, mask, TRUE); } -void LLRenderPass::pushBatches(U32 type, U32 mask, BOOL texture) +void LLRenderPass::pushBatches(U32 type, U32 mask, BOOL texture, BOOL batch_textures) { for (LLCullResult::drawinfo_list_t::iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) { LLDrawInfo* pparams = *i; if (pparams) { - pushBatch(*pparams, mask, texture); + pushBatch(*pparams, mask, texture, batch_textures); } } } @@ -467,7 +471,7 @@ void LLRenderPass::applyModelMatrix(LLDrawInfo& params) } } -void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) +void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures) { applyModelMatrix(params); @@ -475,21 +479,35 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) if (texture) { - if (params.mTexture.notNull()) + if (batch_textures && params.mTextureList.size() > 1) { - params.mTexture->addTextureStats(params.mVSize); - gGL.getTexUnit(0)->bind(params.mTexture, TRUE) ; - if (params.mTextureMatrix) + for (U32 i = 0; i < params.mTextureList.size(); ++i) { - tex_setup = true; - glMatrixMode(GL_TEXTURE); - glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix); - gPipeline.mTextureMatrixOps++; + if (params.mTextureList[i].notNull()) + { + gGL.getTexUnit(i)->bind(params.mTextureList[i], TRUE); + } } } else - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + { //not batching textures or batch has only 1 texture -- might need a texture matrix + if (params.mTexture.notNull()) + { + params.mTexture->addTextureStats(params.mVSize); + gGL.getTexUnit(0)->bind(params.mTexture, TRUE) ; + if (params.mTextureMatrix) + { + tex_setup = true; + gGL.getTexUnit(0)->activate(); + glMatrixMode(GL_TEXTURE); + glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix); + gPipeline.mTextureMatrixOps++; + } + } + else + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + } } } diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index 440a2a845..481614592 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -147,8 +147,8 @@ public: void resetDrawOrders() { } static void applyModelMatrix(LLDrawInfo& params); - virtual void pushBatches(U32 type, U32 mask, BOOL texture = TRUE); - virtual void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture); + virtual void pushBatches(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE); + virtual void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures = FALSE); virtual void renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE); virtual void renderGroups(U32 type, U32 mask, BOOL texture = TRUE); virtual void renderTexture(U32 type, U32 mask); @@ -169,10 +169,7 @@ public: LLFacePool(const U32 type); virtual ~LLFacePool(); - virtual void renderForSelect() {}; //Override if neded. BOOL isDead() { return mReferences.empty(); } - virtual void renderFaceSelected(LLFace *facep, LLViewerTexture *image, const LLColor4 &color, - const S32 index_offset = 0, const S32 index_count = 0) {}; //Override if neded. virtual LLViewerTexture *getTexture(); virtual void dirtyTextures(const std::set& textures); @@ -186,8 +183,6 @@ public: virtual void resetDrawOrders(); void resetAll(); - BOOL moveFace(LLFace *face, LLDrawPool *poolp, BOOL copy_data = FALSE); - void destroy(); void buildEdges(); diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 926fa78d7..664db16b7 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -95,31 +95,57 @@ void LLDrawPoolAlpha::endDeferredPass(S32 pass) void LLDrawPoolAlpha::renderDeferred(S32 pass) { - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.f); - { - LLFastTimer t(LLFastTimer::FTM_RENDER_GRASS); - gDeferredTreeProgram.bind(); - LLGLEnable test(GL_ALPHA_TEST); - //render alpha masked objects - LLRenderPass::renderTexture(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask()); - gDeferredTreeProgram.unbind(); - } - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); + LLFastTimer t(LLFastTimer::FTM_RENDER_GRASS); + gDeferredDiffuseAlphaMaskProgram.bind(); + gDeferredDiffuseAlphaMaskProgram.setAlphaRange(0.33f, 1.f); + + //render alpha masked objects + LLRenderPass::pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + gDeferredDiffuseAlphaMaskProgram.unbind(); } S32 LLDrawPoolAlpha::getNumPostDeferredPasses() { - return 1; + if (LLPipeline::sImpostorRender) + { //skip depth buffer filling pass when rendering impostors + return 1; + } + else if (gSavedSettings.getBOOL("RenderDepthOfField")) + { + return 2; + } + else + { + return 1; + } } void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) { LLFastTimer t(LLFastTimer::FTM_RENDER_ALPHA); - simple_shader = &gDeferredAlphaProgram; - fullbright_shader = &gDeferredFullbrightProgram; - + if (pass == 0) + { + simple_shader = &gDeferredAlphaProgram; + fullbright_shader = &gObjectFullbrightAlphaMaskProgram; + + //prime simple shader (loads shadow relevant uniforms) + gPipeline.bindDeferredShader(*simple_shader); + } + else + { + //update depth buffer sampler + gPipeline.mScreen.flush(); + gPipeline.mDeferredDepth.copyContents(gPipeline.mDeferredScreen, 0, 0, gPipeline.mDeferredScreen.getWidth(), gPipeline.mDeferredScreen.getHeight(), + 0, 0, gPipeline.mDeferredDepth.getWidth(), gPipeline.mDeferredDepth.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); + gPipeline.mDeferredDepth.bindTarget(); + simple_shader = NULL; + fullbright_shader = NULL; + gObjectFullbrightAlphaMaskProgram.bind(); + gObjectFullbrightAlphaMaskProgram.setAlphaRange(0.33f, 1.f); + } + deferred_render = TRUE; if (mVertexShaderLevel > 0) { @@ -131,6 +157,14 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) void LLDrawPoolAlpha::endPostDeferredPass(S32 pass) { + + if (pass == 1) + { + gPipeline.mDeferredDepth.flush(); + gPipeline.mScreen.bindTarget(); + gObjectFullbrightAlphaMaskProgram.unbind(); + } + deferred_render = FALSE; endRenderPass(pass); } @@ -146,13 +180,13 @@ void LLDrawPoolAlpha::beginRenderPass(S32 pass) if (LLPipeline::sUnderWaterRender) { - simple_shader = &gObjectSimpleWaterProgram; - fullbright_shader = &gObjectFullbrightWaterProgram; + simple_shader = &gObjectSimpleWaterAlphaMaskProgram; + fullbright_shader = &gObjectFullbrightWaterAlphaMaskProgram; } else { - simple_shader = &gObjectSimpleProgram; - fullbright_shader = &gObjectFullbrightProgram; + simple_shader = &gObjectSimpleAlphaMaskProgram; + fullbright_shader = &gObjectFullbrightAlphaMaskProgram; } if (mVertexShaderLevel > 0) @@ -181,8 +215,15 @@ void LLDrawPoolAlpha::render(S32 pass) LLGLSPipelineAlpha gls_pipeline_alpha; - gGL.setColorMask(true, true); - if (LLPipeline::sFastAlpha && !deferred_render) + if (deferred_render && pass == 1) + { //depth only + gGL.setColorMask(false, false); + } + else + { + gGL.setColorMask(true, true); + } + if (LLPipeline::sFastAlpha) { mColorSFactor = LLRender::BF_ONE; // } mColorDFactor = LLRender::BF_ZERO; // } these are like disabling blend on the color channels, but we're still blending on the alpha channel so that we can suppress glow @@ -190,60 +231,115 @@ void LLDrawPoolAlpha::render(S32 pass) mAlphaDFactor = LLRender::BF_ZERO; // block (zero-out) glow where the alpha test succeeds gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.33f); if (mVertexShaderLevel > 0) { - if (!LLPipeline::sRenderDeferred) + if (!LLPipeline::sRenderDeferred || !deferred_render) { simple_shader->bind(); - pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask()); + simple_shader->setAlphaRange(0.33f, 1.f); + + pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); } if (fullbright_shader) { fullbright_shader->bind(); + fullbright_shader->setAlphaRange(0.33f, 1.f); } - pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask()); - LLGLSLShader::bindNoShader(); + pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + //LLGLSLShader::bindNoShader(); } else { + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.33f); //OK gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask()); gPipeline.enableLightsDynamic(); pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask()); + gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); //OK } - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } - LLGLDepthTest depth(GL_TRUE, LLDrawPoolWater::sSkipScreenCopy ? GL_TRUE : GL_FALSE); + LLGLDepthTest depth(GL_TRUE, LLDrawPoolWater::sSkipScreenCopy || + (deferred_render && pass == 1) ? GL_TRUE : GL_FALSE); - mColorSFactor = LLRender::BF_SOURCE_ALPHA; // } regular alpha blend - mColorDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // } - mAlphaSFactor = LLRender::BF_ZERO; // } glow suppression - mAlphaDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // } - gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); + if (deferred_render && pass == 1) + { + gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); + } + else + { + mColorSFactor = LLRender::BF_SOURCE_ALPHA; // } regular alpha blend + mColorDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // } + mAlphaSFactor = LLRender::BF_ZERO; // } glow suppression + mAlphaDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // } + gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); - renderAlpha(getVertexDataMask()); + if (mVertexShaderLevel > 0) + { + if (LLPipeline::sImpostorRender) + { + fullbright_shader->bind(); + fullbright_shader->setAlphaRange(0.5f, 1.f); + simple_shader->bind(); + simple_shader->setAlphaRange(0.5f, 1.f); + } + else + { + fullbright_shader->bind(); + fullbright_shader->setAlphaRange(0.f, 1.f); + simple_shader->bind(); + simple_shader->setAlphaRange(0.f, 1.f); + } + } + else + { + if (LLPipeline::sImpostorRender) + { + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); //OK + } + else + { + gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); //OK + } + } + } + + if (mVertexShaderLevel > 0) + { + renderAlpha(getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX); + } + else + { + renderAlpha(getVertexDataMask()); + } gGL.setColorMask(true, false); - if (deferred_render && current_shader != NULL) + if (deferred_render && pass == 1) { - gPipeline.unbindDeferredShader(*current_shader); + gGL.setSceneBlendType(LLRender::BT_ALPHA); } if (sShowDebugAlpha) { - if(gPipeline.canUseWindLightShaders()) + BOOL shaders = gPipeline.canUseVertexShaders(); + if(shaders) { - LLGLSLShader::bindNoShader(); + gObjectFullbrightNonIndexedProgram.bind(); + } + else + { + gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); } - gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); glColor4f(1,0,0,1); LLViewerFetchedTexture::sSmokeImagep->addTextureStats(1024.f*1024.f); gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sSmokeImagep, TRUE) ; renderAlphaHighlight(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); + if(shaders) + { + gObjectFullbrightNonIndexedProgram.unbind(); + } } } @@ -283,24 +379,9 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) { BOOL initialized_lighting = FALSE; BOOL light_enabled = TRUE; - S32 diffuse_channel = 0; - - //BOOL is_particle = FALSE; - BOOL use_shaders = (LLPipeline::sUnderWaterRender && gPipeline.canUseVertexShaders()) - || gPipeline.canUseWindLightShadersOnObjects(); - // check to see if it's a particle and if it's "close" - { - if (LLPipeline::sImpostorRender) - { - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); - } - else - { - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); - } - } - + BOOL use_shaders = gPipeline.canUseVertexShaders(); + for (LLCullResult::sg_list_t::iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i) { LLSpatialGroup* group = *i; @@ -357,36 +438,18 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) } // If we need shaders, and we're not ALREADY using the proper shader, then bind it - // (this way we won't rebind shaders unnecessarily). - if(use_shaders && (current_shader != target_shader)) - { - llassert(target_shader != NULL); - if (deferred_render && current_shader != NULL) - { - gPipeline.unbindDeferredShader(*current_shader); - diffuse_channel = 0; - } - current_shader = target_shader; - if (deferred_render) - { - gPipeline.bindDeferredShader(*current_shader); - diffuse_channel = current_shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); - } - else - { - current_shader->bind(); - } - } - else if (!use_shaders && current_shader != NULL) - { - if (deferred_render) - { - gPipeline.unbindDeferredShader(*current_shader); - diffuse_channel = 0; - } - LLGLSLShader::bindNoShader(); - current_shader = NULL; - } + // (this way we won't rebind shaders unnecessarily). + if(use_shaders && (current_shader != target_shader)) + { + llassert(target_shader != NULL); + current_shader = target_shader; + current_shader->bind(); + } + else if (!use_shaders && current_shader != NULL) + { + LLGLSLShader::bindNoShader(); + current_shader = NULL; + } if (params.mGroup) { @@ -394,14 +457,23 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) } bool tex_setup = false; - + + if (use_shaders && params.mTextureList.size() > 1) + { + for (U32 i = 0; i < params.mTextureList.size(); ++i) + { + if (params.mTextureList[i].notNull()) + { + gGL.getTexUnit(i)->bind(params.mTextureList[i], TRUE); + } + } + } + else + { //not batching textures or batch has only 1 texture -- might need a texture matrix if (params.mTexture.notNull()) { - gGL.getTexUnit(diffuse_channel)->bind(params.mTexture.get()); - if(params.mTexture.notNull()) - { - params.mTexture->addTextureStats(params.mVSize); - } + params.mTexture->addTextureStats(params.mVSize); + gGL.getTexUnit(0)->bind(params.mTexture, TRUE) ; if (params.mTextureMatrix) { tex_setup = true; @@ -411,6 +483,11 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) gPipeline.mTextureMatrixOps++; } } + else + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + } + } params.mVertexBuffer->setBuffer(mask); params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); gPipeline.addTrianglesDrawn(params.mCount/3); @@ -445,15 +522,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) } } - if (deferred_render && current_shader != NULL) - { - gPipeline.unbindDeferredShader(*current_shader); - LLVertexBuffer::unbind(); - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); - } - + LLVertexBuffer::unbind(); + if (!light_enabled) { gPipeline.enableLightsDynamic(); diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index b3cd43bc6..a43169547 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -69,6 +69,7 @@ S32 LLDrawPoolAvatar::sDiffuseChannel = 0; #if MESH_ENABLED static bool is_deferred_render = false; +static bool is_skipped_pass = false; #endif //MESH_ENABLED extern BOOL gUseGLPick; @@ -162,9 +163,6 @@ LLMatrix4& LLDrawPoolAvatar::getModelView() //----------------------------------------------------------------------------- // render() //----------------------------------------------------------------------------- - - - void LLDrawPoolAvatar::beginDeferredPass(S32 pass) { sSkipTransparent = TRUE; @@ -177,6 +175,12 @@ void LLDrawPoolAvatar::beginDeferredPass(S32 pass) pass += 2; } + if(pass >= 3 && mRiggedFace[pass + 4].empty()) + { + is_skipped_pass = true; + return; + } + switch (pass) { case 0: @@ -212,6 +216,12 @@ void LLDrawPoolAvatar::endDeferredPass(S32 pass) pass += 2; } + if(is_skipped_pass) + { + is_skipped_pass = false; + return; + } + switch (pass) { case 0: @@ -251,6 +261,12 @@ S32 LLDrawPoolAvatar::getNumPostDeferredPasses() void LLDrawPoolAvatar::beginPostDeferredPass(S32 pass) { + if(pass >= 1 && mRiggedFace[pass + (S32)(pass != 1)].empty()) + { + is_skipped_pass = true; + return; + } + switch (pass) { case 0: @@ -310,6 +326,12 @@ void LLDrawPoolAvatar::endDeferredRiggedAlpha() #endif //MESH_ENABLED void LLDrawPoolAvatar::endPostDeferredPass(S32 pass) { + if(is_skipped_pass) + { + is_skipped_pass = false; + return; + } + switch (pass) { case 0: @@ -397,7 +419,7 @@ void LLDrawPoolAvatar::beginShadowPass(S32 pass) { gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX]; } - gGL.setAlphaRejectSettings(LLRender::CF_GREATER_EQUAL, 0.2f); + //gGL.setAlphaRejectSettings(LLRender::CF_GREATER_EQUAL, 0.2f); glColor4f(1,1,1,1); @@ -431,7 +453,6 @@ void LLDrawPoolAvatar::endShadowPass(S32 pass) sVertexProgram->unbind(); disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]); } - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } #if MESH_ENABLED @@ -519,9 +540,13 @@ S32 LLDrawPoolAvatar::getNumDeferredPasses() #endif //!MESH_ENABLED } + void LLDrawPoolAvatar::render(S32 pass) { LLFastTimer t(LLFastTimer::FTM_RENDER_CHARACTERS); + if(is_skipped_pass) + return; + if (LLPipeline::sImpostorRender) { renderAvatars(NULL, pass+2); @@ -547,6 +572,12 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass) pass += 2; } + if(pass >= 3 && mRiggedFace[pass - 3].empty()) + { + is_skipped_pass = true; + return; + } + switch (pass) { case 0: @@ -593,6 +624,12 @@ void LLDrawPoolAvatar::endRenderPass(S32 pass) pass += 2; } + if(is_skipped_pass) + { + is_skipped_pass = false; + return; + } + switch (pass) { case 0: @@ -638,12 +675,22 @@ void LLDrawPoolAvatar::beginImpostor() LLVOAvatar::sNumVisibleAvatars = 0; } + if (LLGLSLShader::sNoFixedFunction) + { + gImpostorProgram.bind(); + gImpostorProgram.setAlphaRange(0.01f, 1.f); + } + gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); sDiffuseChannel = 0; } void LLDrawPoolAvatar::endImpostor() { + if (LLGLSLShader::sNoFixedFunction) + { + gImpostorProgram.unbind(); + } gPipeline.enableLightsDynamic(); } @@ -653,16 +700,17 @@ void LLDrawPoolAvatar::beginRigid() { if (LLPipeline::sUnderWaterRender) { - sVertexProgram = &gObjectSimpleWaterProgram; + sVertexProgram = &gObjectAlphaMaskNonIndexedWaterProgram; } else { - sVertexProgram = &gObjectSimpleProgram; + sVertexProgram = &gObjectAlphaMaskNonIndexedProgram; } if (sVertexProgram != NULL) { //eyeballs render with the specular shader sVertexProgram->bind(); + sVertexProgram->setAlphaRange(0.2f, 1.f); } } else @@ -695,6 +743,7 @@ void LLDrawPoolAvatar::beginDeferredImpostor() sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); sVertexProgram->bind(); + sVertexProgram->setAlphaRange(0.01f, 1.f); } void LLDrawPoolAvatar::endDeferredImpostor() @@ -709,7 +758,7 @@ void LLDrawPoolAvatar::endDeferredImpostor() void LLDrawPoolAvatar::beginDeferredRigid() { - sVertexProgram = &gDeferredDiffuseProgram; + sVertexProgram = &gDeferredNonIndexedDiffuseProgram; sVertexProgram->bind(); } @@ -740,11 +789,11 @@ void LLDrawPoolAvatar::beginSkinned() { if (LLPipeline::sUnderWaterRender) { - sVertexProgram = &gObjectSimpleWaterProgram; + sVertexProgram = &gObjectAlphaMaskNonIndexedWaterProgram; } else { - sVertexProgram = &gObjectSimpleProgram; + sVertexProgram = &gObjectAlphaMaskNonIndexedProgram; } } @@ -776,6 +825,11 @@ void LLDrawPoolAvatar::beginSkinned() sVertexProgram->bind(); } } + + if (LLGLSLShader::sNoFixedFunction) + { + sVertexProgram->setAlphaRange(0.2f, 1.f); + } } void LLDrawPoolAvatar::endSkinned() @@ -830,11 +884,11 @@ void LLDrawPoolAvatar::beginRiggedSimple() { if (LLPipeline::sUnderWaterRender) { - sVertexProgram = &gObjectSimpleWaterProgram; + sVertexProgram = &gObjectSimpleNonIndexedWaterProgram; } else { - sVertexProgram = &gObjectSimpleProgram; + sVertexProgram = &gObjectSimpleNonIndexedProgram; } } @@ -905,11 +959,11 @@ void LLDrawPoolAvatar::beginRiggedFullbright() { if (LLPipeline::sUnderWaterRender) { - sVertexProgram = &gObjectFullbrightWaterProgram; + sVertexProgram = &gObjectFullbrightNonIndexedWaterProgram; } else { - sVertexProgram = &gObjectFullbrightProgram; + sVertexProgram = &gObjectFullbrightNonIndexedProgram; } } @@ -949,11 +1003,11 @@ void LLDrawPoolAvatar::beginRiggedShinySimple() { if (LLPipeline::sUnderWaterRender) { - sVertexProgram = &gObjectShinyWaterProgram; + sVertexProgram = &gObjectShinyNonIndexedWaterProgram; } else { - sVertexProgram = &gObjectShinyProgram; + sVertexProgram = &gObjectShinyNonIndexedProgram; } } @@ -994,11 +1048,11 @@ void LLDrawPoolAvatar::beginRiggedFullbrightShiny() { if (LLPipeline::sUnderWaterRender) { - sVertexProgram = &gObjectFullbrightShinyWaterProgram; + sVertexProgram = &gObjectFullbrightShinyNonIndexedWaterProgram; } else { - sVertexProgram = &gObjectFullbrightShinyProgram; + sVertexProgram = &gObjectFullbrightShinyNonIndexedProgram; } } @@ -1141,7 +1195,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) if (!single_avatar && !avatarp->isFullyLoaded() ) { - if (pass==1 && (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) || LLViewerPartSim::getMaxPartCount() <= 0)) + if (pass==0 && (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) || LLViewerPartSim::getMaxPartCount() <= 0)) { // debug code to draw a sphere in place of avatar gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sWhiteImagep); @@ -1348,29 +1402,38 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLVOAvatar* avatar, LLFace* return; } - LLVertexBuffer* buffer = face->getVertexBuffer(); + LLPointer buffer = face->getVertexBuffer(); + LLDrawable* drawable = face->getDrawable(); U32 data_mask = face->getRiggedVertexBufferDataMask(); - if (!buffer || + if (buffer.isNull() || buffer->getTypeMask() != data_mask || - buffer->getRequestedVerts() != vol_face.mNumVertices) + buffer->getRequestedVerts() != vol_face.mNumVertices || + buffer->getRequestedIndices() != vol_face.mNumIndices || + (drawable && drawable->isState(LLDrawable::REBUILD_ALL))) { face->setGeomIndex(0); face->setIndicesIndex(0); - face->setSize(vol_face.mNumVertices, vol_face.mNumIndices, true); - - if (sShaderLevel > 0) - { - buffer = new LLVertexBuffer(data_mask, GL_DYNAMIC_DRAW_ARB); + if (buffer.isNull() || buffer->getTypeMask() != data_mask) + { //make a new buffer + if (sShaderLevel > 0) + { + buffer = new LLVertexBuffer(data_mask, GL_DYNAMIC_DRAW_ARB); + } + else + { + buffer = new LLVertexBuffer(data_mask, GL_STREAM_DRAW_ARB); + } + buffer->allocateBuffer(vol_face.mNumVertices, vol_face.mNumIndices, true); } - else + else //resize existing buffer { - buffer = new LLVertexBuffer(data_mask, GL_STREAM_DRAW_ARB); + buffer->resizeBuffer(vol_face.mNumVertices, vol_face.mNumIndices); } - buffer->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), true); + face->setSize(vol_face.mNumVertices, vol_face.mNumIndices); face->setVertexBuffer(buffer); @@ -1472,6 +1535,11 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLVOAvatar* avatar, LLFace* } } } + + if (drawable && (face->getTEOffset() == drawable->getNumFaces()-1)) + { + drawable->clearState(LLDrawable::REBUILD_ALL); + } } void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow) @@ -1502,7 +1570,7 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow) LLVolume* volume = vobj->getVolume(); S32 te = face->getTEOffset(); - if (!volume || volume->getNumVolumeFaces() <= te) + if (!volume || volume->getNumVolumeFaces() <= te || !volume->isMeshAssetLoaded()) { continue; } @@ -1641,83 +1709,6 @@ void LLDrawPoolAvatar::renderRiggedGlow(LLVOAvatar* avatar) } #endif //MESH_ENABLED -//----------------------------------------------------------------------------- -// renderForSelect() -//----------------------------------------------------------------------------- -void LLDrawPoolAvatar::renderForSelect() -{ - if (!gRenderAvatar) - { - return; - } - - if (mDrawFace.empty()) - { - return; - } - - const LLFace *facep = mDrawFace[0]; - if (!facep->getDrawable()) - { - return; - } - LLVOAvatar *avatarp = (LLVOAvatar *)facep->getDrawable()->getVObj().get(); - - if (avatarp->isDead() || avatarp->mIsDummy || avatarp->mDrawable.isNull()) - { - return; - } - - S32 curr_shader_level = getVertexShaderLevel(); - S32 name = avatarp->mDrawable->getVObj()->mGLName; - LLColor4U color((U8)(name >> 16), (U8)(name >> 8), (U8)name); - - BOOL impostor = avatarp->isImpostor(); - if (impostor) - { - gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_VERT_COLOR); - gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_VERT_ALPHA); - - avatarp->renderImpostor(color); - - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); - return; - } - - sVertexProgram = &gAvatarPickProgram; - if (curr_shader_level > 0) - { - gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX]; - } - gGL.setAlphaRejectSettings(LLRender::CF_GREATER_EQUAL, 0.2f); - gGL.setSceneBlendType(LLRender::BT_REPLACE); - - glColor4ubv(color.mV); - - if (curr_shader_level > 0) // for hardware blending - { - sRenderingSkinned = TRUE; - sVertexProgram->bind(); - enable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]); - } - - avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); - - // if we're in software-blending, remember to set the fence _after_ we draw so we wait till this rendering is done - if (curr_shader_level > 0) - { - sRenderingSkinned = FALSE; - sVertexProgram->unbind(); - disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]); - } - - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - - // restore texture mode - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); -} - //----------------------------------------------------------------------------- // getDebugTexture() //----------------------------------------------------------------------------- diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h index 8cef71882..30fcf3794 100644 --- a/indra/newview/lldrawpoolavatar.h +++ b/indra/newview/lldrawpoolavatar.h @@ -76,7 +76,6 @@ public: /*virtual*/ void endRenderPass(S32 pass); /*virtual*/ void prerender(); /*virtual*/ void render(S32 pass = 0); - /*virtual*/ void renderForSelect(); /*virtual*/ S32 getNumDeferredPasses(); /*virtual*/ void beginDeferredPass(S32 pass); @@ -154,18 +153,20 @@ public: void renderDeferredRiggedSimple(LLVOAvatar* avatar); void renderDeferredRiggedBump(LLVOAvatar* avatar); - + //do NOT screw the the order of these. They are ordered in a way such that they cleanly align with render passes in drawpoolavatar. typedef enum { RIGGED_SIMPLE = 0, RIGGED_FULLBRIGHT, RIGGED_SHINY, RIGGED_FULLBRIGHT_SHINY, - RIGGED_GLOW, + //RIGGED_GLOW, RIGGED_ALPHA, RIGGED_FULLBRIGHT_ALPHA, - RIGGED_DEFERRED_BUMP, + RIGGED_GLOW, + //RIGGED_DEFERRED_BUMP, RIGGED_DEFERRED_SIMPLE, + RIGGED_DEFERRED_BUMP, NUM_RIGGED_PASSES, RIGGED_UNKNOWN, } eRiggedPass; diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 83495217c..20d169853 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -162,6 +162,7 @@ void LLStandardBumpmap::addstandard() LLViewerTextureManager::getFetchedTexture(LLUUID(bump_image_id)); gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mImage->setBoostLevel(LLViewerTexture::BOOST_BUMP) ; gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mImage->setLoadedCallback(LLBumpImageList::onSourceStandardLoaded, 0, TRUE, FALSE, NULL, NULL ); + gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mImage->forceToSaveRawImage(0) ; LLStandardBumpmap::sStandardBumpmapCount++; } @@ -324,6 +325,9 @@ void LLDrawPoolBump::endRenderPass(S32 pass) llassert(0); break; } + + //to cleanup texture channels + LLRenderPass::endRenderPass(pass); } //static @@ -362,6 +366,11 @@ void LLDrawPoolBump::beginShiny(bool invisible) } bindCubeMap(shader, mVertexShaderLevel, diffuse_channel, cube_channel, invisible); + + if (mVertexShaderLevel > 1) + { //indexed texture rendering, channel 0 is always diffuse + diffuse_channel = 0; + } } //static @@ -429,16 +438,16 @@ void LLDrawPoolBump::renderShiny(bool invisible) LLGLEnable blend_enable(GL_BLEND); if (!invisible && mVertexShaderLevel > 1) { - LLRenderPass::renderTexture(LLRenderPass::PASS_SHINY, sVertexMask); + LLRenderPass::pushBatches(LLRenderPass::PASS_SHINY, sVertexMask | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); } else if (!invisible) { renderGroups(LLRenderPass::PASS_SHINY, sVertexMask); } - else // invisible - { - renderGroups(LLRenderPass::PASS_INVISI_SHINY, sVertexMask); - } + //else // invisible (deprecated) + //{ + //renderGroups(LLRenderPass::PASS_INVISI_SHINY, sVertexMask); + //} } } @@ -464,11 +473,15 @@ void LLDrawPoolBump::unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& } } } - gGL.getTexUnit(diffuse_channel)->disable(); - gGL.getTexUnit(cube_channel)->disable(); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + if (!LLGLSLShader::sNoFixedFunction) + { + gGL.getTexUnit(diffuse_channel)->disable(); + gGL.getTexUnit(cube_channel)->disable(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + } } void LLDrawPoolBump::endShiny(bool invisible) @@ -537,6 +550,12 @@ void LLDrawPoolBump::beginFullbrightShiny() gGL.getTexUnit(cube_channel)->bind(cube_map); gGL.getTexUnit(0)->activate(); } + + if (mVertexShaderLevel > 1) + { //indexed texture rendering, channel 0 is always diffuse + diffuse_channel = 0; + } + mShiny = TRUE; } @@ -551,7 +570,15 @@ void LLDrawPoolBump::renderFullbrightShiny() if( gSky.mVOSkyp->getCubeMap() ) { LLGLEnable blend_enable(GL_BLEND); - LLRenderPass::renderTexture(LLRenderPass::PASS_FULLBRIGHT_SHINY, sVertexMask); + + if (mVertexShaderLevel > 1) + { + LLRenderPass::pushBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY, sVertexMask | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + } + else + { + LLRenderPass::renderTexture(LLRenderPass::PASS_FULLBRIGHT_SHINY, sVertexMask); + } } } @@ -569,19 +596,19 @@ void LLDrawPoolBump::endFullbrightShiny() cube_map->disable(); cube_map->restoreMatrix(); - if (diffuse_channel != 0) + /*if (diffuse_channel != 0) { shader->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); } gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);*/ shader->unbind(); - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + //gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); } - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + //gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + //gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); diffuse_channel = -1; cube_channel = 0; @@ -692,36 +719,44 @@ void LLDrawPoolBump::beginBump(U32 pass) // Optional second pass: emboss bump map stop_glerror(); - // TEXTURE UNIT 0 - // Output.rgb = texture at texture coord 0 - gGL.getTexUnit(0)->activate(); + if (LLGLSLShader::sNoFixedFunction) + { + gObjectBumpProgram.bind(); + } + else + { + // TEXTURE UNIT 0 + // Output.rgb = texture at texture coord 0 + gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); - gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); + gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); + gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); - // TEXTURE UNIT 1 - gGL.getTexUnit(1)->activate(); + // TEXTURE UNIT 1 + gGL.getTexUnit(1)->activate(); - gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_ADD_SIGNED, LLTexUnit::TBS_PREV_COLOR, LLTexUnit::TBS_ONE_MINUS_TEX_ALPHA); - gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); + gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_ADD_SIGNED, LLTexUnit::TBS_PREV_COLOR, LLTexUnit::TBS_ONE_MINUS_TEX_ALPHA); + gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); - // src = tex0 + (1 - tex1) - 0.5 - // = (bump0/2 + 0.5) + (1 - (bump1/2 + 0.5)) - 0.5 - // = (1 + bump0 - bump1) / 2 + // src = tex0 + (1 - tex1) - 0.5 + // = (bump0/2 + 0.5) + (1 - (bump1/2 + 0.5)) - 0.5 + // = (1 + bump0 - bump1) / 2 - // Blend: src * dst + dst * src - // = 2 * src * dst - // = 2 * ((1 + bump0 - bump1) / 2) * dst [0 - 2 * dst] - // = (1 + bump0 - bump1) * dst.rgb - // = dst.rgb + dst.rgb * (bump0 - bump1) + // Blend: src * dst + dst * src + // = 2 * src * dst + // = 2 * ((1 + bump0 - bump1) / 2) * dst [0 - 2 * dst] + // = (1 + bump0 - bump1) * dst.rgb + // = dst.rgb + dst.rgb * (bump0 - bump1) + + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + } + gGL.setSceneBlendType(LLRender::BT_MULT_X2); - gGL.getTexUnit(0)->activate(); stop_glerror(); - - gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); } //static @@ -751,14 +786,21 @@ void LLDrawPoolBump::endBump(U32 pass) return; } - // Disable texture unit 1 - gGL.getTexUnit(1)->activate(); - gGL.getTexUnit(1)->disable(); - gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT); + if (LLGLSLShader::sNoFixedFunction) + { + gObjectBumpProgram.unbind(); + } + else + { + // Disable texture blending on unit 1 + gGL.getTexUnit(1)->activate(); + //gGL.getTexUnit(1)->disable(); + gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT); - // Disable texture unit 0 - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + // Disable texture blending on unit 0 + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + } gGL.setSceneBlendType(LLRender::BT_ALPHA); } @@ -845,6 +887,9 @@ void LLDrawPoolBump::endPostDeferredPass(S32 pass) endBump(LLRenderPass::PASS_POST_BUMP); break; } + + //to disable texture channels + LLRenderPass::endRenderPass(pass); } void LLDrawPoolBump::renderPostDeferred(S32 pass) @@ -930,7 +975,6 @@ void LLBumpImageList::addTextureStats(U8 bump, const LLUUID& base_image_id, F32 void LLBumpImageList::updateImages() { - llpushcallstacks ; for (bump_image_map_t::iterator iter = mBrightnessEntries.begin(); iter != mBrightnessEntries.end(); ) { bump_image_map_t::iterator curiter = iter++; @@ -957,7 +1001,7 @@ void LLBumpImageList::updateImages() } } } - llpushcallstacks ; + for (bump_image_map_t::iterator iter = mDarknessEntries.begin(); iter != mDarknessEntries.end(); ) { bump_image_map_t::iterator curiter = iter++; @@ -984,7 +1028,6 @@ void LLBumpImageList::updateImages() } } } - llpushcallstacks ; } @@ -1032,11 +1075,12 @@ LLViewerTexture* LLBumpImageList::getBrightnessDarknessImage(LLViewerFetchedText if (!src_image->hasCallbacks()) { //if image has no callbacks but resolutions don't match, trigger raw image loaded callback again if (src_image->getWidth() != bump->getWidth() || - src_image->getHeight() != bump->getHeight() || - (LLPipeline::sRenderDeferred && bump->getComponents() != 4)) + src_image->getHeight() != bump->getHeight())// || + //(LLPipeline::sRenderDeferred && bump->getComponents() != 4)) { src_image->setBoostLevel(LLViewerTexture::BOOST_BUMP) ; src_image->setLoadedCallback( callback_func, 0, TRUE, FALSE, new LLUUID(src_image->getID()), NULL ); + src_image->forceToSaveRawImage(0) ; } } } @@ -1304,43 +1348,59 @@ void LLDrawPoolBump::renderBump(U32 type, U32 mask) } } -void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) +void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures) { applyModelMatrix(params); - if (params.mTextureMatrix) + bool tex_setup = false; + + if (batch_textures && params.mTextureList.size() > 1) { - if (mShiny) + for (U32 i = 0; i < params.mTextureList.size(); ++i) { - gGL.getTexUnit(0)->activate(); - glMatrixMode(GL_TEXTURE); + if (params.mTextureList[i].notNull()) + { + gGL.getTexUnit(i)->bind(params.mTextureList[i], TRUE); + } } - else + } + else + { //not batching textures or batch has only 1 texture -- might need a texture matrix + if (params.mTextureMatrix) { - gGL.getTexUnit(1)->activate(); - glMatrixMode(GL_TEXTURE); + if (mShiny) + { + gGL.getTexUnit(0)->activate(); + glMatrixMode(GL_TEXTURE); + } + else + { + gGL.getTexUnit(1)->activate(); + glMatrixMode(GL_TEXTURE); + glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix); + gPipeline.mTextureMatrixOps++; + gGL.getTexUnit(0)->activate(); + } + glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix); gPipeline.mTextureMatrixOps++; - gGL.getTexUnit(0)->activate(); + + tex_setup = true; } - glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix); - gPipeline.mTextureMatrixOps++; - } - - if (mShiny && mVertexShaderLevel > 1 && texture) - { - if (params.mTexture.notNull()) + if (mShiny && mVertexShaderLevel > 1 && texture) { - gGL.getTexUnit(diffuse_channel)->bind(params.mTexture) ; - params.mTexture->addTextureStats(params.mVSize); - } - else - { - gGL.getTexUnit(diffuse_channel)->unbind(LLTexUnit::TT_TEXTURE); + if (params.mTexture.notNull()) + { + gGL.getTexUnit(diffuse_channel)->bind(params.mTexture) ; + params.mTexture->addTextureStats(params.mVSize); + } + else + { + gGL.getTexUnit(diffuse_channel)->unbind(LLTexUnit::TT_TEXTURE); + } } } - if (params.mGroup) { params.mGroup->rebuildMesh(); @@ -1348,7 +1408,7 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) params.mVertexBuffer->setBuffer(mask); params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); gPipeline.addTrianglesDrawn(params.mCount/3); - if (params.mTextureMatrix) + if (tex_setup) { if (mShiny) { @@ -1369,6 +1429,11 @@ void LLDrawPoolInvisible::render(S32 pass) { //render invisiprims LLFastTimer t(LLFastTimer::FTM_RENDER_INVISIBLE); + if (gPipeline.canUseVertexShaders()) + { + gOcclusionProgram.bind(); + } + U32 invisi_mask = LLVertexBuffer::MAP_VERTEX; glStencilMask(0); gGL.setColorMask(false, false); @@ -1376,6 +1441,11 @@ void LLDrawPoolInvisible::render(S32 pass) gGL.setColorMask(true, false); glStencilMask(0xFFFFFFFF); + if (gPipeline.canUseVertexShaders()) + { + gOcclusionProgram.unbind(); + } + if (gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY)) { beginShiny(true); diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h index 9c6569665..2611730ee 100644 --- a/indra/newview/lldrawpoolbump.h +++ b/indra/newview/lldrawpoolbump.h @@ -61,7 +61,7 @@ public: virtual void endRenderPass( S32 pass ); virtual S32 getNumPasses(); /*virtual*/ void prerender(); - /*virtual*/ void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture); + /*virtual*/ void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures = FALSE); void renderBump(U32 type, U32 mask); void renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture); diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp index 7ca763a18..638563ccb 100644 --- a/indra/newview/lldrawpoolsimple.cpp +++ b/indra/newview/lldrawpoolsimple.cpp @@ -48,6 +48,39 @@ static LLGLSLShader* simple_shader = NULL; static LLGLSLShader* fullbright_shader = NULL; +void LLDrawPoolGlow::beginPostDeferredPass(S32 pass) +{ + gDeferredFullbrightProgram.bind(); +} + +void LLDrawPoolGlow::renderPostDeferred(S32 pass) +{ + LLFastTimer t(LLFastTimer::FTM_RENDER_GLOW); + LLGLEnable blend(GL_BLEND); + LLGLDisable test(GL_ALPHA_TEST); + gGL.flush(); + /// Get rid of z-fighting with non-glow pass. + LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -1.0f); + gGL.setSceneBlendType(LLRender::BT_ADD); + + LLGLDepthTest depth(GL_TRUE, GL_FALSE); + gGL.setColorMask(false, true); + + { + //LLFastTimer t(FTM_RENDER_GLOW_PUSH); + pushBatches(LLRenderPass::PASS_GLOW, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + } + + gGL.setColorMask(true, false); + gGL.setSceneBlendType(LLRender::BT_ALPHA); +} + +void LLDrawPoolGlow::endPostDeferredPass(S32 pass) +{ + gDeferredFullbrightProgram.unbind(); + LLRenderPass::endRenderPass(pass); +} void LLDrawPoolGlow::render(S32 pass) { LLFastTimer t(LLFastTimer::FTM_RENDER_GLOW); @@ -72,7 +105,15 @@ void LLDrawPoolGlow::render(S32 pass) LLGLDepthTest depth(GL_TRUE, GL_FALSE); gGL.setColorMask(false, true); - renderTexture(LLRenderPass::PASS_GLOW, getVertexDataMask()); + + if (shader_level > 1) + { + pushBatches(LLRenderPass::PASS_GLOW, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + } + else + { + renderTexture(LLRenderPass::PASS_GLOW, getVertexDataMask()); + } gGL.setColorMask(true, false); gGL.setSceneBlendType(LLRender::BT_ALPHA); @@ -83,10 +124,10 @@ void LLDrawPoolGlow::render(S32 pass) } } -void LLDrawPoolGlow::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) +void LLDrawPoolGlow::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures) { glColor4ubv(params.mGlowColor.mV); - LLRenderPass::pushBatch(params, mask, texture); + LLRenderPass::pushBatch(params, mask, texture, batch_textures); } @@ -130,10 +171,11 @@ void LLDrawPoolSimple::beginRenderPass(S32 pass) void LLDrawPoolSimple::endRenderPass(S32 pass) { LLFastTimer t(LLFastTimer::FTM_RENDER_SIMPLE); + stop_glerror(); LLRenderPass::endRenderPass(pass); - - if (mVertexShaderLevel > 0){ - + stop_glerror(); + if (mVertexShaderLevel > 0) + { simple_shader->unbind(); } } @@ -141,17 +183,29 @@ void LLDrawPoolSimple::endRenderPass(S32 pass) void LLDrawPoolSimple::render(S32 pass) { LLGLDisable blend(GL_BLEND); - LLGLDisable alpha_test(GL_ALPHA_TEST); { //render simple LLFastTimer t(LLFastTimer::FTM_RENDER_SIMPLE); gPipeline.enableLightsDynamic(); - renderTexture(LLRenderPass::PASS_SIMPLE, getVertexDataMask()); - if (LLPipeline::sRenderDeferred) + if (mVertexShaderLevel > 0) { - renderTexture(LLRenderPass::PASS_BUMP, getVertexDataMask()); + U32 mask = getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX; + + pushBatches(LLRenderPass::PASS_SIMPLE, mask, TRUE, TRUE); + + if (LLPipeline::sRenderDeferred) + { //if deferred rendering is enabled, bump faces aren't registered as simple + //render bump faces here as simple so bump faces will appear under water + pushBatches(LLRenderPass::PASS_BUMP, mask, TRUE, TRUE); + } } + else + { + LLGLDisable alpha_test(GL_ALPHA_TEST); + renderTexture(LLRenderPass::PASS_SIMPLE, getVertexDataMask()); + } + } } @@ -180,7 +234,7 @@ void LLDrawPoolSimple::renderDeferred(S32 pass) { //render simple LLFastTimer t(LLFastTimer::FTM_RENDER_SIMPLE); - renderTexture(LLRenderPass::PASS_SIMPLE, getVertexDataMask()); + pushBatches(LLRenderPass::PASS_SIMPLE, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); } } @@ -203,19 +257,21 @@ void LLDrawPoolGrass::beginRenderPass(S32 pass) if (LLPipeline::sUnderWaterRender) { - simple_shader = &gObjectSimpleWaterProgram; + simple_shader = &gObjectAlphaMaskNonIndexedWaterProgram; } else { - simple_shader = &gObjectSimpleProgram; + simple_shader = &gObjectAlphaMaskNonIndexedProgram; } if (mVertexShaderLevel > 0) { simple_shader->bind(); + simple_shader->setAlphaRange(0.5f, 1.f); } else { + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); // don't use shaders! if (gGLManager.mHasShaderObjects) { @@ -233,22 +289,23 @@ void LLDrawPoolGrass::endRenderPass(S32 pass) { simple_shader->unbind(); } + else + { + gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); + } } void LLDrawPoolGrass::render(S32 pass) { LLGLDisable blend(GL_BLEND); - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); - + { LLFastTimer t(LLFastTimer::FTM_RENDER_GRASS); LLGLEnable test(GL_ALPHA_TEST); gGL.setSceneBlendType(LLRender::BT_ALPHA); //render grass LLRenderPass::renderTexture(LLRenderPass::PASS_GRASS, getVertexDataMask()); - } - - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); + } } void LLDrawPoolGrass::beginDeferredPass(S32 pass) @@ -263,17 +320,14 @@ void LLDrawPoolGrass::endDeferredPass(S32 pass) void LLDrawPoolGrass::renderDeferred(S32 pass) { - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.f); - { LLFastTimer t(LLFastTimer::FTM_RENDER_GRASS); - gDeferredTreeProgram.bind(); - LLGLEnable test(GL_ALPHA_TEST); + //LLFastTimer t(FTM_RENDER_GRASS_DEFERRED); + gDeferredNonIndexedDiffuseAlphaMaskProgram.bind(); + gDeferredNonIndexedDiffuseAlphaMaskProgram.setAlphaRange(0.5f, 1.f); //render grass LLRenderPass::renderTexture(LLRenderPass::PASS_GRASS, getVertexDataMask()); } - - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } @@ -288,6 +342,26 @@ void LLDrawPoolFullbright::prerender() mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); } +void LLDrawPoolFullbright::beginPostDeferredPass(S32 pass) +{ + gDeferredFullbrightProgram.bind(); +} + +void LLDrawPoolFullbright::renderPostDeferred(S32 pass) +{ + LLFastTimer t(LLFastTimer::FTM_RENDER_FULLBRIGHT); + + gGL.setSceneBlendType(LLRender::BT_ALPHA); + U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXTURE_INDEX; + pushBatches(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask, TRUE, TRUE); +} + +void LLDrawPoolFullbright::endPostDeferredPass(S32 pass) +{ + gDeferredFullbrightProgram.unbind(); + LLRenderPass::endRenderPass(pass); +} + void LLDrawPoolFullbright::beginRenderPass(S32 pass) { LLFastTimer t(LLFastTimer::FTM_RENDER_FULLBRIGHT); @@ -307,34 +381,38 @@ void LLDrawPoolFullbright::endRenderPass(S32 pass) LLFastTimer t(LLFastTimer::FTM_RENDER_FULLBRIGHT); LLRenderPass::endRenderPass(pass); + stop_glerror(); + if (mVertexShaderLevel > 0) { fullbright_shader->unbind(); } + + stop_glerror(); } void LLDrawPoolFullbright::render(S32 pass) { //render fullbright LLFastTimer t(LLFastTimer::FTM_RENDER_FULLBRIGHT); + gGL.setSceneBlendType(LLRender::BT_ALPHA); + + stop_glerror(); + if (mVertexShaderLevel > 0) { fullbright_shader->bind(); fullbright_shader->uniform1f(LLViewerShaderMgr::FULLBRIGHT, 1.f); + U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXTURE_INDEX; + pushBatches(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask, TRUE, TRUE); } else { gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); + U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR; + renderTexture(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask); } - - //gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.25f); - - //LLGLEnable test(GL_ALPHA_TEST); - //LLGLEnable blend(GL_BLEND); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR; - renderTexture(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask); - //gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); + stop_glerror(); } S32 LLDrawPoolFullbright::getNumPasses() diff --git a/indra/newview/lldrawpoolsimple.h b/indra/newview/lldrawpoolsimple.h index f56151037..54277cad3 100644 --- a/indra/newview/lldrawpoolsimple.h +++ b/indra/newview/lldrawpoolsimple.h @@ -104,9 +104,9 @@ public: LLDrawPoolFullbright(); /*virtual*/ S32 getNumPostDeferredPasses() { return 1; } - /*virtual*/ void beginPostDeferredPass(S32 pass) { beginRenderPass(pass); } - /*virtual*/ void endPostDeferredPass(S32 pass) { endRenderPass(pass); } - /*virtual*/ void renderPostDeferred(S32 pass) { render(pass); } + /*virtual*/ void beginPostDeferredPass(S32 pass); + /*virtual*/ void endPostDeferredPass(S32 pass); + /*virtual*/ void renderPostDeferred(S32 pass); /*virtual*/ void beginRenderPass(S32 pass); /*virtual*/ void endRenderPass(S32 pass); @@ -132,12 +132,12 @@ public: virtual void prerender() { } /*virtual*/ S32 getNumPostDeferredPasses() { return 1; } - /*virtual*/ void beginPostDeferredPass(S32 pass) { beginRenderPass(pass); } - /*virtual*/ void endPostDeferredPass(S32 pass) { endRenderPass(pass); } - /*virtual*/ void renderPostDeferred(S32 pass) { render(pass); } + /*virtual*/ void beginPostDeferredPass(S32 pass); + /*virtual*/ void endPostDeferredPass(S32 pass); + /*virtual*/ void renderPostDeferred(S32 pass); void render(S32 pass = 0); - void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture = TRUE); + void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE); }; diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index f3f0d1a4a..8c8a2266b 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -88,6 +88,10 @@ void LLDrawPoolSky::render(S32 pass) mShader = &gObjectFullbrightWaterProgram; mShader->bind(); } + else if (LLGLSLShader::sNoFixedFunction) + { //just use the UI shader (generic single texture no lighting) + gUIProgram.bind(); + } else { // don't use shaders! diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp index b9654c57c..5a221b7a8 100644 --- a/indra/newview/lldrawpoolterrain.cpp +++ b/indra/newview/lldrawpoolterrain.cpp @@ -147,7 +147,7 @@ void LLDrawPoolTerrain::beginRenderPass( S32 pass ) void LLDrawPoolTerrain::endRenderPass( S32 pass ) { LLFastTimer t(LLFastTimer::FTM_RENDER_TERRAIN); - LLFacePool::endRenderPass(pass); + //LLFacePool::endRenderPass(pass); if (mVertexShaderLevel > 1 && sShader->mShaderLevel > 0) { sShader->unbind(); @@ -220,7 +220,7 @@ void LLDrawPoolTerrain::render(S32 pass) { //use fullbright shader for highlighting LLGLSLShader* old_shader = sShader; sShader->unbind(); - sShader = &gObjectFullbrightProgram; + sShader = &gObjectFullbrightNonIndexedProgram; sShader->bind(); LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL); glPolygonOffset(-1.0f, -1.0f); @@ -905,28 +905,6 @@ void LLDrawPoolTerrain::renderOwnership() glMatrixMode(GL_MODELVIEW); } - -void LLDrawPoolTerrain::renderForSelect() -{ - if (mDrawFace.empty()) - { - return; - } - - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - for (std::vector::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace *facep = *iter; - if (!facep->getDrawable()->isDead() && (facep->getDrawable()->getVObj()->mGLName)) - { - facep->renderForSelect(LLVertexBuffer::MAP_VERTEX); - } - } -} - void LLDrawPoolTerrain::dirtyTextures(const std::set& textures) { LLViewerFetchedTexture* tex = LLViewerTextureManager::staticCastToFetchedTexture(mTexturep) ; diff --git a/indra/newview/lldrawpoolterrain.h b/indra/newview/lldrawpoolterrain.h index 61cec0e47..8eb5c5737 100644 --- a/indra/newview/lldrawpoolterrain.h +++ b/indra/newview/lldrawpoolterrain.h @@ -74,7 +74,6 @@ public: /*virtual*/ void prerender(); /*virtual*/ void beginRenderPass( S32 pass ); /*virtual*/ void endRenderPass( S32 pass ); - /*virtual*/ void renderForSelect(); /*virtual*/ void dirtyTextures(const std::set& textures); /*virtual*/ LLViewerTexture *getTexture(); /*virtual*/ LLViewerTexture *getDebugTexture(); diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp index 762a087ff..5da531216 100644 --- a/indra/newview/lldrawpooltree.cpp +++ b/indra/newview/lldrawpooltree.cpp @@ -37,7 +37,6 @@ #include "lldrawable.h" #include "llface.h" #include "llsky.h" -#include "llviewerwindow.h" #include "llvotree.h" #include "pipeline.h" #include "llviewercamera.h" @@ -68,24 +67,25 @@ void LLDrawPoolTree::prerender() void LLDrawPoolTree::beginRenderPass(S32 pass) { LLFastTimer t(LLFastTimer::FTM_RENDER_TREES); - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); - + if (LLPipeline::sUnderWaterRender) { - shader = &gObjectSimpleWaterProgram; + shader = &gObjectAlphaMaskNonIndexedWaterProgram; } else { - shader = &gObjectSimpleProgram; + shader = &gObjectAlphaMaskNonIndexedProgram; } - if (gPipeline.canUseWindLightShadersOnObjects()) + if (gPipeline.canUseVertexShaders()) { shader->bind(); + shader->setAlphaRange(0.5f, 1.f); } else { gPipeline.enableLightsDynamic(); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); } } @@ -98,7 +98,7 @@ void LLDrawPoolTree::render(S32 pass) return; } - LLGLEnable test(GL_ALPHA_TEST); + LLGLState test(GL_ALPHA_TEST, LLGLSLShader::sNoFixedFunction ? 0 : 1); LLOverrideFaceColor color(this, 1.f, 1.f, 1.f, 1.f); static const LLCachedControl render_animate_trees("RenderAnimateTrees",false); @@ -128,12 +128,16 @@ void LLDrawPoolTree::render(S32 pass) void LLDrawPoolTree::endRenderPass(S32 pass) { LLFastTimer t(LLFastTimer::FTM_RENDER_TREES); - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); - + if (gPipeline.canUseWindLightShadersOnObjects()) { shader->unbind(); } + + if (mVertexShaderLevel <= 0) + { + gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); + } } //============================================ @@ -142,10 +146,10 @@ void LLDrawPoolTree::endRenderPass(S32 pass) void LLDrawPoolTree::beginDeferredPass(S32 pass) { LLFastTimer t(LLFastTimer::FTM_RENDER_TREES); - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.f); - - shader = &gDeferredTreeProgram; + + shader = &gDeferredNonIndexedDiffuseAlphaMaskProgram; shader->bind(); + shader->setAlphaRange(0.5f, 1.f); } void LLDrawPoolTree::renderDeferred(S32 pass) @@ -156,7 +160,6 @@ void LLDrawPoolTree::renderDeferred(S32 pass) void LLDrawPoolTree::endDeferredPass(S32 pass) { LLFastTimer t(LLFastTimer::FTM_RENDER_TREES); - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); shader->unbind(); } @@ -167,12 +170,12 @@ void LLDrawPoolTree::endDeferredPass(S32 pass) void LLDrawPoolTree::beginShadowPass(S32 pass) { LLFastTimer t(LLFastTimer::FTM_SHADOW_TREE); - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); + static const LLCachedControl render_deferred_offset("RenderDeferredTreeShadowOffset",1.f); static const LLCachedControl render_deferred_bias("RenderDeferredTreeShadowBias",1.f); glPolygonOffset(render_deferred_offset,render_deferred_bias); - - gDeferredShadowProgram.bind(); + gDeferredShadowAlphaMaskProgram.bind(); + gDeferredShadowAlphaMaskProgram.setAlphaRange(0.5f, 1.f); } void LLDrawPoolTree::renderShadow(S32 pass) @@ -183,77 +186,10 @@ void LLDrawPoolTree::renderShadow(S32 pass) void LLDrawPoolTree::endShadowPass(S32 pass) { LLFastTimer t(LLFastTimer::FTM_SHADOW_TREE); - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); - static const LLCachedControl render_deferred_offset("RenderDeferredTreeShadowOffset",1.f); - static const LLCachedControl render_deferred_bias("RenderDeferredTreeShadowBias",1.f); + + static const LLCachedControl render_deferred_offset("RenderDeferredSpotShadowOffset",1.f); + static const LLCachedControl render_deferred_bias("RenderDeferredSpotShadowBias",1.f); glPolygonOffset(render_deferred_offset,render_deferred_bias); - - //gDeferredShadowProgram.unbind(); -} - - -void LLDrawPoolTree::renderForSelect() -{ - if (mDrawFace.empty()) - { - return; - } - - LLOverrideFaceColor color(this, 1.f, 1.f, 1.f, 1.f); - - LLGLSObjectSelectAlpha gls_alpha; - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - gGL.setSceneBlendType(LLRender::BT_REPLACE); - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); - - gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); - gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_VERT_ALPHA); - - static const LLCachedControl render_animate_trees("RenderAnimateTrees",false); - if (render_animate_trees) - { - renderTree(TRUE); - } - else - { - gGL.getTexUnit(sDiffTex)->bind(mTexturep); - - for (std::vector::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace *face = *iter; - LLDrawable *drawablep = face->getDrawable(); - - if (drawablep->isDead() || face->getVertexBuffer()) - { - continue; - } - - // Render each of the trees - LLVOTree *treep = (LLVOTree *)drawablep->getVObj().get(); - - LLColor4U color(255,255,255,255); - - if (treep->mGLName != 0) - { - S32 name = treep->mGLName; - color = LLColor4U((U8)(name >> 16), (U8)(name >> 8), (U8)name, 255); - - LLFacePool::LLOverrideFaceColor col(this, color); - - LLVertexBuffer *buff = face->getVertexBuffer(); - buff->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK); - buff->drawRange(LLRender::TRIANGLES, 0, buff->getRequestedVerts()-1, buff->getRequestedIndices(), 0); - gPipeline.addTrianglesDrawn(buff->getRequestedIndices()/3); - } - } - } - - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); } void LLDrawPoolTree::renderTree(BOOL selecting) diff --git a/indra/newview/lldrawpooltree.h b/indra/newview/lldrawpooltree.h index bc7711d4e..714dc25e1 100644 --- a/indra/newview/lldrawpooltree.h +++ b/indra/newview/lldrawpooltree.h @@ -68,7 +68,6 @@ public: /*virtual*/ void render(S32 pass = 0); /*virtual*/ void endRenderPass( S32 pass ); /*virtual*/ S32 getNumPasses() { return 1; } - /*virtual*/ void renderForSelect(); /*virtual*/ BOOL verify() const; /*virtual*/ LLViewerTexture *getTexture(); /*virtual*/ LLViewerTexture *getDebugTexture(); diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 2b93af7b1..7dcc82218 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -114,7 +114,7 @@ void LLDrawPoolWater::prerender() // got rid of modulation by light color since it got a little too // green at sunset and sl-57047 (underwater turns black at 8:00) - sWaterFogColor = LLWaterParamManager::instance()->getFogColor(); + sWaterFogColor = LLWaterParamManager::getInstance()->getFogColor(); sWaterFogColor.mV[3] = 0; } @@ -532,7 +532,7 @@ void LLDrawPoolWater::shade() //bind normal map S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP); - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamManager * param_mgr = LLWaterParamManager::getInstance(); // change mWaterNormp if needed if (mWaterNormp->getID() != param_mgr->getNormalMapID()) diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 4a6321a69..e6da1e631 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -40,6 +40,8 @@ #include "llviewercamera.h" #include "llimage.h" #include "llwlparammanager.h" +#include "llviewershadermgr.h" +#include "llglslshader.h" #include "llsky.h" #include "llvowlsky.h" #include "llviewerregion.h" @@ -50,6 +52,8 @@ LLPointer LLDrawPoolWLSky::sCloudNoiseTexture = NULL; LLPointer LLDrawPoolWLSky::sCloudNoiseRawImage = NULL; +static LLGLSLShader* cloud_shader = NULL; +static LLGLSLShader* sky_shader = NULL; LLDrawPoolWLSky::LLDrawPoolWLSky(void) : @@ -64,15 +68,26 @@ LLDrawPoolWLSky::LLDrawPoolWLSky(void) : llerrs << "Error: Failed to load cloud noise image " << cloudNoiseFilename << llendl; } - cloudNoiseFile->load(cloudNoiseFilename); + if(cloudNoiseFile->load(cloudNoiseFilename)) + { + sCloudNoiseRawImage = new LLImageRaw(); - sCloudNoiseRawImage = new LLImageRaw(); + if(cloudNoiseFile->decode(sCloudNoiseRawImage, 0.0f)) + { + //debug use + lldebugs << "cloud noise raw image width: " << sCloudNoiseRawImage->getWidth() << " : height: " << sCloudNoiseRawImage->getHeight() << " : components: " << + (S32)sCloudNoiseRawImage->getComponents() << " : data size: " << sCloudNoiseRawImage->getDataSize() << llendl ; + llassert_always(sCloudNoiseRawImage->getData()) ; - cloudNoiseFile->decode(sCloudNoiseRawImage, 0.0f); + sCloudNoiseTexture = LLViewerTextureManager::getLocalTexture(sCloudNoiseRawImage.get(), TRUE); + } + else + { + sCloudNoiseRawImage = NULL ; + } + } - sCloudNoiseTexture = LLViewerTextureManager::getLocalTexture(sCloudNoiseRawImage.get(), TRUE); - - LLWLParamManager::instance()->propagateParameters(); + LLWLParamManager::getInstance()->propagateParameters(); } LLDrawPoolWLSky::~LLDrawPoolWLSky() @@ -89,12 +104,32 @@ LLViewerTexture *LLDrawPoolWLSky::getDebugTexture() void LLDrawPoolWLSky::beginRenderPass( S32 pass ) { + sky_shader = + LLPipeline::sUnderWaterRender ? + &gObjectSimpleWaterProgram : + &gWLSkyProgram; + + cloud_shader = + LLPipeline::sUnderWaterRender ? + &gObjectSimpleWaterProgram : + &gWLCloudProgram; } void LLDrawPoolWLSky::endRenderPass( S32 pass ) { } +void LLDrawPoolWLSky::beginDeferredPass(S32 pass) +{ + sky_shader = &gDeferredWLSkyProgram; + cloud_shader = &gDeferredWLCloudProgram; +} + +void LLDrawPoolWLSky::endDeferredPass(S32 pass) +{ + +} + void LLDrawPoolWLSky::renderDome(F32 camHeightLocal, LLGLSLShader * shader) const { LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); @@ -134,19 +169,14 @@ void LLDrawPoolWLSky::renderSkyHaze(F32 camHeightLocal) const { if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY)) { - LLGLSLShader* shader = - LLPipeline::sUnderWaterRender ? - &gObjectSimpleWaterProgram : - &gWLSkyProgram; - LLGLDisable blend(GL_BLEND); - shader->bind(); + sky_shader->bind(); /// Render the skydome - renderDome(camHeightLocal, shader); + renderDome(camHeightLocal, sky_shader); - shader->unbind(); + sky_shader->unbind(); } } @@ -172,7 +202,7 @@ void LLDrawPoolWLSky::renderStars(void) const // clamping and allow the star_alpha param to brighten the stars. bool error; LLColor4 star_alpha(LLColor4::black); - star_alpha.mV[3] = LLWLParamManager::instance()->mCurParams.getFloat("star_brightness", error) / 2.f; + star_alpha.mV[3] = LLWLParamManager::getInstance()->mCurParams.getFloat("star_brightness", error) / 2.f; llassert_always(!error); // gl_FragColor.rgb = gl_Color.rgb; @@ -182,43 +212,50 @@ void LLDrawPoolWLSky::renderStars(void) const gGL.pushMatrix(); glRotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f); - gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_VERT_COLOR); - gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT_X2, LLTexUnit::TBS_CONST_ALPHA, LLTexUnit::TBS_TEX_ALPHA); - /*//Old - gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); - gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT_X2, LLTexUnit::TBS_PREV_ALPHA, LLTexUnit::TBS_CONST_ALPHA); */ - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, star_alpha.mV); - + // gl_FragColor.rgb = gl_Color.rgb; + // gl_FragColor.a = gl_Color.a * star_alpha.a; + if (LLGLSLShader::sNoFixedFunction) + { + gCustomAlphaProgram.bind(); + gCustomAlphaProgram.uniform1f("custom_alpha", star_alpha.mV[3]); + } + else + { + gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_VERT_COLOR); + gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT_X2, LLTexUnit::TBS_CONST_ALPHA, LLTexUnit::TBS_TEX_ALPHA); + glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, star_alpha.mV); + } + gSky.mVOWLSkyp->drawStars(); - gGL.popMatrix(); //New - //glPointSize(1.f); - - // and disable the combiner states - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + gGL.popMatrix(); + + if (LLGLSLShader::sNoFixedFunction) + { + gCustomAlphaProgram.unbind(); + } + else + { + // and disable the combiner states + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + } } void LLDrawPoolWLSky::renderSkyClouds(F32 camHeightLocal) const { - if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_WL_CLOUDS)) + if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_WL_CLOUDS) && sCloudNoiseTexture.notNull()) { - LLGLSLShader* shader = - LLPipeline::sUnderWaterRender ? - &gObjectSimpleWaterProgram : - &gWLCloudProgram; - LLGLEnable blend(GL_BLEND); gGL.setSceneBlendType(LLRender::BT_ALPHA); - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); - + gGL.getTexUnit(0)->bind(sCloudNoiseTexture); - shader->bind(); + cloud_shader->bind(); /// Render the skydome - renderDome(camHeightLocal, shader); + renderDome(camHeightLocal, cloud_shader); - shader->unbind(); + cloud_shader->unbind(); } } @@ -244,6 +281,10 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() if (gSky.mVOSkyp->getMoon().getDraw() && face->getGeomCount()) { + if (gPipeline.canUseVertexShaders()) + { + gUIProgram.bind(); + } // *NOTE: even though we already bound this texture above for the // stars register combiners, we bind again here for defensive reasons, // since LLImageGL::bind detects that it's a noop, and optimizes it out. @@ -259,9 +300,61 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() LLFacePool::LLOverrideFaceColor color_override(this, color); face->renderIndexed(); + + if (gPipeline.canUseVertexShaders()) + { + gUIProgram.unbind(); + } } } +void LLDrawPoolWLSky::renderDeferred(S32 pass) +{ + if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY)) + { + return; + } + LLFastTimer ftm(LLFastTimer::FTM_RENDER_WL_SKY); + + const F32 camHeightLocal = LLWLParamManager::getInstance()->getDomeOffset() * LLWLParamManager::getInstance()->getDomeRadius(); + + LLGLSNoFog disableFog; + LLGLDepthTest depth(GL_TRUE, GL_FALSE); + LLGLDisable clip(GL_CLIP_PLANE0); + + gGL.setColorMask(true, false); + + LLGLSquashToFarClip far_clip(glh_get_current_projection()); + + renderSkyHaze(camHeightLocal); + + LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); + glPushMatrix(); + + + glTranslatef(origin.mV[0], origin.mV[1], origin.mV[2]); + + gDeferredStarProgram.bind(); + // *NOTE: have to bind a texture here since register combiners blending in + // renderStars() requires something to be bound and we might as well only + // bind the moon's texture once. + gGL.getTexUnit(0)->bind(gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]->getTexture()); + + renderHeavenlyBodies(); + + renderStars(); + + gDeferredStarProgram.unbind(); + + glPopMatrix(); + + renderSkyClouds(camHeightLocal); + + gGL.setColorMask(true, true); + //gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + +} + void LLDrawPoolWLSky::render(S32 pass) { if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY)) @@ -270,7 +363,7 @@ void LLDrawPoolWLSky::render(S32 pass) } LLFastTimer ftm(LLFastTimer::FTM_RENDER_WL_SKY); - const F32 camHeightLocal = LLWLParamManager::instance()->getDomeOffset() * LLWLParamManager::instance()->getDomeRadius(); + const F32 camHeightLocal = LLWLParamManager::getInstance()->getDomeOffset() * LLWLParamManager::getInstance()->getDomeRadius(); LLGLSNoFog disableFog; LLGLDepthTest depth(GL_TRUE, GL_FALSE); @@ -330,5 +423,8 @@ void LLDrawPoolWLSky::cleanupGL() //static void LLDrawPoolWLSky::restoreGL() { - sCloudNoiseTexture = LLViewerTextureManager::getLocalTexture(sCloudNoiseRawImage.get(), TRUE); + if(sCloudNoiseRawImage.notNull()) + { + sCloudNoiseTexture = LLViewerTextureManager::getLocalTexture(sCloudNoiseRawImage.get(), TRUE); + } } diff --git a/indra/newview/lldrawpoolwlsky.h b/indra/newview/lldrawpoolwlsky.h index 9059f6382..1057ef7bd 100644 --- a/indra/newview/lldrawpoolwlsky.h +++ b/indra/newview/lldrawpoolwlsky.h @@ -50,10 +50,10 @@ public: /*virtual*/ BOOL isDead() { return FALSE; } - /*virtual*/ S32 getNumPostDeferredPasses() { return getNumPasses(); } - /*virtual*/ void beginPostDeferredPass(S32 pass) { beginRenderPass(pass); } - /*virtual*/ void endPostDeferredPass(S32 pass) { endRenderPass(pass); } - /*virtual*/ void renderPostDeferred(S32 pass) { render(pass); } + /*virtual*/ S32 getNumDeferredPasses() { return 1; } + /*virtual*/ void beginDeferredPass(S32 pass); + /*virtual*/ void endDeferredPass(S32 pass); + /*virtual*/ void renderDeferred(S32 pass); /*virtual*/ LLViewerTexture *getDebugTexture(); /*virtual*/ void beginRenderPass( S32 pass ); diff --git a/indra/newview/lldriverparam.cpp b/indra/newview/lldriverparam.cpp index 7fcfa5504..fb220d24a 100644 --- a/indra/newview/lldriverparam.cpp +++ b/indra/newview/lldriverparam.cpp @@ -160,7 +160,7 @@ BOOL LLDriverParam::parseData(LLXmlTreeNode* node) } #endif -void LLDriverParam::setWeight(F32 weight, BOOL set_by_user) +void LLDriverParam::setWeight(F32 weight, BOOL upload_bake) { F32 min_weight = getMinWeight(); F32 max_weight = getMaxWeight(); @@ -219,7 +219,7 @@ void LLDriverParam::setWeight(F32 weight, BOOL set_by_user) driven_weight = driven_min; } - driven->mParam->setWeight( driven_weight, set_by_user ); + setDrivenWeight(driven,driven_weight,upload_bake); continue; } else @@ -243,13 +243,13 @@ void LLDriverParam::setWeight(F32 weight, BOOL set_by_user) driven_weight = driven_min; } - driven->mParam->setWeight( driven_weight, set_by_user ); + setDrivenWeight(driven,driven_weight,upload_bake); continue; } } driven_weight = getDrivenWeight(driven, mCurWeight); - driven->mParam->setWeight( driven_weight, set_by_user ); + setDrivenWeight(driven,driven_weight,upload_bake); } } @@ -379,9 +379,9 @@ const LLVector3* LLDriverParam::getNextDistortion(U32 *index, LLPolyMesh **poly_ //----------------------------------------------------------------------------- // setAnimationTarget() //----------------------------------------------------------------------------- -void LLDriverParam::setAnimationTarget( F32 target_value, BOOL set_by_user ) +void LLDriverParam::setAnimationTarget( F32 target_value, BOOL upload_bake ) { - LLVisualParam::setAnimationTarget(target_value, set_by_user); + LLVisualParam::setAnimationTarget(target_value, upload_bake); for( entry_list_t::iterator iter = mDriven.begin(); iter != mDriven.end(); iter++ ) { @@ -390,16 +390,16 @@ void LLDriverParam::setAnimationTarget( F32 target_value, BOOL set_by_user ) // this isn't normally necessary, as driver params handle interpolation of their driven params // but texture params need to know to assume their final value at beginning of interpolation - driven->mParam->setAnimationTarget(driven_weight, set_by_user); + driven->mParam->setAnimationTarget(driven_weight, upload_bake); } } //----------------------------------------------------------------------------- // stopAnimating() //----------------------------------------------------------------------------- -void LLDriverParam::stopAnimating(BOOL set_by_user) +void LLDriverParam::stopAnimating(BOOL upload_bake) { - LLVisualParam::stopAnimating(set_by_user); + LLVisualParam::stopAnimating(upload_bake); for( entry_list_t::iterator iter = mDriven.begin(); iter != mDriven.end(); iter++ ) { @@ -464,3 +464,19 @@ F32 LLDriverParam::getDrivenWeight(const LLDrivenEntry* driven, F32 input_weight return driven_weight; } + +void LLDriverParam::setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight, bool upload_bake) +{ + /*if(isAgentAvatarValid() && + mWearablep && + driven->mParam->getCrossWearable() && + mWearablep->isOnTop()) + { + // call setWeight through LLVOAvatarSelf so other wearables can be updated with the correct values + gAgentAvatarp->setVisualParamWeight( (LLVisualParam*)driven->mParam, driven_weight, upload_bake ); + } + else*/ + { + driven->mParam->setWeight( driven_weight, upload_bake ); + } +} diff --git a/indra/newview/lldriverparam.h b/indra/newview/lldriverparam.h index 2e53ce563..f881e445e 100644 --- a/indra/newview/lldriverparam.h +++ b/indra/newview/lldriverparam.h @@ -92,9 +92,9 @@ public: // LLVisualParam Virtual functions ///*virtual*/ BOOL parseData(LLXmlTreeNode* node); /*virtual*/ void apply( ESex sex ) {} // apply is called separately for each driven param. - /*virtual*/ void setWeight(F32 weight, BOOL set_by_user); - /*virtual*/ void setAnimationTarget( F32 target_value, BOOL set_by_user ); - /*virtual*/ void stopAnimating(BOOL set_by_user); + /*virtual*/ void setWeight(F32 weight, BOOL upload_bake); + /*virtual*/ void setAnimationTarget( F32 target_value, BOOL upload_bake ); + /*virtual*/ void stopAnimating(BOOL upload_bake); // LLViewerVisualParam Virtual functions /*virtual*/ F32 getTotalDistortion(); @@ -103,8 +103,10 @@ public: /*virtual*/ LLVector3 getVertexDistortion(S32 index, LLPolyMesh *poly_mesh); /*virtual*/ const LLVector3* getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh); /*virtual*/ const LLVector3* getNextDistortion(U32 *index, LLPolyMesh **poly_mesh); + protected: F32 getDrivenWeight(const LLDrivenEntry* driven, F32 input_weight); + void setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight, bool upload_bake); LLVector3 mDefaultVec; // temp holder diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp index 609fdc64b..b53cfd649 100644 --- a/indra/newview/lldynamictexture.cpp +++ b/indra/newview/lldynamictexture.cpp @@ -34,6 +34,7 @@ #include "lldynamictexture.h" #include "llglheaders.h" +#include "llwindow.h" // getPosition() #include "llviewerwindow.h" #include "llviewercamera.h" #include "llviewercontrol.h" @@ -41,6 +42,7 @@ #include "llvertexbuffer.h" #include "llviewerdisplay.h" #include "llrender.h" +#include "llglslshader.h" // static LLViewerDynamicTexture::instance_list_t LLViewerDynamicTexture::sInstances[ LLViewerDynamicTexture::ORDER_COUNT ]; @@ -55,6 +57,13 @@ LLViewerDynamicTexture::LLViewerDynamicTexture(S32 width, S32 height, S32 compon { llassert((1 <= components) && (components <= 4)); + if(gGLManager.mDebugGPU) + { + if(components == 3) + { + mComponents = 4 ; //convert to 32bits. + } + } generateGLTexture(); llassert( 0 <= order && order < ORDER_COUNT ); @@ -123,7 +132,7 @@ void LLViewerDynamicTexture::preRender(BOOL clear_depth) // force rendering to on-screen portion of frame buffer LLCoordScreen window_pos; gViewerWindow->getWindow()->getPosition( &window_pos ); - mOrigin.set(0, gViewerWindow->getWindowDisplayHeight() - mFullHeight); // top left corner + mOrigin.set(0, gViewerWindow->getWindowHeightRaw() - mFullHeight); // top left corner if (window_pos.mX < 0) { @@ -178,7 +187,7 @@ void LLViewerDynamicTexture::postRender(BOOL success) } // restore viewport - gViewerWindow->setupViewport(); + gViewerWindow->setup2DViewport(); // restore camera LLViewerCamera* camera = LLViewerCamera::getInstance(); @@ -202,6 +211,14 @@ BOOL LLViewerDynamicTexture::updateAllInstances() return TRUE; } + LLGLSLShader::bindNoShader(); + LLVertexBuffer::unbind(); + + bool no_ff = LLGLSLShader::sNoFixedFunction; + static const LLCachedControl force_fixed_functions("ShyotlUseLegacyDynamicTexture",false); + if(force_fixed_functions) + LLGLSLShader::sNoFixedFunction = false; + BOOL result = FALSE; BOOL ret = FALSE ; for( S32 order = 0; order < ORDER_COUNT; order++ ) @@ -232,6 +249,8 @@ BOOL LLViewerDynamicTexture::updateAllInstances() } } + LLGLSLShader::sNoFixedFunction = no_ff; + return ret; } diff --git a/indra/newview/lldynamictexture.h b/indra/newview/lldynamictexture.h index 2342669f2..14b8e582d 100644 --- a/indra/newview/lldynamictexture.h +++ b/indra/newview/lldynamictexture.h @@ -33,6 +33,7 @@ #ifndef LL_LLDYNAMICTEXTURE_H #define LL_LLDYNAMICTEXTURE_H +#include "llcamera.h" #include "llgl.h" #include "llcoord.h" #include "llviewertexture.h" diff --git a/indra/newview/lleventnotifier.cpp b/indra/newview/lleventnotifier.cpp index 1e915a266..20422369d 100644 --- a/indra/newview/lleventnotifier.cpp +++ b/indra/newview/lleventnotifier.cpp @@ -34,6 +34,7 @@ #include "lleventnotifier.h" +#include "llnotificationsutil.h" #include "message.h" #include "llnotify.h" @@ -78,24 +79,42 @@ void LLEventNotifier::update() { LLEventNotification *np = iter->second; + iter++; if (np->getEventDate() < (alert_time)) { LLSD args; args["NAME"] = np->getEventName(); args["DATE"] = np->getEventDateStr(); - LLNotifications::instance().add("EventNotification", args, LLSD(), - boost::bind(&LLEventNotification::handleResponse, np, _1, _2)); - mEventNotifications.erase(iter++); - } - else - { - iter++; + LLNotificationsUtil::add("EventNotification", args, LLSD(), + boost::bind(&LLEventNotifier::handleResponse, this, np->getEventID(), np->getEventPosGlobal(), _1, _2)); + remove(np->getEventID()); } } mNotificationTimer.reset(); } } +bool LLEventNotifier::handleResponse(U32 eventId, LLVector3d eventPos, const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + switch (option) + { + case 0: + gAgent.teleportViaLocation(eventPos); + gFloaterWorldMap->trackLocation(eventPos); + break; + case 1: + gDisplayEventHack = TRUE; + LLFloaterDirectory::showEvents(eventId); + break; + case 2: + break; + } + + // We could clean up the notification on the server now if we really wanted to. + return true; +} + void LLEventNotifier::load(const LLUserAuth::options_t& event_options) { LLUserAuth::options_t::const_iterator resp_it; @@ -117,6 +136,19 @@ void LLEventNotifier::load(const LLUserAuth::options_t& event_options) } } +void LLEventNotifier::add(U32 eventId) +{ + + gMessageSystem->newMessageFast(_PREHASH_EventInfoRequest); + gMessageSystem->nextBlockFast(_PREHASH_AgentData); + gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); + gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() ); + gMessageSystem->nextBlockFast(_PREHASH_EventData); + gMessageSystem->addU32Fast(_PREHASH_EventID, eventId); + gAgent.sendReliableMessage(); + +} + BOOL LLEventNotifier::hasNotification(const U32 event_id) { if (mEventNotifications.find(event_id) != mEventNotifications.end()) @@ -137,14 +169,7 @@ void LLEventNotifier::add(LLEventInfo &event_info) return; } - // Push up a message to tell the server we have this notification. - gMessageSystem->newMessage("EventNotificationAddRequest"); - gMessageSystem->nextBlockFast(_PREHASH_AgentData); - gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); - gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - gMessageSystem->nextBlock("EventData"); - gMessageSystem->addU32("EventID", event_info.mID); - gAgent.sendReliableMessage(); + serverPushRequest(event_info.mID, true); LLEventNotification *enp = new LLEventNotification; enp->load(event_info); @@ -161,17 +186,22 @@ void LLEventNotifier::remove(const U32 event_id) return; } - // Push up a message to tell the server to remove this notification. - gMessageSystem->newMessage("EventNotificationRemoveRequest"); + serverPushRequest(event_id, false); + delete iter->second; + mEventNotifications.erase(iter); +} + + +void LLEventNotifier::serverPushRequest(U32 event_id, bool add) +{ + // Push up a message to tell the server we have this notification. + gMessageSystem->newMessage(add?"EventNotificationAddRequest":"EventNotificationRemoveRequest"); gMessageSystem->nextBlockFast(_PREHASH_AgentData); gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); gMessageSystem->nextBlock("EventData"); gMessageSystem->addU32("EventID", event_id); gAgent.sendReliableMessage(); - - delete iter->second; - mEventNotifications.erase(iter); } LLEventNotification::LLEventNotification() : @@ -185,26 +215,6 @@ LLEventNotification::~LLEventNotification() { } -bool LLEventNotification::handleResponse(const LLSD& notification, const LLSD& response) -{ - S32 option = LLNotification::getSelectedOption(notification, response); - switch (option) - { - case 0: - gAgent.teleportViaLocation(getEventPosGlobal()); - gFloaterWorldMap->trackLocation(getEventPosGlobal()); - break; - case 1: - gDisplayEventHack = TRUE; - LLFloaterDirectory::showEvents(getEventID()); - break; - case 2: - break; - } - - // We could clean up the notification on the server now if we really wanted to. - return false; -} BOOL LLEventNotification::load(const LLUserAuth::response_t &response) { diff --git a/indra/newview/lleventnotifier.h b/indra/newview/lleventnotifier.h index feb734948..f5e03a3fb 100644 --- a/indra/newview/lleventnotifier.h +++ b/indra/newview/lleventnotifier.h @@ -39,6 +39,7 @@ class LLEventInfo; class LLEventNotification; +class LLMessageSystem; class LLEventNotifier @@ -48,14 +49,17 @@ public: virtual ~LLEventNotifier(); void update(); // Notify the user of the event if it's coming up + void add(LLEventInfo &event_info); // Add a new notification for an event + void add(U32 eventId); void load(const LLUserAuth::options_t& event_options); // In the format that it comes in from LLUserAuth - void add(LLEventInfo &event_info); // Add a new notification for an event void remove(U32 event_id); BOOL hasNotification(const U32 event_id); + void serverPushRequest(U32 event_id, bool add); typedef std::map en_map; + bool handleResponse(U32 eventId, LLVector3d eventPos, const LLSD& notification, const LLSD& response); protected: en_map mEventNotifications; @@ -78,7 +82,6 @@ public: time_t getEventDate() const { return mEventDate; } const std::string &getEventDateStr() const { return mEventDateStr; } LLVector3d getEventPosGlobal() const { return mEventPosGlobal; } - bool handleResponse(const LLSD& notification, const LLSD& payload); protected: U32 mEventID; // EventID for this event std::string mEventName; diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index afef985d7..4a57b390e 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -173,6 +173,7 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp) mIndexInTex = 0; mTexture = NULL; mTEOffset = -1; + mTextureIndex = 255; setDrawable(drawablep); mVObjp = objp; @@ -390,6 +391,26 @@ void LLFace::setGeomIndex(U16 idx) } } +void LLFace::setTextureIndex(U8 index) +{ + if (index != mTextureIndex) + { + mTextureIndex = index; + + if (mTextureIndex != 255) + { + mDrawablep->setState(LLDrawable::REBUILD_POSITION); + } + else + { + if (mDrawInfo && !mDrawInfo->mTextureList.empty()) + { + llerrs << "Face with no texture index references indexed texture draw info." << llendl; + } + } + } +} + void LLFace::setIndicesIndex(S32 idx) { if (mIndicesIndex != idx) @@ -457,83 +478,6 @@ void LLFace::updateCenterAgent() } } -void LLFace::renderForSelect(U32 data_mask) -{ - if(mDrawablep.isNull() || mVertexBuffer.isNull()) - { - return; - } - - LLSpatialGroup* group = mDrawablep->getSpatialGroup(); - if (!group || group->isState(LLSpatialGroup::GEOM_DIRTY)) - { - return; - } - - if (mVObjp->mGLName) - { - S32 name = mVObjp->mGLName; - - LLColor4U color((U8)(name >> 16), (U8)(name >> 8), (U8)name); -#if 0 // *FIX: Postponing this fix until we have texcoord pick info... - if (mTEOffset != -1) - { - color.mV[VALPHA] = (U8)(getTextureEntry()->getColor().mV[VALPHA] * 255.f); - } -#endif - glColor4ubv(color.mV); - - if (!getPool()) - { - switch (getPoolType()) - { - case LLDrawPool::POOL_ALPHA: - gGL.getTexUnit(0)->bind(getTexture()); - break; - default: - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - break; - } - } - - mVertexBuffer->setBuffer(data_mask); -#if !LL_RELEASE_FOR_DOWNLOAD - LLGLState::checkClientArrays("", data_mask); -#endif - if (mTEOffset != -1) - { - // mask off high 4 bits (16 total possible faces) - color.mV[0] &= 0x0f; - color.mV[0] |= (mTEOffset & 0x0f) << 4; - glColor4ubv(color.mV); - } - - if (mIndicesCount) - { - if (isState(GLOBAL)) - { - if (mDrawablep->getVOVolume()) - { - glPushMatrix(); - glMultMatrixf((float*) mDrawablep->getRegion()->mRenderMatrix.mMatrix); - mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); - glPopMatrix(); - } - else - { - mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); - } - } - else - { - glPushMatrix(); - glMultMatrixf((float*)getRenderMatrix().mMatrix); - mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); - glPopMatrix(); - } - } - } -} void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color) { if (mDrawablep->getSpatialGroup() == NULL) @@ -1136,15 +1080,15 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } } - LLStrider vertices; + LLStrider vert; LLStrider tex_coords; LLStrider tex_coords2; - LLStrider normals; + LLStrider norm; LLStrider colors; - LLStrider binormals; + LLStrider binorm; LLStrider indicesp; #if MESH_ENABLED - LLStrider weights; + LLStrider wght; #endif //MESH_ENABLED BOOL full_rebuild = force_rebuild || mDrawablep->isState(LLDrawable::REBUILD_VOLUME); @@ -1172,8 +1116,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, const LLTextureEntry *tep = mVObjp->getTE(f); if (!tep) rebuild_color = FALSE; // can't get color when tep is NULL U8 bump_code = tep ? tep->getBumpmap() : 0; - - BOOL is_static = mDrawablep->isStatic(); BOOL is_global = is_static; @@ -1214,12 +1156,23 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (full_rebuild) { mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex); - for (U32 i = 0; i < (U32) num_indices; i++) + + __m128i* dst = (__m128i*) indicesp.get(); + __m128i* src = (__m128i*) vf.mIndices; + __m128i offset = _mm_set1_epi16(index_offset); + + S32 end = num_indices/8; + + for (S32 i = 0; i < end; i++) { - indicesp[i] = vf.mIndices[i] + index_offset; + __m128i res = _mm_add_epi16(src[i], offset); + _mm_storeu_si128(dst+i, res); } - //mVertexBuffer->setBuffer(0); + for (S32 i = end*8; i < num_indices; ++i) + { + indicesp[i] = vf.mIndices[i]+index_offset; + } } LLMatrix4a mat_normal; @@ -1440,7 +1393,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } } - //mVertexBuffer->setBuffer(0); } else { //either bump mapped or in atlas, just do the whole expensive loop @@ -1498,8 +1450,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } } - //mVertexBuffer->setBuffer(0); - if (do_bump) { @@ -1533,75 +1483,165 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, *tex_coords2++ = tc; } - //mVertexBuffer->setBuffer(0); } } } if (rebuild_pos) { - mVertexBuffer->getVertexStrider(vertices, mGeomIndex); + llassert(num_vertices > 0); + mVertexBuffer->getVertexStrider(vert, mGeomIndex); LLMatrix4a mat_vert; mat_vert.loadu(mat_vert_in); LLVector4a* src = vf.mPositions; - LLVector4a position; - for (S32 i = 0; i < num_vertices; i++) + + if(!vert.isStrided()) { - mat_vert.affineTransform(src[i], position); - vertices[i].set(position.getF32ptr()); + LLVector4a* vertices = (LLVector4a*) vert.get(); + + LLVector4a* dst = vertices; + + LLVector4a* end = dst+num_vertices; + do + { + mat_vert.affineTransform(*src++, *dst++); + } + while(dst < end); + + F32 index = (F32) (mTextureIndex < 255 ? mTextureIndex : 0); + F32 *index_dst = (F32*) vertices; + F32 *index_end = (F32*) end; + + index_dst += 3; + index_end += 3; + do + { + *index_dst = index; + index_dst += 4; + } + while (index_dst < index_end); + + S32 aligned_pad_vertices = mGeomCount - num_vertices; + LLVector4a* last_vec = end - 1; + while (aligned_pad_vertices > 0) + { + --aligned_pad_vertices; + *dst++ = *last_vec; + } + + } + else + { + LLVector4a position; + F32 index = (F32) (mTextureIndex < 255 ? mTextureIndex : 0); + for (S32 i = 0; i < num_vertices; i++) + { + mat_vert.affineTransform(src[i], position); + //Still using getF32ptr() because if the array is strided then theres no guarantee vertices will aligned, which LLVector4a requires + vert[i].set(position.getF32ptr()); //This assignment and the one below are oddly sensitive. Suspect something's off around here. + *(vert[i].mV+3) = index; + } + for (S32 i = num_vertices; i < mGeomCount; i++) + { + memcpy(vert[i].mV,vert[num_vertices-1].mV,sizeof(LLVector4)); + } } - - - //mVertexBuffer->setBuffer(0); } if (rebuild_normal) { - mVertexBuffer->getNormalStrider(normals, mGeomIndex); - for (S32 i = 0; i < num_vertices; i++) - { - LLVector4a normal; - mat_normal.rotate(vf.mNormals[i], normal); - normal.normalize3fast(); - normals[i].set(normal.getF32ptr()); + mVertexBuffer->getNormalStrider(norm, mGeomIndex); + if(!norm.isStrided()) + { + LLVector4a* normals = (LLVector4a*) norm.get(); + + for (S32 i = 0; i < num_vertices; i++) + { + LLVector4a normal; + mat_normal.rotate(vf.mNormals[i], normal); + normal.normalize3fast(); + normals[i] = normal; + } + } + else + { + for (S32 i = 0; i < num_vertices; i++) + { + LLVector4a normal; + mat_normal.rotate(vf.mNormals[i], normal); + normal.normalize3fast(); + norm[i].set(normal.getF32ptr()); + } } - - //mVertexBuffer->setBuffer(0); } if (rebuild_binormal) { - mVertexBuffer->getBinormalStrider(binormals, mGeomIndex); - for (S32 i = 0; i < num_vertices; i++) - { - LLVector4a binormal; - mat_normal.rotate(vf.mBinormals[i], binormal); - binormal.normalize3fast(); - binormals[i].set(binormal.getF32ptr()); + mVertexBuffer->getBinormalStrider(binorm, mGeomIndex); + if(!binorm.isStrided()) + { + LLVector4a* binormals = (LLVector4a*) binorm.get(); + + for (S32 i = 0; i < num_vertices; i++) + { + LLVector4a binormal; + mat_normal.rotate(vf.mBinormals[i], binormal); + binormal.normalize3fast(); + binormals[i] = binormal; + } + } + else + { + for (S32 i = 0; i < num_vertices; i++) + { + LLVector4a binormal; + mat_normal.rotate(vf.mBinormals[i], binormal); + binormal.normalize3fast(); + binorm[i].set(binormal.getF32ptr()); + } } - - //mVertexBuffer->setBuffer(0); } #if MESH_ENABLED if (rebuild_weights && vf.mWeights) { - mVertexBuffer->getWeight4Strider(weights, mGeomIndex); - weights.assignArray((U8*) vf.mWeights, sizeof(vf.mWeights[0]), num_vertices); - //mVertexBuffer->setBuffer(0); + mVertexBuffer->getWeight4Strider(wght, mGeomIndex); + wght.assignArray((U8*) vf.mWeights, sizeof(vf.mWeights[0]), num_vertices); } #endif //MESH_ENABLED if (rebuild_color) { mVertexBuffer->getColorStrider(colors, mGeomIndex); - for (S32 i = 0; i < num_vertices; i++) + if(!colors.isStrided()) { - colors[i] = color; - } + LLVector4a src; - //mVertexBuffer->setBuffer(0); + U32 vec[4]; + vec[0] = vec[1] = vec[2] = vec[3] = color.mAll; + + src.loadua((F32*) vec); + + LLVector4a* dst = (LLVector4a*) colors.get(); + S32 num_vecs = num_vertices/4; + if (num_vertices%4 > 0) + { + ++num_vecs; + } + + for (S32 i = 0; i < num_vecs; i++) + { + dst[i] = src; + } + } + else + { + for (S32 i = 0; i < num_vertices; i++) + { + colors[i] = color; + } + } } if (rebuild_tcoord) @@ -1724,7 +1764,7 @@ BOOL LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) //the projection of the face partially overlaps with the screen F32 LLFace::adjustPartialOverlapPixelArea(F32 cos_angle_to_view_dir, F32 radius ) { - F32 screen_radius = (F32)llmax(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()) ; + F32 screen_radius = (F32)llmax(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw()) ; F32 center_angle = acosf(cos_angle_to_view_dir) ; F32 d = center_angle * LLDrawable::sCurPixelAngle ; @@ -1830,10 +1870,10 @@ BOOL LLFace::verify(const U32* indices_array) const } // First, check whether the face data fits within the pool's range. - if ((mGeomIndex + mGeomCount) > mVertexBuffer->getNumVerts()) + if ((mGeomIndex + mGeomCount) > mVertexBuffer->getRequestedVerts()) { ok = FALSE; - llinfos << "Face not within pool range!" << llendl; + llinfos << "Face references invalid vertices!" << llendl; } S32 indices_count = (S32)getIndicesCount(); @@ -1849,6 +1889,12 @@ BOOL LLFace::verify(const U32* indices_array) const llinfos << "Face has bogus indices count" << llendl; } + if (mIndicesIndex + mIndicesCount > (U32)mVertexBuffer->getRequestedIndices()) + { + ok = FALSE; + llinfos << "Face references invalid indices!" << llendl; + } + #if 0 S32 geom_start = getGeomStart(); S32 geom_count = mGeomCount; @@ -2018,6 +2064,7 @@ void LLFace::clearVertexBuffer() #if MESH_ENABLED //static +//do NOT screw the the order of these. Must match order of LLDrawPoolAvatar::eRiggedPass. Order differs from LL's. U32 LLFace::getRiggedDataMask(U32 type) { static const U32 rigged_data_mask[] = { @@ -2025,11 +2072,13 @@ U32 LLFace::getRiggedDataMask(U32 type) LLDrawPoolAvatar::RIGGED_FULLBRIGHT_MASK, LLDrawPoolAvatar::RIGGED_SHINY_MASK, LLDrawPoolAvatar::RIGGED_FULLBRIGHT_SHINY_MASK, - LLDrawPoolAvatar::RIGGED_GLOW_MASK, + //LLDrawPoolAvatar::RIGGED_GLOW_MASK, LLDrawPoolAvatar::RIGGED_ALPHA_MASK, LLDrawPoolAvatar::RIGGED_FULLBRIGHT_ALPHA_MASK, - LLDrawPoolAvatar::RIGGED_DEFERRED_BUMP_MASK, + LLDrawPoolAvatar::RIGGED_GLOW_MASK, + //LLDrawPoolAvatar::RIGGED_DEFERRED_BUMP_MASK, LLDrawPoolAvatar::RIGGED_DEFERRED_SIMPLE_MASK, + LLDrawPoolAvatar::RIGGED_DEFERRED_BUMP_MASK, }; llassert(type < sizeof(rigged_data_mask)/sizeof(U32)); @@ -2080,4 +2129,4 @@ void LLFace::setRiggedIndex(U32 type, S32 index) } -#endif //MESH_ENABLED \ No newline at end of file +#endif //MESH_ENABLED diff --git a/indra/newview/llface.h b/indra/newview/llface.h index 15d26d7da..2f77abbb0 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -101,6 +101,8 @@ public: U16 getGeomCount() const { return mGeomCount; } // vertex count for this face U16 getGeomIndex() const { return mGeomIndex; } // index into draw pool U16 getGeomStart() const { return mGeomIndex; } // index into draw pool + void setTextureIndex(U8 index); + U8 getTextureIndex() const { return mTextureIndex; } void setTexture(LLViewerTexture* tex) ; void switchTexture(LLViewerTexture* new_texture); void dirtyTexture(); @@ -194,7 +196,6 @@ public: void updateCenterAgent(); // Update center when xform has changed. void renderSelectedUV(); - void renderForSelect(U32 data_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); void renderSelected(LLViewerTexture *image, const LLColor4 &color); F32 getKey() const { return mDistance; } @@ -260,6 +261,7 @@ private: U16 mGeomCount; // vertex count for this face U16 mGeomIndex; // index into draw pool + U8 mTextureIndex; // index of texture channel to use for pseudo-atlasing U32 mIndicesCount; U32 mIndicesIndex; // index into draw pool for indices (yeah, I know!) S32 mIndexInTex ; diff --git a/indra/newview/llfirstuse.cpp b/indra/newview/llfirstuse.cpp index 4c7cedf9b..d59167ddf 100644 --- a/indra/newview/llfirstuse.cpp +++ b/indra/newview/llfirstuse.cpp @@ -36,6 +36,8 @@ // library includes #include "indra_constants.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" // viewer includes #include "llagent.h" // for gAgent.inPrelude() @@ -94,7 +96,7 @@ void LLFirstUse::useBalanceIncrease(S32 delta) LLSD args; args["AMOUNT"] = llformat("%d",delta); args["CURRENCY"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); - LLNotifications::instance().add("FirstBalanceIncrease", args); + LLNotificationsUtil::add("FirstBalanceIncrease", args); } } @@ -109,7 +111,7 @@ void LLFirstUse::useBalanceDecrease(S32 delta) LLSD args; args["AMOUNT"] = llformat("%d",-delta); args["CURRENCY"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); - LLNotifications::instance().add("FirstBalanceDecrease", args); + LLNotificationsUtil::add("FirstBalanceDecrease", args); } } @@ -123,7 +125,7 @@ void LLFirstUse::useSit() //{ // gSavedSettings.setWarning("FirstSit", FALSE); // - // LLNotifications::instance().add("FirstSit"); + // LLNotificationsUtil::add("FirstSit"); //} } @@ -134,7 +136,7 @@ void LLFirstUse::useMap() { gSavedSettings.setWarning("FirstMap", FALSE); - LLNotifications::instance().add("FirstMap"); + LLNotificationsUtil::add("FirstMap"); } } @@ -151,7 +153,7 @@ void LLFirstUse::useBuild() { gSavedSettings.setWarning("FirstBuild", FALSE); - LLNotifications::instance().add("FirstBuild"); + LLNotificationsUtil::add("FirstBuild"); } } @@ -162,7 +164,7 @@ void LLFirstUse::useLeftClickNoHit() { gSavedSettings.setWarning("FirstLeftClickNoHit", FALSE); - LLNotifications::instance().add("FirstLeftClickNoHit"); + LLNotificationsUtil::add("FirstLeftClickNoHit"); } } @@ -176,7 +178,7 @@ void LLFirstUse::useTeleport() { gSavedSettings.setWarning("FirstTeleport", FALSE); - LLNotifications::instance().add("FirstTeleport"); + LLNotificationsUtil::add("FirstTeleport"); } } } @@ -192,7 +194,7 @@ void LLFirstUse::useOverrideKeys() { gSavedSettings.setWarning("FirstOverrideKeys", FALSE); - LLNotifications::instance().add("FirstOverrideKeys"); + LLNotificationsUtil::add("FirstOverrideKeys"); } } } @@ -210,7 +212,7 @@ void LLFirstUse::useAO() { gSavedSettings.setWarning("FirstAO", FALSE); - LLNotifications::instance().add("FirstAO"); + LLNotificationsUtil::add("FirstAO"); } } @@ -221,7 +223,7 @@ void LLFirstUse::useAppearance() { gSavedSettings.setWarning("FirstAppearance", FALSE); - LLNotifications::instance().add("FirstAppearance"); + LLNotificationsUtil::add("FirstAppearance"); } } @@ -232,7 +234,7 @@ void LLFirstUse::useInventory() { gSavedSettings.setWarning("FirstInventory", FALSE); - LLNotifications::instance().add("FirstInventory"); + LLNotificationsUtil::add("FirstInventory"); } } @@ -247,7 +249,7 @@ void LLFirstUse::useSandbox() LLSD args; args["HOURS"] = llformat("%d",SANDBOX_CLEAN_FREQ); args["TIME"] = llformat("%d",SANDBOX_FIRST_CLEAN_HOUR); - LLNotifications::instance().add("FirstSandbox", args); + LLNotificationsUtil::add("FirstSandbox", args); } } @@ -258,7 +260,7 @@ void LLFirstUse::useFlexible() { gSavedSettings.setWarning("FirstFlexible", FALSE); - LLNotifications::instance().add("FirstFlexible"); + LLNotificationsUtil::add("FirstFlexible"); } } @@ -269,7 +271,7 @@ void LLFirstUse::useDebugMenus() { gSavedSettings.setWarning("FirstDebugMenus", FALSE); - LLNotifications::instance().add("FirstDebugMenus"); + LLNotificationsUtil::add("FirstDebugMenus"); } } @@ -280,7 +282,7 @@ void LLFirstUse::useSculptedPrim() { gSavedSettings.setWarning("FirstSculptedPrim", FALSE); - LLNotifications::instance().add("FirstSculptedPrim"); + LLNotificationsUtil::add("FirstSculptedPrim"); } } @@ -292,7 +294,7 @@ void LLFirstUse::useMedia() { gSavedSettings.setWarning("FirstMedia", FALSE); - LLNotifications::instance().add("FirstMedia"); + LLNotificationsUtil::add("FirstMedia"); } } diff --git a/indra/newview/llfloateranimpreview.cpp b/indra/newview/llfloateranimpreview.cpp index 2fcc7a135..73627253e 100644 --- a/indra/newview/llfloateranimpreview.cpp +++ b/indra/newview/llfloateranimpreview.cpp @@ -37,6 +37,7 @@ #include "llbvhloader.h" #include "lldatapacker.h" #include "lldir.h" +#include "llnotificationsutil.h" #include "llvfile.h" #include "llapr.h" #include "llstring.h" @@ -1444,7 +1445,7 @@ void LLFloaterAnimPreview::onBtnOK(void* userdata) else { llwarns << "Failure writing animation data." << llendl; - LLNotifications::instance().add("WriteAnimationFail"); + LLNotificationsUtil::add("WriteAnimationFail"); } } diff --git a/indra/newview/llfloaterauction.cpp b/indra/newview/llfloaterauction.cpp index fd886f10b..c4121fae9 100644 --- a/indra/newview/llfloaterauction.cpp +++ b/indra/newview/llfloaterauction.cpp @@ -41,10 +41,13 @@ #include "llparcel.h" #include "llvfile.h" #include "llvfs.h" +#include "llwindow.h" +#include "message.h" #include "llagent.h" #include "llcombobox.h" -#include "llnotify.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llviewertexturelist.h" #include "llviewerparcelmgr.h" #include "llviewerregion.h" @@ -238,7 +241,7 @@ void LLFloaterAuction::onClickOK(void* data) FALSE); self->getWindow()->incBusyCount(); - LLNotifications::instance().add("UploadingAuctionSnapshot"); + LLNotificationsUtil::add("UploadingAuctionSnapshot"); } LLMessageSystem* msg = gMessageSystem; @@ -277,13 +280,13 @@ void auction_tga_upload_done(const LLUUID& asset_id, void* user_data, S32 status if (0 == status) { - LLNotifications::instance().add("UploadWebSnapshotDone"); + LLNotificationsUtil::add("UploadWebSnapshotDone"); } else { LLSD args; args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); - LLNotifications::instance().add("UploadAuctionSnapshotFail", args); + LLNotificationsUtil::add("UploadAuctionSnapshotFail", args); } } @@ -298,12 +301,12 @@ void auction_j2c_upload_done(const LLUUID& asset_id, void* user_data, S32 status if (0 == status) { - LLNotifications::instance().add("UploadSnapshotDone"); + LLNotificationsUtil::add("UploadSnapshotDone"); } else { LLSD args; args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); - LLNotifications::instance().add("UploadAuctionSnapshotFail", args); + LLNotificationsUtil::add("UploadAuctionSnapshotFail", args); } } diff --git a/indra/newview/llfloateravatarlist.cpp b/indra/newview/llfloateravatarlist.cpp index a568b88e9..b02ca306d 100644 --- a/indra/newview/llfloateravatarlist.cpp +++ b/indra/newview/llfloateravatarlist.cpp @@ -22,9 +22,11 @@ #include "lluictrlfactory.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llscrolllistctrl.h" #include "llradiogroup.h" #include "llviewercontrol.h" +#include "llnotificationsutil.h" #include "llvoavatar.h" #include "llimview.h" @@ -59,6 +61,10 @@ #include "llviewermenu.h" // +// [RLVa:KB] +#include "rlvhandler.h" +// [/RLVa:KB] + /** * @brief How long to keep people who are gone in the list and in memory. */ @@ -237,18 +243,14 @@ void LLFloaterAvatarList::createInstance(bool visible) //static void LLFloaterAvatarList::toggle(void*) { -#ifdef LL_RRINTERFACE_H //MK - if (gRRenabled && gAgent.mRRInterface.mContainsShownames) - { - if (sInstance && sInstance->getVisible()) - { - sInstance->close(false); - } - } -#endif //mk if (sInstance) { - if (sInstance->getVisible()) + if (sInstance->getVisible() +// [RLVa:KB] + || gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES) +// [/RLVa:KB] + ) + { sInstance->close(false); } @@ -266,12 +268,10 @@ void LLFloaterAvatarList::toggle(void*) //static void LLFloaterAvatarList::showInstance() { -#ifdef LL_RRINTERFACE_H //MK - if (gRRenabled && gAgent.mRRInterface.mContainsShownames) - { +// [RLVa:KB] + if(gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) return; - } -#endif //mk +// [/RLVa:KB] if (sInstance) { if (!sInstance->getVisible()) @@ -457,12 +457,6 @@ void LLFloaterAvatarList::updateAvatarList() continue; } } -#ifdef LL_RRINTERFACE_H //MK - if (gRRenabled && gAgent.mRRInterface.mContainsShownames) - { - name = gAgent.mRRInterface.getDummyName(name); - } -#endif //mk if (avid.isNull()) { @@ -501,12 +495,6 @@ void LLFloaterAvatarList::updateAvatarList() //name = gCacheName->getDefaultName(); continue; //prevent (Loading...) } -#ifdef LL_RRINTERFACE_H //MK - if (gRRenabled && gAgent.mRRInterface.mContainsShownames) - { - name = gAgent.mRRInterface.getDummyName(name); - } -#endif //mk if (mAvatars.count(avid) > 0) { @@ -1287,7 +1275,7 @@ void LLFloaterAvatarList::sound_trigger_hook(LLMessageSystem* msg,void **) { LLSD args; args["MESSAGE"] = "An object owned by you has request the keys from your radar.\nWould you like to enable announcing keys to objects in the sim?"; - LLNotifications::instance().add("GenericAlertYesCancel", args, LLSD(), onConfirmRadarChatKeys); + LLNotificationsUtil::add("GenericAlertYesCancel", args, LLSD(), onConfirmRadarChatKeys); } } } @@ -1515,7 +1503,7 @@ void LLFloaterAvatarList::onClickFreeze(void *userdata) LLSD args; LLSD payload; args["AVATAR_NAME"] = ((LLFloaterAvatarList*)userdata)->getSelectedNames(); - LLNotifications::instance().add("FreezeAvatarFullname", args, payload, callbackFreeze); + LLNotificationsUtil::add("FreezeAvatarFullname", args, payload, callbackFreeze); } //static @@ -1524,7 +1512,7 @@ void LLFloaterAvatarList::onClickEject(void *userdata) LLSD args; LLSD payload; args["AVATAR_NAME"] = ((LLFloaterAvatarList*)userdata)->getSelectedNames(); - LLNotifications::instance().add("EjectAvatarFullname", args, payload, callbackEject); + LLNotificationsUtil::add("EjectAvatarFullname", args, payload, callbackEject); } //static @@ -1563,7 +1551,7 @@ void LLFloaterAvatarList::onClickEjectFromEstate(void *userdata) LLSD args; LLSD payload; args["EVIL_USER"] = ((LLFloaterAvatarList*)userdata)->getSelectedNames(); - LLNotifications::instance().add("EstateKickUser", args, payload, callbackEjectFromEstate); + LLNotificationsUtil::add("EstateKickUser", args, payload, callbackEjectFromEstate); } //static diff --git a/indra/newview/llfloaterblacklist.cpp b/indra/newview/llfloaterblacklist.cpp index 65c64cce7..07c0a94cb 100644 --- a/indra/newview/llfloaterblacklist.cpp +++ b/indra/newview/llfloaterblacklist.cpp @@ -9,6 +9,7 @@ #include "llcheckboxctrl.h" #include "statemachine/aifilepicker.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llviewercontrol.h" #include "lldate.h" #include "llagent.h" diff --git a/indra/newview/llfloaterbulkpermission.cpp b/indra/newview/llfloaterbulkpermission.cpp index 3216a8de0..a79527456 100644 --- a/indra/newview/llfloaterbulkpermission.cpp +++ b/indra/newview/llfloaterbulkpermission.cpp @@ -35,6 +35,7 @@ #include "llviewerprecompiledheaders.h" #include "llfloaterbulkpermission.h" #include "llfloaterperms.h" // for utilities +#include "llinventorydefines.h" #include "llagent.h" #include "llchat.h" #include "llviewerwindow.h" @@ -52,6 +53,7 @@ #include "llviewerstats.h" #include "lluictrlfactory.h" #include "llselectmgr.h" +#include "llnotificationsutil.h" #include "roles_constants.h" // for GP_OBJECT_MANIPULATE @@ -152,7 +154,7 @@ void LLFloaterBulkPermission::onApplyBtn(void* user_data) void LLFloaterBulkPermission::onHelpBtn(void* user_data) { - LLNotifications::instance().add("HelpBulkPermission"); + LLNotificationsUtil::add("HelpBulkPermission"); } void LLFloaterBulkPermission::onCloseBtn(void* user_data) diff --git a/indra/newview/llfloaterbuy.cpp b/indra/newview/llfloaterbuy.cpp index 49199fff2..b7de17cc6 100644 --- a/indra/newview/llfloaterbuy.cpp +++ b/indra/newview/llfloaterbuy.cpp @@ -43,7 +43,9 @@ #include "llagent.h" // for agent id #include "llalertdialog.h" #include "llinventorymodel.h" // for gInventory +#include "llinventorydefines.h" #include "llinventoryview.h" // for get_item_icon +#include "llnotificationsutil.h" #include "llselectmgr.h" #include "llscrolllistctrl.h" #include "llviewerobject.h" @@ -89,7 +91,7 @@ void LLFloaterBuy::show(const LLSaleInfo& sale_info) if (selection->getRootObjectCount() != 1) { - LLNotifications::instance().add("BuyOneObjectOnly"); + LLNotificationsUtil::add("BuyOneObjectOnly"); return; } @@ -139,7 +141,7 @@ void LLFloaterBuy::show(const LLSaleInfo& sale_info) BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name); if (!owners_identical) { - LLNotifications::instance().add("BuyObjectOneOwner"); + LLNotificationsUtil::add("BuyObjectOneOwner"); return; } diff --git a/indra/newview/llfloaterbuycontents.cpp b/indra/newview/llfloaterbuycontents.cpp index f78ab995a..cb72659cb 100644 --- a/indra/newview/llfloaterbuycontents.cpp +++ b/indra/newview/llfloaterbuycontents.cpp @@ -46,7 +46,9 @@ #include "llalertdialog.h" #include "llcheckboxctrl.h" #include "llinventorymodel.h" // for gInventory +#include "llinventorydefines.h" #include "llinventoryview.h" // for get_item_icon +#include "llnotificationsutil.h" #include "llselectmgr.h" #include "llscrolllistctrl.h" #include "llviewerobject.h" @@ -86,7 +88,7 @@ void LLFloaterBuyContents::show(const LLSaleInfo& sale_info) if (selection->getRootObjectCount() != 1) { - LLNotifications::instance().add("BuyContentsOneOnly"); + LLNotificationsUtil::add("BuyContentsOneOnly"); return; } @@ -116,7 +118,7 @@ void LLFloaterBuyContents::show(const LLSaleInfo& sale_info) BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name); if (!owners_identical) { - LLNotifications::instance().add("BuyContentsOneOwner"); + LLNotificationsUtil::add("BuyContentsOneOwner"); return; } diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp index 1340ad905..bd8cd5286 100644 --- a/indra/newview/llfloaterbuyland.cpp +++ b/indra/newview/llfloaterbuyland.cpp @@ -47,7 +47,7 @@ #include "llframetimer.h" #include "lliconctrl.h" #include "lllineeditor.h" -#include "llnotify.h" +#include "llnotificationsutil.h" #include "llparcel.h" #include "llstatusbar.h" #include "lltextbox.h" @@ -215,7 +215,7 @@ void LLFloaterBuyLand::buyLand( { if(is_for_group && !gAgent.hasPowerInActiveGroup(GP_LAND_DEED)) { - LLNotifications::instance().add("OnlyOfficerCanBuyLand"); + LLNotificationsUtil::add("OnlyOfficerCanBuyLand"); return; } @@ -334,9 +334,8 @@ LLFloaterBuyLandUI::LLFloaterBuyLandUI() LLFloaterBuyLandUI::~LLFloaterBuyLandUI() { + LLViewerParcelMgr::getInstance()->deleteParcelBuy(&mParcelBuyInfo); delete mTransaction; - - LLViewerParcelMgr::getInstance()->deleteParcelBuy(mParcelBuyInfo); if (sInstance == this) { @@ -494,10 +493,18 @@ void LLFloaterBuyLandUI::updateParcelInfo() return; } - if (!authorizedBuyer.isNull() && buyer != authorizedBuyer) + if (!authorizedBuyer.isNull() && buyer != authorizedBuyer) { - mCannotBuyReason = getString("set_to_sell_to_other"); - return; + // Maybe the parcel is set for sale to a group we are in. + bool authorized_group = + gAgent.hasPowerInGroup(authorizedBuyer,GP_LAND_DEED) + && gAgent.hasPowerInGroup(authorizedBuyer,GP_LAND_SET_SALE_INFO); + + if (!authorized_group) + { + mCannotBuyReason = getString("set_to_sell_to_other"); + return; + } } } else @@ -807,7 +814,7 @@ void LLFloaterBuyLandUI::sendBuyLand() if (mParcelBuyInfo) { LLViewerParcelMgr::getInstance()->sendParcelBuy(mParcelBuyInfo); - LLViewerParcelMgr::getInstance()->deleteParcelBuy(mParcelBuyInfo); + LLViewerParcelMgr::getInstance()->deleteParcelBuy(&mParcelBuyInfo); mBought = true; } } @@ -984,7 +991,7 @@ BOOL LLFloaterBuyLandUI::canClose() if (!can_close) { // explain to user why they can't do this, see DEV-9605 - LLNotifications::instance().add("CannotCloseFloaterBuyLand"); + LLNotificationsUtil::add("CannotCloseFloaterBuyLand"); } return can_close; } diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp index 88d925490..717922394 100644 --- a/indra/newview/llfloatercolorpicker.cpp +++ b/indra/newview/llfloatercolorpicker.cpp @@ -50,6 +50,7 @@ #include "llviewercontrol.h" #include "lluictrlfactory.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llgl.h" #include "llmemory.h" #include "llimage.h" @@ -203,7 +204,7 @@ showUI () { LLColor4 curCol = swatch->get (); send_agent_pause(); - gViewerWindow->getWindow ()->dialog_color_picker ( &curCol [ 0 ], &curCol [ 1 ], &curCol [ 2 ] ); + gViewerWindow->getWindow()->dialogColorPicker( &curCol [ 0 ], &curCol [ 1 ], &curCol [ 2 ] ); send_agent_resume(); setOrigRgb ( curCol [ 0 ], curCol [ 1 ], curCol [ 2 ] ); diff --git a/indra/newview/llfloatercustomize.cpp b/indra/newview/llfloatercustomize.cpp index 36853413c..b199cb939 100644 --- a/indra/newview/llfloatercustomize.cpp +++ b/indra/newview/llfloatercustomize.cpp @@ -75,6 +75,7 @@ #include "llviewermessage.h" #include "llviewercontrol.h" #include "lluictrlfactory.h" +#include "llnotificationsutil.h" #include "statemachine/aifilepicker.h" #include "hippogridmanager.h" @@ -708,7 +709,7 @@ void LLPanelEditWearable::onBtnCreateNew( void* userdata ) LLPanelEditWearable* self = (LLPanelEditWearable*) userdata; LLSD payload; payload["wearable_type"] = (S32)self->getType(); - LLNotifications::instance().add("AutoWearNewClothing", LLSD(), payload, &onSelectAutoWearOption); + LLNotificationsUtil::add("AutoWearNewClothing", LLSD(), payload, &onSelectAutoWearOption); } bool LLPanelEditWearable::onSelectAutoWearOption(const LLSD& notification, const LLSD& response) @@ -2723,7 +2724,7 @@ void LLFloaterCustomize::askToSaveIfDirty( void(*next_step_callback)(BOOL procee mNextStepAfterSaveUserdata = userdata; // Bring up view-modal dialog: Save changes? Yes, No, Cancel - LLNotifications::instance().add("SaveClothingBodyChanges", LLSD(), LLSD(), + LLNotificationsUtil::add("SaveClothingBodyChanges", LLSD(), LLSD(), boost::bind(&LLFloaterCustomize::onSaveDialog, this, _1, _2)); return; } diff --git a/indra/newview/llfloaterdaycycle.cpp b/indra/newview/llfloaterdaycycle.cpp index 07106e6b1..0799ca330 100644 --- a/indra/newview/llfloaterdaycycle.cpp +++ b/indra/newview/llfloaterdaycycle.cpp @@ -41,6 +41,8 @@ #include "llsliderctrl.h" #include "llmultislider.h" #include "llmultisliderctrl.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llspinctrl.h" #include "llcheckboxctrl.h" #include "lluictrlfactory.h" @@ -77,9 +79,9 @@ LLFloaterDayCycle::LLFloaterDayCycle() : LLFloater(std::string("Day Cycle Floate if(keyCombo != NULL) { - std::map::iterator mIt = - LLWLParamManager::instance()->mParamList.begin(); - for(; mIt != LLWLParamManager::instance()->mParamList.end(); mIt++) + std::map::const_iterator mIt = + LLWLParamManager::getInstance()->getPresets().begin(); + for(; mIt != LLWLParamManager::getInstance()->getPresets().end(); mIt++) { keyCombo->add(std::string(mIt->first)); } @@ -181,11 +183,11 @@ void LLFloaterDayCycle::initCallbacks(void) void LLFloaterDayCycle::syncMenu() { -// std::map & currentParams = LLWLParamManager::instance()->mCurParams.mParamValues; +// std::map & currentParams = LLWLParamManager::getInstance()->mCurParams.mParamValues; // set time LLMultiSliderCtrl* sldr = LLFloaterDayCycle::sDayCycle->getChild("WLTimeSlider"); - sldr->setCurSliderValue((F32)LLWLParamManager::instance()->mAnimator.getDayTime() * sHoursPerDay); + sldr->setCurSliderValue((F32)LLWLParamManager::getInstance()->mAnimator.getDayTime() * sHoursPerDay); LLSpinCtrl* secSpin = sDayCycle->getChild("WLLengthOfDaySec"); LLSpinCtrl* minSpin = sDayCycle->getChild("WLLengthOfDayMin"); @@ -195,7 +197,7 @@ void LLFloaterDayCycle::syncMenu() F32 hours, min, sec; // get the current rate - curRate = LLWLParamManager::instance()->mDay.mDayRate; + curRate = LLWLParamManager::getInstance()->mDay.mDayRate; hours = (F32)((int)(curRate / 60 / 60)); curRate -= (hours * 60 * 60); min = (F32)((int)(curRate / 60)); @@ -207,7 +209,7 @@ void LLFloaterDayCycle::syncMenu() secSpin->setValue(sec); // turn off Use Estate Time button if it's already being used - if( LLWLParamManager::instance()->mAnimator.mUseLindenTime == true) + if( LLWLParamManager::getInstance()->mAnimator.mUseLindenTime == true) { LLFloaterDayCycle::sDayCycle->childDisable("WLUseLindenTime"); } @@ -227,8 +229,8 @@ void LLFloaterDayCycle::syncSliderTrack() // add sliders std::map::iterator mIt = - LLWLParamManager::instance()->mDay.mTimeMap.begin(); - for(; mIt != LLWLParamManager::instance()->mDay.mTimeMap.end(); mIt++) + LLWLParamManager::getInstance()->mDay.mTimeMap.begin(); + for(; mIt != LLWLParamManager::getInstance()->mDay.mTimeMap.end(); mIt++) { addSliderKey(mIt->first * sHoursPerDay, mIt->second); } @@ -252,22 +254,22 @@ void LLFloaterDayCycle::syncTrack() "WLTimeSlider"); // create a new animation track - LLWLParamManager::instance()->mDay.clearKeys(); + LLWLParamManager::getInstance()->mDay.clearKeys(); // add the keys one by one std::map::iterator mIt = sSliderToKey.begin(); for(; mIt != sSliderToKey.end(); mIt++) { - LLWLParamManager::instance()->mDay.addKey(mIt->second.time / sHoursPerDay, + LLWLParamManager::getInstance()->mDay.addKey(mIt->second.time / sHoursPerDay, mIt->second.presetName); } // set the param manager's track to the new one - LLWLParamManager::instance()->resetAnimator( + LLWLParamManager::getInstance()->resetAnimator( tSldr->getCurSliderValue() / sHoursPerDay, false); - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } // static @@ -315,7 +317,7 @@ void LLFloaterDayCycle::onClose(bool app_quitting) void LLFloaterDayCycle::onNewPreset(void* userData) { - LLNotifications::instance().add("NewDaycyclePreset", LLSD(), LLSD(), newPromptCallback); + LLNotificationsUtil::add("NewDaycyclePreset", LLSD(), LLSD(), newPromptCallback); } void LLFloaterDayCycle::onSavePreset(void* userData) @@ -335,14 +337,14 @@ void LLFloaterDayCycle::onSavePreset(void* userData) comboBox->getSelectedItemLabel()); if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("SkyEditPresets")) { - LLNotifications::instance().add("WLNoEditDefault"); + LLNotificationsUtil::add("WLNoEditDefault"); return; } - LLWLParamManager::instance()->mCurParams.mName = + LLWLParamManager::getInstance()->mCurParams.mName = comboBox->getSelectedItemLabel(); - LLNotifications::instance().add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback); + LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback); } bool LLFloaterDayCycle::saveAlertCallback(const LLSD& notification, const LLSD& response) @@ -353,7 +355,7 @@ bool LLFloaterDayCycle::saveAlertCallback(const LLSD& notification, const LLSD& { LLComboBox* combo_box = sDayCycle->getChild("DayCyclePresetsCombo"); // comment this back in to save to file - LLWLParamManager::instance()->mDay.saveDayCycle(combo_box->getSelectedValue().asString()); + LLWLParamManager::getInstance()->mDay.saveDayCycle(combo_box->getSelectedValue().asString()); } return false; } @@ -370,7 +372,7 @@ void LLFloaterDayCycle::onDeletePreset(void* userData) LLSD args; args["SKY"] = combo_box->getSelectedValue().asString(); - LLNotifications::instance().add("WLDeletePresetAlert", args, LLSD(), + LLNotificationsUtil::add("WLDeletePresetAlert", args, LLSD(), boost::bind(&LLFloaterDayCycle::deleteAlertCallback, sDayCycle, _1, _2)); } @@ -401,7 +403,7 @@ bool LLFloaterDayCycle::deleteAlertCallback(const LLSD& notification, const LLSD std::set::iterator sIt = sDefaultPresets.find(name); if(sIt != sDefaultPresets.end()) { - LLNotifications::instance().add("WLNoEditDefault"); + LLNotificationsUtil::add("WLNoEditDefault"); return false; } @@ -483,13 +485,13 @@ bool LLFloaterDayCycle::newPromptCallback(const LLSD& notification, const LLSD& keyCombo->add(text); keyCombo->sortByName(); } - LLWLParamManager::instance()->mDay.saveDayCycle(text); + LLWLParamManager::getInstance()->mDay.saveDayCycle(text); // otherwise, send a message to the user } else { - LLNotifications::instance().add("ExistsSkyPresetAlert"); + LLNotificationsUtil::add("ExistsSkyPresetAlert"); } } return false; @@ -505,7 +507,7 @@ void LLFloaterDayCycle::onChangePresetName(LLUICtrl* ctrl, void * userData) return; } - LLWLParamManager::instance()->mDay.loadDayCycle(combo_box->getSelectedValue().asString()); + LLWLParamManager::getInstance()->mDay.loadDayCycle(combo_box->getSelectedValue().asString()); gSavedSettings.setString("AscentActiveDayCycle", combo_box->getSelectedValue().asString()); // sync it all up syncSliderTrack(); @@ -515,12 +517,12 @@ void LLFloaterDayCycle::onChangePresetName(LLUICtrl* ctrl, void * userData) LLMultiSliderCtrl* tSldr; tSldr = sDayCycle->getChild( "WLTimeSlider"); - LLWLParamManager::instance()->resetAnimator( + LLWLParamManager::getInstance()->resetAnimator( tSldr->getCurSliderValue() / sHoursPerDay, false); // and draw it - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } void LLFloaterDayCycle::onRunAnimSky(void* userData) @@ -539,13 +541,13 @@ void LLFloaterDayCycle::onRunAnimSky(void* userData) tSldr = sDayCycle->getChild("WLTimeSlider"); // turn off linden time - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = false; // set the param manager's track to the new one - LLWLParamManager::instance()->resetAnimator( + LLWLParamManager::getInstance()->resetAnimator( tSldr->getCurSliderValue() / sHoursPerDay, true); - llassert_always(LLWLParamManager::instance()->mAnimator.mTimeTrack.size() == sldr->getValue().size()); + llassert_always(LLWLParamManager::getInstance()->mAnimator.mTimeTrack.size() == sldr->getValue().size()); } void LLFloaterDayCycle::onStopAnimSky(void* userData) @@ -556,8 +558,8 @@ void LLFloaterDayCycle::onStopAnimSky(void* userData) } // turn off animation and using linden time - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.mIsRunning = false; + LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = false; } void LLFloaterDayCycle::onUseLindenTime(void* userData) @@ -566,13 +568,13 @@ void LLFloaterDayCycle::onUseLindenTime(void* userData) LLComboBox* box = dc->getChild("DayCyclePresetsCombo"); box->selectByValue(""); - LLWLParamManager::instance()->mAnimator.mIsRunning = true; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = true; + LLWLParamManager::getInstance()->mAnimator.mIsRunning = true; + LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = true; } void LLFloaterDayCycle::onLoadDayCycle(void* userData) { - //LLWLParamManager::instance()->mDay.loadDayCycle("Default.xml"); + //LLWLParamManager::getInstance()->mDay.loadDayCycle("Default.xml"); // sync it all up syncSliderTrack(); @@ -582,17 +584,17 @@ void LLFloaterDayCycle::onLoadDayCycle(void* userData) LLMultiSliderCtrl* tSldr; tSldr = sDayCycle->getChild( "WLTimeSlider"); - LLWLParamManager::instance()->resetAnimator( + LLWLParamManager::getInstance()->resetAnimator( tSldr->getCurSliderValue() / sHoursPerDay, false); // and draw it - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } void LLFloaterDayCycle::onSaveDayCycle(void* userData) { - //LLWLParamManager::instance()->mDay.saveDayCycle("Default.xml"); + //LLWLParamManager::getInstance()->mDay.saveDayCycle("Default.xml"); } @@ -605,13 +607,13 @@ void LLFloaterDayCycle::onTimeSliderMoved(LLUICtrl* ctrl, void* userData) F32 val = sldr->getCurSliderValue() / sHoursPerDay; // set the value, turn off animation - LLWLParamManager::instance()->mAnimator.setDayTime((F64)val); - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.setDayTime((F64)val); + LLWLParamManager::getInstance()->mAnimator.mIsRunning = false; + LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = false; // then call update once - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } void LLFloaterDayCycle::onKeyTimeMoved(LLUICtrl* ctrl, void* userData) @@ -736,7 +738,7 @@ void LLFloaterDayCycle::onTimeRateChanged(LLUICtrl* ctrl, void* userData) if(time <= 0) { time = 1; } - LLWLParamManager::instance()->mDay.mDayRate = time; + LLWLParamManager::getInstance()->mDay.mDayRate = time; syncTrack(); } diff --git a/indra/newview/llfloaterdisplayname.cpp b/indra/newview/llfloaterdisplayname.cpp index 25d103c61..1eb0ca856 100644 --- a/indra/newview/llfloaterdisplayname.cpp +++ b/indra/newview/llfloaterdisplayname.cpp @@ -29,7 +29,7 @@ #include "llviewerprecompiledheaders.h" #include "llfloater.h" -#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llviewerdisplayname.h" #include "llnotify.h" @@ -152,7 +152,7 @@ void LLFloaterDisplayName::onCacheSetName(bool success, // to percolate. LLSD args; args["DISPLAY_NAME"] = content["display_name"]; - LLNotifications::instance().add("SetDisplayNameSuccess", args); + LLNotificationsUtil::add("SetDisplayNameSuccess", args); // Re-fetch my name, as it may have been sanitized by the service //LLAvatarNameCache::get(getAvatarId(), @@ -180,12 +180,12 @@ void LLFloaterDisplayName::onCacheSetName(bool success, { LLSD args; args["MESSAGE"] = error_desc[lang_code].asString(); - LLNotifications::instance().add("GenericAlert", args); + LLNotificationsUtil::add("GenericAlert", args); return; } // No specific error, throw a generic one - LLNotifications::instance().add("SetDisplayNameFailedGeneric"); + LLNotificationsUtil::add("SetDisplayNameFailedGeneric"); } void LLFloaterDisplayName::onCancel(void* data) @@ -204,7 +204,7 @@ void LLFloaterDisplayName::onReset(void* data) } else { - LLNotifications::instance().add("SetDisplayNameFailedGeneric"); + LLNotificationsUtil::add("SetDisplayNameFailedGeneric"); } self->setVisible(false); @@ -219,7 +219,7 @@ void LLFloaterDisplayName::onSave(void* data) if (display_name_utf8.compare(display_name_confirm)) { - LLNotifications::instance().add("SetDisplayNameMismatch"); + LLNotificationsUtil::add("SetDisplayNameMismatch"); return; } @@ -229,7 +229,7 @@ void LLFloaterDisplayName::onSave(void* data) { LLSD args; args["LENGTH"] = llformat("%d", DISPLAY_NAME_MAX_LENGTH); - LLNotifications::instance().add("SetDisplayNameFailedLength", args); + LLNotificationsUtil::add("SetDisplayNameFailedLength", args); return; } @@ -240,7 +240,7 @@ void LLFloaterDisplayName::onSave(void* data) } else { - LLNotifications::instance().add("SetDisplayNameFailedGeneric"); + LLNotificationsUtil::add("SetDisplayNameFailedGeneric"); } self->setVisible(false); diff --git a/indra/newview/llfloaterenvsettings.cpp b/indra/newview/llfloaterenvsettings.cpp index 6a55b8598..196cf92b7 100644 --- a/indra/newview/llfloaterenvsettings.cpp +++ b/indra/newview/llfloaterenvsettings.cpp @@ -79,11 +79,11 @@ void LLFloaterEnvSettings::initCallbacks(void) childSetCommitCallback("EnvTimeSlider", onChangeDayTime, NULL); childSetCommitCallback("EnvCloudSlider", onChangeCloudCoverage, NULL); childSetCommitCallback("EnvWaterFogSlider", onChangeWaterFogDensity, - &LLWaterParamManager::instance()->mFogDensity); + &LLWaterParamManager::getInstance()->mFogDensity); // color picker childSetCommitCallback("EnvWaterColor", onChangeWaterColor, - &LLWaterParamManager::instance()->mFogColor); + &LLWaterParamManager::getInstance()->mFogColor); // WL Top childSetAction("EnvAdvancedSkyButton", onOpenAdvancedSky, NULL); @@ -102,7 +102,7 @@ void LLFloaterEnvSettings::syncMenu() sldr = sEnvSettings->getChild("EnvTimeSlider"); // sync the clock - F32 val = (F32)LLWLParamManager::instance()->mAnimator.getDayTime(); + F32 val = (F32)LLWLParamManager::getInstance()->mAnimator.getDayTime(); std::string timeStr = timeToString(val); LLTextBox* textBox; @@ -120,9 +120,9 @@ void LLFloaterEnvSettings::syncMenu() // sync cloud coverage bool err; - childSetValue("EnvCloudSlider", LLWLParamManager::instance()->mCurParams.getFloat("cloud_shadow", err)); + childSetValue("EnvCloudSlider", LLWLParamManager::getInstance()->mCurParams.getFloat("cloud_shadow", err)); - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamManager * param_mgr = LLWaterParamManager::getInstance(); // sync water params LLColor4 col = param_mgr->getFogColor(); LLColorSwatchCtrl* colCtrl = sEnvSettings->getChild("EnvWaterColor"); @@ -133,7 +133,7 @@ void LLFloaterEnvSettings::syncMenu() param_mgr->setDensitySliderValue(param_mgr->mFogDensity.mExp); // turn off Use Estate Time button if it's already being used - if(LLWLParamManager::instance()->mAnimator.mUseLindenTime) + if(LLWLParamManager::getInstance()->mAnimator.mUseLindenTime) { childDisable("EnvUseEstateTimeButton"); } else { @@ -218,8 +218,8 @@ void LLFloaterEnvSettings::onChangeDayTime(LLUICtrl* ctrl, void* userData) sldr = sEnvSettings->getChild("EnvTimeSlider"); // deactivate animator - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.mIsRunning = false; + LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = false; F32 val = sldr->getValueF32() + 0.25f; if(val > 1.0) @@ -227,9 +227,9 @@ void LLFloaterEnvSettings::onChangeDayTime(LLUICtrl* ctrl, void* userData) val--; } - LLWLParamManager::instance()->mAnimator.setDayTime((F64)val); - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.setDayTime((F64)val); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } void LLFloaterEnvSettings::onChangeCloudCoverage(LLUICtrl* ctrl, void* userData) @@ -238,11 +238,11 @@ void LLFloaterEnvSettings::onChangeCloudCoverage(LLUICtrl* ctrl, void* userData) sldr = sEnvSettings->getChild("EnvCloudSlider"); // deactivate animator - //LLWLParamManager::instance()->mAnimator.mIsRunning = false; - //LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + //LLWLParamManager::getInstance()->mAnimator.mIsRunning = false; + //LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = false; F32 val = sldr->getValueF32(); - LLWLParamManager::instance()->mCurParams.set("cloud_shadow", val); + LLWLParamManager::getInstance()->mCurParams.set("cloud_shadow", val); } void LLFloaterEnvSettings::onChangeWaterFogDensity(LLUICtrl* ctrl, void* userData) @@ -259,10 +259,10 @@ void LLFloaterEnvSettings::onChangeWaterFogDensity(LLUICtrl* ctrl, void* userDat F32 val = sldr->getValueF32(); expFloatControl->mExp = val; - LLWaterParamManager::instance()->setDensitySliderValue(val); + LLWaterParamManager::getInstance()->setDensitySliderValue(val); - expFloatControl->update(LLWaterParamManager::instance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + expFloatControl->update(LLWaterParamManager::getInstance()->mCurParams); + LLWaterParamManager::getInstance()->propagateParameters(); } void LLFloaterEnvSettings::onChangeWaterColor(LLUICtrl* ctrl, void* userData) @@ -271,8 +271,8 @@ void LLFloaterEnvSettings::onChangeWaterColor(LLUICtrl* ctrl, void* userData) WaterColorControl * colorControl = static_cast(userData); *colorControl = swatch->get(); - colorControl->update(LLWaterParamManager::instance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + colorControl->update(LLWaterParamManager::getInstance()->mCurParams); + LLWaterParamManager::getInstance()->propagateParameters(); } @@ -290,7 +290,7 @@ void LLFloaterEnvSettings::onSubmitWindlight(void* userData) { Meta7WindlightPacket * wl = new Meta7WindlightPacket(); - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamManager * param_mgr = LLWaterParamManager::getInstance(); wl->reflectionWaveletScale.X = param_mgr->mNormalScale.mX; wl->reflectionWaveletScale.Y = param_mgr->mNormalScale.mY; wl->reflectionWaveletScale.Z = param_mgr->mNormalScale.mZ; @@ -311,8 +311,8 @@ void LLFloaterEnvSettings::onUseEstateTime(void* userData) box->selectByValue(""); } - LLWLParamManager::instance()->mAnimator.mIsRunning = true; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = true; + LLWLParamManager::getInstance()->mAnimator.mIsRunning = true; + LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = true; } std::string LLFloaterEnvSettings::timeToString(F32 curTime) diff --git a/indra/newview/llfloaterfriends.cpp b/indra/newview/llfloaterfriends.cpp index 608078119..03eaa4ac5 100644 --- a/indra/newview/llfloaterfriends.cpp +++ b/indra/newview/llfloaterfriends.cpp @@ -55,7 +55,7 @@ #include "llfloateravatarinfo.h" #include "llinventorymodel.h" #include "llnamelistctrl.h" -#include "llnotify.h" +#include "llnotificationsutil.h" #include "llresmgr.h" #include "llimview.h" #include "lluictrlfactory.h" @@ -820,7 +820,7 @@ void LLPanelFriends::onMaximumSelect(void* user_data) { LLSD args; args["MAX_SELECT"] = llformat("%d", MAX_FRIEND_SELECT); - LLNotifications::instance().add("MaxListSelectMessage", args); + LLNotificationsUtil::add("MaxListSelectMessage", args); }; // static @@ -942,7 +942,7 @@ void LLPanelFriends::requestFriendship(const LLUUID& target_id, const std::strin // static bool LLPanelFriends::callbackAddFriendWithMessage(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option == 0) { requestFriendship(notification["payload"]["id"].asUUID(), @@ -985,7 +985,7 @@ void LLPanelFriends::requestFriendshipDialog(const LLUUID& id, { if(id == gAgentID) { - LLNotifications::instance().add("AddSelfFriend"); + LLNotificationsUtil::add("AddSelfFriend"); return; } @@ -999,11 +999,11 @@ void LLPanelFriends::requestFriendshipDialog(const LLUUID& id, { // Old and busted server version, doesn't support friend // requests with messages. - LLNotifications::instance().add("AddFriend", args, payload, &callbackAddFriend); + LLNotificationsUtil::add("AddFriend", args, payload, &callbackAddFriend); } else { - LLNotifications::instance().add("AddFriendWithMessage", args, payload, &callbackAddFriendWithMessage); + LLNotificationsUtil::add("AddFriendWithMessage", args, payload, &callbackAddFriendWithMessage); } } @@ -1325,14 +1325,14 @@ void LLPanelFriends::confirmModifyRights(rights_map_t& ids, EGrantRevoke command if (command == GRANT) { - LLNotifications::instance().add("GrantModifyRights", + LLNotificationsUtil::add("GrantModifyRights", args, LLSD(), boost::bind(&LLPanelFriends::modifyRightsConfirmation, this, _1, _2, rights)); } else { - LLNotifications::instance().add("RevokeModifyRights", + LLNotificationsUtil::add("RevokeModifyRights", args, LLSD(), boost::bind(&LLPanelFriends::modifyRightsConfirmation, this, _1, _2, rights)); @@ -1342,14 +1342,14 @@ void LLPanelFriends::confirmModifyRights(rights_map_t& ids, EGrantRevoke command { if (command == GRANT) { - LLNotifications::instance().add("GrantModifyRightsMultiple", + LLNotificationsUtil::add("GrantModifyRightsMultiple", args, LLSD(), boost::bind(&LLPanelFriends::modifyRightsConfirmation, this, _1, _2, rights)); } else { - LLNotifications::instance().add("RevokeModifyRightsMultiple", + LLNotificationsUtil::add("RevokeModifyRightsMultiple", args, LLSD(), boost::bind(&LLPanelFriends::modifyRightsConfirmation, this, _1, _2, rights)); @@ -1360,7 +1360,7 @@ void LLPanelFriends::confirmModifyRights(rights_map_t& ids, EGrantRevoke command bool LLPanelFriends::modifyRightsConfirmation(const LLSD& notification, const LLSD& response, rights_map_t* rights) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if(0 == option) { sendRightsGrant(*rights); @@ -1504,7 +1504,7 @@ void LLPanelFriends::sendRightsGrant(rights_map_t& ids) // static bool LLPanelFriends::handleRemove(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); const LLSD& ids = notification["payload"]["ids"]; for(LLSD::array_const_iterator itr = ids.beginArray(); itr != ids.endArray(); ++itr) diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp index cf641e0ea..78d7a6b28 100644 --- a/indra/newview/llfloatergesture.cpp +++ b/indra/newview/llfloatergesture.cpp @@ -86,13 +86,13 @@ LLFloaterGesture::LLFloaterGesture() sInstance = this; sObserver = new LLFloaterGestureObserver; - gGestureManager.addObserver(sObserver); + LLGestureMgr::instance().addObserver(sObserver); } // virtual LLFloaterGesture::~LLFloaterGesture() { - gGestureManager.removeObserver(sObserver); + LLGestureMgr::instance().removeObserver(sObserver); delete sObserver; sObserver = NULL; @@ -223,8 +223,8 @@ void LLFloaterGesture::buildGestureList() list->operateOnAll(LLCtrlListInterface::OP_DELETE); - LLGestureManager::item_map_t::iterator it; - for (it = gGestureManager.mActive.begin(); it != gGestureManager.mActive.end(); ++it) + LLGestureMgr::item_map_t::const_iterator it; + for (it = LLGestureMgr::instance().getActiveGestures().begin(); it != LLGestureMgr::instance().getActiveGestures().end(); ++it) { const LLUUID& item_id = (*it).first; LLMultiGesture* gesture = (*it).second; @@ -344,13 +344,13 @@ void LLFloaterGesture::onClickPlay(void* data) if (!list) return; const LLUUID& item_id = list->getCurrentID(); - if (gGestureManager.isGesturePlaying(item_id)) + if (LLGestureMgr::instance().isGesturePlaying(item_id)) { - gGestureManager.stopGesture(item_id); + LLGestureMgr::instance().stopGesture(item_id); } else { - gGestureManager.playGesture(item_id); + LLGestureMgr::instance().playGesture(item_id); } } @@ -411,7 +411,7 @@ void LLFloaterGesture::onCommitList(LLUICtrl* ctrl, void* data) const LLUUID& item_id = self->childGetValue("gesture_list").asUUID(); self->mSelectedID = item_id; - if (gGestureManager.isGesturePlaying(item_id)) + if (LLGestureMgr::instance().isGesturePlaying(item_id)) { self->childSetVisible("play_btn", false); self->childSetVisible("stop_btn", true); diff --git a/indra/newview/llfloatergodtools.cpp b/indra/newview/llfloatergodtools.cpp index f918e8a46..9eff1a2c4 100644 --- a/indra/newview/llfloatergodtools.cpp +++ b/indra/newview/llfloatergodtools.cpp @@ -39,6 +39,7 @@ #include "llframetimer.h" #include "llgl.h" #include "llhost.h" +#include "llnotificationsutil.h" #include "llregionflags.h" #include "llstring.h" #include "message.h" @@ -931,7 +932,7 @@ void LLPanelGridTools::onClickKickAll(void* userdata) gFloaterView->getNewFloaterPosition(&left, &top); LLRect rect(left, top, left+400, top-300); - LLNotifications::instance().add("KickAllUsers", LLSD(), LLSD(), LLPanelGridTools::confirmKick); + LLNotificationsUtil::add("KickAllUsers", LLSD(), LLSD(), LLPanelGridTools::confirmKick); } @@ -941,7 +942,7 @@ bool LLPanelGridTools::confirmKick(const LLSD& notification, const LLSD& respons { LLSD payload; payload["kick_message"] = response["message"].asString(); - LLNotifications::instance().add("ConfirmKick", LLSD(), payload, LLPanelGridTools::finishKick); + LLNotificationsUtil::add("ConfirmKick", LLSD(), payload, LLPanelGridTools::finishKick); } return false; } @@ -973,7 +974,7 @@ bool LLPanelGridTools::finishKick(const LLSD& notification, const LLSD& response // static void LLPanelGridTools::onClickFlushMapVisibilityCaches(void* data) { - LLNotifications::instance().add("FlushMapVisibilityCaches", LLSD(), LLSD(), flushMapVisibilityCachesConfirm); + LLNotificationsUtil::add("FlushMapVisibilityCaches", LLSD(), LLSD(), flushMapVisibilityCachesConfirm); } // static @@ -1435,7 +1436,7 @@ void LLPanelRequestTools::onClickRequest(void* data) void terrain_download_done(void** data, S32 status, LLExtStat ext_status) { - LLNotifications::instance().add("TerrainDownloaded"); + LLNotificationsUtil::add("TerrainDownloaded"); } diff --git a/indra/newview/llfloatergroups.cpp b/indra/newview/llfloatergroups.cpp index 72455bb8b..0e2f8d6d0 100644 --- a/indra/newview/llfloatergroups.cpp +++ b/indra/newview/llfloatergroups.cpp @@ -54,6 +54,7 @@ #include "llalertdialog.h" #include "llselectmgr.h" #include "llscrolllistctrl.h" +#include "llnotificationsutil.h" #include "lltextbox.h" #include "lluictrlfactory.h" #include "llviewerwindow.h" @@ -425,7 +426,7 @@ void LLPanelGroups::leave() args["GROUP"] = gAgent.mGroups.get(i).mName; LLSD payload; payload["group_id"] = group_id; - LLNotifications::instance().add("GroupLeaveConfirmMember", args, payload, callbackLeaveGroup); + LLNotificationsUtil::add("GroupLeaveConfirmMember", args, payload, callbackLeaveGroup); } } } diff --git a/indra/newview/llfloaterhardwaresettings.cpp b/indra/newview/llfloaterhardwaresettings.cpp index 23da0629b..d1d19e86c 100644 --- a/indra/newview/llfloaterhardwaresettings.cpp +++ b/indra/newview/llfloaterhardwaresettings.cpp @@ -35,6 +35,7 @@ #include "llfloaterhardwaresettings.h" #include "llfloaterpreference.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llviewercontrol.h" #include "llviewertexturelist.h" #include "llfeaturemanager.h" diff --git a/indra/newview/llfloaterhud.cpp b/indra/newview/llfloaterhud.cpp index 6324b5656..33fbec1d4 100644 --- a/indra/newview/llfloaterhud.cpp +++ b/indra/newview/llfloaterhud.cpp @@ -40,6 +40,7 @@ #include "llalertdialog.h" // Linden libs +#include "llnotificationsutil.h" #include "lluictrlfactory.h" // statics @@ -125,7 +126,7 @@ void LLFloaterHUD::showHUD() // do not build the floater if there the url is empty if (gSavedSettings.getString("TutorialURL") == "") { - LLNotifications::instance().add("TutorialNotFound"); + LLNotificationsUtil::add("TutorialNotFound"); return; } diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 57d5a004e..6ccc45376 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -39,6 +39,7 @@ #include "llcachename.h" #include "llfocusmgr.h" +#include "llnotificationsutil.h" #include "llparcel.h" #include "message.h" #include "lluserauth.h" @@ -932,7 +933,7 @@ void LLPanelLandGeneral::onClickBuyPass(void* data) args["PARCEL_NAME"] = parcel_name; args["TIME"] = time; - LLNotifications::instance().add("LandBuyPass", args, LLSD(), cbBuyPass); + LLNotificationsUtil::add("LandBuyPass", args, LLSD(), cbBuyPass); } // static @@ -944,7 +945,7 @@ void LLPanelLandGeneral::onClickStartAuction(void* data) { if(parcelp->getForSale()) { - LLNotifications::instance().add("CannotStartAuctionAlreadyForSale"); + LLNotificationsUtil::add("CannotStartAuctionAlreadyForSale"); } else { @@ -956,7 +957,7 @@ void LLPanelLandGeneral::onClickStartAuction(void* data) // static bool LLPanelLandGeneral::cbBuyPass(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (0 == option) { // User clicked OK @@ -1303,7 +1304,7 @@ void send_return_objects_message(S32 parcel_local_id, S32 return_type, bool LLPanelLandObjects::callbackReturnOwnerObjects(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); LLParcel *parcel = mParcel->getParcel(); if (0 == option) { @@ -1313,14 +1314,14 @@ bool LLPanelLandObjects::callbackReturnOwnerObjects(const LLSD& notification, co LLSD args; if (owner_id == gAgentID) { - LLNotifications::instance().add("OwnedObjectsReturned"); + LLNotificationsUtil::add("OwnedObjectsReturned"); } else { std::string full_name; gCacheName->getFullName(owner_id, full_name); args["NAME"] = full_name; - LLNotifications::instance().add("OtherObjectsReturned", args); + LLNotificationsUtil::add("OtherObjectsReturned", args); } send_return_objects_message(parcel->getLocalID(), RT_OWNER); } @@ -1334,7 +1335,7 @@ bool LLPanelLandObjects::callbackReturnOwnerObjects(const LLSD& notification, co bool LLPanelLandObjects::callbackReturnGroupObjects(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); LLParcel *parcel = mParcel->getParcel(); if (0 == option) { @@ -1344,7 +1345,7 @@ bool LLPanelLandObjects::callbackReturnGroupObjects(const LLSD& notification, co gCacheName->getGroupName(parcel->getGroupID(), group_name); LLSD args; args["GROUPNAME"] = group_name; - LLNotifications::instance().add("GroupObjectsReturned", args); + LLNotificationsUtil::add("GroupObjectsReturned", args); send_return_objects_message(parcel->getLocalID(), RT_GROUP); } } @@ -1356,13 +1357,13 @@ bool LLPanelLandObjects::callbackReturnGroupObjects(const LLSD& notification, co bool LLPanelLandObjects::callbackReturnOtherObjects(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); LLParcel *parcel = mParcel->getParcel(); if (0 == option) { if (parcel) { - LLNotifications::instance().add("UnOwnedObjectsReturned"); + LLNotificationsUtil::add("UnOwnedObjectsReturned"); send_return_objects_message(parcel->getLocalID(), RT_OTHER); } } @@ -1374,7 +1375,7 @@ bool LLPanelLandObjects::callbackReturnOtherObjects(const LLSD& notification, co bool LLPanelLandObjects::callbackReturnOwnerList(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); LLParcel *parcel = mParcel->getParcel(); if (0 == option) { @@ -1388,12 +1389,12 @@ bool LLPanelLandObjects::callbackReturnOwnerList(const LLSD& notification, const if (mSelectedIsGroup) { args["GROUPNAME"] = mSelectedName; - LLNotifications::instance().add("GroupObjectsReturned", args); + LLNotificationsUtil::add("GroupObjectsReturned", args); } else { args["NAME"] = mSelectedName; - LLNotifications::instance().add("OtherObjectsReturned2", args); + LLNotificationsUtil::add("OtherObjectsReturned2", args); } send_return_objects_message(parcel->getLocalID(), RT_LIST, &(mSelectedOwners)); @@ -1430,11 +1431,11 @@ void LLPanelLandObjects::onClickReturnOwnerList(void* userdata) args["N"] = llformat("%d",self->mSelectedCount); if (self->mSelectedIsGroup) { - LLNotifications::instance().add("ReturnObjectsDeededToGroup", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOwnerList, self, _1, _2)); + LLNotificationsUtil::add("ReturnObjectsDeededToGroup", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOwnerList, self, _1, _2)); } else { - LLNotifications::instance().add("ReturnObjectsOwnedByUser", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOwnerList, self, _1, _2)); + LLNotificationsUtil::add("ReturnObjectsOwnedByUser", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOwnerList, self, _1, _2)); } } @@ -1659,14 +1660,14 @@ void LLPanelLandObjects::onClickReturnOwnerObjects(void* userdata) if (owner_id == gAgent.getID()) { - LLNotifications::instance().add("ReturnObjectsOwnedBySelf", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOwnerObjects, panelp, _1, _2)); + LLNotificationsUtil::add("ReturnObjectsOwnedBySelf", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOwnerObjects, panelp, _1, _2)); } else { std::string name; gCacheName->getFullName(owner_id, name); args["NAME"] = name; - LLNotifications::instance().add("ReturnObjectsOwnedByUser", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOwnerObjects, panelp, _1, _2)); + LLNotificationsUtil::add("ReturnObjectsOwnedByUser", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOwnerObjects, panelp, _1, _2)); } } @@ -1687,7 +1688,7 @@ void LLPanelLandObjects::onClickReturnGroupObjects(void* userdata) args["N"] = llformat("%d", parcel->getGroupPrimCount()); // create and show confirmation textbox - LLNotifications::instance().add("ReturnObjectsDeededToGroup", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnGroupObjects, panelp, _1, _2)); + LLNotificationsUtil::add("ReturnObjectsDeededToGroup", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnGroupObjects, panelp, _1, _2)); } // static @@ -1712,7 +1713,7 @@ void LLPanelLandObjects::onClickReturnOtherObjects(void* userdata) gCacheName->getGroupName(parcel->getGroupID(), group_name); args["NAME"] = group_name; - LLNotifications::instance().add("ReturnObjectsNotOwnedByGroup", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOtherObjects, panelp, _1, _2)); + LLNotificationsUtil::add("ReturnObjectsNotOwnedByGroup", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOtherObjects, panelp, _1, _2)); } else { @@ -1720,15 +1721,14 @@ void LLPanelLandObjects::onClickReturnOtherObjects(void* userdata) if (owner_id == gAgent.getID()) { - LLNotifications::instance().add("ReturnObjectsNotOwnedBySelf", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOtherObjects, panelp, _1, _2)); + LLNotificationsUtil::add("ReturnObjectsNotOwnedBySelf", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOtherObjects, panelp, _1, _2)); } else { std::string name; gCacheName->getFullName(owner_id, name); args["NAME"] = name; - - LLNotifications::instance().add("ReturnObjectsNotOwnedByUser", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOtherObjects, panelp, _1, _2)); + LLNotificationsUtil::add("ReturnObjectsNotOwnedByUser", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOtherObjects, panelp, _1, _2)); } } } @@ -2221,7 +2221,7 @@ void LLPanelLandOptions::onCommitAny(LLUICtrl *ctrl, void *userdata) if (!allow_other_scripts && region && region->getAllowDamage()) { - LLNotifications::instance().add("UnableToDisableOutsideScripts"); + LLNotificationsUtil::add("UnableToDisableOutsideScripts"); return; } @@ -2265,7 +2265,7 @@ void LLPanelLandOptions::onClickSet(void* userdata) if (agent_parcel->getLocalID() != selected_parcel->getLocalID()) { - LLNotifications::instance().add("MustBeInParcel"); + LLNotificationsUtil::add("MustBeInParcel"); return; } @@ -2308,11 +2308,11 @@ void LLPanelLandOptions::onClickPublishHelp(void*) if(! can_change_identity) { - LLNotifications::instance().add("ClickPublishHelpLandDisabled"); + LLNotificationsUtil::add("ClickPublishHelpLandDisabled"); } else { - LLNotifications::instance().add("ClickPublishHelpLand"); + LLNotificationsUtil::add("ClickPublishHelpLand"); } } diff --git a/indra/newview/llfloaterlandmark.cpp b/indra/newview/llfloaterlandmark.cpp index 6f0940c9b..49d3874d6 100644 --- a/indra/newview/llfloaterlandmark.cpp +++ b/indra/newview/llfloaterlandmark.cpp @@ -46,6 +46,7 @@ #include "llpermissions.h" #include "llsaleinfo.h" #include "llparcel.h" +#include "llnotificationsutil.h" #include "llviewerwindow.h" // alertXml #include "llviewercontrol.h" @@ -296,7 +297,7 @@ void LLFloaterLandmark::onBtnNew(void* userdata) if (!agent_parcel->getAllowLandmark() && !LLViewerParcelMgr::isParcelOwnedByAgent(agent_parcel, GP_LAND_ALLOW_LANDMARK)) { - LLNotifications::instance().add("CannotCreateLandmarkNotOwner"); + LLNotificationsUtil::add("CannotCreateLandmarkNotOwner"); return; } diff --git a/indra/newview/llfloatermediabrowser.cpp b/indra/newview/llfloatermediabrowser.cpp index a90ea14f3..d73cfde72 100644 --- a/indra/newview/llfloatermediabrowser.cpp +++ b/indra/newview/llfloatermediabrowser.cpp @@ -45,13 +45,14 @@ #include "llweb.h" #include "llui.h" #include "roles_constants.h" +#include "llwindow.h" #include "llurlhistory.h" #include "llmediactrl.h" #include "llviewermedia.h" #include "llviewerparcelmedia.h" #include "llcombobox.h" - +#include "llnotificationsutil.h" // TEMP #include "llsdutil.h" @@ -414,7 +415,7 @@ void LLViewerHtmlHelp::show(std::string url) LLSD notificationData; notificationData["url"] = url; - LLNotifications::instance().add("ClickOpenF1Help", notificationData, LLSD(), onClickF1HelpLoadURL); + LLNotificationsUtil::add("ClickOpenF1Help", notificationData, LLSD(), onClickF1HelpLoadURL); floater_html->close(); } else diff --git a/indra/newview/llfloatermessagelog.cpp b/indra/newview/llfloatermessagelog.cpp index 74241d35e..57ffac013 100644 --- a/indra/newview/llfloatermessagelog.cpp +++ b/indra/newview/llfloatermessagelog.cpp @@ -3,6 +3,7 @@ #include "llfloatermessagelog.h" #include "lluictrlfactory.h" #include "llworld.h" +#include "llnotificationsutil.h" #include "llviewerregion.h" #include "llscrolllistctrl.h" #include "lltexteditor.h" @@ -819,7 +820,7 @@ BOOL LLFloaterMessageLog::onClickCloseCircuit(void* user_data) args["MESSAGE"] = "This will delete local circuit data.\nDo you want to tell the remote host to close the circuit too?"; LLSD payload; payload["circuittoclose"] = myhost.getString(); - LLNotifications::instance().add("GenericAlertYesCancel", args, payload, onConfirmCloseCircuit); + LLNotificationsUtil::add("GenericAlertYesCancel", args, payload, onConfirmCloseCircuit); return TRUE; } // static @@ -853,7 +854,7 @@ bool LLFloaterMessageLog::onConfirmCloseCircuit(const LLSD& notification, const args["MESSAGE"] = "That host had a region associated with it.\nDo you want to clean that up?"; LLSD payload; payload["regionhost"] = myhost.getString(); - LLNotifications::instance().add("GenericAlertYesCancel", args, payload, onConfirmRemoveRegion); + LLNotificationsUtil::add("GenericAlertYesCancel", args, payload, onConfirmRemoveRegion); } return false; } diff --git a/indra/newview/llfloatermute.cpp b/indra/newview/llfloatermute.cpp index 179650ce5..8e071dcde 100644 --- a/indra/newview/llfloatermute.cpp +++ b/indra/newview/llfloatermute.cpp @@ -39,6 +39,7 @@ #include "llerror.h" #include "llstring.h" #include "message.h" +#include "llnotificationsutil.h" // project include #include "llagent.h" @@ -349,6 +350,6 @@ void LLFloaterMute::callbackMuteByName(const std::string& text, void* data) BOOL success = LLMuteList::getInstance()->add(mute); if (!success) { - LLNotifications::instance().add("MuteByNameFailed"); + LLNotificationsUtil::add("MuteByNameFailed"); } } diff --git a/indra/newview/llfloateropenobject.cpp b/indra/newview/llfloateropenobject.cpp index 6d2d1f7ab..71d413f33 100644 --- a/indra/newview/llfloateropenobject.cpp +++ b/indra/newview/llfloateropenobject.cpp @@ -41,6 +41,7 @@ #include "llcachename.h" #include "llbutton.h" +#include "llnotificationsutil.h" #include "lltextbox.h" #include "llagent.h" // for agent id @@ -76,6 +77,28 @@ LLFloaterOpenObject::~LLFloaterOpenObject() sInstance = NULL; } +// static +void LLFloaterOpenObject::show() +{ + LLObjectSelectionHandle object_selection = LLSelectMgr::getInstance()->getSelection(); + if (object_selection->getRootObjectCount() != 1) + { + LLNotificationsUtil::add("UnableToViewContentsMoreThanOne"); + return; + } + + // Create a new instance only if needed + if (!sInstance) + { + sInstance = new LLFloaterOpenObject(); + sInstance->center(); + } + + sInstance->open(); /* Flawfinder: ignore */ + sInstance->setFocus(TRUE); + + sInstance->mObjectSelection = LLSelectMgr::getInstance()->getEditSelection(); +} void LLFloaterOpenObject::refresh() { mPanelInventory->refresh(); @@ -104,35 +127,13 @@ void LLFloaterOpenObject::dirty() if (sInstance) sInstance->mDirty = TRUE; } -// static -void LLFloaterOpenObject::show() -{ - LLObjectSelectionHandle object_selection = LLSelectMgr::getInstance()->getSelection(); - if (object_selection->getRootObjectCount() != 1) - { - LLNotifications::instance().add("UnableToViewContentsMoreThanOne"); - return; - } - - // Create a new instance only if needed - if (!sInstance) - { - sInstance = new LLFloaterOpenObject(); - sInstance->center(); - } - - sInstance->open(); /* Flawfinder: ignore */ - sInstance->setFocus(TRUE); - - sInstance->mObjectSelection = LLSelectMgr::getInstance()->getEditSelection(); -} void LLFloaterOpenObject::moveToInventory(bool wear) { if (mObjectSelection->getRootObjectCount() != 1) { - LLNotifications::instance().add("OnlyCopyContentsOfSingleItem"); + LLNotificationsUtil::add("OnlyCopyContentsOfSingleItem"); return; } @@ -173,7 +174,7 @@ void LLFloaterOpenObject::moveToInventory(bool wear) delete data; data = NULL; - LLNotifications::instance().add("OpenObjectCannotCopy"); + LLNotificationsUtil::add("OpenObjectCannotCopy"); } } diff --git a/indra/newview/llfloaterperms.cpp b/indra/newview/llfloaterperms.cpp index cd3553b92..ccbeb8c5c 100644 --- a/indra/newview/llfloaterperms.cpp +++ b/indra/newview/llfloaterperms.cpp @@ -35,6 +35,7 @@ #include "llalertdialog.h" #include "llcheckboxctrl.h" #include "llfloaterperms.h" +#include "llnotificationsutil.h" #include "llviewercontrol.h" #include "llviewerwindow.h" #include "lluictrlfactory.h" @@ -155,5 +156,5 @@ U32 LLFloaterPerms::getNextOwnerPerms(std::string prefix) //static void LLFloaterPerms::onClickHelp(void* data) { - LLNotifications::instance().add("ClickUploadHelpPermissions"); + LLNotificationsUtil::add("ClickUploadHelpPermissions"); } diff --git a/indra/newview/llfloaterpostcard.cpp b/indra/newview/llfloaterpostcard.cpp index c2f76c354..fe7d7816f 100644 --- a/indra/newview/llfloaterpostcard.cpp +++ b/indra/newview/llfloaterpostcard.cpp @@ -45,6 +45,7 @@ #include "lllineeditor.h" #include "llviewertexteditor.h" #include "llbutton.h" +#include "llnotificationsutil.h" #include "llviewercontrol.h" #include "llviewernetwork.h" #include "lluictrlfactory.h" @@ -255,20 +256,20 @@ void LLFloaterPostcard::onClickSend(void* data) if (to.empty() || !boost::regex_match(to, emailFormat)) { - LLNotifications::instance().add("PromptRecipientEmail"); + LLNotificationsUtil::add("PromptRecipientEmail"); return; } if (from.empty() || !boost::regex_match(from, emailFormat)) { - LLNotifications::instance().add("PromptSelfEmail"); + LLNotificationsUtil::add("PromptSelfEmail"); return; } std::string subject(self->childGetValue("subject_form").asString()); if(subject.empty() || !self->mHasFirstMsgFocus) { - LLNotifications::instance().add("PromptMissingSubjMsg", LLSD(), LLSD(), boost::bind(&LLFloaterPostcard::missingSubjMsgAlertCallback, self, _1, _2)); + LLNotificationsUtil::add("PromptMissingSubjMsg", LLSD(), LLSD(), boost::bind(&LLFloaterPostcard::missingSubjMsgAlertCallback, self, _1, _2)); return; } @@ -278,7 +279,7 @@ void LLFloaterPostcard::onClickSend(void* data) } else { - LLNotifications::instance().add("ErrorProcessingSnapshot"); + LLNotificationsUtil::add("ErrorProcessingSnapshot"); } } } @@ -294,7 +295,7 @@ void LLFloaterPostcard::uploadCallback(const LLUUID& asset_id, void *user_data, { LLSD args; args["REASON"] = std::string(LLAssetStorage::getErrorString(result)); - LLNotifications::instance().add("ErrorUploadingPostcard", args); + LLNotificationsUtil::add("ErrorUploadingPostcard", args); } else { @@ -353,7 +354,7 @@ void LLFloaterPostcard::onMsgFormFocusRecieved(LLFocusableElement* receiver, voi bool LLFloaterPostcard::missingSubjMsgAlertCallback(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if(0 == option) { // User clicked OK diff --git a/indra/newview/llfloaterpostprocess.cpp b/indra/newview/llfloaterpostprocess.cpp index a7e4e7a3e..19346c19b 100644 --- a/indra/newview/llfloaterpostprocess.cpp +++ b/indra/newview/llfloaterpostprocess.cpp @@ -36,6 +36,7 @@ #include "llsliderctrl.h" #include "llcheckboxctrl.h" +#include "llnotificationsutil.h" #include "lluictrlfactory.h" #include "llviewerdisplay.h" #include "llpostprocess.h" @@ -180,7 +181,7 @@ void LLFloaterPostProcess::onSaveEffect(void* userData) { LLSD payload; payload["effect_name"] = effectName; - LLNotifications::instance().add("PPSaveEffectAlert", LLSD(), payload, &LLFloaterPostProcess::saveAlertCallback); + LLNotificationsUtil::add("PPSaveEffectAlert", LLSD(), payload, &LLFloaterPostProcess::saveAlertCallback); } else { @@ -201,7 +202,7 @@ void LLFloaterPostProcess::onChangeEffectName(LLUICtrl* ctrl, void * userData) bool LLFloaterPostProcess::saveAlertCallback(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); // if they choose save, do it. Otherwise, don't do anything if (option == 0) diff --git a/indra/newview/llfloaterproperties.cpp b/indra/newview/llfloaterproperties.cpp index 62ecd8faf..c9c8e0482 100644 --- a/indra/newview/llfloaterproperties.cpp +++ b/indra/newview/llfloaterproperties.cpp @@ -38,6 +38,7 @@ #include "llcachename.h" #include "lldbstrings.h" #include "llinventory.h" +#include "llinventorydefines.h" #include "llagent.h" #include "llbutton.h" diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index fbf7d2e34..6e07e2b03 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -64,6 +64,8 @@ #include "lllineeditor.h" #include "llalertdialog.h" #include "llnamelistctrl.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llsliderctrl.h" #include "llspinctrl.h" #include "lltabcontainer.h" @@ -79,7 +81,7 @@ #include "llviewertexteditor.h" #include "llviewerwindow.h" #include "llvlcomposition.h" - +#include "llagentui.h" // [RLVa:KB] #include "rlvhandler.h" // [/RLVa:KB] @@ -656,7 +658,7 @@ void LLPanelRegionGeneralInfo::onKickCommit(const std::vector& name void LLPanelRegionGeneralInfo::onClickKickAll(void* userdata) { llinfos << "LLPanelRegionGeneralInfo::onClickKickAll" << llendl; - LLNotifications::instance().add("KickUsersFromRegion", + LLNotificationsUtil::add("KickUsersFromRegion", LLSD(), LLSD(), boost::bind(&LLPanelRegionGeneralInfo::onKickAllCommit, (LLPanelRegionGeneralInfo*)userdata, _1, _2)); @@ -664,7 +666,7 @@ void LLPanelRegionGeneralInfo::onClickKickAll(void* userdata) bool LLPanelRegionGeneralInfo::onKickAllCommit(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option == 0) { strings_t strings; @@ -684,7 +686,7 @@ bool LLPanelRegionGeneralInfo::onKickAllCommit(const LLSD& notification, const L void LLPanelRegionGeneralInfo::onClickMessage(void* userdata) { llinfos << "LLPanelRegionGeneralInfo::onClickMessage" << llendl; - LLNotifications::instance().add("MessageRegion", + LLNotificationsUtil::add("MessageRegion", LLSD(), LLSD(), boost::bind(&LLPanelRegionGeneralInfo::onMessageCommit, (LLPanelRegionGeneralInfo*)userdata, _1, _2)); @@ -693,7 +695,7 @@ void LLPanelRegionGeneralInfo::onClickMessage(void* userdata) // static bool LLPanelRegionGeneralInfo::onMessageCommit(const LLSD& notification, const LLSD& response) { - if(LLNotification::getSelectedOption(notification, response) != 0) return false; + if(LLNotificationsUtil::getSelectedOption(notification, response) != 0) return false; std::string text = response["message"].asString(); if (text.empty()) return false; @@ -711,7 +713,7 @@ bool LLPanelRegionGeneralInfo::onMessageCommit(const LLSD& notification, const L gAgent.getID().toString(buffer); strings.push_back(buffer); std::string name; - gAgent.buildFullname(name); + LLAgentUI::buildFullname(name); strings.push_back(strings_t::value_type(name)); strings.push_back(strings_t::value_type(text)); LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); @@ -802,7 +804,7 @@ BOOL LLPanelRegionGeneralInfo::sendUpdate() LLViewerRegion* region = gAgent.getRegion(); if (region && (childGetValue("access_combo").asInteger() != region->getSimAccess()) ) { - LLNotifications::instance().add("RegionMaturityChange"); + LLNotificationsUtil::add("RegionMaturityChange"); } return TRUE; @@ -916,13 +918,13 @@ void LLPanelRegionDebugInfo::onClickReturn(void* data) } payload["flags"] = int(flags); payload["return_estate_wide"] = panelp->childGetValue("return_estate_wide").asBoolean(); - LLNotifications::instance().add("EstateObjectReturn", args, payload, + LLNotificationsUtil::add("EstateObjectReturn", args, payload, boost::bind(&LLPanelRegionDebugInfo::callbackReturn, panelp, _1, _2)); } bool LLPanelRegionDebugInfo::callbackReturn(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option != 0) return false; LLUUID target_avatar = notification["payload"]["avatar_id"].asUUID(); @@ -978,13 +980,13 @@ void LLPanelRegionDebugInfo::onClickTopScripts(void* data) // static void LLPanelRegionDebugInfo::onClickRestart(void* data) { - LLNotifications::instance().add("ConfirmRestart", LLSD(), LLSD(), + LLNotificationsUtil::add("ConfirmRestart", LLSD(), LLSD(), boost::bind(&LLPanelRegionDebugInfo::callbackRestart, (LLPanelRegionDebugInfo*)data, _1, _2)); } bool LLPanelRegionDebugInfo::callbackRestart(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option != 0) return false; strings_t strings; @@ -1153,7 +1155,7 @@ BOOL LLPanelRegionTextureInfo::validateTextureSizes() LLSD args; args["TEXTURE_NUM"] = i+1; args["TEXTURE_BIT_DEPTH"] = llformat("%d",components * 8); - LLNotifications::instance().add("InvalidTerrainBitDepth", args); + LLNotificationsUtil::add("InvalidTerrainBitDepth", args); return FALSE; } @@ -1164,7 +1166,7 @@ BOOL LLPanelRegionTextureInfo::validateTextureSizes() args["TEXTURE_NUM"] = i+1; args["TEXTURE_SIZE_X"] = width; args["TEXTURE_SIZE_Y"] = height; - LLNotifications::instance().add("InvalidTerrainSize", args); + LLNotificationsUtil::add("InvalidTerrainSize", args); return FALSE; } @@ -1370,20 +1372,18 @@ void LLPanelRegionTerrainInfo::onClickUploadRaw_continued(AIFilePicker* filepick LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); - LLNotifications::instance().add("RawUploadStarted"); + LLNotificationsUtil::add("RawUploadStarted"); } // static void LLPanelRegionTerrainInfo::onClickBakeTerrain(void* data) { - LLNotifications::instance().add( - LLNotification::Params("ConfirmBakeTerrain") - .functor(boost::bind(&LLPanelRegionTerrainInfo::callbackBakeTerrain, (LLPanelRegionTerrainInfo*)data, _1, _2))); + LLNotificationsUtil::add("ConfirmBakeTerrain", LLSD(), LLSD(), boost::bind(&LLPanelRegionTerrainInfo::callbackBakeTerrain, (LLPanelRegionTerrainInfo*)data, _1, _2)); } bool LLPanelRegionTerrainInfo::callbackBakeTerrain(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option != 0) return false; strings_t strings; @@ -1479,7 +1479,7 @@ void LLPanelEstateInfo::onClickAddAllowedAgent(void* user_data) LLSD args; args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); - LLNotifications::instance().add("MaxAllowedAgentOnRegion", args); + LLNotificationsUtil::add("MaxAllowedAgentOnRegion", args); return; } accessAddCore(ESTATE_ACCESS_ALLOWED_AGENT_ADD, "EstateAllowedAgentAdd"); @@ -1501,7 +1501,7 @@ void LLPanelEstateInfo::onClickAddAllowedGroup(void* user_data) { LLSD args; args["MAX_GROUPS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); - LLNotifications::instance().add("MaxAllowedGroupsOnRegion", args); + LLNotificationsUtil::add("MaxAllowedGroupsOnRegion", args); return; } @@ -1519,7 +1519,7 @@ void LLPanelEstateInfo::onClickAddAllowedGroup(void* user_data) bool LLPanelEstateInfo::addAllowedGroup(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option != 0) return false; LLFloater* parent_floater = gFloaterView->getParentFloater(this); @@ -1556,7 +1556,7 @@ void LLPanelEstateInfo::onClickAddBannedAgent(void* user_data) { LLSD args; args["MAX_BANNED"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); - LLNotifications::instance().add("MaxBannedAgentsOnRegion", args); + LLNotificationsUtil::add("MaxBannedAgentsOnRegion", args); return; } accessAddCore(ESTATE_ACCESS_BANNED_AGENT_ADD, "EstateBannedAgentAdd"); @@ -1578,7 +1578,7 @@ void LLPanelEstateInfo::onClickAddEstateManager(void* user_data) { // Tell user they can't add more managers LLSD args; args["MAX_MANAGER"] = llformat("%d",ESTATE_MAX_MANAGERS); - LLNotifications::instance().add("MaxManagersOnRegion", args); + LLNotificationsUtil::add("MaxManagersOnRegion", args); } else { // Go pick managers to add @@ -1636,13 +1636,13 @@ void LLPanelEstateInfo::onKickUserCommit(const std::vector& names, args["EVIL_USER"] = names[0]; LLSD payload; payload["agent_id"] = ids[0]; - LLNotifications::instance().add("EstateKickUser", args, payload, boost::bind(&LLPanelEstateInfo::kickUserConfirm, self, _1, _2)); + LLNotificationsUtil::add("EstateKickUser", args, payload, boost::bind(&LLPanelEstateInfo::kickUserConfirm, self, _1, _2)); } bool LLPanelEstateInfo::kickUserConfirm(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); switch(option) { case 0: @@ -1789,7 +1789,7 @@ void LLPanelEstateInfo::accessAddCore(U32 operation_flag, const std::string& dia // static bool LLPanelEstateInfo::accessAddCore2(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option != 0) { // abort change @@ -1833,7 +1833,7 @@ void LLPanelEstateInfo::accessAddCore3(const std::vector& names, co args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); args["LIST_TYPE"] = "Allowed Residents"; args["NUM_EXCESS"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS); - LLNotifications::instance().add("MaxAgentOnRegionBatch", args); + LLNotificationsUtil::add("MaxAgentOnRegionBatch", args); delete change_info; return; } @@ -1849,7 +1849,7 @@ void LLPanelEstateInfo::accessAddCore3(const std::vector& names, co args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); args["LIST_TYPE"] = "Banned Residents"; args["NUM_EXCESS"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS); - LLNotifications::instance().add("MaxAgentOnRegionBatch", args); + LLNotificationsUtil::add("MaxAgentOnRegionBatch", args); delete change_info; return; } @@ -1918,7 +1918,7 @@ void LLPanelEstateInfo::accessRemoveCore(U32 operation_flag, const std::string& // static bool LLPanelEstateInfo::accessRemoveCore2(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option != 0) { // abort @@ -1935,7 +1935,7 @@ bool LLPanelEstateInfo::accessRemoveCore2(const LLSD& notification, const LLSD& { LLSD args; args["ALL_ESTATES"] = all_estates_text(); - LLNotifications::instance().add(notification["payload"]["dialog_name"], + LLNotificationsUtil::add(notification["payload"]["dialog_name"], args, notification["payload"], accessCoreConfirm); @@ -1948,7 +1948,7 @@ bool LLPanelEstateInfo::accessRemoveCore2(const LLSD& notification, const LLSD& // static bool LLPanelEstateInfo::accessCoreConfirm(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); const U32 originalFlags = (U32)notification["payload"]["operation"].asInteger(); LLViewerRegion* region = gAgent.getRegion(); @@ -1967,7 +1967,7 @@ bool LLPanelEstateInfo::accessCoreConfirm(const LLSD& notification, const LLSD& if (((U32)notification["payload"]["operation"].asInteger() & ESTATE_ACCESS_BANNED_AGENT_ADD) && region && (region->getOwner() == id)) { - LLNotifications::instance().add("OwnerCanNotBeDenied"); + LLNotificationsUtil::add("OwnerCanNotBeDenied"); break; } switch(option) @@ -2243,7 +2243,7 @@ BOOL LLPanelEstateInfo::sendUpdate() bool LLPanelEstateInfo::callbackChangeLindenEstate(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); switch(option) { case 0: @@ -2650,12 +2650,12 @@ BOOL LLPanelEstateInfo::checkSunHourSlider(LLUICtrl* child_ctrl) void LLPanelEstateInfo::onClickMessageEstate(void* userdata) { llinfos << "LLPanelEstateInfo::onClickMessageEstate" << llendl; - LLNotifications::instance().add("MessageEstate", LLSD(), LLSD(), boost::bind(&LLPanelEstateInfo::onMessageCommit, (LLPanelEstateInfo*)userdata, _1, _2)); + LLNotificationsUtil::add("MessageEstate", LLSD(), LLSD(), boost::bind(&LLPanelEstateInfo::onMessageCommit, (LLPanelEstateInfo*)userdata, _1, _2)); } bool LLPanelEstateInfo::onMessageCommit(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); std::string text = response["message"].asString(); if(option != 0) return false; if(text.empty()) return false; @@ -2663,7 +2663,7 @@ bool LLPanelEstateInfo::onMessageCommit(const LLSD& notification, const LLSD& re strings_t strings; //integers_t integers; std::string name; - gAgent.buildFullname(name); + LLAgentUI::buildFullname(name); strings.push_back(strings_t::value_type(name)); strings.push_back(strings_t::value_type(text)); LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); @@ -2786,7 +2786,7 @@ BOOL LLPanelEstateCovenant::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop { LLSD payload; payload["item_id"] = item->getUUID(); - LLNotifications::instance().add("EstateChangeCovenant", LLSD(), payload, + LLNotificationsUtil::add("EstateChangeCovenant", LLSD(), payload, LLPanelEstateCovenant::confirmChangeCovenantCallback); } break; @@ -2801,7 +2801,7 @@ BOOL LLPanelEstateCovenant::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop // static bool LLPanelEstateCovenant::confirmChangeCovenantCallback(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); LLInventoryItem* item = gInventory.getItem(notification["payload"]["item_id"].asUUID()); LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant(); @@ -2821,7 +2821,7 @@ bool LLPanelEstateCovenant::confirmChangeCovenantCallback(const LLSD& notificati // static void LLPanelEstateCovenant::resetCovenantID(void* userdata) { - LLNotifications::instance().add("EstateChangeCovenant", LLSD(), LLSD(), confirmResetCovenantCallback); + LLNotificationsUtil::add("EstateChangeCovenant", LLSD(), LLSD(), confirmResetCovenantCallback); } // static @@ -2830,7 +2830,7 @@ bool LLPanelEstateCovenant::confirmResetCovenantCallback(const LLSD& notificatio LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant(); if (!self) return false; - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); switch(option) { case 0: @@ -2900,7 +2900,7 @@ void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs, if( !panelp->mEditor->importBuffer( buffer, file_length+1 ) ) { llwarns << "Problem importing estate covenant." << llendl; - LLNotifications::instance().add("ProblemImportingEstateCovenant"); + LLNotificationsUtil::add("ProblemImportingEstateCovenant"); } else { @@ -2921,15 +2921,15 @@ void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs, if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { - LLNotifications::instance().add("MissingNotecardAssetID"); + LLNotificationsUtil::add("MissingNotecardAssetID"); } else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) { - LLNotifications::instance().add("NotAllowedToViewNotecard"); + LLNotificationsUtil::add("NotAllowedToViewNotecard"); } else { - LLNotifications::instance().add("UnableToLoadNotecardAsset"); + LLNotificationsUtil::add("UnableToLoadNotecardAsset"); } llwarns << "Problem loading notecard: " << status << llendl; diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp index 2219ab235..9dec6b49f 100644 --- a/indra/newview/llfloaterreporter.cpp +++ b/indra/newview/llfloaterreporter.cpp @@ -43,6 +43,7 @@ #include "llfontgl.h" #include "llgl.h" // for renderer #include "llinventory.h" +#include "llnotificationsutil.h" #include "llimagej2c.h" #include "llstring.h" #include "llsys.h" @@ -232,10 +233,10 @@ void LLFloaterReporter::processRegionInfo(LLMessageSystem* msg) { if ( gEmailToEstateOwner ) { - LLNotifications::instance().add("HelpReportAbuseEmailEO"); + LLNotificationsUtil::add("HelpReportAbuseEmailEO"); } else - LLNotifications::instance().add("HelpReportAbuseEmailLL"); + LLNotificationsUtil::add("HelpReportAbuseEmailLL"); }; } @@ -443,7 +444,7 @@ void LLFloaterReporter::onClickSend(void *userdata) category_value == IP_CONTENT_REMOVAL || category_value == IP_PERMISSONS_EXPLOIT) { - LLNotifications::instance().add("HelpReportAbuseContainsCopyright"); + LLNotificationsUtil::add("HelpReportAbuseContainsCopyright"); self->mCopyrightWarningSeen = TRUE; return; } @@ -452,7 +453,7 @@ void LLFloaterReporter::onClickSend(void *userdata) { // IP_CONTENT_REMOVAL *always* shows the dialog - // ergo you can never send that abuse report type. - LLNotifications::instance().add("HelpReportAbuseContainsCopyright"); + LLNotificationsUtil::add("HelpReportAbuseContainsCopyright"); return; } } @@ -561,7 +562,7 @@ void LLFloaterReporter::showFromMenu(EReportType report_type) if (report_type == BUG_REPORT) { - LLNotifications::instance().add("HelpReportBug"); + LLNotificationsUtil::add("HelpReportBug"); } else { @@ -653,11 +654,11 @@ bool LLFloaterReporter::validateReport() { if ( mReportType != BUG_REPORT ) { - LLNotifications::instance().add("HelpReportAbuseSelectCategory"); + LLNotificationsUtil::add("HelpReportAbuseSelectCategory"); } else { - LLNotifications::instance().add("HelpReportBugSelectCategory"); + LLNotificationsUtil::add("HelpReportAbuseAbuserNameEmpty"); } return false; } @@ -666,13 +667,13 @@ bool LLFloaterReporter::validateReport() { if ( childGetText("abuser_name_edit").empty() ) { - LLNotifications::instance().add("HelpReportAbuseAbuserNameEmpty"); + LLNotificationsUtil::add("HelpReportAbuseAbuserLocationEmpty"); return false; }; if ( childGetText("abuse_location_edit").empty() ) { - LLNotifications::instance().add("HelpReportAbuseAbuserLocationEmpty"); + LLNotificationsUtil::add("HelpReportAbuseAbuserLocationEmpty"); return false; }; }; @@ -681,11 +682,11 @@ bool LLFloaterReporter::validateReport() { if ( mReportType != BUG_REPORT ) { - LLNotifications::instance().add("HelpReportAbuseSummaryEmpty"); + LLNotificationsUtil::add("HelpReportAbuseSummaryEmpty"); } else { - LLNotifications::instance().add("HelpReportBugSummaryEmpty"); + LLNotificationsUtil::add("HelpReportBugSummaryEmpty"); } return false; }; @@ -694,11 +695,11 @@ bool LLFloaterReporter::validateReport() { if ( mReportType != BUG_REPORT ) { - LLNotifications::instance().add("HelpReportAbuseDetailsEmpty"); + LLNotificationsUtil::add("HelpReportAbuseDetailsEmpty"); } else { - LLNotifications::instance().add("HelpReportBugDetailsEmpty"); + LLNotificationsUtil::add("HelpReportBugDetailsEmpty"); } return false; }; @@ -1001,7 +1002,7 @@ void LLFloaterReporter::uploadDoneCallback(const LLUUID &uuid, void *user_data, { LLSD args; args["REASON"] = std::string(LLAssetStorage::getErrorString(result)); - LLNotifications::instance().add("ErrorUploadingReportScreenshot", args); + LLNotificationsUtil::add("ErrorUploadingReportScreenshot", args); std::string err_msg("There was a problem uploading a report screenshot"); err_msg += " due to the following reason: " + args["REASON"].asString(); diff --git a/indra/newview/llfloatersellland.cpp b/indra/newview/llfloatersellland.cpp index 3c5b9cfa9..f4cc7c30e 100644 --- a/indra/newview/llfloatersellland.cpp +++ b/indra/newview/llfloatersellland.cpp @@ -37,7 +37,8 @@ #include "llfloater.h" #include "llfloaterland.h" #include "lllineeditor.h" -#include "llnotify.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llparcel.h" #include "llselectmgr.h" #include "lltexturectrl.h" @@ -448,7 +449,7 @@ void LLFloaterSellLandUI::doShowObjects(void *userdata) send_parcel_select_objects(parcel->getLocalID(), RT_SELL); - LLNotifications::instance().add("TransferObjectsHighlighted", + LLNotificationsUtil::add("TransferObjectsHighlighted", LLSD(), LLSD(), &LLFloaterSellLandUI::callbackHighlightTransferable); } @@ -483,7 +484,7 @@ void LLFloaterSellLandUI::doSellLand(void *userdata) && (sale_price == 0) && sell_to_anyone) { - LLNotifications::instance().add("SalePriceRestriction"); + LLNotificationsUtil::add("SalePriceRestriction"); return; } @@ -516,7 +517,7 @@ void LLFloaterSellLandUI::doSellLand(void *userdata) bool LLFloaterSellLandUI::onConfirmSale(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option != 0) { return false; diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 00d53193d..3f60a27e0 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -61,6 +61,7 @@ #include "llviewerstats.h" #include "llviewercamera.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llviewermenufile.h" // upload_new_resource() #include "llfloaterpostcard.h" #include "llcheckboxctrl.h" @@ -76,6 +77,7 @@ #include "llimagepng.h" #include "llimagebmp.h" #include "llimagej2c.h" +#include "llnotificationsutil.h" #include "llvfile.h" #include "llvfs.h" @@ -996,7 +998,7 @@ void LLSnapshotLivePreview::saveTexture() } else { - LLNotifications::instance().add("ErrorEncodingSnapshot"); + LLNotificationsUtil::add("ErrorEncodingSnapshot"); llwarns << "Error encoding snapshot" << llendl; } @@ -1135,8 +1137,6 @@ LLViewerWindow::ESnapshotType LLFloaterSnapshot::Impl::getLayerType(LLFloaterSna type = LLViewerWindow::SNAPSHOT_TYPE_COLOR; else if (id == "depth") type = LLViewerWindow::SNAPSHOT_TYPE_DEPTH; - else if (id == "objects") - type = LLViewerWindow::SNAPSHOT_TYPE_OBJECT_ID; return type; } diff --git a/indra/newview/llfloaterstats.cpp b/indra/newview/llfloaterstats.cpp index f19b86040..4d8fd7099 100644 --- a/indra/newview/llfloaterstats.cpp +++ b/indra/newview/llfloaterstats.cpp @@ -107,7 +107,7 @@ void LLFloaterStats::buildStats() LLStatView *render_statviewp = stat_viewp->addStatView("render stat view", "Render", "OpenDebugStatRender", rect); - stat_barp = render_statviewp->addStat("KTris Drawn", &(gPipeline.mTrianglesDrawnStat), "DebugStatModeKTrisDrawnFr"); + stat_barp = render_statviewp->addStat("KTris Drawn", &(LLViewerStats::getInstance()->mTrianglesDrawnStat), "DebugStatModeKTrisDrawnFr"); stat_barp->setUnitLabel("/fr"); stat_barp->mMinBar = 0.f; stat_barp->mMaxBar = 500.f; @@ -116,7 +116,7 @@ void LLFloaterStats::buildStats() stat_barp->mPrecision = 1; stat_barp->mPerSec = FALSE; - stat_barp = render_statviewp->addStat("KTris Drawn", &(gPipeline.mTrianglesDrawnStat), "DebugStatModeKTrisDrawnSec"); + stat_barp = render_statviewp->addStat("KTris Drawn", &(LLViewerStats::getInstance()->mTrianglesDrawnStat), "DebugStatModeKTrisDrawnSec"); stat_barp->setUnitLabel("/sec"); stat_barp->mMinBar = 0.f; stat_barp->mMaxBar = 3000.f; @@ -124,14 +124,14 @@ void LLFloaterStats::buildStats() stat_barp->mLabelSpacing = 1000.f; stat_barp->mPrecision = 1; - stat_barp = render_statviewp->addStat("Total Objs", &(gObjectList.mNumObjectsStat), "DebugStatModeTotalObjs"); + stat_barp = render_statviewp->addStat("Total Objs", &(LLViewerStats::getInstance()->mNumObjectsStat), "DebugStatModeTotalObjs"); stat_barp->mMinBar = 0.f; stat_barp->mMaxBar = 10000.f; stat_barp->mTickSpacing = 2500.f; stat_barp->mLabelSpacing = 5000.f; stat_barp->mPerSec = FALSE; - stat_barp = render_statviewp->addStat("New Objs", &(gObjectList.mNumNewObjectsStat), "DebugStatModeNewObjs"); + stat_barp = render_statviewp->addStat("New Objs", &(LLViewerStats::getInstance()->mNumNewObjectsStat), "DebugStatModeNewObjs"); stat_barp->setLabel("New Objs"); stat_barp->setUnitLabel("/sec"); stat_barp->mMinBar = 0.f; @@ -144,7 +144,7 @@ void LLFloaterStats::buildStats() // Texture statistics LLStatView *texture_statviewp = render_statviewp->addStatView("texture stat view", "Texture", "OpenDebugStatTexture", rect); - stat_barp = texture_statviewp->addStat("Count", &(gTextureList.sNumImagesStat), "DebugStatModeTextureCount"); + stat_barp = texture_statviewp->addStat("Count", &(LLViewerStats::getInstance()->mNumImagesStat), "DebugStatModeTextureCount"); stat_barp->setUnitLabel(""); stat_barp->mMinBar = 0.f; stat_barp->mMaxBar = 8000.f; @@ -152,7 +152,7 @@ void LLFloaterStats::buildStats() stat_barp->mLabelSpacing = 4000.f; stat_barp->mPerSec = FALSE; - stat_barp = texture_statviewp->addStat("Raw Count", &(gTextureList.sNumRawImagesStat), "DebugStatModeRawCount"); + stat_barp = texture_statviewp->addStat("Raw Count", &(LLViewerStats::getInstance()->mNumRawImagesStat), "DebugStatModeRawCount"); stat_barp->setUnitLabel(""); stat_barp->mMinBar = 0.f; stat_barp->mMaxBar = 8000.f; @@ -160,7 +160,7 @@ void LLFloaterStats::buildStats() stat_barp->mLabelSpacing = 4000.f; stat_barp->mPerSec = FALSE; - stat_barp = texture_statviewp->addStat("GL Mem", &(gTextureList.sGLTexMemStat), "DebugStatModeGLMem"); + stat_barp = texture_statviewp->addStat("GL Mem", &(LLViewerStats::getInstance()->mGLTexMemStat), "DebugStatModeGLMem"); stat_barp->setUnitLabel(""); stat_barp->mMinBar = 0.f; stat_barp->mMaxBar = 400.f; @@ -169,7 +169,7 @@ void LLFloaterStats::buildStats() stat_barp->mPrecision = 1; stat_barp->mPerSec = FALSE; - stat_barp = texture_statviewp->addStat("Formatted Mem", &(gTextureList.sFormattedMemStat), "DebugStatModeFormattedMem"); + stat_barp = texture_statviewp->addStat("Formatted Mem", &(LLViewerStats::getInstance()->mFormattedMemStat), "DebugStatModeFormattedMem"); stat_barp->setUnitLabel(""); stat_barp->mMinBar = 0.f; stat_barp->mMaxBar = 400.f; @@ -178,7 +178,7 @@ void LLFloaterStats::buildStats() stat_barp->mPrecision = 1; stat_barp->mPerSec = FALSE; - stat_barp = texture_statviewp->addStat("Raw Mem", &(gTextureList.sRawMemStat), "DebugStatModeRawMem"); + stat_barp = texture_statviewp->addStat("Raw Mem", &(LLViewerStats::getInstance()->mRawMemStat), "DebugStatModeRawMem"); stat_barp->setUnitLabel(""); stat_barp->mMinBar = 0.f; stat_barp->mMaxBar = 400.f; @@ -187,7 +187,7 @@ void LLFloaterStats::buildStats() stat_barp->mPrecision = 1; stat_barp->mPerSec = FALSE; - stat_barp = texture_statviewp->addStat("Bound Mem", &(gTextureList.sGLBoundMemStat), "DebugStatModeBoundMem"); + stat_barp = texture_statviewp->addStat("Bound Mem", &(LLViewerStats::getInstance()->mGLBoundMemStat), "DebugStatModeBoundMem"); stat_barp->setUnitLabel(""); stat_barp->mMinBar = 0.f; stat_barp->mMaxBar = 400.f; diff --git a/indra/newview/llfloaterteleport.cpp b/indra/newview/llfloaterteleport.cpp index df2226be2..a4a88bfd0 100644 --- a/indra/newview/llfloaterteleport.cpp +++ b/indra/newview/llfloaterteleport.cpp @@ -82,7 +82,7 @@ public: args["REASON"] = reason; - LLNotifications::instance().add("CouldNotTeleportReason", args); + LLNotificationsUtil::add("CouldNotTeleportReason", args); gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); @@ -131,7 +131,7 @@ public: args["REASON"] = "Place Avatar Failed"; //gViewerWindow->alertXml("CouldNotTeleportReason", args); - LLNotifications::instance().add("CouldNotTeleportReason",args); + LLNotificationsUtil::add("CouldNotTeleportReason",args); gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); @@ -164,7 +164,7 @@ public: LLSD args; args["REASON"] = "Failed to resolve host."; //gViewerWindow->alertXml("CouldNotTeleportReason", args); - LLNotifications::instance().add("CouldNotTeleportReason", args); + LLNotificationsUtil::add("CouldNotTeleportReason", args); gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); return; } diff --git a/indra/newview/llfloaterteleporthistory.cpp b/indra/newview/llfloaterteleporthistory.cpp index 9547bf0b6..14ddd9541 100644 --- a/indra/newview/llfloaterteleporthistory.cpp +++ b/indra/newview/llfloaterteleporthistory.cpp @@ -50,8 +50,12 @@ #include "llurlsimstring.h" #include "llviewercontrol.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llweb.h" #include "llsdserialize.h" +// [RLVa:KB] +#include "rlvhandler.h" +// [/RLVa:KB] LLFloaterTeleportHistory::LLFloaterTeleportHistory(const LLSD& seed) : LLFloater(std::string("teleporthistory")), @@ -103,12 +107,11 @@ BOOL LLFloaterTeleportHistory::postBuild() void LLFloaterTeleportHistory::addPendingEntry(std::string regionName, S16 x, S16 y, S16 z) { -#ifdef LL_RRINTERFACE_H //MK - if (gRRenabled && gAgent.mRRInterface.mContainsShowloc) - { +// [RLVa:KB] + if(gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) return; - } -#endif //mk +// [/RLVa:KB] + // Set pending entry timestamp U32 utc_time; diff --git a/indra/newview/llfloatertopobjects.cpp b/indra/newview/llfloatertopobjects.cpp index 76ea40008..8abbc2d26 100644 --- a/indra/newview/llfloatertopobjects.cpp +++ b/indra/newview/llfloatertopobjects.cpp @@ -41,6 +41,7 @@ #include "llbutton.h" #include "llfloatergodtools.h" #include "llfloateravatarinfo.h" +#include "llnotificationsutil.h" #include "llparcel.h" #include "llscrolllistctrl.h" #include "lllineeditor.h" @@ -398,7 +399,7 @@ void LLFloaterTopObjects::doToObjects(int action, bool all) //static bool LLFloaterTopObjects::callbackReturnAll(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option == 0) { sInstance->doToObjects(ACTION_RETURN, true); @@ -408,7 +409,7 @@ bool LLFloaterTopObjects::callbackReturnAll(const LLSD& notification, const LLSD void LLFloaterTopObjects::onReturnAll(void* data) { - LLNotifications::instance().add("ReturnAllTopObjects", LLSD(), LLSD(), &callbackReturnAll); + LLNotificationsUtil::add("ReturnAllTopObjects", LLSD(), LLSD(), &callbackReturnAll); } @@ -541,7 +542,7 @@ void LLFloaterTopObjects::onTP(void* data) //static bool LLFloaterTopObjects::callbackDisableAll(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option == 0) { sInstance->doToObjects(ACTION_DISABLE, true); @@ -551,7 +552,7 @@ bool LLFloaterTopObjects::callbackDisableAll(const LLSD& notification, const LLS void LLFloaterTopObjects::onDisableAll(void* data) { - LLNotifications::instance().add("DisableAllTopObjects", LLSD(), LLSD(), callbackDisableAll); + LLNotificationsUtil::add("DisableAllTopObjects", LLSD(), LLSD(), callbackDisableAll); } void LLFloaterTopObjects::onDisableSelected(void* data) diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp index 2dedc79af..d83dab9fd 100644 --- a/indra/newview/llfloatertos.cpp +++ b/indra/newview/llfloatertos.cpp @@ -46,6 +46,7 @@ #include "llbutton.h" #include "llhttpclient.h" #include "llhttpstatuscodes.h" // for HTTP_FOUND +#include "llnotificationsutil.h" #include "llradiogroup.h" #include "lltextbox.h" #include "llui.h" @@ -254,7 +255,7 @@ void LLFloaterTOS::onCancel( void* userdata ) { LLFloaterTOS* self = (LLFloaterTOS*) userdata; llinfos << "User disagrees with TOS." << llendl; - LLNotifications::instance().add("MustAgreeToLogIn", LLSD(), LLSD(), login_alert_done); + LLNotificationsUtil::add("MustAgreeToLogIn", LLSD(), LLSD(), login_alert_done); LLStartUp::setStartupState( STATE_LOGIN_SHOW ); self->mLoadCompleteCount = 0; // reset counter for next time we come to TOS self->close(); // destroys this object diff --git a/indra/newview/llfloaterurlentry.cpp b/indra/newview/llfloaterurlentry.cpp index 8d483e59e..35dc9ddda 100644 --- a/indra/newview/llfloaterurlentry.cpp +++ b/indra/newview/llfloaterurlentry.cpp @@ -38,6 +38,7 @@ // project includes #include "llcombobox.h" +#include "llnotificationsutil.h" #include "llurlhistory.h" #include "lluictrlfactory.h" #include "llwindow.h" @@ -263,13 +264,13 @@ void LLFloaterURLEntry::onBtnCancel( void* userdata ) //----------------------------------------------------------------------------- void LLFloaterURLEntry::onBtnClear( void* userdata ) { - LLNotifications::instance().add( "ConfirmClearMediaUrlList", LLSD(), LLSD(), + LLNotificationsUtil::add( "ConfirmClearMediaUrlList", LLSD(), LLSD(), boost::bind(&LLFloaterURLEntry::callback_clear_url_list, (LLFloaterURLEntry*)userdata, _1, _2) ); } bool LLFloaterURLEntry::callback_clear_url_list(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if ( option == 0 ) // YES { // clear saved list diff --git a/indra/newview/llfloaterwater.cpp b/indra/newview/llfloaterwater.cpp index 4ea21cf10..e35d7e6c0 100644 --- a/indra/newview/llfloaterwater.cpp +++ b/indra/newview/llfloaterwater.cpp @@ -49,6 +49,7 @@ #include "llfloaterdaycycle.h" #include "llboost.h" #include "llmultisliderctrl.h" +#include "llnotificationsutil.h" #include "v4math.h" #include "llviewerdisplay.h" @@ -74,9 +75,9 @@ LLFloaterWater::LLFloaterWater() : LLFloater(std::string("water floater")) if(comboBox != NULL) { - std::map::iterator mIt = - LLWaterParamManager::instance()->mParamList.begin(); - for(; mIt != LLWaterParamManager::instance()->mParamList.end(); mIt++) + std::map::const_iterator mIt = + LLWaterParamManager::getInstance()->getPresets().begin(); + for(; mIt != LLWaterParamManager::getInstance()->getPresets().end(); mIt++) { comboBox->add(mIt->first); } @@ -123,7 +124,7 @@ void LLFloaterWater::initCallbacks(void) { initHelpBtn("WaterWave1Help", "HelpWaterWave1"); initHelpBtn("WaterWave2Help", "HelpWaterWave2"); - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamManager * param_mgr = LLWaterParamManager::getInstance(); childSetCommitCallback("WaterFogColor", onWaterFogColorMoved, ¶m_mgr->mFogColor); @@ -197,15 +198,15 @@ bool LLFloaterWater::newPromptCallback(const LLSD& notification, const LLSD& res if(option == 0) { LLComboBox* comboBox = sWaterMenu->getChild( "WaterPresetsCombo"); - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamManager * param_mgr = LLWaterParamManager::getInstance(); // add the current parameters to the list // see if it's there first - std::map::iterator mIt = - param_mgr->mParamList.find(text); + std::map::const_iterator mIt = + param_mgr->getPresets().find(text); // if not there, add a new one - if(mIt == param_mgr->mParamList.end()) + if(mIt == param_mgr->getPresets().end()) { param_mgr->addParamSet(text, param_mgr->mCurParams); comboBox->add(text); @@ -219,7 +220,7 @@ bool LLFloaterWater::newPromptCallback(const LLSD& notification, const LLSD& res } else { - LLNotifications::instance().add("ExistsWaterPresetAlert"); + LLNotificationsUtil::add("ExistsWaterPresetAlert"); } } return false; @@ -229,7 +230,7 @@ void LLFloaterWater::syncMenu() { bool err; - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamManager * param_mgr = LLWaterParamManager::getInstance(); LLWaterParamSet & current_params = param_mgr->mCurParams; @@ -337,9 +338,9 @@ void LLFloaterWater::onVector3ControlXMoved(LLUICtrl* ctrl, void* userData) vectorControl->mX = sldrCtrl->getValueF32(); - vectorControl->update(LLWaterParamManager::instance()->mCurParams); + vectorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } // vector control callbacks @@ -350,9 +351,9 @@ void LLFloaterWater::onVector3ControlYMoved(LLUICtrl* ctrl, void* userData) vectorControl->mY = sldrCtrl->getValueF32(); - vectorControl->update(LLWaterParamManager::instance()->mCurParams); + vectorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } // vector control callbacks @@ -363,9 +364,9 @@ void LLFloaterWater::onVector3ControlZMoved(LLUICtrl* ctrl, void* userData) vectorControl->mZ = sldrCtrl->getValueF32(); - vectorControl->update(LLWaterParamManager::instance()->mCurParams); + vectorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } @@ -377,9 +378,9 @@ void LLFloaterWater::onVector2ControlXMoved(LLUICtrl* ctrl, void* userData) vectorControl->mX = sldrCtrl->getValueF32(); - vectorControl->update(LLWaterParamManager::instance()->mCurParams); + vectorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } // vector control callbacks @@ -390,9 +391,9 @@ void LLFloaterWater::onVector2ControlYMoved(LLUICtrl* ctrl, void* userData) vectorControl->mY = sldrCtrl->getValueF32(); - vectorControl->update(LLWaterParamManager::instance()->mCurParams); + vectorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } // color control callbacks @@ -415,9 +416,9 @@ void LLFloaterWater::onColorControlRMoved(LLUICtrl* ctrl, void* userData) sWaterMenu->childSetValue(name, colorControl->mR); } - colorControl->update(LLWaterParamManager::instance()->mCurParams); + colorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } void LLFloaterWater::onColorControlGMoved(LLUICtrl* ctrl, void* userData) @@ -440,9 +441,9 @@ void LLFloaterWater::onColorControlGMoved(LLUICtrl* ctrl, void* userData) } - colorControl->update(LLWaterParamManager::instance()->mCurParams); + colorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } void LLFloaterWater::onColorControlBMoved(LLUICtrl* ctrl, void* userData) @@ -464,9 +465,9 @@ void LLFloaterWater::onColorControlBMoved(LLUICtrl* ctrl, void* userData) sWaterMenu->childSetValue(name, colorControl->mB); } - colorControl->update(LLWaterParamManager::instance()->mCurParams); + colorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } void LLFloaterWater::onColorControlAMoved(LLUICtrl* ctrl, void* userData) @@ -476,9 +477,9 @@ void LLFloaterWater::onColorControlAMoved(LLUICtrl* ctrl, void* userData) colorControl->mA = sldrCtrl->getValueF32(); - colorControl->update(LLWaterParamManager::instance()->mCurParams); + colorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } @@ -538,8 +539,8 @@ void LLFloaterWater::onColorControlIMoved(LLUICtrl* ctrl, void* userData) } // now update the current parameters and send them to shaders - colorControl->update(LLWaterParamManager::instance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + colorControl->update(LLWaterParamManager::getInstance()->mCurParams); + LLWaterParamManager::getInstance()->propagateParameters(); } void LLFloaterWater::onExpFloatControlMoved(LLUICtrl* ctrl, void* userData) @@ -549,10 +550,10 @@ void LLFloaterWater::onExpFloatControlMoved(LLUICtrl* ctrl, void* userData) F32 val = sldrCtrl->getValueF32(); expFloatControl->mExp = val; - LLWaterParamManager::instance()->setDensitySliderValue(val); + LLWaterParamManager::getInstance()->setDensitySliderValue(val); - expFloatControl->update(LLWaterParamManager::instance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + expFloatControl->update(LLWaterParamManager::getInstance()->mCurParams); + LLWaterParamManager::getInstance()->propagateParameters(); } void LLFloaterWater::onFloatControlMoved(LLUICtrl* ctrl, void* userData) @@ -562,8 +563,8 @@ void LLFloaterWater::onFloatControlMoved(LLUICtrl* ctrl, void* userData) floatControl->mX = sldrCtrl->getValueF32() / floatControl->mMult; - floatControl->update(LLWaterParamManager::instance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + floatControl->update(LLWaterParamManager::getInstance()->mCurParams); + LLWaterParamManager::getInstance()->propagateParameters(); } void LLFloaterWater::onWaterFogColorMoved(LLUICtrl* ctrl, void* userData) { @@ -571,8 +572,8 @@ void LLFloaterWater::onWaterFogColorMoved(LLUICtrl* ctrl, void* userData) WaterColorControl * colorControl = static_cast(userData); *colorControl = swatch->get(); - colorControl->update(LLWaterParamManager::instance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + colorControl->update(LLWaterParamManager::getInstance()->mCurParams); + LLWaterParamManager::getInstance()->propagateParameters(); } void LLFloaterWater::onBoolToggle(LLUICtrl* ctrl, void* userData) @@ -587,12 +588,12 @@ void LLFloaterWater::onNormalMapPicked(LLUICtrl* ctrl, void* userData) { LLTextureCtrl* textCtrl = static_cast(ctrl); LLUUID textID = textCtrl->getImageAssetID(); - LLWaterParamManager::instance()->setNormalMapID(textID); + LLWaterParamManager::getInstance()->setNormalMapID(textID); } void LLFloaterWater::onNewPreset(void* userData) { - LLNotifications::instance().add("NewWaterPreset", LLSD(), LLSD(), newPromptCallback); + LLNotificationsUtil::add("NewWaterPreset", LLSD(), LLSD(), newPromptCallback); } void LLFloaterWater::onSavePreset(void* userData) @@ -606,7 +607,7 @@ void LLFloaterWater::onSavePreset(void* userData) return; } - LLWaterParamManager::instance()->mCurParams.mName = + LLWaterParamManager::getInstance()->mCurParams.mName = comboBox->getSelectedItemLabel(); // check to see if it's a default and shouldn't be overwritten @@ -614,11 +615,11 @@ void LLFloaterWater::onSavePreset(void* userData) comboBox->getSelectedItemLabel()); if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("WaterEditPresets")) { - LLNotifications::instance().add("WLNoEditDefault"); + LLNotificationsUtil::add("WLNoEditDefault"); return; } - LLNotifications::instance().add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback); + LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback); } bool LLFloaterWater::saveAlertCallback(const LLSD& notification, const LLSD& response) @@ -627,7 +628,7 @@ bool LLFloaterWater::saveAlertCallback(const LLSD& notification, const LLSD& res // if they choose save, do it. Otherwise, don't do anything if(option == 0) { - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamManager * param_mgr = LLWaterParamManager::getInstance(); param_mgr->setParamSet( param_mgr->mCurParams.mName, @@ -650,7 +651,7 @@ void LLFloaterWater::onDeletePreset(void* userData) LLSD args; args["SKY"] = combo_box->getSelectedValue().asString(); - LLNotifications::instance().add("WLDeletePresetAlert", args, LLSD(), deleteAlertCallback); + LLNotificationsUtil::add("WLDeletePresetAlert", args, LLSD(), deleteAlertCallback); } bool LLFloaterWater::deleteAlertCallback(const LLSD& notification, const LLSD& response) @@ -677,11 +678,11 @@ bool LLFloaterWater::deleteAlertCallback(const LLSD& notification, const LLSD& r std::set::iterator sIt = sDefaultPresets.find(name); if(sIt != sDefaultPresets.end()) { - LLNotifications::instance().add("WaterNoEditDefault"); + LLNotificationsUtil::add("WaterNoEditDefault"); return false; } - LLWaterParamManager::instance()->removeParamSet(name, true); + LLWaterParamManager::getInstance()->removeParamSet(name, true); // remove and choose another S32 new_index = combo_box->getCurrentIndex(); @@ -720,7 +721,7 @@ void LLFloaterWater::onChangePresetName(LLUICtrl* ctrl, void * userData) return; } - LLWaterParamManager::instance()->loadPreset( + LLWaterParamManager::getInstance()->loadPreset( combo_box->getSelectedValue().asString()); sWaterMenu->syncMenu(); } diff --git a/indra/newview/llfloaterwindlight.cpp b/indra/newview/llfloaterwindlight.cpp index 898c5dc2a..dba360b88 100644 --- a/indra/newview/llfloaterwindlight.cpp +++ b/indra/newview/llfloaterwindlight.cpp @@ -48,6 +48,7 @@ #include "lllineeditor.h" #include "llfloaterdaycycle.h" #include "llboost.h" +#include "llnotificationsutil.h" #include "v4math.h" #include "llviewerdisplay.h" @@ -75,9 +76,9 @@ LLFloaterWindLight::LLFloaterWindLight() : LLFloater(std::string("windlight floa if(comboBox != NULL) { - std::map::iterator mIt = - LLWLParamManager::instance()->mParamList.begin(); - for(; mIt != LLWLParamManager::instance()->mParamList.end(); mIt++) + std::map::const_iterator mIt = + LLWLParamManager::getInstance()->getPresets().begin(); + for(; mIt != LLWLParamManager::getInstance()->getPresets().end(); mIt++) { comboBox->add(mIt->first); } @@ -141,7 +142,7 @@ void LLFloaterWindLight::initCallbacks(void) { initHelpBtn("WLClassicCloudsHelp", "HelpClassicClouds"); - LLWLParamManager * param_mgr = LLWLParamManager::instance(); + LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); // blue horizon childSetCommitCallback("WLBlueHorizonR", onColorControlRMoved, ¶m_mgr->mBlueHorizon); @@ -267,14 +268,14 @@ bool LLFloaterWindLight::newPromptCallback(const LLSD& notification, const LLSD& // add the current parameters to the list // see if it's there first - std::map::iterator mIt = - LLWLParamManager::instance()->mParamList.find(text); + std::map::const_iterator mIt = + LLWLParamManager::getInstance()->getPresets().find(text); // if not there, add a new one - if(mIt == LLWLParamManager::instance()->mParamList.end()) + if(mIt == LLWLParamManager::getInstance()->getPresets().end()) { - LLWLParamManager::instance()->addParamSet(text, - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->addParamSet(text, + LLWLParamManager::getInstance()->mCurParams); comboBox->add(text); comboBox->sortByName(); @@ -292,13 +293,13 @@ bool LLFloaterWindLight::newPromptCallback(const LLSD& notification, const LLSD& keyCombo->add(text); keyCombo->sortByName(); } - LLWLParamManager::instance()->savePreset(text); + LLWLParamManager::getInstance()->savePreset(text); // otherwise, send a message to the user } else { - LLNotifications::instance().add("ExistsSkyPresetAlert"); + LLNotificationsUtil::add("ExistsSkyPresetAlert"); } } return false; @@ -308,7 +309,7 @@ void LLFloaterWindLight::syncMenu() { bool err; - LLWLParamManager * param_mgr = LLWLParamManager::instance(); + LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); LLWLParamSet& currentParams = param_mgr->mCurParams; //std::map & currentParams = param_mgr->mCurParams.mParamValues; @@ -518,9 +519,9 @@ void LLFloaterWindLight::onColorControlRMoved(LLUICtrl* ctrl, void* userData) } } - colorControl->update(LLWLParamManager::instance()->mCurParams); + colorControl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::instance()->propagateParameters(); + LLWLParamManager::getInstance()->propagateParameters(); } void LLFloaterWindLight::onColorControlGMoved(LLUICtrl* ctrl, void* userData) @@ -554,9 +555,9 @@ void LLFloaterWindLight::onColorControlGMoved(LLUICtrl* ctrl, void* userData) } } - colorControl->update(LLWLParamManager::instance()->mCurParams); + colorControl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::instance()->propagateParameters(); + LLWLParamManager::getInstance()->propagateParameters(); } void LLFloaterWindLight::onColorControlBMoved(LLUICtrl* ctrl, void* userData) @@ -590,9 +591,9 @@ void LLFloaterWindLight::onColorControlBMoved(LLUICtrl* ctrl, void* userData) } } - colorControl->update(LLWLParamManager::instance()->mCurParams); + colorControl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::instance()->propagateParameters(); + LLWLParamManager::getInstance()->propagateParameters(); } void LLFloaterWindLight::onColorControlIMoved(LLUICtrl* ctrl, void* userData) @@ -679,8 +680,8 @@ void LLFloaterWindLight::onColorControlIMoved(LLUICtrl* ctrl, void* userData) } // now update the current parameters and send them to shaders - colorControl->update(LLWLParamManager::instance()->mCurParams); - LLWLParamManager::instance()->propagateParameters(); + colorControl->update(LLWLParamManager::getInstance()->mCurParams); + LLWLParamManager::getInstance()->propagateParameters(); } /// GLOW SPECIFIC CODE @@ -694,8 +695,8 @@ void LLFloaterWindLight::onGlowRMoved(LLUICtrl* ctrl, void* userData) // scaled by 20 colorControl->r = (2 - sldrCtrl->getValueF32()) * 20; - colorControl->update(LLWLParamManager::instance()->mCurParams); - LLWLParamManager::instance()->propagateParameters(); + colorControl->update(LLWLParamManager::getInstance()->mCurParams); + LLWLParamManager::getInstance()->propagateParameters(); } /// \NOTE that we want NEGATIVE (-) B @@ -709,8 +710,8 @@ void LLFloaterWindLight::onGlowBMoved(LLUICtrl* ctrl, void* userData) /// \NOTE that we want NEGATIVE (-) B and NOT by 20 as 20 is too big colorControl->b = -sldrCtrl->getValueF32() * 5; - colorControl->update(LLWLParamManager::instance()->mCurParams); - LLWLParamManager::instance()->propagateParameters(); + colorControl->update(LLWLParamManager::getInstance()->mCurParams); + LLWLParamManager::getInstance()->propagateParameters(); } void LLFloaterWindLight::onFloatControlMoved(LLUICtrl* ctrl, void* userData) @@ -722,8 +723,8 @@ void LLFloaterWindLight::onFloatControlMoved(LLUICtrl* ctrl, void* userData) floatControl->x = sldrCtrl->getValueF32() / floatControl->mult; - floatControl->update(LLWLParamManager::instance()->mCurParams); - LLWLParamManager::instance()->propagateParameters(); + floatControl->update(LLWLParamManager::getInstance()->mCurParams); + LLWLParamManager::getInstance()->propagateParameters(); } void LLFloaterWindLight::onBoolToggle(LLUICtrl* ctrl, void* userData) @@ -750,7 +751,7 @@ void LLFloaterWindLight::onSunMoved(LLUICtrl* ctrl, void* userData) WLColorControl * colorControl = static_cast(userData); // get the two angles - LLWLParamManager * param_mgr = LLWLParamManager::instance(); + LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); param_mgr->mCurParams.setSunAngle(F_TWO_PI * sunSldr->getValueF32()); param_mgr->mCurParams.setEastAngle(F_TWO_PI * eastSldr->getValueF32()); @@ -775,7 +776,7 @@ void LLFloaterWindLight::onFloatTweakMoved(LLUICtrl* ctrl, void* userData) F32 * tweak = static_cast(userData); (*tweak) = sldrCtrl->getValueF32(); - LLWLParamManager::instance()->propagateParameters(); + LLWLParamManager::getInstance()->propagateParameters(); } void LLFloaterWindLight::onStarAlphaMoved(LLUICtrl* ctrl, void* userData) @@ -784,12 +785,12 @@ void LLFloaterWindLight::onStarAlphaMoved(LLUICtrl* ctrl, void* userData) LLSliderCtrl* sldrCtrl = static_cast(ctrl); - LLWLParamManager::instance()->mCurParams.setStarBrightness(sldrCtrl->getValueF32()); + LLWLParamManager::getInstance()->mCurParams.setStarBrightness(sldrCtrl->getValueF32()); } void LLFloaterWindLight::onNewPreset(void* userData) { - LLNotifications::instance().add("NewSkyPreset", LLSD(), LLSD(), newPromptCallback); + LLNotificationsUtil::add("NewSkyPreset", LLSD(), LLSD(), newPromptCallback); } void LLFloaterWindLight::onSavePreset(void* userData) @@ -809,14 +810,14 @@ void LLFloaterWindLight::onSavePreset(void* userData) comboBox->getSelectedItemLabel()); if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("SkyEditPresets")) { - LLNotifications::instance().add("WLNoEditDefault"); + LLNotificationsUtil::add("WLNoEditDefault"); return; } - LLWLParamManager::instance()->mCurParams.mName = + LLWLParamManager::getInstance()->mCurParams.mName = comboBox->getSelectedItemLabel(); - LLNotifications::instance().add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback); + LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback); } bool LLFloaterWindLight::saveAlertCallback(const LLSD& notification, const LLSD& response) @@ -825,7 +826,7 @@ bool LLFloaterWindLight::saveAlertCallback(const LLSD& notification, const LLSD& // if they choose save, do it. Otherwise, don't do anything if(option == 0) { - LLWLParamManager * param_mgr = LLWLParamManager::instance(); + LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); param_mgr->setParamSet(param_mgr->mCurParams.mName, param_mgr->mCurParams); @@ -847,7 +848,7 @@ void LLFloaterWindLight::onDeletePreset(void* userData) LLSD args; args["SKY"] = combo_box->getSelectedValue().asString(); - LLNotifications::instance().add("WLDeletePresetAlert", args, LLSD(), + LLNotificationsUtil::add("WLDeletePresetAlert", args, LLSD(), boost::bind(&LLFloaterWindLight::deleteAlertCallback, sWindLight, _1, _2)); } @@ -878,11 +879,11 @@ bool LLFloaterWindLight::deleteAlertCallback(const LLSD& notification, const LLS std::set::iterator sIt = sDefaultPresets.find(name); if(sIt != sDefaultPresets.end()) { - LLNotifications::instance().add("WLNoEditDefault"); + LLNotificationsUtil::add("WLNoEditDefault"); return false; } - LLWLParamManager::instance()->removeParamSet(name, true); + LLWLParamManager::getInstance()->removeParamSet(name, true); // remove and choose another S32 new_index = combo_box->getCurrentIndex(); @@ -922,7 +923,7 @@ void LLFloaterWindLight::onChangePresetName(LLUICtrl* ctrl, void * userData) return; } - LLWLParamManager::instance()->loadPreset( + LLWLParamManager::getInstance()->loadPreset( combo_box->getSelectedValue().asString()); sWindLight->syncMenu(); } @@ -939,7 +940,7 @@ void LLFloaterWindLight::onCloudScrollXMoved(LLUICtrl* ctrl, void* userData) LLSliderCtrl* sldrCtrl = static_cast(ctrl); // *HACK all cloud scrolling is off by an additive of 10. - LLWLParamManager::instance()->mCurParams.setCloudScrollX(sldrCtrl->getValueF32() + 10.0f); + LLWLParamManager::getInstance()->mCurParams.setCloudScrollX(sldrCtrl->getValueF32() + 10.0f); } void LLFloaterWindLight::onCloudScrollYMoved(LLUICtrl* ctrl, void* userData) @@ -949,7 +950,7 @@ void LLFloaterWindLight::onCloudScrollYMoved(LLUICtrl* ctrl, void* userData) LLSliderCtrl* sldrCtrl = static_cast(ctrl); // *HACK all cloud scrolling is off by an additive of 10. - LLWLParamManager::instance()->mCurParams.setCloudScrollY(sldrCtrl->getValueF32() + 10.0f); + LLWLParamManager::getInstance()->mCurParams.setCloudScrollY(sldrCtrl->getValueF32() + 10.0f); } void LLFloaterWindLight::onCloudScrollXToggled(LLUICtrl* ctrl, void* userData) @@ -959,7 +960,7 @@ void LLFloaterWindLight::onCloudScrollXToggled(LLUICtrl* ctrl, void* userData) LLCheckBoxCtrl* cbCtrl = static_cast(ctrl); bool lock = cbCtrl->get(); - LLWLParamManager::instance()->mCurParams.setEnableCloudScrollX(!lock); + LLWLParamManager::getInstance()->mCurParams.setEnableCloudScrollX(!lock); LLSliderCtrl* sldr = sWindLight->getChild( "WLCloudScrollX"); @@ -981,7 +982,7 @@ void LLFloaterWindLight::onCloudScrollYToggled(LLUICtrl* ctrl, void* userData) LLCheckBoxCtrl* cbCtrl = static_cast(ctrl); bool lock = cbCtrl->get(); - LLWLParamManager::instance()->mCurParams.setEnableCloudScrollY(!lock); + LLWLParamManager::getInstance()->mCurParams.setEnableCloudScrollY(!lock); LLSliderCtrl* sldr = sWindLight->getChild( "WLCloudScrollY"); @@ -998,6 +999,6 @@ void LLFloaterWindLight::onCloudScrollYToggled(LLUICtrl* ctrl, void* userData) void LLFloaterWindLight::deactivateAnimator() { - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.mIsRunning = false; + LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = false; } diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp index 0750f9e78..fa514014d 100644 --- a/indra/newview/llfloaterworldmap.cpp +++ b/indra/newview/llfloaterworldmap.cpp @@ -43,6 +43,7 @@ #include "llagent.h" #include "llagentcamera.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llbutton.h" #include "llcallingcard.h" #include "llcolorscheme.h" @@ -52,6 +53,7 @@ #include "llfirstuse.h" #include "llfocusmgr.h" #include "lllandmarklist.h" +#include "llnotificationsutil.h" #include "lllineeditor.h" #include "llpreviewlandmark.h" #include "llregionhandle.h" @@ -1340,7 +1342,7 @@ void LLFloaterWorldMap::onCopySLURL(void* data) LLSD args; args["SLURL"] = self->mSLURL; - LLNotifications::instance().add("CopySLURL", args); + LLNotificationsUtil::add("CopySLURL", args); } void LLFloaterWorldMap::onCheckEvents(LLUICtrl*, void* data) diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp index 5878a8b48..73e902df0 100644 --- a/indra/newview/llgesturemgr.cpp +++ b/indra/newview/llgesturemgr.cpp @@ -43,6 +43,7 @@ #include "lldatapacker.h" #include "llinventory.h" #include "llmultigesture.h" +#include "llnotificationsutil.h" #include "llstl.h" #include "llstring.h" // todo: remove #include "llvfile.h" @@ -53,7 +54,6 @@ #include "llchatbar.h" #include "lldelayedgestureerror.h" #include "llinventorymodel.h" -#include "llnotify.h" #include "llviewermessage.h" #include "llvoavatar.h" #include "llviewerstats.h" @@ -64,8 +64,6 @@ #include "shcommandhandler.h" #endif //shy_mod -LLGestureManager gGestureManager; - // Longest time, in seconds, to wait for all animations to stop playing const F32 MAX_WAIT_ANIM_SECS = 30.f; @@ -75,7 +73,7 @@ static const LLUUID& get_linked_uuid(const LLUUID& item_id); // Lightweight constructor. // init() does the heavy lifting. -LLGestureManager::LLGestureManager() +LLGestureMgr::LLGestureMgr() : mValid(FALSE), mPlaying(), mActive(), @@ -84,7 +82,7 @@ LLGestureManager::LLGestureManager() // We own the data for gestures, so clean them up. -LLGestureManager::~LLGestureManager() +LLGestureMgr::~LLGestureMgr() { item_map_t::iterator it; for (it = mActive.begin(); it != mActive.end(); ++it) @@ -97,7 +95,7 @@ LLGestureManager::~LLGestureManager() } -void LLGestureManager::init() +void LLGestureMgr::init() { // TODO } @@ -105,10 +103,12 @@ void LLGestureManager::init() // Use this version when you have the item_id but not the asset_id, // and you KNOW the inventory is loaded. -void LLGestureManager::activateGesture(const LLUUID& item_id) +void LLGestureMgr::activateGesture(const LLUUID& item_id) { LLViewerInventoryItem* item = gInventory.getItem(item_id); if (!item) return; + if (item->getType() != LLAssetType::AT_GESTURE) + return; LLUUID asset_id = item->getAssetUUID(); @@ -121,7 +121,7 @@ void LLGestureManager::activateGesture(const LLUUID& item_id) } -void LLGestureManager::activateGestures(LLViewerInventoryItem::item_array_t& items) +void LLGestureMgr::activateGestures(LLViewerInventoryItem::item_array_t& items) { // Load up the assets S32 count = 0; @@ -214,7 +214,10 @@ struct LLLoadInfo // If inform_server is true, will send a message upstream to update // the user_gesture_active table. -void LLGestureManager::activateGestureWithAsset(const LLUUID& item_id, +/** + * It will load a gesture from remote storage + */ +void LLGestureMgr::activateGestureWithAsset(const LLUUID& item_id, const LLUUID& asset_id, BOOL inform_server, BOOL deactivate_similar) @@ -223,7 +226,7 @@ void LLGestureManager::activateGestureWithAsset(const LLUUID& item_id, if( !gAssetStorage ) { - llwarns << "LLGestureManager::activateGestureWithAsset without valid gAssetStorage" << llendl; + llwarns << "LLGestureMgr::activateGestureWithAsset without valid gAssetStorage" << llendl; return; } // If gesture is already active, nothing to do. @@ -265,7 +268,7 @@ void LLGestureManager::activateGestureWithAsset(const LLUUID& item_id, } -void LLGestureManager::deactivateGesture(const LLUUID& item_id) +void LLGestureMgr::deactivateGesture(const LLUUID& item_id) { const LLUUID& base_item_id = get_linked_uuid(item_id); item_map_t::iterator it = mActive.find(base_item_id); @@ -308,10 +311,10 @@ void LLGestureManager::deactivateGesture(const LLUUID& item_id) } -void LLGestureManager::deactivateSimilarGestures(LLMultiGesture* in, const LLUUID& in_item_id) +void LLGestureMgr::deactivateSimilarGestures(LLMultiGesture* in, const LLUUID& in_item_id) { const LLUUID& base_in_item_id = get_linked_uuid(in_item_id); - std::vector gest_item_ids; + uuid_vec_t gest_item_ids; // Deactivate all gestures that match item_map_t::iterator it; @@ -350,7 +353,7 @@ void LLGestureManager::deactivateSimilarGestures(LLMultiGesture* in, const LLUUI // Inform database of the change LLMessageSystem* msg = gMessageSystem; BOOL start_message = TRUE; - std::vector::const_iterator vit = gest_item_ids.begin(); + uuid_vec_t::const_iterator vit = gest_item_ids.begin(); while (vit != gest_item_ids.end()) { if (start_message) @@ -395,7 +398,7 @@ void LLGestureManager::deactivateSimilarGestures(LLMultiGesture* in, const LLUUI } -BOOL LLGestureManager::isGestureActive(const LLUUID& item_id) +BOOL LLGestureMgr::isGestureActive(const LLUUID& item_id) { const LLUUID& base_item_id = get_linked_uuid(item_id); item_map_t::iterator it = mActive.find(base_item_id); @@ -403,7 +406,7 @@ BOOL LLGestureManager::isGestureActive(const LLUUID& item_id) } -BOOL LLGestureManager::isGesturePlaying(const LLUUID& item_id) +BOOL LLGestureMgr::isGesturePlaying(const LLUUID& item_id) { const LLUUID& base_item_id = get_linked_uuid(item_id); item_map_t::iterator it = mActive.find(base_item_id); @@ -415,7 +418,17 @@ BOOL LLGestureManager::isGesturePlaying(const LLUUID& item_id) return gesture->mPlaying; } -void LLGestureManager::replaceGesture(const LLUUID& item_id, LLMultiGesture* new_gesture, const LLUUID& asset_id) +BOOL LLGestureMgr::isGesturePlaying(LLMultiGesture* gesture) +{ + if(!gesture) + { + return FALSE; + } + + return gesture->mPlaying; +} + +void LLGestureMgr::replaceGesture(const LLUUID& item_id, LLMultiGesture* new_gesture, const LLUUID& asset_id) { const LLUUID& base_item_id = get_linked_uuid(item_id); item_map_t::iterator it = mActive.find(base_item_id); @@ -456,10 +469,11 @@ void LLGestureManager::replaceGesture(const LLUUID& item_id, LLMultiGesture* new notifyObservers(); } -void LLGestureManager::replaceGesture(const LLUUID& item_id, const LLUUID& new_asset_id) +void LLGestureMgr::replaceGesture(const LLUUID& item_id, const LLUUID& new_asset_id) { const LLUUID& base_item_id = get_linked_uuid(item_id); - item_map_t::iterator it = gGestureManager.mActive.find(base_item_id); + + item_map_t::iterator it = LLGestureMgr::instance().mActive.find(base_item_id); if (it == mActive.end()) { llwarns << "replaceGesture for inactive gesture " << base_item_id << llendl; @@ -468,10 +482,10 @@ void LLGestureManager::replaceGesture(const LLUUID& item_id, const LLUUID& new_a // mActive owns this gesture pointer, so clean up memory. LLMultiGesture* gesture = (*it).second; - gGestureManager.replaceGesture(base_item_id, gesture, new_asset_id); + LLGestureMgr::instance().replaceGesture(base_item_id, gesture, new_asset_id); } -void LLGestureManager::playGesture(LLMultiGesture* gesture) +void LLGestureMgr::playGesture(LLMultiGesture* gesture) { if (!gesture) return; @@ -490,9 +504,10 @@ void LLGestureManager::playGesture(LLMultiGesture* gesture) // Convenience function that looks up the item_id for you. -void LLGestureManager::playGesture(const LLUUID& item_id) +void LLGestureMgr::playGesture(const LLUUID& item_id) { const LLUUID& base_item_id = get_linked_uuid(item_id); + item_map_t::iterator it = mActive.find(base_item_id); if (it == mActive.end()) return; @@ -506,7 +521,7 @@ void LLGestureManager::playGesture(const LLUUID& item_id) // Iterates through space delimited tokens in string, triggering any gestures found. // Generates a revised string that has the found tokens replaced by their replacement strings // and (as a minor side effect) has multiple spaces in a row replaced by single spaces. -BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::string* revised_string) +BOOL LLGestureMgr::triggerAndReviseString(const std::string &utf8str, std::string* revised_string) { std::string tokenized = utf8str; @@ -599,7 +614,7 @@ BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::s } -BOOL LLGestureManager::triggerGesture(KEY key, MASK mask) +BOOL LLGestureMgr::triggerGesture(KEY key, MASK mask) { std::vector matching; item_map_t::iterator it; @@ -633,7 +648,7 @@ BOOL LLGestureManager::triggerGesture(KEY key, MASK mask) } -S32 LLGestureManager::getPlayingCount() const +S32 LLGestureMgr::getPlayingCount() const { return mPlaying.size(); } @@ -647,7 +662,7 @@ struct IsGesturePlaying : public std::unary_function } }; -void LLGestureManager::update() +void LLGestureMgr::update() { S32 i; for (i = 0; i < (S32)mPlaying.size(); ++i) @@ -690,7 +705,7 @@ void LLGestureManager::update() // Run all steps until you're either done or hit a wait. -void LLGestureManager::stepGesture(LLMultiGesture* gesture) +void LLGestureMgr::stepGesture(LLMultiGesture* gesture) { if (!gesture) { @@ -838,7 +853,7 @@ void LLGestureManager::stepGesture(LLMultiGesture* gesture) } -void LLGestureManager::runStep(LLMultiGesture* gesture, LLGestureStep* step) +void LLGestureMgr::runStep(LLMultiGesture* gesture, LLGestureStep* step) { switch(step->getType()) { @@ -929,7 +944,7 @@ void LLGestureManager::runStep(LLMultiGesture* gesture, LLGestureStep* step) // static -void LLGestureManager::onLoadComplete(LLVFS *vfs, +void LLGestureMgr::onLoadComplete(LLVFS *vfs, const LLUUID& asset_uuid, LLAssetType::EType type, void* user_data, S32 status, LLExtStat ext_status) @@ -942,8 +957,8 @@ void LLGestureManager::onLoadComplete(LLVFS *vfs, delete info; info = NULL; - - gGestureManager.mLoadingCount--; + LLGestureMgr& self = LLGestureMgr::instance(); + self.mLoadingCount--; if (0 == status) { @@ -970,21 +985,22 @@ void LLGestureManager::onLoadComplete(LLVFS *vfs, { if (deactivate_similar) { - gGestureManager.deactivateSimilarGestures(gesture, item_id); + self.deactivateSimilarGestures(gesture, item_id); // Display deactivation message if this was the last of the bunch. - if (gGestureManager.mLoadingCount == 0 - && gGestureManager.mDeactivateSimilarNames.length() > 0) + if (self.mLoadingCount == 0 + && self.mDeactivateSimilarNames.length() > 0) { // we're done with this set of deactivations LLSD args; - args["NAMES"] = gGestureManager.mDeactivateSimilarNames; - LLNotifications::instance().add("DeactivatedGesturesTrigger", args); + args["NAMES"] = self.mDeactivateSimilarNames; + LLNotificationsUtil::add("DeactivatedGesturesTrigger", args); } } + self.mActive[item_id] = gesture; + // Everything has been successful. Add to the active list. - gGestureManager.mActive[item_id] = gesture; gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); if (inform_server) { @@ -1004,13 +1020,13 @@ void LLGestureManager::onLoadComplete(LLVFS *vfs, gAgent.sendReliableMessage(); } - gGestureManager.notifyObservers(); + self.notifyObservers(); } else { llwarns << "Unable to load gesture" << llendl; - gGestureManager.mActive.erase(item_id); + self.mActive.erase(item_id); delete gesture; gesture = NULL; @@ -1035,12 +1051,13 @@ void LLGestureManager::onLoadComplete(LLVFS *vfs, llwarns << "Problem loading gesture: " << status << llendl; - gGestureManager.mActive.erase(item_id); + LLGestureMgr::instance().mActive.erase(item_id); } } -void LLGestureManager::stopGesture(LLMultiGesture* gesture) + +void LLGestureMgr::stopGesture(LLMultiGesture* gesture) { if (!gesture) return; @@ -1080,7 +1097,7 @@ void LLGestureManager::stopGesture(LLMultiGesture* gesture) } -void LLGestureManager::stopGesture(const LLUUID& item_id) +void LLGestureMgr::stopGesture(const LLUUID& item_id) { const LLUUID& base_item_id = get_linked_uuid(item_id); item_map_t::iterator it = mActive.find(base_item_id); @@ -1093,12 +1110,12 @@ void LLGestureManager::stopGesture(const LLUUID& item_id) } -void LLGestureManager::addObserver(LLGestureManagerObserver* observer) +void LLGestureMgr::addObserver(LLGestureManagerObserver* observer) { mObservers.push_back(observer); } -void LLGestureManager::removeObserver(LLGestureManagerObserver* observer) +void LLGestureMgr::removeObserver(LLGestureManagerObserver* observer) { std::vector::iterator it; it = std::find(mObservers.begin(), mObservers.end(), observer); @@ -1111,9 +1128,9 @@ void LLGestureManager::removeObserver(LLGestureManagerObserver* observer) // Call this method when it's time to update everyone on a new state. // Copy the list because an observer could respond by removing itself // from the list. -void LLGestureManager::notifyObservers() +void LLGestureMgr::notifyObservers() { - lldebugs << "LLGestureManager::notifyObservers" << llendl; + lldebugs << "LLGestureMgr::notifyObservers" << llendl; for(std::vector::iterator iter = mObservers.begin(); iter != mObservers.end(); @@ -1124,7 +1141,7 @@ void LLGestureManager::notifyObservers() } } -BOOL LLGestureManager::matchPrefix(const std::string& in_str, std::string* out_str) +BOOL LLGestureMgr::matchPrefix(const std::string& in_str, std::string* out_str) { S32 in_len = in_str.length(); @@ -1155,7 +1172,7 @@ BOOL LLGestureManager::matchPrefix(const std::string& in_str, std::string* out_s } -void LLGestureManager::getItemIDs(std::vector* ids) +void LLGestureMgr::getItemIDs(uuid_vec_t* ids) { item_map_t::const_iterator it; for (it = mActive.begin(); it != mActive.end(); ++it) diff --git a/indra/newview/llgesturemgr.h b/indra/newview/llgesturemgr.h index f564c1748..88d3b9c4a 100644 --- a/indra/newview/llgesturemgr.h +++ b/indra/newview/llgesturemgr.h @@ -52,11 +52,14 @@ public: virtual void changed() = 0; }; -class LLGestureManager +class LLGestureMgr : public LLSingleton { public: - LLGestureManager(); - ~LLGestureManager(); + // Maps inventory item_id to gesture + typedef std::map item_map_t; + + LLGestureMgr(); + ~LLGestureMgr(); void init(); @@ -95,6 +98,9 @@ public: BOOL isGesturePlaying(const LLUUID& item_id); + BOOL isGesturePlaying(LLMultiGesture* gesture); + + const item_map_t& getActiveGestures() const { return mActive; } // Force a gesture to be played, for example, if it is being // previewed. void playGesture(LLMultiGesture* gesture); @@ -124,7 +130,7 @@ public: BOOL matchPrefix(const std::string& in_str, std::string* out_str); // Copy item ids into the vector - void getItemIDs(std::vector* ids); + void getItemIDs(uuid_vec_t* ids); protected: // Handle the processing of a single gesture @@ -139,13 +145,10 @@ protected: LLAssetType::EType type, void* user_data, S32 status, LLExtStat ext_status); -public: - BOOL mValid; - std::vector mPlaying; - // Maps inventory item_id to gesture - typedef std::map item_map_t; + +private: // Active gestures. // NOTE: The gesture pointer CAN BE NULL. This means that // there is a gesture with that item_id, but the asset data @@ -156,8 +159,7 @@ public: std::string mDeactivateSimilarNames; std::vector mObservers; + std::vector mPlaying; + BOOL mValid; }; - -extern LLGestureManager gGestureManager; - #endif diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 5da3926b7..c4829d326 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -776,7 +776,7 @@ void LLViewerParcelMgr::renderCollisionSegments(U8* segments, BOOL use_pass, LLV F32 pos_y = pos.mV[VY]; LLGLSUIDefault gls_ui; - LLGLDepthTest gls_depth(GL_TRUE); + LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); LLGLDisable cull(GL_CULL_FACE); if (mCollisionBanned == BA_BANNED) @@ -819,12 +819,6 @@ void LLViewerParcelMgr::renderCollisionSegments(U8* segments, BOOL use_pass, LLV x2 = x1 + PARCEL_GRID_STEP_METERS; y2 = y1; - if (gRenderForSelect) - { - LLColor4U color((U8)(GL_NAME_PARCEL_WALL >> 16), (U8)(GL_NAME_PARCEL_WALL >> 8), (U8)GL_NAME_PARCEL_WALL); - gGL.color4ubv(color.mV); - } - else { dy = (pos_y - y1) + DIST_OFFSET; @@ -865,12 +859,6 @@ void LLViewerParcelMgr::renderCollisionSegments(U8* segments, BOOL use_pass, LLV x2 = x1; y2 = y1 + PARCEL_GRID_STEP_METERS; - if (gRenderForSelect) - { - LLColor4U color((U8)(GL_NAME_PARCEL_WALL >> 16), (U8)(GL_NAME_PARCEL_WALL >> 8), (U8)GL_NAME_PARCEL_WALL); - gGL.color4ubv(color.mV); - } - else { dx = (pos_x - x1) + DIST_OFFSET; diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 6e1f6de57..3cea45937 100644 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -53,6 +53,7 @@ #include "llviewerwindow.h" #include "llfloaterdirectory.h" #include "llfloatergroupinfo.h" +#include "llnotificationsutil.h" #include "lluictrlfactory.h" #if LL_MSVC #pragma warning( disable : 4265 ) // "class has virtual functions, but destructor is not virtual" @@ -1376,7 +1377,7 @@ void LLGroupMgr::processCreateGroupReply(LLMessageSystem* msg, void ** data) // *TODO:translate LLSD args; args["MESSAGE"] = message; - LLNotifications::instance().add("UnableToCreateGroup", args); + LLNotificationsUtil::add("UnableToCreateGroup", args); } } diff --git a/indra/newview/llhoverview.cpp b/indra/newview/llhoverview.cpp index 1821b7da7..171977066 100644 --- a/indra/newview/llhoverview.cpp +++ b/indra/newview/llhoverview.cpp @@ -179,7 +179,7 @@ void LLHoverView::pickCallback(const LLPickInfo& pick_info) { gHoverView->setHoverActive(TRUE); gHoverView->mHoverLandGlobal = pick_info.mPosGlobal; - LLViewerParcelMgr::getInstance()->requestHoverParcelProperties( gHoverView->mHoverLandGlobal ); + LLViewerParcelMgr::getInstance()->setHoverParcel( gHoverView->mHoverLandGlobal ); } else { diff --git a/indra/newview/llhudeffectlookat.cpp b/indra/newview/llhudeffectlookat.cpp index e25efdf42..14c1f3000 100644 --- a/indra/newview/llhudeffectlookat.cpp +++ b/indra/newview/llhudeffectlookat.cpp @@ -543,7 +543,7 @@ void LLHUDEffectLookAt::render() const LLFontGL* font = LLResMgr::getInstance()->getRes(LLFONT_SANSSERIF); LLGLEnable gl_blend(GL_BLEND); glPushMatrix(); - gViewerWindow->setupViewport(); + gViewerWindow->setup2DViewport(); hud_render_utf8text(text, target + shadow_offset, *font, diff --git a/indra/newview/llhudicon.cpp b/indra/newview/llhudicon.cpp index 3fcabee32..9da28a2de 100644 --- a/indra/newview/llhudicon.cpp +++ b/indra/newview/llhudicon.cpp @@ -39,6 +39,7 @@ #include "llviewerobject.h" #include "lldrawable.h" +#include "llvector4a.h" #include "llviewercamera.h" #include "llviewertexture.h" #include "llviewerwindow.h" @@ -73,7 +74,6 @@ LLHUDIcon::LLHUDIcon(const U8 type) : mScale(0.1f), mHidden(FALSE) { - llassert(this); sIconInstances.push_back(this); } @@ -146,9 +146,9 @@ void LLHUDIcon::renderIcon(BOOL for_select) alpha_factor *= clamp_rescale(time_elapsed, MAX_VISIBLE_TIME - FADE_OUT_TIME, MAX_VISIBLE_TIME, 1.f, 0.f); } - F32 image_aspect = (F32)mImagep->getFullWidth() / (F32)mImagep->getFullHeight(); - LLVector3 x_scale = image_aspect * (F32)gViewerWindow->getWindowHeight() * mScale * scale_factor * x_pixel_vec; - LLVector3 y_scale = (F32)gViewerWindow->getWindowHeight() * mScale * scale_factor * y_pixel_vec; + F32 image_aspect = (F32)mImagep->getFullWidth() / (F32)mImagep->getFullHeight() ; + LLVector3 x_scale = image_aspect * (F32)gViewerWindow->getWindowHeightScaled() * mScale * scale_factor * x_pixel_vec; + LLVector3 y_scale = (F32)gViewerWindow->getWindowHeightScaled() * mScale * scale_factor * y_pixel_vec; LLVector3 lower_left = icon_position - (x_scale * 0.5f); LLVector3 lower_right = icon_position + (x_scale * 0.5f); @@ -208,11 +208,6 @@ void LLHUDIcon::render() renderIcon(FALSE); } -void LLHUDIcon::renderForSelect() -{ - renderIcon(TRUE); -} - BOOL LLHUDIcon::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, LLVector3* intersection) { if (mHidden) @@ -263,27 +258,46 @@ BOOL LLHUDIcon::lineSegmentIntersect(const LLVector3& start, const LLVector3& en return FALSE; } - F32 image_aspect = (F32)mImagep->getFullWidth() / (F32)mImagep->getFullHeight(); - LLVector3 x_scale = image_aspect * (F32)gViewerWindow->getWindowHeight() * mScale * scale_factor * x_pixel_vec; - LLVector3 y_scale = (F32)gViewerWindow->getWindowHeight() * mScale * scale_factor * y_pixel_vec; + F32 image_aspect = (F32)mImagep->getFullWidth() / (F32)mImagep->getFullHeight() ; + LLVector3 x_scale = image_aspect * (F32)gViewerWindow->getWindowHeightScaled() * mScale * scale_factor * x_pixel_vec; + LLVector3 y_scale = (F32)gViewerWindow->getWindowHeightScaled() * mScale * scale_factor * y_pixel_vec; - LLVector3 lower_left = icon_position - (x_scale * 0.5f); - LLVector3 lower_right = icon_position + (x_scale * 0.5f); - LLVector3 upper_left = icon_position - (x_scale * 0.5f) + y_scale; - LLVector3 upper_right = icon_position + (x_scale * 0.5f) + y_scale; + LLVector4a x_scalea; + LLVector4a icon_positiona; + LLVector4a y_scalea; - - F32 t = 0.f; - LLVector3 dir = end-start; + x_scalea.load3(x_scale.mV); + x_scalea.mul(0.5f); + y_scalea.load3(y_scale.mV); - F32 a,b; + icon_positiona.load3(icon_position.mV); - if (LLTriangleRayIntersect(upper_right, upper_left, lower_right, start, dir, a, b, t, FALSE) || - LLTriangleRayIntersect(upper_left, lower_left, lower_right, start, dir, a, b, t, FALSE)) + LLVector4a lower_left; + lower_left.setSub(icon_positiona, x_scalea); + LLVector4a lower_right; + lower_right.setAdd(icon_positiona, x_scalea); + LLVector4a upper_left; + upper_left.setAdd(lower_left, y_scalea); + LLVector4a upper_right; + upper_right.setAdd(lower_right, y_scalea); + + LLVector4a enda; + enda.load3(end.mV); + LLVector4a starta; + starta.load3(start.mV); + LLVector4a dir; + dir.setSub(enda, starta); + + F32 a,b,t; + + if (LLTriangleRayIntersect(upper_right, upper_left, lower_right, starta, dir, a,b,t) || + LLTriangleRayIntersect(upper_left, lower_left, lower_right, starta, dir, a,b,t)) { if (intersection) { - *intersection = start + dir*t; + dir.mul(t); + starta.add(dir); + *intersection = LLVector3(starta.getF32ptr()); } return TRUE; } diff --git a/indra/newview/llhudicon.h b/indra/newview/llhudicon.h index 6d523a287..5697cc94f 100644 --- a/indra/newview/llhudicon.h +++ b/indra/newview/llhudicon.h @@ -33,7 +33,7 @@ #ifndef LL_LLHUDICON_H #define LL_LLHUDICON_H -#include "llmemory.h" +#include "llpointer.h" #include "lldarrayptr.h" #include "llhudobject.h" @@ -58,7 +58,6 @@ friend class LLHUDObject; public: /*virtual*/ void render(); - /*virtual*/ void renderForSelect(); /*virtual*/ void markDead(); /*virtual*/ F32 getDistance() const { return mDistance; } diff --git a/indra/newview/llhudobject.cpp b/indra/newview/llhudobject.cpp index b2ba698bc..d136a1df7 100644 --- a/indra/newview/llhudobject.cpp +++ b/indra/newview/llhudobject.cpp @@ -286,26 +286,6 @@ void LLHUDObject::renderAll() LLVertexBuffer::unbind(); } -// static -void LLHUDObject::renderAllForSelect() -{ - LLHUDObject *hud_objp; - - hud_object_list_t::iterator object_it; - for (object_it = sHUDObjects.begin(); object_it != sHUDObjects.end(); ) - { - hud_object_list_t::iterator cur_it = object_it++; - hud_objp = (*cur_it); - if (hud_objp->getNumRefs() == 1) - { - sHUDObjects.erase(cur_it); - } - else if (hud_objp->isVisible()) - { - hud_objp->renderForSelect(); - } - } -} // static void LLHUDObject::renderAllForTimer() { diff --git a/indra/newview/llhudobject.h b/indra/newview/llhudobject.h index b645ae07a..73140eba6 100644 --- a/indra/newview/llhudobject.h +++ b/indra/newview/llhudobject.h @@ -74,7 +74,6 @@ public: static LLHUDEffect *addHUDEffect(const U8 type); static void updateAll(); static void renderAll(); - static void renderAllForSelect(); static void renderAllForTimer(); static void cleanupHUDObjects(); @@ -106,7 +105,6 @@ protected: ~LLHUDObject(); virtual void render() = 0; - virtual void renderForSelect() {} //Only override when needed. virtual void renderForTimer() {}; protected: diff --git a/indra/newview/llhudrender.cpp b/indra/newview/llhudrender.cpp index 56fb13c87..9b5633872 100644 --- a/indra/newview/llhudrender.cpp +++ b/indra/newview/llhudrender.cpp @@ -75,8 +75,8 @@ void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent, LLVector3 up_axis; if (orthographic) { - right_axis.setVec(0.f, -1.f / gViewerWindow->getWindowHeight(), 0.f); - up_axis.setVec(0.f, 0.f, 1.f / gViewerWindow->getWindowHeight()); + right_axis.setVec(0.f, -1.f / gViewerWindow->getWorldViewHeightScaled(), 0.f); + up_axis.setVec(0.f, 0.f, 1.f / gViewerWindow->getWorldViewHeightScaled()); } else { @@ -104,23 +104,31 @@ void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent, //get the render_pos in screen space F64 winX, winY, winZ; + LLRect world_view_rect = gViewerWindow->getWorldViewRectRaw(); + S32 viewport[4]; + viewport[0] = world_view_rect.mLeft; + viewport[1] = world_view_rect.mBottom; + viewport[2] = world_view_rect.getWidth(); + viewport[3] = world_view_rect.getHeight(); gluProject(render_pos.mV[0], render_pos.mV[1], render_pos.mV[2], - gGLModelView, gGLProjection, (GLint*) gGLViewport, + gGLModelView, gGLProjection, (GLint*) viewport, &winX, &winY, &winZ); - //fonts all render orthographically, set up projection + //fonts all render orthographically, set up projection`` glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_MODELVIEW); gGL.pushMatrix(); LLUI::pushMatrix(); - gViewerWindow->setup2DRender(); - + gl_state_for_2d(world_view_rect.getWidth(), world_view_rect.getHeight()); + gViewerWindow->setup3DViewport(); + + winX -= world_view_rect.mLeft; + winY -= world_view_rect.mBottom; LLUI::loadIdentity(); + glLoadIdentity(); LLUI::translate((F32) winX*1.0f/LLFontGL::sScaleX, (F32) winY*1.0f/(LLFontGL::sScaleY), -(((F32) winZ*2.f)-1.f)); - //glRotatef(angle * RAD_TO_DEG, axis.mV[VX], axis.mV[VY], axis.mV[VZ]); - //glScalef(right_scale, up_scale, 1.f); F32 right_x; font.render(wstr, 0, 0, 0, color, LLFontGL::LEFT, LLFontGL::BASELINE, style, wstr.length(), 1000, &right_x); diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp index fc210a142..683f46a1f 100644 --- a/indra/newview/llhudtext.cpp +++ b/indra/newview/llhudtext.cpp @@ -239,15 +239,6 @@ void LLHUDText::render() } } -void LLHUDText::renderForSelect() -{ - if (!mOnHUDAttachment) - { - LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - renderText(TRUE); - } -} - void LLHUDText::renderText(BOOL for_select) { if (!mVisible || mHidden) diff --git a/indra/newview/llhudtext.h b/indra/newview/llhudtext.h index ab266bd96..2c404cfad 100644 --- a/indra/newview/llhudtext.h +++ b/indra/newview/llhudtext.h @@ -146,7 +146,6 @@ protected: LLHUDText(const U8 type); /*virtual*/ void render(); - /*virtual*/ void renderForSelect(); void renderText(BOOL for_select); static void updateAll(); void setLOD(S32 lod); diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp index 2feae487d..ff574bea8 100644 --- a/indra/newview/llimpanel.cpp +++ b/indra/newview/llimpanel.cpp @@ -42,6 +42,7 @@ #include "llstring.h" #include "message.h" #include "lltextbox.h" +#include "llnotificationsutil.h" #include "llagent.h" #include "llbutton.h" @@ -394,13 +395,13 @@ void LLVoiceChannel::setChannelInfo( { if (mURI.empty()) { - LLNotifications::instance().add("VoiceChannelJoinFailed", mNotifyArgs); + LLNotificationsUtil::add("VoiceChannelJoinFailed", mNotifyArgs); llwarns << "Received empty URI for channel " << mSessionName << llendl; deactivate(); } else if (mCredentials.empty()) { - LLNotifications::instance().add("VoiceChannelJoinFailed", mNotifyArgs); + LLNotificationsUtil::add("VoiceChannelJoinFailed", mNotifyArgs); llwarns << "Received empty credentials for channel " << mSessionName << llendl; deactivate(); } @@ -444,7 +445,7 @@ void LLVoiceChannel::handleStatusChange(EStatusType type) { case STATUS_LOGIN_RETRY: //mLoginNotificationHandle = LLNotifyBox::showXml("VoiceLoginRetry")->getHandle(); - LLNotifications::instance().add("VoiceLoginRetry"); + LLNotificationsUtil::add("VoiceLoginRetry"); break; case STATUS_LOGGED_IN: //if (!mLoginNotificationHandle.isDead()) @@ -462,7 +463,7 @@ void LLVoiceChannel::handleStatusChange(EStatusType type) { // if forceably removed from channel // update the UI and revert to default channel - LLNotifications::instance().add("VoiceChannelDisconnected", mNotifyArgs); + LLNotificationsUtil::add("VoiceChannelDisconnected", mNotifyArgs); deactivate(); } mIgnoreNextSessionLeave = FALSE; @@ -954,12 +955,12 @@ void LLVoiceChannelP2P::handleStatusChange(EStatusType type) if (mState == STATE_RINGING) { // other user declined call - LLNotifications::instance().add("P2PCallDeclined", mNotifyArgs); + LLNotificationsUtil::add("P2PCallDeclined", mNotifyArgs); } else { // other user hung up - LLNotifications::instance().add("VoiceChannelDisconnectedP2P", mNotifyArgs); + LLNotificationsUtil::add("VoiceChannelDisconnectedP2P", mNotifyArgs); } deactivate(); } @@ -977,7 +978,7 @@ void LLVoiceChannelP2P::handleError(EStatusType type) switch(type) { case ERROR_NOT_AVAILABLE: - LLNotifications::instance().add("P2PCallNoAnswer", mNotifyArgs); + LLNotificationsUtil::add("P2PCallNoAnswer", mNotifyArgs); break; default: break; diff --git a/indra/newview/llinventoryactions.cpp b/indra/newview/llinventoryactions.cpp index 61fdb29e4..aa0db9c4e 100644 --- a/indra/newview/llinventoryactions.cpp +++ b/indra/newview/llinventoryactions.cpp @@ -43,11 +43,13 @@ #include "llagent.h" #include "llcallingcard.h" #include "llcheckboxctrl.h" // for radio buttons +#include "llnotificationsutil.h" #include "llradiogroup.h" #include "llspinctrl.h" #include "lltextbox.h" #include "llui.h" + #include "llviewercontrol.h" #include "llfirstuse.h" #include "llfloateravatarinfo.h" @@ -289,7 +291,7 @@ class LLEmptyTrash : public inventory_panel_listener_t { LLInventoryModel* model = mPtr->getModel(); if(!model) return false; - LLNotifications::instance().add("ConfirmEmptyTrash", LLSD(), LLSD(), boost::bind(&LLEmptyTrash::callback_empty_trash, this, _1, _2)); + LLNotificationsUtil::add("ConfirmEmptyTrash", LLSD(), LLSD(), boost::bind(&LLEmptyTrash::callback_empty_trash, this, _1, _2)); return true; } @@ -313,7 +315,7 @@ class LLEmptyLostAndFound : public inventory_panel_listener_t { LLInventoryModel* model = mPtr->getModel(); if(!model) return false; - LLNotifications::instance().add("ConfirmEmptyLostAndFound", LLSD(), LLSD(), boost::bind(&LLEmptyLostAndFound::callback_empty_lost_and_found, this, _1, _2)); + LLNotificationsUtil::add("ConfirmEmptyLostAndFound", LLSD(), LLSD(), boost::bind(&LLEmptyLostAndFound::callback_empty_lost_and_found, this, _1, _2)); return true; } diff --git a/indra/newview/llinventorybackup.cpp b/indra/newview/llinventorybackup.cpp index 055cc2d61..3f58e3064 100644 --- a/indra/newview/llinventorybackup.cpp +++ b/indra/newview/llinventorybackup.cpp @@ -13,7 +13,7 @@ #include "lluictrlfactory.h" #include "llscrolllistctrl.h" #include "llimagetga.h" - +#include "llnotificationsutil.h" std::list LLFloaterInventoryBackup::sInstances; @@ -115,7 +115,7 @@ void LLFloaterInventoryBackupSettings::onClickNext(void* userdata) { LLSD args; args["ERROR_MESSAGE"] = "No items passed the filter \\o/"; - LLNotifications::instance().add("ErrorMessage", args); + LLNotificationsUtil::add("ErrorMessage", args); return; } @@ -353,7 +353,7 @@ void LLInventoryBackup::imageCallback(BOOL success, { LLSD args; args["ERROR_MESSAGE"] = "Download didn't work on " + item->getName() + "."; - LLNotifications::instance().add("ErrorMessage", args); + LLNotificationsUtil::add("ErrorMessage", args); return; } @@ -379,13 +379,13 @@ void LLInventoryBackup::imageCallback_continued(LLImageRaw* src, AIFilePicker* f { LLSD args; args["ERROR_MESSAGE"] = "Couldn't encode file."; - LLNotifications::instance().add("ErrorMessage", args); + LLNotificationsUtil::add("ErrorMessage", args); } else if( !image_tga->save( filename ) ) { LLSD args; args["ERROR_MESSAGE"] = "Couldn't write file."; - LLNotifications::instance().add("ErrorMessage", args); + LLNotificationsUtil::add("ErrorMessage", args); } } @@ -402,7 +402,7 @@ void LLInventoryBackup::assetCallback(LLVFS *vfs, { LLSD args; args["ERROR_MESSAGE"] = "Download didn't work on " + item->getName() + "."; - LLNotifications::instance().add("ErrorMessage", args); + LLNotificationsUtil::add("ErrorMessage", args); return; } diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 8ae7f8523..57194eba0 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -36,6 +36,7 @@ #include "llinventoryview.h" #include "llinventorybridge.h" +#include "llinventorydefines.h" #include "message.h" @@ -66,6 +67,8 @@ #include "llinventoryclipboard.h" #include "lllineeditor.h" #include "llmenugl.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llpreviewanim.h" #include "llpreviewgesture.h" #include "llpreviewlandmark.h" @@ -225,7 +228,7 @@ BOOL get_is_item_worn(const LLInventoryItem *item) return TRUE; break; case LLAssetType::AT_GESTURE: - if (gGestureManager.isGestureActive(item->getLinkedUUID())) + if (LLGestureMgr::instance().isGestureActive(item->getLinkedUUID())) return TRUE; break; default: @@ -361,7 +364,7 @@ void LLInvFVBridge::removeBatch(LLDynamicArray& batc { if(LLAssetType::AT_GESTURE == item->getType()) { - gGestureManager.deactivateGesture(item->getUUID()); + LLGestureMgr::instance().deactivateGesture(item->getUUID()); } } } @@ -377,7 +380,7 @@ void LLInvFVBridge::removeBatch(LLDynamicArray& batc { if(LLAssetType::AT_GESTURE == descendent_items[j]->getType()) { - gGestureManager.deactivateGesture(descendent_items[j]->getUUID()); + LLGestureMgr::instance().deactivateGesture(descendent_items[j]->getUUID()); } } } @@ -1837,9 +1840,9 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, { LLInventoryItem* item = descendent_items[i]; if (item->getType() == LLAssetType::AT_GESTURE - && gGestureManager.isGestureActive(item->getUUID())) + && LLGestureMgr::instance().isGestureActive(item->getUUID())) { - gGestureManager.deactivateGesture(item->getUUID()); + LLGestureMgr::instance().deactivateGesture(item->getUUID()); } } } @@ -1875,7 +1878,7 @@ void warn_move_inventory(LLViewerObject* object, LLMoveInv* move_inv) { dialog = "MoveInventoryFromObject"; } - LLNotifications::instance().add(dialog, LLSD(), LLSD(), boost::bind(move_task_inventory_callback, _1, _2, move_inv)); + LLNotificationsUtil::add(dialog, LLSD(), LLSD(), boost::bind(move_task_inventory_callback, _1, _2, move_inv)); } // Move/copy all inventory items from the Contents folder of an in-world @@ -2402,9 +2405,9 @@ BOOL LLFolderBridge::removeItem() { LLInventoryItem* item = descendent_items[i]; if (item->getType() == LLAssetType::AT_GESTURE - && gGestureManager.isGestureActive(item->getUUID())) + && LLGestureMgr::instance().isGestureActive(item->getUUID())) { - gGestureManager.deactivateGesture(item->getUUID()); + LLGestureMgr::instance().deactivateGesture(item->getUUID()); } } @@ -2931,7 +2934,7 @@ bool move_task_inventory_callback(const LLSD& notification, const LLSD& response { LLFloaterOpenObject::LLCatAndWear* cat_and_wear = (LLFloaterOpenObject::LLCatAndWear* )move_inv->mUserData; LLViewerObject* object = gObjectList.findObject(move_inv->mObjectID); - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if(option == 0 && object) { @@ -3019,9 +3022,9 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item, if(accept && drop) { if (inv_item->getType() == LLAssetType::AT_GESTURE - && gGestureManager.isGestureActive(inv_item->getUUID()) && move_is_into_trash) + && LLGestureMgr::instance().isGestureActive(inv_item->getUUID()) && move_is_into_trash) { - gGestureManager.deactivateGesture(inv_item->getUUID()); + LLGestureMgr::instance().deactivateGesture(inv_item->getUUID()); } // If an item is being dragged between windows, unselect // everything in the active window so that we don't follow @@ -3411,7 +3414,7 @@ void open_landmark(LLViewerInventoryItem* inv_item, static bool open_landmark_callback(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); LLUUID asset_id = notification["payload"]["asset_id"].asUUID(); LLUUID item_id = notification["payload"]["item_id"].asUUID(); @@ -3445,7 +3448,7 @@ void LLLandmarkBridge::openItem() LLSD payload; payload["asset_id"] = item->getAssetUUID(); payload["item_id"] = item->getUUID(); - LLNotifications::instance().add("TeleportFromLandmark", LLSD(), payload); + LLNotificationsUtil::add("TeleportFromLandmark", LLSD(), payload); } } @@ -3748,7 +3751,7 @@ LLFontGL::StyleFlags LLGestureBridge::getLabelStyle() const { U8 font = LLFontGL::NORMAL; - if (gGestureManager.isGestureActive(mUUID)) + if (LLGestureMgr::instance().isGestureActive(mUUID)) { font |= LLFontGL::BOLD; } @@ -3764,7 +3767,7 @@ LLFontGL::StyleFlags LLGestureBridge::getLabelStyle() const std::string LLGestureBridge::getLabelSuffix() const { - if( gGestureManager.isGestureActive(mUUID) ) + if( LLGestureMgr::instance().isGestureActive(mUUID) ) { return LLItemBridge::getLabelSuffix() + " (active)"; } @@ -3779,7 +3782,7 @@ void LLGestureBridge::performAction(LLFolderView* folder, LLInventoryModel* mode { if ("activate" == action) { - gGestureManager.activateGesture(mUUID); + LLGestureMgr::instance().activateGesture(mUUID); LLViewerInventoryItem* item = gInventory.getItem(mUUID); if (!item) return; @@ -3791,7 +3794,7 @@ void LLGestureBridge::performAction(LLFolderView* folder, LLInventoryModel* mode } else if ("deactivate" == action) { - gGestureManager.deactivateGesture(mUUID); + LLGestureMgr::instance().deactivateGesture(mUUID); LLViewerInventoryItem* item = gInventory.getItem(mUUID); if (!item) return; @@ -3837,7 +3840,7 @@ BOOL LLGestureBridge::removeItem() const LLUUID item_id = mUUID; // Force close the preview window, if it exists - gGestureManager.deactivateGesture(item_id); + LLGestureMgr::instance().deactivateGesture(item_id); // If deactivateGesture deleted *this, then return out immediately. if (!model->getObject(item_id)) @@ -3867,7 +3870,7 @@ void LLGestureBridge::buildContextMenu(LLMenuGL& menu, U32 flags) getClipboardEntries(true, items, disabled_items, flags); items.push_back(std::string("Gesture Separator")); - if (gGestureManager.isGestureActive(getUUID())) + if (LLGestureMgr::instance().isGestureActive(getUUID())) { items.push_back(std::string("Deactivate")); } @@ -4119,13 +4122,10 @@ void LLObjectBridge::openItem() } if (avatar->isWearingAttachment(mUUID)) { -#ifdef LL_RRINTERFACE_H //MK - if (gRRenabled && !gAgent.mRRInterface.canDetach(avatar->getWornAttachment(mUUID))) - { - return; - } -#endif //mk - performAction(NULL, NULL, "detach"); +// [RLVa:KB] + if ( !(rlv_handler_t::isEnabled()) || (gRlvAttachmentLocks.canDetach(getItem()))) + performAction(NULL, NULL, "detach"); +// [/RLVa:KB] } else { @@ -4194,7 +4194,7 @@ void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attach if ( (rlv_handler_t::isEnabled()) && ((gRlvAttachmentLocks.canAttach(attachment) & RLV_WEAR_REPLACE) == 0) ) return; // [/RLVa:KB] - LLNotifications::instance().add("ReplaceAttachment", LLSD(), payload, confirm_replace_attachment_rez); + LLNotificationsUtil::add("ReplaceAttachment", LLSD(), payload, confirm_replace_attachment_rez); } else { @@ -4213,11 +4213,11 @@ bool confirm_replace_attachment_rez(const LLSD& notification, const LLSD& respon { LLSD args; args["MAX_ATTACHMENTS"] = llformat("%d", MAX_AGENT_ATTACHMENTS); - LLNotifications::instance().add("MaxAttachmentsOnOutfit", args); + LLNotificationsUtil::add("MaxAttachmentsOnOutfit", args); return false; } - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option == 0/*YES*/) { LLUUID item_id = notification["payload"]["item_id"].asUUID(); @@ -4850,7 +4850,7 @@ void wear_inventory_category_on_avatar_step2( BOOL proceed, void* userdata ) if( !wearable_count && !obj_count && !gest_count) { - LLNotifications::instance().add("CouldNotPutOnOutfit"); + LLNotificationsUtil::add("CouldNotPutOnOutfit"); delete wear_info; return; } @@ -4866,7 +4866,7 @@ void wear_inventory_category_on_avatar_step2( BOOL proceed, void* userdata ) { llinfos << "Activating " << gest_count << " gestures" << llendl; - gGestureManager.activateGestures(gest_item_array); + LLGestureMgr::instance().activateGestures(gest_item_array); // Update the inventory item labels to reflect the fact // they are active. @@ -5172,7 +5172,7 @@ void remove_inventory_category_from_avatar_step2( BOOL proceed, void* userdata) LLViewerInventoryItem *gest_item = gest_item_array.get(i); if (get_is_item_worn(gest_item->getUUID())) { - gGestureManager.deactivateGesture( gest_item_array.get(i)->getLinkedUUID() ); + LLGestureMgr::instance().deactivateGesture( gest_item_array.get(i)->getLinkedUUID() ); gInventory.updateItem( gest_item ); gInventory.notifyObservers(); } @@ -5262,7 +5262,7 @@ void LLWearableBridge::openItem() { if( isItemInTrash() ) { - LLNotifications::instance().add("CannotWearTrash"); + LLNotificationsUtil::add("CannotWearTrash"); } else if(isAgentInventory()) { @@ -5295,7 +5295,7 @@ void LLWearableBridge::openItem() { // *TODO: We should fetch the item details, and then do // the operation above. - LLNotifications::instance().add("CannotWearInfoNotComplete"); + LLNotificationsUtil::add("CannotWearInfoNotComplete"); } } } @@ -5419,7 +5419,7 @@ void LLWearableBridge::wearOnAvatar() // destroy clothing items. if (!gAgentWearables.areWearablesLoaded()) { - LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded"); + LLNotificationsUtil::add("CanNotChangeAppearanceUntilLoaded"); return; } diff --git a/indra/newview/llinventoryview.cpp b/indra/newview/llinventoryview.cpp index 69fbc19cd..6b50d56ed 100644 --- a/indra/newview/llinventoryview.cpp +++ b/indra/newview/llinventoryview.cpp @@ -36,6 +36,7 @@ #include "llinventoryview.h" #include "llinventorybridge.h" +#include "llinventorydefines.h" #include "message.h" diff --git a/indra/newview/lllandmarklist.cpp b/indra/newview/lllandmarklist.cpp index e8cdcdfdd..85a893122 100644 --- a/indra/newview/lllandmarklist.cpp +++ b/indra/newview/lllandmarklist.cpp @@ -38,7 +38,7 @@ #include "llassetstorage.h" #include "llagent.h" -#include "llnotify.h" +#include "llnotificationsutil.h" #include "llvfile.h" #include "llviewerstats.h" @@ -120,11 +120,11 @@ void LLLandmarkList::processGetAssetReply( if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ) { - LLNotifications::instance().add("LandmarkMissing"); + LLNotificationsUtil::add("LandmarkMissing"); } else { - LLNotifications::instance().add("UnableToLoadLandmark"); + LLNotificationsUtil::add("UnableToLoadLandmark"); } gLandmarkList.mBadList.insert(uuid); diff --git a/indra/newview/lllocalinventory.cpp b/indra/newview/lllocalinventory.cpp index 4d61a5c0e..9b1494edf 100644 --- a/indra/newview/lllocalinventory.cpp +++ b/indra/newview/lllocalinventory.cpp @@ -18,6 +18,7 @@ #include "lluictrlfactory.h" #include "llcombobox.h" +#include "llnotificationsutil.h" #include "llagent.h" // gAgent #include "llviewerwindow.h" // alertXml @@ -315,7 +316,7 @@ void LLLocalInventory::loadInvCache(std::string filename) LLSD args; args["ERROR_MESSAGE"] = message.str(); - LLNotifications::instance().add("ErrorMessage", args); + LLNotificationsUtil::add("ErrorMessage", args); } conflicting_cats.clear();// srsly dont think this is need but w/e :D } diff --git a/indra/newview/llmanip.cpp b/indra/newview/llmanip.cpp index f1ef63b67..6e3421f1f 100644 --- a/indra/newview/llmanip.cpp +++ b/indra/newview/llmanip.cpp @@ -70,11 +70,7 @@ S32 LLManip::sMaxTimesShowHelpText = 5; F32 LLManip::sGridMaxSubdivisionLevel = 32.f; F32 LLManip::sGridMinSubdivisionLevel = 1.f; LLVector2 LLManip::sTickLabelSpacing(60.f, 25.f); -bool LLManip::sActualRoot = false;// going to set these up in the main entry -bool LLManip::sPivotPerc = false; -F32 LLManip::sPivotX = 0.f; -F32 LLManip::sPivotY = 0.f; -F32 LLManip::sPivotZ = 0.f; + //static void LLManip::rebuild(LLViewerObject* vobj) @@ -106,53 +102,6 @@ LLManip::LLManip( const std::string& name, LLToolComposite* composite ) mHighlightedPart(LL_NO_PART), mManipPart(LL_NO_PART) { - initPivot(); - - gSavedSettings.getControl("AscentBuildPrefs_ActualRoot")->getSignal()->connect(boost::bind(&updateActualRoot)); - gSavedSettings.getControl("AscentBuildPrefs_PivotIsPercent")->getSignal()->connect(boost::bind(&updatePivotIsPercent)); - gSavedSettings.getControl("AscentBuildPrefs_PivotX")->getSignal()->connect(boost::bind(&updatePivotX)); - gSavedSettings.getControl("AscentBuildPrefs_PivotY")->getSignal()->connect(boost::bind(&updatePivotY)); - gSavedSettings.getControl("AscentBuildPrefs_PivotZ")->getSignal()->connect(boost::bind(&updatePivotZ)); -} -//static -void LLManip::initPivot() -{ - sActualRoot = (bool)gSavedSettings.getBOOL("AscentBuildPrefs_ActualRoot"); - sPivotPerc = (bool)gSavedSettings.getBOOL("AscentBuildPrefs_PivotIsPercent"); - sPivotX = gSavedSettings.getF32("AscentBuildPrefs_PivotX"); - sPivotY = gSavedSettings.getF32("AscentBuildPrefs_PivotY"); - sPivotZ = gSavedSettings.getF32("AscentBuildPrefs_PivotZ"); -} -//static -bool LLManip::updateActualRoot() -{ - //sActualRoot = (bool)data.asBoolean(); - sActualRoot = gSavedSettings.getBOOL("AscentBuildPrefs_ActualRoot"); - return true; -} -//static -bool LLManip::updatePivotIsPercent() -{ - sPivotPerc = gSavedSettings.getBOOL("AscentBuildPrefs_PivotIsPercent"); - return true; -} -//static -bool LLManip::updatePivotX() -{ - sPivotX = gSavedSettings.getF32("AscentBuildPrefs_PivotX"); - return true; -} -//static -bool LLManip::updatePivotY() -{ - sPivotY = gSavedSettings.getF32("AscentBuildPrefs_PivotY"); - return true; -} -//static -bool LLManip::updatePivotZ() -{ - sPivotZ = gSavedSettings.getF32("AscentBuildPrefs_PivotZ"); - return true; } void LLManip::getManipNormal(LLViewerObject* object, EManipPart manip, LLVector3 &normal) @@ -317,8 +266,8 @@ BOOL LLManip::getMousePointOnPlaneGlobal(LLVector3d& point, S32 x, S32 y, LLVect if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD) { BOOL result = FALSE; - F32 mouse_x = ((F32)x / gViewerWindow->getWindowWidth() - 0.5f) * LLViewerCamera::getInstance()->getAspect() / gAgentCamera.mHUDCurZoom; - F32 mouse_y = ((F32)y / gViewerWindow->getWindowHeight() - 0.5f) / gAgentCamera.mHUDCurZoom; + F32 mouse_x = ((F32)x / gViewerWindow->getWorldViewWidthScaled() - 0.5f) * LLViewerCamera::getInstance()->getAspect() / gAgentCamera.mHUDCurZoom; + F32 mouse_y = ((F32)y / gViewerWindow->getWorldViewHeightScaled() - 0.5f) / gAgentCamera.mHUDCurZoom; LLVector3 origin_agent = gAgent.getPosAgentFromGlobal(origin); LLVector3 mouse_pos = LLVector3(0.f, -mouse_x, mouse_y); @@ -356,8 +305,8 @@ BOOL LLManip::nearestPointOnLineFromMouse( S32 x, S32 y, const LLVector3& b1, co if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD) { - F32 mouse_x = (((F32)x / gViewerWindow->getWindowWidth()) - 0.5f) * LLViewerCamera::getInstance()->getAspect() / gAgentCamera.mHUDCurZoom; - F32 mouse_y = (((F32)y / gViewerWindow->getWindowHeight()) - 0.5f) / gAgentCamera.mHUDCurZoom; + F32 mouse_x = (((F32)x / gViewerWindow->getWindowWidthScaled()) - 0.5f) * LLViewerCamera::getInstance()->getAspect() / gAgentCamera.mHUDCurZoom; + F32 mouse_y = (((F32)y / gViewerWindow->getWindowHeightScaled()) - 0.5f) / gAgentCamera.mHUDCurZoom; a1 = LLVector3(llmin(b1.mV[VX] - 0.1f, b2.mV[VX] - 0.1f, 0.f), -mouse_x, mouse_y); a2 = a1 + LLVector3(1.f, 0.f, 0.f); } @@ -404,43 +353,22 @@ LLVector3 LLManip::getSavedPivotPoint() const LLVector3 LLManip::getPivotPoint() { - LLVector3 pos; - LLVector3 scale; - LLQuaternion rot;// = mObjectSelection->getFirstObject()->getRotation(); - if (mObjectSelection->getFirstRootObject(TRUE) && (mObjectSelection->getObjectCount() == 1 || sActualRoot) && mObjectSelection->getSelectType() != SELECT_TYPE_HUD) + static LLCachedControl actual_root("AscentBuildPrefs_ActualRoot"); + static LLCachedControl pivot_as_percent("AscentBuildPrefs_PivotIsPercent"); + static LLCachedControl pivot_x("AscentBuildPrefs_PivotX"); + static LLCachedControl pivot_y("AscentBuildPrefs_PivotY"); + static LLCachedControl pivot_z("AscentBuildPrefs_PivotZ"); + LLVector3 offset(pivot_x,pivot_y,pivot_z); + + if (mObjectSelection->getFirstRootObject(TRUE) && (mObjectSelection->getObjectCount() == 1 || actual_root) && mObjectSelection->getSelectType() != SELECT_TYPE_HUD) { - pos = mObjectSelection->getFirstRootObject(TRUE)->getPivotPositionAgent(); - scale = mObjectSelection->getFirstRootObject(TRUE)->getScale(); - rot = mObjectSelection->getFirstRootObject(TRUE)->getRotation(); - }else - { - pos = LLSelectMgr::getInstance()->getBBoxOfSelection().getCenterAgent(); - scale = LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal(); - rot = LLSelectMgr::getInstance()->getBBoxOfSelection().getRotation(); + if(pivot_as_percent) + offset = ((offset * .01f) - LLVector3(.5f,.5f,.5f)).scaleVec(mObjectSelection->getFirstRootObject(TRUE)->getScale()); + return mObjectSelection->getFirstObject()->getPivotPositionAgent() + offset * mObjectSelection->getFirstRootObject(TRUE)->getRotation(); } - if(sPivotPerc) - { - - LLVector3 add( - (-scale[VX]*0.5) + (scale[VX]*(sPivotX*0.01)), - (-scale[VY]*0.5) + (scale[VY]*(sPivotY*0.01)), - (-scale[VZ]*0.5) + (scale[VZ]*(sPivotZ*0.01))); - add = add * rot; - pos = pos + add; - }else - { - //pos[VX] = pos[VX] + gSavedSettings.getF32("EmeraldBuildPrefs_PivotX"); - //pos[VY] = pos[VY] + gSavedSettings.getF32("EmeraldBuildPrefs_PivotY"); - //pos[VZ] = pos[VZ] + gSavedSettings.getF32("EmeraldBuildPrefs_PivotZ"); - LLVector3 add( - sPivotX, - sPivotY, - sPivotZ); - add = add * rot; - pos = pos + add; - } - //pos = pos * rot; - return pos; + if(pivot_as_percent) + offset = ((offset * .01f) - LLVector3(.5f,.5f,.5f)).scaleVec(LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal()); + return LLSelectMgr::getInstance()->getBBoxOfSelection().getCenterAgent() + offset * LLSelectMgr::getInstance()->getBBoxOfSelection().getRotation(); } @@ -514,17 +442,17 @@ void LLManip::renderXYZ(const LLVector3 &vec) const S32 PAD = 10; std::string feedback_string; LLVector3 camera_pos = LLViewerCamera::getInstance()->getOrigin() + LLViewerCamera::getInstance()->getAtAxis(); - S32 window_center_x = gViewerWindow->getWindowWidth() / 2; - S32 window_center_y = gViewerWindow->getWindowHeight() / 2; - S32 vertical_offset = window_center_y - VERTICAL_OFFSET; + S32 window_center_x = gViewerWindow->getWorldViewRectScaled().getWidth() / 2; + S32 window_center_y = gViewerWindow->getWorldViewRectScaled().getHeight() / 2; + S32 vertical_offset = window_center_y - VERTICAL_OFFSET; - - glPushMatrix(); + + gGL.pushMatrix(); { LLUIImagePtr imagep = LLUI::getUIImage("rounded_square.tga"); gViewerWindow->setup2DRender(); const LLVector2& display_scale = gViewerWindow->getDisplayScale(); - glScalef(display_scale.mV[VX], display_scale.mV[VY], 1.f); + gGL.scalef(display_scale.mV[VX], display_scale.mV[VY], 1.f); gGL.color4f(0.f, 0.f, 0.f, 0.7f); imagep->draw( @@ -534,7 +462,7 @@ void LLManip::renderXYZ(const LLVector3 &vec) PAD * 2 + 10, LLColor4(0.f, 0.f, 0.f, 0.7f) ); } - glPopMatrix(); + gGL.popMatrix(); gViewerWindow->setup3DRender(); @@ -586,9 +514,9 @@ void LLManip::renderTickText(const LLVector3& pos, const std::string& text, cons // render shadow first LLColor4 shadow_color = LLColor4::black; shadow_color.mV[VALPHA] = color.mV[VALPHA] * 0.5f; - gViewerWindow->setupViewport(1, -1); + gViewerWindow->setup3DViewport(1, -1); hud_render_utf8text(text, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(text), 3.f, shadow_color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD); - gViewerWindow->setupViewport(); + gViewerWindow->setup3DViewport(); hud_render_utf8text(text, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(text), 3.f, color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD); glPopMatrix(); @@ -648,19 +576,19 @@ void LLManip::renderTickValue(const LLVector3& pos, F32 value, const std::string { fraction_string = llformat("%c%02d%s", LLResMgr::getInstance()->getDecimalPoint(), fractional_portion, suffix.c_str()); - gViewerWindow->setupViewport(1, -1); + gViewerWindow->setup3DViewport(1, -1); hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -1.f * big_fontp->getWidthF32(val_string), 3.f, shadow_color, hud_selection); hud_render_utf8text(fraction_string, render_pos, *small_fontp, LLFontGL::NORMAL, 1.f, 3.f, shadow_color, hud_selection); - gViewerWindow->setupViewport(); + gViewerWindow->setup3DViewport(); hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -1.f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection); hud_render_utf8text(fraction_string, render_pos, *small_fontp, LLFontGL::NORMAL, 1.f, 3.f, color, hud_selection); } else { - gViewerWindow->setupViewport(1, -1); + gViewerWindow->setup3DViewport(1, -1); hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(val_string), 3.f, shadow_color, hud_selection); - gViewerWindow->setupViewport(); + gViewerWindow->setup3DViewport(); hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection); } glPopMatrix(); @@ -679,14 +607,14 @@ LLColor4 LLManip::setupSnapGuideRenderPass(S32 pass) { case 0: // shadow - gViewerWindow->setupViewport(1, -1); + gViewerWindow->setup3DViewport(1, -1); line_color = grid_color_shadow; line_color.mV[VALPHA] *= line_alpha; LLUI::setLineWidth(2.f); break; case 1: // hidden lines - gViewerWindow->setupViewport(); + gViewerWindow->setup3DViewport(); line_color = grid_color_bg; line_color.mV[VALPHA] *= line_alpha; LLUI::setLineWidth(1.f); diff --git a/indra/newview/llmanip.h b/indra/newview/llmanip.h index 9577412ed..cdf6a3657 100644 --- a/indra/newview/llmanip.h +++ b/indra/newview/llmanip.h @@ -151,13 +151,6 @@ protected: BOOL getMousePointOnPlaneAgent(LLVector3& point, S32 x, S32 y, LLVector3 origin, LLVector3 normal); BOOL nearestPointOnLineFromMouse( S32 x, S32 y, const LLVector3& b1, const LLVector3& b2, F32 &a_param, F32 &b_param ); LLColor4 setupSnapGuideRenderPass(S32 pass); -private: - static void initPivot(); - static bool updateActualRoot(); - static bool updatePivotIsPercent(); - static bool updatePivotX(); - static bool updatePivotY(); - static bool updatePivotZ(); protected: LLFrameTimer mHelpTextTimer; BOOL mInSnapRegime; @@ -172,11 +165,6 @@ protected: static F32 sGridMaxSubdivisionLevel; static F32 sGridMinSubdivisionLevel; static LLVector2 sTickLabelSpacing; - static bool sActualRoot; - static bool sPivotPerc; - static F32 sPivotX; - static F32 sPivotY; - static F32 sPivotZ; }; diff --git a/indra/newview/llmaniprotate.cpp b/indra/newview/llmaniprotate.cpp index 8db7d7cb6..90d17bed6 100644 --- a/indra/newview/llmaniprotate.cpp +++ b/indra/newview/llmaniprotate.cpp @@ -1108,8 +1108,11 @@ BOOL LLManipRotate::updateVisiblity() mCenterToProfilePlaneMag = mRadiusMeters * mRadiusMeters / mCenterToCamMag; mCenterToProfilePlane = -mCenterToProfilePlaneMag * mCenterToCamNorm; - mCenterScreen.set((S32)((0.5f - mRotationCenter.mdV[VY]) / gAgentCamera.mHUDCurZoom * gViewerWindow->getWindowWidth()), - (S32)((mRotationCenter.mdV[VZ] + 0.5f) / gAgentCamera.mHUDCurZoom * gViewerWindow->getWindowHeight())); + // x axis range is (-aspect * 0.5f, +aspect * 0.5) + // y axis range is (-0.5, 0.5) + // so use getWorldViewHeightRaw as scale factor when converting to pixel coordinates + mCenterScreen.set((S32)((0.5f - center.mV[VY]) / gAgentCamera.mHUDCurZoom * gViewerWindow->getWorldViewHeightScaled()), + (S32)((center.mV[VZ] + 0.5f) / gAgentCamera.mHUDCurZoom * gViewerWindow->getWorldViewHeightScaled())); visible = TRUE; } else @@ -1129,7 +1132,7 @@ BOOL LLManipRotate::updateVisiblity() if (gSavedSettings.getBOOL("LimitSelectDistance")) { F32 max_select_distance = gSavedSettings.getF32("MaxSelectDistance"); - if (dist_vec(gAgent.getPositionAgent(), center) > max_select_distance) + if (dist_vec_squared(gAgent.getPositionAgent(), center) > (max_select_distance * max_select_distance)) { visible = FALSE; } @@ -1625,8 +1628,8 @@ void LLManipRotate::mouseToRay( S32 x, S32 y, LLVector3* ray_pt, LLVector3* ray_ { if (LLSelectMgr::getInstance()->getSelection()->getSelectType() == SELECT_TYPE_HUD) { - F32 mouse_x = (((F32)x / gViewerWindow->getWindowWidth()) - 0.5f) / gAgentCamera.mHUDCurZoom; - F32 mouse_y = ((((F32)y) / gViewerWindow->getWindowHeight()) - 0.5f) / gAgentCamera.mHUDCurZoom; + F32 mouse_x = (((F32)x / gViewerWindow->getWorldViewRectScaled().getWidth()) - 0.5f) / gAgentCamera.mHUDCurZoom; + F32 mouse_y = ((((F32)y) / gViewerWindow->getWorldViewRectScaled().getHeight()) - 0.5f) / gAgentCamera.mHUDCurZoom; *ray_pt = LLVector3(-1.f, -mouse_x, mouse_y); *ray_dir = LLVector3(1.f, 0.f, 0.f); @@ -1700,7 +1703,7 @@ void LLManipRotate::highlightManipulators( S32 x, S32 y ) F32 dist_y = mouse_dir_y.normVec(); F32 dist_z = mouse_dir_z.normVec(); - F32 distance_threshold = (MAX_MANIP_SELECT_DISTANCE * mRadiusMeters) / gViewerWindow->getWindowHeight(); + F32 distance_threshold = (MAX_MANIP_SELECT_DISTANCE * mRadiusMeters) / gViewerWindow->getWorldViewHeightScaled(); if (llabs(dist_x - mRadiusMeters) * llmax(0.05f, proj_rot_x_axis) < distance_threshold) { diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp index 54af78285..3441df1a2 100644 --- a/indra/newview/llmanipscale.cpp +++ b/indra/newview/llmanipscale.cpp @@ -60,6 +60,7 @@ #include "llviewerobject.h" #include "llviewerregion.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llhudrender.h" #include "llworld.h" #include "v2math.h" @@ -516,8 +517,9 @@ void LLManipScale::highlightManipulators(S32 x, S32 y) mProjectedManipulators.insert(projManipulator); } - F32 half_width = (F32)gViewerWindow->getWindowWidth() / 2.f; - F32 half_height = (F32)gViewerWindow->getWindowHeight() / 2.f; + LLRect world_view_rect = gViewerWindow->getWorldViewRectScaled(); + F32 half_width = (F32)world_view_rect.getWidth() / 2.f; + F32 half_height = (F32)world_view_rect.getHeight() / 2.f; LLVector2 manip2d; LLVector2 mousePos((F32)x - half_width, (F32)y - half_height); LLVector2 delta; @@ -1391,7 +1393,7 @@ void LLManipScale::updateSnapGuides(const LLBBox& bbox) else { F32 object_distance = dist_vec(mScaleCenter, LLViewerCamera::getInstance()->getOrigin()); - mSnapRegimeOffset = (SNAP_GUIDE_SCREEN_OFFSET * gViewerWindow->getWindowWidth() * object_distance) / LLViewerCamera::getInstance()->getPixelMeterRatio(); + mSnapRegimeOffset = (SNAP_GUIDE_SCREEN_OFFSET * gViewerWindow->getWorldViewWidthRaw() * object_distance) / LLViewerCamera::getInstance()->getPixelMeterRatio(); } LLVector3 cam_at_axis; F32 snap_guide_length; @@ -1404,7 +1406,7 @@ void LLManipScale::updateSnapGuides(const LLBBox& bbox) { cam_at_axis = LLViewerCamera::getInstance()->getAtAxis(); F32 manipulator_distance = dist_vec(box_corner_agent, LLViewerCamera::getInstance()->getOrigin()); - snap_guide_length = (SNAP_GUIDE_SCREEN_LENGTH * gViewerWindow->getWindowWidth() * manipulator_distance) / LLViewerCamera::getInstance()->getPixelMeterRatio(); + snap_guide_length = (SNAP_GUIDE_SCREEN_LENGTH * gViewerWindow->getWorldViewWidthRaw() * manipulator_distance) / LLViewerCamera::getInstance()->getPixelMeterRatio(); } mSnapGuideLength = snap_guide_length / llmax(0.1f, (llmin(mSnapGuideDir1 * cam_at_axis, mSnapGuideDir2 * cam_at_axis))); diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp index ed88881f8..81f2ea618 100644 --- a/indra/newview/llmaniptranslate.cpp +++ b/indra/newview/llmaniptranslate.cpp @@ -106,6 +106,16 @@ const U32 ARROW_TO_AXIS[4] = VZ }; +// Sort manipulator handles by their screen-space projection +struct ClosestToCamera +{ + bool operator()(const LLManipTranslate::ManipulatorHandle& a, + const LLManipTranslate::ManipulatorHandle& b) const + { + return a.mEndPosition.mV[VZ] < b.mEndPosition.mV[VZ]; + } +}; + LLManipTranslate::LLManipTranslate( LLToolComposite* composite ) : LLManip( std::string("Move"), composite ), mLastHoverMouseX(-1), @@ -118,9 +128,13 @@ LLManipTranslate::LLManipTranslate( LLToolComposite* composite ) mAxisArrowLength(50), mConeSize(0), mArrowLengthMeters(0.f), + mGridSizeMeters(1.f), mPlaneManipOffsetMeters(0.f), mUpdateTimer(), mSnapOffsetMeters(0.f), + mSubdivisions(10.f), + mInSnapRegime(FALSE), + mSnapped(FALSE), mArrowScales(1.f, 1.f, 1.f), mPlaneScales(1.f, 1.f, 1.f), mPlaneManipPositions(1.f, 1.f, 1.f, 1.f) @@ -278,7 +292,6 @@ void LLManipTranslate::restoreGL() LLManipTranslate::~LLManipTranslate() { - for_each(mProjectedManipulators.begin(), mProjectedManipulators.end(), DeletePointer()); } @@ -418,8 +431,9 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask) } // Handle auto-rotation if necessary. + LLRect world_rect = gViewerWindow->getWorldViewRectScaled(); const F32 ROTATE_ANGLE_PER_SECOND = 30.f * DEG_TO_RAD; - const S32 ROTATE_H_MARGIN = gViewerWindow->getWindowWidth() / 20; + const S32 ROTATE_H_MARGIN = world_rect.getWidth() / 20; const F32 rotate_angle = ROTATE_ANGLE_PER_SECOND / gFPSClamped; BOOL rotated = FALSE; @@ -431,7 +445,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask) gAgentCamera.cameraOrbitAround(rotate_angle); rotated = TRUE; } - else if (x > gViewerWindow->getWindowWidth() - ROTATE_H_MARGIN) + else if (x > world_rect.getWidth() - ROTATE_H_MARGIN) { gAgentCamera.cameraOrbitAround(-rotate_angle); rotated = TRUE; @@ -729,7 +743,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask) LLVector3d new_position_global = selectNode->mSavedPositionGlobal + clamped_relative_move; // Don't let object centers go too far underground - F64 min_height = LLWorld::getInstance()->getMinAllowedZ(object); + F64 min_height = LLWorld::getInstance()->getMinAllowedZ(object, object->getPositionGlobal()); if (new_position_global.mdV[VZ] < min_height) { new_position_global.mdV[VZ] = min_height; @@ -899,8 +913,9 @@ void LLManipTranslate::highlightManipulators(S32 x, S32 y) planar_manip_xy_visible = TRUE; } - for_each(mProjectedManipulators.begin(), mProjectedManipulators.end(), DeletePointer()); - mProjectedManipulators.clear(); + // Project up to 9 manipulators to screen space 2*X, 2*Y, 2*Z, 3*planes + std::vector projected_manipulators; + projected_manipulators.reserve(9); for (S32 i = 0; i < num_arrow_manips; i+= 2) { @@ -910,12 +925,12 @@ void LLManipTranslate::highlightManipulators(S32 x, S32 y) LLVector4 projected_end = mManipulatorVertices[i + 1] * transform; projected_end = projected_end * (1.f / projected_end.mV[VW]); - ManipulatorHandle* projManipulator = - new ManipulatorHandle(LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]), + ManipulatorHandle projected_manip( + LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]), LLVector3(projected_end.mV[VX], projected_end.mV[VY], projected_end.mV[VZ]), MANIPULATOR_IDS[i / 2], 10.f); // 10 pixel hotspot for arrows - mProjectedManipulators.insert(projManipulator); + projected_manipulators.push_back(projected_manip); } if (planar_manip_yz_visible) @@ -927,12 +942,12 @@ void LLManipTranslate::highlightManipulators(S32 x, S32 y) LLVector4 projected_end = mManipulatorVertices[i + 1] * transform; projected_end = projected_end * (1.f / projected_end.mV[VW]); - ManipulatorHandle* projManipulator = - new ManipulatorHandle(LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]), + ManipulatorHandle projected_manip( + LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]), LLVector3(projected_end.mV[VX], projected_end.mV[VY], projected_end.mV[VZ]), MANIPULATOR_IDS[i / 2], 20.f); // 20 pixels for planar manipulators - mProjectedManipulators.insert(projManipulator); + projected_manipulators.push_back(projected_manip); } if (planar_manip_xz_visible) @@ -944,12 +959,12 @@ void LLManipTranslate::highlightManipulators(S32 x, S32 y) LLVector4 projected_end = mManipulatorVertices[i + 1] * transform; projected_end = projected_end * (1.f / projected_end.mV[VW]); - ManipulatorHandle* projManipulator = - new ManipulatorHandle(LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]), + ManipulatorHandle projected_manip( + LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]), LLVector3(projected_end.mV[VX], projected_end.mV[VY], projected_end.mV[VZ]), MANIPULATOR_IDS[i / 2], 20.f); // 20 pixels for planar manipulators - mProjectedManipulators.insert(projManipulator); + projected_manipulators.push_back(projected_manip); } if (planar_manip_xy_visible) @@ -961,29 +976,35 @@ void LLManipTranslate::highlightManipulators(S32 x, S32 y) LLVector4 projected_end = mManipulatorVertices[i + 1] * transform; projected_end = projected_end * (1.f / projected_end.mV[VW]); - ManipulatorHandle* projManipulator = - new ManipulatorHandle(LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]), + ManipulatorHandle projected_manip( + LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]), LLVector3(projected_end.mV[VX], projected_end.mV[VY], projected_end.mV[VZ]), MANIPULATOR_IDS[i / 2], 20.f); // 20 pixels for planar manipulators - mProjectedManipulators.insert(projManipulator); + projected_manipulators.push_back(projected_manip); } LLVector2 manip_start_2d; LLVector2 manip_end_2d; LLVector2 manip_dir; - F32 half_width = gViewerWindow->getWindowWidth() / 2.f; - F32 half_height = gViewerWindow->getWindowHeight() / 2.f; + LLRect world_view_rect = gViewerWindow->getWorldViewRectScaled(); + F32 half_width = (F32)world_view_rect.getWidth() / 2.f; + F32 half_height = (F32)world_view_rect.getHeight() / 2.f; LLVector2 mousePos((F32)x - half_width, (F32)y - half_height); LLVector2 mouse_delta; - for (minpulator_list_t::iterator iter = mProjectedManipulators.begin(); - iter != mProjectedManipulators.end(); ++iter) + // Keep order consistent with insertion via stable_sort + std::stable_sort( projected_manipulators.begin(), + projected_manipulators.end(), + ClosestToCamera() ); + + std::vector::iterator it = projected_manipulators.begin(); + for ( ; it != projected_manipulators.end(); ++it) { - ManipulatorHandle* manipulator = *iter; + ManipulatorHandle& manipulator = *it; { - manip_start_2d.setVec(manipulator->mStartPosition.mV[VX] * half_width, manipulator->mStartPosition.mV[VY] * half_height); - manip_end_2d.setVec(manipulator->mEndPosition.mV[VX] * half_width, manipulator->mEndPosition.mV[VY] * half_height); + manip_start_2d.setVec(manipulator.mStartPosition.mV[VX] * half_width, manipulator.mStartPosition.mV[VY] * half_height); + manip_end_2d.setVec(manipulator.mEndPosition.mV[VX] * half_width, manipulator.mEndPosition.mV[VY] * half_height); manip_dir = manip_end_2d - manip_start_2d; mouse_delta = mousePos - manip_start_2d; @@ -995,9 +1016,9 @@ void LLManipTranslate::highlightManipulators(S32 x, S32 y) if (mouse_pos_manip > 0.f && mouse_pos_manip < manip_length && - mouse_dist_manip_squared < manipulator->mHotSpotRadius * manipulator->mHotSpotRadius) + mouse_dist_manip_squared < manipulator.mHotSpotRadius * manipulator.mHotSpotRadius) { - mHighlightedPart = manipulator->mManipID; + mHighlightedPart = manipulator.mManipID; break; } } @@ -1238,7 +1259,7 @@ void LLManipTranslate::renderSnapGuides() { LLVector3 cam_to_selection = getPivotPoint() - LLViewerCamera::getInstance()->getOrigin(); F32 current_range = cam_to_selection.normVec(); - guide_size_meters = SNAP_GUIDE_SCREEN_SIZE * gViewerWindow->getWindowHeight() * current_range / LLViewerCamera::getInstance()->getPixelMeterRatio(); + guide_size_meters = SNAP_GUIDE_SCREEN_SIZE * gViewerWindow->getWorldViewHeightRaw() * current_range / LLViewerCamera::getInstance()->getPixelMeterRatio(); F32 fraction_of_fov = mAxisArrowLength / (F32) LLViewerCamera::getInstance()->getViewHeightInPixels(); F32 apparent_angle = fraction_of_fov * LLViewerCamera::getInstance()->getView(); // radians @@ -1813,7 +1834,7 @@ void LLManipTranslate::renderTranslationHandles() // Drag handles if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD) { - mArrowLengthMeters = mAxisArrowLength / gViewerWindow->getWindowHeight(); + mArrowLengthMeters = mAxisArrowLength / gViewerWindow->getWorldViewHeightRaw(); mArrowLengthMeters /= gAgentCamera.mHUDCurZoom; } else diff --git a/indra/newview/llmaniptranslate.h b/indra/newview/llmaniptranslate.h index 25ff35cc7..d20b86b2f 100644 --- a/indra/newview/llmaniptranslate.h +++ b/indra/newview/llmaniptranslate.h @@ -89,17 +89,6 @@ protected: F32 getMinGridScale(); private: - struct compare_manipulators - { - bool operator() (const ManipulatorHandle* const a, const ManipulatorHandle* const b) const - { - if (a->mEndPosition.mV[VZ] != b->mEndPosition.mV[VZ]) - return (a->mEndPosition.mV[VZ] < b->mEndPosition.mV[VZ]); - else - return a->mManipID < b->mManipID; - } - }; - S32 mLastHoverMouseX; S32 mLastHoverMouseY; BOOL mSendUpdateOnMouseUp; @@ -116,8 +105,6 @@ private: LLVector3d mDragCursorStartGlobal; LLVector3d mDragSelectionStartGlobal; LLTimer mUpdateTimer; - typedef std::set minpulator_list_t; - minpulator_list_t mProjectedManipulators; LLVector4 mManipulatorVertices[18]; F32 mSnapOffsetMeters; LLVector3 mSnapOffsetAxis; diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp index ded15470e..842ab3b97 100644 --- a/indra/newview/llmediactrl.cpp +++ b/indra/newview/llmediactrl.cpp @@ -45,7 +45,7 @@ #include "llviewercontrol.h" #include "llviewermedia.h" #include "llviewerwindow.h" -#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llweb.h" #include "llrender.h" #include "llpluginclassmedia.h" @@ -1042,7 +1042,7 @@ void LLMediaCtrl::onClickLinkNoFollow( LLPluginClassMedia* self ) && !mTrusted) { // block handling of this secondlife:///app/ URL - LLNotifications::instance().add("UnableToOpenCommandURL"); + LLNotificationsUtil::add("UnableToOpenCommandURL"); return; } diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 1185fea01..bacde05f2 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -45,7 +45,7 @@ #include "lleconomy.h" #include "llimagej2c.h" #include "llhost.h" -#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llsd.h" #include "llsdutil_math.h" #include "llsdserialize.h" @@ -1472,8 +1472,8 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures) if (model_name.empty()) model_name = "mesh model"; result["name"] = model_name; - if (model_metric.empty()) model_metric = "MUT_Other"; - result["metric"] = model_metric; + if (model_metric.empty()) model_metric = "MUT_Unspecified"; + res["metric"] = model_metric; result["asset_resources"] = res; dump_llsd_to_file(result,make_dump_name("whole_model_",dump_num)); @@ -1718,6 +1718,7 @@ void LLMeshRepository::cacheOutgoingMesh(LLMeshUploadData& data, LLSD& header) { LLPointer volume = new LLVolume(volume_params, LLVolumeLODGroup::getVolumeScaleFromDetail(i)); volume->copyVolumeFaces(data.mModel[i]); + volume->setMeshAssetLoaded(TRUE); } } @@ -2184,11 +2185,6 @@ S32 LLMeshRepository::loadMesh(LLVOVolume* vobj, const LLVolumeParams& mesh_para if (volume) { - if (volume->getNumVolumeFaces() == 0 && !volume->isTetrahedron()) - { - volume->makeTetrahedron(); - } - LLVolumeParams params = volume->getParams(); LLVolumeLODGroup* group = LLPrimitive::getVolumeManager()->getGroup(params); @@ -2199,7 +2195,7 @@ S32 LLMeshRepository::loadMesh(LLVOVolume* vobj, const LLVolumeParams& mesh_para if (last_lod >= 0) { LLVolume* lod = group->refLOD(last_lod); - if (lod && !lod->isTetrahedron() && lod->getNumVolumeFaces() > 0) + if (lod && lod->isMeshAssetLoaded() && lod->getNumVolumeFaces() > 0) { group->derefLOD(lod); return last_lod; @@ -2211,7 +2207,7 @@ S32 LLMeshRepository::loadMesh(LLVOVolume* vobj, const LLVolumeParams& mesh_para for (S32 i = detail-1; i >= 0; --i) { LLVolume* lod = group->refLOD(i); - if (lod && !lod->isTetrahedron() && lod->getNumVolumeFaces() > 0) + if (lod && lod->isMeshAssetLoaded() && lod->getNumVolumeFaces() > 0) { group->derefLOD(lod); return i; @@ -2224,7 +2220,7 @@ S32 LLMeshRepository::loadMesh(LLVOVolume* vobj, const LLVolumeParams& mesh_para for (S32 i = detail+1; i < 4; ++i) { LLVolume* lod = group->refLOD(i); - if (lod && !lod->isTetrahedron() && lod->getNumVolumeFaces() > 0) + if (lod && lod->isMeshAssetLoaded() && lod->getNumVolumeFaces() > 0) { group->derefLOD(lod); return i; @@ -2359,7 +2355,7 @@ void LLMeshRepository::notifyLoadedMeshes() //popup queued error messages from background threads while (!mUploadErrorQ.empty()) { - LLNotifications::instance().add("MeshUploadError", mUploadErrorQ.front()); + LLNotificationsUtil::add("MeshUploadError", mUploadErrorQ.front()); mUploadErrorQ.pop(); } @@ -2493,7 +2489,6 @@ void LLMeshRepository::notifyMeshLoaded(const LLVolumeParams& mesh_params, LLVol if (volume->getNumVolumeFaces() <= 0) { llwarns << "Mesh loading returned empty volume." << llendl; - volume->makeTetrahedron(); } { //update system volume @@ -2501,6 +2496,7 @@ void LLMeshRepository::notifyMeshLoaded(const LLVolumeParams& mesh_params, LLVol if (sys_volume) { sys_volume->copyVolumeFaces(volume); + sys_volume->setMeshAssetLoaded(TRUE); LLPrimitive::getVolumeManager()->unrefVolume(sys_volume); } else @@ -2557,7 +2553,7 @@ S32 LLMeshRepository::getActualMeshLOD(const LLVolumeParams& mesh_params, S32 lo return mThread->getActualMeshLOD(mesh_params, lod); } -const LLMeshSkinInfo* LLMeshRepository::getSkinInfo(const LLUUID& mesh_id, LLVOVolume* requesting_obj) +const LLMeshSkinInfo* LLMeshRepository::getSkinInfo(const LLUUID& mesh_id, const LLVOVolume* requesting_obj) { if (mesh_id.notNull()) { @@ -2818,7 +2814,7 @@ void LLMeshRepository::uploadError(LLSD& args) } //static -F32 LLMeshRepository::getStreamingCost(LLSD& header, F32 radius, S32* bytes, S32* bytes_visible, S32 lod) +F32 LLMeshRepository::getStreamingCost(LLSD& header, F32 radius, S32* bytes, S32* bytes_visible, S32 lod, F32 *unscaled_value) { F32 max_distance = 512.f; @@ -2826,10 +2822,15 @@ F32 LLMeshRepository::getStreamingCost(LLSD& header, F32 radius, S32* bytes, S32 F32 dlow = llmin(radius/0.06f, max_distance); F32 dmid = llmin(radius/0.24f, max_distance); - F32 METADATA_DISCOUNT = (F32) gSavedSettings.getU32("MeshMetaDataDiscount"); //discount 128 bytes to cover the cost of LLSD tags and compression domain overhead - F32 MINIMUM_SIZE = (F32) gSavedSettings.getU32("MeshMinimumByteSize"); //make sure nothing is "free" + static const LLCachedControl mesh_meta_data_discount("MeshMetaDataDiscount"); + static const LLCachedControl mesh_minimum_byte_size("MeshMinimumByteSize"); + static const LLCachedControl mesh_bytes_per_triangle("MeshBytesPerTriangle"); + static const LLCachedControl mesh_triangle_budget("MeshTriangleBudget"); - F32 bytes_per_triangle = (F32) gSavedSettings.getU32("MeshBytesPerTriangle"); + F32 METADATA_DISCOUNT = (F32) mesh_meta_data_discount.get(); //discount 128 bytes to cover the cost of LLSD tags and compression domain overhead + F32 MINIMUM_SIZE = (F32) mesh_minimum_byte_size.get(); //make sure nothing is "free" + + F32 bytes_per_triangle = (F32) mesh_bytes_per_triangle.get(); S32 bytes_lowest = header["lowest_lod"]["size"].asInteger(); S32 bytes_low = header["low_lod"]["size"].asInteger(); @@ -2907,7 +2908,12 @@ F32 LLMeshRepository::getStreamingCost(LLSD& header, F32 radius, S32* bytes, S32 triangles_low*low_area + triangles_lowest*lowest_area; - return weighted_avg/gSavedSettings.getU32("MeshTriangleBudget")*15000.f; + if (unscaled_value) + { + *unscaled_value = weighted_avg; + } + + return weighted_avg/mesh_triangle_budget*15000.f; } @@ -3209,32 +3215,33 @@ void LLPhysicsDecomp::doDecompositionSingleHull() llwarns << "Could not execute decomposition stage when attempting to create single hull." << llendl; make_box(mCurRequest); } - - mMutex->lock(); - mCurRequest->mHull.clear(); - mCurRequest->mHull.resize(1); - mCurRequest->mHullMesh.clear(); - mMutex->unlock(); - - std::vector p; - LLCDHull hull; - - // if LLConvexDecomposition is a stub, num_hulls should have been set to 0 above, and we should not reach this code - decomp->getSingleHull(&hull); - - const F32* v = hull.mVertexBase; - - for (S32 j = 0; j < hull.mNumVertices; ++j) + else { - LLVector3 vert(v[0], v[1], v[2]); - p.push_back(vert); - v = (F32*) (((U8*) v) + hull.mVertexStrideBytes); - } + mMutex->lock(); + mCurRequest->mHull.clear(); + mCurRequest->mHull.resize(1); + mCurRequest->mHullMesh.clear(); + mMutex->unlock(); + + std::vector p; + LLCDHull hull; + + // if LLConvexDecomposition is a stub, num_hulls should have been set to 0 above, and we should not reach this code + decomp->getSingleHull(&hull); + + const F32* v = hull.mVertexBase; + + for (S32 j = 0; j < hull.mNumVertices; ++j) + { + LLVector3 vert(v[0], v[1], v[2]); + p.push_back(vert); + v = (F32*) (((U8*) v) + hull.mVertexStrideBytes); + } - mMutex->lock(); - mCurRequest->mHull[0] = p; - mMutex->unlock(); - + mMutex->lock(); + mCurRequest->mHull[0] = p; + mMutex->unlock(); + } #else setMeshData(mesh, false); diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index 80511a1d8..e23a5981e 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -474,7 +474,7 @@ public: static U32 sCacheBytesWritten; static U32 sPeakKbps; - static F32 getStreamingCost(LLSD& header, F32 radius, S32* bytes = NULL, S32* visible_bytes = NULL, S32 detail = -1); + static F32 getStreamingCost(LLSD& header, F32 radius, S32* bytes = NULL, S32* visible_bytes = NULL, S32 detail = -1, F32 *unscaled_value = NULL); LLMeshRepository(); @@ -493,7 +493,7 @@ public: S32 getActualMeshLOD(const LLVolumeParams& mesh_params, S32 lod); static S32 getActualMeshLOD(LLSD& header, S32 lod); - const LLMeshSkinInfo* getSkinInfo(const LLUUID& mesh_id, LLVOVolume* requesting_obj); + const LLMeshSkinInfo* getSkinInfo(const LLUUID& mesh_id, const LLVOVolume* requesting_obj); LLModel::Decomposition* getDecomposition(const LLUUID& mesh_id); void fetchPhysicsShape(const LLUUID& mesh_id); bool hasPhysicsShape(const LLUUID& mesh_id); diff --git a/indra/newview/llmutelist.cpp b/indra/newview/llmutelist.cpp index a140c7421..752e9be35 100644 --- a/indra/newview/llmutelist.cpp +++ b/indra/newview/llmutelist.cpp @@ -67,7 +67,7 @@ #include "llfloaterchat.h" #include "llimpanel.h" #include "llimview.h" -#include "llnotifications.h" +#include "llnotificationsutil.h" #include "lluistring.h" #include "llviewerobject.h" #include "llviewerobjectlist.h" @@ -302,7 +302,7 @@ BOOL LLMuteList::add(const LLMute& mute, U32 flags) if ((mute.mType == LLMute::AGENT) && isLinden(mute.mName) && (flags & LLMute::flagTextChat || flags == 0)) { - LLNotifications::instance().add("MuteLinden"); + LLNotificationsUtil::add("MuteLinden"); return FALSE; } diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 614d6d39c..02964a038 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -638,33 +638,22 @@ BOOL LLNetMap::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rec } else { -#ifdef LL_RRINTERFACE_H //MK - if (gRRenabled && gAgent.mRRInterface.mContainsShownames) + if (LLAvatarNameCache::useDisplayNames()) { - fullname = gAgent.mRRInterface.getDummyName(fullname); - } - else - { -#endif //mk - if (LLAvatarNameCache::useDisplayNames()) - { - LLAvatarName avatar_name; - if (LLAvatarNameCache::get(mClosestAgentToCursor, &avatar_name)) - { - static const LLCachedControl phoenix_name_system("PhoenixNameSystem", 0); - if (phoenix_name_system == 2 || (phoenix_name_system == 1 && avatar_name.mIsDisplayNameDefault)) - { - fullname = avatar_name.mDisplayName; - } - else - { - fullname = avatar_name.getCompleteName(true); - } - } - } -#ifdef LL_RRINTERFACE_H //MK - } -#endif //mk + LLAvatarName avatar_name; + if (LLAvatarNameCache::get(mClosestAgentToCursor, &avatar_name)) + { + static const LLCachedControl phoenix_name_system("PhoenixNameSystem", 0); + if (phoenix_name_system == 2 || (phoenix_name_system == 1 && avatar_name.mIsDisplayNameDefault)) + { + fullname = avatar_name.mDisplayName; + } + else + { + fullname = avatar_name.getCompleteName(true); + } + } + } msg.append(fullname); } // [/Ansariel: Display name support] diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp index db52949c7..d2b3c76cc 100644 --- a/indra/newview/llpanelavatar.cpp +++ b/indra/newview/llpanelavatar.cpp @@ -61,6 +61,7 @@ #include "lllineeditor.h" #include "llnameeditor.h" #include "llmutelist.h" +#include "llnotificationsutil.h" #include "llpanelclassified.h" #include "llpanelpick.h" #include "llpreviewtexture.h" @@ -380,13 +381,13 @@ void LLPanelAvatarSecondLife::onDoubleClickGroup(void* data) // static void LLPanelAvatarSecondLife::onClickPublishHelp(void *) { - LLNotifications::instance().add("ClickPublishHelpAvatar"); + LLNotificationsUtil::add("ClickPublishHelpAvatar"); } // static void LLPanelAvatarSecondLife::onClickPartnerHelp(void *) { - LLNotifications::instance().add("ClickPartnerHelpAvatar", LLSD(), LLSD(), onClickPartnerHelpLoadURL); + LLNotificationsUtil::add("ClickPartnerHelpAvatar", LLSD(), LLSD(), onClickPartnerHelpLoadURL); } // static @@ -646,7 +647,7 @@ void LLPanelAvatarWeb::onCommitURL(LLUICtrl* ctrl, void* data) // static void LLPanelAvatarWeb::onClickWebProfileHelp(void *) { - LLNotifications::instance().add("ClickWebProfileHelpAvatar"); + LLNotificationsUtil::add("ClickWebProfileHelpAvatar"); } void LLPanelAvatarWeb::load(std::string url) @@ -1006,7 +1007,7 @@ void LLPanelAvatarClassified::onClickNew(void* data) // [/RLVa:KB] LLPanelAvatarClassified* self = (LLPanelAvatarClassified*)data; - LLNotifications::instance().add("AddClassified", LLSD(), LLSD(), boost::bind(&LLPanelAvatarClassified::callbackNew, self, _1, _2)); + LLNotificationsUtil::add("AddClassified", LLSD(), LLSD(), boost::bind(&LLPanelAvatarClassified::callbackNew, self, _1, _2)); } @@ -1043,7 +1044,7 @@ void LLPanelAvatarClassified::onClickDelete(void* data) LLSD args; args["NAME"] = panel_classified->getClassifiedName(); - LLNotifications::instance().add("DeleteClassified", args, LLSD(), boost::bind(&LLPanelAvatarClassified::callbackDelete, self, _1, _2)); + LLNotificationsUtil::add("DeleteClassified", args, LLSD(), boost::bind(&LLPanelAvatarClassified::callbackDelete, self, _1, _2)); } @@ -1258,7 +1259,7 @@ void LLPanelAvatarPicks::onClickDelete(void* data) LLSD args; args["PICK"] = panel_pick->getPickName(); - LLNotifications::instance().add("DeleteAvatarPick", args, LLSD(), + LLNotificationsUtil::add("DeleteAvatarPick", args, LLSD(), boost::bind(&LLPanelAvatarPicks::callbackDelete, self, _1, _2)); } @@ -2471,7 +2472,7 @@ void LLPanelAvatar::onClickKick(void* userdata) LLSD payload; payload["avatar_id"] = self->mAvatarID; - LLNotifications::instance().add("KickUser", LLSD(), payload, finishKick); + LLNotificationsUtil::add("KickUser", LLSD(), payload, finishKick); } //static @@ -2502,7 +2503,7 @@ void LLPanelAvatar::onClickFreeze(void* userdata) LLPanelAvatar* self = (LLPanelAvatar*) userdata; LLSD payload; payload["avatar_id"] = self->mAvatarID; - LLNotifications::instance().add("FreezeUser", LLSD(), payload, LLPanelAvatar::finishFreeze); + LLNotificationsUtil::add("FreezeUser", LLSD(), payload, LLPanelAvatar::finishFreeze); } // static @@ -2533,7 +2534,7 @@ void LLPanelAvatar::onClickUnfreeze(void* userdata) LLPanelAvatar* self = (LLPanelAvatar*) userdata; LLSD payload; payload["avatar_id"] = self->mAvatarID; - LLNotifications::instance().add("UnFreezeUser", LLSD(), payload, LLPanelAvatar::finishUnfreeze); + LLNotificationsUtil::add("UnFreezeUser", LLSD(), payload, LLPanelAvatar::finishUnfreeze); } // static diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp index 7f67853fa..45dfb60b9 100644 --- a/indra/newview/llpanelclassified.cpp +++ b/indra/newview/llpanelclassified.cpp @@ -40,6 +40,8 @@ #include "lldir.h" #include "lldispatcher.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llparcel.h" #include "message.h" @@ -327,12 +329,12 @@ BOOL LLPanelClassified::titleIsValid() const std::string& name = mNameEditor->getText(); if (name.empty()) { - LLNotifications::instance().add("BlankClassifiedName"); + LLNotificationsUtil::add("BlankClassifiedName"); return FALSE; } if (!isalnum(name[0])) { - LLNotifications::instance().add("ClassifiedMustBeAlphanumeric"); + LLNotificationsUtil::add("ClassifiedMustBeAlphanumeric"); return FALSE; } @@ -387,7 +389,7 @@ BOOL LLPanelClassified::canClose() LLSD args; args["NAME"] = mNameEditor->getText(); - LLNotifications::instance().add("ClassifiedSave", args, LLSD(), boost::bind(&LLPanelClassified::saveCallback, this, _1, _2)); + LLNotificationsUtil::add("ClassifiedSave", args, LLSD(), boost::bind(&LLPanelClassified::saveCallback, this, _1, _2)); return FALSE; } @@ -813,7 +815,7 @@ void LLPanelClassified::onClickUpdate(void* data) if(self->mMatureCombo->getCurrentIndex() == DECLINE_TO_STATE) { // Tell user about it - LLNotifications::instance().add("SetClassifiedMature", + LLNotificationsUtil::add("SetClassifiedMature", LLSD(), LLSD(), boost::bind(&LLPanelClassified::confirmMature, self, _1, _2)); @@ -883,7 +885,7 @@ void LLPanelClassified::callbackGotPriceForListing(S32 option, std::string text, args["MIN_PRICE"] = price_text; args["[CURRENCY]"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); - LLNotifications::instance().add("MinClassifiedPrice", args); + LLNotificationsUtil::add("MinClassifiedPrice", args); return; } @@ -894,7 +896,7 @@ void LLPanelClassified::callbackGotPriceForListing(S32 option, std::string text, LLSD args; args["AMOUNT"] = llformat("%d", price_for_listing); args["CURRENCY"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); - LLNotifications::instance().add("PublishClassified", args, LLSD(), + LLNotificationsUtil::add("PublishClassified", args, LLSD(), boost::bind(&LLPanelClassified::confirmPublish, self, _1, _2)); } diff --git a/indra/newview/llpanelcontents.cpp b/indra/newview/llpanelcontents.cpp index 5ab510eed..b35b91b6c 100644 --- a/indra/newview/llpanelcontents.cpp +++ b/indra/newview/llpanelcontents.cpp @@ -45,6 +45,7 @@ #include "llpermissionsflags.h" #include "lleconomy.h" #include "material_codes.h" +#include "llinventorydefines.h" // project includes #include "llui.h" diff --git a/indra/newview/llpaneldirbrowser.cpp b/indra/newview/llpaneldirbrowser.cpp index e2a24c163..35f207ab2 100644 --- a/indra/newview/llpaneldirbrowser.cpp +++ b/indra/newview/llpaneldirbrowser.cpp @@ -56,6 +56,7 @@ #include "lllineeditor.h" #include "llmenucommands.h" #include "llmenugl.h" +#include "llnotificationsutil.h" #include "llpanelavatar.h" #include "llpanelevent.h" #include "llpanelgroup.h" @@ -72,7 +73,6 @@ #include "llviewertexturelist.h" #include "llviewermessage.h" #include "lluictrlfactory.h" -#include "llnotify.h" #include #include @@ -596,7 +596,7 @@ void LLPanelDirBrowser::processDirPlacesReply(LLMessageSystem* msg, void**) msg->getU32("StatusData", "Status", status); if (status & STATUS_SEARCH_PLACES_BANNEDWORD) { - LLNotifications::instance().add("SearchWordBanned"); + LLNotificationsUtil::add("SearchWordBanned"); } } @@ -690,7 +690,7 @@ void LLPanelDirBrowser::processDirEventsReply(LLMessageSystem* msg, void**) msg->getU32("StatusData", "Status", status); if (status & STATUS_SEARCH_EVENTS_BANNEDWORD) { - LLNotifications::instance().add("SearchWordBanned"); + LLNotificationsUtil::add("SearchWordBanned"); } } @@ -926,7 +926,7 @@ void LLPanelDirBrowser::processDirClassifiedReply(LLMessageSystem* msg, void**) msg->getU32("StatusData", "Status", status); if (status & STATUS_SEARCH_CLASSIFIEDS_BANNEDWORD) { - LLNotifications::instance().add("SearchWordBanned"); + LLNotificationsUtil::add("SearchWordBanned"); } } diff --git a/indra/newview/llpaneldirclassified.cpp b/indra/newview/llpaneldirclassified.cpp index 6703ec39e..eaa83aff0 100644 --- a/indra/newview/llpaneldirclassified.cpp +++ b/indra/newview/llpaneldirclassified.cpp @@ -65,7 +65,7 @@ // #include "llfloateravatarinfo.h" #include "llviewermenu.h" -#include "llnotify.h" +#include "llnotificationsutil.h" //----------------------------------------------------------------------------- // Constants @@ -189,7 +189,7 @@ void LLPanelDirClassified::performQuery() BOOL inc_adult = childGetValue("incadult").asBoolean(); if (!(inc_pg || inc_mature || inc_adult)) { - LLNotifications::instance().add("NoContentToSearch"); + LLNotificationsUtil::add("NoContentToSearch"); return; } diff --git a/indra/newview/llpaneldirevents.cpp b/indra/newview/llpaneldirevents.cpp index 54d32a8ce..44bea8693 100644 --- a/indra/newview/llpaneldirevents.cpp +++ b/indra/newview/llpaneldirevents.cpp @@ -50,7 +50,7 @@ #include "lluiconstants.h" #include "llpanelevent.h" #include "llappviewer.h" -#include "llnotify.h" +#include "llnotificationsutil.h" BOOL gDisplayEventHack = FALSE; @@ -190,7 +190,7 @@ void LLPanelDirEvents::performQueryOrDelete(U32 event_id) if ( !( scope & (DFQ_INC_PG | DFQ_INC_MATURE | DFQ_INC_ADULT ))) { - LLNotifications::instance().add("NoContentToSearch"); + LLNotificationsUtil::add("NoContentToSearch"); return; } diff --git a/indra/newview/llpaneldirfind.cpp b/indra/newview/llpaneldirfind.cpp index 398cb2972..f960fbb69 100644 --- a/indra/newview/llpaneldirfind.cpp +++ b/indra/newview/llpaneldirfind.cpp @@ -50,6 +50,7 @@ #include "llviewercontrol.h" #include "llmenucommands.h" #include "llmenugl.h" +#include "llnotificationsutil.h" #include "llpluginclassmedia.h" #include "lltextbox.h" #include "lluiconstants.h" @@ -218,7 +219,7 @@ void LLPanelDirFindAll::search(const std::string& search_text) BOOL inc_adult = childGetValue("incadult").asBoolean(); if (!(inc_pg || inc_mature || inc_adult)) { - LLNotifications::instance().add("NoContentToSearch"); + LLNotificationsUtil::add("NoContentToSearch"); return; } @@ -445,7 +446,7 @@ void LLPanelDirFind::onClickBack( void* data ) // static void LLPanelDirFind::onClickHelp( void* data ) { - LLNotifications::instance().add("ClickSearchHelpAll"); + LLNotificationsUtil::add("ClickSearchHelpAll"); } // static @@ -597,7 +598,7 @@ void LLPanelDirFindAllOld::onClickSearch(void *userdata) BOOL inc_adult = self->childGetValue("incadult").asBoolean(); if (!(inc_pg || inc_mature || inc_adult)) { - LLNotifications::instance().add("NoContentToSearch"); + LLNotificationsUtil::add("NoContentToSearch"); return; } diff --git a/indra/newview/llpaneldirgroups.cpp b/indra/newview/llpaneldirgroups.cpp index 5345304ec..009e68367 100644 --- a/indra/newview/llpaneldirgroups.cpp +++ b/indra/newview/llpaneldirgroups.cpp @@ -41,6 +41,7 @@ #include "llqueryflags.h" #include "llviewercontrol.h" #include "llviewerwindow.h" +#include "llnotificationsutil.h" LLPanelDirGroups::LLPanelDirGroups(const std::string& name, LLFloaterDirectory* floater) : LLPanelDirBrowser(name, floater) @@ -92,7 +93,7 @@ void LLPanelDirGroups::performQuery() // possible we threw away all the short words in the query so check length if ( query_string.length() < mMinSearchChars ) { - LLNotifications::instance().add("SeachFilteredOnShortWordsEmpty"); + LLNotificationsUtil::add("SeachFilteredOnShortWordsEmpty"); return; }; @@ -101,7 +102,7 @@ void LLPanelDirGroups::performQuery() BOOL inc_adult = childGetValue("incadult").asBoolean(); if (!(inc_pg || inc_mature || inc_adult)) { - LLNotifications::instance().add("NoContentToSearch"); + LLNotificationsUtil::add("NoContentToSearch"); return; } @@ -110,7 +111,7 @@ void LLPanelDirGroups::performQuery() { LLSD args; args["[FINALQUERY]"] = query_string; - LLNotifications::instance().add("SeachFilteredOnShortWords", args); + LLNotificationsUtil::add("SeachFilteredOnShortWords", args); }; setupNewSearch(); diff --git a/indra/newview/llpaneldirland.cpp b/indra/newview/llpaneldirland.cpp index 98b65f98f..c1b4c8ce9 100644 --- a/indra/newview/llpaneldirland.cpp +++ b/indra/newview/llpaneldirland.cpp @@ -45,13 +45,13 @@ #include "llcheckboxctrl.h" #include "llcombobox.h" #include "lllineeditor.h" +#include "llnotificationsutil.h" #include "llscrolllistctrl.h" #include "llstatusbar.h" #include "lluiconstants.h" #include "lltextbox.h" #include "llviewercontrol.h" #include "llviewermessage.h" -#include "llnotify.h" #include "hippogridmanager.h" @@ -175,7 +175,7 @@ void LLPanelDirLand::performQuery() BOOL inc_adult = childGetValue("incadult").asBoolean(); if (!(inc_pg || inc_mature || inc_adult)) { - LLNotifications::instance().add("NoContentToSearch"); + LLNotificationsUtil::add("NoContentToSearch"); return; } diff --git a/indra/newview/llpaneldirpeople.cpp b/indra/newview/llpaneldirpeople.cpp index 053cad558..a771db70c 100644 --- a/indra/newview/llpaneldirpeople.cpp +++ b/indra/newview/llpaneldirpeople.cpp @@ -34,6 +34,7 @@ #include "llpaneldirpeople.h" #include "llviewerwindow.h" +#include "llnotificationsutil.h" // linden library includes #include "message.h" @@ -87,7 +88,7 @@ void LLPanelDirPeople::performQuery() // possible we threw away all the short words in the query so check length if ( query_string.length() < mMinSearchChars ) { - LLNotifications::instance().add("SeachFilteredOnShortWordsEmpty"); + LLNotificationsUtil::add("SeachFilteredOnShortWordsEmpty"); return; }; @@ -96,7 +97,7 @@ void LLPanelDirPeople::performQuery() { LLSD args; args["FINALQUERY"] = query_string; - LLNotifications::instance().add("SeachFilteredOnShortWords", args); + LLNotificationsUtil::add("SeachFilteredOnShortWords", args); }; setupNewSearch(); diff --git a/indra/newview/llpaneldirplaces.cpp b/indra/newview/llpaneldirplaces.cpp index 305d2e2ac..96070b4b0 100644 --- a/indra/newview/llpaneldirplaces.cpp +++ b/indra/newview/llpaneldirplaces.cpp @@ -50,6 +50,7 @@ #include "llcombobox.h" #include "llfloaterdirectory.h" #include "lllineeditor.h" +#include "llnotificationsutil.h" #include "llviewerwindow.h" #include "llpaneldirbrowser.h" #include "lltextbox.h" @@ -57,7 +58,6 @@ #include "llviewercontrol.h" #include "llviewermessage.h" #include "llworldmap.h" -#include "llnotify.h" LLPanelDirPlaces::LLPanelDirPlaces(const std::string& name, LLFloaterDirectory* floater) : LLPanelDirBrowser(name, floater) @@ -141,7 +141,7 @@ void LLPanelDirPlaces::performQuery() // possible we threw away all the short words in the query so check length if ( query_string.length() < mMinSearchChars ) { - LLNotifications::instance().add("SeachFilteredOnShortWordsEmpty"); + LLNotificationsUtil::add("SeachFilteredOnShortWordsEmpty"); return; }; @@ -150,7 +150,7 @@ void LLPanelDirPlaces::performQuery() { LLSD args; args["FINALQUERY"] = query_string; - LLNotifications::instance().add("SeachFilteredOnShortWords", args); + LLNotificationsUtil::add("SeachFilteredOnShortWords", args); }; std::string catstring = childGetValue("Category").asString(); @@ -207,7 +207,7 @@ void LLPanelDirPlaces::performQuery() if (0x0 == flags) { - LLNotifications::instance().add("NoContentToSearch"); + LLNotificationsUtil::add("NoContentToSearch"); return; } diff --git a/indra/newview/llpaneldisplay.cpp b/indra/newview/llpaneldisplay.cpp index c7aeabcce..925ca40c7 100644 --- a/indra/newview/llpaneldisplay.cpp +++ b/indra/newview/llpaneldisplay.cpp @@ -120,7 +120,7 @@ BOOL LLPanelDisplay::postBuild() // radio set for fullscreen size mCtrlWindowed = getChild( "windowed mode"); - mCtrlWindowed->setCommitCallback(onCommitWindowedMode); + mCtrlWindowed->setCommitCallback(&LLPanelDisplay::onCommitWindowedMode); mCtrlWindowed->setCallbackUserData(this); mAspectRatioLabel1 = getChild("AspectRatioLabel1"); @@ -215,7 +215,7 @@ BOOL LLPanelDisplay::postBuild() // radio performance box mCtrlSliderQuality = getChild("QualityPerformanceSelection"); - mCtrlSliderQuality->setSliderMouseUpCallback(onChangeQuality); + mCtrlSliderQuality->setSliderMouseUpCallback(boost::bind(&LLPanelDisplay::onChangeQuality,mCtrlSliderQuality,this)); mCtrlSliderQuality->setCallbackUserData(this); mCtrlCustomSettings = getChild("CustomSettings"); diff --git a/indra/newview/llpanelevent.cpp b/indra/newview/llpanelevent.cpp index c8c49a872..0105180a4 100644 --- a/indra/newview/llpanelevent.cpp +++ b/indra/newview/llpanelevent.cpp @@ -45,6 +45,7 @@ #include "llfloater.h" #include "llfloaterworldmap.h" #include "llinventorymodel.h" +#include "llnotificationsutil.h" #include "llsecondlifeurls.h" #include "lltextbox.h" #include "llviewertexteditor.h" @@ -114,25 +115,10 @@ void LLPanelEvent::setEventID(const U32 event_id) if (event_id != 0) { - sendEventInfoRequest(); + gEventNotifier.add(event_id); } } - -void LLPanelEvent::sendEventInfoRequest() -{ - LLMessageSystem *msg = gMessageSystem; - - msg->newMessageFast(_PREHASH_EventInfoRequest); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() ); - msg->nextBlockFast(_PREHASH_EventData); - msg->addU32Fast(_PREHASH_EventID, mEventID); - gAgent.sendReliableMessage(); -} - - //static void LLPanelEvent::processEventInfoReply(LLMessageSystem *msg, void **) { @@ -277,7 +263,7 @@ void LLPanelEvent::onClickLandmark(void* data) // static void LLPanelEvent::onClickCreateEvent(void* data) { - LLNotifications::instance().add("PromptGoToEventsPage", LLSD(), LLSD(), callbackCreateEventWebPage); + LLNotificationsUtil::add("PromptGoToEventsPage", LLSD(), LLSD(), callbackCreateEventWebPage); } // static diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp index add1f3caa..835d8e514 100644 --- a/indra/newview/llpanelgroup.cpp +++ b/indra/newview/llpanelgroup.cpp @@ -46,7 +46,7 @@ #include "lluictrlfactory.h" #include "llviewerwindow.h" #include "llappviewer.h" -#include "llnotifications.h" +#include "llnotificationsutil.h" // static void* LLPanelGroupTab::createTab(void* data) @@ -411,7 +411,7 @@ BOOL LLPanelGroup::attemptTransition() LLSD args; args["NEEDS_APPLY_MESSAGE"] = mesg; args["WANT_APPLY_MESSAGE"] = mWantApplyMesg; - LLNotifications::instance().add("PanelGroupApply", args, LLSD(), + LLNotificationsUtil::add("PanelGroupApply", args, LLSD(), boost::bind(&LLPanelGroup::handleNotifyCallback, this, _1, _2)); mShowingNotifyDialog = TRUE; @@ -559,7 +559,7 @@ bool LLPanelGroup::apply() { LLSD args; args["MESSAGE"] = apply_mesg; - LLNotifications::instance().add("GenericAlert", args); + LLNotificationsUtil::add("GenericAlert", args); } return false; diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp index 1c05d340f..044b40337 100644 --- a/indra/newview/llpanelgroupgeneral.cpp +++ b/indra/newview/llpanelgroupgeneral.cpp @@ -50,6 +50,7 @@ #include "llnamebox.h" #include "llnamelistctrl.h" #include "llnameeditor.h" +#include "llnotificationsutil.h" #include "llspinctrl.h" #include "llstatusbar.h" // can_afford_transaction() #include "lltextbox.h" @@ -377,11 +378,11 @@ void LLPanelGroupGeneral::onClickJoin(void *userdata) if (can_afford_transaction(cost)) { - LLNotifications::instance().add("JoinGroupCanAfford", args, payload, LLPanelGroupGeneral::joinDlgCB); + LLNotificationsUtil::add("JoinGroupCanAfford", args, payload, LLPanelGroupGeneral::joinDlgCB); } else { - LLNotifications::instance().add("JoinGroupCannotAfford", args, payload); + LLNotificationsUtil::add("JoinGroupCannotAfford", args, payload); } } else @@ -472,7 +473,7 @@ bool LLPanelGroupGeneral::apply(std::string& mesg) if(mComboMature && mComboMature->getCurrentIndex() == DECLINE_TO_STATE) { - LLNotifications::instance().add("SetGroupMature", LLSD(), LLSD(), + LLNotificationsUtil::add("SetGroupMature", LLSD(), LLSD(), boost::bind(&LLPanelGroupGeneral::confirmMatureApply, this, _1, _2)); return false; } @@ -493,7 +494,7 @@ bool LLPanelGroupGeneral::apply(std::string& mesg) LLSD args; args["MESSAGE"] = mConfirmGroupCreateStr; - LLNotifications::instance().add("GenericAlertYesCancel", args, LLSD(), boost::bind(&LLPanelGroupGeneral::createGroupCallback, this, _1, _2)); + LLNotificationsUtil::add("GenericAlertYesCancel", args, LLSD(), boost::bind(&LLPanelGroupGeneral::createGroupCallback, this, _1, _2)); return false; } diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index f95a27aad..cff4637bd 100644 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -39,6 +39,7 @@ #include "llcombobox.h" #include "llgroupmgr.h" #include "llnamelistctrl.h" +#include "llnotificationsutil.h" #include "llspinctrl.h" #include "lltextbox.h" #include "llviewerobject.h" @@ -161,7 +162,7 @@ void LLPanelGroupInvite::impl::submitInvitations() { LLSD args; args["MESSAGE"] = mOwnerWarning; - LLNotifications::instance().add("GenericAlertYesCancel", args, LLSD(), boost::bind(&LLPanelGroupInvite::impl::inviteOwnerCallback, this, _1, _2)); + LLNotificationsUtil::add("GenericAlertYesCancel", args, LLSD(), boost::bind(&LLPanelGroupInvite::impl::inviteOwnerCallback, this, _1, _2)); return; // we'll be called again if user confirms } } diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp index 950f08699..48115837a 100644 --- a/indra/newview/llpanelgroupnotices.cpp +++ b/indra/newview/llpanelgroupnotices.cpp @@ -39,6 +39,7 @@ #include "llinventory.h" #include "llviewerinventory.h" #include "llinventorymodel.h" +#include "llinventorydefines.h" #include "llinventoryview.h" #include "llagent.h" #include "lltooldraganddrop.h" @@ -48,6 +49,7 @@ #include "llbutton.h" #include "lliconctrl.h" #include "llcheckboxctrl.h" +#include "llnotificationsutil.h" #include "llscrolllistctrl.h" #include "lltextbox.h" @@ -55,7 +57,6 @@ #include "llviewerwindow.h" #include "llviewercontrol.h" #include "llviewermessage.h" -#include "llnotifications.h" const S32 NOTICE_DATE_STRING_SIZE = 30; @@ -351,7 +352,7 @@ void LLPanelGroupNotices::onClickSendMessage(void* data) if (self->mCreateSubject->getText().empty()) { // Must supply a subject - LLNotifications::instance().add("MustSpecifyGroupNoticeSubject"); + LLNotificationsUtil::add("MustSpecifyGroupNoticeSubject"); return; } send_group_notice( diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp index fe42aef8d..be41b0f87 100644 --- a/indra/newview/llpanelgrouproles.cpp +++ b/indra/newview/llpanelgrouproles.cpp @@ -41,7 +41,7 @@ #include "lliconctrl.h" #include "lllineeditor.h" #include "llnamelistctrl.h" -#include "llnotify.h" +#include "llnotificationsutil.h" #include "llpanelgrouproles.h" #include "llscrolllistctrl.h" #include "lltabcontainer.h" @@ -241,7 +241,7 @@ BOOL LLPanelGroupRoles::attemptTransition() LLSD args; args["NEEDS_APPLY_MESSAGE"] = mesg; args["WANT_APPLY_MESSAGE"] = mWantApplyMesg; - LLNotifications::instance().add("PanelGroupApply", args, LLSD(), + LLNotificationsUtil::add("PanelGroupApply", args, LLSD(), boost::bind(&LLPanelGroupRoles::handleNotifyCallback, this, _1, _2)); mHasModal = TRUE; // We need to reselect the current tab, since it isn't finished. @@ -301,7 +301,7 @@ bool LLPanelGroupRoles::handleNotifyCallback(const LLSD& notification, const LLS mHasModal = TRUE; LLSD args; args["MESSAGE"] = apply_mesg; - LLNotifications::instance().add("GenericAlert", args, LLSD(), boost::bind(&LLPanelGroupRoles::onModalClose, this, _1, _2)); + LLNotificationsUtil::add("GenericAlert", args, LLSD(), boost::bind(&LLPanelGroupRoles::onModalClose, this, _1, _2)); } // Skip switching tabs. break; @@ -1370,7 +1370,7 @@ bool LLPanelGroupMembersSubTab::apply(std::string& mesg) { mHasModal = TRUE; args["ROLE_NAME"] = rd.mRoleName; - LLNotifications::instance().add("AddGroupOwnerWarning", + LLNotificationsUtil::add("AddGroupOwnerWarning", args, LLSD(), boost::bind(&LLPanelGroupMembersSubTab::addOwnerCB, this, _1, _2)); @@ -2397,7 +2397,7 @@ void LLPanelGroupRolesSubTab::handleDeleteRole() { LLSD args; args["MESSAGE"] = mRemoveEveryoneTxt; - LLNotifications::instance().add("GenericAlert", args); + LLNotificationsUtil::add("GenericAlert", args); return; } diff --git a/indra/newview/llpanelgroupvoting.cpp b/indra/newview/llpanelgroupvoting.cpp index 162806c63..5094d1c26 100644 --- a/indra/newview/llpanelgroupvoting.cpp +++ b/indra/newview/llpanelgroupvoting.cpp @@ -35,6 +35,7 @@ #include "roles_constants.h" #include "lllineeditor.h" +#include "llnotificationsutil.h" #include "lltextbox.h" #include "lltexteditor.h" #include "llscrolllistctrl.h" @@ -648,7 +649,7 @@ void LLPanelGroupVoting::handleResponse( args["MESSAGE"] = self->mPanel.getString("vote_previously_recorded"); } - LLNotifications::instance().add("SystemMessage", args); + LLNotificationsUtil::add("SystemMessage", args); self->sendGroupVoteHistoryRequest(self->mGroupID); } @@ -1357,7 +1358,7 @@ void LLPanelGroupVoting::impl::onClickSubmitProposal(void *userdata) //throw up an error dialog LLSD args; args["MESSAGE"] = self->mPanel.getString("empty_proposal_txt"); - LLNotifications::instance().add("GenericAlert", args); + LLNotificationsUtil::add("GenericAlert", args); return; } @@ -1400,7 +1401,7 @@ void LLPanelGroupVoting::impl::onClickViewProposalItem(void *userdata) } else { - LLNotifications::instance().add("SelectProposalToView"); + LLNotificationsUtil::add("SelectProposalToView"); } } } @@ -1440,7 +1441,7 @@ void LLPanelGroupVoting::impl::onClickViewHistoryItem(void *userdata) } else { - LLNotifications::instance().add("SelectHistoryItemToView"); + LLNotificationsUtil::add("SelectHistoryItemToView"); } } } diff --git a/indra/newview/llpanelinventory.cpp b/indra/newview/llpanelinventory.cpp index 8a1e7c112..4fc93bcc7 100644 --- a/indra/newview/llpanelinventory.cpp +++ b/indra/newview/llpanelinventory.cpp @@ -50,6 +50,8 @@ #include "llfontgl.h" #include "llassetstorage.h" #include "llinventory.h" +#include "llinventorydefines.h" +#include "llnotificationsutil.h" #include "llagent.h" #include "llcallbacklist.h" @@ -232,7 +234,7 @@ void LLTaskInvFVBridge::buyItem() LLViewerObject* obj; if( ( obj = gObjectList.findObject( mPanel->getTaskUUID() ) ) && obj->isAttachment() ) { - LLNotifications::instance().add("Cannot_Purchase_an_Attachment"); + LLNotificationsUtil::add("Cannot_Purchase_an_Attachment"); llinfos << "Attempt to purchase an attachment" << llendl; delete inv; } @@ -532,7 +534,7 @@ BOOL LLTaskInvFVBridge::removeItem() LLSD payload; payload["task_id"] = mPanel->getTaskUUID(); payload["inventory_ids"].append(mUUID); - LLNotifications::instance().add("RemoveItemWarn", LLSD(), payload, boost::bind(&remove_task_inventory_callback, _1, _2, mPanel)); + LLNotificationsUtil::add("RemoveItemWarn", LLSD(), payload, boost::bind(&remove_task_inventory_callback, _1, _2, mPanel)); return FALSE; } } @@ -562,7 +564,7 @@ void LLTaskInvFVBridge::removeBatch(LLDynamicArray& LLTaskInvFVBridge* itemp = (LLTaskInvFVBridge*)batch[i]; payload["inventory_ids"].append(itemp->getUUID()); } - LLNotifications::instance().add("RemoveItemWarn", LLSD(), payload, boost::bind(&remove_task_inventory_callback, _1, _2, mPanel)); + LLNotificationsUtil::add("RemoveItemWarn", LLSD(), payload, boost::bind(&remove_task_inventory_callback, _1, _2, mPanel)); } else diff --git a/indra/newview/llpanelland.cpp b/indra/newview/llpanelland.cpp index 05de7fdc4..f3591c0ad 100644 --- a/indra/newview/llpanelland.cpp +++ b/indra/newview/llpanelland.cpp @@ -40,6 +40,7 @@ #include "llbutton.h" #include "llcheckboxctrl.h" #include "llfloaterland.h" +#include "llnotificationsutil.h" #include "lltextbox.h" #include "llviewercontrol.h" #include "llviewerparcelmgr.h" @@ -280,5 +281,5 @@ void LLPanelLandInfo::onClickAbout(void*) void LLPanelLandInfo::onShowOwnersHelp(void* user_data) { - LLNotifications::instance().add("ShowOwnersHelp"); + LLNotificationsUtil::add("ShowOwnersHelp"); } diff --git a/indra/newview/llpanellandaudio.cpp b/indra/newview/llpanellandaudio.cpp index dd38bdbd4..ce9f17f6e 100644 --- a/indra/newview/llpanellandaudio.cpp +++ b/indra/newview/llpanellandaudio.cpp @@ -47,6 +47,7 @@ #include "llfloaterurlentry.h" #include "llfocusmgr.h" #include "lllineeditor.h" +#include "llnotificationsutil.h" #include "llparcel.h" #include "lltextbox.h" #include "llradiogroup.h" @@ -197,5 +198,5 @@ void LLPanelLandAudio::onCommitAny(LLUICtrl*, void *userdata) // static void LLPanelLandAudio::onClickSoundHelp(void*) { - LLNotifications::instance().add("ClickSoundHelpLand"); + LLNotificationsUtil::add("ClickSoundHelpLand"); } diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index c0251cac7..fde18272d 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -56,6 +56,7 @@ #include "llfloaterpreference.h" #include "llfocusmgr.h" #include "lllineeditor.h" +#include "llnotificationsutil.h" #include "llstartup.h" #include "lltextbox.h" #include "llui.h" @@ -1116,9 +1117,9 @@ void LLPanelLogin::onClickConnect(void *) else { if (gHippoGridManager->getConnectedGrid()->getRegisterUrl().empty()) { - LLNotifications::instance().add("MustHaveAccountToLogInNoLinks"); + LLNotificationsUtil::add("MustHaveAccountToLogInNoLinks"); } else { - LLNotifications::instance().add("MustHaveAccountToLogIn", LLSD(), LLSD(), + LLNotificationsUtil::add("MustHaveAccountToLogIn", LLSD(), LLSD(), LLPanelLogin::newAccountAlertCallback); } } @@ -1212,7 +1213,7 @@ void LLPanelLogin::onPassKey(LLLineEditor* caller, void* user_data) { if (gKeyboard->getKeyDown(KEY_CAPSLOCK) && sCapslockDidNotification == FALSE) { - LLNotifications::instance().add("CapsKeyOn"); + LLNotificationsUtil::add("CapsKeyOn"); sCapslockDidNotification = TRUE; } } diff --git a/indra/newview/llpanelmediahud.cpp b/indra/newview/llpanelmediahud.cpp index a71bddfee..2d0aa931c 100644 --- a/indra/newview/llpanelmediahud.cpp +++ b/indra/newview/llpanelmediahud.cpp @@ -41,6 +41,7 @@ #include "llrender.h" #include "lldrawable.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "lluictrlfactory.h" #include "llbutton.h" #include "llface.h" diff --git a/indra/newview/llpanelmsgs.cpp b/indra/newview/llpanelmsgs.cpp index e0b105293..96fe7129b 100644 --- a/indra/newview/llpanelmsgs.cpp +++ b/indra/newview/llpanelmsgs.cpp @@ -34,6 +34,7 @@ #include "llpanelmsgs.h" +#include "llnotificationsutil.h" #include "llscrolllistctrl.h" #include "llviewerwindow.h" #include "llviewercontrol.h" @@ -222,7 +223,7 @@ bool callback_reset_dialogs(const LLSD& notification, const LLSD& response, LLPa // static void LLPanelMsgs::onClickResetDialogs(void* user_data) { - LLNotifications::instance().add("ResetShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_reset_dialogs, _1, _2, (LLPanelMsgs*)user_data)); + LLNotificationsUtil::add("ResetShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_reset_dialogs, _1, _2, (LLPanelMsgs*)user_data)); } bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLPanelMsgs* panelp) @@ -243,5 +244,5 @@ bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLPan // static void LLPanelMsgs::onClickSkipDialogs(void* user_data) { - LLNotifications::instance().add("SkipShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_skip_dialogs, _1, _2, (LLPanelMsgs*)user_data)); + LLNotificationsUtil::add("SkipShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_skip_dialogs, _1, _2, (LLPanelMsgs*)user_data)); } diff --git a/indra/newview/llpanelnetwork.cpp b/indra/newview/llpanelnetwork.cpp index 003af8116..ebe4b1f84 100644 --- a/indra/newview/llpanelnetwork.cpp +++ b/indra/newview/llpanelnetwork.cpp @@ -41,6 +41,7 @@ #include "llradiogroup.h" #include "statemachine/aidirpicker.h" #include "lluictrlfactory.h" +#include "llnotificationsutil.h" #include "llviewercontrol.h" #include "llviewerwindow.h" @@ -126,7 +127,7 @@ void LLPanelNetwork::apply() { if (LLStartUp::getStartupState() != STATE_LOGIN_WAIT) { - LLNotifications::instance().add("ProxyNeedRestart"); + LLNotificationsUtil::add("ProxyNeedRestart"); } else { @@ -145,7 +146,7 @@ void LLPanelNetwork::onClickClearCache(void*) { // flag client cache for clearing next time the client runs gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE); - LLNotifications::instance().add("CacheWillClear"); + LLNotificationsUtil::add("CacheWillClear"); } // static @@ -172,7 +173,7 @@ void LLPanelNetwork::onClickSetCache_continued(void* user_data, AIDirPicker* dir if (!dir_name.empty() && dir_name != cur_name) { self->childSetText("cache_location", dir_name); - LLNotifications::instance().add("CacheWillBeMoved"); + LLNotificationsUtil::add("CacheWillBeMoved"); gSavedSettings.setString("NewCacheLocation", dir_name); } else @@ -192,7 +193,7 @@ void LLPanelNetwork::onClickResetCache(void* user_data) return; } gSavedSettings.setString("NewCacheLocation", ""); - LLNotifications::instance().add("CacheWillBeMoved"); + LLNotificationsUtil::add("CacheWillBeMoved"); std::string cache_location = gDirUtilp->getCacheDir(false); self->childSetText("cache_location", cache_location); } @@ -205,7 +206,7 @@ void LLPanelNetwork::onCommitPort(LLUICtrl* ctrl, void* data) if (!self || !check) return; self->childSetEnabled("connection_port", check->get()); - LLNotifications::instance().add("ChangeConnectionPort"); + LLNotificationsUtil::add("ChangeConnectionPort"); } // static diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp index b5bbc99c4..b92632337 100644 --- a/indra/newview/llpanelobject.cpp +++ b/indra/newview/llpanelobject.cpp @@ -53,6 +53,7 @@ #include "llcombobox.h" #include "llfocusmgr.h" #include "llmanipscale.h" +#include "llnotificationsutil.h" #include "llpanelinventory.h" #include "llpreviewscript.h" #include "llresmgr.h" @@ -67,6 +68,7 @@ #include "llviewerobject.h" #include "llviewerregion.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llvovolume.h" #include "llworld.h" #include "pipeline.h" @@ -2154,7 +2156,7 @@ void LLPanelObject::sendPosition(BOOL btn_down) // Clamp the Z height const F32 height = newpos.mV[VZ]; - const F32 min_height = LLWorld::getInstance()->getMinAllowedZ(mObject); + const F32 min_height = LLWorld::getInstance()->getMinAllowedZ(mObject, mObject->getPositionGlobal()); // //const F32 max_height = LLWorld::getInstance()->getRegionMaxHeight(); const F32 max_height = F32(340282346638528859811704183484516925440.0f); @@ -2543,7 +2545,7 @@ void LLPanelObject::onCommitSculptType(LLUICtrl *ctrl, void* userdata) // static void LLPanelObject::onClickBuildConstants(void *) { - LLNotifications::instance().add("ClickBuildConstants"); + LLNotificationsUtil::add("ClickBuildConstants"); } std::string shortfloat(F32 in) diff --git a/indra/newview/llpanelpermissions.cpp b/indra/newview/llpanelpermissions.cpp index d1819733f..8e42927fd 100644 --- a/indra/newview/llpanelpermissions.cpp +++ b/indra/newview/llpanelpermissions.cpp @@ -41,9 +41,11 @@ #include "llcategory.h" #include "llclickaction.h" #include "llfocusmgr.h" +#include "llnotificationsutil.h" #include "llstring.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llresmgr.h" #include "lltextbox.h" #include "llbutton.h" @@ -1193,7 +1195,7 @@ void LLPanelPermissions::onCommitClickAction(LLUICtrl* ctrl, void*) LLSelectMgr::getInstance()->selectGetSaleInfo(sale_info); if (!sale_info.isForSale()) { - LLNotifications::instance().add("CantSetBuyObject"); + LLNotificationsUtil::add("CantSetBuyObject"); // Set click action back to its old value U8 click_action = 0; @@ -1211,7 +1213,7 @@ void LLPanelPermissions::onCommitClickAction(LLUICtrl* ctrl, void*) if (!can_pay) { // Warn, but do it anyway. - LLNotifications::instance().add("ClickActionNotPayable"); + LLNotificationsUtil::add("ClickActionNotPayable"); } } LLSelectMgr::getInstance()->selectionSetClickAction(click_action); diff --git a/indra/newview/llpanelpick.cpp b/indra/newview/llpanelpick.cpp index a33b3dd60..aece29b17 100644 --- a/indra/newview/llpanelpick.cpp +++ b/indra/newview/llpanelpick.cpp @@ -59,6 +59,7 @@ #include "llfloaterworldmap.h" #include "llviewerregion.h" #include "llviewerwindow.h" +#include "llnotificationsutil.h" // [RLVa:KB] #include "rlvhandler.h" @@ -596,7 +597,7 @@ void LLPanelPick::onClickSet(void* data) // is the location and nothing else if ( gAgent.getRegion ()->getName () != self->mSimName ) { - LLNotifications::instance().add("SetPickLocation"); + LLNotificationsUtil::add("SetPickLocation"); }; self->mLocationEditor->setText(location_text); diff --git a/indra/newview/llpanelplace.cpp b/indra/newview/llpanelplace.cpp index 35499f581..38b75572a 100644 --- a/indra/newview/llpanelplace.cpp +++ b/indra/newview/llpanelplace.cpp @@ -47,6 +47,7 @@ #include "llbutton.h" #include "llfloaterworldmap.h" #include "lllineeditor.h" +#include "llnotificationsutil.h" #include "lluiconstants.h" #include "lltextbox.h" #include "llviewertexteditor.h" @@ -460,7 +461,7 @@ void LLPanelPlace::onClickAuction(void* data) LLSD payload; payload["auction_id"] = self->mAuctionID; - LLNotifications::instance().add("GoToAuctionPage", LLSD(), payload, callbackAuctionWebPage); + LLNotificationsUtil::add("GoToAuctionPage", LLSD(), payload, callbackAuctionWebPage); } // static diff --git a/indra/newview/llpanelskins.cpp b/indra/newview/llpanelskins.cpp index 7be656031..828598c3d 100644 --- a/indra/newview/llpanelskins.cpp +++ b/indra/newview/llpanelskins.cpp @@ -39,6 +39,7 @@ #include "llbutton.h" #include "lluictrlfactory.h" #include "lldiriterator.h" +#include "llnotificationsutil.h" // project includes #include "llviewercontrol.h" @@ -147,7 +148,7 @@ void LLPanelSkins::apply() if (oldSkin != mSkin) { oldSkin=mSkin; - LLNotifications::instance().add("ChangeSkin"); + LLNotificationsUtil::add("ChangeSkin"); refresh(); } } diff --git a/indra/newview/llpanelweb.cpp b/indra/newview/llpanelweb.cpp index 955c4b668..9f60ecda4 100644 --- a/indra/newview/llpanelweb.cpp +++ b/indra/newview/llpanelweb.cpp @@ -37,6 +37,7 @@ // project includes #include "llcheckboxctrl.h" +#include "llnotificationsutil.h" #include "lluictrlfactory.h" #include "llviewercontrol.h" #include "llviewermedia.h" @@ -116,7 +117,7 @@ void LLPanelWeb::cancel() // static void LLPanelWeb::onClickClearCache(void*) { - LLNotifications::instance().add("ConfirmClearBrowserCache", LLSD(), LLSD(), callback_clear_browser_cache); + LLNotificationsUtil::add("ConfirmClearBrowserCache", LLSD(), LLSD(), callback_clear_browser_cache); } //static @@ -135,7 +136,7 @@ bool LLPanelWeb::callback_clear_browser_cache(const LLSD& notification, const LL // static void LLPanelWeb::onClickClearCookies(void*) { - LLNotifications::instance().add("ConfirmClearCookies", LLSD(), LLSD(), callback_clear_cookies); + LLNotificationsUtil::add("ConfirmClearCookies", LLSD(), LLSD(), callback_clear_cookies); } //static diff --git a/indra/newview/llparcelselection.h b/indra/newview/llparcelselection.h index 5f26fafc3..0481bea6f 100644 --- a/indra/newview/llparcelselection.h +++ b/indra/newview/llparcelselection.h @@ -33,7 +33,8 @@ #ifndef LLPARCELSELECTION_H #define LLPARCELSELECTION_H -#include "llmemory.h" +#include "llrefcount.h" +#include "llsafehandle.h" class LLParcel; diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp index ba1508f62..63742e917 100644 --- a/indra/newview/llpreview.cpp +++ b/indra/newview/llpreview.cpp @@ -36,6 +36,7 @@ #include "llpreview.h" #include "lllineeditor.h" #include "llinventory.h" +#include "llinventorydefines.h" #include "llinventorymodel.h" #include "llresmgr.h" #include "lltextbox.h" diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index 9dba4df0b..1cd3b5162 100644 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -39,6 +39,7 @@ // libraries #include "lldatapacker.h" #include "lldarray.h" +#include "llinventorydefines.h" #include "llstring.h" #include "lldir.h" #include "llmultigesture.h" @@ -57,7 +58,7 @@ #include "llinventorymodel.h" #include "llkeyboard.h" #include "lllineeditor.h" -#include "llnotify.h" +#include "llnotificationsutil.h" #include "llradiogroup.h" #include "llscrolllistctrl.h" #include "lltextbox.h" @@ -286,7 +287,7 @@ BOOL LLPreviewGesture::canClose() else { // Bring up view-modal dialog: Save changes? Yes, No, Cancel - LLNotifications::instance().add("SaveChanges", LLSD(), LLSD(), + LLNotificationsUtil::add("SaveChanges", LLSD(), LLSD(), boost::bind(&LLPreviewGesture::handleSaveChangesDialog, this, _1, _2) ); return FALSE; } @@ -295,7 +296,7 @@ BOOL LLPreviewGesture::canClose() // virtual void LLPreviewGesture::onClose(bool app_quitting) { - gGestureManager.stopGesture(mPreviewGesture); + LLGestureMgr::instance().stopGesture(mPreviewGesture); LLPreview::onClose(app_quitting); } @@ -327,13 +328,13 @@ bool LLPreviewGesture::handleSaveChangesDialog(const LLSD& notification, const L switch(option) { case 0: // "Yes" - gGestureManager.stopGesture(mPreviewGesture); + LLGestureMgr::instance().stopGesture(mPreviewGesture); mCloseAfterSave = TRUE; onClickSave(this); break; case 1: // "No" - gGestureManager.stopGesture(mPreviewGesture); + LLGestureMgr::instance().stopGesture(mPreviewGesture); mDirty = FALSE; // Force the dirty flag because user has clicked NO on confirm save dialog... close(); break; @@ -840,7 +841,7 @@ void LLPreviewGesture::refresh() mOptionsText->setText(optionstext); - BOOL active = gGestureManager.isGestureActive(mItemUUID); + BOOL active = LLGestureMgr::instance().isGestureActive(mItemUUID); mActiveCheck->set(active); // Can only preview if there are steps @@ -1126,14 +1127,14 @@ void LLPreviewGesture::saveIfNeeded() if(0) // { - LLNotifications::instance().add("GestureSaveFailedTooManySteps"); + LLNotificationsUtil::add("GestureSaveFailedTooManySteps"); delete gesture; gesture = NULL; } else if (!ok) { - LLNotifications::instance().add("GestureSaveFailedTryAgain"); + LLNotificationsUtil::add("GestureSaveFailedTryAgain"); delete gesture; gesture = NULL; } @@ -1194,10 +1195,10 @@ void LLPreviewGesture::saveIfNeeded() // If this gesture is active, then we need to update the in-memory // active map with the new pointer. - if (!delayedUpload && gGestureManager.isGestureActive(mItemUUID)) + if (!delayedUpload && LLGestureMgr::instance().isGestureActive(mItemUUID)) { // gesture manager now owns the pointer - gGestureManager.replaceGesture(mItemUUID, gesture, asset_id); + LLGestureMgr::instance().replaceGesture(mItemUUID, gesture, asset_id); // replaceGesture may deactivate other gestures so let the // inventory know. @@ -1272,7 +1273,7 @@ void LLPreviewGesture::onSaveComplete(const LLUUID& asset_uuid, void* user_data, } else { - LLNotifications::instance().add("GestureSaveFailedObjectNotFound"); + LLNotificationsUtil::add("GestureSaveFailedObjectNotFound"); } } @@ -1288,7 +1289,7 @@ void LLPreviewGesture::onSaveComplete(const LLUUID& asset_uuid, void* user_data, llwarns << "Problem saving gesture: " << status << llendl; LLSD args; args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); - LLNotifications::instance().add("GestureSaveFailedReason", args); + LLNotificationsUtil::add("GestureSaveFailedReason", args); } delete info; info = NULL; @@ -1720,13 +1721,13 @@ void LLPreviewGesture::onClickDelete(void* data) void LLPreviewGesture::onCommitActive(LLUICtrl* ctrl, void* data) { LLPreviewGesture* self = (LLPreviewGesture*)data; - if (!gGestureManager.isGestureActive(self->mItemUUID)) + if (!LLGestureMgr::instance().isGestureActive(self->mItemUUID)) { - gGestureManager.activateGesture(self->mItemUUID); + LLGestureMgr::instance().activateGesture(self->mItemUUID); } else { - gGestureManager.deactivateGesture(self->mItemUUID); + LLGestureMgr::instance().deactivateGesture(self->mItemUUID); } // Make sure the (active) label in the inventory gets updated. @@ -1765,14 +1766,14 @@ void LLPreviewGesture::onClickPreview(void* data) self->mPreviewBtn->setLabel(self->getString("stop_txt")); // play it, and delete when done - gGestureManager.playGesture(self->mPreviewGesture); + LLGestureMgr::instance().playGesture(self->mPreviewGesture); self->refresh(); } else { // Will call onDonePreview() below - gGestureManager.stopGesture(self->mPreviewGesture); + LLGestureMgr::instance().stopGesture(self->mPreviewGesture); self->refresh(); } diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp index 642a75a91..98ed9a409 100644 --- a/indra/newview/llpreviewnotecard.cpp +++ b/indra/newview/llpreviewnotecard.cpp @@ -35,6 +35,7 @@ #include "llpreviewnotecard.h" #include "llinventory.h" +#include "llinventorydefines.h" #include "llagent.h" #include "llagentcamera.h" @@ -43,7 +44,7 @@ #include "llbutton.h" #include "llinventorymodel.h" #include "lllineeditor.h" -#include "llnotify.h" +#include "llnotificationsutil.h" #include "llresmgr.h" #include "roles_constants.h" #include "llscrollbar.h" @@ -237,7 +238,7 @@ BOOL LLPreviewNotecard::canClose() else { // Bring up view-modal dialog: Save changes? Yes, No, Cancel - LLNotifications::instance().add("SaveChanges", LLSD(), LLSD(), boost::bind(&LLPreviewNotecard::handleSaveChangesDialog,this, _1, _2)); + LLNotificationsUtil::add("SaveChanges", LLSD(), LLSD(), boost::bind(&LLPreviewNotecard::handleSaveChangesDialog,this, _1, _2)); return FALSE; } @@ -412,15 +413,15 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs, if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { - LLNotifications::instance().add("NotecardMissing"); + LLNotificationsUtil::add("NotecardMissing"); } else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) { - LLNotifications::instance().add("NotecardNoPermissions"); + LLNotificationsUtil::add("NotecardNoPermissions"); } else { - LLNotifications::instance().add("UnableToLoadNotecard"); + LLNotificationsUtil::add("UnableToLoadNotecard"); } llwarns << "Problem loading notecard: " << status << llendl; @@ -631,7 +632,7 @@ void LLPreviewNotecard::onSaveComplete(const LLUUID& asset_uuid, void* user_data } else { - LLNotifications::instance().add("SaveNotecardFailObjectNotFound"); + LLNotificationsUtil::add("SaveNotecardFailObjectNotFound"); } } // Perform item copy to inventory @@ -656,7 +657,7 @@ void LLPreviewNotecard::onSaveComplete(const LLUUID& asset_uuid, void* user_data llwarns << "Problem saving notecard: " << status << llendl; LLSD args; args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); - LLNotifications::instance().add("SaveNotecardFailReason", args); + LLNotificationsUtil::add("SaveNotecardFailReason", args); } std::string uuid_string; diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index e4abac51d..3019fca11 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -40,10 +40,12 @@ #include "llcheckboxctrl.h" #include "llcombobox.h" #include "lldir.h" +#include "llinventorydefines.h" #include "llinventorymodel.h" #include "llkeyboard.h" #include "lllineeditor.h" +#include "llnotificationsutil.h" #include "llresmgr.h" #include "llscrollbar.h" #include "llscrollcontainer.h" @@ -707,7 +709,7 @@ BOOL LLScriptEdCore::canClose() else { // Bring up view-modal dialog: Save changes? Yes, No, Cancel - LLNotifications::instance().add("SaveChanges", LLSD(), LLSD(), boost::bind(&LLScriptEdCore::handleSaveChangesDialog, this, _1, _2)); + LLNotificationsUtil::add("SaveChanges", LLSD(), LLSD(), boost::bind(&LLScriptEdCore::handleSaveChangesDialog, this, _1, _2)); return FALSE; } } @@ -765,7 +767,7 @@ void LLScriptEdCore::onBtnHelp(void* userdata) LLScriptEdCore* corep = (LLScriptEdCore*)userdata; LLSD payload; payload["help_url"] = corep->mHelpURL; - LLNotifications::instance().add("WebLaunchLSLGuide", LLSD(), payload, onHelpWebDialog); + LLNotificationsUtil::add("WebLaunchLSLGuide", LLSD(), payload, onHelpWebDialog); } // static @@ -924,7 +926,7 @@ void LLScriptEdCore::onBtnUndoChanges( void* userdata ) LLScriptEdCore* self = (LLScriptEdCore*) userdata; if( !self->mEditor->tryToRevertToPristineState() ) { - LLNotifications::instance().add("ScriptCannotUndo", LLSD(), LLSD(), boost::bind(&LLScriptEdCore::handleReloadFromServerDialog, self, _1, _2)); + LLNotificationsUtil::add("ScriptCannotUndo", LLSD(), LLSD(), boost::bind(&LLScriptEdCore::handleReloadFromServerDialog, self, _1, _2)); } } @@ -1562,7 +1564,7 @@ void LLPreviewLSL::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 llwarns << "Problem saving script: " << status << llendl; LLSD args; args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); - LLNotifications::instance().add("SaveScriptFailReason", args); + LLNotificationsUtil::add("SaveScriptFailReason", args); } delete info; } @@ -1600,7 +1602,7 @@ void LLPreviewLSL::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_d llwarns << "Problem saving LSL Bytecode (Preview)" << llendl; LLSD args; args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); - LLNotifications::instance().add("SaveBytecodeFailReason", args); + LLNotificationsUtil::add("SaveBytecodeFailReason", args); } delete instance_uuid; } @@ -1646,15 +1648,15 @@ void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAsset if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { - LLNotifications::instance().add("ScriptMissing"); + LLNotificationsUtil::add("ScriptMissing"); } else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) { - LLNotifications::instance().add("ScriptNoPermissions"); + LLNotificationsUtil::add("ScriptNoPermissions"); } else { - LLNotifications::instance().add("UnableToLoadScript"); + LLNotificationsUtil::add("UnableToLoadScript"); } preview->mAssetStatus = PREVIEW_ASSET_ERROR; @@ -1994,15 +1996,15 @@ void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id, if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { - LLNotifications::instance().add("ScriptMissing"); + LLNotificationsUtil::add("ScriptMissing"); } else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) { - LLNotifications::instance().add("ScriptNoPermissions"); + LLNotificationsUtil::add("ScriptNoPermissions"); } else { - LLNotifications::instance().add("UnableToLoadScript"); + LLNotificationsUtil::add("UnableToLoadScript"); } instance->mAssetStatus = PREVIEW_ASSET_ERROR; } @@ -2096,7 +2098,7 @@ void LLLiveLSLEditor::onRunningCheckboxClicked( LLUICtrl*, void* userdata ) else { runningCheckbox->set(!running); - LLNotifications::instance().add("CouldNotStartStopScript"); + LLNotificationsUtil::add("CouldNotStartStopScript"); } } @@ -2126,7 +2128,7 @@ void LLLiveLSLEditor::onReset(void *userdata) } else { - LLNotifications::instance().add("CouldNotStartStopScript"); + LLNotificationsUtil::add("CouldNotStartStopScript"); } } @@ -2220,7 +2222,7 @@ void LLLiveLSLEditor::saveIfNeeded() LLViewerObject* object = gObjectList.findObject(mObjectID); if(!object) { - LLNotifications::instance().add("SaveScriptFailObjectNotFound"); + LLNotificationsUtil::add("SaveScriptFailObjectNotFound"); return; } @@ -2228,7 +2230,7 @@ void LLLiveLSLEditor::saveIfNeeded() { // $NOTE: While the error message may not be exactly correct, // it's pretty close. - LLNotifications::instance().add("SaveScriptFailObjectNotFound"); + LLNotificationsUtil::add("SaveScriptFailObjectNotFound"); return; } @@ -2432,7 +2434,7 @@ void LLLiveLSLEditor::onSaveTextComplete(const LLUUID& asset_uuid, void* user_da llwarns << "Unable to save text for a script." << llendl; LLSD args; args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); - LLNotifications::instance().add("CompileQueueSaveText", args); + LLNotificationsUtil::add("CompileQueueSaveText", args); } else { @@ -2493,7 +2495,7 @@ void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* use LLSD args; args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); - LLNotifications::instance().add("CompileQueueSaveBytecode", args); + LLNotificationsUtil::add("CompileQueueSaveBytecode", args); } std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_uuid.asString()); diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index 55a5ef6b0..7846bef47 100644 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -41,6 +41,7 @@ #include "llimagetga.h" #include "llinventoryview.h" #include "llinventory.h" +#include "llnotificationsutil.h" #include "llresmgr.h" #include "lltextbox.h" #include "lltextureview.h" @@ -436,13 +437,13 @@ void LLPreviewTexture::onFileLoadedForSave(BOOL success, { LLSD args; args["FILE"] = self->mSaveFileName; - LLNotifications::instance().add("CannotEncodeFile", args); + LLNotificationsUtil::add("CannotEncodeFile", args); } else if( !image_tga->save( self->mSaveFileName ) ) { LLSD args; args["FILE"] = self->mSaveFileName; - LLNotifications::instance().add("CannotWriteFile", args); + LLNotificationsUtil::add("CannotWriteFile", args); } else { @@ -454,7 +455,7 @@ void LLPreviewTexture::onFileLoadedForSave(BOOL success, if( self && !success ) { - LLNotifications::instance().add("CannotDownloadFile"); + LLNotificationsUtil::add("CannotDownloadFile"); } } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 6246c7ebe..f9adea36b 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -42,6 +42,7 @@ #include "lleconomy.h" #include "llgl.h" #include "llrender.h" +#include "llnotifications.h" #include "llpermissions.h" #include "llpermissionsflags.h" #include "llundo.h" @@ -67,6 +68,7 @@ #include "llinventorymodel.h" #include "llmenugl.h" #include "llmutelist.h" +#include "llnotificationsutil.h" #include "llstatusbar.h" #include "llsurface.h" #include "lltool.h" @@ -571,7 +573,7 @@ bool LLSelectMgr::linkObjects() { if (!LLSelectMgr::getInstance()->selectGetAllRootsValid()) { - LLNotifications::getInstance()->add("UnableToLinkWhileDownloading"); + LLNotificationsUtil::add("UnableToLinkWhileDownloading"); return true; } @@ -582,19 +584,19 @@ bool LLSelectMgr::linkObjects() args["COUNT"] = llformat("%d", object_count); int max = MAX_CHILDREN_PER_TASK+1; args["MAX"] = llformat("%d", max); - LLNotifications::getInstance()->add("UnableToLinkObjects", args); + LLNotificationsUtil::add("UnableToLinkObjects", args); return true; } if (LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() < 2) { - LLNotifications::instance().add("CannotLinkIncompleteSet"); + LLNotificationsUtil::add("CannotLinkIncompleteSet"); return true; } if (!LLSelectMgr::getInstance()->selectGetRootsModify()) { - LLNotifications::instance().add("CannotLinkModify"); + LLNotificationsUtil::add("CannotLinkModify"); return true; } @@ -605,7 +607,7 @@ bool LLSelectMgr::linkObjects() // we don't actually care if you're the owner, but novices are // the most likely to be stumped by this one, so offer the // easiest and most likely solution. - LLNotifications::instance().add("CannotLinkDifferentOwners"); + LLNotificationsUtil::add("CannotLinkDifferentOwners"); return true; } @@ -5155,7 +5157,6 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) gGL.getTexUnit(0)->bind(mSilhouetteImagep); LLGLSPipelineSelection gls_select; - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.f); LLGLEnable blend(GL_BLEND); LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); @@ -5271,7 +5272,6 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) } gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } void LLSelectMgr::generateSilhouette(LLSelectNode* nodep, const LLVector3& view_point) @@ -6538,31 +6538,77 @@ U32 LLObjectSelection::getSelectedObjectTriangleCount() return count; } -/*S32 LLObjectSelection::getSelectedObjectRenderCost() + +S32 LLObjectSelection::getSelectedObjectRenderCost() { S32 cost = 0; LLVOVolume::texture_cost_t textures; + typedef std::set uuid_list_t; + uuid_list_t computed_objects; + + typedef std::list > child_list_t; + typedef const child_list_t const_child_list_t; + + // add render cost of complete linksets first, to get accurate texture counts for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter) { LLSelectNode* node = *iter; + LLVOVolume* object = (LLVOVolume*)node->getObject(); - if (object) + if (object && object->isRootEdit()) { - cost += object->getRenderCost(textures); - } + cost += object->getRenderCost(textures); + computed_objects.insert(object->getID()); - for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter) - { - // add the cost of each individual texture in the linkset - cost += iter->second; + const_child_list_t children = object->getChildren(); + for (const_child_list_t::const_iterator child_iter = children.begin(); + child_iter != children.end(); + ++child_iter) + { + LLViewerObject* child_obj = *child_iter; + LLVOVolume *child = dynamic_cast( child_obj ); + if (child) + { + cost += child->getRenderCost(textures); + computed_objects.insert(child->getID()); + } + } + + for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter) + { + // add the cost of each individual texture in the linkset + cost += iter->second; + } + + textures.clear(); } - textures.clear(); } + + // add any partial linkset objects, texture cost may be slightly misleading + for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter) + { + LLSelectNode* node = *iter; + LLVOVolume* object = (LLVOVolume*)node->getObject(); + if (object && computed_objects.find(object->getID()) == computed_objects.end() ) + { + cost += object->getRenderCost(textures); + computed_objects.insert(object->getID()); + } + + for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter) + { + // add the cost of each individual texture in the linkset + cost += iter->second; + } + + textures.clear(); + } return cost; -}*/ +} + #endif //MESH_ENABLED diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index 2ea1f46b7..37027f450 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -37,7 +37,8 @@ #include "lleditmenuhandler.h" #include "llundo.h" #include "lluuid.h" -#include "llmemory.h" +#include "llpointer.h" +#include "llsafehandle.h" #include "llsaleinfo.h" #include "llcategory.h" #include "v3dmath.h" diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 96db56418..2bce7e36d 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -400,6 +400,11 @@ void LLSpatialGroup::clearDrawMap() mDrawMap.clear(); } +BOOL LLSpatialGroup::isHUDGroup() +{ + return mSpatialPartition && mSpatialPartition->isHUDPartition() ; +} + BOOL LLSpatialGroup::isRecentlyVisible() const { return (LLDrawable::getCurrentFrame() - mVisible[LLViewerCamera::sCurCameraID]) < LLDrawable::getMinVisFrameRange() ; @@ -1530,7 +1535,7 @@ void LLSpatialGroup::doOcclusion(LLCamera* camera) LLGLEnable clamp(use_depth_clamp ? GL_DEPTH_CLAMP : 0); #if !LL_DARWIN - U32 mode = gGLManager.mHasOcclusionQuery2 ? /*GL_ANY_SAMPLES_PASSED*/0x8C2F : GL_SAMPLES_PASSED_ARB; + U32 mode = gGLManager.mHasOcclusionQuery2 ? GL_ANY_SAMPLES_PASSED : GL_SAMPLES_PASSED_ARB; #else U32 mode = GL_SAMPLES_PASSED_ARB; #endif @@ -3094,6 +3099,29 @@ public: { renderAgentTarget(avatar); } + + if (gDebugGL) + { + for (U32 i = 0; i < (U32)drawable->getNumFaces(); ++i) + { + LLFace* facep = drawable->getFace(i); + U8 index = facep->getTextureIndex(); + if (facep->mDrawInfo) + { + if (index < 255) + { + if (facep->mDrawInfo->mTextureList.size() <= index) + { + llerrs << "Face texture index out of bounds." << llendl; + } + else if (facep->mDrawInfo->mTextureList[index] != facep->getTexture()) + { + llerrs << "Face texture index incorrect." << llendl; + } + } + } + } + } } for (LLSpatialGroup::draw_map_t::iterator i = group->mDrawMap.begin(); i != group->mDrawMap.end(); ++i) @@ -3292,6 +3320,10 @@ void LLSpatialGroup::drawObjectBox(LLColor4 col) drawBox(mObjectBounds[0], size); } +bool LLSpatialPartition::isHUDPartition() +{ + return mPartitionType == LLViewerRegion::PARTITION_HUD ; +} BOOL LLSpatialPartition::isVisible(const LLVector3& v) { diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 56e5ca2e5..803c63680 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -93,7 +93,9 @@ public: LLVector4a mExtents[2]; LLPointer mVertexBuffer; - LLPointer mTexture; + LLPointer mTexture; + std::vector > mTextureList; + LLColor4U mGlowColor; S32 mDebugColor; const LLMatrix4* mTextureMatrix; @@ -271,6 +273,7 @@ public: LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part); + BOOL isHUDGroup() ; BOOL isDead() { return isState(DEAD); } BOOL isState(eSpatialState state) const; //Using enum type here and below to force type-safeness. BOOL isOcclusionState(eOcclusionState state) const { return mOcclusionState[LLViewerCamera::sCurCameraID] & state ? TRUE : FALSE; } @@ -436,6 +439,7 @@ public: S32 cull(LLCamera &camera, std::vector* results = NULL, BOOL for_select = FALSE); // Cull on arbitrary frustum BOOL isVisible(const LLVector3& v); + bool isHUDPartition() ; virtual LLSpatialBridge* asBridge() { return NULL; } virtual BOOL isBridge() { return asBridge() != NULL; } @@ -644,7 +648,7 @@ public: virtual void rebuildGeom(LLSpatialGroup* group); virtual void rebuildMesh(LLSpatialGroup* group); virtual void getGeometry(LLSpatialGroup* group); - void genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector& faces, BOOL distance_sort = FALSE); + void genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector& faces, BOOL distance_sort = FALSE, BOOL batch_textures = FALSE); void registerFace(LLSpatialGroup* group, LLFace* facep, U32 type); }; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index cc9f7adfe..8897d1f62 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -72,6 +72,8 @@ #include "llmemorystream.h" #include "llmessageconfig.h" #include "llmoveview.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llregionhandle.h" #include "llsd.h" #include "llsdserialize.h" @@ -370,7 +372,7 @@ bool idle_startup() static U64 first_sim_handle = 0; static LLHost first_sim; static std::string first_sim_seed_cap; - static U32 first_sim_size_x = 256; + static U32 first_sim_size_x = 256; static U32 first_sim_size_y = 256; static LLVector3 initial_sun_direction(1.f, 0.f, 0.f); @@ -424,12 +426,12 @@ bool idle_startup() if (LLFeatureManager::getInstance()->isSafe()) { - LLNotifications::instance().add("DisplaySetToSafe"); + LLNotificationsUtil::add("DisplaySetToSafe"); } else if ((gSavedSettings.getS32("LastFeatureVersion") < LLFeatureManager::getInstance()->getVersion()) && (gSavedSettings.getS32("LastFeatureVersion") != 0)) { - LLNotifications::instance().add("DisplaySetToRecommended"); + LLNotificationsUtil::add("DisplaySetToRecommended"); } else if (!gViewerWindow->getInitAlert().empty()) { @@ -1873,7 +1875,7 @@ bool idle_startup() // Bounce back to the login screen. LLSD args; args["ERROR_MESSAGE"] = emsg.str(); - LLNotifications::instance().add("ErrorMessage", args, LLSD(), login_alert_done); + LLNotificationsUtil::add("ErrorMessage", args, LLSD(), login_alert_done); reset_login(); gSavedSettings.setBOOL("AutoLogin", FALSE); show_connect_box = true; @@ -1893,7 +1895,7 @@ bool idle_startup() // Bounce back to the login screen. LLSD args; args["ERROR_MESSAGE"] = emsg.str(); - LLNotifications::instance().add("ErrorMessage", args, LLSD(), login_alert_done); + LLNotificationsUtil::add("ErrorMessage", args, LLSD(), login_alert_done); reset_login(); gSavedSettings.setBOOL("AutoLogin", FALSE); show_connect_box = true; @@ -1936,9 +1938,7 @@ bool idle_startup() // init the shader managers LLPostProcess::initClass(); - LLWLParamManager::initClass(); AscentDayCycleManager::initClass(); - LLWaterParamManager::initClass(); // RN: don't initialize VO classes in drone mode, they are too closely tied to rendering LLViewerObject::initVOClasses(); @@ -2628,7 +2628,7 @@ bool idle_startup() // Could schedule and delay these for later. const BOOL no_inform_server = FALSE; const BOOL no_deactivate_similar = FALSE; - gGestureManager.activateGestureWithAsset(item_id, asset_id, + LLGestureMgr::instance().activateGestureWithAsset(item_id, asset_id, no_inform_server, no_deactivate_similar); // We need to fetch the inventory items for these gestures @@ -2657,9 +2657,6 @@ bool idle_startup() gForegroundTime.reset(); if (gSavedSettings.getBOOL("FetchInventoryOnLogin") -#ifdef LL_RRINTERFACE_H //MK - || gRRenabled -#endif //mk ) { // Fetch inventory in the background @@ -2707,7 +2704,7 @@ bool idle_startup() args["TYPE"] = "home"; args["HELP"] = "You may want to set a new home location."; } - LLNotifications::instance().add("AvatarMoved", args); + LLNotificationsUtil::add("AvatarMoved", args); } else { @@ -2808,7 +2805,7 @@ bool idle_startup() // initial outfit, but if the load hasn't started // already then something is wrong so fall back // to generic outfits. JC - LLNotifications::instance().add("WelcomeChooseSex", LLSD(), LLSD(), + LLNotificationsUtil::add("WelcomeChooseSex", LLSD(), LLSD(), callback_choose_gender); LLStartUp::setStartupState( STATE_CLEANUP ); return TRUE; @@ -2816,7 +2813,7 @@ bool idle_startup() if (wearables_time > MAX_WEARABLES_TIME) { - LLNotifications::instance().add("ClothingLoading"); + LLNotificationsUtil::add("ClothingLoading"); LLViewerStats::getInstance()->incStat(LLViewerStats::ST_WEARABLES_TOO_LONG); LLStartUp::setStartupState( STATE_CLEANUP ); return TRUE; @@ -3104,7 +3101,7 @@ void LLStartUp::deletePasswordFromDisk() void show_first_run_dialog() { - LLNotifications::instance().add("FirstRun", LLSD(), LLSD(), first_run_dialog_callback); + LLNotificationsUtil::add("FirstRun", LLSD(), LLSD(), first_run_dialog_callback); } bool first_run_dialog_callback(const LLSD& notification, const LLSD& response) @@ -3391,7 +3388,7 @@ void use_circuit_callback(void**, S32 result) { // Make sure user knows something bad happened. JC LL_WARNS("AppInit") << "Backing up to login screen!" << LL_ENDL; - LLNotifications::instance().add("LoginPacketNeverReceived", LLSD(), LLSD(), login_alert_status); + LLNotificationsUtil::add("LoginPacketNeverReceived", LLSD(), LLSD(), login_alert_status); reset_login(); } else @@ -3978,33 +3975,33 @@ bool LLStartUp::handleSocksProxy(bool reportOK) case SOCKS_OK: if (reportOK == true) { - LLNotifications::instance().add("SOCKS_CONNECT_OK", subs); + LLNotificationsUtil::add("SOCKS_CONNECT_OK", subs); } return true; break; case SOCKS_CONNECT_ERROR: // TCP Fail - LLNotifications::instance().add("SOCKS_CONNECT_ERROR", subs); + LLNotificationsUtil::add("SOCKS_CONNECT_ERROR", subs); break; case SOCKS_NOT_PERMITTED: // Socks5 server rule set refused connection - LLNotifications::instance().add("SOCKS_NOT_PERMITTED", subs); + LLNotificationsUtil::add("SOCKS_NOT_PERMITTED", subs); break; case SOCKS_NOT_ACCEPTABLE: // Selected authentication is not acceptable to server - LLNotifications::instance().add("SOCKS_NOT_ACCEPTABLE", subs); + LLNotificationsUtil::add("SOCKS_NOT_ACCEPTABLE", subs); break; case SOCKS_AUTH_FAIL: // Authentication failed - LLNotifications::instance().add("SOCKS_AUTH_FAIL", subs); + LLNotificationsUtil::add("SOCKS_AUTH_FAIL", subs); break; case SOCKS_UDP_FWD_NOT_GRANTED: // UDP forward request failed - LLNotifications::instance().add("SOCKS_UDP_FWD_NOT_GRANTED", subs); + LLNotificationsUtil::add("SOCKS_UDP_FWD_NOT_GRANTED", subs); break; case SOCKS_HOST_CONNECT_FAILED: // Failed to open a TCP channel to the socks server - LLNotifications::instance().add("SOCKS_HOST_CONNECT_FAILED", subs); + LLNotificationsUtil::add("SOCKS_HOST_CONNECT_FAILED", subs); break; } diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index f897b6c50..5b0b508b5 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -80,6 +80,7 @@ #include "llfontgl.h" #include "llrect.h" #include "llerror.h" +#include "llnotificationsutil.h" #include "llparcel.h" #include "llstring.h" #include "message.h" @@ -792,7 +793,7 @@ static void onClickBuyCurrency(void* data) static void onClickHealth(void* ) { - LLNotifications::instance().add("NotSafe"); + LLNotificationsUtil::add("NotSafe"); } static void onClickScriptDebug(void*) @@ -802,22 +803,22 @@ static void onClickScriptDebug(void*) static void onClickFly(void* ) { - LLNotifications::instance().add("NoFly"); + LLNotificationsUtil::add("NoFly"); } static void onClickPush(void* ) { - LLNotifications::instance().add("PushRestricted"); + LLNotificationsUtil::add("PushRestricted"); } static void onClickVoice(void* ) { - LLNotifications::instance().add("NoVoice"); + LLNotificationsUtil::add("NoVoice"); } static void onClickBuild(void*) { - LLNotifications::instance().add("NoBuild"); + LLNotificationsUtil::add("NoBuild"); } static void onClickScripts(void*) @@ -825,15 +826,15 @@ static void onClickScripts(void*) LLViewerRegion* region = gAgent.getRegion(); if(region && region->getRegionFlags() & REGION_FLAGS_ESTATE_SKIP_SCRIPTS) { - LLNotifications::instance().add("ScriptsStopped"); + LLNotificationsUtil::add("ScriptsStopped"); } else if(region && region->getRegionFlags() & REGION_FLAGS_SKIP_SCRIPTS) { - LLNotifications::instance().add("ScriptsNotRunning"); + LLNotificationsUtil::add("ScriptsNotRunning"); } else { - LLNotifications::instance().add("NoOutsideScripts"); + LLNotificationsUtil::add("NoOutsideScripts"); } } diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp index 6d40b57ab..e0dc129ad 100644 --- a/indra/newview/llsurface.cpp +++ b/indra/newview/llsurface.cpp @@ -340,17 +340,28 @@ void LLSurface::setOriginGlobal(const LLVector3d &origin_global) } } +void LLSurface::getNeighboringRegions( std::vector& uniqueRegions ) +{ + S32 i; + for (i = 0; i < 8; i++) + { + if ( mNeighbors[i] != NULL ) + { + uniqueRegions.push_back( mNeighbors[i]->getRegion() ); + } + } +} void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction) { - S32 i; - LLSurfacePatch *patchp, *neighbor_patchp; - if (gNoRender) { return; } + S32 i; + LLSurfacePatch *patchp, *neighbor_patchp; + mNeighbors[direction] = neighborp; neighborp->mNeighbors[gDirOpposite[direction]] = this; @@ -688,14 +699,14 @@ void LLSurface::decompressDCTPatch(LLBitPack &bitpack, LLGroupHeader *gopp, BOOL } if (b_large_patch) - { - i = ph.patchids >> 16; //x - j = ph.patchids & 0xFFFF; //y - } - else - { - i = ph.patchids >> 5; //x - j = ph.patchids & 0x1F; //y + { + i = ph.patchids >> 16; //x + j = ph.patchids & 0xFFFF; //y + } + else + { + i = ph.patchids >> 5; //x + j = ph.patchids & 0x1F; //y } if ((i >= mPatchesPerEdge) || (j >= mPatchesPerEdge)) diff --git a/indra/newview/llsurface.h b/indra/newview/llsurface.h index 7e11b9a22..127bec465 100644 --- a/indra/newview/llsurface.h +++ b/indra/newview/llsurface.h @@ -146,6 +146,9 @@ public: friend class LLSurfacePatch; friend std::ostream& operator<<(std::ostream &s, const LLSurface &S); + + void getNeighboringRegions( std::vector& uniqueRegions ); + public: // Number of grid points on one side of a region, including +1 buffer for // north and east edge. diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp index 17a1a3ce9..e2ec067ca 100644 --- a/indra/newview/lltexlayer.cpp +++ b/indra/newview/lltexlayer.cpp @@ -266,11 +266,19 @@ BOOL LLTexLayerSetBuffer::render() BOOL upload_now = needsUploadNow(); BOOL success = TRUE; + //hack to use fixed function when updating tex layer sets + bool no_ff = LLGLSLShader::sNoFixedFunction; + static const LLCachedControl force_fixed_functions("ShyotlUseLegacyTextureBaking",true); + if(force_fixed_functions) + LLGLSLShader::sNoFixedFunction = false; + // Composite the color data LLGLSUIDefault gls_ui; success &= mTexLayerSet->render( mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight ); gGL.flush(); + LLGLSLShader::sNoFixedFunction = no_ff; + if( upload_now ) { if (!success) diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index 73583c769..4da777c5b 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -748,14 +748,13 @@ LLTextureCache::LLTextureCache(bool threaded) mTexturesSizeTotal(0), mDoPurge(FALSE) { - purgeTextureFilesTimeSliced(true); - clearDeleteList(); - writeUpdatedEntries(); } LLTextureCache::~LLTextureCache() { - purgeTextureFilesTimeSliced(TRUE); // VWR-3878 - NB - force-flush all pending file deletes + clearDeleteList(); + writeUpdatedEntries(); + purgeTextureFilesTimeSliced(true); // VWR-3878 - NB - force-flush all pending file deletes } ////////////////////////////////////////////////////////////////////////////// @@ -1556,7 +1555,7 @@ void LLTextureCache::purgeTextures(bool validate) return; } - if (!validate && mTexturesSizeTotal < sCacheMaxTexturesSize) + if (!validate && mTexturesSizeTotal <= sCacheMaxTexturesSize) { return; } @@ -1569,6 +1568,8 @@ void LLTextureCache::purgeTextures(bool validate) LLMutexLock lock(&mHeaderMutex); + llinfos << "TEXTURE CACHE: Purging." << llendl; + // Read the entries list std::vector entries; U32 num_entries = openAndReadEntries(entries); @@ -1597,10 +1598,10 @@ void LLTextureCache::purgeTextures(bool validate) } else { - LL_WARNS("TextureCache") << "mTexturesSizeMap / mHeaderIDMap corrupted." << LL_ENDL; - clearCorruptedCache(); - LLAppViewer::instance()->resumeMainloopTimeout(); - return; + llerrs << "mTexturesSizeMap / mHeaderIDMap corrupted." << llendl ; + //clearCorruptedCache(); + //LLAppViewer::instance()->resumeMainloopTimeout(); + //return; } } } @@ -1652,9 +1653,10 @@ void LLTextureCache::purgeTextures(bool validate) if (purge_entry) { purge_count++; + LL_DEBUGS("TextureCache") << "PURGING: " << filename << LL_ENDL; mFilesToDelete.insert(std::make_pair(entries[idx].mID, filename)); - cache_size -= entries[idx].mBodySize; removeEntry(idx, entries[idx], filename, false); // remove the entry but not the file + cache_size -= entries[idx].mBodySize; } } @@ -1662,26 +1664,17 @@ void LLTextureCache::purgeTextures(bool validate) writeEntriesAndClose(entries); - if (purge_count > 0) - { - writeEntriesAndClose(entries); - - LL_INFOS("TextureCache") << "TEXTURE CACHE:" - << " Purged: " << purge_count - << " - Entries: " << num_entries - << " - Cache size: " << mTexturesSizeTotal / (1024 * 1024) << " MB" - << " - Files scheduled for deletion: " << mFilesToDelete.size() - << LL_ENDL; - } - else - { - LL_INFOS("TextureCache") << "TEXTURE CACHE: nothing to purge." << LL_ENDL; - } - - // *FIX:Mani - watchdog back on. - LLAppViewer::instance()->resumeMainloopTimeout(); + // *FIX:Mani - watchdog back on. + LLAppViewer::instance()->resumeMainloopTimeout(); mSlicedPurgeTimer.reset(); + + LL_INFOS("TextureCache") << "TEXTURE CACHE:" + << " PURGED: " << purge_count + << " ENTRIES: " << num_entries + << " CACHE SIZE: " << mTexturesSizeTotal / (1024 * 1024) << " MB" + << llendl; + } void LLTextureCache::purgeTextureFilesTimeSliced(bool force) @@ -1947,8 +1940,7 @@ void LLTextureCache::removeCachedTexture(const LLUUID& id) mTexturesSizeMap.erase(id); } mHeaderIDMap.erase(id); - std::string filename = getTextureFileName(id); - LLAPRFile::remove(filename); + LLAPRFile::remove(getTextureFileName(id)); } //called after mHeaderMutex is locked. diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index d5e094b0f..a72d6b5e0 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -308,9 +308,9 @@ public: const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) { - static LLCachedControl log_to_viewer_log("LogTextureDownloadsToViewerLog",false); - static LLCachedControl log_to_sim("LogTextureDownloadsToSimulator",false); - static bool log_texture_traffic = false; + static LLCachedControl log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog"); + static LLCachedControl log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator"); + static LLCachedControl log_texture_traffic(gSavedSettings,"LogTextureNetworkTraffic") ; if (log_to_viewer_log || log_to_sim) { @@ -661,7 +661,6 @@ public: * Corresponds to LLTextureFetch::commandSendMetrics() */ -#if HTTP_METRICS class TFReqSendMetrics : public LLTextureFetch::TFRequest { public: @@ -705,7 +704,6 @@ public: const LLUUID mAgentID; LLViewerAssetStats * mMainStats; }; -#endif /* * Examines the merged viewer metrics report and if found to be too long, @@ -1131,7 +1129,7 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mState == LOAD_FROM_NETWORK) { - static const LLCachedControl use_http("ImagePipelineUseHTTP", false); + static LLCachedControl use_http(gSavedSettings,"ImagePipelineUseHTTP"); // if (mHost != LLHost::invalid) use_http = false; if (use_http && mCanUseHTTP && mUrl.empty()) // get http url. @@ -1486,7 +1484,7 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mState == DECODE_IMAGE) { - static LLCachedControl textures_decode_disabled("TextureDecodeDisabled", false); + static LLCachedControl textures_decode_disabled(gSavedSettings,"TextureDecodeDisabled"); if(textures_decode_disabled) { // for debug use, don't decode @@ -2360,12 +2358,13 @@ void LLTextureFetch::commonUpdate() //virtual S32 LLTextureFetch::update(U32 max_time_ms) { + static LLCachedControl band_width(gSavedSettings,"ThrottleBandwidthKBPS"); + { mNetworkQueueMutex.lock() ; - static const LLCachedControl max_bandwidth("ThrottleBandwidthKBPS", 2000); - mMaxBandwidth = max_bandwidth; - - gTextureList.sTextureBits += mHTTPTextureBits; + mMaxBandwidth = band_width ; + + gTextureList.sTextureBits += mHTTPTextureBits ; mHTTPTextureBits = 0 ; mNetworkQueueMutex.unlock() ; @@ -2567,8 +2566,8 @@ void LLTextureFetch::sendRequestListToSimulators() // llinfos << "IMAGE REQUEST: " << req->mID << " Discard: " << req->mDesiredDiscard // << " Packet: " << packet << " Priority: " << req->mImagePriority << llendl; - static LLCachedControl log_to_viewer_log("LogTextureDownloadsToViewerLog",false); - static LLCachedControl log_to_sim("LogTextureDownloadsToSimulator",false); + static LLCachedControl log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog"); + static LLCachedControl log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator"); if (log_to_viewer_log || log_to_sim) { mTextureInfo.setRequestStartTime(req->mID, LLTimer::getTotalTime()); @@ -2789,8 +2788,8 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U1 if(packet_num >= (worker->mTotalPackets - 1)) { - static LLCachedControl log_to_viewer_log("LogTextureDownloadsToViewerLog",false); - static LLCachedControl log_to_sim("LogTextureDownloadsToSimulator",false); + static LLCachedControl log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog"); + static LLCachedControl log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator"); if (log_to_viewer_log || log_to_sim) { diff --git a/indra/newview/lltool.cpp b/indra/newview/lltool.cpp index da9f3c5bd..1a11957fb 100644 --- a/indra/newview/lltool.cpp +++ b/indra/newview/lltool.cpp @@ -39,6 +39,7 @@ #include "llview.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "lltoolcomp.h" #include "lltoolfocus.h" #include "llfocusmgr.h" diff --git a/indra/newview/lltoolbar.cpp b/indra/newview/lltoolbar.cpp index 8b1325ea2..8f5c767a5 100644 --- a/indra/newview/lltoolbar.cpp +++ b/indra/newview/lltoolbar.cpp @@ -300,7 +300,7 @@ void LLToolBar::refresh() childSetEnabled("fly_btn", (gAgent.canFly() || gAgent.getFlying() || gSavedSettings.getBOOL("AscentFlyAlwaysEnabled")) && !sitting ); - childSetEnabled("build_btn", (LLViewerParcelMgr::getInstance()->agentCanBuild() || gSavedSettings.getBOOL("AscentBuildAlwaysEnabled")) ); + childSetEnabled("build_btn", (LLViewerParcelMgr::getInstance()->allowAgentBuild() || gSavedSettings.getBOOL("AscentBuildAlwaysEnabled")) ); // Check to see if we're in build mode BOOL build_mode = LLToolMgr::getInstance()->inEdit(); @@ -477,11 +477,6 @@ void LLToolBar::onClickAppearance(void*) void LLToolBar::onClickRadarList(void*) { LLFloaterAvatarList::toggle(0); - bool vis = false; - if(LLFloaterAvatarList::getInstance()) - { - vis = (bool)LLFloaterAvatarList::getInstance()->getVisible(); - } } diff --git a/indra/newview/lltoolbrush.cpp b/indra/newview/lltoolbrush.cpp index c42693d03..b1268fc1d 100644 --- a/indra/newview/lltoolbrush.cpp +++ b/indra/newview/lltoolbrush.cpp @@ -36,6 +36,7 @@ #include "lltoolselectland.h" #include "llgl.h" +#include "llnotificationsutil.h" #include "llrender.h" #include "message.h" @@ -43,6 +44,7 @@ #include "llagent.h" #include "llcallbacklist.h" #include "llviewercontrol.h" +#include "llwindow.h" #include "llfloatertools.h" #include "llregionposition.h" #include "llstatusbar.h" @@ -672,7 +674,7 @@ void LLToolBrushLand::alertNoTerraform(LLViewerRegion* regionp) LLSD args; args["REGION"] = regionp->getName(); - LLNotifications::instance().add("RegionNoTerraforming", args); + LLNotificationsUtil::add("RegionNoTerraforming", args); } diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 5da60b8b1..64fd39527 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -35,6 +35,8 @@ #include "message.h" #include "lltooldraganddrop.h" +#include "llnotificationsutil.h" + #include "llinstantmessage.h" #include "lldir.h" @@ -49,6 +51,7 @@ #include "llhudeffecttrail.h" #include "llhudmanager.h" #include "llinventorybridge.h" +#include "llinventorydefines.h" #include "llinventorymodel.h" #include "llinventoryview.h" #include "llmutelist.h" @@ -1086,7 +1089,7 @@ BOOL LLToolDragAndDrop::handleDropTextureProtections(LLViewerObject* hit_obj, hit_obj->fetchInventoryFromServer(); LLSD args; args["ERROR_MESSAGE"] = "Unable to add texture.\nPlease wait a few seconds and try again."; - LLNotifications::instance().add("ErrorMessage", args); + LLNotificationsUtil::add("ErrorMessage", args); return FALSE; } if (hit_obj->getInventoryItemByAsset(item->getAssetUUID())) @@ -1579,7 +1582,7 @@ void LLToolDragAndDrop::giveInventory(const LLUUID& to_agent, LLSD payload; payload["agent_id"] = to_agent; payload["item_id"] = item->getUUID(); - LLNotifications::instance().add("CannotCopyWarning", LLSD(), payload, + LLNotificationsUtil::add("CannotCopyWarning", LLSD(), payload, &LLToolDragAndDrop::handleCopyProtectedItem); } } @@ -1603,12 +1606,12 @@ bool LLToolDragAndDrop::handleCopyProtectedItem(const LLSD& notification, const } else { - LLNotifications::instance().add("CannotGiveItem"); + LLNotificationsUtil::add("CannotGiveItem"); } break; default: // no, cancel, whatever, who cares, not yes. - LLNotifications::instance().add("TransactionCancelled"); + LLNotificationsUtil::add("TransactionCancelled"); break; } return false; @@ -1708,18 +1711,18 @@ void LLToolDragAndDrop::giveInventoryCategory(const LLUUID& to_agent, } if(!complete) { - LLNotifications::instance().add("IncompleteInventory"); + LLNotificationsUtil::add("IncompleteInventory"); return; } count = items.count() + cats.count(); if(count > MAX_ITEMS) { - LLNotifications::instance().add("TooManyItems"); + LLNotificationsUtil::add("TooManyItems"); return; } else if(count == 0) { - LLNotifications::instance().add("NoItems"); + LLNotificationsUtil::add("NoItems"); return; } else @@ -1737,7 +1740,7 @@ void LLToolDragAndDrop::giveInventoryCategory(const LLUUID& to_agent, LLSD payload; payload["agent_id"] = to_agent; payload["folder_id"] = cat->getUUID(); - LLNotifications::instance().add("CannotCopyCountItems", args, payload, &LLToolDragAndDrop::handleCopyProtectedCategory); + LLNotificationsUtil::add("CannotCopyCountItems", args, payload, &LLToolDragAndDrop::handleCopyProtectedCategory); } } } @@ -1773,12 +1776,12 @@ bool LLToolDragAndDrop::handleCopyProtectedCategory(const LLSD& notification, co } else { - LLNotifications::instance().add("CannotGiveCategory"); + LLNotificationsUtil::add("CannotGiveCategory"); } break; default: // no, cancel, whatever, who cares, not yes. - LLNotifications::instance().add("TransactionCancelled"); + LLNotificationsUtil::add("TransactionCancelled"); break; } return false; @@ -1810,12 +1813,12 @@ void LLToolDragAndDrop::commitGiveInventoryCategory(const LLUUID& to_agent, S32 count = items.count() + cats.count(); if(count > MAX_ITEMS) { - LLNotifications::instance().add("TooManyItems"); + LLNotificationsUtil::add("TooManyItems"); return; } else if(count == 0) { - LLNotifications::instance().add("NoItems"); + LLNotificationsUtil::add("NoItems"); return; } else @@ -2561,7 +2564,7 @@ EAcceptance LLToolDragAndDrop::dad3dWearItem( // destroy clothing items. if (!gAgentWearables.areWearablesLoaded()) { - LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded"); + LLNotificationsUtil::add("CanNotChangeAppearanceUntilLoaded"); return ACCEPT_NO; } @@ -2628,7 +2631,7 @@ EAcceptance LLToolDragAndDrop::dad3dActivateGesture( } else { - gGestureManager.activateGesture(item->getUUID()); + LLGestureMgr::instance().activateGesture(item->getUUID()); gInventory.updateItem(item); gInventory.notifyObservers(); } @@ -2656,7 +2659,7 @@ EAcceptance LLToolDragAndDrop::dad3dWearCategory( // destroy clothing items. if (!gAgentWearables.areWearablesLoaded()) { - LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded"); + LLNotificationsUtil::add("CanNotChangeAppearanceUntilLoaded"); return ACCEPT_NO; } } diff --git a/indra/newview/lltoolgun.cpp b/indra/newview/lltoolgun.cpp index fa65eafd9..055236f43 100644 --- a/indra/newview/lltoolgun.cpp +++ b/indra/newview/lltoolgun.cpp @@ -49,6 +49,9 @@ #include "lltoolmgr.h" #include "lltoolgrab.h" +// Linden library includes +#include "llwindow.h" // setMouseClipping() + LLToolGun::LLToolGun( LLToolComposite* composite ) : LLTool( std::string("gun"), composite ), mIsSelected(FALSE) @@ -138,7 +141,7 @@ void LLToolGun::draw() { LLUIImagePtr crosshair = LLUI::getUIImage("UIImgCrosshairsUUID"); crosshair->draw( - ( gViewerWindow->getWindowWidth() - crosshair->getWidth() ) / 2, - ( gViewerWindow->getWindowHeight() - crosshair->getHeight() ) / 2); + ( gViewerWindow->getWorldViewRectScaled().getWidth() - crosshair->getWidth() ) / 2, + ( gViewerWindow->getWorldViewRectScaled().getHeight() - crosshair->getHeight() ) / 2); } } diff --git a/indra/newview/lltoolobjpicker.cpp b/indra/newview/lltoolobjpicker.cpp index d69688706..db150bbed 100644 --- a/indra/newview/lltoolobjpicker.cpp +++ b/indra/newview/lltoolobjpicker.cpp @@ -47,6 +47,7 @@ #include "llviewermenu.h" #include "llviewercamera.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "lldrawable.h" diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index e26e039e4..82e30203e 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -63,6 +63,7 @@ #include "llviewerobject.h" #include "llviewerparcelmgr.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llviewermedia.h" #include "llviewermediafocus.h" #include "llvoavatar.h" diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp index b2a61a4ac..4710a096a 100644 --- a/indra/newview/lltoolplacer.cpp +++ b/indra/newview/lltoolplacer.cpp @@ -50,6 +50,7 @@ #include "llviewerobject.h" #include "llviewerregion.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llworld.h" #include "llui.h" diff --git a/indra/newview/lltoolselectland.cpp b/indra/newview/lltoolselectland.cpp index f80b4e3ad..0c6637828 100644 --- a/indra/newview/lltoolselectland.cpp +++ b/indra/newview/lltoolselectland.cpp @@ -44,6 +44,7 @@ #include "llstatusbar.h" #include "llviewerparcelmgr.h" #include "llviewerwindow.h" +#include "llwindow.h" // // Member functions diff --git a/indra/newview/lltoolselectrect.cpp b/indra/newview/lltoolselectrect.cpp index 890666f34..f57820afd 100644 --- a/indra/newview/lltoolselectrect.cpp +++ b/indra/newview/lltoolselectrect.cpp @@ -48,6 +48,7 @@ #include "llviewerobject.h" #include "llviewerobjectlist.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llviewercamera.h" #include "llglheaders.h" diff --git a/indra/newview/lltracker.cpp b/indra/newview/lltracker.cpp index 299db5c1a..d5b66e61b 100644 --- a/indra/newview/lltracker.cpp +++ b/indra/newview/lltracker.cpp @@ -56,6 +56,7 @@ #include "llfloaterworldmap.h" #include "llhudtext.h" #include "llhudview.h" +#include "llinventorydefines.h" #include "llinventorymodel.h" #include "lllandmarklist.h" #include "llsky.h" diff --git a/indra/newview/lltrans.cpp b/indra/newview/lltrans.cpp index b6a2382a9..187782d5e 100644 --- a/indra/newview/lltrans.cpp +++ b/indra/newview/lltrans.cpp @@ -36,6 +36,7 @@ #include "llxmlnode.h" #include "lluictrlfactory.h" #include "llalertdialog.h" +#include "llnotificationsutil.h" #include @@ -93,7 +94,7 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil:: LLSD args; args["STRING_NAME"] = xml_desc; LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - LLNotifications::instance().add("MissingString", args); + LLNotificationsUtil::add("MissingString", args); return xml_desc; } diff --git a/indra/newview/llviewerassettype.cpp b/indra/newview/llviewerassettype.cpp index b0817f64b..5bab702cf 100644 --- a/indra/newview/llviewerassettype.cpp +++ b/indra/newview/llviewerassettype.cpp @@ -36,6 +36,7 @@ #include "llviewerassettype.h" #include "lldictionary.h" #include "llmemory.h" +#include "llsingleton.h" static const std::string empty_string; diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp index 9f6a5e8b1..d58a4d0f5 100644 --- a/indra/newview/llviewercamera.cpp +++ b/indra/newview/llviewercamera.cpp @@ -34,18 +34,10 @@ #include "llviewercamera.h" -#include // for setprecision - -#include "llquaternion.h" - #include "llagent.h" #include "llagentcamera.h" #include "llmatrix4a.h" #include "llviewercontrol.h" -#include "lldrawable.h" -#include "llface.h" -#include "llgl.h" -#include "llglheaders.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" #include "llviewerwindow.h" @@ -54,6 +46,17 @@ #include "lltoolmgr.h" #include "llviewerjoystick.h" +// Linden library includes +#include "lldrawable.h" +#include "llface.h" +#include "llgl.h" +#include "llglheaders.h" +#include "llquaternion.h" +#include "llwindow.h" // getPixelAspectRatio() + +// System includes +#include // for setprecision + U32 LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; //glu pick matrix implementation borrowed from Mesa3D @@ -114,15 +117,15 @@ LLViewerCamera::LLViewerCamera() : LLCamera() mZoomSubregion = 1; mAverageSpeed = 0.f; mAverageAngularSpeed = 0.f; + gSavedSettings.getControl("CameraAngle")->getCommitSignal()->connect(boost::bind(&LLViewerCamera::updateCameraAngle, this, _2)); } void LLViewerCamera::updateCameraLocation(const LLVector3 ¢er, const LLVector3 &up_direction, const LLVector3 &point_of_interest) { - // do not update if we are in build mode AND avatar didn't move - if (LLToolMgr::getInstance()->inBuildMode() - && !LLViewerJoystick::getInstance()->getCameraNeedsUpdate()) + // do not update if avatar didn't move + if (!LLViewerJoystick::getInstance()->getCameraNeedsUpdate()) { return; } @@ -332,7 +335,12 @@ void LLViewerCamera::setPerspective(BOOL for_selection, { // make a tiny little viewport // anything drawn into this viewport will be "selected" - GLint* viewport = (GLint*) gGLViewport; + + GLint viewport[4]; + viewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; + viewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; + viewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); + viewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); proj_mat = gl_pick_matrix(x+width/2.f, y_from_bot+height/2.f, (GLfloat) width, (GLfloat) height, viewport); @@ -399,10 +407,13 @@ void LLViewerCamera::setPerspective(BOOL for_selection, if (for_selection && (width > 1 || height > 1)) { - calculateFrustumPlanesFromWindow((F32)(x - width / 2) / (F32)gViewerWindow->getWindowWidth() - 0.5f, - (F32)(y_from_bot - height / 2) / (F32)gViewerWindow->getWindowHeight() - 0.5f, - (F32)(x + width / 2) / (F32)gViewerWindow->getWindowWidth() - 0.5f, - (F32)(y_from_bot + height / 2) / (F32)gViewerWindow->getWindowHeight() - 0.5f); + // NB: as of this writing, i believe the code below is broken (doesn't take into account the world view, assumes entire window) + // however, it is also unused (the GL matricies are used for selection, (see LLCamera::sphereInFrustum())) and so i'm not + // comfortable hacking on it. + calculateFrustumPlanesFromWindow((F32)(x - width / 2) / (F32)gViewerWindow->getWindowWidthScaled() - 0.5f, + (F32)(y_from_bot - height / 2) / (F32)gViewerWindow->getWindowHeightScaled() - 0.5f, + (F32)(x + width / 2) / (F32)gViewerWindow->getWindowWidthScaled() - 0.5f, + (F32)(y_from_bot + height / 2) / (F32)gViewerWindow->getWindowHeightScaled() - 0.5f); } @@ -467,8 +478,15 @@ BOOL LLViewerCamera::projectPosAgentToScreen(const LLVector3 &pos_agent, LLCoord } } + LLRect world_view_rect = gViewerWindow->getWorldViewRectRaw(); + S32 viewport[4]; + viewport[0] = world_view_rect.mLeft; + viewport[1] = world_view_rect.mBottom; + viewport[2] = world_view_rect.getWidth(); + viewport[3] = world_view_rect.getHeight(); + if (GL_TRUE == gluProject(pos_agent.mV[VX], pos_agent.mV[VY], pos_agent.mV[VZ], - gGLModelView, gGLProjection, (GLint*)gGLViewport, + gGLModelView, gGLProjection, (GLint*)viewport, &x, &y, &z)) { // convert screen coordinates to virtual UI coordinates @@ -476,7 +494,7 @@ BOOL LLViewerCamera::projectPosAgentToScreen(const LLVector3 &pos_agent, LLCoord y /= gViewerWindow->getDisplayScale().mV[VY]; // should now have the x,y coords of grab_point in screen space - const LLRect& window_rect = gViewerWindow->getWindowRect(); + LLRect world_rect = gViewerWindow->getWorldViewRectScaled(); // ...sanity check S32 int_x = lltrunc(x); @@ -486,14 +504,14 @@ BOOL LLViewerCamera::projectPosAgentToScreen(const LLVector3 &pos_agent, LLCoord if (clamp) { - if (int_x < window_rect.mLeft) + if (int_x < world_rect.mLeft) { - out_point.mX = window_rect.mLeft; + out_point.mX = world_rect.mLeft; valid = FALSE; } - else if (int_x > window_rect.mRight) + else if (int_x > world_rect.mRight) { - out_point.mX = window_rect.mRight; + out_point.mX = world_rect.mRight; valid = FALSE; } else @@ -501,14 +519,14 @@ BOOL LLViewerCamera::projectPosAgentToScreen(const LLVector3 &pos_agent, LLCoord out_point.mX = int_x; } - if (int_y < window_rect.mBottom) + if (int_y < world_rect.mBottom) { - out_point.mY = window_rect.mBottom; + out_point.mY = world_rect.mBottom; valid = FALSE; } - else if (int_y > window_rect.mTop) + else if (int_y > world_rect.mTop) { - out_point.mY = window_rect.mTop; + out_point.mY = world_rect.mTop; valid = FALSE; } else @@ -522,19 +540,19 @@ BOOL LLViewerCamera::projectPosAgentToScreen(const LLVector3 &pos_agent, LLCoord out_point.mX = int_x; out_point.mY = int_y; - if (int_x < window_rect.mLeft) + if (int_x < world_rect.mLeft) { valid = FALSE; } - else if (int_x > window_rect.mRight) + else if (int_x > world_rect.mRight) { valid = FALSE; } - if (int_y < window_rect.mBottom) + if (int_y < world_rect.mBottom) { valid = FALSE; } - else if (int_y > window_rect.mTop) + else if (int_y > world_rect.mTop) { valid = FALSE; } @@ -563,24 +581,30 @@ BOOL LLViewerCamera::projectPosAgentToScreenEdge(const LLVector3 &pos_agent, in_front = FALSE; } + LLRect world_view_rect = gViewerWindow->getWorldViewRectRaw(); + S32 viewport[4]; + viewport[0] = world_view_rect.mLeft; + viewport[1] = world_view_rect.mBottom; + viewport[2] = world_view_rect.getWidth(); + viewport[3] = world_view_rect.getHeight(); GLdouble x, y, z; // object's window coords, GL-style if (GL_TRUE == gluProject(pos_agent.mV[VX], pos_agent.mV[VY], pos_agent.mV[VZ], gGLModelView, - gGLProjection, (GLint*)gGLViewport, + gGLProjection, (GLint*)viewport, &x, &y, &z)) { x /= gViewerWindow->getDisplayScale().mV[VX]; y /= gViewerWindow->getDisplayScale().mV[VY]; // should now have the x,y coords of grab_point in screen space - const LLRect& window_rect = gViewerWindow->getVirtualWindowRect(); + const LLRect& world_rect = gViewerWindow->getWorldViewRectScaled(); // ...sanity check S32 int_x = lltrunc(x); S32 int_y = lltrunc(y); // find the center - GLdouble center_x = (GLdouble)(0.5f * (window_rect.mLeft + window_rect.mRight)); - GLdouble center_y = (GLdouble)(0.5f * (window_rect.mBottom + window_rect.mTop)); + GLdouble center_x = (GLdouble)world_rect.getCenterX(); + GLdouble center_y = (GLdouble)world_rect.getCenterY(); if (x == center_x && y == center_y) { @@ -601,41 +625,41 @@ BOOL LLViewerCamera::projectPosAgentToScreenEdge(const LLVector3 &pos_agent, // the slope of the line is undefined if (line_y > 0.f) { - int_y = window_rect.mTop; + int_y = world_rect.mTop; } else { - int_y = window_rect.mBottom; + int_y = world_rect.mBottom; } } - else if (0 == window_rect.getWidth()) + else if (0 == world_rect.getWidth()) { // the diagonal slope of the view is undefined - if (y < window_rect.mBottom) + if (y < world_rect.mBottom) { - int_y = window_rect.mBottom; + int_y = world_rect.mBottom; } - else if ( y > window_rect.mTop) + else if ( y > world_rect.mTop) { - int_y = window_rect.mTop; + int_y = world_rect.mTop; } } else { F32 line_slope = (F32)(line_y / line_x); - F32 rect_slope = ((F32)window_rect.getHeight()) / ((F32)window_rect.getWidth()); + F32 rect_slope = ((F32)world_rect.getHeight()) / ((F32)world_rect.getWidth()); if (fabs(line_slope) > rect_slope) { if (line_y < 0.f) { // bottom - int_y = window_rect.mBottom; + int_y = world_rect.mBottom; } else { // top - int_y = window_rect.mTop; + int_y = world_rect.mTop; } int_x = lltrunc(((GLdouble)int_y - center_y) / line_slope + center_x); } @@ -644,12 +668,12 @@ BOOL LLViewerCamera::projectPosAgentToScreenEdge(const LLVector3 &pos_agent, if (line_x < 0.f) { // left - int_x = window_rect.mLeft; + int_x = world_rect.mLeft; } else { // right - int_x = window_rect.mRight; + int_x = world_rect.mRight; } int_y = lltrunc(((GLdouble)int_x - center_x) * line_slope + center_y); } @@ -658,29 +682,30 @@ BOOL LLViewerCamera::projectPosAgentToScreenEdge(const LLVector3 &pos_agent, // exactly parallel ==> push to the corners if (line_x > 0.f) { - int_x = window_rect.mRight; + int_x = world_rect.mRight; } else { - int_x = window_rect.mLeft; + int_x = world_rect.mLeft; } if (line_y > 0.0f) { - int_y = window_rect.mTop; + int_y = world_rect.mTop; } else { - int_y = window_rect.mBottom; + int_y = world_rect.mBottom; } } } if (!in_front) { - int_x = window_rect.mLeft + window_rect.mRight - int_x; - int_y = window_rect.mBottom + window_rect.mTop - int_y; + int_x = world_rect.mLeft + world_rect.mRight - int_x; + int_y = world_rect.mBottom + world_rect.mTop - int_y; } - out_point.mX = int_x; - out_point.mY = int_y; + + out_point.mX = int_x + world_rect.mLeft; + out_point.mY = int_y + world_rect.mBottom; return TRUE; } return FALSE; @@ -832,3 +857,10 @@ void LLViewerCamera::setDefaultFOV(F32 vertical_fov_rads) mCosHalfCameraFOV = cosf(mCameraFOVDefault * 0.5f); } + +// static +void LLViewerCamera::updateCameraAngle( void* user_data, const LLSD& value) +{ + LLViewerCamera* self=(LLViewerCamera*)user_data; + self->setDefaultFOV(value.asReal()); +} diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h index 1fcda6362..2b8a0892b 100644 --- a/indra/newview/llviewercamera.h +++ b/indra/newview/llviewercamera.h @@ -34,8 +34,9 @@ #define LL_LLVIEWERCAMERA_H #include "llcamera.h" -#include "lltimer.h" +#include "llsingleton.h" #include "llstat.h" +#include "lltimer.h" #include "m4math.h" class LLCoordGL; @@ -79,6 +80,7 @@ public: const LLVector3 &point_of_interest); static void updateFrustumPlanes(LLCamera& camera, BOOL ortho = FALSE, BOOL zflip = FALSE, BOOL no_hacks = FALSE); + static void updateCameraAngle(void* user_data, const LLSD& value); void setPerspective(BOOL for_selection, S32 x, S32 y_from_bot, S32 width, S32 height, BOOL limit_select_distance, F32 z_near = 0, F32 z_far = 0); const LLMatrix4 &getProjection() const; diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index e19923f5a..0f13fbb3d 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -54,6 +54,7 @@ #include "llviewertexturelist.h" #include "llviewerthrottle.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llvoavatar.h" #include "llvoiceclient.h" #include "llvosky.h" @@ -522,6 +523,30 @@ bool handleVectorizeChanged(const LLSD& newvalue) return true; } +bool handleVelocityInterpolate(const LLSD& newvalue) +{ + LLMessageSystem* msg = gMessageSystem; + if ( newvalue.asBoolean() ) + { + msg->newMessageFast(_PREHASH_VelocityInterpolateOn); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + gAgent.sendReliableMessage(); + llinfos << "Velocity Interpolation On" << llendl; + } + else + { + msg->newMessageFast(_PREHASH_VelocityInterpolateOff); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + gAgent.sendReliableMessage(); + llinfos << "Velocity Interpolation Off" << llendl; + } + return true; +} + bool handleVoiceClientPrefsChanged(const LLSD& newvalue) { if(gVoiceClient) @@ -610,6 +635,7 @@ void settings_setup_listeners() gSavedSettings.getControl("OctreeMaxNodeCapacity")->getSignal()->connect(boost::bind(&handleRepartition, _2)); gSavedSettings.getControl("OctreeAlphaDistanceFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2)); gSavedSettings.getControl("OctreeAttachmentSizeFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2)); + gSavedSettings.getControl("RenderMaxTextureIndex")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2)); gSavedSettings.getControl("RenderAnimateTrees")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2)); gSavedSettings.getControl("RenderAvatarVP")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2)); gSavedSettings.getControl("VertexShaderEnable")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2)); @@ -647,6 +673,8 @@ void settings_setup_listeners() //See LL jira VWR-3258 comment section. Implemented by LL in 2.1 -Shyotl gSavedSettings.getControl("ShyotlRenderUseStreamVBO")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2)); gSavedSettings.getControl("ShyotlRenderVBOStrideMode")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2)); + gSavedSettings.getControl("ShyotlUseLegacyRenderPath")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2)); + gSavedSettings.getControl("ShyotlUseLegacyTextureBatching")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2)); gSavedSettings.getControl("SianaRenderOmitBlankVBO")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2)); gSavedSettings.getControl("RenderUseFBO")->getSignal()->connect(boost::bind(&handleRenderUseFBOChanged, _2)); gSavedSettings.getControl("RenderDeferredNoise")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2)); @@ -747,6 +775,7 @@ void settings_setup_listeners() gSavedSettings.getControl("VoiceOutputAudioDevice")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _2)); gSavedSettings.getControl("AudioLevelMic")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _2)); gSavedSettings.getControl("LipSyncEnabled")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _2)); + gSavedSettings.getControl("VelocityInterpolate")->getSignal()->connect(boost::bind(&handleVelocityInterpolate, _2)); gSavedSettings.getControl("TranslateChat")->getSignal()->connect(boost::bind(&handleTranslateChatPrefsChanged, _2)); gSavedSettings.getControl("StateMachineMaxTime")->getSignal()->connect(boost::bind(&handleStateMachineMaxTimeChanged, _2)); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 8c7839cb5..bef35f755 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -191,8 +191,8 @@ void display_update_camera(bool tiling=false) gViewerWindow->setup3DRender(); // update all the sky/atmospheric/water settings - LLWLParamManager::instance()->update(LLViewerCamera::getInstance()); - LLWaterParamManager::instance()->update(LLViewerCamera::getInstance()); + LLWLParamManager::getInstance()->update(LLViewerCamera::getInstance()); + LLWaterParamManager::getInstance()->update(LLViewerCamera::getInstance()); // Update land visibility too LLWorld::getInstance()->setLandFarClip(final_far); @@ -586,7 +586,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo } } - gViewerWindow->setupViewport(); + gViewerWindow->setup3DViewport(); gPipeline.resetFrameStats(); // Reset per-frame statistics. if (!gDisconnected) @@ -619,6 +619,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo gPipeline.createObjects(max_geom_update_time); gPipeline.processPartitionQ(); gPipeline.updateGeom(max_geom_update_time); + stop_glerror(); gPipeline.updateGL(); stop_glerror(); @@ -649,6 +650,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo && LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") && gSavedSettings.getBOOL("UseOcclusion") && gGLManager.mHasOcclusionQuery) ? 2 : 0; + LLTexUnit::sWhiteTexture = LLViewerFetchedTexture::sWhiteImagep->getTexName(); /*if (LLPipeline::sUseOcclusion && LLPipeline::sRenderDeferred) { //force occlusion on for all render types if doing deferred render @@ -680,7 +682,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); - BOOL to_texture = gPipeline.canUseVertexShaders() && LLPipeline::sRenderGlow; + BOOL to_texture = gPipeline.canUseVertexShaders() && + LLPipeline::sRenderGlow; LLAppViewer::instance()->pingMainloopTimeout("Display:Swap"); @@ -729,7 +732,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo glLoadMatrixf(proj.m); glMatrixMode(GL_MODELVIEW); glLoadMatrixf(mod.m); - gViewerWindow->setupViewport(); + gViewerWindow->setup3DViewport(); LLGLState::checkStates(); LLGLState::checkTextureChannels(); @@ -739,12 +742,18 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } + LLGLState::checkStates(); + LLGLState::checkClientArrays(); + if (!for_snapshot || tiling) { LLAppViewer::instance()->pingMainloopTimeout("Display:Imagery"); gPipeline.generateWaterReflection(*LLViewerCamera::getInstance()); } + LLGLState::checkStates(); + LLGLState::checkClientArrays(); + ////////////////////////////////////// // // Update images, using the image stats generated during object update/culling @@ -774,6 +783,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo stop_glerror(); } llpushcallstacks ; + LLGLState::checkStates(); + LLGLState::checkClientArrays(); /////////////////////////////////// // // StateSort @@ -802,6 +813,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo } } + LLGLState::checkStates(); + LLGLState::checkClientArrays(); + LLPipeline::sUseOcclusion = occlusion; { @@ -862,6 +876,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE; LLPipeline::updateRenderDeferred(); + LLGLState::checkStates(); + LLGLState::checkClientArrays(); + stop_glerror(); if (to_texture) @@ -870,7 +887,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) { gPipeline.mDeferredScreen.bindTarget(); - glClearColor(0,0,0,0); + glClearColor(1,0,1,1); gPipeline.mDeferredScreen.clear(); } else if(!tiling) @@ -910,6 +927,14 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo stop_glerror(); } + for (U32 i = 0; i < (U32)gGLManager.mNumTextureImageUnits; i++) + { //dummy cleanup of any currently bound textures + if (gGL.getTexUnit(i)->getCurrType() != LLTexUnit::TT_NONE) + { + gGL.getTexUnit(i)->unbind(gGL.getTexUnit(i)->getCurrType()); + gGL.getTexUnit(i)->disable(); + } + } LLAppViewer::instance()->pingMainloopTimeout("Display:RenderFlush"); if (to_texture) @@ -1031,7 +1056,6 @@ void render_hud_attachments() S32 use_occlusion = LLPipeline::sUseOcclusion; LLPipeline::sUseOcclusion = 0; - LLPipeline::sDisableShaders = TRUE; //cull, sort, and render hud objects static LLCullResult result; @@ -1060,6 +1084,7 @@ void render_hud_attachments() gPipeline.renderGeom(hud_cam); LLSpatialGroup::sNoDelete = FALSE; + //gPipeline.clearReferences(); render_hud_elements(); @@ -1071,7 +1096,6 @@ void render_hud_attachments() gPipeline.toggleRenderDebugFeature((void*) LLPipeline::RENDER_DEBUG_FEATURE_UI); } LLPipeline::sUseOcclusion = use_occlusion; - LLPipeline::sDisableShaders = FALSE; } glMatrixMode(GL_PROJECTION); glPopMatrix(); @@ -1084,20 +1108,20 @@ void render_hud_attachments() LLRect get_whole_screen_region() { - LLRect whole_screen = gViewerWindow->getVirtualWindowRect(); - + LLRect whole_screen = gViewerWindow->getWorldViewRectScaled(); + // apply camera zoom transform (for high res screenshots) F32 zoom_factor = LLViewerCamera::getInstance()->getZoomFactor(); S16 sub_region = LLViewerCamera::getInstance()->getZoomSubRegion(); if (zoom_factor > 1.f) { S32 num_horizontal_tiles = llceil(zoom_factor); - S32 tile_width = llround((F32)gViewerWindow->getWindowWidth() / zoom_factor); - S32 tile_height = llround((F32)gViewerWindow->getWindowHeight() / zoom_factor); + S32 tile_width = llround((F32)gViewerWindow->getWorldViewWidthScaled() / zoom_factor); + S32 tile_height = llround((F32)gViewerWindow->getWorldViewHeightScaled() / zoom_factor); int tile_y = sub_region / num_horizontal_tiles; int tile_x = sub_region - (tile_y * num_horizontal_tiles); - - whole_screen.setLeftTopAndSize(tile_x * tile_width, gViewerWindow->getWindowHeight() - (tile_y * tile_height), tile_width, tile_height); + + whole_screen.setLeftTopAndSize(tile_x * tile_width, gViewerWindow->getWorldViewHeightScaled() - (tile_y * tile_height), tile_width, tile_height); } return whole_screen; } @@ -1116,14 +1140,14 @@ bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::mat proj.element(2,2) = -0.01f; F32 aspect_ratio = LLViewerCamera::getInstance()->getAspect(); - + glh::matrix4f mat; - F32 scale_x = (F32)gViewerWindow->getWindowWidth() / (F32)screen_region.getWidth(); - F32 scale_y = (F32)gViewerWindow->getWindowHeight() / (F32)screen_region.getHeight(); + F32 scale_x = (F32)gViewerWindow->getWorldViewWidthScaled() / (F32)screen_region.getWidth(); + F32 scale_y = (F32)gViewerWindow->getWorldViewHeightScaled() / (F32)screen_region.getHeight(); mat.set_scale(glh::vec3f(scale_x, scale_y, 1.f)); mat.set_translate( - glh::vec3f(clamp_rescale((F32)screen_region.getCenterX(), 0.f, (F32)gViewerWindow->getWindowWidth(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio), - clamp_rescale((F32)screen_region.getCenterY(), 0.f, (F32)gViewerWindow->getWindowHeight(), 0.5f * scale_y, -0.5f * scale_y), + glh::vec3f(clamp_rescale((F32)(screen_region.getCenterX() - screen_region.mLeft), 0.f, (F32)gViewerWindow->getWorldViewWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio), + clamp_rescale((F32)(screen_region.getCenterY() - screen_region.mBottom), 0.f, (F32)gViewerWindow->getWorldViewHeightScaled(), 0.5f * scale_y, -0.5f * scale_y), 0.f)); proj *= mat; @@ -1375,19 +1399,19 @@ void render_ui_2d() int pos_y = sub_region / llceil(zoom_factor); int pos_x = sub_region - (pos_y*llceil(zoom_factor)); // offset for this tile - LLFontGL::sCurOrigin.mX -= llround((F32)gViewerWindow->getWindowWidth() * (F32)pos_x / zoom_factor); - LLFontGL::sCurOrigin.mY -= llround((F32)gViewerWindow->getWindowHeight() * (F32)pos_y / zoom_factor); + LLFontGL::sCurOrigin.mX -= llround((F32)gViewerWindow->getWindowWidthScaled() * (F32)pos_x / zoom_factor); + LLFontGL::sCurOrigin.mY -= llround((F32)gViewerWindow->getWindowHeightScaled() * (F32)pos_y / zoom_factor); } stop_glerror(); - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + //gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); // render outline for HUD - if (gAgent.getAvatarObject() && gAgentCamera.mHUDCurZoom < 0.98f) + if (isAgentAvatarValid() && gAgentCamera.mHUDCurZoom < 0.98f) { gGL.pushMatrix(); - S32 half_width = (gViewerWindow->getWindowWidth() / 2); - S32 half_height = (gViewerWindow->getWindowHeight() / 2); + S32 half_width = (gViewerWindow->getWorldViewWidthScaled() / 2); + S32 half_height = (gViewerWindow->getWorldViewHeightScaled() / 2); glScalef(LLUI::sGLScaleFactor.mV[0], LLUI::sGLScaleFactor.mV[1], 1.f); glTranslatef((F32)half_width, (F32)half_height, 0.f); F32 zoom = gAgentCamera.mHUDCurZoom; @@ -1455,8 +1479,8 @@ void render_disconnected_background() } // Make sure the progress view always fills the entire window. - S32 width = gViewerWindow->getWindowWidth(); - S32 height = gViewerWindow->getWindowHeight(); + S32 width = gViewerWindow->getWindowWidthScaled(); + S32 height = gViewerWindow->getWindowHeightScaled(); if (gDisconnectedImagep) { diff --git a/indra/newview/llviewerdisplayname.cpp b/indra/newview/llviewerdisplayname.cpp index 8aca75b43..f4f23c85a 100644 --- a/indra/newview/llviewerdisplayname.cpp +++ b/indra/newview/llviewerdisplayname.cpp @@ -23,9 +23,7 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ -/* -Ported to Phoenix by Wolfspirit Magic. -*/ + #include "llviewerprecompiledheaders.h" #include "llviewerdisplayname.h" @@ -39,7 +37,7 @@ Ported to Phoenix by Wolfspirit Magic. #include "llavatarnamecache.h" #include "llhttpclient.h" #include "llhttpnode.h" -#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llui.h" // getLanguage() namespace LLViewerDisplayName @@ -194,7 +192,7 @@ class LLDisplayNameUpdate : public LLHTTPNode args["OLD_NAME"] = old_display_name; args["SLID"] = av_name.mUsername; args["NEW_NAME"] = av_name.mDisplayName; - LLNotifications::instance().add("DisplayNameUpdate", args); + LLNotificationsUtil::add("DisplayNameUpdate", args); if (agent_id == gAgent.getID()) { LLViewerDisplayName::sNameChangedSignal(); diff --git a/indra/newview/llviewerdisplayname.h b/indra/newview/llviewerdisplayname.h index 6066cc880..16d59ae43 100644 --- a/indra/newview/llviewerdisplayname.h +++ b/indra/newview/llviewerdisplayname.h @@ -23,9 +23,7 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ -/* -Ported to Phoenix by Wolfspirit Magic. -*/ + #ifndef LLVIEWERDISPLAYNAME_H #define LLVIEWERDISPLAYNAME_H diff --git a/indra/newview/llviewergenericmessage.cpp b/indra/newview/llviewergenericmessage.cpp index 1aa4919ac..796a49fa4 100644 --- a/indra/newview/llviewergenericmessage.cpp +++ b/indra/newview/llviewergenericmessage.cpp @@ -109,7 +109,7 @@ void process_generic_message(LLMessageSystem* msg, void**) Meta7WindlightPacket* wl = (Meta7WindlightPacket*)buf; - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamManager * param_mgr = LLWaterParamManager::getInstance(); LLWaterParamSet & param_set = param_mgr->mCurParams; LLWaterParamSet backup; if(!param_mgr->getParamSet("LightShare-Backup", backup)) { @@ -154,7 +154,7 @@ void process_generic_message(LLMessageSystem* msg, void**) param_mgr->setParamSet( "LightShare-CurrentRegion", param_set); param_mgr->setNormalMapID(normalMapTexture); - LLWLParamManager * wl_param_mgr = LLWLParamManager::instance(); + LLWLParamManager * wl_param_mgr = LLWLParamManager::getInstance(); LLWLParamSet & wl_param_set = wl_param_mgr->mCurParams; LLWLParamSet wl_backup; if(!wl_param_mgr->getParamSet("LightShare-Backup", wl_backup)) { @@ -187,8 +187,8 @@ void process_generic_message(LLMessageSystem* msg, void**) wl_param_mgr->removeParamSet("LightShare-CurrentRegion",true); wl_param_mgr->addParamSet( "LightShare-CurrentRegion", wl_param_set); wl_param_mgr->savePreset( "LightShare-CurrentRegion"); - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.mIsRunning = false; + LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = false; wl_param_mgr->loadPreset( "LightShare-CurrentRegion",true); } } diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 21f26d7dd..ef2c4e9ab 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -33,6 +33,7 @@ #include "llviewerprecompiledheaders.h" #include "llviewerinventory.h" +#include "llnotificationsutil.h" #include "message.h" #include "indra_constants.h" @@ -46,6 +47,7 @@ #include "llgesturemgr.h" #include "llinventorybridge.h" +#include "llinventorydefines.h" #include "llinventoryview.h" #include "llviewerregion.h" @@ -192,7 +194,7 @@ void LLViewerInventoryItem::updateServer(BOOL is_new) const // *FIX: deal with this better. llwarns << "LLViewerInventoryItem::updateServer() - for incomplete item" << llendl; - LLNotifications::instance().add("IncompleteInventoryItem"); + LLNotificationsUtil::add("IncompleteInventoryItem"); return; } LLInventoryModel::LLCategoryUpdate up(mParentUUID, is_new ? 1 : 0); @@ -443,7 +445,7 @@ void LLViewerInventoryCategory::updateServer(BOOL is_new) const // communicate that change with the server. if ( (LLFolderType::FT_NONE != mPreferredType) && (LLFolderType::FT_OUTFIT != mPreferredType) ) { - LLNotifications::instance().add("CannotModifyProtectedCategories"); + LLNotificationsUtil::add("CannotModifyProtectedCategories"); return; } @@ -467,7 +469,7 @@ void LLViewerInventoryCategory::removeFromServer( void ) // communicate that change with the server. if ( (LLFolderType::FT_NONE != mPreferredType) && (LLFolderType::FT_OUTFIT != mPreferredType) ) { - LLNotifications::instance().add("CannotRemoveProtectedCategories"); + LLNotificationsUtil::add("CannotRemoveProtectedCategories"); return; } @@ -719,13 +721,12 @@ void RezAttachmentCallback::fire(const LLUUID& inv_item) } } -extern LLGestureManager gGestureManager; void ActivateGestureCallback::fire(const LLUUID& inv_item) { if (inv_item.isNull()) return; - gGestureManager.activateGesture(inv_item); + LLGestureMgr::instance().activateGesture(inv_item); } void CreateGestureCallback::fire(const LLUUID& inv_item) @@ -733,7 +734,7 @@ void CreateGestureCallback::fire(const LLUUID& inv_item) if (inv_item.isNull()) return; - gGestureManager.activateGesture(inv_item); + LLGestureMgr::instance().activateGesture(inv_item); LLViewerInventoryItem* item = gInventory.getItem(inv_item); if (!item) return; diff --git a/indra/newview/llviewerjoint.cpp b/indra/newview/llviewerjoint.cpp index 8f2006b43..aa8c78296 100644 --- a/indra/newview/llviewerjoint.cpp +++ b/indra/newview/llviewerjoint.cpp @@ -263,7 +263,7 @@ U32 LLViewerJoint::render( F32 pixelArea, BOOL first_pass, BOOL is_dummy ) // if object is transparent, defer it, otherwise // give the joint subclass a chance to draw itself //---------------------------------------------------------------- - if ( gRenderForSelect || is_dummy ) + if ( is_dummy ) { triangle_count += drawShape( pixelArea, first_pass, is_dummy ); } diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index 762218711..d457a1a2d 100644 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -68,7 +68,6 @@ extern PFNGLWEIGHTPOINTERARBPROC glWeightPointerARB; extern PFNGLWEIGHTFVARBPROC glWeightfvARB; extern PFNGLVERTEXBLENDARBPROC glVertexBlendARB; #endif -extern BOOL gRenderForSelect; static LLPointer sRenderBuffer = NULL; static const U32 sRenderMask = LLVertexBuffer::MAP_VERTEX | @@ -533,17 +532,14 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) //---------------------------------------------------------------- // setup current color //---------------------------------------------------------------- - if (!gRenderForSelect) - { - if (is_dummy) - glColor4fv(LLVOAvatar::getDummyColor().mV); - else - glColor4fv(mColor.mV); - } + if (is_dummy) + glColor4fv(LLVOAvatar::getDummyColor().mV); + else + glColor4fv(mColor.mV); stop_glerror(); - LLGLSSpecular specular(LLColor4(1.f,1.f,1.f,1.f), (mFace->getPool()->getVertexShaderLevel() > 0 && !gRenderForSelect) ? 0.f : mShiny); + LLGLSSpecular specular(LLColor4(1.f,1.f,1.f,1.f), (mFace->getPool()->getVertexShaderLevel() > 0) ? 0.f : mShiny); //---------------------------------------------------------------- // setup current texture @@ -598,19 +594,6 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) gGL.getTexUnit(diffuse_channel)->bind(LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT_AVATAR)); } - if (gRenderForSelect) - { - if (isTransparent()) - { - gGL.getTexUnit(diffuse_channel)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); - gGL.getTexUnit(diffuse_channel)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_CONST_ALPHA); - } - else - { - gGL.getTexUnit(diffuse_channel)->unbind(LLTexUnit::TT_TEXTURE); - } - } - mFace->getVertexBuffer()->setBuffer(sRenderMask); U32 start = mMesh->mFaceVertexOffset; @@ -729,8 +712,7 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w verticesp.assignArray((U8*)mMesh->getCoords(), sizeof(mMesh->getCoords()[0]), num_verts); //LLVector4a::memcpyNonAliased16(n, (F32*) mMesh->getNormals(), words*sizeof(F32)); normalsp.assignArray((U8*)mMesh->getNormals(), sizeof(mMesh->getNormals()[0]), num_verts); - - + if (!terse_update) { vertex_weightsp += mMesh->mFaceVertexOffset; @@ -746,7 +728,7 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w //LLVector4a::memcpyNonAliased16(vw, (F32*) mMesh->getWeights(), num_verts*sizeof(F32)); vertex_weightsp.assignArray((U8*)mMesh->getWeights(), sizeof(mMesh->getWeights()[0]), num_verts); //LLVector4a::memcpyNonAliased16(cw, (F32*) mMesh->getClothingWeights(), num_verts*4*sizeof(F32)); - clothing_weightsp.assignArray((U8*)mMesh->getClothingWeights(), sizeof(mMesh->getClothingWeights()[0]), num_verts); + clothing_weightsp.assignArray((U8*)mMesh->getClothingWeights(), sizeof(mMesh->getClothingWeights()[0]), num_verts); } const U32 idx_count = mMesh->getNumFaces()*3; @@ -789,16 +771,16 @@ void LLViewerJointMesh::updateGeometryOriginal(LLFace *mFace, LLPolyMesh *mMesh) buffer->getVertexStrider(o_vertices, 0); buffer->getNormalStrider(o_normals, 0); - F32* __restrict vert = o_vertices[0].mV; - F32* __restrict norm = o_normals[0].mV; + //F32* __restrict vert = o_vertices[0].mV; + //F32* __restrict norm = o_normals[0].mV; const F32* __restrict weights = mMesh->getWeights(); const LLVector4a* __restrict coords = (LLVector4a*) mMesh->getCoords(); const LLVector4a* __restrict normals = (LLVector4a*) mMesh->getNormals(); - U32 offset = mMesh->mFaceVertexOffset*4; - vert += offset; - norm += offset; + U32 offset = mMesh->mFaceVertexOffset; + o_vertices += offset; + o_normals += offset; for (U32 index = 0; index < mMesh->getNumVertices(); index++) { @@ -816,17 +798,21 @@ void LLViewerJointMesh::updateGeometryOriginal(LLFace *mFace, LLPolyMesh *mMesh) LLVector4a res; gBlendMat.affineTransform(coords[index], res); - res.store4a(vert+index*4); + (o_vertices++)->set(res.getF32ptr()); + //res.store4a(vert+index*4); gBlendMat.rotate(normals[index], res); - res.store4a(norm+index*4); + (o_normals++)->set(res.getF32ptr()); + //res.store4a(norm+index*4); } else { // No lerp required in this case. LLVector4a res; gJointMatAligned[joint].affineTransform(coords[index], res); - res.store4a(vert+index*4); + (o_vertices++)->set(res.getF32ptr()); + //res.store4a(vert+index*4); gJointMatAligned[joint].rotate(normals[index], res); - res.store4a(norm+index*4); + (o_normals++)->set(res.getF32ptr()); + //res.store4a(norm+index*4); } } @@ -869,31 +855,33 @@ void LLViewerJointMesh::updateVectorize() LL_INFOS("AppInit") << "Vectorization : " << ( vectorizeEnable ? "ENABLED" : "DISABLED" ) << LL_ENDL ; LL_INFOS("AppInit") << "Vector Processor : " << vp << LL_ENDL ; LL_INFOS("AppInit") << "Vectorized Skinning : " << ( vectorizeSkin ? "ENABLED" : "DISABLED" ) << LL_ENDL ; + + sUpdateGeometryFunc = &updateGeometryOriginal; + if(vectorizeEnable && vectorizeSkin) { switch(sVectorizeProcessor) { case 2: - sUpdateGeometryFunc = &updateGeometrySSE2; if(!supportsSSE2()) LL_INFOS("AppInit") << "VectorizeProcessor set to unsupported implementation! (SSE2)" << LL_ENDL ; + else + sUpdateGeometryFunc = &updateGeometrySSE2; break; case 1: - sUpdateGeometryFunc = &updateGeometrySSE; if(!supportsSSE()) LL_INFOS("AppInit") << "VectorizeProcessor set to unsupported implementation! (SSE)" << LL_ENDL ; + else + sUpdateGeometryFunc = &updateGeometrySSE; break; default: - sUpdateGeometryFunc = &updateGeometryVectorized; if(!gSysCPU.hasAltivec()) LL_INFOS("AppInit") << "VectorizeProcessor set to unsupported implementation! (Altivec)" << LL_ENDL ; + else + sUpdateGeometryFunc = &updateGeometryVectorized; break; } } - else - { - sUpdateGeometryFunc = &updateGeometryOriginal; - } } void LLViewerJointMesh::updateJointGeometry() diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index b79249860..911813104 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -43,7 +43,9 @@ #include "llpluginclassmedia.h" +#include "llnotifications.h" #include "llevent.h" // LLSimpleListener +#include "llnotificationsutil.h" #include "lluuid.h" #include "llkeyboard.h" @@ -334,7 +336,7 @@ bool LLViewerMediaImpl::initializeMedia(const std::string& mime_type) LL_WARNS("Plugin") << "plugin intialization failed for mime type: " << mime_type << LL_ENDL; LLSD args; args["MIME_TYPE"] = mime_type; - LLNotifications::instance().add("NoPlugin", args); + LLNotificationsUtil::add("NoPlugin", args); return false; } @@ -440,7 +442,7 @@ LLPluginClassMedia* LLViewerMediaImpl::newSourceFromMediaType(std::string media_ LL_WARNS("Plugin") << "plugin intialization failed for mime type: " << media_type << LL_ENDL; LLSD args; args["MIME_TYPE"] = media_type; - LLNotifications::instance().add("NoPlugin", args); + LLNotificationsUtil::add("NoPlugin", args); return NULL; } @@ -1131,7 +1133,7 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* self, LLPluginClass { LLSD args; args["PLUGIN"] = LLMIMETypes::implType(mMimeType); - LLNotifications::instance().add("MediaPluginFailed", args); + LLNotificationsUtil::add("MediaPluginFailed", args); } break; default: diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index dc5587615..0debf03b6 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -44,6 +44,8 @@ #include "indra_constants.h" #include "llassetstorage.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llchat.h" #include "llfeaturemanager.h" #include "llfocusmgr.h" @@ -167,6 +169,7 @@ #include "llimagebmp.h" #include "llimagej2c.h" #include "llimagetga.h" +#include "llinventorydefines.h" #include "llinventorymodel.h" #include "llinventoryview.h" #include "llkeyboard.h" @@ -1541,7 +1544,7 @@ void init_debug_rendering_menu(LLMenuGL* menu) item = new LLMenuItemCheckGL("Animate Textures", menu_toggle_control, NULL, menu_check_control, (void*)"AnimateTextures"); menu->append(item); - item = new LLMenuItemCheckGL("Disable Textures", menu_toggle_variable, NULL, menu_check_variable, (void*)&LLViewerTexture::sDontLoadVolumeTextures); + item = new LLMenuItemCheckGL("Disable Textures", menu_toggle_control, NULL, menu_check_control, (void*)"TextureDisable"); menu->append(item); item = new LLMenuItemCheckGL("HTTP Get Textures", menu_toggle_control, NULL, menu_check_control, (void*)"ImagePipelineUseHTTP"); @@ -2360,7 +2363,7 @@ class LLEnableEdit : public view_listener_t bool enable = true; if (gAgent.inPrelude()) { - enable = LLViewerParcelMgr::getInstance()->agentCanBuild() + enable = LLViewerParcelMgr::getInstance()->allowAgentBuild() || LLSelectMgr::getInstance()->getSelection()->isAttachment(); } // [RLVa:KB] - Checked: 2009-07-05 (RLVa-1.0.0b) @@ -2773,9 +2776,6 @@ bool handle_go_to() std::string val; LLVector3d pos = LLToolPie::getInstance()->getPick().mPosGlobal; if (gSavedSettings.getBOOL("DoubleClickTeleport") -#ifdef LL_RRINTERFACE_H //MK - && !(gRRenabled && gAgent.mRRInterface.contains ("tploc")) -#endif //mk ) { LLVector3d hips_offset(0.0f, 0.0f, 1.2f); @@ -3007,14 +3007,14 @@ class LLAvatarFreeze : public view_listener_t // [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.0.0e | OK args["AVATAR_NAME"] = (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? fullname : RlvStrings::getAnonym(fullname); // [/RLVa:KB] - LLNotifications::instance().add("FreezeAvatarFullname", + LLNotificationsUtil::add("FreezeAvatarFullname", args, payload, callback_freeze); } else { - LLNotifications::instance().add("FreezeAvatar", + LLNotificationsUtil::add("FreezeAvatar", LLSD(), payload, callback_freeze); @@ -3149,14 +3149,14 @@ class LLAvatarEject : public view_listener_t // [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.0.0e | OK args["AVATAR_NAME"] = (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? fullname : RlvStrings::getAnonym(fullname); // [/RLVa:KB] - LLNotifications::instance().add("EjectAvatarFullname", + LLNotificationsUtil::add("EjectAvatarFullname", args, payload, callback_eject); } else { - LLNotifications::instance().add("EjectAvatarFullname", + LLNotificationsUtil::add("EjectAvatarFullname", LLSD(), payload, callback_eject); @@ -3172,14 +3172,14 @@ class LLAvatarEject : public view_listener_t // [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.0.0e | OK args["AVATAR_NAME"] = (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? fullname : RlvStrings::getAnonym(fullname); // [/RLVa:KB] - LLNotifications::instance().add("EjectAvatarFullnameNoBan", + LLNotificationsUtil::add("EjectAvatarFullnameNoBan", args, payload, callback_eject); } else { - LLNotifications::instance().add("EjectAvatarNoBan", + LLNotificationsUtil::add("EjectAvatarNoBan", LLSD(), payload, callback_eject); @@ -3292,11 +3292,11 @@ class LLAvatarGiveCard : public view_listener_t transaction_id.generate(); msg->addUUIDFast(_PREHASH_TransactionID, transaction_id); msg->sendReliable(dest_host); - LLNotifications::instance().add("OfferedCard", args); + LLNotificationsUtil::add("OfferedCard", args); } else { - LLNotifications::instance().add("CantOfferCallingCard", old_args); + LLNotificationsUtil::add("CantOfferCallingCard", old_args); } } return true; @@ -3337,7 +3337,7 @@ void handle_leave_group(void *) { LLSD args; args["GROUP"] = gAgent.getGroupName(); - LLNotifications::instance().add("GroupLeaveConfirmMember", args, LLSD(), callback_leave_group); + LLNotificationsUtil::add("GroupLeaveConfirmMember", args, LLSD(), callback_leave_group); } } @@ -3400,7 +3400,7 @@ void handle_buy_object(LLSaleInfo sale_info) { if(!LLSelectMgr::getInstance()->selectGetAllRootsValid()) { - LLNotifications::instance().add("UnableToBuyWhileDownloading"); + LLNotificationsUtil::add("UnableToBuyWhileDownloading"); return; } @@ -3409,7 +3409,7 @@ void handle_buy_object(LLSaleInfo sale_info) BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name); if (!owners_identical) { - LLNotifications::instance().add("CannotBuyObjectsFromDifferentOwners"); + LLNotificationsUtil::add("CannotBuyObjectsFromDifferentOwners"); return; } @@ -3419,7 +3419,7 @@ void handle_buy_object(LLSaleInfo sale_info) valid &= LLSelectMgr::getInstance()->selectGetAggregatePermissions(ag_perm); if(!valid || !sale_info.isForSale() || !perm.allowTransferTo(gAgent.getID())) { - LLNotifications::instance().add("ObjectNotForSale"); + LLNotificationsUtil::add("ObjectNotForSale"); return; } @@ -3632,12 +3632,12 @@ void set_god_level(U8 god_level) if(god_level > GOD_NOT) { args["LEVEL"] = llformat("%d",(S32)god_level); - LLNotifications::instance().add("EnteringGodMode", args); + LLNotificationsUtil::add("EnteringGodMode", args); } else { args["LEVEL"] = llformat("%d",(S32)old_god_level); - LLNotifications::instance().add("LeavingGodMode", args); + LLNotificationsUtil::add("LeavingGodMode", args); } @@ -3884,7 +3884,7 @@ void request_friendship(const LLUUID& dest_id) } else { - LLNotifications::instance().add("CantOfferFriendship"); + LLNotificationsUtil::add("CantOfferFriendship"); } } } @@ -4284,7 +4284,7 @@ void disabled_duplicate(void*) { if (LLSelectMgr::getInstance()->getSelection()->getPrimaryObject()) { - LLNotifications::instance().add("CopyFailed"); + LLNotificationsUtil::add("CopyFailed"); } } @@ -4417,7 +4417,7 @@ void handle_claim_public_land(void*) { if (LLViewerParcelMgr::getInstance()->getSelectionRegion() != gAgent.getRegion()) { - LLNotifications::instance().add("ClaimPublicLand"); + LLNotificationsUtil::add("ClaimPublicLand"); return; } @@ -4695,7 +4695,7 @@ class LLObjectReturn : public view_listener_t mObjectSelection = LLSelectMgr::getInstance()->getEditSelection(); - LLNotifications::instance().add("ReturnToOwner", LLSD(), LLSD(), boost::bind(&LLObjectReturn::onReturnToOwner, this, _1, _2)); + LLNotificationsUtil::add("ReturnToOwner", LLSD(), LLSD(), boost::bind(&LLObjectReturn::onReturnToOwner, this, _1, _2)); return true; } @@ -5086,7 +5086,7 @@ void show_buy_currency(const char* extra) args["EXTRA"] = extra; } args["URL"] = BUY_CURRENCY_URL; - LLNotifications::instance().add("PromptGoToCurrencyPage", args, LLSD(), callback_show_buy_currency); + LLNotificationsUtil::add("PromptGoToCurrencyPage", args, LLSD(), callback_show_buy_currency); } void handle_buy_currency(void*) @@ -5637,11 +5637,6 @@ class LLViewToggleRadar: public view_listener_t bool handleEvent(LLPointer event, const LLSD& userdata) { LLFloaterAvatarList::toggle(0); - bool vis = false; - if(LLFloaterAvatarList::getInstance()) - { - vis = (bool)LLFloaterAvatarList::getInstance()->getVisible(); - } return true; } }; @@ -5983,7 +5978,7 @@ class LLWorldSetBusy : public view_listener_t else { gAgent.setBusy(); - LLNotifications::instance().add("BusyModeSet"); + LLNotificationsUtil::add("BusyModeSet"); } return true; } @@ -6016,7 +6011,7 @@ class LLWorldCreateLandmark : public view_listener_t if (!agent_parcel->getAllowLandmark() && !LLViewerParcelMgr::isParcelOwnedByAgent(agent_parcel, GP_LAND_ALLOW_LANDMARK)) { - LLNotifications::instance().add("CannotCreateLandmarkNotOwner"); + LLNotificationsUtil::add("CannotCreateLandmarkNotOwner"); return true; } @@ -7154,7 +7149,7 @@ class LLAttachmentEnableDrop : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) { - BOOL can_build = gAgent.isGodlike() || (LLViewerParcelMgr::getInstance()->agentCanBuild()); + BOOL can_build = gAgent.isGodlike() || (LLViewerParcelMgr::getInstance()->allowAgentBuild()); //Add an inventory observer to only allow dropping the newly attached item //once it exists in your inventory. Look at Jira 2422. @@ -8959,7 +8954,7 @@ void handle_save_to_xml(void*) LLFloater* frontmost = gFloaterView->getFrontmost(); if (!frontmost) { - LLNotifications::instance().add("NoFrontmostFloater"); + LLNotificationsUtil::add("NoFrontmostFloater"); return; } @@ -9366,51 +9361,51 @@ class LLWorldEnvSettings : public view_listener_t if (tod == "sunrise") { // set the value, turn off animation - LLWLParamManager::instance()->mAnimator.setDayTime(0.25); - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.setDayTime(0.25); + LLWLParamManager::getInstance()->mAnimator.mIsRunning = false; + LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = false; // then call update once - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } else if (tod == "noon") { // set the value, turn off animation - LLWLParamManager::instance()->mAnimator.setDayTime(0.567); - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.setDayTime(0.567); + LLWLParamManager::getInstance()->mAnimator.mIsRunning = false; + LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = false; // then call update once - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } else if (tod == "sunset") { // set the value, turn off animation - LLWLParamManager::instance()->mAnimator.setDayTime(0.75); - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.setDayTime(0.75); + LLWLParamManager::getInstance()->mAnimator.mIsRunning = false; + LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = false; // then call update once - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } else if (tod == "midnight") { // set the value, turn off animation - LLWLParamManager::instance()->mAnimator.setDayTime(0.0); - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.setDayTime(0.0); + LLWLParamManager::getInstance()->mAnimator.mIsRunning = false; + LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = false; // then call update once - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } else { - LLWLParamManager::instance()->mAnimator.mIsRunning = true; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = true; + LLWLParamManager::getInstance()->mAnimator.mIsRunning = true; + LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = true; } return true; } diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 2c1aecaf8..db4ca65dd 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -77,6 +77,7 @@ #include "llassetuploadresponders.h" #include "lleconomy.h" #include "llhttpclient.h" +#include "llnotificationsutil.h" #include "llmemberlistener.h" #include "llsdserialize.h" #include "llstring.h" @@ -206,7 +207,7 @@ bool AIFileUpload::is_valid(std::string const& filename, ELoadFilter type) // No extension LLSD args; args["FILE"] = short_name; - LLNotifications::instance().add("NoFileExtension", args); + LLNotificationsUtil::add("NoFileExtension", args); return false; } else @@ -249,7 +250,7 @@ bool AIFileUpload::is_valid(std::string const& filename, ELoadFilter type) LLSD args; args["EXTENSION"] = ext; args["VALIDS"] = valid_extensions; - LLNotifications::instance().add("InvalidFileExtension", args); + LLNotificationsUtil::add("InvalidFileExtension", args); return false; } }//end else (non-null extension) @@ -354,7 +355,7 @@ class LLFileUploadBulk : public view_listener_t if(expected_upload_cost) msg.append(llformat("\nWARNING: Each upload costs L$%d if it's not temporary.",expected_upload_cost)); args["MESSAGE"] = msg; - LLNotifications::instance().add("GenericAlertYesNoCancel", args, LLSD(), onConfirmBulkUploadTemp); + LLNotificationsUtil::add("GenericAlertYesNoCancel", args, LLSD(), onConfirmBulkUploadTemp); return true; } @@ -959,7 +960,7 @@ void upload_new_resource(const std::string& src_filename, std::string name, llwarns << error_message << llendl; LLSD args; args["ERROR_MESSAGE"] = error_message; - LLNotifications::instance().add("ErrorMessage", args); + LLNotificationsUtil::add("ErrorMessage", args); if(LLFile::remove(filename) == -1) { lldebugs << "unable to remove temp file" << llendl; @@ -1021,7 +1022,7 @@ void temp_upload_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt LLSD args; args["FILE"] = LLInventoryType::lookupHumanReadable(data->mInventoryType); args["REASON"] = std::string(LLAssetStorage::getErrorString(result)); - LLNotifications::instance().add("CannotUploadReason", args); + LLNotificationsUtil::add("CannotUploadReason", args); } LLUploadDialog::modalUploadFinished(); @@ -1114,7 +1115,7 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt LLSD args; args["FILE"] = LLInventoryType::lookupHumanReadable(data->mInventoryType); args["REASON"] = std::string(LLAssetStorage::getErrorString(result)); - LLNotifications::instance().add("CannotUploadReason", args); + LLNotificationsUtil::add("CannotUploadReason", args); } LLUploadDialog::modalUploadFinished(); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 0cb987908..5c69f3471 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -38,6 +38,7 @@ #include #include "llimagejpeg.h" +#include "llanimationstates.h" #include "llaudioengine.h" #include "llavatarnamecache.h" #include "indra_constants.h" @@ -95,12 +96,14 @@ #include "llhudeffecttrail.h" #include "llhudmanager.h" #include "llimpanel.h" +#include "llinventorydefines.h" #include "llinventorymodel.h" #include "llinventoryview.h" #include "llmenugl.h" #include "llmutelist.h" -#include "llnotifications.h" #include "llnotify.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llpanelgrouplandmoney.h" #include "llselectmgr.h" #include "llstartup.h" @@ -360,9 +363,9 @@ void give_money(const LLUUID& uuid, LLViewerRegion* region, S32 amount, BOOL is_ S32 trx_type, const std::string& desc) { // - //if(0 == amount || !region) return; - if(!region) return; + //if(!region) return; // + if(0 == amount || !region) return; amount = abs(amount); LL_INFOS("Messaging") << "give_money(" << uuid << "," << amount << ")"<< LL_ENDL; if(can_afford_transaction(amount)) @@ -739,7 +742,7 @@ bool join_group_response(const LLSD& notification, const LLSD& response) LLFloaterGroupInfo::showFromUUID(group_id); LLSD args; args["MESSAGE"] = message; - LLNotifications::instance().add("JoinGroup", args, notification["payload"]); + LLNotificationsUtil::add("JoinGroup", args, notification["payload"]); return false; } if(option == 0 && !group_id.isNull()) @@ -758,7 +761,7 @@ bool join_group_response(const LLSD& notification, const LLSD& response) LLSD args; args["NAME"] = name; args["INVITE"] = message; - LLNotifications::instance().add("JoinedTooManyGroupsMember", args, notification["payload"]); + LLNotificationsUtil::add("JoinedTooManyGroupsMember", args, notification["payload"]); } } @@ -776,7 +779,7 @@ bool join_group_response(const LLSD& notification, const LLSD& response) // asking about a fee. LLSD next_payload = notification["payload"]; next_payload["fee"] = 0; - LLNotifications::instance().add("JoinGroupCanAfford", + LLNotificationsUtil::add("JoinGroupCanAfford", args, next_payload); } @@ -1952,7 +1955,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // Note: don't put the message in the IM history, even though was sent // via the IM mechanism. - LLNotifications::instance().add("SystemMessageTip",args); + LLNotificationsUtil::add("SystemMessageTip",args); break; case IM_NOTHING_SPECIAL: @@ -2053,7 +2056,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // Message to everyone from GOD args["NAME"] = name; args["MESSAGE"] = message; - LLNotifications::instance().add("GodMessage", args); + LLNotificationsUtil::add("GodMessage", args); // Treat like a system message and put in chat history. // Claim to be from a local agent so it doesn't go into @@ -2134,7 +2137,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // This is a block, modeless dialog. //*TODO:translate args["MESSAGE"] = message; - LLNotifications::instance().add("SystemMessage", args); + LLNotificationsUtil::add("SystemMessage", args); } break; case IM_GROUP_NOTICE: @@ -2270,7 +2273,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) LLSD args; args["MESSAGE"] = message; - LLNotifications::instance().add("JoinGroup", args, payload, join_group_response); + LLNotificationsUtil::add("JoinGroup", args, payload, join_group_response); } } break; @@ -2370,7 +2373,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) args["NAME"] = (!fRlvObfuscate) ? name : RlvStrings::getAnonym(name); // [/RLVa:KB] //args["NAME"] = name; - LLNotifications::instance().add("InventoryAccepted", args); + LLNotificationsUtil::add("InventoryAccepted", args); break; } case IM_INVENTORY_DECLINED: @@ -2381,7 +2384,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) args["NAME"] = (!fRlvObfuscate) ? name : RlvStrings::getAnonym(name); // [/RLVa:KB] //args["NAME"] = name; - LLNotifications::instance().add("InventoryDeclined", args); + LLNotificationsUtil::add("InventoryDeclined", args); break; } case IM_GROUP_VOTE: @@ -2392,7 +2395,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) LLSD payload; payload["group_id"] = session_id; - LLNotifications::instance().add("GroupVote", args, payload); + LLNotificationsUtil::add("GroupVote", args, payload); } break; @@ -2539,7 +2542,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // Construct a viewer alert for this message. args["NAME"] = name; args["MESSAGE"] = message; - LLNotifications::instance().add("ObjectMessage", args); + LLNotificationsUtil::add("ObjectMessage", args); } break; case IM_BUSY_AUTO_RESPONSE: @@ -2607,7 +2610,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) payload["from_id"] = from_id; payload["lure_id"] = session_id; payload["godlike"] = FALSE; - //LLNotifications::instance().add("TeleportOffered", args, payload); + //LLNotificationsUtil::add("TeleportOffered", args, payload); // [RLVa:KB] - Version: 1.23.4 | Checked: 2009-07-07 (RLVa-1.0.0d) | Modified: RLVa-0.2.0b if ( (rlv_handler_t::isEnabled()) && @@ -2618,7 +2621,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) } else { - LLNotifications::instance().add("TeleportOffered", args, payload); + LLNotificationsUtil::add("TeleportOffered", args, payload); // if(binary_bucket_size) { @@ -2679,7 +2682,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // } // [/RLVa:KB] - //LLNotifications::instance().add("TeleportOffered", args, payload); + //LLNotificationsUtil::add("TeleportOffered", args, payload); } } break; @@ -2716,7 +2719,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) args["URL"] = url; LLSD payload; payload["url"] = url; - LLNotifications::instance().add("GotoURL", args, payload ); + LLNotificationsUtil::add("GotoURL", args, payload ); } break; @@ -2743,12 +2746,12 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) if(message.empty()) { //support for frienship offers from clients before July 2008 - LLNotifications::instance().add("OfferFriendshipNoMessage", args, payload); + LLNotificationsUtil::add("OfferFriendshipNoMessage", args, payload); } else { args["[MESSAGE]"] = message; - LLNotifications::instance().add("OfferFriendship", args, payload); + LLNotificationsUtil::add("OfferFriendship", args, payload); } } } @@ -2766,7 +2769,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) send_generic_message("requestonlinenotification", strings); args["NAME"] = name; - LLNotifications::instance().add("FriendshipAccepted", args); + LLNotificationsUtil::add("FriendshipAccepted", args); } break; @@ -2889,7 +2892,7 @@ void process_offer_callingcard(LLMessageSystem* msg, void**) static SH_SpamHandler spam_check("SGBlockCardSpam","SHSpamTime","SGSpamCount"); if(spam_check.isBlocked(source_id,source_id,"BlockedCards",args)) return; - LLNotifications::instance().add("OfferCallingCard", args, payload); + LLNotificationsUtil::add("OfferCallingCard", args, payload); } } else @@ -2900,12 +2903,12 @@ void process_offer_callingcard(LLMessageSystem* msg, void**) void process_accept_callingcard(LLMessageSystem* msg, void**) { - LLNotifications::instance().add("CallingCardAccepted"); + LLNotificationsUtil::add("CallingCardAccepted"); } void process_decline_callingcard(LLMessageSystem* msg, void**) { - LLNotifications::instance().add("CallingCardDeclined"); + LLNotificationsUtil::add("CallingCardDeclined"); } class ChatTranslationReceiver : public LLTranslate::TranslationReceiver @@ -3113,18 +3116,20 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) U32 links_for_chatting_objects = gSavedSettings.getU32("LinksForChattingObjects"); if (links_for_chatting_objects != 0 && chatter && chat.mSourceType == CHAT_SOURCE_OBJECT && -#ifdef LL_RRINTERFACE_H //MK - (!gRRenabled || !gAgent.mRRInterface.mContainsShownames) && -#endif //mk - (!is_owned_by_me || links_for_chatting_objects == 2)) + (!is_owned_by_me || links_for_chatting_objects == 2) +// [RLVa:KB] + && !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES) +// [/RLVa:KB] + ) { LLSD query_string; query_string["name"] = from_name; query_string["owner"] = owner_id; -#ifdef LL_RRINTERFACE_H //MK - if (!gRRenabled || !gAgent.mRRInterface.mContainsShowloc) + +// [RLVa:KB] + if( !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC) ) +// [/RLVa:KB] { -#endif //mk // Compute the object SLURL. LLVector3 pos = chatter->getPositionRegion(); S32 x = llround((F32)fmod((F64)pos.mV[VX], (F64)REGION_WIDTH_METERS)); @@ -3133,9 +3138,8 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) std::ostringstream location; location << chatter->getRegion()->getName() << "/" << x << "/" << y << "/" << z; query_string["slurl"] = location.str(); -#ifdef LL_RRINTERFACE_H //MK } -#endif //mk + std::ostringstream link; link << "secondlife:///app/objectim/" << from_id << LLURI::mapToQueryString(query_string); chat.mURL = link.str(); @@ -3199,30 +3203,23 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) // [Ansariel/Henri: Display name support] if (chatter && chatter->isAvatar()) { -#ifdef LL_RRINTERFACE_H //MK - if (!gRRenabled || !gAgent.mRRInterface.mContainsShownames) + if (LLAvatarNameCache::useDisplayNames()) { -#endif //mk - if (LLAvatarNameCache::useDisplayNames()) + LLAvatarName avatar_name; + if (LLAvatarNameCache::get(from_id, &avatar_name)) { - LLAvatarName avatar_name; - if (LLAvatarNameCache::get(from_id, &avatar_name)) + static const LLCachedControl phoenix_name_system("PhoenixNameSystem", 0); + if (phoenix_name_system == 2 || (phoenix_name_system == 1 && avatar_name.mIsDisplayNameDefault)) { - static const LLCachedControl phoenix_name_system("PhoenixNameSystem", 0); - if (phoenix_name_system == 2 || (phoenix_name_system == 1 && avatar_name.mIsDisplayNameDefault)) - { - from_name = avatar_name.mDisplayName; - } - else - { - from_name = avatar_name.getCompleteName(); - } + from_name = avatar_name.mDisplayName; + } + else + { + from_name = avatar_name.getCompleteName(); } - chat.mFromName = from_name; } -#ifdef LL_RRINTERFACE_H //MK + chat.mFromName = from_name; } -#endif //mk } // [/Ansariel/Henri: Display name support] @@ -3602,13 +3599,13 @@ public: { // Show notification that they can now teleport to landmarks. Use a random landmark from the inventory S32 random_land = ll_rand( land_items.count() - 1 ); args["NAME"] = land_items[random_land]->getName(); - LLNotifications::instance().add("TeleportToLandmark",args); + LLNotificationsUtil::add("TeleportToLandmark",args); } if ( card_items.count() > 0 ) { // Show notification that they can now contact people. Use a random calling card from the inventory S32 random_card = ll_rand( card_items.count() - 1 ); args["NAME"] = card_items[random_card]->getName(); - LLNotifications::instance().add("TeleportToPerson",args); + LLNotificationsUtil::add("TeleportToPerson",args); } gInventory.removeObserver(this); @@ -3708,17 +3705,17 @@ void process_teleport_finish(LLMessageSystem* msg, void**) U32 teleport_flags; msg->getU32Fast(_PREHASH_Info, _PREHASH_TeleportFlags, teleport_flags); - U32 region_size_x = 256; - msg->getU32Fast(_PREHASH_Info, _PREHASH_RegionSizeX, region_size_x); - - U32 region_size_y = 256; - msg->getU32Fast(_PREHASH_Info, _PREHASH_RegionSizeY, region_size_y); - - //and a little hack for Second Life compatibility - if (region_size_y == 0 || region_size_x == 0) - { - region_size_x = 256; - region_size_y = 256; + U32 region_size_x = 256; + msg->getU32Fast(_PREHASH_Info, _PREHASH_RegionSizeX, region_size_x); + + U32 region_size_y = 256; + msg->getU32Fast(_PREHASH_Info, _PREHASH_RegionSizeY, region_size_y); + + //and a little hack for Second Life compatibility + if (region_size_y == 0 || region_size_x == 0) + { + region_size_x = 256; + region_size_y = 256; } std::string seedCap; @@ -3762,17 +3759,17 @@ void process_teleport_finish(LLMessageSystem* msg, void**) */ //Reset the windlight profile to default - //LLWLParamManager::instance()->mAnimator.mIsRunning = false; - //LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + //LLWLParamManager::getInstance()->mAnimator.mIsRunning = false; + //LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = false; LLWLParamSet wl_backup; - if(LLWLParamManager::instance()->getParamSet("LightShare-Backup", wl_backup)) { - LLWLParamManager::instance()->propagateParameters(); - LLWLParamManager::instance()->removeParamSet("LightShare-Backup", true); + if(LLWLParamManager::getInstance()->getParamSet("LightShare-Backup", wl_backup)) { + LLWLParamManager::getInstance()->propagateParameters(); + LLWLParamManager::getInstance()->removeParamSet("LightShare-Backup", true); } LLWaterParamSet backup; - if(LLWaterParamManager::instance()->getParamSet("LightShare-Backup", backup)) { - LLWaterParamManager::instance()->propagateParameters(); - LLWaterParamManager::instance()->removeParamSet("LightShare-Backup", true); + if(LLWaterParamManager::getInstance()->getParamSet("LightShare-Backup", backup)) { + LLWaterParamManager::getInstance()->propagateParameters(); + LLWaterParamManager::getInstance()->removeParamSet("LightShare-Backup", true); } // now, use the circuit info to tell simulator about us! @@ -4014,7 +4011,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) { LLSD payload; payload["message"] = version_channel; - LLNotifications::instance().add("ServerVersionChanged", LLSD(), payload); + LLNotificationsUtil::add("ServerVersionChanged", LLSD(), payload); } gLastVersionChannel = version_channel; @@ -4045,17 +4042,17 @@ void process_crossed_region(LLMessageSystem* msg, void**) std::string seedCap; msg->getStringFast(_PREHASH_RegionData, _PREHASH_SeedCapability, seedCap); - U32 region_size_x = 256; - msg->getU32(_PREHASH_RegionData, _PREHASH_RegionSizeX, region_size_x); - - U32 region_size_y = 256; - msg->getU32(_PREHASH_RegionData, _PREHASH_RegionSizeY, region_size_y); - - //and a little hack for Second Life compatibility - if (region_size_y == 0 || region_size_x == 0) - { - region_size_x = 256; - region_size_y = 256; + U32 region_size_x = 256; + msg->getU32(_PREHASH_RegionData, _PREHASH_RegionSizeX, region_size_x); + + U32 region_size_y = 256; + msg->getU32(_PREHASH_RegionData, _PREHASH_RegionSizeY, region_size_y); + + //and a little hack for Second Life compatibility + if (region_size_y == 0 || region_size_x == 0) + { + region_size_x = 256; + region_size_y = 256; } send_complete_agent_movement(sim_host); @@ -4850,6 +4847,17 @@ void process_avatar_animation(LLMessageSystem *mesgsys, void **user_data) avatarp->mSignaledAnimations[animation_id] = anim_sequence_id; + // *HACK: Disabling flying mode if it has been enabled shortly before the agent + // stand up animation is signaled. In this case we don't get a signal to start + // flying animation from server, the AGENT_CONTROL_FLY flag remains set but the + // avatar does not play flying animation, so we switch flying mode off. + // See LLAgent::setFlying(). This may cause "Stop Flying" button to blink. + // See EXT-2781. + if (animation_id == ANIM_AGENT_STANDUP && gAgent.getFlying()) + { + gAgent.setFlying(FALSE); + } + if (i < num_source_blocks) { mesgsys->getUUIDFast(_PREHASH_AnimationSourceList, _PREHASH_ObjectID, object_id, i); @@ -4956,6 +4964,9 @@ void process_avatar_sit_response(LLMessageSystem *mesgsys, void **user_data) } gAgentCamera.setForceMouselook(force_mouselook); + // Forcing turning off flying here to prevent flying after pressing "Stand" + // to stand up from an object. See EXT-1655. + gAgent.setFlying(FALSE); LLViewerObject* object = gObjectList.findObject(sitObjectID); if (object) @@ -5270,7 +5281,7 @@ void process_money_balance_reply( LLMessageSystem* msg, void** ) // *TODO:translate LLSD args; args["MESSAGE"] = desc; - LLNotifications::instance().add("SystemMessage", args); + LLNotificationsUtil::add("SystemMessage", args); // Also send notification to chat -- MC LLChat chat(desc); @@ -5347,7 +5358,7 @@ bool handle_special_notification(std::string notificationID, LLSD& llsdBlock) bool attempt_standard_notification(LLMessageSystem* msgsystem) { // if we have additional alert data - if (msgsystem->getNumberOfBlocksFast(_PREHASH_AlertInfo) > 0) + if (msgsystem->has(_PREHASH_AlertInfo) && msgsystem->getNumberOfBlocksFast(_PREHASH_AlertInfo) > 0) { // notification was specified using the new mechanism, so we can just handle it here std::string notificationID; @@ -5453,7 +5464,7 @@ void process_alert_core(const std::string& message, BOOL modal) std::string snap_filename = gDirUtilp->getLindenUserDir(); snap_filename += gDirUtilp->getDirDelimiter(); snap_filename += SCREEN_HOME_FILENAME; - gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight(), FALSE, FALSE); + gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), FALSE, FALSE); } const std::string ALERT_PREFIX("ALERT: "); @@ -5482,20 +5493,20 @@ void process_alert_core(const std::string& message, BOOL modal) S32 mins = 0; LLStringUtil::convertToS32(text.substr(18), mins); args["MINUTES"] = llformat("%d",mins); - LLNotifications::instance().add("RegionRestartMinutes", args); + LLNotificationsUtil::add("RegionRestartMinutes", args); } else if (text.substr(0,17) == "RESTART_X_SECONDS") { S32 secs = 0; LLStringUtil::convertToS32(text.substr(18), secs); args["SECONDS"] = llformat("%d",secs); - LLNotifications::instance().add("RegionRestartSeconds", args); + LLNotificationsUtil::add("RegionRestartSeconds", args); } else { // *TODO:translate args["MESSAGE"] = text; - LLNotifications::instance().add("SystemMessage", args); + LLNotificationsUtil::add("SystemMessage", args); } } else if (modal) @@ -5503,14 +5514,14 @@ void process_alert_core(const std::string& message, BOOL modal) // *TODO:translate LLSD args; args["ERROR_MESSAGE"] = message; - LLNotifications::instance().add("ErrorMessage", args); + LLNotificationsUtil::add("ErrorMessage", args); } else { // *TODO:translate LLSD args; args["MESSAGE"] = message; - LLNotifications::instance().add("SystemMessageTip", args); + LLNotificationsUtil::add("SystemMessageTip", args); } } @@ -5806,7 +5817,7 @@ bool script_question_cb(const LLSD& notification, const LLSD& response) LLNotifications::instance().add(notification["name"], notification["substitutions"], notification["payload"]); // ...with description on top - LLNotifications::instance().add("DebitPermissionDetails"); + LLNotificationsUtil::add("DebitPermissionDetails"); } return false; } @@ -5935,7 +5946,7 @@ void process_script_question(LLMessageSystem *msg, void **user_data) else { // fall back to default behavior if cautions are entirely disabled - LLNotifications::instance().add("ScriptQuestion", args, payload); + LLNotificationsUtil::add("ScriptQuestion", args, payload); } } @@ -6074,7 +6085,7 @@ void process_teleport_failed(LLMessageSystem *msg, void**) LLSD args; // if we have additional alert data - if (msg->getNumberOfBlocksFast(_PREHASH_AlertInfo) > 0) + if (msg->has(_PREHASH_AlertInfo) && msg->getSizeFast(_PREHASH_AlertInfo, _PREHASH_Message) > 0) { // Get the message ID msg->getStringFast(_PREHASH_AlertInfo, _PREHASH_Message, reason); @@ -6129,7 +6140,10 @@ void process_teleport_failed(LLMessageSystem *msg, void**) } } - LLNotifications::instance().add("CouldNotTeleportReason", args); + LLNotificationsUtil::add("CouldNotTeleportReason", args); + + // Let the interested parties know that teleport failed. + LLViewerParcelMgr::getInstance()->onTeleportFailed(); if( gAgent.getTeleportState() != LLAgent::TELEPORT_NONE ) { @@ -6190,9 +6204,14 @@ void process_teleport_local(LLMessageSystem *msg,void**) } // send camera update to new region - //gAgent.updateCamera(); + gAgentCamera.updateCamera(); send_agent_update(TRUE, TRUE); + + // Let the interested parties know we've teleported. + // Vadim *HACK: Agent position seems to get reset (to render position?) + // on each frame, so we have to pass the new position manually. + LLViewerParcelMgr::getInstance()->onTeleportFinished(true, gAgent.getPosGlobalFromAgent(pos)); } void send_simple_im(const LLUUID& to_id, @@ -6350,11 +6369,11 @@ void handle_lure(const uuid_vec_t& ids) } if (gAgent.isGodlike()) { - LLNotifications::instance().add("OfferTeleportFromGod", edit_args, payload, handle_lure_callback); + LLNotificationsUtil::add("OfferTeleportFromGod", edit_args, payload, handle_lure_callback); } else { - LLNotifications::instance().add("OfferTeleport", edit_args, payload, handle_lure_callback); + LLNotificationsUtil::add("OfferTeleport", edit_args, payload, handle_lure_callback); } } @@ -6484,7 +6503,14 @@ void process_script_dialog(LLMessageSystem* msg, void**) LLUUID object_id; msg->getUUID("Data", "ObjectID", object_id); - if (LLMuteList::getInstance()->isMuted(object_id)) +// For compability with OS grids first check for presence of extended packet before fetching data. + LLUUID owner_id; + if (gMessageSystem->getNumberOfBlocks("OwnerData") > 0) + { + msg->getUUID("OwnerData", "OwnerID", owner_id); + } + + if (LLMuteList::getInstance()->isMuted(object_id) || LLMuteList::getInstance()->isMuted(owner_id)) { return; } @@ -6562,7 +6588,7 @@ void process_script_dialog(LLMessageSystem* msg, void**) { args["DEFAULT"] = default_text; payload["textbox"] = "true"; - LLNotifications::instance().add("ScriptTextBoxDialog", args, payload, callback_script_dialog); + LLNotificationsUtil::add("ScriptTextBoxDialog", args, payload, callback_script_dialog); } else { @@ -6630,7 +6656,7 @@ void callback_load_url_name(const LLUUID& id, const std::string& full_name, bool args["OBJECTNAME"] = load_url_info["object_name"].asString(); args["NAME"] = owner_name; - LLNotifications::instance().add("LoadWebPage", args, load_url_info); + LLNotificationsUtil::add("LoadWebPage", args, load_url_info); } else { @@ -6686,7 +6712,7 @@ void callback_download_complete(void** data, S32 result, LLExtStat ext_status) std::string* filepath = (std::string*)data; LLSD args; args["DOWNLOAD_PATH"] = *filepath; - LLNotifications::instance().add("FinishedRawDownload", args); + LLNotificationsUtil::add("FinishedRawDownload", args); delete filepath; } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 856a39cb1..71a0e6a58 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -45,6 +45,7 @@ #include "llfontgl.h" #include "llframetimer.h" #include "llinventory.h" +#include "llinventorydefines.h" #include "llmaterialtable.h" #include "llmutelist.h" #include "llnamevalue.h" @@ -78,6 +79,7 @@ #include "llviewerparceloverlay.h" #include "llviewerpartsource.h" #include "llviewerregion.h" +#include "llviewerstats.h" #include "llviewertextureanim.h" #include "llviewerwindow.h" // For getSpinAxis #include "llvoavatar.h" @@ -106,8 +108,8 @@ //#define DEBUG_UPDATE_TYPE -BOOL gVelocityInterpolate = TRUE; -BOOL gPingInterpolate = TRUE; +BOOL LLViewerObject::sVelocityInterpolate = TRUE; +BOOL LLViewerObject::sPingInterpolate = TRUE; U32 LLViewerObject::sNumZombieObjects = 0; S32 LLViewerObject::sNumObjects = 0; @@ -118,6 +120,10 @@ S32 LLViewerObject::sAxisArrowLength(50); BOOL LLViewerObject::sPulseEnabled(FALSE); BOOL LLViewerObject::sUseSharedDrawables(FALSE); // TRUE +// sMaxUpdateInterpolationTime must be greater than sPhaseOutUpdateInterpolationTime +F64 LLViewerObject::sMaxUpdateInterpolationTime = 3.0; // For motion interpolation: after X seconds with no updates, don't predict object motion +F64 LLViewerObject::sPhaseOutUpdateInterpolationTime = 2.0; // For motion interpolation: after Y seconds with no updates, taper off motion prediction + // static LLViewerObject *LLViewerObject::createObject(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) { @@ -1899,9 +1905,9 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, } } - new_rot.normalize(); + new_rot.normQuat(); - if (gPingInterpolate) + if (sPingInterpolate) { LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(mesgsys->getSender()); if (cdp) @@ -1974,6 +1980,12 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, avatar->clampAttachmentPositions(); } + + // If we're snapping the position by more than 0.5m, update LLViewerStats::mAgentPositionSnaps + if ( isAvatar() && gAgent.getAvatarObject() == this && (mag_sqr > 0.25f) ) + { + LLViewerStats::getInstance()->mAgentPositionSnaps.push( diff.length() ); + } } if (new_rot != mLastRot @@ -2064,7 +2076,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, // U32 ping_delay = mesgsys->mCircuitInfo.getPingDelay(); mLastInterpUpdateSecs = LLFrameTimer::getElapsedSeconds(); - mLastMessageUpdateSecs = LLFrameTimer::getElapsedSeconds(); + mLastMessageUpdateSecs = mLastInterpUpdateSecs; if (mDrawable.notNull()) { // Don't clear invisibility flag on update if still orphaned! @@ -2101,7 +2113,7 @@ BOOL LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) // CRO - don't velocity interp linked objects! // Leviathan - but DO velocity interp joints - if (!mStatic && gVelocityInterpolate && !isSelected()) + if (!mStatic && sVelocityInterpolate && !isSelected()) { // calculate dt from last update F32 dt_raw = (F32)(time - mLastInterpUpdateSecs); @@ -2191,48 +2203,170 @@ BOOL LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) return TRUE; } else - { - // linear motion - // PHYSICS_TIMESTEP is used below to correct for the fact that the velocity in object - // updates represents the average velocity of the last timestep, rather than the final velocity. - // the time dilation above should guarantee that dt is never less than PHYSICS_TIMESTEP, theoretically - // - // There is a problem here if dt is negative. . . - - // *TODO: should also wrap linear accel/velocity in check - // to see if object is selected, instead of explicitly - // zeroing it out - LLVector3 accel = getAcceleration(); - LLVector3 vel = getVelocity(); - - if (!(accel.isExactlyZero() && vel.isExactlyZero())) - { - LLVector3 pos = (vel + (0.5f * (dt-PHYSICS_TIMESTEP)) * accel) * dt; - - // region local - setPositionRegion(pos + getPositionRegion()); - setVelocity(vel + accel*dt); - - // for objects that are spinning but not translating, make sure to flag them as having moved - setChanged(MOVED | SILHOUETTE); - } - - mLastInterpUpdateSecs = time; + { // Move object based on it's velocity and rotation + interpolateLinearMotion(time, dt); } } - if (gNoRender) - { - // Skip drawable stuff if not rendering. - return TRUE; - } - updateDrawable(FALSE); return TRUE; } +// Move an object due to idle-time viewer side updates by iterpolating motion +void LLViewerObject::interpolateLinearMotion(const F64 & time, const F32 & dt) +{ + // linear motion + // PHYSICS_TIMESTEP is used below to correct for the fact that the velocity in object + // updates represents the average velocity of the last timestep, rather than the final velocity. + // the time dilation above should guarantee that dt is never less than PHYSICS_TIMESTEP, theoretically + // + // *TODO: should also wrap linear accel/velocity in check + // to see if object is selected, instead of explicitly + // zeroing it out + + F64 time_since_last_update = time - mLastMessageUpdateSecs; + if (time_since_last_update <= 0.0 || dt <= 0.f) + { + return; + } + + LLVector3 accel = getAcceleration(); + LLVector3 vel = getVelocity(); + + if (sMaxUpdateInterpolationTime <= 0.0) + { // Old code path ... unbounded, simple interpolation + if (!(accel.isExactlyZero() && vel.isExactlyZero())) + { + LLVector3 pos = (vel + (0.5f * (dt-PHYSICS_TIMESTEP)) * accel) * dt; + + // region local + setPositionRegion(pos + getPositionRegion()); + setVelocity(vel + accel*dt); + + // for objects that are spinning but not translating, make sure to flag them as having moved + setChanged(MOVED | SILHOUETTE); + } + } + else if (!accel.isExactlyZero() || !vel.isExactlyZero()) // object is moving + { // Object is moving, and hasn't been too long since we got an update from the server + + // Calculate predicted position and velocity + LLVector3 new_pos = (vel + (0.5f * (dt-PHYSICS_TIMESTEP)) * accel) * dt; + LLVector3 new_v = accel * dt; + + if (time_since_last_update > sPhaseOutUpdateInterpolationTime && + sPhaseOutUpdateInterpolationTime > 0.0) + { // Haven't seen a viewer update in a while, check to see if the ciruit is still active + if (mRegionp) + { // The simulator will NOT send updates if the object continues normally on the path + // predicted by the velocity and the acceleration (often gravity) sent to the viewer + // So check to see if the circuit is blocked, which means the sim is likely in a long lag + LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit( mRegionp->getHost() ); + if (cdp) + { + // Find out how many seconds since last packet arrived on the circuit + F64 time_since_last_packet = LLMessageSystem::getMessageTimeSeconds() - cdp->getLastPacketInTime(); + + if (!cdp->isAlive() || // Circuit is dead or blocked + cdp->isBlocked() || // or doesn't seem to be getting any packets + (time_since_last_packet > sPhaseOutUpdateInterpolationTime)) + { + // Start to reduce motion interpolation since we haven't seen a server update in a while + F64 time_since_last_interpolation = time - mLastInterpUpdateSecs; + F64 phase_out = 1.0; + if (time_since_last_update > sMaxUpdateInterpolationTime) + { // Past the time limit, so stop the object + phase_out = 0.0; + //llinfos << "Motion phase out to zero" << llendl; + + // Kill angular motion as well. Note - not adding this due to paranoia + // about stopping rotation for llTargetOmega objects and not having it restart + // setAngularVelocity(LLVector3::zero); + } + else if (mLastInterpUpdateSecs - mLastMessageUpdateSecs > sPhaseOutUpdateInterpolationTime) + { // Last update was already phased out a bit + phase_out = (sMaxUpdateInterpolationTime - time_since_last_update) / + (sMaxUpdateInterpolationTime - time_since_last_interpolation); + //llinfos << "Continuing motion phase out of " << (F32) phase_out << llendl; + } + else + { // Phase out from full value + phase_out = (sMaxUpdateInterpolationTime - time_since_last_update) / + (sMaxUpdateInterpolationTime - sPhaseOutUpdateInterpolationTime); + //llinfos << "Starting motion phase out of " << (F32) phase_out << llendl; + } + phase_out = llclamp(phase_out, 0.0, 1.0); + + new_pos = new_pos * ((F32) phase_out); + new_v = new_v * ((F32) phase_out); + } + } + } + } + + new_pos = new_pos + getPositionRegion(); + new_v = new_v + vel; + + + // Clamp interpolated position to minimum underground and maximum region height + LLVector3d new_pos_global = mRegionp->getPosGlobalFromRegion(new_pos); + F32 min_height; + if (isAvatar()) + { // Make a better guess about AVs not going underground + min_height = LLWorld::getInstance()->resolveLandHeightGlobal(new_pos_global); + min_height += (0.5f * getScale().mV[VZ]); + } + else + { // This will put the object underground, but we can't tell if it will stop + // at ground level or not + min_height = LLWorld::getInstance()->getMinAllowedZ(this, new_pos_global); + } + + new_pos.mV[VZ] = llmax(min_height, new_pos.mV[VZ]); + new_pos.mV[VZ] = llmin(LLWorld::getInstance()->getRegionMaxHeight(), new_pos.mV[VZ]); + + // Check to see if it's going off the region + LLVector3 temp(new_pos); + if (temp.clamp(0.f, mRegionp->getWidth())) + { // Going off this region, so see if we might end up on another region + LLVector3d old_pos_global = mRegionp->getPosGlobalFromRegion(getPositionRegion()); + new_pos_global = mRegionp->getPosGlobalFromRegion(new_pos); // Re-fetch in case it got clipped above + + // Clip the positions to known regions + LLVector3d clip_pos_global = LLWorld::getInstance()->clipToVisibleRegions(old_pos_global, new_pos_global); + if (clip_pos_global != new_pos_global) + { // Was clipped, so this means we hit a edge where there is no region to enter + + //llinfos << "Hit empty region edge, clipped predicted position to " << mRegionp->getPosRegionFromGlobal(clip_pos_global) + // << " from " << new_pos << llendl; + new_pos = mRegionp->getPosRegionFromGlobal(clip_pos_global); + + // Stop motion and get server update for bouncing on the edge + new_v.clear(); + setAcceleration(LLVector3::zero); + } + else + { // Let predicted movement cross into another region + //llinfos << "Predicting region crossing to " << new_pos << llendl; + } + } + + // Set new position and velocity + setPositionRegion(new_pos); + setVelocity(new_v); + + // for objects that are spinning but not translating, make sure to flag them as having moved + setChanged(MOVED | SILHOUETTE); + } + + // Update the last time we did anything + mLastInterpUpdateSecs = time; +} + + + BOOL LLViewerObject::setData(const U8 *datap, const U32 data_size) { LLMemType mt(LLMemType::MTYPE_OBJECT); @@ -2930,6 +3064,8 @@ void LLViewerObject::setScale(const LLVector3 &scale, BOOL damped) { if (!mOnMap) { + llassert_always(LLWorld::getInstance()->getRegionFromHandle(getRegion()->getHandle())); + gObjectList.addToMap(this); mOnMap = TRUE; } @@ -3031,12 +3167,12 @@ F32 LLViewerObject::getLinksetPhysicsCost() return mLinksetPhysicsCost; } -F32 LLViewerObject::getStreamingCost(S32* bytes, S32* visible_bytes) +F32 LLViewerObject::getStreamingCost(S32* bytes, S32* visible_bytes, F32* unscaled_value) const { return 0.f; } -U32 LLViewerObject::getTriangleCount() +U32 LLViewerObject::getTriangleCount() const { return 0; } diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 591578d78..fe31ec725 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -328,8 +328,8 @@ public: virtual void setScale(const LLVector3 &scale, BOOL damped = FALSE); #if MESH_ENABLED - virtual F32 getStreamingCost(S32* bytes = NULL, S32* visible_bytes = NULL); - virtual U32 getTriangleCount(); + virtual F32 getStreamingCost(S32* bytes = NULL, S32* visible_bytes = NULL, F32* unscaled_value = NULL) const; + virtual U32 getTriangleCount() const; virtual U32 getHighLODTriangleCount(); void setObjectCost(F32 cost); @@ -545,6 +545,9 @@ private: ExtraParameter* getExtraParameterEntryCreate(U16 param_type); bool unpackParameterEntry(U16 param_type, LLDataPacker *dp); + // Motion prediction between updates + void interpolateLinearMotion(const F64 & time, const F32 & dt); + public: // // Viewer-side only types - use the LL_PCODE_APP mask. @@ -735,8 +738,24 @@ protected: mutable LLVector3 mPositionRegion; mutable LLVector3 mPositionAgent; + static void setPhaseOutUpdateInterpolationTime(F32 value) { sPhaseOutUpdateInterpolationTime = (F64) value; } + static void setMaxUpdateInterpolationTime(F32 value) { sMaxUpdateInterpolationTime = (F64) value; } + + static void setVelocityInterpolate(BOOL value) { sVelocityInterpolate = value; } + static void setPingInterpolate(BOOL value) { sPingInterpolate = value; } + private: static S32 sNumObjects; + + static F64 sPhaseOutUpdateInterpolationTime; // For motion interpolation + static F64 sMaxUpdateInterpolationTime; // For motion interpolation + + static BOOL sVelocityInterpolate; + static BOOL sPingInterpolate; + + //-------------------------------------------------------------------- + // For objects that are attachments + //-------------------------------------------------------------------- public: // S32 getAttachmentPoint(); @@ -816,7 +835,4 @@ public: virtual void updateDrawable(BOOL force_damped); }; -extern BOOL gVelocityInterpolate; -extern BOOL gPingInterpolate; - #endif diff --git a/indra/newview/llviewerobjectbackup.cpp b/indra/newview/llviewerobjectbackup.cpp index d3e41550b..7f6325350 100644 --- a/indra/newview/llviewerobjectbackup.cpp +++ b/indra/newview/llviewerobjectbackup.cpp @@ -49,6 +49,7 @@ #include "llsdutil.h" #include "llsdutil_math.h" #include "lltransactiontypes.h" +#include "llinventorydefines.h" // newview includes #include "llagent.h" @@ -61,7 +62,7 @@ #include "llfloaternamedesc.h" #include "llfloatersnapshot.h" #include "llinventorymodel.h" // gInventory -#include "llnotify.h" +#include "llnotificationsutil.h" #include "llresourcedata.h" #include "llselectmgr.h" #include "llstatusbar.h" @@ -560,7 +561,7 @@ void LLObjectBackup::exportWorker(void *userdata) if (LLObjectBackup::getInstance()->mNonExportedTextures == LLObjectBackup::TEXTURE_OK) { LL_INFOS("ObjectBackup") << "Export successful and complete." << LL_ENDL; - LLNotifications::instance().add("ExportSuccessful"); + LLNotificationsUtil::add("ExportSuccessful"); } else { @@ -588,7 +589,7 @@ void LLObjectBackup::exportWorker(void *userdata) } LLSD args; args["REASON"] = reason; - LLNotifications::instance().add("ExportPartial", args); + LLNotificationsUtil::add("ExportPartial", args); } LLObjectBackup::getInstance()->close(); break; @@ -596,7 +597,7 @@ void LLObjectBackup::exportWorker(void *userdata) case EXPORT_FAILED: gIdleCallbacks.deleteFunction(exportWorker); LL_WARNS("ObjectBackup") << "Export process aborted." << LL_ENDL; - LLNotifications::instance().add("ExportFailed"); + LLNotificationsUtil::add("ExportFailed"); LLObjectBackup::getInstance()->close(); break; } diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index ca29e5103..0330f9670 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -38,12 +38,14 @@ #include "timing.h" #include "llfasttimer.h" #include "llrender.h" +#include "llwindow.h" // decBusyCount() #include "llviewercontrol.h" #include "llface.h" #include "llvoavatar.h" #include "llviewerobject.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llnetmap.h" #include "llagent.h" #include "llagentcamera.h" @@ -61,6 +63,7 @@ #include "llresmgr.h" #include "llviewerregion.h" #include "llviewerstats.h" +#include "llvovolume.h" #include "lltoolmgr.h" #include "lltoolpie.h" #include "llkeyboard.h" @@ -597,33 +600,30 @@ void LLViewerObjectList::dirtyAllObjectInventory() void LLViewerObjectList::updateApparentAngles(LLAgent &agent) { S32 i; - S32 const objects_size = mObjects.size(); + S32 num_objects = 0; LLViewerObject *objectp; S32 num_updates, max_value; - // The list can have shrinked since mCurLazyUpdateIndex was last updated. - if (mCurLazyUpdateIndex >= objects_size) - { - mCurLazyUpdateIndex = 0; - } if (NUM_BINS - 1 == mCurBin) { - num_updates = objects_size - mCurLazyUpdateIndex; - max_value = objects_size; + num_updates = (S32) mObjects.size() - mCurLazyUpdateIndex; + max_value = (S32) mObjects.size(); gTextureList.setUpdateStats(TRUE); } else { - num_updates = (objects_size / NUM_BINS) + 1; - max_value = llmin(objects_size, mCurLazyUpdateIndex + num_updates); + num_updates = ((S32) mObjects.size() / NUM_BINS) + 1; + max_value = llmin((S32) mObjects.size(), mCurLazyUpdateIndex + num_updates); } - if (!gNoRender) + + // Slam priorities for textures that we care about (hovered, selected, and focused) + // Hovered + // Assumes only one level deep of parenting + LLSelectNode* nodep = LLSelectMgr::instance().getHoverNode(); + if (nodep) { - // Slam priorities for textures that we care about (hovered, selected, and focused) - // Hovered - // Assumes only one level deep of parenting - objectp = gHoverView->getLastHoverObject(); + objectp = nodep->getObject(); if (objectp) { objectp->boostTexturePriority(); @@ -654,6 +654,8 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent) objectp = mObjects[i]; if (!objectp->isDead()) { + num_objects++; + // Update distance & gpw objectp->setPixelAreaAndAngle(agent); // Also sets the approx. pixel area objectp->updateTextures(); // Update the image levels of textures for this object. @@ -661,7 +663,7 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent) } mCurLazyUpdateIndex = max_value; - if (mCurLazyUpdateIndex == objects_size) + if (mCurLazyUpdateIndex == mObjects.size()) { mCurLazyUpdateIndex = 0; } @@ -861,9 +863,24 @@ private: void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) { LLMemType mt(LLMemType::MTYPE_OBJECT); + // Update globals - gVelocityInterpolate = gSavedSettings.getBOOL("VelocityInterpolate"); - gPingInterpolate = gSavedSettings.getBOOL("PingInterpolate"); + LLViewerObject::setVelocityInterpolate( gSavedSettings.getBOOL("VelocityInterpolate") ); + LLViewerObject::setPingInterpolate( gSavedSettings.getBOOL("PingInterpolate") ); + + F32 interp_time = gSavedSettings.getF32("InterpolationTime"); + F32 phase_out_time = gSavedSettings.getF32("InterpolationPhaseOut"); + if (interp_time < 0.0 || + phase_out_time < 0.0 || + phase_out_time > interp_time) + { + llwarns << "Invalid values for InterpolationTime or InterpolationPhaseOut, resetting to defaults" << llendl; + interp_time = 3.0f; + phase_out_time = 1.0f; + } + LLViewerObject::setPhaseOutUpdateInterpolationTime( interp_time ); + LLViewerObject::setMaxUpdateInterpolationTime( phase_out_time ); + gAnimateTextures = gSavedSettings.getBOOL("AnimateTextures"); // update global timer @@ -956,6 +973,9 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) mNumSizeCulled = 0; mNumVisCulled = 0; + // update max computed render cost + LLVOVolume::updateRenderComplexity(); + // compute all sorts of time-based stats // don't factor frames that were paused into the stats if (! mWasPaused) @@ -1012,10 +1032,10 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) } */ - mNumObjectsStat.addValue((S32) mObjects.size() - mNumDeadObjects); - mNumActiveObjectsStat.addValue(num_active_objects); - mNumSizeCulledStat.addValue(mNumSizeCulled); - mNumVisCulledStat.addValue(mNumVisCulled); + LLViewerStats::getInstance()->mNumObjectsStat.addValue((S32) mObjects.size() - mNumDeadObjects); + LLViewerStats::getInstance()->mNumActiveObjectsStat.addValue(num_active_objects); + LLViewerStats::getInstance()->mNumSizeCulledStat.addValue(mNumSizeCulled); + LLViewerStats::getInstance()->mNumVisCulledStat.addValue(mNumVisCulled); } #if MESH_ENABLED @@ -1660,12 +1680,6 @@ void LLViewerObjectList::renderObjectBounds(const LLVector3 ¢er) { } -void LLViewerObjectList::renderObjectsForSelect(LLCamera &camera, const LLRect& screen_rect, BOOL pick_parcel_wall, BOOL render_transparent) -{ - generatePickList(camera); - renderPickList(screen_rect, pick_parcel_wall, render_transparent); -} - void LLViewerObjectList::generatePickList(LLCamera &camera) { LLViewerObject *objectp; @@ -1789,34 +1803,6 @@ void LLViewerObjectList::generatePickList(LLCamera &camera) } } -void LLViewerObjectList::renderPickList(const LLRect& screen_rect, BOOL pick_parcel_wall, BOOL render_transparent) -{ - gRenderForSelect = TRUE; - - gPipeline.renderForSelect(mSelectPickList, render_transparent, screen_rect); - - // - // Render pass for selected objects - // - gGL.color4f(1,1,1,1); - gViewerWindow->renderSelections( TRUE, pick_parcel_wall, FALSE ); - - //fix for DEV-19335. Don't pick hud objects when customizing avatar (camera mode doesn't play nice with nametags). - if (!gAgentCamera.cameraCustomizeAvatar()) - { - // render pickable ui elements, like names, etc. - LLHUDObject::renderAllForSelect(); - } - - gGL.flush(); - LLVertexBuffer::unbind(); - - gRenderForSelect = FALSE; - - //llinfos << "Rendered " << count << " for select" << llendl; - //llinfos << "Took " << pick_timer.getElapsedTimeF32()*1000.f << "ms to pick" << llendl; -} - LLViewerObject *LLViewerObjectList::getSelectedObject(const U32 object_id) { std::set::iterator pick_it; diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index f38daf617..a458f8e10 100644 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -135,9 +135,7 @@ public: void updateAvatarVisibility(); // Selection related stuff - void renderObjectsForSelect(LLCamera &camera, const LLRect& screen_rect, BOOL pick_parcel_wall = FALSE, BOOL render_transparent = TRUE); void generatePickList(LLCamera &camera); - void renderPickList(const LLRect& screen_rect, BOOL pick_parcel_wall, BOOL render_transparent); LLViewerObject *getSelectedObject(const U32 object_id); @@ -176,17 +174,6 @@ public: U32 mCurBin; // Current bin we're working on... - ////////////////////// - // - // Statistics data - // - // - LLStat mNumObjectsStat; - LLStat mNumActiveObjectsStat; - LLStat mNumNewObjectsStat; - LLStat mNumSizeCulledStat; - LLStat mNumVisCulledStat; - S32 mNumNewObjects; S32 mNumSizeCulled; diff --git a/indra/newview/llviewerparcelmedia.cpp b/indra/newview/llviewerparcelmedia.cpp index 7ebaf5706..a233136b5 100644 --- a/indra/newview/llviewerparcelmedia.cpp +++ b/indra/newview/llviewerparcelmedia.cpp @@ -43,6 +43,7 @@ #include "message.h" #include "llviewermediafocus.h" #include "llviewerparcelmediaautoplay.h" +#include "llnotificationsutil.h" #include "llviewerwindow.h" #include "llfirstuse.h" #include "llpluginclassmedia.h" @@ -120,7 +121,7 @@ void LLViewerParcelMedia::update(LLParcel* parcel) // First use warning if( ! mediaUrl.empty() && gSavedSettings.getWarning("FirstStreamingVideo") ) { - LLNotifications::instance().add("ParcelCanPlayMedia", LLSD(), LLSD(), + LLNotificationsUtil::add("ParcelCanPlayMedia", LLSD(), LLSD(), boost::bind(callback_play_media, _1, _2, parcel)); return; @@ -176,7 +177,7 @@ void LLViewerParcelMedia::update(LLParcel* parcel) { gSavedSettings.setWarning("QuickTimeInstalled", FALSE); - LLNotifications::instance().add("NoQuickTime" ); + LLNotificationsUtil::add("NoQuickTime" ); }; } } @@ -782,7 +783,7 @@ void LLViewerParcelMedia::filterMedia(LLParcel* parcel, U32 type) if (media_action == "deny") { - LLNotifications::instance().add("MediaBlocked", args); + LLNotificationsUtil::add("MediaBlocked", args); if (type == 1) { LLViewerParcelMedia::stopStreamingMusic(); @@ -805,7 +806,7 @@ void LLViewerParcelMedia::filterMedia(LLParcel* parcel, U32 type) { args["TYPE"] = "audio"; } - LLNotifications::instance().add("MediaAlert", args, LLSD(), boost::bind(callback_media_alert, _1, _2, parcel, type, domain)); + LLNotificationsUtil::add("MediaAlert", args, LLSD(), boost::bind(callback_media_alert, _1, _2, parcel, type, domain)); } } @@ -843,7 +844,7 @@ void callback_media_alert(const LLSD ¬ification, const LLSD &response, LLParc } LLViewerParcelMedia::saveDomainFilterList(); args["LISTED"] = "whitelisted"; - LLNotifications::instance().add("MediaListed", args); + LLNotificationsUtil::add("MediaListed", args); } if (type == 0) { @@ -867,7 +868,7 @@ void callback_media_alert(const LLSD ¬ification, const LLSD &response, LLParc } if (option == 1) // Deny { - LLNotifications::instance().add("MediaBlocked", args); + LLNotificationsUtil::add("MediaBlocked", args); } else // Blacklist { @@ -882,7 +883,7 @@ void callback_media_alert(const LLSD ¬ification, const LLSD &response, LLParc } LLViewerParcelMedia::saveDomainFilterList(); args["LISTED"] = "blacklisted"; - LLNotifications::instance().add("MediaListed", args); + LLNotificationsUtil::add("MediaListed", args); } } @@ -933,7 +934,7 @@ void LLViewerParcelMedia::clearDomainFilterList() sAllowedMedia.clear(); sDeniedMedia.clear(); saveDomainFilterList(); - LLNotifications::instance().add("MediaFiltersCleared"); + LLNotificationsUtil::add("MediaFiltersCleared"); SLFloaterMediaFilter::setDirty(); } diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index fa216df28..c79ea10e7 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -39,6 +39,8 @@ #include "indra_constants.h" #include "llcachename.h" #include "llgl.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llparcel.h" #include "llsecondlifeurls.h" #include "message.h" @@ -163,6 +165,8 @@ void LLViewerParcelMgr::init(F32 region_size) { mAgentParcelOverlay[i] = 0; } + + mTeleportInProgress = TRUE; // the initial parcel update is treated like teleport } @@ -524,7 +528,7 @@ LLParcelSelectionHandle LLViewerParcelMgr::selectLand(const LLVector3d &corner1, if (region != region_other) { - LLNotifications::instance().add("CantSelectLandFromMultipleRegions"); + LLNotificationsUtil::add("CantSelectLandFromMultipleRegions"); mSelected = FALSE; notifyObservers(); return NULL; @@ -654,14 +658,13 @@ LLParcel *LLViewerParcelMgr::getAgentParcel() const } // Return whether the agent can build on the land they are on -BOOL LLViewerParcelMgr::agentCanBuild() const +bool LLViewerParcelMgr::allowAgentBuild() const { if (mAgentParcel) { - return (gAgent.isGodlike() - || (mAgentParcel->allowModifyBy( - gAgent.getID(), - gAgent.getGroupID()))); + return (gAgent.isGodlike() || + (mAgentParcel->allowModifyBy(gAgent.getID(), gAgent.getGroupID())) || + (isParcelOwnedByAgent(mAgentParcel, GP_LAND_ALLOW_CREATE))); } else { @@ -669,19 +672,53 @@ BOOL LLViewerParcelMgr::agentCanBuild() const } } -BOOL LLViewerParcelMgr::agentCanTakeDamage() const +// Return whether anyone can build on the given parcel +bool LLViewerParcelMgr::allowAgentBuild(const LLParcel* parcel) const { - return mAgentParcel->getAllowDamage(); + return parcel->getAllowModify(); } -BOOL LLViewerParcelMgr::agentCanFly() const +bool LLViewerParcelMgr::allowAgentVoice() const { - return TRUE; + return allowAgentVoice(gAgent.getRegion(), mAgentParcel); } -F32 LLViewerParcelMgr::agentDrawDistance() const +bool LLViewerParcelMgr::allowAgentVoice(const LLViewerRegion* region, const LLParcel* parcel) const { - return 512.f; + return region && region->isVoiceEnabled() + && parcel && parcel->getParcelFlagAllowVoice(); +} + +bool LLViewerParcelMgr::allowAgentFly(const LLViewerRegion* region, const LLParcel* parcel) const +{ + return region && !region->getBlockFly() + && parcel && parcel->getAllowFly(); +} + +// Can the agent be pushed around by LLPushObject? +bool LLViewerParcelMgr::allowAgentPush(const LLViewerRegion* region, const LLParcel* parcel) const +{ + return region && !region->getRestrictPushObject() + && parcel && !parcel->getRestrictPushObject(); +} + +bool LLViewerParcelMgr::allowAgentScripts(const LLViewerRegion* region, const LLParcel* parcel) const +{ + // *NOTE: This code does not take into account group-owned parcels + // and the flag to allow group-owned scripted objects to run. + // This mirrors the traditional menu bar parcel icon code, but is not + // technically correct. + return region + && !(region->getRegionFlags() & REGION_FLAGS_SKIP_SCRIPTS) + && !(region->getRegionFlags() & REGION_FLAGS_ESTATE_SKIP_SCRIPTS) + && parcel + && parcel->getAllowOtherScripts(); +} + +bool LLViewerParcelMgr::allowAgentDamage(const LLViewerRegion* region, const LLParcel* parcel) const +{ + return (region && region->getAllowDamage()) + || (parcel && parcel->getAllowDamage()); } BOOL LLViewerParcelMgr::isOwnedAt(const LLVector3d& pos_global) const @@ -920,7 +957,7 @@ void LLViewerParcelMgr::sendParcelGodForceOwner(const LLUUID& owner_id) { if (!mSelected) { - LLNotifications::instance().add("CannotSetLandOwnerNothingSelected"); + LLNotificationsUtil::add("CannotSetLandOwnerNothingSelected"); return; } @@ -935,7 +972,7 @@ void LLViewerParcelMgr::sendParcelGodForceOwner(const LLUUID& owner_id) if (!region) { // TODO: Add a force owner version of this alert. - LLNotifications::instance().add("CannotContentifyNoRegion"); + LLNotificationsUtil::add("CannotContentifyNoRegion"); return; } @@ -943,7 +980,7 @@ void LLViewerParcelMgr::sendParcelGodForceOwner(const LLUUID& owner_id) LLViewerRegion *region2 = LLWorld::getInstance()->getRegionFromPosGlobal( east_north_region_check ); if (region != region2) { - LLNotifications::instance().add("CannotSetLandOwnerMultipleRegions"); + LLNotificationsUtil::add("CannotSetLandOwnerMultipleRegions"); return; } @@ -988,13 +1025,13 @@ void LLViewerParcelMgr::sendParcelGodForceToContent() { if (!mSelected) { - LLNotifications::instance().add("CannotContentifyNothingSelected"); + LLNotificationsUtil::add("CannotContentifyNothingSelected"); return; } LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal( mWestSouth ); if (!region) { - LLNotifications::instance().add("CannotContentifyNoRegion"); + LLNotificationsUtil::add("CannotContentifyNoRegion"); return; } @@ -1012,14 +1049,14 @@ void LLViewerParcelMgr::sendParcelRelease() { if (!mSelected) { - LLNotifications::instance().add("CannotReleaseLandNothingSelected"); + LLNotificationsUtil::add("CannotReleaseLandNothingSelected"); return; } LLViewerRegion *region = LLWorld::getInstance()->getRegionFromPosGlobal( mWestSouth ); if (!region) { - LLNotifications::instance().add("CannotReleaseLandNoRegion"); + LLNotificationsUtil::add("CannotReleaseLandNoRegion"); return; } @@ -1074,14 +1111,14 @@ LLViewerParcelMgr::ParcelBuyInfo* LLViewerParcelMgr::setupParcelBuy( { if (!mSelected || !mCurrentParcel) { - LLNotifications::instance().add("CannotBuyLandNothingSelected"); + LLNotificationsUtil::add("CannotBuyLandNothingSelected"); return NULL; } LLViewerRegion *region = LLWorld::getInstance()->getRegionFromPosGlobal( mWestSouth ); if (!region) { - LLNotifications::instance().add("CannotBuyLandNoRegion"); + LLNotificationsUtil::add("CannotBuyLandNoRegion"); return NULL; } @@ -1099,7 +1136,7 @@ LLViewerParcelMgr::ParcelBuyInfo* LLViewerParcelMgr::setupParcelBuy( if (region != region2) { - LLNotifications::instance().add("CantBuyLandAcrossMultipleRegions"); + LLNotificationsUtil::add("CantBuyLandAcrossMultipleRegions"); return NULL; } } @@ -1170,28 +1207,29 @@ void LLViewerParcelMgr::sendParcelBuy(ParcelBuyInfo* info) msg->sendReliable(info->mHost); } -void LLViewerParcelMgr::deleteParcelBuy(ParcelBuyInfo*& info) +void LLViewerParcelMgr::deleteParcelBuy(ParcelBuyInfo* *info) { - delete info; - info = NULL; + // Must be here because ParcelBuyInfo is local to this .cpp file + delete *info; + *info = NULL; } void LLViewerParcelMgr::sendParcelDeed(const LLUUID& group_id) { if (!mSelected || !mCurrentParcel) { - LLNotifications::instance().add("CannotDeedLandNothingSelected"); + LLNotificationsUtil::add("CannotDeedLandNothingSelected"); return; } if(group_id.isNull()) { - LLNotifications::instance().add("CannotDeedLandNoGroup"); + LLNotificationsUtil::add("CannotDeedLandNoGroup"); return; } LLViewerRegion *region = LLWorld::getInstance()->getRegionFromPosGlobal( mWestSouth ); if (!region) { - LLNotifications::instance().add("CannotDeedLandNoRegion"); + LLNotificationsUtil::add("CannotDeedLandNoRegion"); return; } @@ -1291,9 +1329,15 @@ void LLViewerParcelMgr::sendParcelPropertiesUpdate(LLParcel* parcel, bool use_ag } -void LLViewerParcelMgr::requestHoverParcelProperties(const LLVector3d& pos) +void LLViewerParcelMgr::setHoverParcel(const LLVector3d& pos) { static U32 last_west, last_south; + + // only request parcel info when tooltip is shown + if (!gSavedSettings.getBOOL("ShowLandHoverTip")) + { + return; + } // only request parcel info if position has changed outside of the // last parcel grid step U32 west_parcel_step = (U32) floor( pos.mdV[VX] / PARCEL_GRID_STEP_METERS ); @@ -1544,9 +1588,19 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use LLViewerParcelMgr::getInstance()->writeAgentParcelFromBitmap(bitmap); delete[] bitmap; + + // Let interesting parties know about agent parcel change. + LLViewerParcelMgr* instance = LLViewerParcelMgr::getInstance(); + + instance->mAgentParcelChangedSignal(); + + if (instance->mTeleportInProgress) + { + instance->mTeleportInProgress = FALSE; + instance->mTeleportFinishedSignal(gAgent.getPositionGlobal()); + } } } - // Add any pending entry to the TP history now that we got the *new* parcel name. LLFloaterTeleportHistory::getInstance()->addEntry(LLViewerParcelMgr::getInstance()->getAgentParcelName()); @@ -2023,11 +2077,11 @@ void LLViewerParcelMgr::deedLandToGroup() std::string full_name; gCacheName->getFullName(mCurrentParcel->getOwnerID(),full_name); args["NAME"] = full_name; - LLNotifications::instance().add("DeedLandToGroupWithContribution",args, LLSD(), deedAlertCB); + LLNotificationsUtil::add("DeedLandToGroupWithContribution",args, LLSD(), deedAlertCB); } else { - LLNotifications::instance().add("DeedLandToGroup",args, LLSD(), deedAlertCB); + LLNotificationsUtil::add("DeedLandToGroup",args, LLSD(), deedAlertCB); } } @@ -2053,26 +2107,26 @@ void LLViewerParcelMgr::startReleaseLand() { if (!mSelected) { - LLNotifications::instance().add("CannotReleaseLandNothingSelected"); + LLNotificationsUtil::add("CannotReleaseLandNothingSelected"); return; } if (mRequestResult == PARCEL_RESULT_NO_DATA) { - LLNotifications::instance().add("CannotReleaseLandWatingForServer"); + LLNotificationsUtil::add("CannotReleaseLandWatingForServer"); return; } if (mRequestResult == PARCEL_RESULT_MULTIPLE) { - LLNotifications::instance().add("CannotReleaseLandSelected"); + LLNotificationsUtil::add("CannotReleaseLandSelected"); return; } if (!isParcelOwnedByAgent(mCurrentParcel, GP_LAND_RELEASE) && !(gAgent.canManageEstate())) { - LLNotifications::instance().add("CannotReleaseLandDontOwn"); + LLNotificationsUtil::add("CannotReleaseLandDontOwn"); return; } @@ -2080,7 +2134,7 @@ void LLViewerParcelMgr::startReleaseLand() LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal(parcel_center); if (!region) { - LLNotifications::instance().add("CannotReleaseLandRegionNotFound"); + LLNotificationsUtil::add("CannotReleaseLandRegionNotFound"); return; } /* @@ -2089,21 +2143,21 @@ void LLViewerParcelMgr::startReleaseLand() { LLSD args; args["REGION"] = region->getName(); - LLNotifications::instance().add("CannotReleaseLandNoTransfer", args); + LLNotificationsUtil::add("CannotReleaseLandNoTransfer", args); return; } */ if (!mCurrentParcelSelection->mWholeParcelSelected) { - LLNotifications::instance().add("CannotReleaseLandPartialSelection"); + LLNotificationsUtil::add("CannotReleaseLandPartialSelection"); return; } // Compute claim price LLSD args; args["AREA"] = llformat("%d",mCurrentParcel->getArea()); - LLNotifications::instance().add("ReleaseLandWarning", args, LLSD(), releaseAlertCB); + LLNotificationsUtil::add("ReleaseLandWarning", args, LLSD(), releaseAlertCB); } bool LLViewerParcelMgr::canAgentBuyParcel(LLParcel* parcel, bool forGroup) const @@ -2158,7 +2212,10 @@ bool LLViewerParcelMgr::canAgentBuyParcel(LLParcel* parcel, bool forGroup) const = parcelOwner == (forGroup ? gAgent.getGroupID() : gAgent.getID()); bool isAuthorized - = (authorizeBuyer.isNull() || (gAgent.getID() == authorizeBuyer)); + = (authorizeBuyer.isNull() + || (gAgent.getID() == authorizeBuyer) + || (gAgent.hasPowerInGroup(authorizeBuyer,GP_LAND_DEED) + && gAgent.hasPowerInGroup(authorizeBuyer,GP_LAND_SET_SALE_INFO))); return isForSale && !isOwner && isAuthorized && isEmpowered; } @@ -2178,13 +2235,13 @@ void LLViewerParcelMgr::startDivideLand() { if (!mSelected) { - LLNotifications::instance().add("CannotDivideLandNothingSelected"); + LLNotificationsUtil::add("CannotDivideLandNothingSelected"); return; } if (mCurrentParcelSelection->mWholeParcelSelected) { - LLNotifications::instance().add("CannotDivideLandPartialSelection"); + LLNotificationsUtil::add("CannotDivideLandPartialSelection"); return; } @@ -2192,7 +2249,7 @@ void LLViewerParcelMgr::startDivideLand() payload["west_south_border"] = ll_sd_from_vector3d(mWestSouth); payload["east_north_border"] = ll_sd_from_vector3d(mEastNorth); - LLNotifications::instance().add("LandDivideWarning", LLSD(), payload, callbackDivideLand); + LLNotificationsUtil::add("LandDivideWarning", LLSD(), payload, callbackDivideLand); } // static @@ -2206,7 +2263,7 @@ bool LLViewerParcelMgr::callbackDivideLand(const LLSD& notification, const LLSD& LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal(parcel_center); if (!region) { - LLNotifications::instance().add("CannotDivideLandNoRegion"); + LLNotificationsUtil::add("CannotDivideLandNoRegion"); return false; } @@ -2235,19 +2292,19 @@ void LLViewerParcelMgr::startJoinLand() { if (!mSelected) { - LLNotifications::instance().add("CannotJoinLandNothingSelected"); + LLNotificationsUtil::add("CannotJoinLandNothingSelected"); return; } if (mCurrentParcelSelection->mWholeParcelSelected) { - LLNotifications::instance().add("CannotJoinLandEntireParcelSelected"); + LLNotificationsUtil::add("CannotJoinLandEntireParcelSelected"); return; } if (!mCurrentParcelSelection->mSelectedMultipleOwners) { - LLNotifications::instance().add("CannotJoinLandSelection"); + LLNotificationsUtil::add("CannotJoinLandSelection"); return; } @@ -2255,7 +2312,7 @@ void LLViewerParcelMgr::startJoinLand() payload["west_south_border"] = ll_sd_from_vector3d(mWestSouth); payload["east_north_border"] = ll_sd_from_vector3d(mEastNorth); - LLNotifications::instance().add("JoinLandWarning", LLSD(), payload, callbackJoinLand); + LLNotificationsUtil::add("JoinLandWarning", LLSD(), payload, callbackJoinLand); } // static @@ -2269,7 +2326,7 @@ bool LLViewerParcelMgr::callbackJoinLand(const LLSD& notification, const LLSD& r LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal(parcel_center); if (!region) { - LLNotifications::instance().add("CannotJoinLandNoRegion"); + LLNotificationsUtil::add("CannotJoinLandNoRegion"); return false; } @@ -2298,19 +2355,19 @@ void LLViewerParcelMgr::startDeedLandToGroup() { if (!mSelected || !mCurrentParcel) { - LLNotifications::instance().add("CannotDeedLandNothingSelected"); + LLNotificationsUtil::add("CannotDeedLandNothingSelected"); return; } if (mRequestResult == PARCEL_RESULT_NO_DATA) { - LLNotifications::instance().add("CannotDeedLandWaitingForServer"); + LLNotificationsUtil::add("CannotDeedLandWaitingForServer"); return; } if (mRequestResult == PARCEL_RESULT_MULTIPLE) { - LLNotifications::instance().add("CannotDeedLandMultipleSelected"); + LLNotificationsUtil::add("CannotDeedLandMultipleSelected"); return; } @@ -2318,7 +2375,7 @@ void LLViewerParcelMgr::startDeedLandToGroup() LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal(parcel_center); if (!region) { - LLNotifications::instance().add("CannotDeedLandNoRegion"); + LLNotificationsUtil::add("CannotDeedLandNoRegion"); return; } @@ -2330,7 +2387,7 @@ void LLViewerParcelMgr::startDeedLandToGroup() { LLSD args; args["REGION"] = region->getName(); - LLNotifications::instance().add("CannotDeedLandNoTransfer", args); + LLNotificationsUtil::add("CannotDeedLandNoTransfer", args); return; } } @@ -2480,3 +2537,52 @@ LLViewerTexture* LLViewerParcelMgr::getPassImage() const { return sPassImage; } + +boost::signals2::connection LLViewerParcelMgr::addAgentParcelChangedCallback(parcel_changed_callback_t cb) +{ + return mAgentParcelChangedSignal.connect(cb); +} +/* + * Set finish teleport callback. You can use it to observe all teleport events. + * NOTE: + * After local( in one region) teleports we + * cannot rely on gAgent.getPositionGlobal(), + * so the new position gets passed explicitly. + * Use args of this callback to get global position of avatar after teleport event. + */ +boost::signals2::connection LLViewerParcelMgr::setTeleportFinishedCallback(teleport_finished_callback_t cb) +{ + return mTeleportFinishedSignal.connect(cb); +} + +boost::signals2::connection LLViewerParcelMgr::setTeleportFailedCallback(parcel_changed_callback_t cb) +{ + return mTeleportFailedSignal.connect(cb); +} + +/* Ok, we're notified that teleport has been finished. + * We should now propagate the notification via mTeleportFinishedSignal + * to all interested parties. + */ +void LLViewerParcelMgr::onTeleportFinished(bool local, const LLVector3d& new_pos) +{ + // Treat only teleports within the same parcel as local (EXT-3139). + if (local && LLViewerParcelMgr::getInstance()->inAgentParcel(new_pos)) + { + // Local teleport. We already have the agent parcel data. + // Emit the signal immediately. + getInstance()->mTeleportFinishedSignal(new_pos); + } + else + { + // Non-local teleport (inter-region or between different parcels of the same region). + // The agent parcel data has not been updated yet. + // Let's wait for the update and then emit the signal. + mTeleportInProgress = TRUE; + } +} + +void LLViewerParcelMgr::onTeleportFailed() +{ + mTeleportFailedSignal(); +} diff --git a/indra/newview/llviewerparcelmgr.h b/indra/newview/llviewerparcelmgr.h index 43e79125c..bdbd471aa 100644 --- a/indra/newview/llviewerparcelmgr.h +++ b/indra/newview/llviewerparcelmgr.h @@ -68,6 +68,9 @@ const F32 PARCEL_POST_HEIGHT = 0.666f; // Base class for people who want to "observe" changes in the viewer // parcel selection. + +//FIXME: this should be done by grabbing a floating parcel selection and observing changes on it, not the parcel mgr +//--RN class LLParcelObserver { public: @@ -79,6 +82,11 @@ class LLViewerParcelMgr : public LLSingleton { public: + typedef boost::function teleport_finished_callback_t; + typedef boost::signals2::signal teleport_finished_signal_t; + typedef boost::function parcel_changed_callback_t; + typedef boost::signals2::signal parcel_changed_signal_t; + LLViewerParcelMgr(); ~LLViewerParcelMgr(); @@ -162,10 +170,31 @@ public: LLParcel* getCollisionParcel() const; - BOOL agentCanTakeDamage() const; - BOOL agentCanFly() const; - F32 agentDrawDistance() const; - BOOL agentCanBuild() const; + // Can this agent build on the parcel he is on? + // Used for parcel property icons in nav bar. + bool allowAgentBuild() const; + bool allowAgentBuild(const LLParcel* parcel) const; + + // Can this agent speak on the parcel he is on? + // Used for parcel property icons in nav bar. + bool allowAgentVoice() const; + bool allowAgentVoice(const LLViewerRegion* region, const LLParcel* parcel) const; + + // Can this agent start flying on this parcel? + // Used for parcel property icons in nav bar. + bool allowAgentFly(const LLViewerRegion* region, const LLParcel* parcel) const; + + // Can this agent be pushed by llPushObject() on this parcel? + // Used for parcel property icons in nav bar. + bool allowAgentPush(const LLViewerRegion* region, const LLParcel* parcel) const; + + // Can scripts written by non-parcel-owners run on the agent's current + // parcel? Used for parcel property icons in nav bar. + bool allowAgentScripts(const LLViewerRegion* region, const LLParcel* parcel) const; + + // Can the agent be damaged here? + // Used for parcel property icons in nav bar. + bool allowAgentDamage(const LLViewerRegion* region, const LLParcel* parcel) const; F32 getHoverParcelWidth() const { return F32(mHoverEastNorth.mdV[VX] - mHoverWestSouth.mdV[VX]); } @@ -211,7 +240,7 @@ public: void sendParcelDwellRequest(); // If the point is outside the current hover parcel, request more data - void requestHoverParcelProperties(const LLVector3d& pos_global); + void setHoverParcel(const LLVector3d& pos_global); bool canAgentBuyParcel(LLParcel*, bool forGroup) const; @@ -237,7 +266,7 @@ public: BOOL remove_contribution); // callers responsibility to call deleteParcelBuy() on return value void sendParcelBuy(ParcelBuyInfo*); - void deleteParcelBuy(ParcelBuyInfo*&); + void deleteParcelBuy(ParcelBuyInfo* *); void sendParcelDeed(const LLUUID& group_id); @@ -263,6 +292,12 @@ public: // the agent is banned or not in the allowed group BOOL isCollisionBanned(); + boost::signals2::connection addAgentParcelChangedCallback(parcel_changed_callback_t cb); + boost::signals2::connection setTeleportFinishedCallback(teleport_finished_callback_t cb); + boost::signals2::connection setTeleportFailedCallback(parcel_changed_callback_t cb); + void onTeleportFinished(bool local, const LLVector3d& new_pos); + void onTeleportFailed(); + static BOOL isParcelOwnedByAgent(const LLParcel* parcelp, U64 group_proxy_power); static BOOL isParcelModifiableByAgent(const LLParcel* parcelp, U64 group_proxy_power); @@ -310,6 +345,11 @@ private: LLDynamicArray mObservers; + BOOL mTeleportInProgress; + teleport_finished_signal_t mTeleportFinishedSignal; + parcel_changed_signal_t mTeleportFailedSignal; + parcel_changed_signal_t mAgentParcelChangedSignal; + // Array of pieces of parcel edges to potentially draw // Has (parcels_per_edge + 1) * (parcels_per_edge + 1) elements so // we can represent edges of the grid. diff --git a/indra/newview/llviewerparceloverlay.cpp b/indra/newview/llviewerparceloverlay.cpp index 27494aba4..7989b6686 100644 --- a/indra/newview/llviewerparceloverlay.cpp +++ b/indra/newview/llviewerparceloverlay.cpp @@ -43,15 +43,16 @@ // newview includes #include "llagentcamera.h" +#include "llviewertexture.h" #include "llviewercontrol.h" #include "llsurface.h" #include "llviewerregion.h" -#include "llagent.h" #include "llviewercamera.h" #include "llviewertexturelist.h" #include "llselectmgr.h" #include "llfloatertools.h" #include "llglheaders.h" +#include "pipeline.h" const U8 OVERLAY_IMG_COMPONENTS = 4; @@ -149,6 +150,120 @@ BOOL LLViewerParcelOverlay::isOwnedOther(const LLVector3& pos) const return (PARCEL_OWNED == overlay || PARCEL_FOR_SALE == overlay); } +bool LLViewerParcelOverlay::encroachesOwned(const std::vector& boxes) const +{ + // boxes are expected to already be axis aligned + for (U32 i = 0; i < boxes.size(); ++i) + { + LLVector3 min = boxes[i].getMinAgent(); + LLVector3 max = boxes[i].getMaxAgent(); + + S32 left = S32(llclamp((min.mV[VX] / PARCEL_GRID_STEP_METERS), 0.f, REGION_WIDTH_METERS - 1)); + S32 right = S32(llclamp((max.mV[VX] / PARCEL_GRID_STEP_METERS), 0.f, REGION_WIDTH_METERS - 1)); + S32 top = S32(llclamp((min.mV[VY] / PARCEL_GRID_STEP_METERS), 0.f, REGION_WIDTH_METERS - 1)); + S32 bottom = S32(llclamp((max.mV[VY] / PARCEL_GRID_STEP_METERS), 0.f, REGION_WIDTH_METERS - 1)); + + for (S32 row = top; row <= bottom; row++) + { + for (S32 column = left; column <= right; column++) + { + U8 type = ownership(row, column); + if ((PARCEL_SELF == type) + || (PARCEL_GROUP == type)) + { + return true; + } + } + } + } + return false; +} +bool LLViewerParcelOverlay::encroachesOnUnowned(const std::vector& boxes) const +{ + // boxes are expected to already be axis aligned + for (U32 i = 0; i < boxes.size(); ++i) + { + LLVector3 min = boxes[i].getMinAgent(); + LLVector3 max = boxes[i].getMaxAgent(); + + S32 left = S32(llclamp((min.mV[VX] / PARCEL_GRID_STEP_METERS), 0.f, REGION_WIDTH_METERS - 1)); + S32 right = S32(llclamp((max.mV[VX] / PARCEL_GRID_STEP_METERS), 0.f, REGION_WIDTH_METERS - 1)); + S32 top = S32(llclamp((min.mV[VY] / PARCEL_GRID_STEP_METERS), 0.f, REGION_WIDTH_METERS - 1)); + S32 bottom = S32(llclamp((max.mV[VY] / PARCEL_GRID_STEP_METERS), 0.f, REGION_WIDTH_METERS - 1)); + + for (S32 row = top; row <= bottom; row++) + { + for (S32 column = left; column <= right; column++) + { + U8 type = ownership(row, column); + if ((PARCEL_SELF != type)) + { + return true; + } + } + } + } + return false; +} + +bool LLViewerParcelOverlay::encroachesOnNearbyParcel(const std::vector& boxes) const +{ + // boxes are expected to already be axis aligned + for (U32 i = 0; i < boxes.size(); ++i) + { + LLVector3 min = boxes[i].getMinAgent(); + LLVector3 max = boxes[i].getMaxAgent(); + + // If an object crosses region borders it crosses a parcel + if ( min.mV[VX] < 0 + || min.mV[VY] < 0 + || max.mV[VX] > REGION_WIDTH_METERS + || max.mV[VY] > REGION_WIDTH_METERS) + { + return true; + } + + S32 left = S32(llclamp((min.mV[VX] / PARCEL_GRID_STEP_METERS), 0.f, REGION_WIDTH_METERS - 1)); + S32 right = S32(llclamp((max.mV[VX] / PARCEL_GRID_STEP_METERS), 0.f, REGION_WIDTH_METERS - 1)); + S32 bottom = S32(llclamp((min.mV[VY] / PARCEL_GRID_STEP_METERS), 0.f, REGION_WIDTH_METERS - 1)); + S32 top = S32(llclamp((max.mV[VY] / PARCEL_GRID_STEP_METERS), 0.f, REGION_WIDTH_METERS - 1)); + + const S32 GRIDS_PER_EDGE = mParcelGridsPerEdge; + + for (S32 row = bottom; row <= top; row++) + { + for (S32 col = left; col <= right; col++) + { + // This is not the rightmost column + if (col < GRIDS_PER_EDGE-1) + { + U8 east_overlay = mOwnership[row*GRIDS_PER_EDGE+col+1]; + // If the column to the east of the current one marks + // the other parcel's west edge and the box extends + // to the west it crosses the parcel border. + if ((east_overlay & PARCEL_WEST_LINE) && col < right) + { + return true; + } + } + + // This is not the topmost column + if (row < GRIDS_PER_EDGE-1) + { + U8 north_overlay = mOwnership[(row+1)*GRIDS_PER_EDGE+col]; + // If the row to the north of the current one marks + // the other parcel's south edge and the box extends + // to the south it crosses the parcel border. + if ((north_overlay & PARCEL_SOUTH_LINE) && row < top) + { + return true; + } + } + } + } + } + return false; +} BOOL LLViewerParcelOverlay::isSoundLocal(const LLVector3& pos) const { S32 row = S32(pos.mV[VY] / PARCEL_GRID_STEP_METERS); @@ -299,7 +414,7 @@ void LLViewerParcelOverlay::uncompressLandOverlay(S32 chunk, U8 *packed_overlay) { // Unpack the message data into the ownership array S32 size = mParcelGridsPerEdge * mParcelGridsPerEdge; - S32 mParcelOverLayChunks = mRegionSize * mRegionSize / (128 * 128); + S32 mParcelOverLayChunks = mRegionSize * mRegionSize / (128 * 128); S32 chunk_size = size / mParcelOverLayChunks; memcpy(mOwnership + chunk*chunk_size, packed_overlay, chunk_size); /*Flawfinder: ignore*/ @@ -809,7 +924,7 @@ S32 LLViewerParcelOverlay::renderPropertyLines () F32* vertexp; U8* colorp; - const F32 PROPERTY_LINE_CLIP_DIST = 256.f; + const F32 PROPERTY_LINE_CLIP_DIST_SQUARED = 256.f * 256.f; for (i = 0; i < mVertexCount; i += vertex_per_edge) { @@ -820,7 +935,7 @@ S32 LLViewerParcelOverlay::renderPropertyLines () vertex.mV[VY] = *(vertexp+1); vertex.mV[VZ] = *(vertexp+2); - if (dist_vec_squared2D(vertex, camera_region) > PROPERTY_LINE_CLIP_DIST*PROPERTY_LINE_CLIP_DIST) + if (dist_vec_squared2D(vertex, camera_region) > PROPERTY_LINE_CLIP_DIST_SQUARED) { continue; } diff --git a/indra/newview/llviewerparceloverlay.h b/indra/newview/llviewerparceloverlay.h index 97f2ec2b8..111ccd687 100644 --- a/indra/newview/llviewerparceloverlay.h +++ b/indra/newview/llviewerparceloverlay.h @@ -36,6 +36,7 @@ // The ownership data for land parcels. // One of these structures per region. +#include "llbbox.h" #include "lldarray.h" #include "llframetimer.h" #include "lluuid.h" @@ -60,6 +61,14 @@ public: BOOL isOwnedSelf(const LLVector3& pos) const; BOOL isOwnedGroup(const LLVector3& pos) const; BOOL isOwnedOther(const LLVector3& pos) const; + + // "encroaches" means the prim hangs over the parcel, but its center + // might be in another parcel. for now, we simply test axis aligned + // bounding boxes which isn't perfect, but is close + bool encroachesOwned(const std::vector& boxes) const; + bool encroachesOnUnowned(const std::vector& boxes) const; + bool encroachesOnNearbyParcel(const std::vector& boxes) const; + BOOL isSoundLocal(const LLVector3& pos) const; BOOL isBuildCameraAllowed(const LLVector3& pos) const; diff --git a/indra/newview/llviewerpartsim.h b/indra/newview/llviewerpartsim.h index f13a9a89f..8f1f72518 100644 --- a/indra/newview/llviewerpartsim.h +++ b/indra/newview/llviewerpartsim.h @@ -35,7 +35,7 @@ #include "lldarrayptr.h" #include "llframetimer.h" -#include "llmemory.h" +#include "llpointer.h" #include "llpartdata.h" #include "llviewerpartsource.h" diff --git a/indra/newview/llviewerpartsource.h b/indra/newview/llviewerpartsource.h index 2aa2bfaa1..540e30eb1 100644 --- a/indra/newview/llviewerpartsource.h +++ b/indra/newview/llviewerpartsource.h @@ -33,8 +33,9 @@ #ifndef LL_LLVIEWERPARTSOURCE_H #define LL_LLVIEWERPARTSOURCE_H -#include "llmemory.h" +#include "llrefcount.h" #include "llpartdata.h" +#include "llpointer.h" #include "llquaternion.h" #include "v3math.h" diff --git a/indra/newview/llviewerpluginmanager.cpp b/indra/newview/llviewerpluginmanager.cpp index fdd48736e..4dc8b0e14 100644 --- a/indra/newview/llviewerpluginmanager.cpp +++ b/indra/newview/llviewerpluginmanager.cpp @@ -32,7 +32,7 @@ #include "llviewerprecompiledheaders.h" #include "llviewerpluginmanager.h" -#include "llnotifications.h" +#include "llnotificationsutil.h" void LLViewerPluginManager::destroyPlugin() { @@ -61,6 +61,6 @@ void LLViewerPluginManager::send_plugin_failure_warning(std::string const& plugi LL_WARNS("Plugin") << "plugin intialization failed for plugin: " << plugin_basename << LL_ENDL; LLSD args; args["MIME_TYPE"] = plugin_basename; // FIXME: Use different notification. - LLNotifications::instance().add("NoPlugin", args); + LLNotificationsUtil::add("NoPlugin", args); } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 7d1b7ca29..f7f860385 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -72,16 +72,42 @@ LLVector4 gShinyOrigin; LLGLSLShader gWLSkyProgram(LLViewerShaderMgr::SHADER_WINDLIGHT); LLGLSLShader gWLCloudProgram(LLViewerShaderMgr::SHADER_WINDLIGHT); +//utility shaders +LLGLSLShader gOcclusionProgram(LLViewerShaderMgr::SHADER_INTERFACE); +LLGLSLShader gCustomAlphaProgram(LLViewerShaderMgr::SHADER_INTERFACE); +LLGLSLShader gGlowCombineProgram(LLViewerShaderMgr::SHADER_INTERFACE); +LLGLSLShader gTwoTextureAddProgram(LLViewerShaderMgr::SHADER_INTERFACE); +LLGLSLShader gUIProgram(LLViewerShaderMgr::SHADER_INTERFACE); +LLGLSLShader gSolidColorProgram(LLViewerShaderMgr::SHADER_INTERFACE); + //object shaders LLGLSLShader gObjectSimpleProgram(LLViewerShaderMgr::SHADER_OBJECT); LLGLSLShader gObjectSimpleWaterProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectSimpleAlphaMaskProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectSimpleWaterAlphaMaskProgram(LLViewerShaderMgr::SHADER_OBJECT); LLGLSLShader gObjectFullbrightProgram(LLViewerShaderMgr::SHADER_OBJECT); LLGLSLShader gObjectFullbrightWaterProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectFullbrightAlphaMaskProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectFullbrightWaterAlphaMaskProgram(LLViewerShaderMgr::SHADER_OBJECT); LLGLSLShader gObjectFullbrightShinyProgram(LLViewerShaderMgr::SHADER_OBJECT); LLGLSLShader gObjectFullbrightShinyWaterProgram(LLViewerShaderMgr::SHADER_OBJECT); LLGLSLShader gObjectShinyProgram(LLViewerShaderMgr::SHADER_OBJECT); LLGLSLShader gObjectShinyWaterProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectBumpProgram(LLViewerShaderMgr::SHADER_OBJECT); + +LLGLSLShader gObjectSimpleNonIndexedProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectSimpleNonIndexedWaterProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectAlphaMaskNonIndexedProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectAlphaMaskNonIndexedWaterProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectFullbrightNonIndexedProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectFullbrightNonIndexedWaterProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectFullbrightShinyNonIndexedProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectFullbrightShinyNonIndexedWaterProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectShinyNonIndexedProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectShinyNonIndexedWaterProgram(LLViewerShaderMgr::SHADER_OBJECT); + + #if MESH_ENABLED //object hardware skinning shaders @@ -110,7 +136,8 @@ LLGLSLShader gAvatarProgram(LLViewerShaderMgr::SHADER_AVATAR); LLGLSLShader gAvatarWaterProgram(LLViewerShaderMgr::SHADER_AVATAR); LLGLSLShader gAvatarEyeballProgram(LLViewerShaderMgr::SHADER_AVATAR); LLGLSLShader gAvatarPickProgram(LLViewerShaderMgr::SHADER_AVATAR); //Not in mShaderList - +LLGLSLShader gImpostorProgram(LLViewerShaderMgr::SHADER_OBJECT); + // Effects Shaders LLGLSLShader gGlowProgram(LLViewerShaderMgr::SHADER_EFFECT); //Not in mShaderList LLGLSLShader gGlowExtractProgram(LLViewerShaderMgr::SHADER_EFFECT); //Not in mShaderList @@ -123,6 +150,9 @@ LLGLSLShader gDeferredImpostorProgram(LLViewerShaderMgr::SHADER_DEFERRED); LLGLSLShader gDeferredEdgeProgram(LLViewerShaderMgr::SHADER_DEFERRED); LLGLSLShader gDeferredWaterProgram(LLViewerShaderMgr::SHADER_DEFERRED); //calculatesAtmospherics LLGLSLShader gDeferredDiffuseProgram(LLViewerShaderMgr::SHADER_DEFERRED);//Not in mShaderList +LLGLSLShader gDeferredDiffuseAlphaMaskProgram(LLViewerShaderMgr::SHADER_DEFERRED); +LLGLSLShader gDeferredNonIndexedDiffuseProgram(LLViewerShaderMgr::SHADER_DEFERRED); +LLGLSLShader gDeferredNonIndexedDiffuseAlphaMaskProgram(LLViewerShaderMgr::SHADER_DEFERRED); #if MESH_ENABLED LLGLSLShader gDeferredSkinnedDiffuseProgram(LLViewerShaderMgr::SHADER_DEFERRED); LLGLSLShader gDeferredSkinnedBumpProgram(LLViewerShaderMgr::SHADER_DEFERRED); @@ -141,6 +171,7 @@ LLGLSLShader gDeferredSunProgram(LLViewerShaderMgr::SHADER_DEFERRED); LLGLSLShader gDeferredBlurLightProgram(LLViewerShaderMgr::SHADER_DEFERRED); LLGLSLShader gDeferredSoftenProgram(LLViewerShaderMgr::SHADER_DEFERRED); LLGLSLShader gDeferredShadowProgram(LLViewerShaderMgr::SHADER_DEFERRED); //Not in mShaderList +LLGLSLShader gDeferredShadowAlphaMaskProgram(LLViewerShaderMgr::SHADER_DEFERRED); LLGLSLShader gDeferredAvatarShadowProgram(LLViewerShaderMgr::SHADER_DEFERRED);//Not in mShaderList #if MESH_ENABLED LLGLSLShader gDeferredAttachmentShadowProgram(LLViewerShaderMgr::SHADER_DEFERRED); @@ -152,8 +183,12 @@ LLGLSLShader gDeferredGIFinalProgram(LLViewerShaderMgr::SHADER_DEFERRED); LLGLSLShader gDeferredPostGIProgram(LLViewerShaderMgr::SHADER_DEFERRED); LLGLSLShader gDeferredPostProgram(LLViewerShaderMgr::SHADER_DEFERRED); LLGLSLShader gDeferredPostNoDoFProgram(LLViewerShaderMgr::SHADER_DEFERRED); - +LLGLSLShader gDeferredWLSkyProgram(LLViewerShaderMgr::SHADER_DEFERRED); +LLGLSLShader gDeferredWLCloudProgram(LLViewerShaderMgr::SHADER_DEFERRED); +LLGLSLShader gDeferredStarProgram(LLViewerShaderMgr::SHADER_DEFERRED); LLGLSLShader gLuminanceGatherProgram(LLViewerShaderMgr::SHADER_DEFERRED); + + //current avatar shader parameter pointer GLint gAvatarMatrixParam; @@ -316,6 +351,9 @@ void LLViewerShaderMgr::setShaders() return; } + //setup preprocessor definitions + LLShaderMgr::instance()->mDefinitions["samples"] = llformat("%d", gSavedSettings.getU32("RenderFSAASamples")/*gGLManager.getNumFBOFSAASamples(gSavedSettings.getU32("RenderFSAASamples"))*/); + LLShaderMgr::instance()->mDefinitions["NUM_TEX_UNITS"] = llformat("%d", gGLManager.mNumTextureImageUnits); reentrance = true; initAttribsAndUniforms(); @@ -352,9 +390,13 @@ void LLViewerShaderMgr::setShaders() } mMaxAvatarShaderLevel = 0; + LLGLSLShader::sNoFixedFunction = false; if (LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable") && gSavedSettings.getBOOL("VertexShaderEnable")) { + //using shaders, disable fixed function + static const LLCachedControl renderforcefixedfuncs("ShyotlUseLegacyRenderPath",false); + LLGLSLShader::sNoFixedFunction = !renderforcefixedfuncs; S32 light_class = 2; S32 env_class = 2; S32 obj_class = 2; @@ -496,6 +538,7 @@ void LLViewerShaderMgr::setShaders() } else { + LLGLSLShader::sNoFixedFunction = false; gPipeline.mVertexShadersEnabled = FALSE; gPipeline.mVertexShadersLoaded = 0; for (S32 i = 0; i < SHADER_COUNT; i++) @@ -512,6 +555,7 @@ void LLViewerShaderMgr::setShaders() } else { + LLGLSLShader::sNoFixedFunction = false; gPipeline.mVertexShadersEnabled = FALSE; gPipeline.mVertexShadersLoaded = 0; for (S32 i = 0; i < SHADER_COUNT; i++) @@ -522,6 +566,10 @@ void LLViewerShaderMgr::setShaders() { gViewerWindow->setCursor(UI_CURSOR_ARROW); } + + LLWaterParamManager::getInstance()->updateShaderLinks(); + LLWLParamManager::getInstance()->updateShaderLinks(); + gPipeline.createGLBuffers(); reentrance = false; } @@ -604,24 +652,49 @@ BOOL LLViewerShaderMgr::loadBasicShaders() shaders.clear(); shaders.reserve(13); - shaders.push_back( make_pair( "windlight/atmosphericsVarsF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); - shaders.push_back( make_pair( "windlight/gammaF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT]) ); - shaders.push_back( make_pair( "windlight/atmosphericsF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); - shaders.push_back( make_pair( "windlight/transportF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); - shaders.push_back( make_pair( "environment/waterFogF.glsl", mVertexShaderLevel[SHADER_WATER] ) ); - shaders.push_back( make_pair( "lighting/lightF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - shaders.push_back( make_pair( "lighting/lightFullbrightF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - shaders.push_back( make_pair( "lighting/lightWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - shaders.push_back( make_pair( "lighting/lightFullbrightWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - shaders.push_back( make_pair( "lighting/lightShinyF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - shaders.push_back( make_pair( "lighting/lightFullbrightShinyF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - shaders.push_back( make_pair( "lighting/lightShinyWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - shaders.push_back( make_pair( "lighting/lightFullbrightShinyWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + S32 ch = gGLManager.mNumTextureImageUnits-1; + + static const LLCachedControl no_texture_indexing("ShyotlUseLegacyTextureBatching",false); + if (gGLManager.mGLVersion < 3.1f || no_texture_indexing) + { //force to 1 texture index channel for old drivers + ch = 1; + } + + std::vector index_channels; + index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsVarsF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/gammaF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT]) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/transportF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "environment/waterFogF.glsl", mVertexShaderLevel[SHADER_WATER] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightAlphaMaskNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightNonIndexedAlphaMaskF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightWaterNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightWaterAlphaMaskNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightWaterNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightShinyNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightShinyNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightShinyWaterNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightShinyWaterNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightAlphaMaskF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightAlphaMaskF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightWaterAlphaMaskF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterAlphaMaskF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightShinyF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightShinyWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); for (U32 i = 0; i < shaders.size(); i++) { // Note usage of GL_FRAGMENT_SHADER_ARB - if (loadShaderFile(shaders[i].first, shaders[i].second, GL_FRAGMENT_SHADER_ARB) == 0) + if (loadShaderFile(shaders[i].first, shaders[i].second, GL_FRAGMENT_SHADER_ARB, index_channels[i]) == 0) { return FALSE; } @@ -864,11 +937,43 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredDiffuseProgram.mName = "Deferred Diffuse Shader"; gDeferredDiffuseProgram.mShaderFiles.clear(); gDeferredDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseIndexedF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredDiffuseProgram.mFeatures.mIndexedTextureChannels = gGLManager.mNumTextureImageUnits; gDeferredDiffuseProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; success = gDeferredDiffuseProgram.createShader(NULL, NULL); } - + + if (success) + { + gDeferredDiffuseAlphaMaskProgram.mName = "Deferred Diffuse Alpha Mask Shader"; + gDeferredDiffuseAlphaMaskProgram.mShaderFiles.clear(); + gDeferredDiffuseAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/diffuseV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredDiffuseAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/diffuseAlphaMaskIndexedF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredDiffuseAlphaMaskProgram.mFeatures.mIndexedTextureChannels = gGLManager.mNumTextureImageUnits; + gDeferredDiffuseAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + success = gDeferredDiffuseAlphaMaskProgram.createShader(NULL, NULL); + } + + if (success) + { + gDeferredNonIndexedDiffuseAlphaMaskProgram.mName = "Deferred Diffuse Non-Indexed Alpha Mask Shader"; + gDeferredNonIndexedDiffuseAlphaMaskProgram.mShaderFiles.clear(); + gDeferredNonIndexedDiffuseAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/diffuseV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredNonIndexedDiffuseAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/diffuseAlphaMaskF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredNonIndexedDiffuseAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + success = gDeferredNonIndexedDiffuseAlphaMaskProgram.createShader(NULL, NULL); + } + + if (success) + { + gDeferredNonIndexedDiffuseProgram.mName = "Non Indexed Deferred Diffuse Shader"; + gDeferredNonIndexedDiffuseProgram.mShaderFiles.clear(); + gDeferredNonIndexedDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredNonIndexedDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredNonIndexedDiffuseProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + success = gDeferredNonIndexedDiffuseProgram.createShader(NULL, NULL); + } + #if MESH_ENABLED if (success) { @@ -901,9 +1006,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSkinnedAlphaProgram.mFeatures.hasGamma = true; gDeferredSkinnedAlphaProgram.mFeatures.hasAtmospherics = true; gDeferredSkinnedAlphaProgram.mFeatures.hasLighting = true; + gDeferredSkinnedAlphaProgram.mFeatures.disableTextureIndex = true; gDeferredSkinnedAlphaProgram.mShaderFiles.clear(); gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaNonIndexedF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredSkinnedAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; success = gDeferredSkinnedAlphaProgram.createShader(NULL, NULL); } @@ -1018,6 +1124,16 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaProgram.mFeatures.hasGamma = true; gDeferredAlphaProgram.mFeatures.hasAtmospherics = true; gDeferredAlphaProgram.mFeatures.hasLighting = true; + gDeferredAlphaProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels + if (mVertexShaderLevel[SHADER_DEFERRED] < 1) + { + gDeferredAlphaProgram.mFeatures.mIndexedTextureChannels = gGLManager.mNumTextureImageUnits; + } + else + { //shave off some texture units for shadow maps + gDeferredAlphaProgram.mFeatures.mIndexedTextureChannels = gGLManager.mNumTextureImageUnits - 6; + } + gDeferredAlphaProgram.mShaderFiles.clear(); gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1031,7 +1147,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightProgram.mFeatures.hasGamma = true; gDeferredFullbrightProgram.mFeatures.hasTransport = true; - gDeferredFullbrightProgram.mFeatures.isFullbright = true; + gDeferredFullbrightProgram.mFeatures.mIndexedTextureChannels = gGLManager.mNumTextureImageUnits; gDeferredFullbrightProgram.mShaderFiles.clear(); gDeferredFullbrightProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredFullbrightProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1057,12 +1173,13 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { std::string fragment; - //Keep this! Fixes shadow softening with ssao off. + /*//Keep this! Fixes shadow softening with ssao off. + //Disabled for now. if (mVertexShaderLevel[SHADER_DEFERRED] < 2 && !gSavedSettings.getBOOL("RenderDeferredSSAO")) { fragment = "deferred/softenLightNoSSAOF.glsl"; } - else + else*/ { fragment = "deferred/softenLightF.glsl"; } @@ -1072,6 +1189,12 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSoftenProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER_ARB)); gDeferredSoftenProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + + if (gSavedSettings.getBOOL("RenderDeferredSSAO")) + { //if using SSAO, take screen space light map into account as if shadows are enabled + gDeferredSoftenProgram.mShaderLevel = llmax(gDeferredSoftenProgram.mShaderLevel, 2); + } + success = gDeferredSoftenProgram.createShader(NULL, NULL); } @@ -1085,6 +1208,16 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() success = gDeferredShadowProgram.createShader(NULL, NULL); } + if (success) + { + gDeferredShadowAlphaMaskProgram.mName = "Deferred Shadow Alpha Mask Shader"; + gDeferredShadowAlphaMaskProgram.mShaderFiles.clear(); + gDeferredShadowAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/shadowAlphaMaskV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredShadowAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/shadowAlphaMaskF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredShadowAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + success = gDeferredShadowAlphaMaskProgram.createShader(NULL, NULL); + } + if (success) { gDeferredAvatarShadowProgram.mName = "Deferred Avatar Shadow Shader"; @@ -1139,9 +1272,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarAlphaProgram.mFeatures.hasGamma = true; gDeferredAvatarAlphaProgram.mFeatures.hasAtmospherics = true; gDeferredAvatarAlphaProgram.mFeatures.hasLighting = true; + gDeferredAvatarAlphaProgram.mFeatures.disableTextureIndex = true; gDeferredAvatarAlphaProgram.mShaderFiles.clear(); gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaNonIndexedF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredAvatarAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; success = gDeferredAvatarAlphaProgram.createShader(&mAvatarAttribs, &mAvatarUniforms); } @@ -1166,6 +1300,40 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() success = gDeferredPostNoDoFProgram.createShader(NULL, NULL); } + if (success) + { + gDeferredWLSkyProgram.mName = "Deferred Windlight Sky Shader"; + //gWLSkyProgram.mFeatures.hasGamma = true; + gDeferredWLSkyProgram.mShaderFiles.clear(); + gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredWLSkyProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY; + success = gDeferredWLSkyProgram.createShader(NULL, &mWLUniforms); + } + + if (success) + { + gDeferredWLCloudProgram.mName = "Deferred Windlight Cloud Program"; + gDeferredWLCloudProgram.mShaderFiles.clear(); + gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredWLCloudProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; + success = gDeferredWLCloudProgram.createShader(NULL, &mWLUniforms); + } + + if (success) + { + gDeferredStarProgram.mName = "Deferred Star Program"; + gDeferredStarProgram.mShaderFiles.clear(); + gDeferredStarProgram.mShaderFiles.push_back(make_pair("deferred/starsV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredStarProgram.mShaderFiles.push_back(make_pair("deferred/starsF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredStarProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredStarProgram.mShaderGroup = LLGLSLShader::SG_SKY; + success = gDeferredStarProgram.createShader(NULL, &mWLUniforms); + } + if (mVertexShaderLevel[SHADER_DEFERRED] > 1) { if (success) @@ -1181,16 +1349,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (mVertexShaderLevel[SHADER_DEFERRED] > 2) { - if (success) - { - gDeferredPostProgram.mName = "Deferred Post Shader"; - gDeferredPostProgram.mShaderFiles.clear(); - gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredPostProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - success = gDeferredPostProgram.createShader(NULL, NULL); - } - if (success) { gDeferredPostGIProgram.mName = "Deferred Post GI Shader"; @@ -1245,6 +1403,183 @@ BOOL LLViewerShaderMgr::loadShadersObject() return TRUE; } + if (success) + { + gObjectSimpleNonIndexedProgram.mName = "Non indexed Shader"; + gObjectSimpleNonIndexedProgram.mFeatures.calculatesLighting = true; + gObjectSimpleNonIndexedProgram.mFeatures.calculatesAtmospherics = true; + gObjectSimpleNonIndexedProgram.mFeatures.hasGamma = true; + gObjectSimpleNonIndexedProgram.mFeatures.hasAtmospherics = true; + gObjectSimpleNonIndexedProgram.mFeatures.hasLighting = true; + gObjectSimpleNonIndexedProgram.mFeatures.disableTextureIndex = true; + gObjectSimpleNonIndexedProgram.mShaderFiles.clear(); + gObjectSimpleNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectSimpleNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectSimpleNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + success = gObjectSimpleNonIndexedProgram.createShader(NULL, NULL); + } + + if (success) + { + gObjectSimpleNonIndexedWaterProgram.mName = "Non indexed Water Shader"; + gObjectSimpleNonIndexedWaterProgram.mFeatures.calculatesLighting = true; + gObjectSimpleNonIndexedWaterProgram.mFeatures.calculatesAtmospherics = true; + gObjectSimpleNonIndexedWaterProgram.mFeatures.hasWaterFog = true; + gObjectSimpleNonIndexedWaterProgram.mFeatures.hasAtmospherics = true; + gObjectSimpleNonIndexedWaterProgram.mFeatures.hasLighting = true; + gObjectSimpleNonIndexedWaterProgram.mFeatures.disableTextureIndex = true; + gObjectSimpleNonIndexedWaterProgram.mShaderFiles.clear(); + gObjectSimpleNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectSimpleNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectSimpleNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectSimpleNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + success = gObjectSimpleNonIndexedWaterProgram.createShader(NULL, NULL); + } + + if (success) + { + gObjectAlphaMaskNonIndexedProgram.mName = "Non indexed alpha mask Shader"; + gObjectAlphaMaskNonIndexedProgram.mFeatures.calculatesLighting = true; + gObjectAlphaMaskNonIndexedProgram.mFeatures.calculatesAtmospherics = true; + gObjectAlphaMaskNonIndexedProgram.mFeatures.hasGamma = true; + gObjectAlphaMaskNonIndexedProgram.mFeatures.hasAtmospherics = true; + gObjectAlphaMaskNonIndexedProgram.mFeatures.hasLighting = true; + gObjectAlphaMaskNonIndexedProgram.mFeatures.disableTextureIndex = true; + gObjectAlphaMaskNonIndexedProgram.mFeatures.hasAlphaMask = true; + gObjectAlphaMaskNonIndexedProgram.mShaderFiles.clear(); + gObjectAlphaMaskNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectAlphaMaskNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectAlphaMaskNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + success = gObjectAlphaMaskNonIndexedProgram.createShader(NULL, NULL); + } + + if (success) + { + gObjectAlphaMaskNonIndexedWaterProgram.mName = "Non indexed alpha mask Water Shader"; + gObjectAlphaMaskNonIndexedWaterProgram.mFeatures.calculatesLighting = true; + gObjectAlphaMaskNonIndexedWaterProgram.mFeatures.calculatesAtmospherics = true; + gObjectAlphaMaskNonIndexedWaterProgram.mFeatures.hasWaterFog = true; + gObjectAlphaMaskNonIndexedWaterProgram.mFeatures.hasAtmospherics = true; + gObjectAlphaMaskNonIndexedWaterProgram.mFeatures.hasLighting = true; + gObjectAlphaMaskNonIndexedWaterProgram.mFeatures.disableTextureIndex = true; + gObjectAlphaMaskNonIndexedWaterProgram.mFeatures.hasAlphaMask = true; + gObjectAlphaMaskNonIndexedWaterProgram.mShaderFiles.clear(); + gObjectAlphaMaskNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectAlphaMaskNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectAlphaMaskNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectAlphaMaskNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + success = gObjectAlphaMaskNonIndexedWaterProgram.createShader(NULL, NULL); + } + + if (success) + { + gObjectFullbrightNonIndexedProgram.mName = "Non Indexed Fullbright Shader"; + gObjectFullbrightNonIndexedProgram.mFeatures.calculatesAtmospherics = true; + gObjectFullbrightNonIndexedProgram.mFeatures.hasGamma = true; + gObjectFullbrightNonIndexedProgram.mFeatures.hasTransport = true; + gObjectFullbrightNonIndexedProgram.mFeatures.isFullbright = true; + gObjectFullbrightNonIndexedProgram.mFeatures.disableTextureIndex = true; + gObjectFullbrightNonIndexedProgram.mShaderFiles.clear(); + gObjectFullbrightNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectFullbrightNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectFullbrightNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + success = gObjectFullbrightNonIndexedProgram.createShader(NULL, NULL); + } + + if (success) + { + gObjectFullbrightNonIndexedWaterProgram.mName = "Non Indexed Fullbright Water Shader"; + gObjectFullbrightNonIndexedWaterProgram.mFeatures.calculatesAtmospherics = true; + gObjectFullbrightNonIndexedWaterProgram.mFeatures.isFullbright = true; + gObjectFullbrightNonIndexedWaterProgram.mFeatures.hasWaterFog = true; + gObjectFullbrightNonIndexedWaterProgram.mFeatures.hasTransport = true; + gObjectFullbrightNonIndexedWaterProgram.mFeatures.disableTextureIndex = true; + gObjectFullbrightNonIndexedWaterProgram.mShaderFiles.clear(); + gObjectFullbrightNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectFullbrightNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectFullbrightNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectFullbrightNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + success = gObjectFullbrightNonIndexedWaterProgram.createShader(NULL, NULL); + } + + if (success) + { + gObjectShinyNonIndexedProgram.mName = "Non Indexed Shiny Shader"; + gObjectShinyNonIndexedProgram.mFeatures.calculatesAtmospherics = true; + gObjectShinyNonIndexedProgram.mFeatures.calculatesLighting = true; + gObjectShinyNonIndexedProgram.mFeatures.hasGamma = true; + gObjectShinyNonIndexedProgram.mFeatures.hasAtmospherics = true; + gObjectShinyNonIndexedProgram.mFeatures.isShiny = true; + gObjectShinyNonIndexedProgram.mFeatures.disableTextureIndex = true; + gObjectShinyNonIndexedProgram.mShaderFiles.clear(); + gObjectShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/shinyF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectShinyNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + success = gObjectShinyNonIndexedProgram.createShader(NULL, &mShinyUniforms); + } + + if (success) + { + gObjectShinyNonIndexedWaterProgram.mName = "Non Indexed Shiny Water Shader"; + gObjectShinyNonIndexedWaterProgram.mFeatures.calculatesAtmospherics = true; + gObjectShinyNonIndexedWaterProgram.mFeatures.calculatesLighting = true; + gObjectShinyNonIndexedWaterProgram.mFeatures.isShiny = true; + gObjectShinyNonIndexedWaterProgram.mFeatures.hasWaterFog = true; + gObjectShinyNonIndexedWaterProgram.mFeatures.hasAtmospherics = true; + gObjectShinyNonIndexedWaterProgram.mFeatures.disableTextureIndex = true; + gObjectShinyNonIndexedWaterProgram.mShaderFiles.clear(); + gObjectShinyNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectShinyNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectShinyNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectShinyNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + success = gObjectShinyNonIndexedWaterProgram.createShader(NULL, &mShinyUniforms); + } + + if (success) + { + gObjectFullbrightShinyNonIndexedProgram.mName = "Non Indexed Fullbright Shiny Shader"; + gObjectFullbrightShinyNonIndexedProgram.mFeatures.calculatesAtmospherics = true; + gObjectFullbrightShinyNonIndexedProgram.mFeatures.isFullbright = true; + gObjectFullbrightShinyNonIndexedProgram.mFeatures.isShiny = true; + gObjectFullbrightShinyNonIndexedProgram.mFeatures.hasGamma = true; + gObjectFullbrightShinyNonIndexedProgram.mFeatures.hasTransport = true; + gObjectFullbrightShinyNonIndexedProgram.mFeatures.disableTextureIndex = true; + gObjectFullbrightShinyNonIndexedProgram.mShaderFiles.clear(); + gObjectFullbrightShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectFullbrightShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectFullbrightShinyNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + success = gObjectFullbrightShinyNonIndexedProgram.createShader(NULL, &mShinyUniforms); + } + + if (success) + { + gObjectFullbrightShinyNonIndexedWaterProgram.mName = "Non Indexed Fullbright Shiny Water Shader"; + gObjectFullbrightShinyNonIndexedWaterProgram.mFeatures.calculatesAtmospherics = true; + gObjectFullbrightShinyNonIndexedWaterProgram.mFeatures.isFullbright = true; + gObjectFullbrightShinyNonIndexedWaterProgram.mFeatures.isShiny = true; + gObjectFullbrightShinyNonIndexedWaterProgram.mFeatures.hasGamma = true; + gObjectFullbrightShinyNonIndexedWaterProgram.mFeatures.hasTransport = true; + gObjectFullbrightShinyNonIndexedWaterProgram.mFeatures.hasWaterFog = true; + gObjectFullbrightShinyNonIndexedWaterProgram.mFeatures.disableTextureIndex = true; + gObjectFullbrightShinyNonIndexedWaterProgram.mShaderFiles.clear(); + gObjectFullbrightShinyNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectFullbrightShinyNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectFullbrightShinyNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectFullbrightShinyNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + success = gObjectFullbrightShinyNonIndexedWaterProgram.createShader(NULL, &mShinyUniforms); + } + + if (success) + { + gImpostorProgram.mName = "Impostor Shader"; + gImpostorProgram.mFeatures.disableTextureIndex = true; + gImpostorProgram.mShaderFiles.clear(); + gImpostorProgram.mShaderFiles.push_back(make_pair("objects/impostorV.glsl", GL_VERTEX_SHADER_ARB)); + gImpostorProgram.mShaderFiles.push_back(make_pair("objects/impostorF.glsl", GL_FRAGMENT_SHADER_ARB)); + gImpostorProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + success = gImpostorProgram.createShader(NULL, NULL); + } + if (success) { gObjectSimpleProgram.mName = "Simple Shader"; @@ -1253,12 +1588,46 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectSimpleProgram.mFeatures.hasGamma = true; gObjectSimpleProgram.mFeatures.hasAtmospherics = true; gObjectSimpleProgram.mFeatures.hasLighting = true; + gObjectSimpleProgram.mFeatures.mIndexedTextureChannels = 0; gObjectSimpleProgram.mShaderFiles.clear(); gObjectSimpleProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); gObjectSimpleProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); gObjectSimpleProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; success = gObjectSimpleProgram.createShader(NULL, NULL); } + + if (success) + { + gObjectSimpleAlphaMaskProgram.mName = "Simple Alpha Mask Shader"; + gObjectSimpleAlphaMaskProgram.mFeatures.calculatesLighting = true; + gObjectSimpleAlphaMaskProgram.mFeatures.calculatesAtmospherics = true; + gObjectSimpleAlphaMaskProgram.mFeatures.hasGamma = true; + gObjectSimpleAlphaMaskProgram.mFeatures.hasAtmospherics = true; + gObjectSimpleAlphaMaskProgram.mFeatures.hasLighting = true; + gObjectSimpleAlphaMaskProgram.mFeatures.hasAlphaMask = true; + gObjectSimpleAlphaMaskProgram.mFeatures.mIndexedTextureChannels = 0; + gObjectSimpleAlphaMaskProgram.mShaderFiles.clear(); + gObjectSimpleAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectSimpleAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectSimpleAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + success = gObjectSimpleAlphaMaskProgram.createShader(NULL, NULL); + } + + if (success) + { + gObjectBumpProgram.mName = "Bump Shader"; + /*gObjectBumpProgram.mFeatures.calculatesLighting = true; + gObjectBumpProgram.mFeatures.calculatesAtmospherics = true; + gObjectBumpProgram.mFeatures.hasGamma = true; + gObjectBumpProgram.mFeatures.hasAtmospherics = true; + gObjectBumpProgram.mFeatures.hasLighting = true; + gObjectBumpProgram.mFeatures.mIndexedTextureChannels = 0;*/ + gObjectBumpProgram.mShaderFiles.clear(); + gObjectBumpProgram.mShaderFiles.push_back(make_pair("objects/bumpV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectBumpProgram.mShaderFiles.push_back(make_pair("objects/bumpF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectBumpProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + success = gObjectBumpProgram.createShader(NULL, NULL); + } if (success) { @@ -1268,6 +1637,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectSimpleWaterProgram.mFeatures.hasWaterFog = true; gObjectSimpleWaterProgram.mFeatures.hasAtmospherics = true; gObjectSimpleWaterProgram.mFeatures.hasLighting = true; + gObjectSimpleWaterProgram.mFeatures.mIndexedTextureChannels = 0; gObjectSimpleWaterProgram.mShaderFiles.clear(); gObjectSimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); gObjectSimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1276,6 +1646,24 @@ BOOL LLViewerShaderMgr::loadShadersObject() success = gObjectSimpleWaterProgram.createShader(NULL, NULL); } + if (success) + { + gObjectSimpleWaterAlphaMaskProgram.mName = "Simple Water Alpha Mask Shader"; + gObjectSimpleWaterAlphaMaskProgram.mFeatures.calculatesLighting = true; + gObjectSimpleWaterAlphaMaskProgram.mFeatures.calculatesAtmospherics = true; + gObjectSimpleWaterAlphaMaskProgram.mFeatures.hasWaterFog = true; + gObjectSimpleWaterAlphaMaskProgram.mFeatures.hasAtmospherics = true; + gObjectSimpleWaterAlphaMaskProgram.mFeatures.hasLighting = true; + gObjectSimpleWaterAlphaMaskProgram.mFeatures.hasAlphaMask = true; + gObjectSimpleWaterAlphaMaskProgram.mFeatures.mIndexedTextureChannels = 0; + gObjectSimpleWaterAlphaMaskProgram.mShaderFiles.clear(); + gObjectSimpleWaterAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectSimpleWaterAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectSimpleWaterAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectSimpleWaterAlphaMaskProgram.mShaderGroup = LLGLSLShader::SG_WATER; + success = gObjectSimpleWaterAlphaMaskProgram.createShader(NULL, NULL); + } + if (success) { gObjectFullbrightProgram.mName = "Fullbright Shader"; @@ -1283,6 +1671,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightProgram.mFeatures.hasGamma = true; gObjectFullbrightProgram.mFeatures.hasTransport = true; gObjectFullbrightProgram.mFeatures.isFullbright = true; + gObjectFullbrightProgram.mFeatures.mIndexedTextureChannels = 0; gObjectFullbrightProgram.mShaderFiles.clear(); gObjectFullbrightProgram.mShaderFiles.push_back(make_pair("objects/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1297,6 +1686,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightWaterProgram.mFeatures.isFullbright = true; gObjectFullbrightWaterProgram.mFeatures.hasWaterFog = true; gObjectFullbrightWaterProgram.mFeatures.hasTransport = true; + gObjectFullbrightWaterProgram.mFeatures.mIndexedTextureChannels = 0; gObjectFullbrightWaterProgram.mShaderFiles.clear(); gObjectFullbrightWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1305,6 +1695,39 @@ BOOL LLViewerShaderMgr::loadShadersObject() success = gObjectFullbrightWaterProgram.createShader(NULL, NULL); } + if (success) + { + gObjectFullbrightAlphaMaskProgram.mName = "Fullbright Alpha Mask Shader"; + gObjectFullbrightAlphaMaskProgram.mFeatures.calculatesAtmospherics = true; + gObjectFullbrightAlphaMaskProgram.mFeatures.hasGamma = true; + gObjectFullbrightAlphaMaskProgram.mFeatures.hasTransport = true; + gObjectFullbrightAlphaMaskProgram.mFeatures.isFullbright = true; + gObjectFullbrightAlphaMaskProgram.mFeatures.hasAlphaMask = true; + gObjectFullbrightAlphaMaskProgram.mFeatures.mIndexedTextureChannels = 0; + gObjectFullbrightAlphaMaskProgram.mShaderFiles.clear(); + gObjectFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectFullbrightAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + success = gObjectFullbrightAlphaMaskProgram.createShader(NULL, NULL); + } + + if (success) + { + gObjectFullbrightWaterAlphaMaskProgram.mName = "Fullbright Water Shader"; + gObjectFullbrightWaterAlphaMaskProgram.mFeatures.calculatesAtmospherics = true; + gObjectFullbrightWaterAlphaMaskProgram.mFeatures.isFullbright = true; + gObjectFullbrightWaterAlphaMaskProgram.mFeatures.hasWaterFog = true; + gObjectFullbrightWaterAlphaMaskProgram.mFeatures.hasTransport = true; + gObjectFullbrightWaterAlphaMaskProgram.mFeatures.hasAlphaMask = true; + gObjectFullbrightWaterAlphaMaskProgram.mFeatures.mIndexedTextureChannels = 0; + gObjectFullbrightWaterAlphaMaskProgram.mShaderFiles.clear(); + gObjectFullbrightWaterAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectFullbrightWaterAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectFullbrightWaterAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectFullbrightWaterAlphaMaskProgram.mShaderGroup = LLGLSLShader::SG_WATER; + success = gObjectFullbrightWaterAlphaMaskProgram.createShader(NULL, NULL); + } + if (success) { gObjectShinyProgram.mName = "Shiny Shader"; @@ -1313,6 +1736,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectShinyProgram.mFeatures.hasGamma = true; gObjectShinyProgram.mFeatures.hasAtmospherics = true; gObjectShinyProgram.mFeatures.isShiny = true; + gObjectShinyProgram.mFeatures.mIndexedTextureChannels = 0; gObjectShinyProgram.mShaderFiles.clear(); gObjectShinyProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB)); gObjectShinyProgram.mShaderFiles.push_back(make_pair("objects/shinyF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1328,6 +1752,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectShinyWaterProgram.mFeatures.isShiny = true; gObjectShinyWaterProgram.mFeatures.hasWaterFog = true; gObjectShinyWaterProgram.mFeatures.hasAtmospherics = true; + gObjectShinyWaterProgram.mFeatures.mIndexedTextureChannels = 0; gObjectShinyWaterProgram.mShaderFiles.clear(); gObjectShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); gObjectShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB)); @@ -1344,6 +1769,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightShinyProgram.mFeatures.isShiny = true; gObjectFullbrightShinyProgram.mFeatures.hasGamma = true; gObjectFullbrightShinyProgram.mFeatures.hasTransport = true; + gObjectFullbrightShinyProgram.mFeatures.mIndexedTextureChannels = 0; gObjectFullbrightShinyProgram.mShaderFiles.clear(); gObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1360,6 +1786,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightShinyWaterProgram.mFeatures.hasGamma = true; gObjectFullbrightShinyWaterProgram.mFeatures.hasTransport = true; gObjectFullbrightShinyWaterProgram.mFeatures.hasWaterFog = true; + gObjectFullbrightShinyWaterProgram.mFeatures.mIndexedTextureChannels = 0; gObjectFullbrightShinyWaterProgram.mShaderFiles.clear(); gObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1381,6 +1808,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectSimpleProgram.mFeatures.hasAtmospherics = true; gSkinnedObjectSimpleProgram.mFeatures.hasLighting = true; gSkinnedObjectSimpleProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectSimpleProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectSimpleProgram.mShaderFiles.clear(); gSkinnedObjectSimpleProgram.mShaderFiles.push_back(make_pair("objects/simpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectSimpleProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1396,6 +1824,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectFullbrightProgram.mFeatures.hasTransport = true; gSkinnedObjectFullbrightProgram.mFeatures.isFullbright = true; gSkinnedObjectFullbrightProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectFullbrightProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectFullbrightProgram.mShaderFiles.clear(); gSkinnedObjectFullbrightProgram.mShaderFiles.push_back(make_pair("objects/fullbrightSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectFullbrightProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1412,6 +1841,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectFullbrightShinyProgram.mFeatures.isShiny = true; gSkinnedObjectFullbrightShinyProgram.mFeatures.isFullbright = true; gSkinnedObjectFullbrightShinyProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectFullbrightShinyProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectFullbrightShinyProgram.mShaderFiles.clear(); gSkinnedObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinySkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1428,6 +1858,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectShinySimpleProgram.mFeatures.hasAtmospherics = true; gSkinnedObjectShinySimpleProgram.mFeatures.hasObjectSkinning = true; gSkinnedObjectShinySimpleProgram.mFeatures.isShiny = true; + gSkinnedObjectShinySimpleProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectShinySimpleProgram.mShaderFiles.clear(); gSkinnedObjectShinySimpleProgram.mShaderFiles.push_back(make_pair("objects/shinySimpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectShinySimpleProgram.mShaderFiles.push_back(make_pair("objects/shinyF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1443,9 +1874,11 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectSimpleWaterProgram.mFeatures.hasGamma = true; gSkinnedObjectSimpleWaterProgram.mFeatures.hasAtmospherics = true; gSkinnedObjectSimpleWaterProgram.mFeatures.hasLighting = true; + gSkinnedObjectSimpleWaterProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectSimpleWaterProgram.mFeatures.hasWaterFog = true; gSkinnedObjectSimpleWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; gSkinnedObjectSimpleWaterProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectSimpleWaterProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectSimpleWaterProgram.mShaderFiles.clear(); gSkinnedObjectSimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectSimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1462,6 +1895,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectFullbrightWaterProgram.mFeatures.isFullbright = true; gSkinnedObjectFullbrightWaterProgram.mFeatures.hasObjectSkinning = true; gSkinnedObjectFullbrightWaterProgram.mFeatures.hasWaterFog = true; + gSkinnedObjectFullbrightWaterProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectFullbrightWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; gSkinnedObjectFullbrightWaterProgram.mShaderFiles.clear(); gSkinnedObjectFullbrightWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); @@ -1480,6 +1914,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.isFullbright = true; gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.hasObjectSkinning = true; gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.hasWaterFog = true; + gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectFullbrightShinyWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.clear(); gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinySkinnedV.glsl", GL_VERTEX_SHADER_ARB)); @@ -1498,6 +1933,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasObjectSkinning = true; gSkinnedObjectShinySimpleWaterProgram.mFeatures.isShiny = true; gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasWaterFog = true; + gSkinnedObjectShinySimpleWaterProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectShinySimpleWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; gSkinnedObjectShinySimpleWaterProgram.mShaderFiles.clear(); gSkinnedObjectShinySimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/shinySimpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); @@ -1535,6 +1971,8 @@ BOOL LLViewerShaderMgr::loadShadersAvatar() gAvatarProgram.mFeatures.hasGamma = true; gAvatarProgram.mFeatures.hasAtmospherics = true; gAvatarProgram.mFeatures.hasLighting = true; + gAvatarProgram.mFeatures.hasAlphaMask = true; + gAvatarProgram.mFeatures.disableTextureIndex = true; gAvatarProgram.mShaderFiles.clear(); gAvatarProgram.mShaderFiles.push_back(make_pair("avatar/avatarV.glsl", GL_VERTEX_SHADER_ARB)); gAvatarProgram.mShaderFiles.push_back(make_pair("avatar/avatarF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1550,6 +1988,8 @@ BOOL LLViewerShaderMgr::loadShadersAvatar() gAvatarWaterProgram.mFeatures.hasWaterFog = true; gAvatarWaterProgram.mFeatures.hasAtmospherics = true; gAvatarWaterProgram.mFeatures.hasLighting = true; + gAvatarWaterProgram.mFeatures.hasAlphaMask = true; + gAvatarWaterProgram.mFeatures.disableTextureIndex = true; gAvatarWaterProgram.mShaderFiles.clear(); gAvatarWaterProgram.mShaderFiles.push_back(make_pair("avatar/avatarV.glsl", GL_VERTEX_SHADER_ARB)); gAvatarWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1570,6 +2010,7 @@ BOOL LLViewerShaderMgr::loadShadersAvatar() { gAvatarPickProgram.mName = "Avatar Pick Shader"; gAvatarPickProgram.mFeatures.hasSkinning = true; + gAvatarPickProgram.mFeatures.disableTextureIndex = true; gAvatarPickProgram.mShaderFiles.clear(); gAvatarPickProgram.mShaderFiles.push_back(make_pair("avatar/pickAvatarV.glsl", GL_VERTEX_SHADER_ARB)); gAvatarPickProgram.mShaderFiles.push_back(make_pair("avatar/pickAvatarF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1586,6 +2027,8 @@ BOOL LLViewerShaderMgr::loadShadersAvatar() gAvatarEyeballProgram.mFeatures.hasGamma = true; gAvatarEyeballProgram.mFeatures.hasAtmospherics = true; gAvatarEyeballProgram.mFeatures.hasLighting = true; + gAvatarEyeballProgram.mFeatures.hasAlphaMask = true; + gAvatarEyeballProgram.mFeatures.disableTextureIndex = true; gAvatarEyeballProgram.mShaderFiles.clear(); gAvatarEyeballProgram.mShaderFiles.push_back(make_pair("avatar/eyeballV.glsl", GL_VERTEX_SHADER_ARB)); gAvatarEyeballProgram.mShaderFiles.push_back(make_pair("avatar/eyeballF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1623,6 +2066,85 @@ BOOL LLViewerShaderMgr::loadShadersInterface() success = gHighlightProgram.createShader(NULL, NULL); } + if (success) + { + gUIProgram.mName = "UI Shader"; + gUIProgram.mShaderFiles.clear(); + gUIProgram.mShaderFiles.push_back(make_pair("interface/uiV.glsl", GL_VERTEX_SHADER_ARB)); + gUIProgram.mShaderFiles.push_back(make_pair("interface/uiF.glsl", GL_FRAGMENT_SHADER_ARB)); + gUIProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gUIProgram.createShader(NULL, NULL); + } + + if (success) + { + gCustomAlphaProgram.mName = "Custom Alpha Shader"; + gCustomAlphaProgram.mShaderFiles.clear(); + gCustomAlphaProgram.mShaderFiles.push_back(make_pair("interface/customalphaV.glsl", GL_VERTEX_SHADER_ARB)); + gCustomAlphaProgram.mShaderFiles.push_back(make_pair("interface/customalphaF.glsl", GL_FRAGMENT_SHADER_ARB)); + gCustomAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gCustomAlphaProgram.createShader(NULL, NULL); + } + + if (success) + { + gGlowCombineProgram.mName = "Glow Combine Shader"; + gGlowCombineProgram.mShaderFiles.clear(); + gGlowCombineProgram.mShaderFiles.push_back(make_pair("interface/glowcombineV.glsl", GL_VERTEX_SHADER_ARB)); + gGlowCombineProgram.mShaderFiles.push_back(make_pair("interface/glowcombineF.glsl", GL_FRAGMENT_SHADER_ARB)); + gGlowCombineProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gGlowCombineProgram.createShader(NULL, NULL); + if (success) + { + gGlowCombineProgram.bind(); + gGlowCombineProgram.uniform1i("glowMap", 0); + gGlowCombineProgram.uniform1i("screenMap", 1); + gGlowCombineProgram.unbind(); + } + } + + if (success) + { + gTwoTextureAddProgram.mName = "Two Texture Add Shader"; + gTwoTextureAddProgram.mShaderFiles.clear(); + gTwoTextureAddProgram.mShaderFiles.push_back(make_pair("interface/twotextureaddV.glsl", GL_VERTEX_SHADER_ARB)); + gTwoTextureAddProgram.mShaderFiles.push_back(make_pair("interface/twotextureaddF.glsl", GL_FRAGMENT_SHADER_ARB)); + gTwoTextureAddProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gTwoTextureAddProgram.createShader(NULL, NULL); + if (success) + { + gTwoTextureAddProgram.bind(); + gTwoTextureAddProgram.uniform1i("tex0", 0); + gTwoTextureAddProgram.uniform1i("tex1", 1); + } + } + + if (success) + { + gSolidColorProgram.mName = "Solid Color Shader"; + gSolidColorProgram.mShaderFiles.clear(); + gSolidColorProgram.mShaderFiles.push_back(make_pair("interface/solidcolorV.glsl", GL_VERTEX_SHADER_ARB)); + gSolidColorProgram.mShaderFiles.push_back(make_pair("interface/solidcolorF.glsl", GL_FRAGMENT_SHADER_ARB)); + gSolidColorProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gSolidColorProgram.createShader(NULL, NULL); + if (success) + { + gSolidColorProgram.bind(); + gSolidColorProgram.uniform1i("tex0", 0); + gSolidColorProgram.unbind(); + } + } + + if (success) + { + gOcclusionProgram.mName = "Occlusion Shader"; + gOcclusionProgram.mShaderFiles.clear(); + gOcclusionProgram.mShaderFiles.push_back(make_pair("interface/occlusionV.glsl", GL_VERTEX_SHADER_ARB)); + gOcclusionProgram.mShaderFiles.push_back(make_pair("interface/occlusionF.glsl", GL_FRAGMENT_SHADER_ARB)); + gOcclusionProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gOcclusionProgram.createShader(NULL, NULL); + } + if( !success ) { mVertexShaderLevel[SHADER_INTERFACE] = 0; @@ -1676,8 +2198,8 @@ std::string LLViewerShaderMgr::getShaderDirPrefix(void) void LLViewerShaderMgr::updateShaderUniforms(LLGLSLShader * shader) { - LLWLParamManager::instance()->updateShaderUniforms(shader); - LLWaterParamManager::instance()->updateShaderUniforms(shader); + LLWLParamManager::getInstance()->updateShaderUniforms(shader); + LLWaterParamManager::getInstance()->updateShaderUniforms(shader); } /*static*/ void LLShaderMgr::unloadShaderClass(int shader_class) diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index fdc0386a2..9bdde5b2c 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -287,9 +287,9 @@ private: std::vector mAvatarUniforms; // the list of shaders we need to propagate parameters to. - // Currently this is replaced with a global list of all shaders - // which isn't quite as efficient. However, if other changes prove - // stable then I will mimic mShaderList on a per-ParamManager basis. + // This is no longer needed, as param managers iterate down the global list + // after shaders have been loaded and automagically add relevant shaders to + // their own local lists. //std::vector mShaderList; }; //LLViewerShaderMgr @@ -305,19 +305,43 @@ inline bool operator != (LLViewerShaderMgr::shader_iter const & a, LLViewerShade extern LLVector4 gShinyOrigin; +//utility shaders +extern LLGLSLShader gOcclusionProgram; +extern LLGLSLShader gCustomAlphaProgram; +extern LLGLSLShader gGlowCombineProgram; + +//output tex0[tc0] + tex1[tc1] +extern LLGLSLShader gTwoTextureAddProgram; + //object shaders extern LLGLSLShader gObjectSimpleProgram; +extern LLGLSLShader gObjectSimpleAlphaMaskProgram; extern LLGLSLShader gObjectSimpleWaterProgram; +extern LLGLSLShader gObjectSimpleWaterAlphaMaskProgram; +extern LLGLSLShader gObjectSimpleNonIndexedProgram; +extern LLGLSLShader gObjectSimpleNonIndexedWaterProgram; +extern LLGLSLShader gObjectAlphaMaskNonIndexedProgram; +extern LLGLSLShader gObjectAlphaMaskNonIndexedWaterProgram; extern LLGLSLShader gObjectFullbrightProgram; extern LLGLSLShader gObjectFullbrightWaterProgram; +extern LLGLSLShader gObjectFullbrightAlphaMaskProgram; +extern LLGLSLShader gObjectFullbrightWaterAlphaMaskProgram; +extern LLGLSLShader gObjectFullbrightNonIndexedProgram; +extern LLGLSLShader gObjectFullbrightNonIndexedWaterProgram; +extern LLGLSLShader gObjectBumpProgram; extern LLGLSLShader gObjectSimpleLODProgram; extern LLGLSLShader gObjectFullbrightLODProgram; extern LLGLSLShader gObjectFullbrightShinyProgram; extern LLGLSLShader gObjectFullbrightShinyWaterProgram; +extern LLGLSLShader gObjectFullbrightShinyNonIndexedProgram; +extern LLGLSLShader gObjectFullbrightShinyNonIndexedWaterProgram; + extern LLGLSLShader gObjectShinyProgram; extern LLGLSLShader gObjectShinyWaterProgram; +extern LLGLSLShader gObjectShinyNonIndexedProgram; +extern LLGLSLShader gObjectShinyNonIndexedWaterProgram; #if MESH_ENABLED extern LLGLSLShader gSkinnedObjectSimpleProgram; @@ -347,6 +371,7 @@ extern LLGLSLShader gAvatarProgram; extern LLGLSLShader gAvatarWaterProgram; extern LLGLSLShader gAvatarEyeballProgram; extern LLGLSLShader gAvatarPickProgram; +extern LLGLSLShader gImpostorProgram; // WindLight shader handles extern LLGLSLShader gWLSkyProgram; @@ -362,8 +387,11 @@ extern LLGLSLShader gDeferredImpostorProgram; extern LLGLSLShader gDeferredEdgeProgram; extern LLGLSLShader gDeferredWaterProgram; extern LLGLSLShader gDeferredDiffuseProgram; -#if MESH_ENABLED +extern LLGLSLShader gDeferredDiffuseAlphaMaskProgram; +extern LLGLSLShader gDeferredNonIndexedDiffuseAlphaMaskProgram; +extern LLGLSLShader gDeferredNonIndexedDiffuseProgram; extern LLGLSLShader gDeferredSkinnedDiffuseProgram; +#if MESH_ENABLED extern LLGLSLShader gDeferredSkinnedBumpProgram; extern LLGLSLShader gDeferredSkinnedAlphaProgram; #endif //MESH_ENABLED @@ -381,6 +409,7 @@ extern LLGLSLShader gDeferredBlurLightProgram; extern LLGLSLShader gDeferredAvatarProgram; extern LLGLSLShader gDeferredSoftenProgram; extern LLGLSLShader gDeferredShadowProgram; +extern LLGLSLShader gDeferredShadowAlphaMaskProgram; extern LLGLSLShader gDeferredPostGIProgram; extern LLGLSLShader gDeferredPostProgram; extern LLGLSLShader gDeferredPostNoDoFProgram; @@ -391,7 +420,9 @@ extern LLGLSLShader gDeferredAttachmentShadowProgram; extern LLGLSLShader gDeferredAlphaProgram; extern LLGLSLShader gDeferredFullbrightProgram; extern LLGLSLShader gDeferredAvatarAlphaProgram; - +extern LLGLSLShader gDeferredWLSkyProgram; +extern LLGLSLShader gDeferredWLCloudProgram; +extern LLGLSLShader gDeferredStarProgram; extern LLGLSLShader gLuminanceGatherProgram; //current avatar shader parameter pointer diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 2c9468743..ca4606f7c 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -60,6 +60,7 @@ #include "llworld.h" #include "llfeaturemanager.h" #include "llviewernetwork.h" +#include "llmeshrepository.h" //for LLMeshRepository::sBytesReceived #if LL_LCD_COMPILE #include "lllcd.h" #endif @@ -206,9 +207,72 @@ const StatAttributes STAT_INFO[LLViewerStats::ST_COUNT] = }; -LLViewerStats::LLViewerStats() - : mPacketsLostPercentStat(64), - mLastTimeDiff(0.0) +LLViewerStats::LLViewerStats() : + mKBitStat("kbitstat"), + mLayersKBitStat("layerskbitstat"), + mObjectKBitStat("objectkbitstat"), + mAssetKBitStat("assetkbitstat"), + mTextureKBitStat("texturekbitstat"), + mVFSPendingOperations("vfspendingoperations"), + mObjectsDrawnStat("objectsdrawnstat"), + mObjectsCulledStat("objectsculledstat"), + mObjectsTestedStat("objectstestedstat"), + mObjectsComparedStat("objectscomparedstat"), + mObjectsOccludedStat("objectsoccludedstat"), + mFPSStat("fpsstat"), + mPacketsInStat("packetsinstat"), + mPacketsLostStat("packetsloststat"), + mPacketsOutStat("packetsoutstat"), + mPacketsLostPercentStat("packetslostpercentstat", 64), + mTexturePacketsStat("texturepacketsstat"), + mActualInKBitStat("actualinkbitstat"), + mActualOutKBitStat("actualoutkbitstat"), + mTrianglesDrawnStat("trianglesdrawnstat"), + mSimTimeDilation("simtimedilation"), + mSimFPS("simfps"), + mSimPhysicsFPS("simphysicsfps"), + mSimAgentUPS("simagentups"), + mSimScriptEPS("simscripteps"), + mSimFrameMsec("simframemsec"), + mSimNetMsec("simnetmsec"), + mSimSimOtherMsec("simsimothermsec"), + mSimSimPhysicsMsec("simsimphysicsmsec"), + mSimSimPhysicsStepMsec("simsimphysicsstepmsec"), + mSimSimPhysicsShapeUpdateMsec("simsimphysicsshapeupdatemsec"), + mSimSimPhysicsOtherMsec("simsimphysicsothermsec"), + mSimAgentMsec("simagentmsec"), + mSimImagesMsec("simimagesmsec"), + mSimScriptMsec("simscriptmsec"), + mSimSpareMsec("simsparemsec"), + mSimSleepMsec("simsleepmsec"), + mSimPumpIOMsec("simpumpiomsec"), + mSimMainAgents("simmainagents"), + mSimChildAgents("simchildagents"), + mSimObjects("simobjects"), + mSimActiveObjects("simactiveobjects"), + mSimActiveScripts("simactivescripts"), + mSimInPPS("siminpps"), + mSimOutPPS("simoutpps"), + mSimPendingDownloads("simpendingdownloads"), + mSimPendingUploads("simpendinguploads"), + mSimPendingLocalUploads("simpendinglocaluploads"), + mSimTotalUnackedBytes("simtotalunackedbytes"), + mPhysicsPinnedTasks("physicspinnedtasks"), + mPhysicsLODTasks("physicslodtasks"), + mPhysicsMemoryAllocated("physicsmemoryallocated"), + mSimPingStat("simpingstat"), + mNumImagesStat("numimagesstat", 32, TRUE), + mNumRawImagesStat("numrawimagesstat", 32, TRUE), + mGLTexMemStat("gltexmemstat", 32, TRUE), + mGLBoundMemStat("glboundmemstat", 32, TRUE), + mRawMemStat("rawmemstat", 32, TRUE), + mFormattedMemStat("formattedmemstat", 32, TRUE), + mNumObjectsStat("numobjectsstat"), + mNumActiveObjectsStat("numactiveobjectsstat"), + mNumNewObjectsStat("numnewobjectsstat"), + mNumSizeCulledStat("numsizeculledstat"), + mNumVisCulledStat("numvisculledstat"), + mLastTimeDiff(0.0) { for (S32 i = 0; i < ST_COUNT; i++) { @@ -219,6 +283,8 @@ LLViewerStats::LLViewerStats() { mStats[ST_HAS_BAD_TIMER] = 1.0; } + + mAgentPositionSnaps.reset(); } LLViewerStats::~LLViewerStats() @@ -238,6 +304,8 @@ void LLViewerStats::resetStats() LLViewerStats::getInstance()->mPacketsOutStat.reset(); LLViewerStats::getInstance()->mFPSStat.reset(); LLViewerStats::getInstance()->mTexturePacketsStat.reset(); + + LLViewerStats::getInstance()->mAgentPositionSnaps.reset(); } @@ -332,6 +400,10 @@ void LLViewerStats::addToMessage(LLSD &body) const << llendl; } } + + body["AgentPositionSnaps"] = mAgentPositionSnaps.getData(); + llinfos << "STAT: AgentPositionSnaps: Mean = " << mAgentPositionSnaps.getMean() << "; StdDev = " << mAgentPositionSnaps.getStdDev() + << "; Count = " << mAgentPositionSnaps.getCount() << llendl; } // static @@ -536,7 +608,7 @@ void update_statistics(U32 frame_count) } } LLViewerStats::getInstance()->setStat(LLViewerStats::ST_ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable")); - //LLViewerStats::getInstance()->setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gSavedSettings.getS32("RenderLightingDetail")); + LLViewerStats::getInstance()->setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail()); LLViewerStats::getInstance()->setStat(LLViewerStats::ST_DRAW_DIST, (F64)gSavedSettings.getF32("RenderFarClip")); LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles")); #if 0 // 1.9.2 @@ -603,7 +675,7 @@ void update_statistics(U32 frame_count) // Only update texture stats ones per second so that they are less noisy { - static const F32 texture_stats_freq = 1.f; + static const F32 texture_stats_freq = 10.f; static LLFrameTimer texture_stats_timer; if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq) { @@ -718,9 +790,11 @@ void send_stats() system["ram"] = (S32) gSysMemory.getPhysicalMemoryKB(); system["os"] = LLAppViewer::instance()->getOSInfo().getOSStringSimple(); system["cpu"] = gSysCPU.getCPUString(); + unsigned char MACAddress[MAC_ADDRESS_BYTES]; + LLUUID::getNodeID(MACAddress); std::string macAddressString = llformat("%02x-%02x-%02x-%02x-%02x-%02x", - gMACAddress[0],gMACAddress[1],gMACAddress[2], - gMACAddress[3],gMACAddress[4],gMACAddress[5]); + MACAddress[0],MACAddress[1],MACAddress[2], + MACAddress[3],MACAddress[4],MACAddress[5]); system["mac_address"] = macAddressString; system["serial_number"] = LLAppViewer::instance()->getSerialNumber(); std::string gpu_desc = llformat( @@ -739,6 +813,7 @@ void send_stats() download["world_kbytes"] = gTotalWorldBytes / 1024.0; download["object_kbytes"] = gTotalObjectBytes / 1024.0; download["texture_kbytes"] = gTotalTextureBytes / 1024.0; + download["mesh_kbytes"] = LLMeshRepository::sBytesReceived/1024.0; LLSD &in = body["stats"]["net"]["in"]; @@ -774,13 +849,15 @@ void send_stats() // Screen size so the UI team can figure out how big the widgets // appear and use a "typical" size for end user tests. - S32 window_width = gViewerWindow->getWindowDisplayWidth(); - S32 window_height = gViewerWindow->getWindowDisplayHeight(); + S32 window_width = gViewerWindow->getWindowWidthRaw(); + S32 window_height = gViewerWindow->getWindowHeightRaw(); S32 window_size = (window_width * window_height) / 1024; misc["string_1"] = llformat("%d", window_size); - // misc["string_2"] = -// misc["int_1"] = LLFloaterDirectory::sOldSearchCount; // Steve: 1.18.6 -// misc["int_2"] = LLFloaterDirectory::sNewSearchCount; // Steve: 1.18.6 + if (gDebugTimers.find(0) != gDebugTimers.end() && gFrameTimeSeconds > 0) + { + misc["string_2"] = llformat("Texture Time: %.2f, Total Time: %.2f", gDebugTimers[0].getElapsedTimeF32(), gFrameTimeSeconds); + } + // misc["int_1"] = LLSD::Integer(gSavedSettings.getU32("RenderQualityPerformance")); // Steve: 1.21 // misc["int_2"] = LLSD::Integer(gFrameStalls); // Steve: 1.21 @@ -791,6 +868,11 @@ void send_stats() llinfos << "Misc Stats: int_1: " << misc["int_1"] << " int_2: " << misc["int_2"] << llendl; llinfos << "Misc Stats: string_1: " << misc["string_1"] << " string_2: " << misc["string_2"] << llendl; + + body["DisplayNamesEnabled"] = gSavedSettings.getS32("PhoenixNameSystem") > 0; + body["DisplayNamesShowUsername"] = gSavedSettings.getS32("PhoenixNameSystem") == 1; + + body["MinimalSkin"] = false; LLViewerStats::getInstance()->addToMessage(body); LLHTTPClient::post(url, body, new ViewerStatsResponder()); diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 1cea273ad..7f0f2d8cf 100644 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -58,6 +58,7 @@ public: LLStat mTexturePacketsStat; LLStat mActualInKBitStat; // From the packet ring (when faking a bad connection) LLStat mActualOutKBitStat; // From the packet ring (when faking a bad connection) + LLStat mTrianglesDrawnStat; // Simulator stats LLStat mSimTimeDilation; @@ -99,15 +100,22 @@ public: LLStat mPhysicsPinnedTasks; LLStat mPhysicsLODTasks; LLStat mPhysicsMemoryAllocated; - /* - LLStat mSimCPUUsageStat; - LLStat mSimMemTotalStat; - LLStat mSimMemRSSStat; - */ - LLStat mSimPingStat; + LLStat mNumImagesStat; + LLStat mNumRawImagesStat; + LLStat mGLTexMemStat; + LLStat mGLBoundMemStat; + LLStat mRawMemStat; + LLStat mFormattedMemStat; + + LLStat mNumObjectsStat; + LLStat mNumActiveObjectsStat; + LLStat mNumNewObjectsStat; + LLStat mNumSizeCulledStat; + LLStat mNumVisCulledStat; + void resetStats(); public: // If you change this, please also add a corresponding text label @@ -190,6 +198,90 @@ public: void addToMessage(LLSD &body) const; + struct StatsAccumulator + { + S32 mCount; + F32 mSum; + F32 mSumOfSquares; + F32 mMinValue; + F32 mMaxValue; + U32 mCountOfNextUpdatesToIgnore; + + inline StatsAccumulator() + { + reset(); + } + + inline void push( F32 val ) + { + if ( mCountOfNextUpdatesToIgnore > 0 ) + { + mCountOfNextUpdatesToIgnore--; + return; + } + + mCount++; + mSum += val; + mSumOfSquares += val * val; + if (mCount == 1 || val > mMaxValue) + { + mMaxValue = val; + } + if (mCount == 1 || val < mMinValue) + { + mMinValue = val; + } + } + + inline F32 getMean() const + { + return (mCount == 0) ? 0.f : ((F32)mSum)/mCount; + } + + inline F32 getMinValue() const + { + return mMinValue; + } + + inline F32 getMaxValue() const + { + return mMaxValue; + } + + inline F32 getStdDev() const + { + const F32 mean = getMean(); + return (mCount == 0) ? 0.f : sqrt( mSumOfSquares/mCount - (mean * mean) ); + } + + inline U32 getCount() const + { + return mCount; + } + + inline void reset() + { + mCount = 0; + mSum = mSumOfSquares = 0.f; + mMinValue = 0.0f; + mMaxValue = 0.0f; + mCountOfNextUpdatesToIgnore = 0; + } + + inline LLSD getData() const + { + LLSD data; + data["mean"] = getMean(); + data["std_dev"] = getStdDev(); + data["count"] = (S32)mCount; + data["min"] = getMinValue(); + data["max"] = getMaxValue(); + return data; + } + }; + + StatsAccumulator mAgentPositionSnaps; + private: F64 mStats[ST_COUNT]; diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index a4590160e..2ec7cf396 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -36,6 +36,7 @@ #include "llaudioengine.h" #include "llagent.h" #include "llinventory.h" +#include "llinventorydefines.h" #include "llinventorymodel.h" #include "llinventoryview.h" #include "llinventorybridge.h" // for landmark prefix string diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 6babdb116..0a8ab1c0d 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -108,7 +108,6 @@ S32 LLViewerTexture::sMaxSmallImageSize = MAX_CACHED_RAW_IMAGE_AREA ; BOOL LLViewerTexture::sFreezeImageScalingDown = FALSE ; F32 LLViewerTexture::sCurrentTime = 0.0f ; //BOOL LLViewerTexture::sUseTextureAtlas = FALSE ; -BOOL LLViewerTexture::sDontLoadVolumeTextures = FALSE ; const F32 desired_discard_bias_min = -2.0f; // -max number of levels to improve image quality by const F32 desired_discard_bias_max = (F32)MAX_DISCARD_LEVEL; // max number of levels to reduce image quality by @@ -1206,6 +1205,7 @@ void LLViewerFetchedTexture::init(bool firstinit) mSavedRawDiscardLevel = -1 ; mDesiredSavedRawDiscardLevel = -1 ; mLastReferencedSavedRawImageTime = 0.0f ; + mKeptSavedRawImageTime = 0.f ; mLastCallBackActiveTime = 0.f; } @@ -1465,9 +1465,16 @@ BOOL LLViewerFetchedTexture::createTexture(S32 usename/*= 0*/) mOrigWidth = mRawImage->getWidth(); mOrigHeight = mRawImage->getHeight(); - // leave black border, do not scale image content - mRawImage->expandToPowerOfTwo(MAX_IMAGE_SIZE, FALSE); + if (mBoostLevel == BOOST_PREVIEW) + { + mRawImage->biasedScaleToPowerOfTwo(1024); + } + else + { // leave black border, do not scale image content + mRawImage->expandToPowerOfTwo(MAX_IMAGE_SIZE, FALSE); + } + mFullWidth = mRawImage->getWidth(); mFullHeight = mRawImage->getHeight(); setTexelsPerImage(); @@ -1551,7 +1558,7 @@ void LLViewerFetchedTexture::processTextureStats() { updateVirtualSize() ; - static LLCachedControl textures_fullres("TextureLoadFullRes",false); + static LLCachedControl textures_fullres(gSavedSettings,"TextureLoadFullRes"); if (textures_fullres) { @@ -1839,7 +1846,7 @@ S32 LLViewerFetchedTexture::getCurrentDiscardLevelForFetching() bool LLViewerFetchedTexture::updateFetch() { - static LLCachedControl textures_decode_disabled("TextureDecodeDisabled",false); + static LLCachedControl textures_decode_disabled(gSavedSettings,"TextureDecodeDisabled"); if(textures_decode_disabled) { return false ; @@ -2043,11 +2050,11 @@ bool LLViewerFetchedTexture::updateFetch() c = mComponents; } - /*const U32 override_tex_discard_level = gSavedSettings.getU32("TextureDiscardLevel"); + const U32 override_tex_discard_level = gSavedSettings.getU32("TextureDiscardLevel"); if (override_tex_discard_level != 0) { desired_discard = override_tex_discard_level; - }*/ + } // bypass texturefetch directly by pulling from LLTextureCache bool fetch_request_created = false; @@ -2755,8 +2762,16 @@ void LLViewerFetchedTexture::saveRawImage() mLastReferencedSavedRawImageTime = sCurrentTime ; } -void LLViewerFetchedTexture::forceToSaveRawImage(S32 desired_discard) +void LLViewerFetchedTexture::forceToSaveRawImage(S32 desired_discard, F32 kept_time) { + mKeptSavedRawImageTime = kept_time ; + mLastReferencedSavedRawImageTime = sCurrentTime ; + + if(mSavedRawDiscardLevel > -1 && mSavedRawDiscardLevel <= desired_discard) + { + return ; //raw imge is ready. + } + if(!mForceToSaveRawImage || mDesiredSavedRawDiscardLevel < 0 || mDesiredSavedRawDiscardLevel > desired_discard) { mForceToSaveRawImage = TRUE ; @@ -2777,6 +2792,14 @@ void LLViewerFetchedTexture::forceToSaveRawImage(S32 desired_discard) } void LLViewerFetchedTexture::destroySavedRawImage() { + if(mLastReferencedSavedRawImageTime < mKeptSavedRawImageTime) + { + return ; //keep the saved raw image. + } + + mForceToSaveRawImage = FALSE ; + mSaveRawImage = FALSE ; + clearCallbackEntryList() ; mSavedRawImage = NULL ; @@ -2785,6 +2808,7 @@ void LLViewerFetchedTexture::destroySavedRawImage() mSavedRawDiscardLevel = -1 ; mDesiredSavedRawDiscardLevel = -1 ; mLastReferencedSavedRawImageTime = 0.0f ; + mKeptSavedRawImageTime = 0.f ; } LLImageRaw* LLViewerFetchedTexture::getSavedRawImage() @@ -3030,8 +3054,8 @@ BOOL LLViewerLODTexture::isUpdateFrozen() void LLViewerLODTexture::processTextureStats() { updateVirtualSize() ; - - static LLCachedControl textures_fullres("TextureLoadFullRes", false); + + static LLCachedControl textures_fullres(gSavedSettings,"TextureLoadFullRes"); if (textures_fullres) { diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 9bfdcd6f3..5fd4275aa 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -338,7 +338,6 @@ public: static BOOL sFreezeImageScalingDown ;//do not scale down image res if set. static F32 sCurrentTime ; //static BOOL sUseTextureAtlas ; - static BOOL sDontLoadVolumeTextures ; static LLPointer sNullImagep; // Null texture for non-textured objects. }; @@ -476,7 +475,7 @@ public: S32 getCachedRawImageLevel() const {return mCachedRawDiscardLevel;} BOOL isCachedRawImageReady() const {return mCachedRawImageReady ;} BOOL isRawImageValid()const { return mIsRawImageValid ; } - void forceToSaveRawImage(S32 desired_discard = 0) ; + void forceToSaveRawImage(S32 desired_discard = 0, F32 kept_time = 0.f) ; /*virtual*/ void setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) ; void destroySavedRawImage() ; LLImageRaw* getSavedRawImage() ; @@ -562,6 +561,7 @@ protected: S32 mSavedRawDiscardLevel; S32 mDesiredSavedRawDiscardLevel; F32 mLastReferencedSavedRawImageTime ; + F32 mKeptSavedRawImageTime ; //a small version of the copy of the raw image (<= 64 * 64) LLPointer mCachedRawImage; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 997823268..5de2a805e 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -72,12 +72,6 @@ void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL; U32 LLViewerTextureList::sTextureBits = 0; U32 LLViewerTextureList::sTexturePackets = 0; S32 LLViewerTextureList::sNumImages = 0; -LLStat LLViewerTextureList::sNumImagesStat(32, TRUE); -LLStat LLViewerTextureList::sNumRawImagesStat(32, TRUE); -LLStat LLViewerTextureList::sGLTexMemStat(32, TRUE); -LLStat LLViewerTextureList::sGLBoundMemStat(32, TRUE); -LLStat LLViewerTextureList::sRawMemStat(32, TRUE); -LLStat LLViewerTextureList::sFormattedMemStat(32, TRUE); LLViewerTextureList gTextureList; @@ -125,7 +119,7 @@ void LLViewerTextureList::doPreloadImages() // Set the "white" image LLViewerFetchedTexture::sWhiteImagep = LLViewerTextureManager::getFetchedTextureFromFile("white.tga", MIPMAP_NO, LLViewerFetchedTexture::BOOST_UI); - + LLTexUnit::sWhiteTexture = LLViewerFetchedTexture::sWhiteImagep->getTexName(); LLUIImageList* image_list = LLUIImageList::getInstance(); image_list->initFromFile(); @@ -612,12 +606,12 @@ void LLViewerTextureList::updateImages(F32 max_time) { global_raw_memory = *AIAccess(LLImageRaw::sGlobalRawMemory); } - sNumImagesStat.addValue(sNumImages); - sNumRawImagesStat.addValue(LLImageRaw::sRawImageCount); - sGLTexMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sGlobalTextureMemoryInBytes)); - sGLBoundMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sBoundTextureMemoryInBytes)); - sRawMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(global_raw_memory)); - sFormattedMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageFormatted::sGlobalFormattedMemory)); + LLViewerStats::getInstance()->mNumImagesStat.addValue(sNumImages); + LLViewerStats::getInstance()->mNumRawImagesStat.addValue(LLImageRaw::sRawImageCount); + LLViewerStats::getInstance()->mGLTexMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sGlobalTextureMemoryInBytes)); + LLViewerStats::getInstance()->mGLBoundMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sBoundTextureMemoryInBytes)); + LLViewerStats::getInstance()->mRawMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(global_raw_memory)); + LLViewerStats::getInstance()->mFormattedMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageFormatted::sGlobalFormattedMemory)); updateImagesDecodePriorities(); @@ -681,10 +675,7 @@ void LLViewerTextureList::updateImagesDecodePriorities() const F32 LAZY_FLUSH_TIMEOUT = 30.f; // stop decoding const F32 MAX_INACTIVE_TIME = 50.f; // actually delete S32 min_refs = 3; // 1 for mImageList, 1 for mUUIDMap, 1 for local reference - if (imagep->hasCallbacks()) - { - min_refs++; // Add an extra reference if we're on the loaded callback list - } + S32 num_refs = imagep->getNumRefs(); if (num_refs == min_refs) { @@ -979,99 +970,54 @@ void LLViewerTextureList::decodeAllImages(F32 max_time) BOOL LLViewerTextureList::createUploadFile(const std::string& filename, const std::string& out_filename, const U8 codec) -{ - // First, load the image. +{ + // Load the image + LLPointer image = LLImageFormatted::createFromType(codec); + if (image.isNull()) + { + image->setLastError("Couldn't open the image to be uploaded."); + return FALSE; + } + if (!image->load(filename)) + { + image->setLastError("Couldn't load the image to be uploaded."); + return FALSE; + } + // Decompress or expand it in a raw image structure LLPointer raw_image = new LLImageRaw; - - switch (codec) + if (!image->decode(raw_image, 0.0f)) { - case IMG_CODEC_BMP: - { - LLPointer bmp_image = new LLImageBMP; - - if (!bmp_image->load(filename)) - { - return FALSE; - } - - if (!bmp_image->decode(raw_image, 0.0f)) - { - return FALSE; - } - } - break; - case IMG_CODEC_TGA: - { - LLPointer tga_image = new LLImageTGA; - - if (!tga_image->load(filename)) - { - return FALSE; - } - - if (!tga_image->decode(raw_image)) - { - return FALSE; - } - - if( (tga_image->getComponents() != 3) && - (tga_image->getComponents() != 4) ) - { - tga_image->setLastError( "Image files with less than 3 or more than 4 components are not supported." ); - return FALSE; - } - } - break; - case IMG_CODEC_JPEG: - { - LLPointer jpeg_image = new LLImageJPEG; - - if (!jpeg_image->load(filename)) - { - return FALSE; - } - - if (!jpeg_image->decode(raw_image, 0.0f)) - { - return FALSE; - } - } - break; - case IMG_CODEC_PNG: - { - LLPointer png_image = new LLImagePNG; - - if (!png_image->load(filename)) - { - return FALSE; - } - - if (!png_image->decode(raw_image, 0.0f)) - { - return FALSE; - } - } - break; - default: - return FALSE; - } - - LLPointer compressedImage = convertToUploadFile(raw_image); - - if( !compressedImage->save(out_filename) ) - { - llinfos << "Couldn't create output file " << out_filename << llendl; + image->setLastError("Couldn't decode the image to be uploaded."); return FALSE; } - - // test to see if the encode and save worked. + // Check the image constraints + if ((image->getComponents() != 3) && (image->getComponents() != 4)) + { + image->setLastError("Image files with less than 3 or more than 4 components are not supported."); + return FALSE; + } + // Convert to j2c (JPEG2000) and save the file locally + LLPointer compressedImage = convertToUploadFile(raw_image); + if (compressedImage.isNull()) + { + image->setLastError("Couldn't convert the image to jpeg2000."); + llinfos << "Couldn't convert to j2c, file : " << filename << llendl; + return FALSE; + } + if (!compressedImage->save(out_filename)) + { + image->setLastError("Couldn't create the jpeg2000 image for upload."); + llinfos << "Couldn't create output file : " << out_filename << llendl; + return FALSE; + } + // Test to see if the encode and save worked LLPointer integrity_test = new LLImageJ2C; - if( !integrity_test->loadAndValidate( out_filename ) ) + if (!integrity_test->loadAndValidate( out_filename )) { - llinfos << "Image: " << out_filename << " is corrupt." << llendl; + image->setLastError("The created jpeg2000 image is corrupt."); + llinfos << "Image file : " << out_filename << " is corrupt" << llendl; return FALSE; } - return TRUE; } @@ -1086,7 +1032,25 @@ LLPointer LLViewerTextureList::convertToUploadFile(LLPointergetWidth() * raw_image->getHeight() <= LL_IMAGE_REZ_LOSSLESS_CUTOFF * LL_IMAGE_REZ_LOSSLESS_CUTOFF)) compressedImage->setReversible(TRUE); - compressedImage->encode(raw_image, 0.0f); + +/* if (gSavedSettings.getBOOL("Jpeg2000AdvancedCompression")) + { + // This test option will create jpeg2000 images with precincts for each level, RPCL ordering + // and PLT markers. The block size is also optionally modifiable. + // Note: the images hence created are compatible with older versions of the viewer. + // Read the blocks and precincts size settings + S32 block_size = gSavedSettings.getS32("Jpeg2000BlocksSize"); + S32 precinct_size = gSavedSettings.getS32("Jpeg2000PrecinctsSize"); + llinfos << "Advanced JPEG2000 Compression: precinct = " << precinct_size << ", block = " << block_size << llendl; + compressedImage->initEncode(*raw_image, block_size, precinct_size, 0); + }*/ + + if (!compressedImage->encode(raw_image, 0.0f)) + { + llinfos << "convertToUploadFile : encode returns with error!!" << llendl; + // Clear up the pointer so we don't leak that one + compressedImage = NULL; + } return compressedImage; } @@ -1201,7 +1165,7 @@ void LLViewerTextureList::updateMaxResidentTexMem(S32 mem) // static void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_data) { - static LLCachedControl log_texture_traffic("LogTextureNetworkTraffic",false) ; + static LLCachedControl log_texture_traffic(gSavedSettings,"LogTextureNetworkTraffic") ; LLFastTimer t(LLFastTimer::FTM_PROCESS_IMAGES); @@ -1273,7 +1237,7 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d // static void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_data) { - static LLCachedControl log_texture_traffic("LogTextureNetworkTraffic",FALSE) ; + static LLCachedControl log_texture_traffic(gSavedSettings,"LogTextureNetworkTraffic") ; LLMemType mt1(LLMemType::MTYPE_APPFMTIMAGE); LLFastTimer t(LLFastTimer::FTM_PROCESS_IMAGES); diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index cabaa6764..fd09c60cd 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -207,13 +207,6 @@ public: static U32 sTextureBits; static U32 sTexturePackets; - static LLStat sNumImagesStat; - static LLStat sNumRawImagesStat; - static LLStat sGLTexMemStat; - static LLStat sGLBoundMemStat; - static LLStat sRawMemStat; - static LLStat sFormattedMemStat; - private: static S32 sNumImages; static void (*sUUIDCallback)(void**, const LLUUID &); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 0ebb74e00..3ee8be54f 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -191,6 +191,9 @@ #include "llviewernetwork.h" #include "llpostprocess.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" + #include "llfloatertest.h" // HACK! #include "llfloaternotificationsconsole.h" @@ -235,6 +238,8 @@ LLVector2 gDebugRaycastTexCoord; LLVector3 gDebugRaycastNormal; LLVector3 gDebugRaycastBinormal; S32 gDebugRaycastFaceHit; +LLVector3 gDebugRaycastStart; +LLVector3 gDebugRaycastEnd; // HUD display lines in lower right BOOL gDisplayWindInfo = FALSE; @@ -305,11 +310,12 @@ public: mTextColor = LLColor4( 0.86f, 0.86f, 0.86f, 1.f ); // Draw stuff growing up from right lower corner of screen - U32 xpos = mWindow->getWindowWidth() - 350; + U32 xpos = mWindow->getWorldViewWidthScaled() - 350; U32 ypos = 64; const U32 y_inc = 20; - if (gSavedSettings.getBOOL("DebugShowTime")) + static const LLCachedControl debug_show_time("DebugShowTime"); + if (debug_show_time) { const U32 y_inc2 = 15; for (std::map::reverse_iterator iter = gDebugTimers.rbegin(); @@ -334,7 +340,8 @@ public: } #if LL_WINDOWS - if (gSavedSettings.getBOOL("DebugShowMemory")) + static const LLCachedControl debug_show_memory("DebugShowMemory"); + if (debug_show_memory) { addText(xpos, ypos, llformat("Memory: %d (KB)", LLMemory::getWorkingSetSize() / 1024)); ypos += y_inc; @@ -424,7 +431,8 @@ public: ypos += y_inc; }*/ - if (gSavedSettings.getBOOL("DebugShowRenderInfo")) + static const LLCachedControl debug_show_render_info("DebugShowRenderInfo"); + if (debug_show_render_info) { if (gPipeline.getUseVertexShaders() == 0) { @@ -454,6 +462,59 @@ public: addText(xpos, ypos, llformat("%.2f MB Video Memory Free", free_memory/1024.f)); ypos += y_inc; } + +#if MESH_ENABLED + //show streaming cost/triangle count of known prims in current region OR selection + //Note: This is SUPER slow + { + F32 cost = 0.f; + S32 count = 0; + S32 object_count = 0; + S32 total_bytes = 0; + S32 visible_bytes = 0; + + const char* label = "Region"; + if (LLSelectMgr::getInstance()->getSelection()->getObjectCount() == 0) + { //region + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + for (U32 i = 0; i < (U32)gObjectList.getNumObjects(); ++i) + { + LLViewerObject* object = gObjectList.getObject(i); + if (object && + object->getRegion() == region && + object->getVolume()) + { + object_count++; + S32 bytes = 0; + S32 visible = 0; + cost += object->getStreamingCost(&bytes, &visible); + count += object->getTriangleCount(); + total_bytes += bytes; + visible_bytes += visible; + } + } + } + } + else + { + label = "Selection"; + cost = LLSelectMgr::getInstance()->getSelection()->getSelectedObjectStreamingCost(&total_bytes, &visible_bytes); + count = LLSelectMgr::getInstance()->getSelection()->getSelectedObjectTriangleCount(); + object_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); + } + + addText(xpos,ypos, llformat("%s streaming cost: %.1f", label, cost)); + ypos += y_inc; + + addText(xpos, ypos, llformat(" %.3f KTris, %.1f/%.1f KB, %d objects", + count/1000.f, visible_bytes/1024.f, total_bytes/1024.f, object_count)); + ypos += y_inc; + + } +#endif //MESH_ENABLED + addText(xpos, ypos, llformat("%d MB Vertex Data", LLVertexBuffer::sAllocatedBytes/(1024*1024))); ypos += y_inc; @@ -518,7 +579,7 @@ public: ypos += y_inc; #if MESH_ENABLED - if (gSavedSettings.getBOOL("MeshEnabled")) + if (gMeshRepo.meshRezEnabled()) { addText(xpos, ypos, llformat("%.3f MB Mesh Data Received", LLMeshRepository::sBytesReceived/(1024.f*1024.f))); @@ -539,7 +600,8 @@ public: LLVertexBuffer::sSetCount = LLImageGL::sUniqueCount = gPipeline.mNumVisibleNodes = LLPipeline::sVisibleLightCount = 0; } - if (gSavedSettings.getBOOL("DebugShowRenderMatrices")) + static const LLCachedControl debug_show_render_matrices("DebugShowRenderMatrices"); + if (debug_show_render_matrices) { addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", gGLProjection[12], gGLProjection[13], gGLProjection[14], gGLProjection[15])); ypos += y_inc; @@ -572,7 +634,8 @@ public: addText(xpos, ypos, "View Matrix"); ypos += y_inc; } - if (gSavedSettings.getBOOL("DebugShowColor")) + static const LLCachedControl debug_show_color("DebugShowColor"); + if (debug_show_color) { U8 color[4]; LLCoordGL coord = gViewerWindow->getCurrentMouse(); @@ -1162,11 +1225,16 @@ void LLViewerWindow::handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask LLCoordGL prev_saved_mouse_point = mCurrentMousePoint; LLCoordGL mouse_point(x, y); + + if (mouse_point != mCurrentMousePoint) + { + gMouseIdleTimer.reset(); + } saveLastMouse(mouse_point); BOOL mouse_actually_moved = !gFocusMgr.getMouseCapture() && // mouse is not currenty captured ((prev_saved_mouse_point.mX != mCurrentMousePoint.mX) || (prev_saved_mouse_point.mY != mCurrentMousePoint.mY)); // mouse moved from last recorded position - gMouseIdleTimer.reset(); + mWindow->showCursorFromMouseMove(); @@ -1514,11 +1582,12 @@ LLViewerWindow::LLViewerWindow( S32 width, S32 height, BOOL fullscreen, BOOL ignore_pixel_depth) : + mWindow(NULL), mActive(TRUE), mWantFullscreen(fullscreen), mShowFullscreenProgress(FALSE), - mWindowRect(0, height, width, 0), - mVirtualWindowRect(0, height, width, 0), + mWindowRectRaw(0, height, width, 0), + mWindowRectScaled(0, height, width, 0), mLeftMouseDown(FALSE), mRightMouseDown(FALSE), mToolTip(NULL), @@ -1548,15 +1617,33 @@ LLViewerWindow::LLViewerWindow( resetSnapshotLoc(); // create window - mWindow = LLWindowManager::createWindow( + mWindow = LLWindowManager::createWindow(this, title, name, x, y, width, height, 0, fullscreen, gNoRender, gSavedSettings.getBOOL("DisableVerticalSync"), !gNoRender, ignore_pixel_depth, - gSavedSettings.getU32("RenderFSAASamples")); + gSavedSettings.getBOOL("RenderUseFBO") ? 0 : gSavedSettings.getU32("RenderFSAASamples")); //don't use window level anti-aliasing if FBOs are enabled + if (NULL == mWindow) + { + LLSplashScreen::update("Graphics Initialization Failed. Please Update Your Graphics Driver!"); + + LL_WARNS("Window") << "Failed to create window, to be shutting Down, be sure your graphics driver is updated." << llendl ; + + ms_sleep(5000) ; //wait for 5 seconds. + LLSplashScreen::update("Shutting down..."); +#if LL_LINUX || LL_SOLARIS + llwarns << "Unable to create window, be sure screen is set at 32-bit color and your graphics driver is configured correctly. See README-linux.txt or README-solaris.txt for further information." + << llendl; +#else + LL_WARNS("Window") << "Unable to create window, be sure screen is set at 32-bit color in Control Panels->Display->Settings" + << LL_ENDL; +#endif + LLAppViewer::instance()->fastQuit(1); + } + if (!LLAppViewer::instance()->restoreErrorTrap()) { LL_WARNS("Window") << " Someone took over my signal/exception handler (post createWindow)!" << LL_ENDL; @@ -1571,19 +1658,6 @@ LLViewerWindow::LLViewerWindow( gSavedSettings.setS32("FullScreenWidth",scr.mX); gSavedSettings.setS32("FullScreenHeight",scr.mY); } - - if (NULL == mWindow) - { - LLSplashScreen::update("Shutting down..."); -#if LL_LINUX || LL_SOLARIS - llwarns << "Unable to create window, be sure screen is set at 32-bit color and your graphics driver is configured correctly. See README-linux.txt or README-solaris.txt for further information." - << llendl; -#else - LL_WARNS("Window") << "Unable to create window, be sure screen is set at 32-bit color in Control Panels->Display->Settings" - << LL_ENDL; -#endif - LLAppViewer::instance()->forceExit(1); - } // Get the real window rect the window was created with (since there are various OS-dependent reasons why // the size of a window or fullscreen context may have been adjusted slightly...) @@ -1596,8 +1670,8 @@ LLViewerWindow::LLViewerWindow( { LLCoordWindow size; mWindow->getSize(&size); - mWindowRect.set(0, size.mY, size.mX, 0); - mVirtualWindowRect.set(0, llround((F32)size.mY / mDisplayScale.mV[VY]), llround((F32)size.mX / mDisplayScale.mV[VX]), 0); + mWindowRectRaw.set(0, size.mY, size.mX, 0); + mWindowRectScaled.set(0, llround((F32)size.mY / mDisplayScale.mV[VY]), llround((F32)size.mX / mDisplayScale.mV[VX]), 0); } LLFontManager::initClass(); @@ -1638,12 +1712,8 @@ LLViewerWindow::LLViewerWindow( mInitAlert = "DisplaySettingsNoShaders"; LLFeatureManager::getInstance()->setGraphicsLevel(0, false); gSavedSettings.setU32("RenderQualityPerformance", 0); - } - // set callbacks - mWindow->setCallbacks(this); - // Init the image list. Must happen after GL is initialized and before the images that // LLViewerWindow needs are requested. LLImageGL::initClass(LLViewerTexture::MAX_GL_IMAGE_CATEGORY) ; @@ -1652,7 +1722,7 @@ LLViewerWindow::LLViewerWindow( gBumpImageList.init(); // Create container for all sub-views - mRootView = new LLRootView("root", mVirtualWindowRect, FALSE); + mRootView = new LLRootView("root", mWindowRectScaled, FALSE); if (!gNoRender) { @@ -1661,8 +1731,8 @@ LLViewerWindow::LLViewerWindow( } // Make avatar head look forward at start - mCurrentMousePoint.mX = getWindowWidth() / 2; - mCurrentMousePoint.mY = getWindowHeight() / 2; + mCurrentMousePoint.mX = getWindowWidthScaled() / 2; + mCurrentMousePoint.mY = getWindowHeightScaled() / 2; gShowOverlayTitle = gSavedSettings.getBOOL("ShowOverlayTitle"); mOverlayTitle = gSavedSettings.getString("OverlayTitle"); @@ -1709,8 +1779,8 @@ void LLViewerWindow::initGLDefaults() void LLViewerWindow::initBase() { - S32 height = getWindowHeight(); - S32 width = getWindowWidth(); + S32 height = getWindowHeightScaled(); + S32 width = getWindowWidthScaled(); LLRect full_window(0, height, width, 0); @@ -2196,8 +2266,8 @@ void LLViewerWindow::sendShapeToSim() msg->addU32Fast(_PREHASH_CircuitCode, gMessageSystem->mOurCircuitCode); msg->nextBlockFast(_PREHASH_HeightWidthBlock); msg->addU32Fast(_PREHASH_GenCounter, 0); - U16 height16 = (U16) mWindowRect.getHeight(); - U16 width16 = (U16) mWindowRect.getWidth(); + U16 height16 = (U16) mWindowRectRaw.getHeight(); + U16 width16 = (U16) mWindowRectRaw.getWidth(); msg->addU16Fast(_PREHASH_Height, height16); msg->addU16Fast(_PREHASH_Width, width16); gAgent.sendReliableMessage(); @@ -2236,18 +2306,18 @@ void LLViewerWindow::reshape(S32 width, S32 height) } // update our window rectangle - mWindowRect.mRight = mWindowRect.mLeft + width; - mWindowRect.mTop = mWindowRect.mBottom + height; + mWindowRectRaw.mRight = mWindowRectRaw.mLeft + width; + mWindowRectRaw.mTop = mWindowRectRaw.mBottom + height; calcDisplayScale(); BOOL display_scale_changed = mDisplayScale != LLUI::sGLScaleFactor; LLUI::setScaleFactor(mDisplayScale); // update our window rectangle - mVirtualWindowRect.mRight = mVirtualWindowRect.mLeft + llround((F32)width / mDisplayScale.mV[VX]); - mVirtualWindowRect.mTop = mVirtualWindowRect.mBottom + llround((F32)height / mDisplayScale.mV[VY]); + mWindowRectScaled.mRight = mWindowRectScaled.mLeft + llround((F32)width / mDisplayScale.mV[VX]); + mWindowRectScaled.mTop = mWindowRectScaled.mBottom + llround((F32)height / mDisplayScale.mV[VY]); - setupViewport(); + setup2DViewport(); // Inform lower views of the change // round up when converting coordinates to make sure there are no gaps at edge of window @@ -2392,8 +2462,8 @@ void LLViewerWindow::draw() microsecondsToTimecodeString(gFrameTime,text); const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ); font->renderUTF8(text, 0, - llround((getWindowWidth()/2)-100.f), - llround((getWindowHeight()-60.f)), + llround((getWindowWidthScaled()/2)-100.f), + llround((getWindowHeightScaled()-60.f)), LLColor4( 1.f, 1.f, 1.f, 1.f ), LLFontGL::LEFT, LLFontGL::TOP); } @@ -2401,6 +2471,10 @@ void LLViewerWindow::draw() // Draw all nested UI views. // No translation needed, this view is glued to 0,0 + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } gGL.pushMatrix(); { // scale view by UI global scale factor and aspect ratio correction factor @@ -2416,8 +2490,8 @@ void LLViewerWindow::draw() int pos_y = sub_region / llceil(zoom_factor); int pos_x = sub_region - (pos_y*llceil(zoom_factor)); // offset for this tile - glTranslatef((F32)getWindowWidth() * -(F32)pos_x, - (F32)getWindowHeight() * -(F32)pos_y, + glTranslatef((F32)getWindowWidthScaled() * -(F32)pos_x, + (F32)getWindowHeightScaled() * -(F32)pos_y, 0.f); glScalef(zoom_factor, zoom_factor, 1.f); LLUI::sGLScaleFactor *= zoom_factor; @@ -2482,8 +2556,8 @@ void LLViewerWindow::draw() const S32 DIST_FROM_TOP = 20; LLFontGL::getFontSansSerifBig()->renderUTF8( mOverlayTitle, 0, - llround( getWindowWidth() * 0.5f), - getWindowHeight() - DIST_FROM_TOP, + llround( getWindowWidthScaled() * 0.5f), + getWindowHeightScaled() - DIST_FROM_TOP, LLColor4(1, 1, 1, 0.4f), LLFontGL::HCENTER, LLFontGL::TOP); } @@ -2492,6 +2566,10 @@ void LLViewerWindow::draw() } gGL.popMatrix(); + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.unbind(); + } #if LL_DEBUG LLView::sIsDrawing = FALSE; #endif @@ -2644,7 +2722,7 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) } // Try for a new-format gesture - if (gGestureManager.triggerGesture(key, mask)) + if (LLGestureMgr::instance().triggerGesture(key, mask)) { return TRUE; } @@ -2802,6 +2880,10 @@ void LLViewerWindow::handleScrollWheel(S32 clicks) } // Zoom the camera in and out behavior + + if(top_ctrl == 0 + && getWorldViewRectScaled().pointInRect(mCurrentMousePoint.mX, mCurrentMousePoint.mY) + && gAgentCamera.isInitialized()) gAgentCamera.handleScrollWheel(clicks); return; @@ -2809,8 +2891,8 @@ void LLViewerWindow::handleScrollWheel(S32 clicks) void LLViewerWindow::moveCursorToCenter() { - S32 x = mVirtualWindowRect.getWidth() / 2; - S32 y = mVirtualWindowRect.getHeight() / 2; + S32 x = getWorldViewWidthScaled() / 2; + S32 y = getWorldViewHeightScaled() / 2; //on a forced move, all deltas get zeroed out to prevent jumping mCurrentMousePoint.set(x,y); @@ -2835,15 +2917,28 @@ BOOL LLViewerWindow::handlePerFrameHover() S32 x = mCurrentMousePoint.mX; S32 y = mCurrentMousePoint.mY; + MASK mask = gKeyboard->currentMask(TRUE); + if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST)) + { + gDebugRaycastFaceHit = -1; + gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, + &gDebugRaycastFaceHit, + &gDebugRaycastIntersection, + &gDebugRaycastTexCoord, + &gDebugRaycastNormal, + &gDebugRaycastBinormal, + &gDebugRaycastStart, + &gDebugRaycastEnd); + } //RN: fix for asynchronous notification of mouse leaving window not working LLCoordWindow mouse_pos; mWindow->getCursorPosition(&mouse_pos); if (mouse_pos.mX < 0 || mouse_pos.mY < 0 || - mouse_pos.mX > mWindowRect.getWidth() || - mouse_pos.mY > mWindowRect.getHeight()) + mouse_pos.mX > mWindowRectRaw.getWidth() || + mouse_pos.mY > mWindowRectRaw.getHeight()) { mMouseInWindow = FALSE; } @@ -3231,16 +3326,6 @@ BOOL LLViewerWindow::handlePerFrameHover() LLSelectMgr::getInstance()->deselectUnused(); } - if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST)) - { - gDebugRaycastFaceHit = -1; - gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, - &gDebugRaycastFaceHit, - &gDebugRaycastIntersection, - &gDebugRaycastTexCoord, - &gDebugRaycastNormal, - &gDebugRaycastBinormal); - } // per frame picking - for tooltips and changing cursor over interactive objects @@ -3286,9 +3371,9 @@ void LLViewerWindow::saveLastMouse(const LLCoordGL &point) { mCurrentMousePoint.mX = 0; } - else if (point.mX > getWindowWidth()) + else if (point.mX > getWindowWidthScaled()) { - mCurrentMousePoint.mX = getWindowWidth(); + mCurrentMousePoint.mX = getWindowWidthScaled(); } else { @@ -3299,9 +3384,9 @@ void LLViewerWindow::saveLastMouse(const LLCoordGL &point) { mCurrentMousePoint.mY = 0; } - else if (point.mY > getWindowHeight() ) + else if (point.mY > getWindowHeightScaled() ) { - mCurrentMousePoint.mY = getWindowHeight(); + mCurrentMousePoint.mY = getWindowHeightScaled(); } else { @@ -3558,8 +3643,8 @@ void LLViewerWindow::pickAsync(S32 x, S32 y_from_bot, MASK mask, void (*callback if (mPickScreenRegion.mLeft < 0) mPickScreenRegion.translate(-mPickScreenRegion.mLeft, 0); if (mPickScreenRegion.mBottom < 0) mPickScreenRegion.translate(0, -mPickScreenRegion.mBottom); - if (mPickScreenRegion.mRight > mWindowRect.getWidth() ) mPickScreenRegion.translate(mWindowRect.getWidth() - mPickScreenRegion.mRight, 0); - if (mPickScreenRegion.mTop > mWindowRect.getHeight() ) mPickScreenRegion.translate(0, mWindowRect.getHeight() - mPickScreenRegion.mTop); + if (mPickScreenRegion.mRight > mWindowRectRaw.getWidth() ) mPickScreenRegion.translate(mWindowRectRaw.getWidth() - mPickScreenRegion.mRight, 0); + if (mPickScreenRegion.mTop > mWindowRectRaw.getHeight() ) mPickScreenRegion.translate(0, mWindowRectRaw.getHeight() - mPickScreenRegion.mTop); } // set frame buffer region for picking results @@ -3586,77 +3671,6 @@ void LLViewerWindow::schedulePick(LLPickInfo& pick_info) } llassert_always(pick_info.mScreenRegion.notEmpty()); mPicks.push_back(pick_info); - - /*S32 scaled_x = llround((F32)pick_info.mMousePt.mX * mDisplayScale.mV[VX]); - S32 scaled_y = llround((F32)pick_info.mMousePt.mY * mDisplayScale.mV[VY]); - - // Default to not hitting anything - LLCamera pick_camera; - pick_camera.setOrigin(LLViewerCamera::getInstance()->getOrigin()); - pick_camera.setOriginAndLookAt(LLViewerCamera::getInstance()->getOrigin(), - LLViewerCamera::getInstance()->getUpAxis(), - LLViewerCamera::getInstance()->getOrigin() + mouseDirectionGlobal(pick_info.mMousePt.mX, pick_info.mMousePt.mY)); - pick_camera.setView(0.5f*DEG_TO_RAD); - pick_camera.setNear(LLViewerCamera::getInstance()->getNear()); - pick_camera.setFar(LLViewerCamera::getInstance()->getFar()); - pick_camera.setAspect(1.f); - - // save our drawing state - // *TODO: should we be saving using the new method here using - // glh_get_current_projection/glh_set_current_projection? -brad - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - - // clear work area - { - LLGLState scissor_state(GL_SCISSOR_TEST); - scissor_state.enable(); - glScissor(pick_info.mScreenRegion.mLeft, pick_info.mScreenRegion.mBottom, pick_info.mScreenRegion.getWidth(), pick_info.mScreenRegion.getHeight()); - glClearColor(0.f, 0.f, 0.f, 0.f); - glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - //glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - } - - // build perspective transform and picking viewport - // Perform pick on a PICK_DIAMETER x PICK_DIAMETER pixel region around cursor point. - // Don't limit the select distance for this pick. - LLViewerCamera::getInstance()->setPerspective(FOR_SELECTION, scaled_x - PICK_HALF_WIDTH, scaled_y - PICK_HALF_WIDTH, PICK_DIAMETER, PICK_DIAMETER, FALSE); - - // render for object picking - - // make viewport big enough to handle antialiased frame buffers - gGLViewport[0] = pick_info.mScreenRegion.mLeft; - gGLViewport[1] = pick_info.mScreenRegion.mBottom; - gGLViewport[2] = pick_info.mScreenRegion.getWidth(); - gGLViewport[3] = pick_info.mScreenRegion.getHeight(); - - glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); - LLViewerCamera::updateFrustumPlanes(pick_camera); - stop_glerror(); - - // Draw the objects so the user can select them. - // The starting ID is 1, since land is zero. - LLRect pick_region; - pick_region.setOriginAndSize(pick_info.mMousePt.mX - PICK_HALF_WIDTH, - pick_info.mMousePt.mY - PICK_HALF_WIDTH, PICK_DIAMETER, PICK_DIAMETER); - gObjectList.renderObjectsForSelect(pick_camera, pick_region, FALSE, pick_info.mPickTransparent); - - stop_glerror(); - - // restore drawing state - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - setup3DRender(); - setup2DRender(); - setupViewport();*/ // delay further event processing until we receive results of pick mWindow->delayInputProcessing(); @@ -3746,7 +3760,9 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de LLVector3 *intersection, LLVector2 *uv, LLVector3 *normal, - LLVector3 *binormal) + LLVector3 *binormal, + LLVector3* start, + LLVector3* end) { S32 x = mouse_x; S32 y = mouse_y; @@ -3778,7 +3794,22 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de LLVector3 mouse_world_start = mouse_point_global; LLVector3 mouse_world_end = mouse_point_global + mouse_direction_global * depth; - + if (!LLViewerJoystick::getInstance()->getOverrideCamera()) + { //always set raycast intersection to mouse_world_end unless + //flycam is on (for DoF effect) + gDebugRaycastIntersection = mouse_world_end; + } + + if (start) + { + *start = mouse_world_start; + } + + if (end) + { + *end = mouse_world_end; + } + LLViewerObject* found = NULL; if (this_object) // check only this object @@ -3850,16 +3881,16 @@ LLVector3 LLViewerWindow::mouseDirectionGlobal(const S32 x, const S32 y) const // find vertical field of view F32 fov = LLViewerCamera::getInstance()->getView(); - // find screen resolution - S32 height = getWindowHeight(); - S32 width = getWindowWidth(); + // find world view center in scaled ui coordinates + F32 center_x = getWorldViewRectScaled().getCenterX(); + F32 center_y = getWorldViewRectScaled().getCenterY(); // calculate pixel distance to screen - F32 distance = (height / 2.f) / (tan(fov / 2.f)); + F32 distance = ((F32)getWorldViewHeightScaled() * 0.5f) / (tan(fov / 2.f)); // calculate click point relative to middle of screen - F32 click_x = x - width / 2.f; - F32 click_y = y - height / 2.f; + F32 click_x = x - center_x; + F32 click_y = y - center_y; // compute mouse vector LLVector3 mouse_vector = distance * LLViewerCamera::getInstance()->getAtAxis() @@ -3874,12 +3905,15 @@ LLVector3 LLViewerWindow::mouseDirectionGlobal(const S32 x, const S32 y) const LLVector3 LLViewerWindow::mousePointHUD(const S32 x, const S32 y) const { // find screen resolution - S32 height = getWindowHeight(); - S32 width = getWindowWidth(); + S32 height = getWorldViewHeightScaled(); + + // find world view center + F32 center_x = getWorldViewRectScaled().getCenterX(); + F32 center_y = getWorldViewRectScaled().getCenterY(); // remap with uniform scale (1/height) so that top is -0.5, bottom is +0.5 - F32 hud_x = -((F32)x - (F32)width/2.f) / height; - F32 hud_y = ((F32)y - (F32)height/2.f) / height; + F32 hud_x = -((F32)x - center_x) / height; + F32 hud_y = ((F32)y - center_y) / height; return LLVector3(0.f, hud_x/gAgentCamera.mHUDCurZoom, hud_y/gAgentCamera.mHUDCurZoom); } @@ -3893,12 +3927,16 @@ LLVector3 LLViewerWindow::mouseDirectionCamera(const S32 x, const S32 y) const F32 fov_width = fov_height * LLViewerCamera::getInstance()->getAspect(); // find screen resolution - S32 height = getWindowHeight(); - S32 width = getWindowWidth(); + S32 height = getWorldViewHeightScaled(); + S32 width = getWorldViewWidthScaled(); + + // find world view center + F32 center_x = getWorldViewRectScaled().getCenterX(); + F32 center_y = getWorldViewRectScaled().getCenterY(); // calculate click point relative to middle of screen - F32 click_x = (((F32)x / (F32)width) - 0.5f) * fov_width * -1.f; - F32 click_y = (((F32)y / (F32)height) - 0.5f) * fov_height; + F32 click_x = (((F32)x - center_x) / (F32)width) * fov_width * -1.f; + F32 click_y = (((F32)y - center_y) / (F32)height) * fov_height; // compute mouse vector LLVector3 mouse_vector = LLVector3(0.f, 0.f, -1.f); @@ -4149,8 +4187,8 @@ void LLViewerWindow::movieSize(S32 new_width, S32 new_height) ||(size.mY != new_height + BORDERHEIGHT)) { // use actual display dimensions, not virtual UI dimensions - S32 x = gViewerWindow->getWindowDisplayWidth(); - S32 y = gViewerWindow->getWindowDisplayHeight(); + S32 x = gViewerWindow->getWindowWidthRaw(); + S32 y = gViewerWindow->getWindowHeightRaw(); BORDERWIDTH = size.mX - x; BORDERHEIGHT = size.mY- y; LLCoordScreen new_size(new_width + BORDERWIDTH, @@ -4248,9 +4286,9 @@ BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 p S32 w = preview_width ; S32 h = preview_height ; LLVector2 display_scale = mDisplayScale ; - mDisplayScale.setVec((F32)w / mWindowRect.getWidth(), (F32)h / mWindowRect.getHeight()) ; + mDisplayScale.setVec((F32)w / mWindowRectRaw.getWidth(), (F32)h / mWindowRectRaw.getHeight()) ; LLRect window_rect = mWindowRect; - mWindowRect.set(0, h, w, 0); + mWindowRectRaw.set(0, h, w, 0); gDisplaySwapBuffers = FALSE; gDepthDirty = TRUE; @@ -4379,10 +4417,11 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei LLPipeline::sShowHUDAttachments = FALSE; } + // Copy screen to a buffer // crop sides or top and bottom, if taking a snapshot of different aspect ratio // from window - LLRect window_rect = mWindowRect; + LLRect window_rect = show_ui ? getWindowRectRaw() : getWorldViewRectRaw(); S32 snapshot_width = window_rect.getWidth(); S32 snapshot_height = window_rect.getHeight(); @@ -4449,7 +4488,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei window_width = snapshot_width; window_height = snapshot_height; scale_factor = 1.f; - mWindowRect.set(0, snapshot_height, snapshot_width, 0); + mWindowRectRaw.set(0, snapshot_height, snapshot_width, 0); target.bindTarget(); } } @@ -4524,17 +4563,6 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei { gDisplaySwapBuffers = FALSE; gDepthDirty = TRUE; - if (type == SNAPSHOT_TYPE_OBJECT_ID) - { - glClearColor(0.f, 0.f, 0.f, 0.f); - glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - - LLViewerCamera::getInstance()->setZoomParameters(scale_factor, subimage_x+(subimage_y*llceil(scale_factor))); - setup3DRender(); - setupViewport(); - gObjectList.renderPickList(gViewerWindow->getVirtualWindowRect(), FALSE, FALSE); - } - else { const U32 subfield = subimage_x+(subimage_y*llceil(scale_factor)); display(do_rebuild, scale_factor, subfield, TRUE, is_tiling); @@ -4563,7 +4591,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei LLAppViewer::instance()->pingMainloopTimeout("LLViewerWindow::rawSnapshot"); } - if (type == SNAPSHOT_TYPE_OBJECT_ID || type == SNAPSHOT_TYPE_COLOR) + if (type == SNAPSHOT_TYPE_COLOR) { glReadPixels( subimage_x_offset, @@ -4711,44 +4739,71 @@ void LLViewerWindow::drawMouselookInstructions() LLFontGL::LEFT, LLFontGL::TOP); } +void* LLViewerWindow::getPlatformWindow() const +{ + return mWindow->getPlatformWindow(); +} +void* LLViewerWindow::getMediaWindow() const +{ + return mWindow->getMediaWindow(); +} + +void LLViewerWindow::focusClient() const +{ + return mWindow->focusClient(); +} S32 LLViewerWindow::getWindowHeight() const { - return mVirtualWindowRect.getHeight(); + return mWindowRectScaled.getHeight(); } S32 LLViewerWindow::getWindowWidth() const { - return mVirtualWindowRect.getWidth(); + return mWindowRectScaled.getWidth(); } S32 LLViewerWindow::getWindowDisplayHeight() const { - return mWindowRect.getHeight(); + return mWindowRectRaw.getHeight(); } S32 LLViewerWindow::getWindowDisplayWidth() const { - return mWindowRect.getWidth(); -} - -void LLViewerWindow::setupViewport(S32 x_offset, S32 y_offset) -{ - gGLViewport[0] = x_offset; - gGLViewport[1] = y_offset; - gGLViewport[2] = mWindowRect.getWidth(); - gGLViewport[3] = mWindowRect.getHeight(); - glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); -} - -void LLViewerWindow::setup3DRender() -{ - LLViewerCamera::getInstance()->setPerspective(NOT_FOR_SELECTION, 0, 0, mWindowRect.getWidth(), mWindowRect.getHeight(), FALSE, LLViewerCamera::getInstance()->getNear(), MAX_FAR_CLIP*2.f); + return mWindowRectRaw.getWidth(); } void LLViewerWindow::setup2DRender() { - gl_state_for_2d(mWindowRect.getWidth(), mWindowRect.getHeight()); + // setup ortho camera + gl_state_for_2d(mWindowRectRaw.getWidth(), mWindowRectRaw.getHeight()); + setup2DViewport(); +} + +void LLViewerWindow::setup2DViewport(S32 x_offset, S32 y_offset) +{ + gGLViewport[0] = mWindowRectRaw.mLeft + x_offset; + gGLViewport[1] = mWindowRectRaw.mBottom + y_offset; + gGLViewport[2] = mWindowRectRaw.getWidth(); + gGLViewport[3] = mWindowRectRaw.getHeight(); + glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); +} + + +void LLViewerWindow::setup3DRender() +{ + // setup perspective camera + LLViewerCamera::getInstance()->setPerspective(NOT_FOR_SELECTION, getWindowRectRaw().mLeft, getWindowRectRaw().mBottom, getWindowRectRaw().getWidth(), getWindowRectRaw().getHeight(), FALSE, LLViewerCamera::getInstance()->getNear(), MAX_FAR_CLIP*2.f); + setup3DViewport(); +} + +void LLViewerWindow::setup3DViewport(S32 x_offset, S32 y_offset) +{ + gGLViewport[0] = getWindowRectRaw().mLeft + x_offset; + gGLViewport[1] = getWindowRectRaw().mBottom + y_offset; + gGLViewport[2] = getWindowRectRaw().getWidth(); + gGLViewport[3] = getWindowRectRaw().getHeight(); + glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); } @@ -4761,10 +4816,7 @@ void LLViewerWindow::setShowProgress(const BOOL show) } } -BOOL LLViewerWindow::getShowProgress() const -{ - return (mProgressView && mProgressView->getVisible()); -} + void LLViewerWindow::moveProgressViewToFront() @@ -4776,6 +4828,11 @@ void LLViewerWindow::moveProgressViewToFront() } } +BOOL LLViewerWindow::getShowProgress() const +{ + return (mProgressView && mProgressView->getVisible()); +} + void LLViewerWindow::setProgressString(const std::string& string) { if (mProgressView) @@ -5001,7 +5058,7 @@ BOOL LLViewerWindow::checkSettings() getWindow()->setNativeAspectRatio(gSavedSettings.getF32("FullScreenAspectRatio")); } - reshape(getWindowDisplayWidth(), getWindowDisplayHeight()); + reshape(getWindowWidthRaw(), getWindowHeightRaw()); // force aspect ratio if (mIsFullscreenChecked) @@ -5163,7 +5220,7 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size, LLSD args; args["RESX"] = llformat("%d",size.mX); args["RESY"] = llformat("%d",size.mY); - LLNotifications::instance().add("ResolutionSwitchFail", args); + LLNotificationsUtil::add("ResolutionSwitchFail", args); size = old_size; // for reshape below } @@ -5235,7 +5292,7 @@ void LLViewerWindow::calcDisplayScale() F32 ui_scale_factor = gSavedSettings.getF32("UIScaleFactor"); LLVector2 display_scale; display_scale.setVec(llmax(1.f / mWindow->getPixelAspectRatio(), 1.f), llmax(mWindow->getPixelAspectRatio(), 1.f)); - F32 height_normalization = gSavedSettings.getBOOL("UIAutoScale") ? ((F32)mWindowRect.getHeight() / display_scale.mV[VY]) / 768.f : 1.f; + F32 height_normalization = gSavedSettings.getBOOL("UIAutoScale") ? ((F32)mWindowRectRaw.getHeight() / display_scale.mV[VY]) / 768.f : 1.f; if(mWindow->getFullscreen()) { display_scale *= (ui_scale_factor * height_normalization); @@ -5253,8 +5310,8 @@ void LLViewerWindow::calcDisplayScale() if (mWindow->getFullscreen()) { - display_scale.mV[0] = llround(display_scale.mV[0], 2.0f/(F32) mWindowRect.getWidth()); - display_scale.mV[1] = llround(display_scale.mV[1], 2.0f/(F32) mWindowRect.getHeight()); + display_scale.mV[0] = llround(display_scale.mV[0], 2.0f/(F32) mWindowRectRaw.getWidth()); + display_scale.mV[1] = llround(display_scale.mV[1], 2.0f/(F32) mWindowRectRaw.getHeight()); } if (display_scale != mDisplayScale) @@ -5278,7 +5335,7 @@ S32 LLViewerWindow::getChatConsoleBottomPad() LLRect LLViewerWindow::getChatConsoleRect() { - LLRect full_window(0, getWindowHeight(), getWindowWidth(), 0); + LLRect full_window(0, getWindowHeightScaled(), getWindowWidthScaled(), 0); LLRect console_rect = full_window; const S32 CONSOLE_PADDING_TOP = 24; @@ -5299,7 +5356,7 @@ LLRect LLViewerWindow::getChatConsoleRect() { // Make console rect somewhat narrow so having inventory open is // less of a problem. - console_rect.mRight = console_rect.mLeft + 2 * getWindowWidth() / 3; + console_rect.mRight = console_rect.mLeft + 2 * getWindowWidthScaled() / 3; } return console_rect; @@ -5448,9 +5505,9 @@ void LLPickInfo::fetchResults() //glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, mPickDepthBuffer ); // find pick region that is fully onscreen - LLCoordGL scaled_pick_point;; - scaled_pick_point.mX = llclamp(llround((F32)mMousePt.mX * gViewerWindow->getDisplayScale().mV[VX]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayWidth() - PICK_HALF_WIDTH); - scaled_pick_point.mY = llclamp(llround((F32)mMousePt.mY * gViewerWindow->getDisplayScale().mV[VY]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayHeight() - PICK_HALF_WIDTH); + //LLCoordGL scaled_pick_point;; + //scaled_pick_point.mX = llclamp(llround((F32)mMousePt.mX * gViewerWindow->getDisplayScale().mV[VX]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayWidth() - PICK_HALF_WIDTH); + //scaled_pick_point.mY = llclamp(llround((F32)mMousePt.mY * gViewerWindow->getDisplayScale().mV[VY]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayHeight() - PICK_HALF_WIDTH); //S32 pixel_index = PICK_HALF_WIDTH * PICK_DIAMETER + PICK_HALF_WIDTH; //S32 pick_id = (U32)mPickBuffer[(pixel_index * 4) + 0] << 16 | (U32)mPickBuffer[(pixel_index * 4) + 1] << 8 | (U32)mPickBuffer[(pixel_index * 4) + 2]; //F32 depth = mPickDepthBuffer[pixel_index]; diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index dec5a177c..036d23bb6 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -44,9 +44,11 @@ #include "v3dmath.h" #include "v2math.h" -#include "llwindow.h" +#include "llcursortypes.h" +#include "llwindowcallbacks.h" #include "lltimer.h" #include "llstat.h" +#include "llmousehandler.h" #include "llalertdialog.h" #include "llnotifications.h" @@ -58,8 +60,9 @@ class LLTool; class LLVelocityBar; class LLTextBox; class LLImageRaw; +class LLImageFormatted; class LLHUDIcon; -class LLMouseHandler; +class LLWindow; class AIFilePicker; #define PICK_HALF_WIDTH 5 @@ -67,6 +70,17 @@ class AIFilePicker; class LLPickInfo { +public: + typedef enum e_pick_type + { + PICK_OBJECT, + PICK_FLORA, + PICK_LAND, + PICK_ICON, + PICK_PARCEL_WALL, + PICK_INVALID + } EPickType; + public: LLPickInfo(); LLPickInfo(const LLCoordGL& mouse_pos, @@ -80,20 +94,11 @@ public: void fetchResults(); LLPointer getObject() const; LLUUID getObjectID() const { return mObjectID; } + bool isValid() const { return mPickType != PICK_INVALID; } void drawPickBuffer() const; static bool isFlora(LLViewerObject* object); - typedef enum e_pick_type - { - PICK_OBJECT, - PICK_FLORA, - PICK_LAND, - PICK_ICON, - PICK_PARCEL_WALL, - PICK_INVALID - } EPickType; - public: LLCoordGL mMousePt; MASK mKeyMask; @@ -190,20 +195,35 @@ public: LLView* getRootView() const { return mRootView; } // Window in raw pixels as seen on screen. - const LLRect& getWindowRect() const { return mWindowRect; }; + const LLRect& getWindowRect() const { return mWindowRectRaw; }; S32 getWindowDisplayHeight() const; S32 getWindowDisplayWidth() const; + //Temporary wrappers. + const LLRect& getWindowRectRaw() const { return getWindowRect(); } + S32 getWindowHeightRaw() const { return getWindowDisplayHeight(); } + S32 getWindowWidthRaw() const { return getWindowDisplayWidth(); } + const LLRect& getWorldViewRectRaw() const { return getWindowRect(); } + S32 getWorldViewHeightRaw() const { return getWindowDisplayHeight(); } + S32 getWorldViewWidthRaw() const { return getWindowDisplayWidth(); } // Window in scaled pixels (via UI scale), use this for // UI elements checking size. - const LLRect& getVirtualWindowRect() const { return mVirtualWindowRect; }; + const LLRect& getVirtualWindowRect() const { return mWindowRectScaled; }; S32 getWindowHeight() const; S32 getWindowWidth() const; + //Temporary wrappers. + const LLRect& getWindowRectScaled() const { return getVirtualWindowRect(); } + S32 getWindowHeightScaled() const { return getWindowHeight(); }; + S32 getWindowWidthScaled() const { return getWindowWidth(); }; + const LLRect& getWorldViewRectScaled() const { return getVirtualWindowRect(); } + S32 getWorldViewHeightScaled() const { return getWindowHeight(); }; + S32 getWorldViewWidthScaled() const { return getWindowWidth(); }; + LLWindow* getWindow() const { return mWindow; } - void* getPlatformWindow() const { return mWindow->getPlatformWindow(); } - void* getMediaWindow() const { return mWindow->getMediaWindow(); } - void focusClient() const { return mWindow->focusClient(); }; + void* getPlatformWindow() const; + void* getMediaWindow() const; + void focusClient() const; LLCoordGL getLastMouse() const { return mLastMousePoint; } S32 getLastMouseX() const { return mLastMousePoint.mX; } @@ -221,7 +241,8 @@ public: const LLPickInfo& getLastPick() const { return mLastPick; } const LLPickInfo& getHoverPick() const { return mHoverPick; } - void setupViewport(S32 x_offset = 0, S32 y_offset = 0); + void setup2DViewport(S32 x_offset = 0, S32 y_offset = 0); + void setup3DViewport(S32 x_offset = 0, S32 y_offset = 0); void setup3DRender(); void setup2DRender(); @@ -287,7 +308,6 @@ public: { SNAPSHOT_TYPE_COLOR, SNAPSHOT_TYPE_DEPTH, - SNAPSHOT_TYPE_OBJECT_ID }; BOOL saveSnapshot(const std::string& filename, S32 image_width, S32 image_height, BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR); BOOL rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, BOOL keep_window_aspect = TRUE, BOOL is_texture = FALSE, @@ -327,7 +347,9 @@ public: LLVector3 *intersection = NULL, LLVector2 *uv = NULL, LLVector3 *normal = NULL, - LLVector3 *binormal = NULL); + LLVector3 *binormal = NULL, + LLVector3* start = NULL, + LLVector3* end = NULL); // Returns a pointer to the last object hit @@ -382,9 +404,9 @@ protected: BOOL mActive; BOOL mWantFullscreen; BOOL mShowFullscreenProgress; - LLRect mWindowRect; - LLRect mVirtualWindowRect; - LLView* mRootView; // a view of size mWindowRect, containing all child views + LLRect mWindowRectRaw; + LLRect mWindowRectScaled; + LLView* mRootView; // a view of size mWindowRectRaw, containing all child views LLVector2 mDisplayScale; LLCoordGL mCurrentMousePoint; // last mouse position in GL coords diff --git a/indra/newview/llvlcomposition.cpp b/indra/newview/llvlcomposition.cpp index 7b70548b8..3fa6a38e6 100644 --- a/indra/newview/llvlcomposition.cpp +++ b/indra/newview/llvlcomposition.cpp @@ -39,6 +39,7 @@ #include "v3math.h" #include "llsurface.h" #include "lltextureview.h" +#include "llviewertexture.h" #include "llviewertexturelist.h" #include "llviewerregion.h" #include "noise.h" diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 6583eff06..2993b141f 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -2930,7 +2930,7 @@ void LLVOAvatar::idleUpdateVoiceVisualizer(bool voice_enabled) else { llinfos << "oops - CurrentGesticulationLevel can be only 0, 1, or 2" << llendl; } // this is the call that Karl S. created for triggering gestures from within the code. - gGestureManager.triggerAndReviseString( gestureString ); + LLGestureMgr::instance().triggerAndReviseString( gestureString ); } } @@ -4465,34 +4465,39 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) if (visible && !isSelf() && !mIsDummy && sUseImpostors && !mNeedsAnimUpdate && !sFreezeCounter) { + const LLVector4a* ext = mDrawable->getSpatialExtents(); + LLVector4a size; + size.setSub(ext[1],ext[0]); + F32 mag = size.getLength3().getF32()*0.5f; + F32 impostor_area = 256.f*512.f*(8.125f - LLVOAvatar::sLODFactor*8.f); if (LLMuteList::getInstance()->isMuted(getID())) { // muted avatars update at 16 hz mUpdatePeriod = 16; } - else if (mVisibilityRank <= LLVOAvatar::sMaxVisible * 0.25f) + else if (mVisibilityRank <= LLVOAvatar::sMaxVisible || + mDrawable->mDistanceWRTCamera < 1.f + mag) { //first 25% of max visible avatars are not impostored + //also, don't impostor avatars whose bounding box may be penetrating the + //impostor camera near clip plane mUpdatePeriod = 1; } - else if (mVisibilityRank > LLVOAvatar::sMaxVisible * 0.75f) - { //back 25% of max visible avatars are slow updating impostors - mUpdatePeriod = 8; - } - else if (mVisibilityRank > (U32) LLVOAvatar::sMaxVisible) + else if (mVisibilityRank > LLVOAvatar::sMaxVisible * 4) { //background avatars are REALLY slow updating impostors mUpdatePeriod = 16; } + else if (mVisibilityRank > LLVOAvatar::sMaxVisible * 3) + { //back 25% of max visible avatars are slow updating impostors + mUpdatePeriod = 8; + } else if (mImpostorPixelArea <= impostor_area) { // stuff in between gets an update period based on pixel area mUpdatePeriod = llclamp((S32) sqrtf(impostor_area*4.f/mImpostorPixelArea), 2, 8); } - else if (mVisibilityRank > LLVOAvatar::sMaxVisible * 0.25f) - { // force nearby impostors in ultra crowded areas - mUpdatePeriod = 2; - } else - { // not impostored - mUpdatePeriod = 1; + { + //nearby avatars, update the impostors more frequently. + mUpdatePeriod = 4; } visible = (LLDrawable::getCurrentFrame()+mID.mData[0])%mUpdatePeriod == 0 ? TRUE : FALSE; @@ -5224,7 +5229,7 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) // *NOTE: this is disabled (there is no UI for enabling sShowFootPlane) due // to DEV-14477. the code is left here to aid in tracking down the cause // of the crash in the future. -brad - if (!gRenderForSelect && sShowFootPlane && mDrawable.notNull()) + if (sShowFootPlane && mDrawable.notNull()) { LLVector3 slaved_pos = mDrawable->getPositionAgent(); LLVector3 foot_plane_normal(mFootPlane.mV[VX], mFootPlane.mV[VY], mFootPlane.mV[VZ]); @@ -5269,7 +5274,7 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) const bool should_alpha_mask = shouldAlphaMask(); LLGLState test(GL_ALPHA_TEST, should_alpha_mask); - if (should_alpha_mask) + if (should_alpha_mask && !LLGLSLShader::sNoFixedFunction) { gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); } @@ -5298,7 +5303,10 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) } } - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); + if (should_alpha_mask && !LLGLSLShader::sNoFixedFunction) + { + gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); + } if (!LLDrawPoolAvatar::sSkipTransparent || LLPipeline::sImpostorRender) { @@ -5381,7 +5389,7 @@ U32 LLVOAvatar::renderRigid() const bool should_alpha_mask = shouldAlphaMask(); LLGLState test(GL_ALPHA_TEST, should_alpha_mask); - if (should_alpha_mask) + if (should_alpha_mask && !LLGLSLShader::sNoFixedFunction) { gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); } @@ -5392,7 +5400,10 @@ U32 LLVOAvatar::renderRigid() num_indices += mMeshLOD[MESH_ID_EYEBALL_RIGHT]->render(mAdjustedPixelArea, TRUE, mIsDummy); } - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); + if (should_alpha_mask && !LLGLSLShader::sNoFixedFunction) + { + gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); + } return num_indices; } @@ -10021,7 +10032,7 @@ void LLVOAvatar::cullAvatarsByPixelArea() std::sort(LLCharacter::sInstances.begin(), LLCharacter::sInstances.end(), CompareScreenAreaGreater()); // Update the avatars that have changed status - U32 rank = 0; + U32 rank = 2; //1 is reserved for self. for (std::vector::iterator iter = LLCharacter::sInstances.begin(); iter != LLCharacter::sInstances.end(); ++iter) { @@ -10045,7 +10056,7 @@ void LLVOAvatar::cullAvatarsByPixelArea() if (inst->isSelf()) { - inst->setVisibilityRank(0); + inst->setVisibilityRank(1); } else if (inst->mDrawable.notNull() && inst->mDrawable->isVisible()) { diff --git a/indra/newview/llvoclouds.cpp b/indra/newview/llvoclouds.cpp index 0346301ff..e56c78638 100644 --- a/indra/newview/llvoclouds.cpp +++ b/indra/newview/llvoclouds.cpp @@ -246,10 +246,14 @@ void LLVOClouds::getGeometry(S32 te, vtx[2] = puff_pos_agent + right + up; vtx[3] = puff_pos_agent + right - up; + *(verticesp->mV+3) = 0.f; *verticesp++ = vtx[0]; + *(verticesp->mV+3) = 0.f; *verticesp++ = vtx[1]; + *(verticesp->mV+3) = 0.f; *verticesp++ = vtx[2]; - *verticesp++ = vtx[3]; + *(verticesp->mV+3) = 0.f; + *verticesp++ = vtx[3];; *texcoordsp++ = uvs[0]; *texcoordsp++ = uvs[1]; diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp index 8110e02b8..1d350d635 100644 --- a/indra/newview/llvograss.cpp +++ b/indra/newview/llvograss.cpp @@ -38,6 +38,7 @@ #include "llviewercontrol.h" #include "llagentcamera.h" +#include "llnotificationsutil.h" #include "llviewerwindow.h" #include "lldrawable.h" #include "llface.h" @@ -222,7 +223,7 @@ void LLVOGrass::initClass() { LLSD args; args["SPECIES"] = err; - LLNotifications::instance().add("ErrorUndefinedGrasses", args); + LLNotificationsUtil::add("ErrorUndefinedGrasses", args); } for (S32 i = 0; i < GRASS_MAX_BLADES; ++i) diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp index 5fef0f877..53b7177ce 100644 --- a/indra/newview/llvoiceclient.cpp +++ b/indra/newview/llvoiceclient.cpp @@ -62,6 +62,7 @@ #include "llfirstuse.h" #include "llviewerwindow.h" #include "llviewercamera.h" +#include "llnotificationsutil.h" #include "llfloaterfriends.h" //VIVOX, inorder to refresh communicate panel #include "llfloaterchat.h" // for LLFloaterChat::addChat() @@ -7040,7 +7041,7 @@ class LLViewerRequiredVoiceVersion : public LLHTTPNode if (!sAlertedUser) { //sAlertedUser = TRUE; - LLNotifications::instance().add("VoiceVersionMismatch"); + LLNotificationsUtil::add("VoiceVersionMismatch"); gSavedSettings.setBOOL("EnableVoiceChat", FALSE); // toggles listener } } diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp index a5704ae89..5391d5841 100644 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -323,10 +323,18 @@ void LLVOPartGroup::getGeometry(S32 idx, LLVector3 normal = -LLViewerCamera::getInstance()->getXAxis(); - + + //HACK -- the verticesp->mV[3] = 0.f here are to set the texture index to 0 (particles don't use texture batching, maybe they should) + // this works because there is actually a 4th float stored after the vertex position which is used as a texture index + // also, somebody please VECTORIZE THIS + + *(verticesp->mV+3) = 0.f; *verticesp++ = part_pos_agent + up - right; + *(verticesp->mV+3) = 0.f; *verticesp++ = part_pos_agent - up - right; + *(verticesp->mV+3) = 0.f; *verticesp++ = part_pos_agent + up + right; + *(verticesp->mV+3) = 0.f; *verticesp++ = part_pos_agent - up + right; *colorsp++ = part.mColor; @@ -359,7 +367,7 @@ U32 LLVOPartGroup::getPartitionType() const } LLParticlePartition::LLParticlePartition() -: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK, TRUE, GL_DYNAMIC_DRAW_ARB) +: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, GL_STREAM_DRAW_ARB) { mRenderPass = LLRenderPass::PASS_ALPHA; mDrawableType = LLPipeline::RENDER_TYPE_PARTICLES; @@ -417,6 +425,7 @@ void LLParticlePartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_co mFaceList.push_back(facep); vertex_count += facep->getGeomCount(); index_count += facep->getIndicesCount(); + llassert(facep->getIndicesCount() < 65536); } obj->mDepth /= count; diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index b143b6bea..b259c0acd 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -377,7 +377,7 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mAtmHeight = ATM_HEIGHT; mEarthCenter = LLVector3(mCameraPosAgent.mV[0], mCameraPosAgent.mV[1], -EARTH_RADIUS); - mSunDefaultPosition = LLVector3(LLWLParamManager::instance()->mCurParams.getVector("lightnorm", error)); + mSunDefaultPosition = LLVector3(LLWLParamManager::getInstance()->mCurParams.getVector("lightnorm", error)); if (gSavedSettings.getBOOL("SkyOverrideSimSunPosition")) { initSunDirection(mSunDefaultPosition, LLVector3(0, 0, 0)); @@ -654,24 +654,24 @@ void LLVOSky::initAtmospherics(void) bool error; // uniform parameters for convenience - dome_radius = LLWLParamManager::instance()->getDomeRadius(); - dome_offset_ratio = LLWLParamManager::instance()->getDomeOffset(); - sunlight_color = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("sunlight_color", error)); - ambient = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("ambient", error)); - //lightnorm = LLWLParamManager::instance()->mCurParams.getVector("lightnorm", error); - gamma = LLWLParamManager::instance()->mCurParams.getVector("gamma", error)[0]; - blue_density = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("blue_density", error)); - blue_horizon = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("blue_horizon", error)); - haze_density = LLWLParamManager::instance()->mCurParams.getVector("haze_density", error)[0]; - haze_horizon = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("haze_horizon", error)); - density_multiplier = LLWLParamManager::instance()->mCurParams.getVector("density_multiplier", error)[0]; - max_y = LLWLParamManager::instance()->mCurParams.getVector("max_y", error)[0]; - glow = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("glow", error)); - cloud_shadow = LLWLParamManager::instance()->mCurParams.getVector("cloud_shadow", error)[0]; - cloud_color = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("cloud_color", error)); - cloud_scale = LLWLParamManager::instance()->mCurParams.getVector("cloud_scale", error)[0]; - cloud_pos_density1 = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("cloud_pos_density1", error)); - cloud_pos_density2 = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("cloud_pos_density2", error)); + dome_radius = LLWLParamManager::getInstance()->getDomeRadius(); + dome_offset_ratio = LLWLParamManager::getInstance()->getDomeOffset(); + sunlight_color = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("sunlight_color", error)); + ambient = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("ambient", error)); + //lightnorm = LLWLParamManager::getInstance()->mCurParams.getVector("lightnorm", error); + gamma = LLWLParamManager::getInstance()->mCurParams.getVector("gamma", error)[0]; + blue_density = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("blue_density", error)); + blue_horizon = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("blue_horizon", error)); + haze_density = LLWLParamManager::getInstance()->mCurParams.getVector("haze_density", error)[0]; + haze_horizon = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("haze_horizon", error)); + density_multiplier = LLWLParamManager::getInstance()->mCurParams.getVector("density_multiplier", error)[0]; + max_y = LLWLParamManager::getInstance()->mCurParams.getVector("max_y", error)[0]; + glow = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("glow", error)); + cloud_shadow = LLWLParamManager::getInstance()->mCurParams.getVector("cloud_shadow", error)[0]; + cloud_color = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("cloud_color", error)); + cloud_scale = LLWLParamManager::getInstance()->mCurParams.getVector("cloud_scale", error)[0]; + cloud_pos_density1 = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("cloud_pos_density1", error)); + cloud_pos_density2 = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("cloud_pos_density2", error)); // light norm is different. We need the sun's direction, not the light direction // which could be from the moon. And we need to clamp it @@ -763,6 +763,11 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo // project the direction ray onto the sky dome. F32 phi = acos(Pn[1]); F32 sinA = sin(F_PI - phi); + if (fabsf(sinA) < 0.01f) + { //avoid division by zero + sinA = 0.01f; + } + F32 Plen = dome_radius * sin(F_PI + phi + asin(dome_offset_ratio * sinA)) / sinA; Pn *= Plen; @@ -1042,7 +1047,7 @@ void LLVOSky::calcAtmospherics(void) // between sunlight and point lights in windlight to normalize point lights. static const LLCachedControl render_sun_dynamic_range("RenderSunDynamicRange", 1.f); F32 sun_dynamic_range = llmax((float)render_sun_dynamic_range, 0.0001f); - LLWLParamManager::instance()->mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); + LLWLParamManager::getInstance()->mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); mSunDiffuse = vary_SunlightColor; mSunAmbient = vary_AmbientColor; @@ -1489,6 +1494,7 @@ BOOL LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 f, cons facep->setVertexBuffer(buff); } + llassert(facep->getVertexBuffer()->getNumIndices() == 6); index_offset = facep->getGeometry(verticesp,normalsp,texCoordsp, indicesp); if (-1 == index_offset) @@ -2133,7 +2139,7 @@ void LLVOSky::updateFog(const F32 distance) F32 depth = water_height - camera_height; // get the water param manager variables - float water_fog_density = LLWaterParamManager::instance()->getFogDensity(); + float water_fog_density = LLWaterParamManager::getInstance()->getFogDensity(); LLColor4 water_fog_color = LLDrawPoolWater::sWaterFogColor.mV; // adjust the color based on depth. We're doing linear approximations diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp index 1f0365761..e4af0224f 100644 --- a/indra/newview/llvosurfacepatch.cpp +++ b/indra/newview/llvosurfacepatch.cpp @@ -60,8 +60,6 @@ public: LLVertexBuffer(MAP_VERTEX | MAP_NORMAL | MAP_TEXCOORD0 | MAP_TEXCOORD1 | MAP_COLOR, GL_DYNAMIC_DRAW_ARB) { //texture coordinates 2 and 3 exist, but use the same data as texture coordinate 1 - mOffsets[TYPE_TEXCOORD3] = mOffsets[TYPE_TEXCOORD2] = mOffsets[TYPE_TEXCOORD1]; - mTypeMask |= MAP_TEXCOORD2 | MAP_TEXCOORD3; }; // virtual @@ -382,6 +380,8 @@ void LLVOSurfacePatch::updateMainGeometry(LLFace *facep, S32 num_vertices, num_indices; U32 index; + llassert(mLastStride > 0); + render_stride = mLastStride; patch_size = mPatchp->getSurface()->getGridsPerPatchEdge(); S32 vert_size = patch_size / render_stride; diff --git a/indra/newview/llvotextbubble.cpp b/indra/newview/llvotextbubble.cpp index 5b46ec681..df3677539 100644 --- a/indra/newview/llvotextbubble.cpp +++ b/indra/newview/llvotextbubble.cpp @@ -243,14 +243,16 @@ void LLVOTextBubble::getGeometry(S32 idx, LLColor4U color = LLColor4U(getTE(idx)->getColor()); U32 offset = mDrawable->getFace(idx)->getGeomIndex(); + normalsp.assignArray((U8*)face.mNormals, sizeof(face.mNormals[0]), face.mNumVertices); + texcoordsp.assignArray((U8*)face.mTexCoords, sizeof(face.mTexCoords[0]), face.mNumVertices); + + for (U32 i = 0; i < (U32)face.mNumVertices; i++) { - LLVector4a vertpos; - vertpos.setMul(face.mPositions[i],scale); - vertpos.add(pos); - (verticesp++)->set(vertpos.getF32ptr()); - (normalsp++)->set(face.mNormals[i].getF32ptr()); - *texcoordsp++ = face.mTexCoords[i]; + LLVector4a t; + t.setMul(face.mPositions[i],scale); + t.add(pos); + (verticesp++)->set(t.getF32ptr()); *colorsp++ = color; } diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index 8a5093bcb..08dbc4df5 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -57,6 +57,7 @@ #include "noise.h" #include "pipeline.h" #include "llspatialpartition.h" +#include "llnotificationsutil.h" #include "llviewerwindow.h" extern LLPipeline gPipeline; @@ -267,7 +268,7 @@ void LLVOTree::initClass() { LLSD args; args["SPECIES"] = err; - LLNotifications::instance().add("ErrorUndefinedTrees", args); + LLNotificationsUtil::add("ErrorUndefinedTrees", args); } }; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 1847e3ff4..7115f16b1 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -73,6 +73,7 @@ #include "lldrawpoolavatar.h" #include "llmeshrepository.h" #include "lldatapacker.h" +#include "llviewershadermgr.h" #include "llvoavatar.h" #include "llfloatertools.h" #endif //MESH_ENABLED @@ -93,6 +94,8 @@ F32 LLVOVolume::sLODFactor = 1.f; F32 LLVOVolume::sLODSlopDistanceFactor = 0.5f; //Changing this to zero, effectively disables the LOD transition slop F32 LLVOVolume::sDistanceFactor = 1.0f; S32 LLVOVolume::sNumLODChanges = 0; +S32 LLVOVolume::mRenderComplexity_last = 0; +S32 LLVOVolume::mRenderComplexity_current = 0; LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) : LLViewerObject(id, pcode, regionp), @@ -489,21 +492,29 @@ BOOL LLVOVolume::isVisible() const return FALSE ; } -void LLVOVolume::updateTextureVirtualSize() + +void LLVOVolume::updateTextureVirtualSize(bool forced) { // Update the pixel area of all faces - if(!isVisible() || mDrawable.isNull()) - { + if(mDrawable.isNull()) return; + if(!forced) + { + if(!isVisible()) + { + return; + } + + if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SIMPLE)) + { + return; + } } - if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SIMPLE)) - { - return; - } - - if (LLViewerTexture::sDontLoadVolumeTextures || LLAppViewer::getTextureFetch()->mDebugPause) + static LLCachedControl dont_load_textures(gSavedSettings,"TextureDisable"); + + if (dont_load_textures || LLAppViewer::getTextureFetch()->mDebugPause) // || !mDrawable->isVisible()) { return; } @@ -557,12 +568,12 @@ void LLVOVolume::updateTextureVirtualSize() // Animating textures also rez badly in Snowglobe because the // actual displayed area is only a fraction (corresponding to one // frame) of the animating texture. Let's fix that here: - if (mTextureAnimp && mTextureAnimp->mScaleS > 0.0f && mTextureAnimp->mScaleT > 0.0f) + /* if (mTextureAnimp && mTextureAnimp->mScaleS > 0.0f && mTextureAnimp->mScaleT > 0.0f) { // Adjust to take into account the actual frame size which is only a // portion of the animating texture vsize = vsize / mTextureAnimp->mScaleS / mTextureAnimp->mScaleT; - } + }*/ if ((vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE) || (vsize > MIN_TEX_ANIM_SIZE && old_size < MIN_TEX_ANIM_SIZE)) @@ -576,13 +587,17 @@ void LLVOVolume::updateTextureVirtualSize() if (vsize < min_vsize) min_vsize = vsize; if (vsize > max_vsize) max_vsize = vsize; } -// else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) -// { -// F32 pri = imagep->getDecodePriority(); -// pri = llmax(pri, 0.0f); -// if (pri < min_vsize) min_vsize = pri; -// if (pri > max_vsize) max_vsize = pri; -// } + else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) + { + LLViewerFetchedTexture* img = LLViewerTextureManager::staticCastToFetchedTexture(imagep) ; + if(img) + { + F32 pri = img->getDecodePriority(); + pri = llmax(pri, 0.0f); + if (pri < min_vsize) min_vsize = pri; + if (pri > max_vsize) max_vsize = pri; + } + } else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_FACE_AREA)) { F32 pri = mPixelArea; @@ -655,10 +670,10 @@ void LLVOVolume::updateTextureVirtualSize() { setDebugText(llformat("%.0f:%.0f", (F32) sqrt(min_vsize),(F32) sqrt(max_vsize))); } -// else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) -// { -// setDebugText(llformat("%.0f:%.0f", (F32) sqrt(min_vsize),(F32) sqrt(max_vsize))); -// } + else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) + { + setDebugText(llformat("%.0f:%.0f", (F32) sqrt(min_vsize),(F32) sqrt(max_vsize))); + } else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_FACE_AREA)) { setDebugText(llformat("%.0f:%.0f", (F32) sqrt(min_vsize),(F32) sqrt(max_vsize))); @@ -763,9 +778,6 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams ¶ms_in, const S32 detail, bo { //meshes might not have all LODs, get the force detail to best existing LOD LLUUID mesh_id = volume_params.getSculptID(); - //profile and path params don't matter for meshes - volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE); - lod = gMeshRepo.getActualMeshLOD(volume_params, lod); if (lod == -1) { @@ -828,7 +840,7 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams ¶ms_in, const S32 detail, bo // if it's a mesh if ((volume_params.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH) { - if (getVolume()->getNumVolumeFaces() == 0 || getVolume()->isTetrahedron()) + if (!getVolume()->isMeshAssetLoaded()) { //load request not yet issued, request pipeline load this mesh LLUUID asset_id = volume_params.getSculptID(); @@ -996,19 +1008,11 @@ BOOL LLVOVolume::calcLOD() F32 distance; #if MESH_ENABLED - if (mDrawable->isState(LLDrawable::RIGGED)) + if (mDrawable->isState(LLDrawable::RIGGED) && getAvatar()) { LLVOAvatar* avatar = getAvatar(); - if(avatar) - { - distance = avatar->mDrawable->mDistanceWRTCamera; - radius = avatar->getBinRadius(); - } - else - { - distance = mDrawable->mDistanceWRTCamera; - radius = getVolume()->mLODScaleBias.scaledVec(getScale()).length(); - } + distance = avatar->mDrawable->mDistanceWRTCamera; + radius = avatar->getBinRadius(); } else #endif //MESH_ENABLED @@ -1436,11 +1440,16 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable) compiled = TRUE; sNumLODChanges += new_num_faces ; + if((S32)getNumTEs() != getVolume()->getNumFaces()) + { + setNumTEs(getVolume()->getNumFaces()); //mesh loading may change number of faces. + } + drawable->setState(LLDrawable::REBUILD_VOLUME); // for face->genVolumeTriangles() { LLFastTimer t(LLFastTimer::FTM_GEN_TRIANGLES); - if (new_num_faces != old_num_faces) + if (new_num_faces != old_num_faces || mNumFaces != (S32)getNumTEs()) { regenFaces(); } @@ -2212,8 +2221,270 @@ const LLMatrix4 LLVOVolume::getRenderMatrix() const return mDrawable->getWorldMatrix(); } +// Returns a base cost and adds textures to passed in set. +// total cost is returned value + 5 * size of the resulting set. +// Cannot include cost of textures, as they may be re-used in linked +// children, and cost should only be increased for unique textures -Nyx +U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const +{ + // Get access to params we'll need at various points. + // Skip if this is object doesn't have a volume (e.g. is an avatar). + BOOL has_volume = (getVolume() != NULL); + LLVolumeParams volume_params; + LLPathParams path_params; + LLProfileParams profile_params; + + U32 num_triangles = 0; + + // per-prim costs + static const U32 ARC_PARTICLE_COST = 1; // determined experimentally + static const U32 ARC_PARTICLE_MAX = 2048; // default values + static const U32 ARC_TEXTURE_COST = 16; // multiplier for texture resolution - performance tested + static const U32 ARC_LIGHT_COST = 500; // static cost for light-producing prims + static const U32 ARC_MEDIA_FACE_COST = 1500; // static cost per media-enabled face + + + // per-prim multipliers + static const F32 ARC_GLOW_MULT = 1.5f; // tested based on performance + static const F32 ARC_BUMP_MULT = 1.25f; // tested based on performance + static const F32 ARC_FLEXI_MULT = 5; // tested based on performance + static const F32 ARC_SHINY_MULT = 1.6f; // tested based on performance + static const F32 ARC_INVISI_COST = 1.2f; // tested based on performance + static const F32 ARC_WEIGHTED_MESH = 1.2f; // tested based on performance + + static const F32 ARC_PLANAR_COST = 1.0f; // tested based on performance to have negligible impact + static const F32 ARC_ANIM_TEX_COST = 4.f; // tested based on performance + static const F32 ARC_ALPHA_COST = 4.f; // 4x max - based on performance + + F32 shame = 0; + + U32 invisi = 0; + U32 shiny = 0; + U32 glow = 0; + U32 alpha = 0; + U32 flexi = 0; + U32 animtex = 0; + U32 particles = 0; + U32 bump = 0; + U32 planar = 0; + U32 weighted_mesh = 0; + U32 produces_light = 0; + U32 media_faces = 0; + + const LLDrawable* drawablep = mDrawable; + U32 num_faces = drawablep->getNumFaces(); + + if (has_volume) + { + volume_params = getVolume()->getParams(); + path_params = volume_params.getPathParams(); + profile_params = volume_params.getProfileParams(); + + F32 weighted_triangles = -1.0; + getStreamingCost(NULL, NULL, &weighted_triangles); + + if (weighted_triangles > 0.0) + { + num_triangles = (U32)(weighted_triangles); + } + } + + if (num_triangles == 0) + { + num_triangles = 4; + } + + if (isSculpted()) + { + if (isMesh()) + { + // base cost is dependent on mesh complexity + // note that 3 is the highest LOD as of the time of this coding. + S32 size = gMeshRepo.getMeshSize(volume_params.getSculptID(),3); + if ( size > 0) + { + if (gMeshRepo.getSkinInfo(volume_params.getSculptID(), this)) + { + // weighted attachment - 1 point for every 3 bytes + weighted_mesh = 1; + } + + } + else + { + // something went wrong - user should know their content isn't render-free + return 0; + } + } + else + { + const LLSculptParams *sculpt_params = (LLSculptParams *) getParameterEntry(LLNetworkData::PARAMS_SCULPT); + LLUUID sculpt_id = sculpt_params->getSculptTexture(); + if (textures.find(sculpt_id) == textures.end()) + { + LLViewerFetchedTexture *texture = LLViewerTextureManager::getFetchedTexture(sculpt_id); + if (texture) + { + S32 texture_cost = 256 + (S32)(ARC_TEXTURE_COST * (texture->getFullHeight() / 128.f + texture->getFullWidth() / 128.f)); + textures.insert(texture_cost_t::value_type(sculpt_id, texture_cost)); + } + } + } + } + + if (isFlexible()) + { + flexi = 1; + } + if (isParticleSource()) + { + particles = 1; + } + + if (getIsLight()) + { + produces_light = 1; + } + + for (U32 i = 0; i < num_faces; ++i) + { + const LLFace* face = drawablep->getFace(i); + const LLTextureEntry* te = face->getTextureEntry(); + const LLViewerTexture* img = face->getTexture(); + + if (img) + { + if (textures.find(img->getID()) == textures.end()) + { + S32 texture_cost = 256 + (S32)(ARC_TEXTURE_COST * (img->getFullHeight() / 128.f + img->getFullWidth() / 128.f)); + textures.insert(texture_cost_t::value_type(img->getID(), texture_cost)); + } + } + + if (face->getPoolType() == LLDrawPool::POOL_ALPHA) + { + alpha = 1; + } + else if (img && img->getPrimaryFormat() == GL_ALPHA) + { + invisi = 1; + } + /*if (face->hasMedia()) + { + media_faces++; + }*/ + + if (te) + { + if (te->getBumpmap()) + { + // bump is a multiplier, don't add per-face + bump = 1; + } + if (te->getShiny()) + { + // shiny is a multiplier, don't add per-face + shiny = 1; + } + if (te->getGlow() > 0.f) + { + // glow is a multiplier, don't add per-face + glow = 1; + } + if (face->mTextureMatrix != NULL) + { + animtex = 1; + } + if (te->getTexGen()) + { + planar = 1; + } + } + } + + // shame currently has the "base" cost of 1 point per 15 triangles, min 2. + shame = num_triangles * 5.f; + shame = shame < 2.f ? 2.f : shame; + + // multiply by per-face modifiers + if (planar) + { + shame *= planar * ARC_PLANAR_COST; + } + + if (animtex) + { + shame *= animtex * ARC_ANIM_TEX_COST; + } + + if (alpha) + { + shame *= alpha * ARC_ALPHA_COST; + } + + if(invisi) + { + shame *= invisi * ARC_INVISI_COST; + } + + if (glow) + { + shame *= glow * ARC_GLOW_MULT; + } + + if (bump) + { + shame *= bump * ARC_BUMP_MULT; + } + + if (shiny) + { + shame *= shiny * ARC_SHINY_MULT; + } + + + // multiply shame by multipliers + if (weighted_mesh) + { + shame *= weighted_mesh * ARC_WEIGHTED_MESH; + } + + if (flexi) + { + shame *= flexi * ARC_FLEXI_MULT; + } + + + // add additional costs + if (particles) + { + const LLPartSysData *part_sys_data = &(mPartSourcep->mPartSysData); + const LLPartData *part_data = &(part_sys_data->mPartData); + U32 num_particles = (U32)(part_sys_data->mBurstPartCount * llceil( part_data->mMaxAge / part_sys_data->mBurstRate)); + num_particles = num_particles > ARC_PARTICLE_MAX ? ARC_PARTICLE_MAX : num_particles; + F32 part_size = (llmax(part_data->mStartScale[0], part_data->mEndScale[0]) + llmax(part_data->mStartScale[1], part_data->mEndScale[1])) / 2.f; + shame += num_particles * part_size * ARC_PARTICLE_COST; + } + + if (produces_light) + { + shame += ARC_LIGHT_COST; + } + + if (media_faces) + { + shame += media_faces * ARC_MEDIA_FACE_COST; + } + + if (shame > mRenderComplexity_current) + { + mRenderComplexity_current = (S32)shame; + } + + return (U32)shame; +} #if MESH_ENABLED -F32 LLVOVolume::getStreamingCost(S32* bytes, S32* visible_bytes) +F32 LLVOVolume::getStreamingCost(S32* bytes, S32* visible_bytes, F32* unscaled_value) const { F32 radius = getScale().length()*0.5f; @@ -2221,7 +2492,7 @@ F32 LLVOVolume::getStreamingCost(S32* bytes, S32* visible_bytes) { LLSD& header = gMeshRepo.getMeshHeader(getVolume()->getParams().getSculptID()); - return LLMeshRepository::getStreamingCost(header, radius, bytes, visible_bytes, mLOD); + return LLMeshRepository::getStreamingCost(header, radius, bytes, visible_bytes, mLOD, unscaled_value); } else { @@ -2235,12 +2506,18 @@ F32 LLVOVolume::getStreamingCost(S32* bytes, S32* visible_bytes) header["medium_lod"]["size"] = counts[2] * 10; header["high_lod"]["size"] = counts[3] * 10; - return LLMeshRepository::getStreamingCost(header, radius); + return LLMeshRepository::getStreamingCost(header, radius, NULL, NULL, -1, unscaled_value); } } #endif //MESH_ENABLED +//static +void LLVOVolume::updateRenderComplexity() +{ + mRenderComplexity_last = mRenderComplexity_current; + mRenderComplexity_current = 0; +} -U32 LLVOVolume::getTriangleCount() +U32 LLVOVolume::getTriangleCount() const { U32 count = 0; LLVolume* volume = getVolume(); @@ -2268,7 +2545,7 @@ U32 LLVOVolume::getHighLODTriangleCount() else if (isMesh()) { LLVolume* ref = LLPrimitive::getVolumeManager()->refVolume(volume->getParams(), 3); - if (ref->isTetrahedron() || ref->getNumVolumeFaces() == 0) + if (!ref->isMeshAssetLoaded() || ref->getNumVolumeFaces() == 0) { gMeshRepo.loadMesh(this, volume->getParams(), LLModel::LOD_HIGH); } @@ -2562,8 +2839,15 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& e end_face = face+1; } + bool special_cursor = specialHoverCursor(); for (S32 i = start_face; i < end_face; ++i) { + if (!special_cursor && !pick_transparent && getTE(i)->getColor().mV[3] == 0.f) + { //don't attempt to pick completely transparent faces unless + //pick_transparent is true + continue; + } + face_hit = volume->lineSegmentIntersect(v_start, v_end, i, &p, &tc, &n, &bn); @@ -2863,6 +3147,26 @@ LLVolumeBridge::LLVolumeBridge(LLDrawable* drawablep) mSlopRatio = 0.25f; } +bool can_batch_texture(LLFace* facep) +{ + if (facep->getTextureEntry()->getBumpmap()) + { //bump maps aren't worked into texture batching yet + return false; + } + + if (facep->getTexture() && facep->getTexture()->getPrimaryFormat() == GL_ALPHA) + { //can't batch invisiprims + return false; + } + + if (facep->isState(LLFace::TEXTURE_ANIM) && facep->getVirtualSize() > MIN_TEX_ANIM_SIZE) + { //texture animation breaks batches + return false; + } + + return true; +} + void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, U32 type) { LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); @@ -2918,22 +3222,37 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, LLViewerTexture* tex = facep->getTexture(); - U8 glow = 0; - - if (type == LLRenderPass::PASS_GLOW || type==LLRenderPass::PASS_ALPHA) //Alpha pass now handles glow internally - { - glow = (U8) (facep->getTextureEntry()->getGlow() * 255); - } - if (!facep->getVertexBuffer()) + U8 index = facep->getTextureIndex(); + + bool batchable = false; + + if (index < 255 && idx >= 0) { - llerrs << "WTF?" << llendl; + if (index < draw_vec[idx]->mTextureList.size()) + { + if (draw_vec[idx]->mTextureList[index].isNull()) + { + batchable = true; + draw_vec[idx]->mTextureList[index] = tex; + } + else if (draw_vec[idx]->mTextureList[index] == tex) + { //this face's texture index can be used with this batch + batchable = true; + } + } + else + { //texture list can be expanded to fit this texture index + batchable = true; + } } + + U8 glow = (U8) (facep->getTextureEntry()->getGlow() * 255); if (idx >= 0 && draw_vec[idx]->mVertexBuffer == facep->getVertexBuffer() && draw_vec[idx]->mEnd == facep->getGeomIndex()-1 && - (LLPipeline::sTextureBindTest || draw_vec[idx]->mTexture == tex) && + (LLPipeline::sTextureBindTest || draw_vec[idx]->mTexture == tex || batchable) && #if LL_DARWIN draw_vec[idx]->mEnd - draw_vec[idx]->mStart + facep->getGeomCount() <= (U32) gGLManager.mGLMaxVertexRange && draw_vec[idx]->mCount + facep->getIndicesCount() <= (U32) gGLManager.mGLMaxIndexRange && @@ -2947,6 +3266,12 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, draw_vec[idx]->mCount += facep->getIndicesCount(); draw_vec[idx]->mEnd += facep->getGeomCount(); draw_vec[idx]->mVSize = llmax(draw_vec[idx]->mVSize, facep->getVirtualSize()); + + if (index >= draw_vec[idx]->mTextureList.size()) + { + draw_vec[idx]->mTextureList.resize(index+1); + draw_vec[idx]->mTextureList[index] = tex; + } draw_vec[idx]->validate(); update_min_max(draw_vec[idx]->mExtents[0], draw_vec[idx]->mExtents[1], facep->mExtents[0]); update_min_max(draw_vec[idx]->mExtents[0], draw_vec[idx]->mExtents[1], facep->mExtents[1]); @@ -2971,6 +3296,12 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, } draw_info->mExtents[0] = facep->mExtents[0]; draw_info->mExtents[1] = facep->mExtents[1]; + + if (index < 255) + { //initialize texture list for texture batching + draw_info->mTextureList.resize(index+1); + draw_info->mTextureList[index] = tex; + } draw_info->validate(); } } @@ -3077,13 +3408,14 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) LLVOVolume* vobj = drawablep->getVOVolume(); #if MESH_ENABLED - if (vobj->getVolume() && vobj->getVolume()->isTetrahedron() || (vobj->isMesh() && !gMeshRepo.meshRezEnabled())) + if (vobj->isMesh() && + (vobj->getVolume() && !vobj->getVolume()->isMeshAssetLoaded() || !gMeshRepo.meshRezEnabled())) { continue; } #endif //MESH_ENABLED llassert_always(vobj); - vobj->updateTextureVirtualSize(); + vobj->updateTextureVirtualSize(true); vobj->preRebuild(); drawablep->clearState(LLDrawable::HAS_ALPHA); @@ -3401,15 +3733,24 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) U32 bump_mask = LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR; U32 fullbright_mask = LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR; - if (LLPipeline::sRenderDeferred) + bool batch_textures = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 1; + + if (batch_textures) { bump_mask |= LLVertexBuffer::MAP_BINORMAL; + genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, simple_faces, FALSE, TRUE); + genDrawInfo(group, fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, fullbright_faces, FALSE, TRUE); + genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, bump_faces, FALSE, TRUE); + genDrawInfo(group, alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, alpha_faces, TRUE, TRUE); } - - genDrawInfo(group, simple_mask, simple_faces); - genDrawInfo(group, fullbright_mask, fullbright_faces); - genDrawInfo(group, bump_mask, bump_faces, FALSE); - genDrawInfo(group, alpha_mask, alpha_faces, TRUE); + else + { + genDrawInfo(group, simple_mask, simple_faces); + genDrawInfo(group, fullbright_mask, fullbright_faces); + genDrawInfo(group, bump_mask, bump_faces, FALSE, TRUE); + genDrawInfo(group, alpha_mask, alpha_faces, TRUE); + } + if (!LLPipeline::sDelayVBUpdate) { @@ -3443,14 +3784,16 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) group->mBuilt = 1.f; + std::set mapped_buffers; + for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter) { LLDrawable* drawablep = *drawable_iter; - if (drawablep->isState(LLDrawable::FORCE_INVISIBLE) ) + /*if (drawablep->isState(LLDrawable::FORCE_INVISIBLE) ) { continue; - } + }*/ if (!drawablep->isDead() && drawablep->isState(LLDrawable::REBUILD_ALL) ) { @@ -3461,33 +3804,29 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) for (S32 i = 0; i < drawablep->getNumFaces(); ++i) { LLFace* face = drawablep->getFace(i); - if (face && face->getVertexBuffer()) + if (face) { - face->getGeometryVolume(*volume, face->getTEOffset(), - vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), face->getGeomIndex()); + LLVertexBuffer* buff = face->getVertexBuffer(); + if (buff) + { + face->getGeometryVolume(*volume, face->getTEOffset(), + vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), face->getGeomIndex()); + + if (buff->isLocked()) + { + mapped_buffers.insert(buff); + } + } } } - + drawablep->clearState(LLDrawable::REBUILD_ALL); } } - //unmap all the buffers - for (LLSpatialGroup::buffer_map_t::iterator i = group->mBufferMap.begin(); i != group->mBufferMap.end(); ++i) + for (std::set::iterator iter = mapped_buffers.begin(); iter != mapped_buffers.end(); ++iter) { - LLSpatialGroup::buffer_texture_map_t& map = i->second; - for (LLSpatialGroup::buffer_texture_map_t::iterator j = map.begin(); j != map.end(); ++j) - { - LLSpatialGroup::buffer_list_t& list = j->second; - for (LLSpatialGroup::buffer_list_t::iterator k = list.begin(); k != list.end(); ++k) - { - LLVertexBuffer* buffer = *k; - if (buffer->isLocked()) - { - buffer->setBuffer(0); - } - } - } + (*iter)->setBuffer(0); } // don't forget alpha @@ -3553,7 +3892,8 @@ struct CompareBatchBreakerModified } }; -void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector& faces, BOOL distance_sort) + +void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector& faces, BOOL distance_sort, BOOL batch_textures) { //calculate maximum number of vertices to store in a single buffer static const LLCachedControl render_max_vbo_size("RenderMaxVBOSize", 512); @@ -3571,6 +3911,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: std::sort(faces.begin(), faces.end(), LLFace::CompareDistanceGreater()); } + bool hud_group = group->isHUDGroup() ; std::vector::iterator face_iter = faces.begin(); LLSpatialGroup::buffer_map_t buffer_map; @@ -3583,6 +3924,21 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: buffer_index = -1; } + S32 texture_index_channels = gGLManager.mNumTextureImageUnits-1; //always reserve one for shiny for now just for simplicity + + static const LLCachedControl no_texture_indexing("ShyotlUseLegacyTextureBatching",false); + if (gGLManager.mGLVersion < 3.1f || no_texture_indexing) + { + texture_index_channels = 1; + } + + if (LLPipeline::sRenderDeferred && distance_sort) + { + texture_index_channels = gDeferredAlphaProgram.mFeatures.mIndexedTextureChannels; + } + + texture_index_channels = llmin(texture_index_channels, (S32) gSavedSettings.getU32("RenderMaxTextureIndex")); + while (face_iter != faces.end()) { //pull off next face @@ -3611,19 +3967,96 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: std::vector::iterator i = face_iter; ++i; - while (i != faces.end() && - (LLPipeline::sTextureBindTest || (distance_sort || (*i)->getTexture() == tex))) + std::vector texture_list; + + if (batch_textures) { - facep = *i; - - if (geom_count + facep->getGeomCount() > max_vertices) - { //cut vertex buffers on geom count too big - break; + U8 cur_tex = 0; + facep->setTextureIndex(cur_tex); + texture_list.push_back(tex); + + //if (can_batch_texture(facep)) + { + while (i != faces.end()) + { + facep = *i; + if (facep->getTexture() != tex) + { + if (distance_sort) + { //textures might be out of order, see if texture exists in current batch + bool found = false; + for (U32 tex_idx = 0; tex_idx < texture_list.size(); ++tex_idx) + { + if (facep->getTexture() == texture_list[tex_idx]) + { + cur_tex = tex_idx; + found = true; + break; + } + } + + if (!found) + { + cur_tex = texture_list.size(); + } + } + else + { + cur_tex++; + } + + if (!can_batch_texture(facep)) + { //face is bump mapped or has an animated texture matrix -- can't + //batch more than 1 texture at a time + break; + } + + if (cur_tex >= texture_index_channels) + { //cut batches when index channels are depleted + break; + } + + tex = facep->getTexture(); + + texture_list.push_back(tex); + } + + if (geom_count + facep->getGeomCount() > max_vertices) + { //cut batches on geom count too big + break; + } + + ++i; + index_count += facep->getIndicesCount(); + geom_count += facep->getGeomCount(); + + facep->setTextureIndex(cur_tex); + } } - ++i; - index_count += facep->getIndicesCount(); - geom_count += facep->getGeomCount(); + tex = texture_list[0]; + } + else + { + while (i != faces.end() && + (LLPipeline::sTextureBindTest || (distance_sort || (*i)->getTexture() == tex))) + { + facep = *i; + + + //face has no texture index + facep->mDrawInfo = NULL; + facep->setTextureIndex(255); + + if (geom_count + facep->getGeomCount() > max_vertices) + { //cut batches on geom count too big + break; + } + + ++i; + index_count += facep->getIndicesCount(); + geom_count += facep->getGeomCount(); + } } //create/delete/resize vertex buffer if needed @@ -3673,8 +4106,15 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: facep->setGeomIndex(index_offset); facep->setVertexBuffer(buffer); + if (batch_textures && facep->getTextureIndex() == 255) { + llerrs << "Invalid texture index." << llendl; + } + + { + //for debugging, set last time face was updated vs moved facep->updateRebuildFlags(); + if (!LLPipeline::sDelayVBUpdate) { //copy face geometry into vertex buffer LLDrawable* drawablep = facep->getDrawable(); @@ -3702,6 +4142,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: } const LLTextureEntry* te = facep->getTextureEntry(); + tex = facep->getTexture(); BOOL is_alpha = (facep->getPoolType() == LLDrawPool::POOL_ALPHA) ? TRUE : FALSE; @@ -3741,7 +4182,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: registerFace(group, facep, LLRenderPass::PASS_INVISI_SHINY); registerFace(group, facep, LLRenderPass::PASS_INVISIBLE); } - else if (LLPipeline::sRenderDeferred) + else if (LLPipeline::sRenderDeferred && !hud_group) { //deferred rendering if (te->getFullbright()) { //register in post deferred fullbright shiny pass @@ -3779,7 +4220,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: else if (fullbright) { //fullbright registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT); - if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && te->getBumpmap()) + if (LLPipeline::sRenderDeferred && !hud_group && LLPipeline::sRenderBump && te->getBumpmap()) { //if this is the deferred render and a bump map is present, register in post deferred bump registerFace(group, facep, LLRenderPass::PASS_POST_BUMP); } @@ -3805,7 +4246,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: } //not sure why this is here, and looks like it might cause bump mapped objects to get rendered redundantly -- davep 5/11/2010 - if (!is_alpha && !LLPipeline::sRenderDeferred) + if (!is_alpha && (hud_group || !LLPipeline::sRenderDeferred)) { llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright); facep->setPoolType((fullbright) ? LLDrawPool::POOL_FULLBRIGHT : LLDrawPool::POOL_SIMPLE); diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 0e91880dc..ec97df042 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -90,6 +90,7 @@ public: // Class which embodies all Volume objects (with pcode LL_PCODE_VOLUME) class LLVOVolume : public LLViewerObject { + LOG_CLASS(LLVOVolume); protected: virtual ~LLVOVolume(); @@ -131,11 +132,12 @@ public: const LLMatrix4& getRelativeXform() const { return mRelativeXform; } const LLMatrix3& getRelativeXformInvTrans() const { return mRelativeXformInvTrans; } /*virtual*/ const LLMatrix4 getRenderMatrix() const; - + typedef std::map texture_cost_t; + U32 getRenderCost(texture_cost_t &textures) const; #if MESH_ENABLED - /*virtual*/ F32 getStreamingCost(S32* bytes = NULL, S32* visible_bytes = NULL); + /*virtual*/ F32 getStreamingCost(S32* bytes = NULL, S32* visible_bytes = NULL, F32* unscaled_value = NULL) const; #endif //MESH_ENABLED - /*virtual*/ U32 getTriangleCount(); + /*virtual*/ U32 getTriangleCount() const; /*virtual*/ U32 getHighLODTriangleCount(); /*virtual*/ BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face = -1, // which face to check, -1 = ALL_SIDES @@ -210,7 +212,7 @@ public: /*virtual*/ BOOL updateLOD(); void updateRadius(); /*virtual*/ void updateTextures(); - void updateTextureVirtualSize(); + void updateTextureVirtualSize(bool forced = false); void updateFaceFlags(); void regenFaces(); @@ -291,7 +293,13 @@ protected: LLFace* addFace(S32 face_index); void updateTEData(); + // stats tracking for render complexity + static S32 mRenderComplexity_last; + static S32 mRenderComplexity_current; public: + + static S32 getRenderComplexityMax() {return mRenderComplexity_last;} + static void updateRenderComplexity(); LLViewerTextureAnim *mTextureAnimp; U8 mTexAnimMode; private: diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp index 49120afa5..3eb24514b 100644 --- a/indra/newview/llvowater.cpp +++ b/indra/newview/llvowater.cpp @@ -286,6 +286,11 @@ void LLVOWater::updateSpatialExtents(LLVector4a &newMin, LLVector4a& newMax) U32 LLVOWater::getPartitionType() const { + if (mIsEdgePatch) + { + //return LLViewerRegion::PARTITION_VOIDWATER; + } + return LLViewerRegion::PARTITION_WATER; } @@ -304,6 +309,7 @@ LLWaterPartition::LLWaterPartition() LLVoidWaterPartition::LLVoidWaterPartition() { + //mOcclusionEnabled = FALSE; mDrawableType = LLPipeline::RENDER_TYPE_VOIDWATER; mPartitionType = LLViewerRegion::PARTITION_VOIDWATER; } diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index 92bc8b65f..fe0dbde4a 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -571,7 +571,7 @@ void LLVOWLSky::buildFanBuffer(LLStrider & vertices, LLStrider & texCoords, LLStrider & indices) { - const F32 RADIUS = LLWLParamManager::instance()->getDomeRadius(); + const F32 RADIUS = LLWLParamManager::getInstance()->getDomeRadius(); U32 i, num_slices; F32 phi0, theta, x0, y0, z0; @@ -632,7 +632,7 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, U32 end_stack, LLStrider & texCoords, LLStrider & indices) { - const F32 RADIUS = LLWLParamManager::instance()->getDomeRadius(); + const F32 RADIUS = LLWLParamManager::getInstance()->getDomeRadius(); U32 i, j, num_slices, num_stacks; F32 phi0, theta, x0, y0, z0; diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index bf8956960..c3c64e17c 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -66,8 +66,6 @@ #include "curl/curl.h" -LLWaterParamManager * LLWaterParamManager::sInstance = NULL; - LLWaterParamManager::LLWaterParamManager() : mFogColor(22.f/255.f, 43.f/255.f, 54.f/255.f, 0.0f, 0.0f, "waterFogColor", "WaterFogColor"), mFogDensity(4, "waterFogDensity", 2), @@ -226,15 +224,10 @@ void LLWaterParamManager::propagateParameters(void) // bind the variables only if we're using shaders if(gPipeline.canUseVertexShaders()) { - LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; - end_shaders = LLViewerShaderMgr::instance()->endShaders(); - for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) + std::vector::iterator shaders_iter=mShaderList.begin(); + for(; shaders_iter != mShaderList.end(); ++shaders_iter) { - if (shaders_iter->mProgramObject != 0 - && shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER) - { - shaders_iter->mUniformsDirty = TRUE; - } + (*shaders_iter)->mUniformsDirty = TRUE; } } @@ -250,7 +243,7 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader) { if (shader->mShaderGroup == LLGLSLShader::SG_WATER) { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLWLParamManager::instance()->getRotatedLightDir().mV); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLWLParamManager::getInstance()->getRotatedLightDir().mV); shader->uniform3fv("camPosLocal", 1, LLViewerCamera::getInstance()->getOrigin().mV); shader->uniform4fv("waterFogColor", 1, LLDrawPoolWater::sWaterFogColor.mV); shader->uniform4fv("waterPlane", 1, mWaterPlane.mV); @@ -260,6 +253,28 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader) } } +void LLWaterParamManager::updateShaderLinks() +{ + mShaderList.clear(); + LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; + end_shaders = LLViewerShaderMgr::instance()->endShaders(); + for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) + { + if (shaders_iter->mProgramObject != 0 + && shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER) + { + if( glGetUniformLocationARB(shaders_iter->mProgramObject,"lightnorm")>=0 || + glGetUniformLocationARB(shaders_iter->mProgramObject,"camPosLocal")>=0 || + glGetUniformLocationARB(shaders_iter->mProgramObject,"waterFogColor")>=0 || + glGetUniformLocationARB(shaders_iter->mProgramObject,"waterPlane")>=0 || + glGetUniformLocationARB(shaders_iter->mProgramObject,"waterFogDensity")>=0 || + glGetUniformLocationARB(shaders_iter->mProgramObject,"waterFogKS")>=0 || + glGetUniformLocationARB(shaders_iter->mProgramObject,"distance_multiplier")>=0) + mShaderList.push_back(&(*shaders_iter)); + } + } +} + void LLWaterParamManager::update(LLViewerCamera * cam) { LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); @@ -315,31 +330,14 @@ void LLWaterParamManager::update(LLViewerCamera * cam) sunMoonDir.normVec(); mWaterFogKS = 1.f/llmax(sunMoonDir.mV[2], WATER_FOG_LIGHT_CLAMP); - LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; - end_shaders = LLViewerShaderMgr::instance()->endShaders(); - for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) + std::vector::iterator shaders_iter=mShaderList.begin(); + for(; shaders_iter != mShaderList.end(); ++shaders_iter) { - if (shaders_iter->mProgramObject != 0 - && shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER) - { - shaders_iter->mUniformsDirty = TRUE; - } + (*shaders_iter)->mUniformsDirty = TRUE; } } } -// static -void LLWaterParamManager::initClass(void) -{ - instance(); -} - -// static -void LLWaterParamManager::cleanupClass(void) -{ - delete sInstance; - sInstance = NULL; -} bool LLWaterParamManager::addParamSet(const std::string& name, LLWaterParamSet& param) { @@ -445,16 +443,11 @@ F32 LLWaterParamManager::getFogDensity(void) } // static -LLWaterParamManager * LLWaterParamManager::instance() +void LLWaterParamManager::initSingleton() { - if(NULL == sInstance) - { - sInstance = new LLWaterParamManager(); + + loadAllPresets(LLStringUtil::null); - sInstance->loadAllPresets(LLStringUtil::null); - - sInstance->getParamSet("Default", sInstance->mCurParams); - } - - return sInstance; + getParamSet("Default", mCurParams); } + diff --git a/indra/newview/llwaterparammanager.h b/indra/newview/llwaterparammanager.h index babaf0076..c1042d06a 100644 --- a/indra/newview/llwaterparammanager.h +++ b/indra/newview/llwaterparammanager.h @@ -218,19 +218,14 @@ struct WaterExpFloatControl /// WindLight parameter manager class - what controls all the wind light shaders -class LLWaterParamManager +class LLWaterParamManager : public LLSingleton { + LOG_CLASS(LLWaterParamManager); public: - LLWaterParamManager(); - ~LLWaterParamManager(); - - /// load a preset file - void loadAllPresets(const std::string & fileName); - - /// load an individual preset into the sky - - void loadPreset(const std::string & name,bool propagate=true); + typedef std::map preset_map_t; + + void updateShaderLinks(); /// save the parameter presets to file void savePreset(const std::string & name); @@ -244,12 +239,6 @@ public: /// Update shader uniforms that have changed. void updateShaderUniforms(LLGLSLShader * shader); - /// Perform global initialization for this class. - static void initClass(void); - - // Cleanup of global data that's only inited once per class. - static void cleanupClass(); - /// add a param to the list bool addParamSet(const std::string& name, LLWaterParamSet& param); @@ -268,6 +257,9 @@ public: /// gets rid of a parameter and any references to it /// returns true if successful bool removeParamSet(const std::string& name, bool delete_from_disk); + /// @return all named water presets. + const preset_map_t& getPresets() const { return mParamList; } + /// set the normap map we want for water bool setNormalMapID(const LLUUID& img); @@ -311,17 +303,29 @@ public: WaterFloatControl mScaleBelow; WaterFloatControl mBlurMultiplier; - // list of all the parameters, listed by name - std::map mParamList; F32 mDensitySliderValue; + /// load an individual preset into the sky + void loadPreset(const std::string & name,bool propagate=true); private: + friend class LLSingleton; + /*virtual*/ void initSingleton(); + LLWaterParamManager(); + ~LLWaterParamManager(); + /// load a preset file + void loadAllPresets(const std::string & fileName); + + + LLVector4 mWaterPlane; F32 mWaterFogKS; + - // our parameter manager singleton instance - static LLWaterParamManager * sInstance; + // list of all the parameters, listed by name + std::map mParamList; + + std::vector mShaderList; }; inline void LLWaterParamManager::setDensitySliderValue(F32 val) diff --git a/indra/newview/llwaterparamset.cpp b/indra/newview/llwaterparamset.cpp index 3e97f9dbe..e7d59c162 100644 --- a/indra/newview/llwaterparamset.cpp +++ b/indra/newview/llwaterparamset.cpp @@ -230,3 +230,46 @@ F32 LLWaterParamSet::getFloat(const std::string& paramName, bool& error) return 0; } +// Added for interpolation effect in DEV-33645 +// Based on LLWLParamSet::mix, but written by Jacob without an intimate knowledge of how WindLight works. +// The function definition existed in the header but was never implemented. If you think there is something +// wrong with this, you're probably right. Ask Jacob, Q, or a member of the original WindLight team. +void LLWaterParamSet::mix(LLWaterParamSet& src, LLWaterParamSet& dest, F32 weight) +{ + // Setup + LLSD srcVal, destVal; // LLSD holders for get/set calls, reusable + + // Iterate through values + for(LLSD::map_iterator iter = mParamValues.beginMap(); iter != mParamValues.endMap(); ++iter) + { + // If param exists in both src and dest, set the holder variables, otherwise skip + if(src.mParamValues.has(iter->first) && dest.mParamValues.has(iter->first)) + { + srcVal = src.mParamValues[iter->first]; + destVal = dest.mParamValues[iter->first]; + } + else + { + continue; + } + + if(iter->second.isReal()) // If it's a real, interpolate directly + { + iter->second = srcVal.asReal() + ((destVal.asReal() - srcVal.asReal()) * weight); + } + else if(iter->second.isArray() && iter->second[0].isReal() // If it's an array of reals, loop through the reals and interpolate on those + && iter->second.size() == srcVal.size() && iter->second.size() == destVal.size()) + { + // Actually do interpolation: old value + (difference in values * factor) + for(int i=0; i < iter->second.size(); ++i) + { + // iter->second[i] = (1.f-weight)*(F32)srcVal[i].asReal() + weight*(F32)destVal[i].asReal(); // old way of doing it -- equivalent but one more operation + iter->second[i] = srcVal[i].asReal() + ((destVal[i].asReal() - srcVal[i].asReal()) * weight); + } + } + else // Else, skip + { + continue; + } + } +} diff --git a/indra/newview/llwaterparamset.h b/indra/newview/llwaterparamset.h index 9087843ec..9d51be652 100644 --- a/indra/newview/llwaterparamset.h +++ b/indra/newview/llwaterparamset.h @@ -40,7 +40,6 @@ #include "v4color.h" #include "llviewershadermgr.h" -class LLFloaterWater; class LLWaterParamSet; /// A class representing a set of parameter values for the Water shaders. diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp index 72deff26d..a8adbb527 100644 --- a/indra/newview/llwearable.cpp +++ b/indra/newview/llwearable.cpp @@ -41,6 +41,7 @@ #include "llagent.h" #include "llagentcamera.h" #include "llagentwearables.h" +#include "llnotificationsutil.h" #include "llassetuploadresponders.h" #include "llviewerwindow.h" #include "llfloatercustomize.h" @@ -1021,7 +1022,7 @@ void LLWearable::saveNewAsset() LLSD args; args["NAME"] = mName; - LLNotifications::instance().add("CannotSaveWearableOutOfSpace", args); + LLNotificationsUtil::add("CannotSaveWearableOutOfSpace", args); return; } @@ -1069,7 +1070,7 @@ void LLWearable::onSaveNewAssetComplete(const LLUUID& new_asset_id, void* userda llwarns << buffer << " Status: " << status << llendl; LLSD args; args["NAME"] = type_name; - LLNotifications::instance().add("CannotSaveToAssetStore", args); + LLNotificationsUtil::add("CannotSaveToAssetStore", args); } // Delete temp file diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp index 0ab91c58e..7b514cf04 100644 --- a/indra/newview/llwearablelist.cpp +++ b/indra/newview/llwearablelist.cpp @@ -41,7 +41,7 @@ #include "llviewerinventory.h" //#include "llfloaterchat.h" #include "llviewerstats.h" -#include "llnotify.h" +#include "llnotificationsutil.h" // Globals LLWearableList gWearableList; // Globally constructed; be careful that there's no dependency with gAgent. @@ -191,16 +191,16 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID args["TYPE"] = LLAssetType::lookupHumanReadable(data->mAssetType); if (isNewWearable) { - LLNotifications::instance().add("InvalidWearable"); + LLNotificationsUtil::add("InvalidWearable"); } else if (data->mName.empty()) { - LLNotifications::instance().add("FailedToFindWearableUnnamed", args); + LLNotificationsUtil::add("FailedToFindWearableUnnamed", args); } else { args["DESC"] = data->mName; - LLNotifications::instance().add("FailedToFindWearable", args); + LLNotificationsUtil::add("FailedToFindWearable", args); } } // Always call callback; wearable will be NULL if we failed diff --git a/indra/newview/llweb.cpp b/indra/newview/llweb.cpp index 82f02df3e..28bfe034a 100644 --- a/indra/newview/llweb.cpp +++ b/indra/newview/llweb.cpp @@ -36,6 +36,7 @@ #include "llweb.h" #include "llviewerwindow.h" +#include "llwindow.h" #include "llviewercontrol.h" #include "llfloatermediabrowser.h" @@ -64,7 +65,7 @@ void LLWeb::loadURL(const std::string& url) void LLWeb::loadURLExternal(const std::string& url) { std::string escaped_url = escapeURL(url); - gViewerWindow->getWindow()->spawnWebBrowser(escaped_url); + gViewerWindow->getWindow()->spawnWebBrowser(escaped_url,true); } diff --git a/indra/newview/llwlanimator.cpp b/indra/newview/llwlanimator.cpp index f7e40e49f..ed90c9d7c 100644 --- a/indra/newview/llwlanimator.cpp +++ b/indra/newview/llwlanimator.cpp @@ -49,7 +49,8 @@ void LLWLAnimator::update(LLWLParamSet& curParams) curTime = getDayTime(); // don't do anything if empty - if(mTimeTrack.size() == 0) { + if(mTimeTrack.size() == 0) + { return; } @@ -59,13 +60,15 @@ void LLWLAnimator::update(LLWLParamSet& curParams) mSecondIt++; // grab the two tween iterators - while(mSecondIt != mTimeTrack.end() && curTime > mSecondIt->first) { + while(mSecondIt != mTimeTrack.end() && curTime > mSecondIt->first) + { mFirstIt++; mSecondIt++; } // scroll it around when you get to the end - if(mSecondIt == mTimeTrack.end() || mFirstIt->first > curTime) { + if(mSecondIt == mTimeTrack.end() || mFirstIt->first > curTime) + { mSecondIt = mTimeTrack.begin(); mFirstIt = mTimeTrack.end(); mFirstIt--; @@ -73,56 +76,66 @@ void LLWLAnimator::update(LLWLParamSet& curParams) F32 weight = 0; - if(mFirstIt->first < mSecondIt->first) { + if(mFirstIt->first < mSecondIt->first) + { // get the delta time and the proper weight weight = F32 (curTime - mFirstIt->first) / (mSecondIt->first - mFirstIt->first); // handle the ends - } else if(mFirstIt->first > mSecondIt->first) { + } + else if(mFirstIt->first > mSecondIt->first) + { // right edge of time line - if(curTime >= mFirstIt->first) { + if(curTime >= mFirstIt->first) + { weight = F32 (curTime - mFirstIt->first) / ((1 + mSecondIt->first) - mFirstIt->first); - // left edge of time line - } else { + } + else + { weight = F32 ((1 + curTime) - mFirstIt->first) / ((1 + mSecondIt->first) - mFirstIt->first); } - // handle same as whatever the last one is - } else { + } + else + { weight = 1; } // do the interpolation and set the parameters - curParams.mix(LLWLParamManager::instance()->mParamList[mFirstIt->second], - LLWLParamManager::instance()->mParamList[mSecondIt->second], weight); + curParams.mix(LLWLParamManager::getInstance()->mParamList[mFirstIt->second], + LLWLParamManager::getInstance()->mParamList[mSecondIt->second], weight); } F64 LLWLAnimator::getDayTime() { - if(!mIsRunning) { + if(!mIsRunning) + { return mDayTime; } - if(mUseLindenTime) { - + if(mUseLindenTime) + { F32 phase = gSky.getSunPhase() / F_PI; // we're not solving the non-linear equation that determines sun phase // we're just linearly interpolating between the major points if (phase <= 5.0 / 4.0) { mDayTime = (1.0 / 3.0) * phase + (1.0 / 3.0); - } else { + } + else + { mDayTime = phase - (1.0 / 2.0); } - if(mDayTime > 1) { + if(mDayTime > 1) + { mDayTime--; } @@ -133,10 +146,12 @@ F64 LLWLAnimator::getDayTime() mDayTime = (LLTimer::getElapsedSeconds() - mStartTime) / mDayRate; // clamp it - if(mDayTime < 0) { + if(mDayTime < 0) + { mDayTime = 0; } - while(mDayTime > 1) { + while(mDayTime > 1) + { mDayTime--; } @@ -150,9 +165,12 @@ void LLWLAnimator::setDayTime(F64 dayTime) mDayTime = dayTime; // clamp it - if(mDayTime < 0) { + if(mDayTime < 0) + { mDayTime = 0; - } else if(mDayTime > 1) { + } + else if(mDayTime > 1) + { mDayTime = 1; } } diff --git a/indra/newview/llwldaycycle.cpp b/indra/newview/llwldaycycle.cpp index 577d1edc1..abb9cd03f 100644 --- a/indra/newview/llwldaycycle.cpp +++ b/indra/newview/llwldaycycle.cpp @@ -96,13 +96,13 @@ void LLWLDayCycle::loadDayCycle(const std::string & fileName) // check each param name exists in param manager bool success; LLWLParamSet pset; - success = LLWLParamManager::instance()->getParamSet(day_data[i][1].asString(), pset); + success = LLWLParamManager::getInstance()->getParamSet(day_data[i][1].asString(), pset); if(!success) { // alert the user LLSD args; args["SKY"] = day_data[i][1].asString(); - LLNotifications::instance().add("WLMissingSky", args); + LLNotifications::instance().add("WLMissingSky", args, LLSD()); continue; } @@ -203,7 +203,7 @@ bool LLWLDayCycle::changeKeyParam(F32 time, const std::string & name) // just remove and add back // make sure param exists LLWLParamSet tmp; - bool stat = LLWLParamManager::instance()->getParamSet(name, tmp); + bool stat = LLWLParamManager::getInstance()->getParamSet(name, tmp); if(stat == false) { return stat; @@ -249,7 +249,7 @@ bool LLWLDayCycle::getKeyedParam(F32 time, LLWLParamSet& param) std::map::iterator mIt = mTimeMap.find(time); if(mIt != mTimeMap.end()) { - return LLWLParamManager::instance()->getParamSet(mIt->second, param); + return LLWLParamManager::getInstance()->getParamSet(mIt->second, param); } // return error if not found diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index d3fc32835..35ee41de8 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -61,9 +61,10 @@ #include "llfloaterdaycycle.h" #include "llfloaterenvsettings.h" -#include "curl/curl.h" +#include "llviewershadermgr.h" +#include "llglslshader.h" -LLWLParamManager * LLWLParamManager::sInstance = NULL; +#include "curl/curl.h" LLWLParamManager::LLWLParamManager() : @@ -286,6 +287,25 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader) } +void LLWLParamManager::updateShaderLinks() +{ + mShaderList.clear(); + LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; + end_shaders = LLViewerShaderMgr::instance()->endShaders(); + for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) + { + if (shaders_iter->mProgramObject != 0 + && (gPipeline.canUseWindLightShaders() || shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER)) + { + if( glGetUniformLocationARB(shaders_iter->mProgramObject,"lightnorm")>=0 || + glGetUniformLocationARB(shaders_iter->mProgramObject,"camPosLocal")>=0 || + glGetUniformLocationARB(shaders_iter->mProgramObject,"scene_light_strength")>=0 || + glGetUniformLocationARB(shaders_iter->mProgramObject,"cloud_pos_density1")>=0) + mShaderList.push_back(&(*shaders_iter)); + } + } +} + void LLWLParamManager::propagateParameters(void) { LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); @@ -337,16 +357,10 @@ void LLWLParamManager::propagateParameters(void) mCurParams.set("lightnorm", mLightDir); // bind the variables for all shaders only if we're using WindLight - LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; - end_shaders = LLViewerShaderMgr::instance()->endShaders(); - for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) + std::vector::iterator shaders_iter=mShaderList.begin(); + for(; shaders_iter != mShaderList.end(); ++shaders_iter) { - if (shaders_iter->mProgramObject != 0 - && (gPipeline.canUseWindLightShaders() - || shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER)) - { - shaders_iter->mUniformsDirty = TRUE; - } + (*shaders_iter)->mUniformsDirty = TRUE; } // get the cfr version of the sun's direction @@ -400,32 +414,14 @@ void LLWLParamManager::update(LLViewerCamera * cam) lightNorm3 *= LLQuaternion(-(camYaw + camYawDelta), LLVector3(0.f, 1.f, 0.f)); mRotatedLightDir = LLVector4(lightNorm3, 0.f); - LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; - end_shaders = LLViewerShaderMgr::instance()->endShaders(); - for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) + std::vector::iterator shaders_iter=mShaderList.begin(); + for(; shaders_iter != mShaderList.end(); ++shaders_iter) { - if (shaders_iter->mProgramObject != 0 - && (gPipeline.canUseWindLightShaders() - || shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER)) - { - shaders_iter->mUniformsDirty = TRUE; - } + (*shaders_iter)->mUniformsDirty = TRUE; } } } -// static -void LLWLParamManager::initClass(void) -{ - instance(); -} - -// static -void LLWLParamManager::cleanupClass() -{ - delete sInstance; - sInstance = NULL; -} void LLWLParamManager::resetAnimator(F32 curTime, bool run) { @@ -537,27 +533,22 @@ bool LLWLParamManager::removeParamSet(const std::string& name, bool delete_from_ } -// static -LLWLParamManager * LLWLParamManager::instance() +// virtual static +void LLWLParamManager::initSingleton() { - if(NULL == sInstance) - { - sInstance = new LLWLParamManager(); - sInstance->loadPresets(LLStringUtil::null); + loadPresets(LLStringUtil::null); - // load the day - sInstance->mDay.loadDayCycle(gSavedSettings.getString("AscentActiveDayCycle")); + // load the day + mDay.loadDayCycle(gSavedSettings.getString("AscentActiveDayCycle")); - // *HACK - sets cloud scrolling to what we want... fix this better in the future - sInstance->getParamSet("Default", sInstance->mCurParams); + // *HACK - sets cloud scrolling to what we want... fix this better in the future + getParamSet("Default", mCurParams); - // set it to noon - sInstance->resetAnimator(0.5, true); + // set it to noon + resetAnimator(0.5, true); - // but use linden time sets it to what the estate is - sInstance->mAnimator.mUseLindenTime = true; - } + // but use linden time sets it to what the estate is + mAnimator.mUseLindenTime = true; - return sInstance; } diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h index a117dc1b0..e89f1ee22 100644 --- a/indra/newview/llwlparammanager.h +++ b/indra/newview/llwlparammanager.h @@ -122,15 +122,14 @@ struct WLFloatControl { }; /// WindLight parameter manager class - what controls all the wind light shaders -class LLWLParamManager +class LLWLParamManager : public LLSingleton { + LOG_CLASS(LLWLParamManager); + public: - LLWLParamManager(); - ~LLWLParamManager(); + void updateShaderLinks(); - /// load a preset file - void loadPresets(const std::string & fileName); /// save the preset file void savePresets(const std::string & fileName); @@ -193,8 +192,8 @@ public: /// returns true if successful bool removeParamSet(const std::string& name, bool delete_from_disk); - // singleton pattern implementation - static LLWLParamManager * instance(); + /// @return all named windlight presets. + const std::map& getPresets() const { return mParamList; } public: @@ -249,13 +248,22 @@ public: F32 mDomeOffset; F32 mDomeRadius; - // list of all the parameters, listed by name - std::map mParamList; private: - // our parameter manager singleton instance - static LLWLParamManager * sInstance; + /// load a preset file + friend class LLWLAnimator; + void loadPresets(const std::string & fileName); + + friend class LLSingleton; + /*virtual*/ void initSingleton(); + LLWLParamManager(); + ~LLWLParamManager(); + + // list of all the parameters, listed by name + std::map mParamList; + + std::vector mShaderList; }; diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp index ea9c00ae8..4f62db627 100644 --- a/indra/newview/llwlparamset.cpp +++ b/indra/newview/llwlparamset.cpp @@ -266,7 +266,6 @@ void LLWLParamSet::setEastAngle(float val) void LLWLParamSet::mix(LLWLParamSet& src, LLWLParamSet& dest, F32 weight) { // set up the iterators - LLSD::map_iterator cIt = mParamValues.beginMap(); // keep cloud positions and coverage the same /// TODO masking will do this later @@ -279,55 +278,39 @@ void LLWLParamSet::mix(LLWLParamSet& src, LLWLParamSet& dest, F32 weight) LLSD srcVal; LLSD destVal; - // do the interpolation for all the ones saved as vectors - // skip the weird ones - for(; cIt != mParamValues.endMap(); cIt++) { + // Iterate through values + for(LLSD::map_iterator iter = mParamValues.beginMap(); iter != mParamValues.endMap(); ++iter) + { - // check params to make sure they're actually there - if(src.mParamValues.has(cIt->first)) + // If param exists in both src and dest, set the holder variables, otherwise skip + if(src.mParamValues.has(iter->first) && dest.mParamValues.has(iter->first)) { - srcVal = src.mParamValues[cIt->first]; + srcVal = src.mParamValues[iter->first]; + destVal = dest.mParamValues[iter->first]; } else { continue; } - if(dest.mParamValues.has(cIt->first)) + if(iter->second.isReal()) // If it's a real, interpolate directly { - destVal = dest.mParamValues[cIt->first]; + iter->second = srcVal.asReal() + ((destVal.asReal() - srcVal.asReal()) * weight); } - else + else if(iter->second.isArray() && iter->second[0].isReal() // If it's an array of reals, loop through the reals and interpolate on those + && iter->second.size() == srcVal.size() && iter->second.size() == destVal.size()) + { + // Actually do interpolation: old value + (difference in values * factor) + for(int i=0; i < iter->second.size(); ++i) + { + // iter->second[i] = (1.f-weight)*(F32)srcVal[i].asReal() + weight*(F32)destVal[i].asReal(); // old way of doing it -- equivalent but one more operation + iter->second[i] = srcVal[i].asReal() + ((destVal[i].asReal() - srcVal[i].asReal()) * weight); + } + } + else // Else, skip { continue; } - - // skip if not a vector - if(!cIt->second.isArray()) - { - continue; - } - - // only Real vectors allowed - if(!cIt->second[0].isReal()) - { - continue; - } - - // make sure all the same size - if( cIt->second.size() != srcVal.size() || - cIt->second.size() != destVal.size()) - { - continue; - } - - // more error checking might be necessary; - - for(int i=0; i < cIt->second.size(); ++i) - { - cIt->second[i] = (1.0f - weight) * (F32) srcVal[i].asReal() + - weight * (F32) destVal[i].asReal(); - } } // now mix the extra parameters diff --git a/indra/newview/llwlparamset.h b/indra/newview/llwlparamset.h index 21d646f3b..f403fbe23 100644 --- a/indra/newview/llwlparamset.h +++ b/indra/newview/llwlparamset.h @@ -38,10 +38,9 @@ #include "v4math.h" #include "v4color.h" -#include "llviewershadermgr.h" -class LLFloaterWindLight; class LLWLParamSet; +class LLGLSLShader; /// A class representing a set of parameter values for the WindLight shaders. class LLWLParamSet { diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 1b3e040b3..38317f5e0 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -46,6 +46,7 @@ #include "llregionhandle.h" #include "llsurface.h" #include "llviewercamera.h" +#include "llviewertexture.h" #include "llviewertexturelist.h" #include "llviewernetwork.h" #include "llviewerobjectlist.h" @@ -171,7 +172,7 @@ LLViewerRegion* LLWorld::addRegion(const U64 ®ion_handle, const LLHost &host, U32 iindex = 0; U32 jindex = 0; - mWidth = region_size_x; + mWidth = region_size_x; mWidthInMeters = mWidth * mScale; from_region_handle(region_handle, &iindex, &jindex); S32 x = (S32)(iindex/256); @@ -441,9 +442,9 @@ BOOL LLWorld::positionRegionValidGlobal(const LLVector3d &pos_global) // Allow objects to go up to their radius underground. -F32 LLWorld::getMinAllowedZ(LLViewerObject* object) +F32 LLWorld::getMinAllowedZ(LLViewerObject* object, const LLVector3d &global_pos) { - F32 land_height = resolveLandHeightGlobal(object->getPositionGlobal()); + F32 land_height = resolveLandHeightGlobal(global_pos); F32 radius = 0.5f * object->getScale().length(); return land_height - radius; } @@ -1255,16 +1256,16 @@ void process_enable_simulator(LLMessageSystem *msg, void **user_data) // which simulator should we modify? LLHost sim(ip_u32, port); - U32 region_size_x = 256; - msg->getU32Fast(_PREHASH_SimulatorInfo, _PREHASH_RegionSizeX, region_size_x); - - U32 region_size_y = 256; - msg->getU32Fast(_PREHASH_SimulatorInfo, _PREHASH_RegionSizeY, region_size_y); - - if (region_size_y == 0 || region_size_x == 0) - { - region_size_x = 256; - region_size_y = 256; + U32 region_size_x = 256; + msg->getU32Fast(_PREHASH_SimulatorInfo, _PREHASH_RegionSizeX, region_size_x); + + U32 region_size_y = 256; + msg->getU32Fast(_PREHASH_SimulatorInfo, _PREHASH_RegionSizeY, region_size_y); + + if (region_size_y == 0 || region_size_x == 0) + { + region_size_x = 256; + region_size_y = 256; } // Viewer trusts the simulator. @@ -1425,6 +1426,8 @@ static LLVector3d unpackLocalToGlobalPosition(U32 compact_local, const LLVector3 void LLWorld::getAvatars(std::vector* avatar_ids, std::vector* positions, const LLVector3d& relative_to, F32 radius) const { + F32 radius_squared = radius * radius; + if(avatar_ids != NULL) { avatar_ids->clear(); @@ -1433,6 +1436,33 @@ void LLWorld::getAvatars(std::vector* avatar_ids, std::vectorclear(); } + // get the list of avatars from the character list first, so distances are correct + // when agent is above 1020m and other avatars are nearby + for (std::vector::iterator iter = LLCharacter::sInstances.begin(); + iter != LLCharacter::sInstances.end(); ++iter) + { + LLVOAvatar* pVOAvatar = (LLVOAvatar*) *iter; + if(!pVOAvatar->isDead() && !pVOAvatar->isSelf()) + { + LLUUID uuid = pVOAvatar->getID(); + if(!uuid.isNull()) + { + LLVector3d pos_global = pVOAvatar->getPositionGlobal(); + if(dist_vec_squared(pos_global, relative_to) <= radius_squared) + { + if(positions != NULL) + { + positions->push_back(pos_global); + } + if(avatar_ids !=NULL) + { + avatar_ids->push_back(uuid); + } + } + } + } + } + // region avatars added for situations where radius is greater than RenderFarClip for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { @@ -1442,50 +1472,16 @@ void LLWorld::getAvatars(std::vector* avatar_ids, std::vectormMapAvatars.get(i), origin_global); - if(dist_vec(pos_global, relative_to) <= radius) + if(dist_vec_squared(pos_global, relative_to) <= radius_squared) { - if(positions != NULL) - { - positions->push_back(pos_global); - } - if(avatar_ids != NULL) - { - avatar_ids->push_back(regionp->mMapAvatarIDs.get(i)); - } - } - } - } - // retrieve the list of close avatars from viewer objects as well - // for when we are above 1000m, only do this when we are retrieving - // uuid's too as there could be duplicates - if(avatar_ids != NULL) - { - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) - { - LLVOAvatar* pVOAvatar = (LLVOAvatar*) *iter; - if(pVOAvatar->isDead() || pVOAvatar->isSelf()) - continue; - LLUUID uuid = pVOAvatar->getID(); - if(uuid.isNull()) - continue; - LLVector3d pos_global = pVOAvatar->getPositionGlobal(); - if(dist_vec(pos_global, relative_to) <= radius) - { - bool found = false; - uuid_vec_t::iterator sel_iter = avatar_ids->begin(); - for (; sel_iter != avatar_ids->end(); sel_iter++) - { - if(*sel_iter == uuid) - { - found = true; - break; - } - } - if(!found) + LLUUID uuid = regionp->mMapAvatarIDs.get(i); + // if this avatar doesn't already exist in the list, add it + if(uuid.notNull() && avatar_ids!=NULL && std::find(avatar_ids->begin(), avatar_ids->end(), uuid) == avatar_ids->end()) { if(positions != NULL) + { positions->push_back(pos_global); + } avatar_ids->push_back(uuid); } } diff --git a/indra/newview/llworld.h b/indra/newview/llworld.h index b3bd661cf..d079582d1 100644 --- a/indra/newview/llworld.h +++ b/indra/newview/llworld.h @@ -95,7 +95,7 @@ public: // Return the lowest allowed Z point to prevent objects from being moved // underground. - F32 getMinAllowedZ(LLViewerObject* object); + F32 getMinAllowedZ(LLViewerObject* object, const LLVector3d &global_pos); // takes a line segment defined by point_a and point_b, then // determines the closest (to point_a) point of intersection that is diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index e8376c57e..7ed337b59 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -52,6 +52,7 @@ #include "llui.h" #include "llglheaders.h" #include "llrender.h" +#include "llwindow.h" // newview includes #include "llagent.h" @@ -85,6 +86,7 @@ #include "llviewerobjectlist.h" #include "llviewerparcelmgr.h" #include "llviewerregion.h" // for audio debugging. +#include "llviewerstats.h" #include "llviewerwindow.h" // For getSpinAxis #include "llvoavatar.h" #include "llvoground.h" @@ -160,8 +162,6 @@ static S32 sDelayedVBOEnable = 0; BOOL gAvatarBacklight = FALSE; -BOOL gRenderForSelect = FALSE; - BOOL gDebugPipeline = FALSE; LLPipeline gPipeline; const LLMatrix4* gGLLastMatrix = NULL; @@ -314,10 +314,12 @@ static const U32 gl_cube_face[] = void validate_framebuffer_object(); -void addDeferredAttachments(LLRenderTarget& target) +bool addDeferredAttachments(LLRenderTarget& target) { - target.addColorAttachment(GL_RGBA); //specular - target.addColorAttachment(GL_RGBA); //normal+z + bool ret1 = target.addColorAttachment(GL_RGBA); + bool ret2 = target.addColorAttachment(GL_RGBA); + return ret1 && //specular + ret2; //normal+z } LLPipeline::LLPipeline() : @@ -391,7 +393,7 @@ void LLPipeline::init() getPool(LLDrawPool::POOL_BUMP); getPool(LLDrawPool::POOL_GLOW); - mTrianglesDrawnStat.reset(); + LLViewerStats::getInstance()->mTrianglesDrawnStat.reset(); resetFrameStats(); for (U32 i = 0; i < NUM_RENDER_TYPES; ++i) @@ -531,8 +533,8 @@ void LLPipeline::resizeScreenTexture() { if (gPipeline.canUseVertexShaders() && assertInitialized()) { - GLuint resX = gViewerWindow->getWindowDisplayWidth(); - GLuint resY = gViewerWindow->getWindowDisplayHeight(); + GLuint resX = gViewerWindow->getWorldViewWidthRaw(); + GLuint resY = gViewerWindow->getWorldViewHeightRaw(); allocateScreenBuffer(resX,resY); } @@ -541,6 +543,49 @@ void LLPipeline::resizeScreenTexture() void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) { U32 samples = gSavedSettings.getU32("RenderFSAASamples"); + + //try to allocate screen buffers at requested resolution and samples + // - on failure, shrink number of samples and try again + // - if not multisampled, shrink resolution and try again (favor X resolution over Y) + // Make sure to call "releaseScreenBuffers" after each failure to cleanup the partially loaded state + + if (!allocateScreenBuffer(resX, resY, samples)) + { + releaseScreenBuffers(); + //reduce number of samples + while (samples > 0) + { + samples /= 2; + if (allocateScreenBuffer(resX, resY, samples)) + { //success + return; + } + releaseScreenBuffers(); + } + + //reduce resolution + while (resY > 0 && resX > 0) + { + resY /= 2; + if (allocateScreenBuffer(resX, resY, samples)) + { + return; + } + releaseScreenBuffers(); + + resX /= 2; + if (allocateScreenBuffer(resX, resY, samples)) + { + return; + } + releaseScreenBuffers(); + } + + llwarns << "Unable to allocate screen buffer at any resolution!" << llendl; + } +} +bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) +{ U32 res_mod = gSavedSettings.getU32("RenderResolutionDivisor"); if (res_mod > 1 && res_mod < resX && res_mod < resY) { @@ -558,22 +603,22 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) //allocate deferred rendering color buffers static const LLCachedControl shadow_precision("DeferredHighPrecision",true); const GLuint format = shadow_precision ? GL_RGBA : GL_RGBA16F_ARB; //TO-DO: Profile 16bit format later - mDeferredScreen.allocate(resX, resY, format, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE); - mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); - addDeferredAttachments(mDeferredScreen); + if (!mDeferredScreen.allocate(resX, resY, format, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; + if (!mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; + if (!addDeferredAttachments(mDeferredScreen)) return false; - mScreen.allocate(resX, resY, format, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); + if (!mScreen.allocate(resX, resY, format, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; #if LL_DARWIN // As of OS X 10.6.7, Apple doesn't support multiple color formats in a single FBO - mEdgeMap.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); + if (!mEdgeMap.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; #else - mEdgeMap.allocate(resX, resY, GL_ALPHA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); + if (!mEdgeMap.allocate(resX, resY, GL_ALPHA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; #endif if (shadow_detail > 0 || ssao) { //only need mDeferredLight[0] for shadows OR ssao - mDeferredLight[0].allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE); + if (!mDeferredLight[0].allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false; } else { @@ -582,7 +627,7 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) if (ssao || gi) { //only need mDeferredLight[1] for ssao... and GI - mDeferredLight[1].allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE); + if (!mDeferredLight[1].allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false; } else { @@ -591,14 +636,14 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) if (gi) { //only need mDeferredLight[2] and mGIMapPost for gi - mDeferredLight[2].allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE); + if (!mDeferredLight[2].allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false; for (U32 i = 0; i < 2; i++) { #if LL_DARWIN // As of OS X 10.6.7, Apple doesn't support multiple color formats in a single FBO - mGIMapPost[i].allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE); + if (!mGIMapPost[i].allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false; #else - mGIMapPost[i].allocate(resX,resY, GL_RGB, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE); + if (!mGIMapPost[i].allocate(resX,resY, GL_RGB, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false; #endif } } @@ -626,7 +671,7 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) { //allocate 4 sun shadow maps for (U32 i = 0; i < 4; i++) { - mShadow[i].allocate(U32(resX*scale),U32(resY*scale), shadow_fmt, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE); + if (!mShadow[i].allocate(U32(resX*scale),U32(resY*scale), shadow_fmt, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false; } } else @@ -644,7 +689,7 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) { //allocate two spot shadow maps for (U32 i = 4; i < 6; i++) { - mShadow[i].allocate(width, height, shadow_fmt, TRUE, FALSE); + if (!mShadow[i].allocate(width, height, shadow_fmt, TRUE, FALSE)) return false; } } else @@ -657,7 +702,7 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) width = nhpo2(resX)/2; height = nhpo2(resY)/2; - mLuminanceMap.allocate(width,height, GL_RGBA, FALSE, FALSE); + if (!mLuminanceMap.allocate(width,height, GL_RGBA, FALSE, FALSE)) return false; } else { @@ -679,7 +724,7 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) mEdgeMap.release(); mLuminanceMap.release(); - mScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE); + if (!mScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; } @@ -689,14 +734,14 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) { static const LLCachedControl shadow_precision("DeferredHighPrecision",true); const GLuint format = shadow_precision ? GL_RGBA : GL_RGBA16F_ARB; //TO-DO: Profile 16bit format later - mSampleBuffer.allocate(resX,resY,format,TRUE,TRUE,LLTexUnit::TT_RECT_TEXTURE,FALSE,samples); - addDeferredAttachments(mSampleBuffer); + if (!mSampleBuffer.allocate(resX,resY,format,TRUE,TRUE,LLTexUnit::TT_RECT_TEXTURE,FALSE,samples)) return false; + if (!addDeferredAttachments(mSampleBuffer))return false; mDeferredScreen.setSampleBuffer(&mSampleBuffer); mEdgeMap.setSampleBuffer(&mSampleBuffer); } else { - mSampleBuffer.allocate(resX,resY,GL_RGBA,TRUE,TRUE,LLTexUnit::TT_RECT_TEXTURE,FALSE,samples); + if(!mSampleBuffer.allocate(resX,resY,GL_RGBA,TRUE,TRUE,LLTexUnit::TT_RECT_TEXTURE,FALSE,samples)) return false;; } mScreen.setSampleBuffer(&mSampleBuffer); @@ -711,19 +756,20 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) if (LLPipeline::sRenderDeferred) { //share depth buffer between deferred targets mDeferredScreen.shareDepthBuffer(mScreen); - for (U32 i = 0; i < 3; i++) + /*for (U32 i = 0; i < 3; i++) { //share stencil buffer with screen space lightmap to stencil out sky if (mDeferredLight[i].getTexture(0)) { mDeferredScreen.shareDepthBuffer(mDeferredLight[i]); } - } + }*/ } gGL.getTexUnit(0)->disable(); stop_glerror(); + return true; } //static @@ -766,6 +812,19 @@ void LLPipeline::releaseGLBuffers() mWaterRef.release(); mWaterDis.release(); + + for (U32 i = 0; i < 3; i++) + { + mGlow[i].release(); + } + + releaseScreenBuffers(); + + LLVOAvatar::resetImpostors(); +} + +void LLPipeline::releaseScreenBuffers() +{ mScreen.release(); mSampleBuffer.release(); mDeferredScreen.release(); @@ -785,13 +844,6 @@ void LLPipeline::releaseGLBuffers() { mShadow[i].release(); } - - for (U32 i = 0; i < 3; i++) - { - mGlow[i].release(); - } - - LLVOAvatar::resetImpostors(); } void LLPipeline::createGLBuffers() @@ -811,9 +863,9 @@ void LLPipeline::createGLBuffers() stop_glerror(); - GLuint resX = gViewerWindow->getWindowDisplayWidth(); - GLuint resY = gViewerWindow->getWindowDisplayHeight(); - + GLuint resX = gViewerWindow->getWorldViewWidthRaw(); + GLuint resY = gViewerWindow->getWorldViewHeightRaw(); + if (LLPipeline::sRenderGlow) { //screen space glow buffers const U32 glow_res = llmax(1, @@ -1393,7 +1445,7 @@ void LLPipeline::resetFrameStats() { assertInitialized(); - mTrianglesDrawnStat.addValue(mTrianglesDrawn/1000.f); + LLViewerStats::getInstance()->mTrianglesDrawnStat.addValue(mTrianglesDrawn/1000.f); if (mBatchCount > 0) { @@ -1916,6 +1968,14 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl LLGLDepthTest depth(GL_TRUE, GL_FALSE); + bool bound_shader = false; + if (gPipeline.canUseVertexShaders() && LLGLSLShader::sCurBoundShader == 0) + { //if no shader is currently bound, use the occlusion shader instead of fixed function if we can + // (shadow render uses a special shader that clamps to clip planes) + bound_shader = true; + gOcclusionProgram.bind(); + } + for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { @@ -1943,12 +2003,16 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl } } + if (bound_shader) + { + gOcclusionProgram.unbind(); + } + camera.disableUserClipPlane(); - // Render non-windlight sky. - if (hasRenderType(LLPipeline::RENDER_TYPE_SKY) && - gSky.mVOSkyp.notNull() && - gSky.mVOSkyp->mDrawable.notNull()) + if (hasRenderType(LLPipeline::RENDER_TYPE_SKY) && + gSky.mVOSkyp.notNull() && + gSky.mVOSkyp->mDrawable.notNull()) { gSky.mVOSkyp->mDrawable->setVisible(camera); sCull->pushDrawable(gSky.mVOSkyp->mDrawable); @@ -2071,7 +2135,21 @@ void LLPipeline::doOcclusion(LLCamera& camera) LLGLDepthTest depth(GL_TRUE, GL_FALSE); LLGLDisable cull(GL_CULL_FACE); + + bool bind_shader = LLGLSLShader::sNoFixedFunction && LLGLSLShader::sCurBoundShader == 0; + if (bind_shader) + { + if (LLPipeline::sShadowRender) + { + gDeferredShadowProgram.bind(); + } + else + { + gOcclusionProgram.bind(); + } + } + for (LLCullResult::sg_list_t::iterator iter = sCull->beginOcclusionGroups(); iter != sCull->endOcclusionGroups(); ++iter) { LLSpatialGroup* group = *iter; @@ -2079,6 +2157,18 @@ void LLPipeline::doOcclusion(LLCamera& camera) group->clearOcclusionState(LLSpatialGroup::ACTIVE_OCCLUSION); } + if (bind_shader) + { + if (LLPipeline::sShadowRender) + { + gDeferredShadowProgram.unbind(); + } + else + { + gOcclusionProgram.unbind(); + } + } + gGL.setColorMask(true, false); } } @@ -3205,6 +3295,13 @@ void render_hud_elements() glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); gGL.color4f(1,1,1,1); + + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } + LLGLDepthTest depth(GL_TRUE, GL_FALSE); + if (!LLPipeline::sReflectionRender && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) { static const LLCachedControl fsaa_samples("RenderFSAASamples",0); @@ -3231,6 +3328,10 @@ void render_hud_elements() { LLHUDText::renderAllHUD(); } + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.unbind(); + } gGL.flush(); } @@ -3356,14 +3457,6 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) LLAppViewer::instance()->pingMainloopTimeout("Pipeline:ForceVBO"); - //by bao - //fake vertex buffer updating - //to guaranttee at least updating one VBO buffer every frame - //to walk around the bug caused by ATI card --> DEV-3855 - // - //if(forceVBOUpdate) - // gSky.mVOSkyp->updateDummyVertexBuffer() ; - gFrameStats.start(LLFrameStats::RENDER_GEOM); // Initialize lots of GL state to "safe" values @@ -3409,12 +3502,6 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) } } - if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PICKING)) - { - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderForSelect"); - gObjectList.renderObjectsForSelect(camera, gViewerWindow->getVirtualWindowRect()); - } - else { LLFastTimer t(LLFastTimer::FTM_POOLS); @@ -3445,6 +3532,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) occlude = FALSE; gGLLastMatrix = NULL; glLoadMatrixd(gGLModelView); + LLGLSLShader::bindNoShader(); doOcclusion(camera); } @@ -3477,8 +3565,8 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) check_stack_depth(stack_depth); std::string msg = llformat("%s pass %d", gPoolNames[cur_type].c_str(), i); LLGLState::checkStates(msg); - LLGLState::checkTextureChannels(msg); - LLGLState::checkClientArrays(msg); + //LLGLState::checkTextureChannels(msg); + //LLGLState::checkClientArrays(msg); } } } @@ -3510,77 +3598,81 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) occlude = FALSE; gGLLastMatrix = NULL; glLoadMatrixd(gGLModelView); + LLGLSLShader::bindNoShader(); doOcclusion(camera); } } LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); + //LLGLState::checkTextureChannels(); + //LLGLState::checkClientArrays(); - stop_glerror(); + //stop_glerror(); - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); - - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderHighlights"); - - if (!sReflectionRender) + //LLGLState::checkStates(); + //LLGLState::checkTextureChannels(); + //LLGLState::checkClientArrays(); + if (!LLPipeline::sImpostorRender) { - renderHighlights(); - } - - // Contains a list of the faces of objects that are physical or - // have touch-handlers. - mHighlightFaces.clear(); - - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderDebug"); - renderDebug(); + LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderHighlights"); - LLVertexBuffer::unbind(); - - if (!LLPipeline::sReflectionRender && !LLPipeline::sRenderDeferred) - { - if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) + if (!sReflectionRender) { - // Render debugging beacons. - gObjectList.renderObjectBeacons(); - gObjectList.resetObjectBeacons(); + renderHighlights(); + } + + // Contains a list of the faces of objects that are physical or + // have touch-handlers. + mHighlightFaces.clear(); + + LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderDebug"); + + renderDebug(); + + LLVertexBuffer::unbind(); + + if (!LLPipeline::sReflectionRender && !LLPipeline::sRenderDeferred) + { + if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) + { + // Render debugging beacons. + gObjectList.renderObjectBeacons(); + gObjectList.resetObjectBeacons(); + } + else + { + // Make sure particle effects disappear + LLHUDObject::renderAllForTimer(); + } } else { // Make sure particle effects disappear LLHUDObject::renderAllForTimer(); } - } - else - { - // Make sure particle effects disappear - LLHUDObject::renderAllForTimer(); - } - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomEnd"); + LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomEnd"); - //HACK: preserve/restore matrices around HUD render - if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) - { - for (U32 i = 0; i < 16; i++) + //HACK: preserve/restore matrices around HUD render + if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) { - gGLModelView[i] = saved_modelview[i]; - gGLProjection[i] = saved_projection[i]; + for (U32 i = 0; i < 16; i++) + { + gGLModelView[i] = saved_modelview[i]; + gGLProjection[i] = saved_projection[i]; + } } } LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); + //LLGLState::checkTextureChannels(); + //LLGLState::checkClientArrays(); } void LLPipeline::renderGeomDeferred(LLCamera& camera) @@ -3662,8 +3754,8 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) llerrs << "GL matrix stack corrupted!" << llendl; } LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); + //LLGLState::checkTextureChannels(); + //LLGLState::checkClientArrays(); } } } @@ -3718,6 +3810,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) occlude = FALSE; gGLLastMatrix = NULL; glLoadMatrixd(gGLModelView); + LLGLSLShader::bindNoShader(); doOcclusion(camera); gGL.setColorMask(true, false); } @@ -3756,8 +3849,8 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) llerrs << "GL matrix stack corrupted!" << llendl; } LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); + //LLGLState::checkTextureChannels(); + //LLGLState::checkClientArrays(); } } } @@ -3831,8 +3924,8 @@ void LLPipeline::renderGeomShadow(LLCamera& camera) LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); + //LLGLState::checkTextureChannels(); + //LLGLState::checkClientArrays(); } } else @@ -3886,6 +3979,8 @@ void LLPipeline::renderDebug() glLoadMatrixd(gGLModelView); gGL.setColorMask(true, false); + bool hud_only = hasRenderType(LLPipeline::RENDER_TYPE_HUD); + // Debug stuff. for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) @@ -3896,7 +3991,8 @@ void LLPipeline::renderDebug() LLSpatialPartition* part = region->getSpatialPartition(i); if (part) { - if (hasRenderType(part->mDrawableType)) + if ( hud_only && (part->mDrawableType == RENDER_TYPE_HUD || part->mDrawableType == RENDER_TYPE_HUD_PARTICLES) || + !hud_only && hasRenderType(part->mDrawableType) ) { part->renderDebug(); } @@ -4138,185 +4234,6 @@ void LLPipeline::renderDebug() gGL.flush(); } -void LLPipeline::renderForSelect(std::set& objects, BOOL render_transparent, const LLRect& screen_rect) -{ - assertInitialized(); - - gGL.setColorMask(true, false); - gPipeline.resetDrawOrders(); - - for (std::set::iterator iter = objects.begin(); iter != objects.end(); ++iter) - { - stateSort((*iter)->mDrawable, *LLViewerCamera::getInstance()); - } - - LLMemType mt(LLMemType::MTYPE_PIPELINE); - - - - glMatrixMode(GL_MODELVIEW); - - LLGLSDefault gls_default; - LLGLSObjectSelect gls_object_select; - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLGLDepthTest gls_depth(GL_TRUE,GL_TRUE); - disableLights(); - - LLVertexBuffer::unbind(); - - //for each drawpool - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); - U32 last_type = 0; - - // If we don't do this, we crash something on changing graphics settings - // from Medium -> Low, because we unload all the shaders and the - // draw pools aren't aware. I don't know if this has to be a separate - // loop before actual rendering. JC - for (pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ++iter) - { - LLDrawPool *poolp = *iter; - if (poolp->isFacePool() && hasRenderType(poolp->getType())) - { - poolp->prerender(); - } - } - for (pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ++iter) - { - LLDrawPool *poolp = *iter; - if (poolp->isFacePool() && hasRenderType(poolp->getType())) - { - LLFacePool* face_pool = (LLFacePool*) poolp; - face_pool->renderForSelect(); - LLVertexBuffer::unbind(); - gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); - - if (poolp->getType() != last_type) - { - last_type = poolp->getType(); - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); - } - } - } - - LLGLEnable alpha_test(GL_ALPHA_TEST); - if (render_transparent) - { - gGL.setAlphaRejectSettings(LLRender::CF_GREATER_EQUAL, 0.f); - } - else - { - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.2f); - } - - gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_VERT_COLOR); - gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_VERT_ALPHA); - - U32 prim_mask = LLVertexBuffer::MAP_VERTEX | - LLVertexBuffer::MAP_TEXCOORD0; - - for (std::set::iterator i = objects.begin(); i != objects.end(); ++i) - { - LLViewerObject* vobj = *i; - LLDrawable* drawable = vobj->mDrawable; - if (vobj->isDead() || - vobj->isHUDAttachment() || - (LLSelectMgr::getInstance()->mHideSelectedObjects && vobj->isSelected()) || - drawable->isDead() || - !hasRenderType(drawable->getRenderType())) - { - continue; - } - - for (S32 j = 0; j < drawable->getNumFaces(); ++j) - { - LLFace* facep = drawable->getFace(j); - if (!facep->getPool()) - { - facep->renderForSelect(prim_mask); - } - } - } - - // pick HUD objects - LLVOAvatar* avatarp = gAgent.getAvatarObject(); - if (avatarp && sShowHUDAttachments) - { - glh::matrix4f save_proj(glh_get_current_projection()); - glh::matrix4f save_model(glh_get_current_modelview()); - - setup_hud_matrices(screen_rect); - for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); - iter != avatarp->mAttachmentPoints.end(); ) - { - LLVOAvatar::attachment_map_t::iterator curiter = iter++; - LLViewerJointAttachment* attachmentp = curiter->second; - if (attachmentp->getIsHUDAttachment()) - { - for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachmentp->mAttachedObjects.begin(); - attachment_iter != attachmentp->mAttachedObjects.end(); - ++attachment_iter) - { - if (LLViewerObject* objectp = (*attachment_iter)) - { - LLDrawable* drawable = objectp->mDrawable; - if (drawable->isDead()) - { - continue; - } - - for (S32 j = 0; j < drawable->getNumFaces(); ++j) - { - LLFace* facep = drawable->getFace(j); - if (!facep->getPool()) - { - facep->renderForSelect(prim_mask); - } - } - - //render child faces - LLViewerObject::const_child_list_t& child_list = objectp->getChildren(); - for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); - iter != child_list.end(); iter++) - { - LLViewerObject* child = *iter; - LLDrawable* child_drawable = child->mDrawable; - for (S32 l = 0; l < child_drawable->getNumFaces(); ++l) - { - LLFace* facep = child_drawable->getFace(l); - if (!facep->getPool()) - { - facep->renderForSelect(prim_mask); - } - } - } - } - } - } - } - - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(save_proj.m); - glh_set_current_projection(save_proj); - - glMatrixMode(GL_MODELVIEW); - glLoadMatrixf(save_model.m); - glh_set_current_modelview(save_model); - - - } - - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); - - LLVertexBuffer::unbind(); - - gGL.setColorMask(true, true); -} - void LLPipeline::rebuildPools() { LLMemType mt(LLMemType::MTYPE_PIPELINE); @@ -5091,12 +5008,14 @@ void LLPipeline::enableLights(U32 mask) } if (mLightMask != mask) { + stop_glerror(); if (!mLightMask) { glEnable(GL_LIGHTING); } if (mask) { + stop_glerror(); for (S32 i=0; i<8; i++) { LLLightState* light = gGL.getLight(i); @@ -5111,14 +5030,17 @@ void LLPipeline::enableLights(U32 mask) light->setDiffuse(LLColor4::black); } } + stop_glerror(); } else { glDisable(GL_LIGHTING); } + stop_glerror(); mLightMask = mask; LLColor4 ambient = gSky.getTotalAmbientColor(); glLightModelfv(GL_LIGHT_MODEL_AMBIENT,ambient.mV); + stop_glerror(); } } @@ -5187,7 +5109,7 @@ void LLPipeline::enableLightsFullbright(const LLColor4& color) void LLPipeline::disableLights() { enableLights(0); // no lighting (full bright) - glColor4f(1.f, 1.f, 1.f, 1.f); +// glColor4f(1.f, 1.f, 1.f, 1.f); } //============================================================================ @@ -5946,25 +5868,25 @@ void apply_cube_face_rotation(U32 face) void validate_framebuffer_object() { GLenum status; - status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + status = glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT); switch(status) { - case GL_FRAMEBUFFER_COMPLETE_EXT: + case GL_FRAMEBUFFER_COMPLETE: //framebuffer OK, no error. break; - case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: // frame buffer not OK: probably means unsupported depth buffer format llerrs << "Framebuffer Incomplete Missing Attachment." << llendl; break; - case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: + case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: //May not work on mac. Remove/ifdef if that's the case, for now. GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS missing from glext.h. // frame buffer not OK: probably means unsupported depth buffer format llerrs << "Framebuffer Incomplete Dimensions." << llendl; break; - case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: // frame buffer not OK: probably means unsupported depth buffer format llerrs << "Framebuffer Incomplete Attachment." << llendl; break; - case GL_FRAMEBUFFER_UNSUPPORTED_EXT: + case GL_FRAMEBUFFER_UNSUPPORTED: /* choose different formats */ llerrs << "Framebuffer unsupported." << llendl; break; @@ -6001,16 +5923,14 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b static const LLCachedControl res_mod("RenderResolutionDivisor",1); LLVector2 tc1(0,0); - LLVector2 tc2((F32) gViewerWindow->getWindowDisplayWidth()*2, - (F32) gViewerWindow->getWindowDisplayHeight()*2); + LLVector2 tc2((F32) gViewerWindow->getWorldViewWidthRaw()*2, + (F32) gViewerWindow->getWorldViewHeightRaw()*2); if (res_mod > 1) { tc2 /= (F32) res_mod.get(); } - gGL.setColorMask(true, true); - LLFastTimer ftm(LLFastTimer::FTM_RENDER_BLOOM); gGL.color4f(1,1,1,1); LLGLDepthTest depth(GL_FALSE); @@ -6103,14 +6023,10 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b gGlowExtractProgram.uniform1f("warmthAmount", warmthAmount); LLGLEnable blend_on(GL_BLEND); LLGLEnable test(GL_ALPHA_TEST); - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->disable(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); - gGL.getTexUnit(0)->bind(&mScreen); - + mScreen.bindTexture(0, 0); + gGL.color4f(1,1,1,1); gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); gGL.begin(LLRender::TRIANGLE_STRIP); @@ -6125,7 +6041,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b gGL.end(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->unbind(mScreen.getUsage()); mGlow[2].flush(); } @@ -6155,7 +6071,6 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b for (S32 i = 0; i < kernel; i++) { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); { LLFastTimer ftm(LLFastTimer::FTM_RENDER_BLOOM_FBO); mGlow[i%2].bindTarget(); @@ -6200,21 +6115,25 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b if (LLRenderTarget::sUseFBO) { LLFastTimer ftm(LLFastTimer::FTM_RENDER_BLOOM_FBO); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); } - gViewerWindow->setupViewport(); + gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; + gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; + gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); + gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); + glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); - tc2.setVec((F32) gViewerWindow->getWindowDisplayWidth(), - (F32) gViewerWindow->getWindowDisplayHeight()); + tc2.setVec((F32) gViewerWindow->getWorldViewWidthRaw(), + (F32) gViewerWindow->getWorldViewHeightRaw()); gGL.flush(); LLVertexBuffer::unbind(); - if (LLPipeline::sRenderDeferred && !LLViewerCamera::getInstance()->cameraUnderWater()) + if (LLPipeline::sRenderDeferred) { - bool dof_enabled = true; + bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater(); LLGLSLShader* shader = &gDeferredPostProgram; static const LLCachedControl render_dof("RenderDepthOfField",false); @@ -6223,7 +6142,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b shader = &gDeferredGIFinalProgram; dof_enabled = false; } - else if (LLToolMgr::getInstance()->inBuildMode() || !render_dof) + else if (!dof_enabled || LLToolMgr::getInstance()->inBuildMode() || !render_dof) { //squish focal length when in build mode (or if DoF is disabled) so DoF doesn't make editing objects difficult shader = &gDeferredPostNoDoFProgram; dof_enabled = false; @@ -6347,7 +6266,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b shader->uniform1f("magnification", magnification); } - S32 channel = shader->enableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, LLTexUnit::TT_RECT_TEXTURE); + S32 channel = shader->enableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); if (channel > -1) { mScreen.bindTexture(0, channel); @@ -6409,19 +6328,20 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b LLGLDisable blend(GL_BLEND); - //tex unit 0 - gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_COLOR); - - gGL.getTexUnit(0)->bind(&mGlow[1]); - gGL.getTexUnit(1)->activate(); - gGL.getTexUnit(1)->enable(LLTexUnit::TT_RECT_TEXTURE); - - - //tex unit 1 - gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_ADD, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR); + if (LLGLSLShader::sNoFixedFunction) + { + gGlowCombineProgram.bind(); + } + else + { + //tex unit 0 + gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_COLOR); + //tex unit 1 + gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_ADD, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR); + } + gGL.getTexUnit(0)->bind(&mGlow[1]); gGL.getTexUnit(1)->bind(&mScreen); - gGL.getTexUnit(1)->activate(); static const LLCachedControl fsaa_samples("RenderFSAASamples",0); LLGLEnable multisample(fsaa_samples > 0 ? GL_MULTISAMPLE_ARB : 0); @@ -6429,11 +6349,19 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b buff->setBuffer(mask); buff->drawArrays(LLRender::TRIANGLE_STRIP, 0, 3); - gGL.getTexUnit(1)->disable(); - gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT); + if (LLGLSLShader::sNoFixedFunction) + { + gGlowCombineProgram.unbind(); + } + else + { + gGL.getTexUnit(1)->disable(); + gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT); - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + } + } if (LLRenderTarget::sUseFBO) @@ -6465,25 +6393,23 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen noise_map = mNoiseMap; } - LLGLState::checkTextureChannels(); - shader.bind(); S32 channel = 0; - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, LLTexUnit::TT_RECT_TEXTURE); + channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, mDeferredScreen.getUsage()); if (channel > -1) { mDeferredScreen.bindTexture(0,channel); gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); } - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_SPECULAR, LLTexUnit::TT_RECT_TEXTURE); + channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_SPECULAR, mDeferredScreen.getUsage()); if (channel > -1) { mDeferredScreen.bindTexture(1, channel); gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); } - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL, LLTexUnit::TT_RECT_TEXTURE); + channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL, mDeferredScreen.getUsage()); if (channel > -1) { mDeferredScreen.bindTexture(2, channel); @@ -6565,14 +6491,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); } - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_LIGHT, LLTexUnit::TT_RECT_TEXTURE); - if (channel > -1) - { - has_gi = TRUE; - gi_source->bindTexture(0, channel); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - } - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_DEPTH); if (channel > -1) { @@ -6614,22 +6532,17 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen shader.uniformMatrix4fv("gi_norm_mat", 1, FALSE, mGINormalMatrix.m); } } - - /*channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_POSITION, LLTexUnit::TT_RECT_TEXTURE); - if (channel > -1) - { - mDeferredScreen.bindTexture(3, channel); - }*/ + stop_glerror(); - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_DEPTH, LLTexUnit::TT_RECT_TEXTURE); + channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_DEPTH, mDeferredDepth.getUsage()); if (channel > -1) { gGL.getTexUnit(channel)->bind(&mDeferredDepth, TRUE); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + //gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); stop_glerror(); - glTexParameteri(LLTexUnit::getInternalType(mDeferredDepth.getUsage()), GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); - glTexParameteri(LLTexUnit::getInternalType(mDeferredDepth.getUsage()), GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA); + //glTexParameteri(LLTexUnit::getInternalType(mDeferredDepth.getUsage()), GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); + //glTexParameteri(LLTexUnit::getInternalType(mDeferredDepth.getUsage()), GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA); stop_glerror(); @@ -6658,7 +6571,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen stop_glerror(); - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_LIGHT, LLTexUnit::TT_RECT_TEXTURE); + channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_LIGHT, mDeferredLight[light_index].getUsage()); if (channel > -1) { mDeferredLight[light_index].bindTexture(0, channel); @@ -6678,6 +6591,13 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen mGlow[1].bindTexture(0, channel); } + channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_LIGHT, LLTexUnit::TT_RECT_TEXTURE); + if (channel > -1) + { + gi_source->bindTexture(0, channel); + gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + } + channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_EDGE, LLTexUnit::TT_RECT_TEXTURE); if (channel > -1) { @@ -6890,9 +6810,9 @@ void LLPipeline::renderDeferredLighting() } //ati doesn't seem to love actually using the stencil buffer on FBO's - LLGLEnable stencil(GL_STENCIL_TEST); - glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + LLGLDisable stencil(GL_STENCIL_TEST); + //glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF); + //glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); gGL.setColorMask(true, true); @@ -7019,7 +6939,7 @@ void LLPipeline::renderDeferredLighting() mLuminanceMap.flush(); gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLuminanceMap.getTexture(), true); gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_TRILINEAR); - glGenerateMipmapEXT(GL_TEXTURE_2D); + glGenerateMipmap(GL_TEXTURE_2D); } } @@ -7348,8 +7268,9 @@ void LLPipeline::renderDeferredLighting() LLFastTimer ftm(LLFastTimer::FTM_LOCAL_LIGHTS); glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s); glColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f); - glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8, - GL_UNSIGNED_BYTE, get_box_fan_indices_ptr(camera, center)); + glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8, + GL_UNSIGNED_BYTE, get_box_fan_indices_ptr(camera, center)); + stop_glerror(); } } else @@ -7717,33 +7638,41 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) LLViewerTexture* img = volume->getLightTexture(); + if (img == NULL) + { + img = LLViewerFetchedTexture::sWhiteImagep; + } + S32 channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION); - if (channel > -1 && img) + if (channel > -1) { - gGL.getTexUnit(channel)->bind(img); + if (img) + { + gGL.getTexUnit(channel)->bind(img); - F32 lod_range = logf(img->getWidth())/logf(2.f); + F32 lod_range = logf(img->getWidth())/logf(2.f); - shader.uniform1f("proj_focus", focus); - shader.uniform1f("proj_lod", lod_range); - shader.uniform1f("proj_ambient_lod", llclamp((proj_range-focus)/proj_range*lod_range, 0.f, 1.f)); + shader.uniform1f("proj_focus", focus); + shader.uniform1f("proj_lod", lod_range); + shader.uniform1f("proj_ambient_lod", llclamp((proj_range-focus)/proj_range*lod_range, 0.f, 1.f)); + } } + } void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) { stop_glerror(); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_POSITION, LLTexUnit::TT_RECT_TEXTURE); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_NORMAL, LLTexUnit::TT_RECT_TEXTURE); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, LLTexUnit::TT_RECT_TEXTURE); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_SPECULAR, LLTexUnit::TT_RECT_TEXTURE); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_DEPTH, LLTexUnit::TT_RECT_TEXTURE); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_LIGHT, LLTexUnit::TT_RECT_TEXTURE); + shader.disableTexture(LLViewerShaderMgr::DEFERRED_NORMAL, mDeferredScreen.getUsage()); + shader.disableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, mDeferredScreen.getUsage()); + shader.disableTexture(LLViewerShaderMgr::DEFERRED_SPECULAR, mDeferredScreen.getUsage()); + shader.disableTexture(LLViewerShaderMgr::DEFERRED_DEPTH, mDeferredScreen.getUsage()); + shader.disableTexture(LLViewerShaderMgr::DEFERRED_LIGHT, mDeferredLight[0].getUsage()); shader.disableTexture(LLViewerShaderMgr::DEFERRED_GI_LIGHT, LLTexUnit::TT_RECT_TEXTURE); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_EDGE, LLTexUnit::TT_RECT_TEXTURE); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_SUN_LIGHT, LLTexUnit::TT_RECT_TEXTURE); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_LOCAL_LIGHT, LLTexUnit::TT_RECT_TEXTURE); + shader.disableTexture(LLViewerShaderMgr::DEFERRED_EDGE, mEdgeMap.getUsage()); + shader.disableTexture(LLViewerShaderMgr::DEFERRED_SUN_LIGHT, mDeferredLight[1].getUsage()); + shader.disableTexture(LLViewerShaderMgr::DEFERRED_LOCAL_LIGHT, mDeferredLight[2].getUsage()); shader.disableTexture(LLViewerShaderMgr::DEFERRED_LUMINANCE); shader.disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); shader.disableTexture(LLViewerShaderMgr::DEFERRED_GI_MIP); @@ -7791,7 +7720,7 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) gGL.getTexUnit(0)->activate(); shader.unbind(); - LLGLState::checkTextureChannels(); + //LLGLState::checkTextureChannels(); } inline float sgn(float a) @@ -7900,7 +7829,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) static LLCullResult ref_result; - if (LLDrawPoolWater::sNeedsDistortionUpdate) + if (LLDrawPoolWater::sNeedsReflectionUpdate) { //initial sky pass (no user clip plane) { //mask out everything but the sky @@ -7948,8 +7877,11 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) LLGLDisable cull(GL_CULL_FACE); updateCull(camera, ref_result, -water_clip, &plane); stateSort(camera, ref_result); - gPipeline.grabReferences(ref_result); - renderGeom(camera); + if (LLDrawPoolWater::sNeedsDistortionUpdate) + { + gPipeline.grabReferences(ref_result); + renderGeom(camera); + } LLPipeline::sSkipUpdate = FALSE; gPipeline.popRenderTypeMask(); } @@ -8025,16 +7957,16 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) glClear(GL_DEPTH_BUFFER_BIT); } glClearColor(0.f, 0.f, 0.f, 0.f); - - gViewerWindow->setupViewport(); + gViewerWindow->setup3DViewport(); gPipeline.popRenderTypeMask(); LLDrawPoolWater::sNeedsReflectionUpdate = FALSE; LLDrawPoolWater::sNeedsDistortionUpdate = FALSE; - LLViewerCamera::getInstance()->setUserClipPlane(LLPlane(-pnorm, -pd)); + LLPlane npnorm(-pnorm, -pd); + LLViewerCamera::getInstance()->setUserClipPlane(npnorm); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); + //LLGLState::checkTextureChannels(); + //LLGLState::checkClientArrays(); if (agent) { @@ -8061,7 +7993,6 @@ glh::matrix4f look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up) dirN = dir; dirN.normVec(); - ret.m[ 0] = lftN[0]; ret.m[ 1] = upN[0]; @@ -8164,14 +8095,21 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLVertexBuffer::unbind(); { + if (!use_shader) + { //occlusion program is general purpose depth-only no-textures + gOcclusionProgram.bind(); + } LLFastTimer ftm(LLFastTimer::FTM_SHADOW_SIMPLE); - LLGLDisable test(GL_ALPHA_TEST); gGL.getTexUnit(0)->disable(); for (U32 i = 0; i < sizeof(types)/sizeof(U32); ++i) { renderObjects(types[i], LLVertexBuffer::MAP_VERTEX, FALSE); } gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + if (!use_shader) + { + gOcclusionProgram.unbind(); + } } if (use_shader) @@ -8187,12 +8125,11 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera { LLFastTimer ftm(LLFastTimer::FTM_SHADOW_ALPHA); - LLGLEnable test(GL_ALPHA_TEST); - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.6f); + gDeferredShadowAlphaMaskProgram.bind(); + gDeferredShadowAlphaMaskProgram.setAlphaRange(0.6f, 1.f); renderObjects(LLRenderPass::PASS_ALPHA_SHADOW, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR, TRUE); glColor4f(1,1,1,1); renderObjects(LLRenderPass::PASS_GRASS, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, TRUE); - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } //glCullFace(GL_BACK); @@ -8601,6 +8538,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) LLPipeline::RENDER_TYPE_WATER, LLPipeline::RENDER_TYPE_VOIDWATER, LLPipeline::RENDER_TYPE_PASS_ALPHA_SHADOW, + LLPipeline::RENDER_TYPE_PASS_GRASS, LLPipeline::RENDER_TYPE_PASS_SIMPLE, LLPipeline::RENDER_TYPE_PASS_BUMP, LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT, @@ -8637,12 +8575,13 @@ void LLPipeline::generateSunShadow(LLCamera& camera) //F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] }; //put together a universal "near clip" plane for shadow frusta - /*LLPlane shadow_near_clip; + LLPlane shadow_near_clip; { - LLVector3 p = gAgentCamera.getCameraPositionAgent();//gAgent.getPositionAgent(); - p += mSunDir * gSavedSettings.getF32("RenderFarClip")*2.f; + LLVector3 p = gAgent.getPositionAgent();//gAgentCamera.getCameraPositionAgent(); + static const LLCachedControl render_far_clip("RenderFarClip"); + p += mSunDir * render_far_clip*2.f; shadow_near_clip.setVec(p, mSunDir); - }*/ + } LLVector3 lightDir = -mSunDir; lightDir.normVec(); @@ -8718,7 +8657,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) near_clip = -max.mV[2]; F32 far_clip = -min.mV[2]*2.f; - far_clip = llmin(far_clip, 128.f); + //far_clip = llmin(far_clip, 128.f); far_clip = llmin(far_clip, camera.getFar()); F32 range = far_clip-near_clip; @@ -9011,11 +8950,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera) fovx = acos(fovx); fovz = acos(fovz); - if (fovx > cutoff || llround(fovz, 0.01f) > cutoff) - { - // llerrs << "WTF?" << llendl; - } - mShadowFOV.mV[j] = cutoff; } @@ -9081,8 +9015,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); - shadow_cam.ignoreAgentFrustumPlane(LLCamera::AGENT_PLANE_NEAR); - //shadow_cam.getAgentPlane(LLCamera::AGENT_PLANE_NEAR).set(shadow_near_clip); + //shadow_cam.ignoreAgentFrustumPlane(LLCamera::AGENT_PLANE_NEAR); + shadow_cam.getAgentPlane(LLCamera::AGENT_PLANE_NEAR).set(shadow_near_clip); //translate and scale to from [-1, 1] to [0, 1] glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, @@ -9262,6 +9196,10 @@ void LLPipeline::generateSunShadow(LLCamera& camera) mShadow[i+4].flush(); } } + else + { //no spotlight shadows + mShadowSpotLight[0] = mShadowSpotLight[1] = NULL; + } static const LLCachedControl camera_offset("CameraOffset",false); if (!camera_offset) @@ -9429,11 +9367,9 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) glClearColor(0.0f,0.0f,0.0f,0.0f); gGL.setColorMask(true, true); - glStencilMask(0xFFFFFFFF); - glClearStencil(0); - + // get the number of pixels per angle - F32 pa = gViewerWindow->getWindowDisplayHeight() / (RAD_TO_DEG * LLViewerCamera::getInstance()->getView()); + F32 pa = gViewerWindow->getWindowHeightRaw() / (RAD_TO_DEG * viewer_camera->getView()); //get resolution based on angle width and height of impostor (double desired resolution to prevent aliasing) U32 resY = llmin(nhpo2((U32) (fov*pa)), (U32) 512); @@ -9442,61 +9378,43 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) if (!avatar->mImpostor.isComplete() || resX != avatar->mImpostor.getWidth() || resY != avatar->mImpostor.getHeight()) { + static const LLCachedControl shadow_precision("DeferredHighPrecision",true); //TO-DO: Profile 16bit format later + avatar->mImpostor.allocate(resX,resY, (!LLPipeline::sRenderDeferred || shadow_precision) ? GL_RGBA : GL_RGBA16F_ARB,TRUE,TRUE); + if (LLPipeline::sRenderDeferred) { - static const LLCachedControl shadow_precision("DeferredHighPrecision",true); - const GLuint format = shadow_precision ? GL_RGBA : GL_RGBA16F_ARB; //TO-DO: Profile 16bit format later - avatar->mImpostor.allocate(resX,resY,format,TRUE,TRUE); addDeferredAttachments(avatar->mImpostor); } - else - { - avatar->mImpostor.allocate(resX,resY,GL_RGBA,TRUE,TRUE); - } + gGL.getTexUnit(0)->bind(&avatar->mImpostor); gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } - LLGLEnable stencil(GL_STENCIL_TEST); - glStencilMask(0xFFFFFFFF); - glStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFF); - glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + avatar->mImpostor.bindTarget(); - { - LLGLEnable scissor(GL_SCISSOR_TEST); - glScissor(0, 0, resX, resY); - avatar->mImpostor.bindTarget(); - avatar->mImpostor.clear(); - } - if (LLPipeline::sRenderDeferred) { - stop_glerror(); + avatar->mImpostor.clear(); renderGeomDeferred(camera); renderGeomPostDeferred(camera); } else { + LLGLEnable scissor(GL_SCISSOR_TEST); + glScissor(0, 0, resX, resY); + avatar->mImpostor.clear(); renderGeom(camera); } - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - glStencilFunc(GL_EQUAL, 1, 0xFFFFFF); - - //if (!sRenderDeferred || muted) - { - LLVector3 left = camera.getLeftAxis()*tdim.mV[0]*2.f; - LLVector3 up = camera.getUpAxis()*tdim.mV[1]*2.f; - - //Safe?? + { //create alpha mask based on depth buffer (grey out if muted) if (LLPipeline::sRenderDeferred) { GLuint buff = GL_COLOR_ATTACHMENT0_EXT; glDrawBuffersARB(1, &buff); } - LLGLEnable blend(muted ? 0 : GL_BLEND); + LLGLDisable blend(GL_BLEND); if (muted) { @@ -9507,25 +9425,34 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) gGL.setColorMask(false, true); } - gGL.setSceneBlendType(LLRender::BT_ADD); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLGLDepthTest depth(GL_FALSE, GL_FALSE); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_GREATER); + + gGL.flush(); + + glPushMatrix(); + glLoadIdentity(); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + + static const F32 clip_plane = 0.99999f; - gGL.color4f(1,1,1,1); gGL.color4ub(64,64,64,255); gGL.begin(LLRender::QUADS); - gGL.vertex3fv((pos+left-up).mV); - gGL.vertex3fv((pos-left-up).mV); - gGL.vertex3fv((pos-left+up).mV); - gGL.vertex3fv((pos+left+up).mV); + gGL.vertex3f(-1, -1, clip_plane); + gGL.vertex3f(1, -1, clip_plane); + gGL.vertex3f(1, 1, clip_plane); + gGL.vertex3f(-1, 1, clip_plane); gGL.end(); gGL.flush(); - gGL.setSceneBlendType(LLRender::BT_ALPHA); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); } - avatar->mImpostor.flush(); avatar->setImpostorDim(tdim); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index b6d728269..d3fea1ff2 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -91,8 +91,11 @@ public: void resetVertexBuffers(); void resizeScreenTexture(); void releaseGLBuffers(); + void releaseScreenBuffers(); void createGLBuffers(); + void allocateScreenBuffer(U32 resX, U32 resY); + bool allocateScreenBuffer(U32 resX, U32 resY, U32 samples); void resetVertexBuffers(LLDrawable* drawable); void setUseVBO(BOOL use_vbo); @@ -237,7 +240,6 @@ public: void renderHighlights(); void renderDebug(); - void renderForSelect(std::set& objects, BOOL render_transparent, const LLRect& screen_rect); void rebuildPools(); // Rebuild pools void findReferences(LLDrawable *drawablep); // Find the lists which have references to this object @@ -441,7 +443,6 @@ public: S32 mMeanBatchSize; S32 mTrianglesDrawn; S32 mNumVisibleNodes; - LLStat mTrianglesDrawnStat; S32 mVerticesRelit; S32 mLightingChanges; @@ -680,7 +681,6 @@ void render_bbox(const LLVector3 &min, const LLVector3 &max); void render_hud_elements(); extern LLPipeline gPipeline; -extern BOOL gRenderForSelect; extern BOOL gDebugPipeline; extern const LLMatrix4* gGLLastMatrix; diff --git a/indra/newview/rlvcommon.cpp b/indra/newview/rlvcommon.cpp index df409ff14..c45551516 100644 --- a/indra/newview/rlvcommon.cpp +++ b/indra/newview/rlvcommon.cpp @@ -18,6 +18,7 @@ #include "llagent.h" #include "llappviewer.h" #include "llavatarnamecache.h" +#include "llnotificationsutil.h" #include "lluictrlfactory.h" #include "llversionviewer.h" #include "llviewermenu.h" @@ -43,7 +44,7 @@ void RlvNotifications::notifyBehaviour(ERlvBehaviour eBhvr, ERlvParamType eType) { LLSD argsNotify; argsNotify["MESSAGE"] = strMsg; - LLNotifications::instance().add("SystemMessageTip", argsNotify); + LLNotificationsUtil::add("SystemMessageTip", argsNotify); } } #endif // RLV_EXTENSION_NOTIFY_BEHAVIOUR @@ -53,7 +54,7 @@ void RlvNotifications::notifyBlocked(const std::string& strRlvString) { LLSD argsNotify; argsNotify["MESSAGE"] = RlvStrings::getString(strRlvString); - LLNotifications::instance().add("SystemMessageTip", argsNotify); + LLNotificationsUtil::add("SystemMessageTip", argsNotify); } // Checked: 2009-11-11 (RLVa-1.1.0a) | Added: RLVa-1.1.0a @@ -65,7 +66,7 @@ void RlvNotifications::notifyBlockedViewXXX(const char* pstrAssetType) LLSD argsNotify; argsNotify["MESSAGE"] = strMsg; - LLNotifications::instance().add("SystemMessageTip", argsNotify); + LLNotificationsUtil::add("SystemMessageTip", argsNotify); } // Checked: 2009-11-13 (RLVa-1.1.0b) | Modified: RLVa-1.1.0b @@ -437,7 +438,7 @@ void RlvUtil::notifyFailedAssertion(const std::string& strAssert, const std::str LLSD argsNotify; argsNotify["MESSAGE"] = llformat("RLVa assertion failure: %s (%s - %d)", strAssert.c_str(), strFile.c_str(), nLine); - LLNotifications::instance().add("SystemMessageTip", argsNotify); + LLNotificationsUtil::add("SystemMessageTip", argsNotify); } // Checked: 2010-03-27 (RLVa-1.1.3a) | Modified: RLVa-1.2.0b diff --git a/indra/newview/rlvextensions.cpp b/indra/newview/rlvextensions.cpp index cc3fc6bc5..818eb9f34 100644 --- a/indra/newview/rlvextensions.cpp +++ b/indra/newview/rlvextensions.cpp @@ -307,7 +307,7 @@ std::string RlvExtGetSet::onGetEnv(std::string strSetting) LLFloaterWindLight::instance()->syncMenu(); } - LLWLParamManager* pWLParams = LLWLParamManager::instance(); + LLWLParamManager* pWLParams = LLWLParamManager::getInstance(); F32 nValue = 0.0f; if ("daytime" == strSetting) @@ -380,7 +380,7 @@ ERlvCmdRet RlvExtGetSet::onSetEnv(std::string strSetting, const std::string& str LLFloaterWindLight::instance()->syncMenu(); } - LLWLParamManager* pWLParams = LLWLParamManager::instance(); + LLWLParamManager* pWLParams = LLWLParamManager::getInstance(); WLFloatControl* pFloat = NULL; WLColorControl* pColour = NULL; diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index 57f3037ee..b7959c31b 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -20,6 +20,7 @@ #include "llgesturemgr.h" #include "llinventoryview.h" #include "llinventorybridge.h" +#include "llnotificationsutil.h" #include "llviewerobject.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" @@ -335,7 +336,7 @@ bool RlvForceWear::isWearingItem(const LLInventoryItem* pItem) case LLAssetType::AT_OBJECT: return (gAgent.getAvatarObject()) && (gAgent.getAvatarObject()->isWearingAttachment(pItem->getUUID())); case LLAssetType::AT_GESTURE: - return gGestureManager.isGestureActive(pItem->getUUID()); + return LLGestureMgr::instance().isGestureActive(pItem->getUUID()); case LLAssetType::AT_LINK: return isWearingItem(gInventory.getItem(pItem->getLinkedUUID())); default: @@ -351,7 +352,7 @@ void RlvForceWear::forceFolder(const LLViewerInventoryCategory* pFolder, EWearAc // [See LLWearableBridge::wearOnAvatar(): don't wear anything until initial wearables are loaded, can destroy clothing items] if (!gAgentWearables.areWearablesLoaded()) { - LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded"); + LLNotificationsUtil::add("CanNotChangeAppearanceUntilLoaded"); return; } LLVOAvatar* pAvatar = gAgent.getAvatarObject(); @@ -784,7 +785,7 @@ void RlvForceWear::done() for (S32 idxGesture = 0, cntGesture = m_remGestures.count(); idxGesture < cntGesture; idxGesture++) { LLViewerInventoryItem* pItem = m_remGestures.get(idxGesture); - gGestureManager.deactivateGesture(pItem->getUUID()); + LLGestureMgr::instance().deactivateGesture(pItem->getUUID()); gInventory.updateItem(pItem); gInventory.notifyObservers(); } @@ -877,7 +878,7 @@ void RlvForceWear::done() // Process gestures if (m_addGestures.size()) { - gGestureManager.activateGestures(m_addGestures); + LLGestureMgr::instance().activateGestures(m_addGestures); for (S32 idxGesture = 0, cntGesture = m_addGestures.count(); idxGesture < cntGesture; idxGesture++) gInventory.updateItem(m_addGestures.get(idxGesture)); gInventory.notifyObservers(); @@ -954,7 +955,7 @@ void RlvBehaviourNotifyHandler::sendNotification(const std::string& strText, con // Checked: 2009-06-03 (RLVa-0.2.0h) | Added: RLVa-0.2.0h void RlvWLSnapshot::restoreSnapshot(const RlvWLSnapshot* pWLSnapshot) { - LLWLParamManager* pWLParams = LLWLParamManager::instance(); + LLWLParamManager* pWLParams = LLWLParamManager::getInstance(); if ( (pWLSnapshot) && (pWLParams) ) { pWLParams->mAnimator.mIsRunning = pWLSnapshot->fIsRunning; @@ -975,7 +976,7 @@ RlvWLSnapshot* RlvWLSnapshot::takeSnapshot() } RlvWLSnapshot* pWLSnapshot = NULL; - LLWLParamManager* pWLParams = LLWLParamManager::instance(); + LLWLParamManager* pWLParams = LLWLParamManager::getInstance(); if (pWLParams) { pWLSnapshot = new RlvWLSnapshot(); @@ -1043,7 +1044,7 @@ bool rlvCanDeleteOrReturn() LLSD args; args["MESSAGE"] = llformat("RestrainedLove Support will be %s after you restart", (rlv_handler_t::isEnabled()) ? "disabled" : "enabled" ); - LLNotifications::instance().add("GenericAlert", args); + LLNotificationsUtil::add("GenericAlert", args); #endif } // Checked: 2009-07-08 (RLVa-1.0.0e) diff --git a/indra/newview/skins/default/xui/en-us/floater_customize.xml b/indra/newview/skins/default/xui/en-us/floater_customize.xml index 261ab3189..ac3c36b95 100644 --- a/indra/newview/skins/default/xui/en-us/floater_customize.xml +++ b/indra/newview/skins/default/xui/en-us/floater_customize.xml @@ -1326,6 +1326,8 @@ scratch and wear it.