From 7abecb48babe6a6f09bf6692ba55076546cfced9 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Mon, 1 Dec 2008 17:39:58 -0600 Subject: Second Life viewer sources 1.22.0-RC --- linden/doc/contributions.txt | 17 +- linden/etc/message.xml | 36 + linden/indra/CMakeLists.txt | 4 + linden/indra/cmake/00-Common.cmake | 8 + linden/indra/cmake/APR.cmake | 21 +- linden/indra/cmake/CopyWinLibs.cmake | 55 + linden/indra/cmake/DBusGlib.cmake | 29 + linden/indra/cmake/DirectX.cmake | 22 +- linden/indra/cmake/FindMono.cmake | 18 +- linden/indra/cmake/GooglePerfTools.cmake | 6 +- linden/indra/cmake/LLAudio.cmake | 8 +- linden/indra/cmake/LLCharacter.cmake | 4 +- linden/indra/cmake/LLCommon.cmake | 8 +- linden/indra/cmake/LLCrashLogger.cmake | 4 +- linden/indra/cmake/LLDatabase.cmake | 5 +- linden/indra/cmake/LLImage.cmake | 6 +- linden/indra/cmake/LLImageJ2COJ.cmake | 5 +- linden/indra/cmake/LLInventory.cmake | 4 +- linden/indra/cmake/LLKDU.cmake | 2 - linden/indra/cmake/LLMath.cmake | 4 +- linden/indra/cmake/LLMedia.cmake | 7 +- linden/indra/cmake/LLMessage.cmake | 9 +- linden/indra/cmake/LLPhysics.cmake | 76 - linden/indra/cmake/LLPrimitive.cmake | 4 +- linden/indra/cmake/LLScene.cmake | 4 +- linden/indra/cmake/LLUI.cmake | 4 +- linden/indra/cmake/LLVFS.cmake | 6 - linden/indra/cmake/LLXML.cmake | 7 +- linden/indra/cmake/Linking.cmake | 8 +- linden/indra/cmake/Python.cmake | 1 + linden/indra/cmake/QuickTime.cmake | 22 +- linden/indra/develop.py | 118 +- linden/indra/lib/python/indra/base/lllog.py | 2 +- linden/indra/lib/python/indra/base/llsd.py | 205 +- linden/indra/lib/python/indra/ipc/llmessage.py | 2 +- linden/indra/lib/python/indra/ipc/llsdhttp.py | 2 + linden/indra/lib/python/indra/ipc/mysql_pool.py | 23 +- linden/indra/lib/python/indra/ipc/saranwrap.py | 651 - linden/indra/lib/python/indra/ipc/siesta.py | 4 +- .../lib/python/indra/util/fastest_elementtree.py | 31 +- linden/indra/lib/python/indra/util/iterators.py | 63 + .../indra/lib/python/indra/util/iterators_test.py | 72 + linden/indra/lib/python/indra/util/llmanifest.py | 3 +- .../indra/lib/python/indra/util/llperformance.py | 158 + linden/indra/lib/python/indra/util/named_query.py | 20 +- .../python/indra/util/simperf_host_xml_parser.py | 338 + .../python/indra/util/simperf_oprof_interface.py | 160 + .../python/indra/util/simperf_proc_interface.py | 164 + linden/indra/linux_crash_logger/CMakeLists.txt | 7 +- linden/indra/llaudio/CMakeLists.txt | 7 + linden/indra/llaudio/audioengine.cpp | 33 +- linden/indra/llaudio/audioengine.h | 27 +- linden/indra/llaudio/audioengine_fmod.cpp | 2 +- linden/indra/llcharacter/llbvhloader.cpp | 45 +- linden/indra/llcharacter/lleditingmotion.cpp | 4 +- linden/indra/llcharacter/llmotioncontroller.cpp | 5 + linden/indra/llcommon/CMakeLists.txt | 7 + linden/indra/llcommon/indra_constants.h | 1 + linden/indra/llcommon/llcommon.cpp | 4 +- linden/indra/llcommon/llfasttimer.h | 1 + linden/indra/llcommon/llfindlocale.cpp | 4 +- linden/indra/llcommon/llfindlocale.h | 4 +- linden/indra/llcommon/llkeythrottle.h | 2 +- linden/indra/llcommon/llprocessor.h | 20 +- linden/indra/llcommon/llsdserialize.cpp | 2 +- linden/indra/llcommon/llsdserialize_xml.cpp | 13 +- linden/indra/llcommon/llstat.cpp | 562 +- linden/indra/llcommon/llstat.h | 142 +- linden/indra/llcommon/llstatenums.h | 17 +- linden/indra/llcommon/llstl.h | 5 +- linden/indra/llcommon/llstring.h | 37 +- linden/indra/llcommon/llthread.cpp | 4 +- linden/indra/llcommon/llthread.h | 4 +- linden/indra/llcommon/lltimer.cpp | 53 +- linden/indra/llcommon/lltimer.h | 5 +- linden/indra/llcommon/llversionserver.h | 4 +- linden/indra/llcommon/llversionviewer.h | 4 +- linden/indra/llcrashlogger/llcrashlogger.cpp | 38 +- linden/indra/llimage/CMakeLists.txt | 7 + linden/indra/llimage/llimage.cpp | 75 +- linden/indra/llimage/llimage.h | 33 +- linden/indra/llimage/llimagej2c.cpp | 141 +- linden/indra/llimage/llimagej2c.h | 5 + linden/indra/llimage/llimageworker.cpp | 4 +- linden/indra/llimage/llimageworker.h | 6 +- linden/indra/llimagej2coj/CMakeLists.txt | 4 + linden/indra/llimagej2coj/llimagej2coj.cpp | 19 +- linden/indra/llinventory/llinventory.cpp | 43 +- linden/indra/llinventory/llparcel.cpp | 14 +- linden/indra/llinventory/llsaleinfo.cpp | 11 +- linden/indra/llmath/llmodularmath.h | 57 + linden/indra/llmath/lloctree.h | 4 +- linden/indra/llmath/v3color.h | 77 +- linden/indra/llmath/v4color.cpp | 166 +- linden/indra/llmath/v4color.h | 109 +- linden/indra/llmath/v4coloru.cpp | 2 +- linden/indra/llmath/v4coloru.h | 89 +- linden/indra/llmedia/CMakeLists.txt | 7 + linden/indra/llmedia/llmediaimplexample2.cpp | 2 +- linden/indra/llmedia/llmediaimplgstreamer.cpp | 3 + linden/indra/llmessage/CMakeLists.txt | 8 + linden/indra/llmessage/llcachename.cpp | 221 +- linden/indra/llmessage/llcachename.h | 14 +- linden/indra/llmessage/llcircuit.cpp | 11 + linden/indra/llmessage/llcircuit.h | 7 + linden/indra/llmessage/llcurl.cpp | 6 +- linden/indra/llmessage/llhttpassetstorage.cpp | 4 + linden/indra/llmessage/llhttpclient.cpp | 36 +- linden/indra/llmessage/lliohttpserver.cpp | 7 +- linden/indra/llmessage/lliosocket.cpp | 3 + linden/indra/llmessage/llmail.cpp | 36 +- linden/indra/llmessage/llmail.h | 61 +- linden/indra/llmessage/llmessagetemplate.cpp | 22 +- linden/indra/llmessage/llmessagetemplate.h | 12 +- linden/indra/llmessage/llnamevalue.cpp | 4 +- linden/indra/llmessage/llnamevalue.h | 4 +- linden/indra/llmessage/llpartdata.h | 1 + linden/indra/llmessage/llpumpio.cpp | 30 +- linden/indra/llmessage/llpumpio.h | 9 + linden/indra/llmessage/llqueryflags.h | 2 +- linden/indra/llmessage/llurlrequest.cpp | 23 +- linden/indra/llmessage/message.cpp | 34 +- linden/indra/llmessage/message.h | 16 +- linden/indra/llprimitive/lltree_common.h | 13 + linden/indra/llrender/llcubemap.cpp | 54 +- linden/indra/llrender/llcubemap.h | 2 + linden/indra/llrender/llfont.cpp | 31 +- linden/indra/llrender/llfont.h | 1 + linden/indra/llrender/llfontgl.cpp | 20 +- linden/indra/llrender/llgl.cpp | 64 +- linden/indra/llrender/llgl.h | 6 +- linden/indra/llrender/llglimmediate.h | 4 +- linden/indra/llrender/llglslshader.cpp | 8 +- linden/indra/llrender/llglslshader.h | 5 +- linden/indra/llrender/llglstates.h | 22 +- linden/indra/llrender/llimagegl.cpp | 266 +- linden/indra/llrender/llimagegl.h | 26 +- linden/indra/llrender/llpostprocess.cpp | 18 +- linden/indra/llrender/llrender.cpp | 364 +- linden/indra/llrender/llrender.h | 124 +- linden/indra/llrender/llrendertarget.cpp | 56 +- linden/indra/llrender/llrendertarget.h | 15 +- linden/indra/llrender/llshadermgr.cpp | 2 +- linden/indra/llrender/llvertexbuffer.cpp | 8 +- linden/indra/llrender/llvertexbuffer.h | 16 +- linden/indra/llui/llfloater.cpp | 22 + linden/indra/llui/lllineeditor.cpp | 29 +- linden/indra/llui/lllineeditor.h | 3 +- linden/indra/llui/llmenugl.cpp | 3 + linden/indra/llui/llmultislider.cpp | 2 +- linden/indra/llui/llscrollcontainer.cpp | 2 +- linden/indra/llui/llscrolllistctrl.cpp | 4 +- linden/indra/llui/llslider.cpp | 2 +- linden/indra/llui/lltexteditor.cpp | 144 +- linden/indra/llui/lltexteditor.h | 20 +- linden/indra/llui/llui.cpp | 88 +- linden/indra/llui/llview.cpp | 4 +- linden/indra/llui/llviewborder.cpp | 8 +- linden/indra/llvfs/CMakeLists.txt | 6 + linden/indra/llvfs/lldir.cpp | 23 + linden/indra/llvfs/lldir.h | 14 +- linden/indra/llvfs/llvfile.cpp | 1 + linden/indra/llvfs/llvfs.cpp | 2 +- linden/indra/llwindow/llwindow.cpp | 6 + linden/indra/llwindow/llwindow.h | 1 + linden/indra/llwindow/llwindowsdl.cpp | 65 +- linden/indra/llwindow/llwindowsdl.h | 25 +- linden/indra/llxml/CMakeLists.txt | 5 + linden/indra/llxml/llcontrol.cpp | 4 +- linden/indra/lscript/lscript_byteconvert.h | 20 +- linden/indra/lscript/lscript_byteformat.h | 1 + .../indra/lscript/lscript_compile/lscript_tree.cpp | 37 +- linden/indra/lscript/lscript_execute.h | 57 +- .../lscript/lscript_execute/lscript_execute.cpp | 84 +- .../lscript/lscript_library/lscript_library.cpp | 1 + linden/indra/mac_crash_logger/CMakeLists.txt | 13 +- .../mac_crash_logger/CrashReporter.nib/info.nib | 8 +- linden/indra/mac_updater/CMakeLists.txt | 13 +- linden/indra/newview/CMakeLists.txt | 105 +- .../indra/newview/English.lproj/InfoPlist.strings | 4 +- linden/indra/newview/Info-SecondLife.plist | 2 +- linden/indra/newview/app_settings/keywords.ini | 10 +- linden/indra/newview/app_settings/settings.xml | 123 +- .../shaders/class1/objects/simpleV.glsl | 2 +- linden/indra/newview/featuretable.txt | 17 +- linden/indra/newview/featuretable_linux.txt | 17 +- linden/indra/newview/featuretable_mac.txt | 17 +- linden/indra/newview/gpu_table.txt | 51 +- .../darwin/releasecandidate-dmg/_DS_Store | Bin 12292 -> 12292 bytes .../windows/FILES_ARE_UNICODE_UTF-16LE.txt | 6 + .../installers/windows/installer_template.nsi | 473 +- .../indra/newview/installers/windows/lang_de.nsi | Bin 3762 -> 8262 bytes .../newview/installers/windows/lang_en-us.nsi | Bin 3211 -> 7162 bytes .../indra/newview/installers/windows/lang_es.nsi | Bin 0 -> 7612 bytes .../indra/newview/installers/windows/lang_fr.nsi | Bin 0 -> 7858 bytes .../indra/newview/installers/windows/lang_it.nsi | Bin 0 -> 7196 bytes .../indra/newview/installers/windows/lang_ja.nsi | Bin 3579 -> 6302 bytes .../indra/newview/installers/windows/lang_ko.nsi | Bin 3448 -> 6200 bytes .../indra/newview/installers/windows/lang_nl.nsi | Bin 0 -> 7160 bytes .../newview/installers/windows/lang_pt-br.nsi | Bin 0 -> 7590 bytes .../indra/newview/installers/windows/lang_zh.nsi | Bin 0 -> 5354 bytes .../newview/installers/windows/language_menu.nsi | Bin 0 -> 1292 bytes linden/indra/newview/llagent.cpp | 278 +- linden/indra/newview/llagent.h | 4 +- linden/indra/newview/llappviewer.cpp | 226 +- linden/indra/newview/llappviewer.h | 25 +- linden/indra/newview/llappviewerlinux.cpp | 307 +- linden/indra/newview/llappviewerlinux.h | 34 +- linden/indra/newview/llappviewerlinux_api.h | 148 + linden/indra/newview/llappviewerlinux_api.xml | 14 + linden/indra/newview/llappviewerlinux_api_dbus.cpp | 131 + linden/indra/newview/llappviewerlinux_api_dbus.h | 49 + .../newview/llappviewerlinux_api_dbus_syms_raw.inc | 9 + linden/indra/newview/llappviewermacosx.cpp | 101 +- linden/indra/newview/llappviewermacosx.h | 3 +- linden/indra/newview/llappviewerwin32.cpp | 104 +- linden/indra/newview/llappviewerwin32.h | 8 +- linden/indra/newview/llaudiosourcevo.cpp | 2 +- linden/indra/newview/llbox.cpp | 2 +- linden/indra/newview/llchatbar.cpp | 10 +- linden/indra/newview/llcommandlineparser.cpp | 12 +- linden/indra/newview/llcompilequeue.cpp | 17 +- linden/indra/newview/llcontainerview.cpp | 2 +- linden/indra/newview/lldrawable.cpp | 10 +- linden/indra/newview/lldrawpool.cpp | 9 +- linden/indra/newview/lldrawpoolalpha.cpp | 8 +- linden/indra/newview/lldrawpoolavatar.cpp | 14 +- linden/indra/newview/lldrawpoolbump.cpp | 55 +- linden/indra/newview/lldrawpoolground.cpp | 5 +- linden/indra/newview/lldrawpoolsky.cpp | 4 +- linden/indra/newview/lldrawpoolterrain.cpp | 124 +- linden/indra/newview/lldrawpooltree.cpp | 5 +- linden/indra/newview/lldrawpoolwater.cpp | 38 +- linden/indra/newview/lldrawpoolwlsky.cpp | 13 +- linden/indra/newview/lldynamictexture.cpp | 19 +- linden/indra/newview/lldynamictexture.h | 4 +- linden/indra/newview/llface.cpp | 16 +- linden/indra/newview/llface.h | 2 +- linden/indra/newview/llface.inl | 1 + linden/indra/newview/llfasttimerview.cpp | 13 +- linden/indra/newview/llfeaturemanager.cpp | 2 - linden/indra/newview/llfilepicker.cpp | 4 +- linden/indra/newview/llfloateractivespeakers.cpp | 6 + linden/indra/newview/llfloateranimpreview.cpp | 9 +- linden/indra/newview/llfloaterauction.cpp | 4 +- linden/indra/newview/llfloaterbeacons.cpp | 150 + linden/indra/newview/llfloaterbeacons.h | 56 + linden/indra/newview/llfloaterbuy.cpp | 12 +- linden/indra/newview/llfloaterbuy.h | 3 +- linden/indra/newview/llfloaterbuycurrency.cpp | 14 - linden/indra/newview/llfloatercolorpicker.cpp | 6 +- linden/indra/newview/llfloaterimagepreview.cpp | 117 +- linden/indra/newview/llfloaterimagepreview.h | 2 + linden/indra/newview/llfloaterjoystick.cpp | 2 +- linden/indra/newview/llfloaterland.cpp | 2 +- linden/indra/newview/llfloaterlandmark.cpp | 56 +- linden/indra/newview/llfloaterlandmark.h | 2 - linden/indra/newview/llfloaterpostcard.cpp | 12 +- linden/indra/newview/llfloaterpreference.cpp | 4 +- linden/indra/newview/llfloatersnapshot.cpp | 285 +- linden/indra/newview/llfloatertopobjects.cpp | 2 +- linden/indra/newview/llfolderview.cpp | 4 +- linden/indra/newview/llframestatview.cpp | 10 +- linden/indra/newview/llglsandbox.cpp | 59 +- linden/indra/newview/llgroupmgr.cpp | 17 + linden/indra/newview/llhomelocationresponder.cpp | 108 + linden/indra/newview/llhomelocationresponder.h | 47 + linden/indra/newview/llhudeffectbeam.cpp | 2 +- linden/indra/newview/llhudeffectlookat.cpp | 4 +- linden/indra/newview/llhudeffectpointat.cpp | 4 +- linden/indra/newview/llhudicon.cpp | 6 +- linden/indra/newview/llhudtext.cpp | 127 +- linden/indra/newview/llhudtext.h | 2 + linden/indra/newview/llinventorymodel.cpp | 536 +- linden/indra/newview/llinventorymodel.h | 38 +- linden/indra/newview/llinventoryview.cpp | 22 +- linden/indra/newview/llinventoryview.h | 4 +- linden/indra/newview/lljoystickbutton.cpp | 4 +- linden/indra/newview/llmanip.cpp | 8 +- linden/indra/newview/llmaniprotate.cpp | 12 +- linden/indra/newview/llmanipscale.cpp | 14 +- linden/indra/newview/llmaniptranslate.cpp | 44 +- linden/indra/newview/llmapresponders.cpp | 4 +- linden/indra/newview/llmemoryview.cpp | 2 +- linden/indra/newview/llmutelist.cpp | 45 +- linden/indra/newview/llmutelist.h | 3 +- linden/indra/newview/llnetmap.cpp | 26 +- linden/indra/newview/llnotify.cpp | 2 +- linden/indra/newview/llpaneldisplay.cpp | 66 +- linden/indra/newview/llpanelgeneral.cpp | 226 +- linden/indra/newview/llpanelgeneral.h | 35 +- linden/indra/newview/llpanelgrouplandmoney.cpp | 3 +- linden/indra/newview/llpanelinput.cpp | 87 +- linden/indra/newview/llpanelinput.h | 17 - linden/indra/newview/llpanellogin.cpp | 39 +- linden/indra/newview/llpanelmsgs.cpp | 22 +- linden/indra/newview/llpanelnetwork.cpp | 46 +- linden/indra/newview/llpanelnetwork.h | 24 +- linden/indra/newview/llpanelobject.cpp | 14 +- linden/indra/newview/llpanelweb.cpp | 174 +- linden/indra/newview/llpanelweb.h | 29 +- linden/indra/newview/llpolymesh.h | 2 +- linden/indra/newview/llprefschat.cpp | 60 +- linden/indra/newview/llprefsim.cpp | 99 +- linden/indra/newview/llprefsvoice.cpp | 285 +- linden/indra/newview/llprefsvoice.h | 47 +- linden/indra/newview/llpreviewscript.cpp | 15 +- linden/indra/newview/llpreviewscript.h | 4 +- linden/indra/newview/llpreviewsound.cpp | 3 +- linden/indra/newview/llpreviewtexture.cpp | 26 +- linden/indra/newview/llprogressview.cpp | 6 +- linden/indra/newview/llselectmgr.cpp | 17 +- linden/indra/newview/llselectmgr.h | 2 +- linden/indra/newview/llsky.cpp | 6 +- linden/indra/newview/llspatialpartition.cpp | 77 +- linden/indra/newview/llspatialpartition.h | 7 + linden/indra/newview/llsprite.cpp | 6 +- linden/indra/newview/llsprite.h | 2 +- linden/indra/newview/llstartup.cpp | 289 +- linden/indra/newview/llstatbar.cpp | 2 +- linden/indra/newview/llsurface.cpp | 6 +- linden/indra/newview/lltexlayer.cpp | 229 +- linden/indra/newview/lltexlayer.h | 39 +- linden/indra/newview/lltexturectrl.cpp | 4 +- linden/indra/newview/lltextureview.cpp | 16 +- linden/indra/newview/lltool.cpp | 6 + linden/indra/newview/lltoolbrush.cpp | 4 +- linden/indra/newview/lltoolmorph.cpp | 7 +- linden/indra/newview/lltoolplacer.cpp | 4 +- linden/indra/newview/lltoolselectrect.cpp | 2 +- linden/indra/newview/lltracker.cpp | 7 +- linden/indra/newview/lluserauth.cpp | 16 +- linden/indra/newview/llvelocitybar.cpp | 2 +- linden/indra/newview/llvieweraudio.cpp | 8 + linden/indra/newview/llviewerdisplay.cpp | 24 +- linden/indra/newview/llviewerimage.cpp | 99 +- linden/indra/newview/llviewerimage.h | 14 +- linden/indra/newview/llviewerimagelist.cpp | 27 +- linden/indra/newview/llviewerimagelist.h | 2 + linden/indra/newview/llviewerinventory.cpp | 41 +- linden/indra/newview/llviewerjoint.cpp | 71 +- linden/indra/newview/llviewerjointattachment.cpp | 2 +- linden/indra/newview/llviewerjointmesh.cpp | 18 +- linden/indra/newview/llviewermedia.cpp | 1 + linden/indra/newview/llviewermenu.cpp | 528 +- linden/indra/newview/llviewermenu.h | 1 - linden/indra/newview/llviewermenufile.cpp | 18 +- linden/indra/newview/llviewermessage.cpp | 16 +- linden/indra/newview/llviewernetwork.cpp | 20 + linden/indra/newview/llviewernetwork.h | 5 + linden/indra/newview/llviewerobject.cpp | 82 +- linden/indra/newview/llviewerobject.h | 10 +- linden/indra/newview/llviewerobjectlist.cpp | 34 +- linden/indra/newview/llviewerparcelmedia.cpp | 2 +- linden/indra/newview/llviewerparceloverlay.cpp | 8 +- linden/indra/newview/llviewerpartsim.cpp | 22 +- linden/indra/newview/llviewerpartsim.h | 6 +- linden/indra/newview/llviewerpartsource.cpp | 9 +- linden/indra/newview/llviewerregion.cpp | 17 +- linden/indra/newview/llviewerregion.h | 1 + linden/indra/newview/llviewershadermgr.cpp | 38 +- linden/indra/newview/llviewerstats.h | 3 + linden/indra/newview/llviewertexteditor.cpp | 3 +- linden/indra/newview/llviewerwindow.cpp | 254 +- linden/indra/newview/llviewerwindow.h | 9 + linden/indra/newview/llvoavatar.cpp | 189 +- linden/indra/newview/llvoavatar.h | 10 + linden/indra/newview/llvograss.cpp | 153 +- linden/indra/newview/llvograss.h | 10 + linden/indra/newview/llvoground.cpp | 2 +- linden/indra/newview/llvoicevisualizer.cpp | 17 +- linden/indra/newview/llvopartgroup.cpp | 61 +- linden/indra/newview/llvopartgroup.h | 17 + linden/indra/newview/llvosky.cpp | 80 +- linden/indra/newview/llvosurfacepatch.cpp | 81 + linden/indra/newview/llvosurfacepatch.h | 10 + linden/indra/newview/llvotextbubble.cpp | 2 +- linden/indra/newview/llvotree.cpp | 72 +- linden/indra/newview/llvotree.h | 11 + linden/indra/newview/llvovolume.cpp | 121 +- linden/indra/newview/llvovolume.h | 1 + linden/indra/newview/llvowlsky.cpp | 6 +- linden/indra/newview/llwaterparammanager.cpp | 85 +- linden/indra/newview/llwaterparammanager.h | 3 +- linden/indra/newview/llwebbrowserctrl.cpp | 4 +- linden/indra/newview/llwindebug.cpp | 63 + linden/indra/newview/llwindebug.h | 3 +- linden/indra/newview/llwlparammanager.cpp | 128 +- linden/indra/newview/llwlparammanager.h | 3 +- linden/indra/newview/llworld.cpp | 3 +- linden/indra/newview/llworldmap.cpp | 5 +- linden/indra/newview/llworldmapview.cpp | 40 +- linden/indra/newview/lsl_guide.html | 22078 ------------------- linden/indra/newview/pipeline.cpp | 187 +- linden/indra/newview/pipeline.h | 3 +- linden/indra/newview/res/viewerRes.rc | 8 +- .../newview/secondlife setup build dazzle.bat | 4 - .../indra/newview/skins/default/xui/de/alerts.xml | 12 +- .../skins/default/xui/de/floater_inventory.xml | 4 +- .../xui/de/floater_inventory_item_properties.xml | 6 +- .../skins/default/xui/de/floater_lsl_guide.xml | 2 +- .../default/xui/de/floater_preview_gesture.xml | 2 + .../skins/default/xui/de/floater_snapshot.xml | 4 +- .../newview/skins/default/xui/de/floater_tools.xml | 20 +- .../default/xui/de/panel_avatar_classified.xml | 2 +- .../skins/default/xui/de/panel_group_general.xml | 8 +- .../default/xui/de/panel_group_land_money.xml | 15 +- .../skins/default/xui/de/panel_group_notices.xml | 6 +- .../skins/default/xui/de/panel_group_roles.xml | 14 +- .../default/xui/de/panel_preferences_chat.xml | 2 +- .../default/xui/de/panel_preferences_input.xml | 12 +- .../indra/newview/skins/default/xui/de/strings.xml | 4 +- .../newview/skins/default/xui/en-us/alerts.xml | 43 +- .../skins/default/xui/en-us/floater_about.xml | 1 + .../skins/default/xui/en-us/floater_about_land.xml | 22 +- .../skins/default/xui/en-us/floater_beacons.xml | 24 + .../default/xui/en-us/floater_chat_history.xml | 9 +- .../default/xui/en-us/floater_instant_message.xml | 1 + .../xui/en-us/floater_instant_message_ad_hoc.xml | 1 + .../xui/en-us/floater_instant_message_group.xml | 1 + .../skins/default/xui/en-us/menu_pie_object.xml | 2 +- .../skins/default/xui/en-us/menu_viewer.xml | 104 +- .../newview/skins/default/xui/en-us/notify.xml | 2 +- .../skins/default/xui/en-us/panel_chat_bar.xml | 11 +- .../default/xui/en-us/panel_preferences_chat.xml | 24 +- .../xui/en-us/panel_preferences_general.xml | 59 +- .../default/xui/en-us/panel_preferences_im.xml | 20 +- .../default/xui/en-us/panel_preferences_input.xml | 38 +- .../xui/en-us/panel_preferences_network.xml | 8 +- .../default/xui/en-us/panel_preferences_popups.xml | 4 +- .../default/xui/en-us/panel_preferences_voice.xml | 10 +- .../default/xui/en-us/panel_preferences_web.xml | 8 +- .../skins/default/xui/en-us/panel_status_bar.xml | 2 +- .../indra/newview/skins/default/xui/es/alerts.xml | 29 +- .../skins/default/xui/es/floater_about_land.xml | 21 - .../indra/newview/skins/default/xui/fr/alerts.xml | 1865 +- .../newview/skins/default/xui/fr/floater_about.xml | 4 +- .../skins/default/xui/fr/floater_about_land.xml | 343 +- .../default/xui/fr/floater_active_speakers.xml | 6 +- .../default/xui/fr/floater_animation_preview.xml | 40 +- .../skins/default/xui/fr/floater_avatar_picker.xml | 10 +- .../skins/default/xui/fr/floater_buy_contents.xml | 10 +- .../skins/default/xui/fr/floater_buy_currency.xml | 26 +- .../skins/default/xui/fr/floater_buy_land.xml | 55 +- .../skins/default/xui/fr/floater_buy_object.xml | 8 +- .../skins/default/xui/fr/floater_chat_history.xml | 15 +- .../skins/default/xui/fr/floater_color_picker.xml | 16 +- .../skins/default/xui/fr/floater_customize.xml | 540 +- .../skins/default/xui/fr/floater_directory.xml | 196 +- .../skins/default/xui/fr/floater_env_settings.xml | 20 +- .../skins/default/xui/fr/floater_god_tools.xml | 116 +- .../skins/default/xui/fr/floater_group_info.xml | 126 +- .../default/xui/fr/floater_hardware_settings.xml | 19 +- .../skins/default/xui/fr/floater_image_preview.xml | 8 +- .../skins/default/xui/fr/floater_import.xml | 6 +- .../default/xui/fr/floater_instant_message.xml | 18 +- .../xui/fr/floater_instant_message_ad_hoc.xml | 11 +- .../xui/fr/floater_instant_message_group.xml | 14 +- .../skins/default/xui/fr/floater_inventory.xml | 74 +- .../xui/fr/floater_inventory_item_properties.xml | 29 +- .../xui/fr/floater_inventory_view_finder.xml | 40 +- .../skins/default/xui/fr/floater_lagmeter.xml | 18 +- .../skins/default/xui/fr/floater_media_browser.xml | 22 +- .../skins/default/xui/fr/floater_moveview.xml | 23 +- .../skins/default/xui/fr/floater_mute_object.xml | 10 +- .../default/xui/fr/floater_name_description.xml | 6 +- .../default/xui/fr/floater_new_outfit_dialog.xml | 129 +- .../newview/skins/default/xui/fr/floater_pay.xml | 24 +- .../skins/default/xui/fr/floater_pay_object.xml | 28 +- .../default/xui/fr/floater_preview_gesture.xml | 2 + .../default/xui/fr/floater_price_for_listing.xml | 8 +- .../skins/default/xui/fr/floater_region_info.xml | 4 +- .../skins/default/xui/fr/floater_report_abuse.xml | 37 +- .../skins/default/xui/fr/floater_report_bug.xml | 20 +- .../skins/default/xui/fr/floater_sell_land.xml | 14 +- .../xui/fr/floater_skin_preview_template.xml | 23 +- .../skins/default/xui/fr/floater_snapshot.xml | 41 +- .../skins/default/xui/fr/floater_sound_preview.xml | 6 +- .../skins/default/xui/fr/floater_texture_ctrl.xml | 26 +- .../newview/skins/default/xui/fr/floater_tools.xml | 354 +- .../skins/default/xui/fr/floater_top_objects.xml | 28 +- .../skins/default/xui/fr/floater_world_map.xml | 95 +- .../skins/default/xui/fr/menu_inventory.xml | 125 +- .../skins/default/xui/fr/menu_pie_avatar.xml | 26 +- .../newview/skins/default/xui/fr/menu_pie_land.xml | 16 +- .../newview/skins/default/xui/fr/menu_viewer.xml | 476 +- .../newview/skins/default/xui/fr/mime_types.xml | 8 +- .../indra/newview/skins/default/xui/fr/notify.xml | 60 +- .../newview/skins/default/xui/fr/panel_audio.xml | 16 +- .../skins/default/xui/fr/panel_audio_device.xml | 9 +- .../newview/skins/default/xui/fr/panel_avatar.xml | 124 +- .../default/xui/fr/panel_avatar_classified.xml | 32 +- .../skins/default/xui/fr/panel_classified.xml | 22 +- .../newview/skins/default/xui/fr/panel_friends.xml | 37 +- .../skins/default/xui/fr/panel_group_general.xml | 52 +- .../skins/default/xui/fr/panel_group_invite.xml | 19 +- .../default/xui/fr/panel_group_land_money.xml | 38 +- .../skins/default/xui/fr/panel_group_notices.xml | 70 +- .../skins/default/xui/fr/panel_group_roles.xml | 86 +- .../skins/default/xui/fr/panel_group_voting.xml | 44 +- .../newview/skins/default/xui/fr/panel_groups.xml | 26 +- .../newview/skins/default/xui/fr/panel_login.xml | 16 +- .../skins/default/xui/fr/panel_master_volume.xml | 7 +- .../skins/default/xui/fr/panel_media_controls.xml | 24 +- .../skins/default/xui/fr/panel_media_remote.xml | 12 +- .../default/xui/fr/panel_media_remote_expanded.xml | 6 +- .../skins/default/xui/fr/panel_overlaybar.xml | 15 +- .../newview/skins/default/xui/fr/panel_place.xml | 20 +- .../skins/default/xui/fr/panel_place_small.xml | 24 +- .../default/xui/fr/panel_preferences_audio.xml | 39 +- .../default/xui/fr/panel_preferences_chat.xml | 75 +- .../default/xui/fr/panel_preferences_general.xml | 89 +- .../default/xui/fr/panel_preferences_graphics1.xml | 94 +- .../skins/default/xui/fr/panel_preferences_im.xml | 44 +- .../default/xui/fr/panel_preferences_input.xml | 31 +- .../default/xui/fr/panel_preferences_network.xml | 21 +- .../default/xui/fr/panel_preferences_popups.xml | 26 +- .../default/xui/fr/panel_preferences_voice.xml | 20 +- .../skins/default/xui/fr/panel_preferences_web.xml | 21 +- .../skins/default/xui/fr/panel_region_debug.xml | 62 +- .../skins/default/xui/fr/panel_region_estate.xml | 74 +- .../skins/default/xui/fr/panel_region_general.xml | 57 +- .../skins/default/xui/fr/panel_region_terrain.xml | 41 +- .../default/xui/fr/panel_speaker_controls.xml | 12 +- .../skins/default/xui/fr/panel_status_bar.xml | 42 +- .../newview/skins/default/xui/fr/panel_toolbar.xml | 25 +- .../skins/default/xui/fr/panel_voice_enable.xml | 4 +- .../skins/default/xui/fr/panel_voice_options.xml | 14 +- .../indra/newview/skins/default/xui/fr/strings.xml | 12 +- .../skins/default/xui/ja/floater_about_land.xml | 3 - .../default/xui/ja/floater_preview_gesture.xml | 2 + .../newview/skins/default/xui/ja/floater_tools.xml | 2 +- .../newview/skins/default/xui/ja/panel_avatar.xml | 2 +- .../default/xui/ja/panel_preferences_chat.xml | 2 +- .../default/xui/ja/panel_preferences_input.xml | 12 +- .../default/xui/ja/panel_preferences_network.xml | 2 +- .../indra/newview/skins/default/xui/ja/strings.xml | 4 +- .../skins/default/xui/ko/floater_about_land.xml | 3 - .../default/xui/ko/floater_preview_gesture.xml | 2 + .../default/xui/ko/panel_preferences_chat.xml | 2 +- .../default/xui/ko/panel_preferences_input.xml | 12 +- .../indra/newview/skins/default/xui/pt/alerts.xml | 2 +- .../indra/newview/skins/default/xui/zh/alerts.xml | 14 - .../skins/default/xui/zh/floater_about_land.xml | 21 - .../skins/default/xui/zh/need_to_translate.xml | 908 - .../skins/silver/xui/en-us/floater_about_land.xml | 22 +- .../skins/silver/xui/en-us/panel_status_bar.xml | 2 +- linden/indra/newview/viewer_manifest.py | 114 +- linden/indra/test/CMakeLists.txt | 8 + linden/indra/test/llapp_tut.cpp | 2 +- linden/indra/test/llblowfish_tut.cpp | 12 +- linden/indra/test/lliohttpserver_tut.cpp | 4 +- linden/indra/test/llmodularmath_tut.cpp | 80 + linden/indra/test/llsd_new_tut.cpp | 11 +- linden/indra/test/llstring_tut.cpp | 7 +- linden/indra/test/math.cpp | 6 + linden/indra/test/v4math_tut.cpp | 15 +- .../win_crash_logger/llcrashloggerwindows.cpp | 2 +- linden/indra/win_crash_logger/win_crash_logger.cpp | 49 +- linden/indra/win_updater/updater.cpp | 103 +- linden/install.xml | 642 +- linden/scripts/install.py | 50 +- linden/scripts/template_verifier.py | 32 +- 563 files changed, 14309 insertions(+), 33421 deletions(-) create mode 100644 linden/indra/cmake/DBusGlib.cmake delete mode 100644 linden/indra/cmake/LLPhysics.cmake delete mode 100644 linden/indra/lib/python/indra/ipc/saranwrap.py create mode 100644 linden/indra/lib/python/indra/util/iterators.py create mode 100755 linden/indra/lib/python/indra/util/iterators_test.py create mode 100755 linden/indra/lib/python/indra/util/llperformance.py create mode 100755 linden/indra/lib/python/indra/util/simperf_host_xml_parser.py create mode 100755 linden/indra/lib/python/indra/util/simperf_oprof_interface.py create mode 100755 linden/indra/lib/python/indra/util/simperf_proc_interface.py create mode 100644 linden/indra/llmath/llmodularmath.h create mode 100644 linden/indra/newview/installers/windows/FILES_ARE_UNICODE_UTF-16LE.txt create mode 100644 linden/indra/newview/installers/windows/lang_es.nsi create mode 100644 linden/indra/newview/installers/windows/lang_fr.nsi create mode 100644 linden/indra/newview/installers/windows/lang_it.nsi create mode 100644 linden/indra/newview/installers/windows/lang_nl.nsi create mode 100644 linden/indra/newview/installers/windows/lang_pt-br.nsi create mode 100644 linden/indra/newview/installers/windows/lang_zh.nsi create mode 100644 linden/indra/newview/installers/windows/language_menu.nsi create mode 100644 linden/indra/newview/llappviewerlinux_api.h create mode 100644 linden/indra/newview/llappviewerlinux_api.xml create mode 100644 linden/indra/newview/llappviewerlinux_api_dbus.cpp create mode 100644 linden/indra/newview/llappviewerlinux_api_dbus.h create mode 100644 linden/indra/newview/llappviewerlinux_api_dbus_syms_raw.inc create mode 100644 linden/indra/newview/llfloaterbeacons.cpp create mode 100644 linden/indra/newview/llfloaterbeacons.h create mode 100644 linden/indra/newview/llhomelocationresponder.cpp create mode 100644 linden/indra/newview/llhomelocationresponder.h delete mode 100644 linden/indra/newview/lsl_guide.html delete mode 100644 linden/indra/newview/secondlife setup build dazzle.bat create mode 100644 linden/indra/newview/skins/default/xui/en-us/floater_beacons.xml delete mode 100644 linden/indra/newview/skins/default/xui/zh/need_to_translate.xml create mode 100644 linden/indra/test/llmodularmath_tut.cpp (limited to 'linden') diff --git a/linden/doc/contributions.txt b/linden/doc/contributions.txt index ea5ba5d..54aad6e 100644 --- a/linden/doc/contributions.txt +++ b/linden/doc/contributions.txt @@ -1,3 +1,4 @@ + Linden Lab would like to acknowledge source code contributions from the following residents. The Second Life resident name is given below, along with the issue identifier corresponding to the patches we've @@ -10,10 +11,12 @@ Able Whitman VWR-1691 VWR-1735 Adam Marker - VWR-2755 + VWR-2755 Aimee Trescothick + VWR-3336 VWR-3903 VWR-4083 + VWR-9255 Alejandro Rosenthal VWR-1184 Alissa Sabre @@ -58,6 +61,8 @@ Angus Boyd VWR-592 Argent Stonecutter VWR-68 +Asuka Neely + VWR-3434 Balp Allen VWR-4157 Benja Kepler @@ -79,6 +84,7 @@ bushing Spatula VWR-424 Carjay McGinnis VWR-3737 + VWR-4070 VWR-6154 Catherine Pfeffer VWR-1282 @@ -184,10 +190,12 @@ Jacek Antonelli VWR-188 VWR-427 VWR-597 + VWR-2054 VWR-2448 VWR-3605 JB Kraft VWR-5283 + VWR-7802 Joghert LeSabre VWR-64 Kage Pixel @@ -205,13 +213,18 @@ Matthew Dowd VWR-1761 McCabe Maxsted VWR-1318 - VWR-7893 + VWR-7893 + VWR-8689 Michelle2 Zenovka VWR-2652 VWR-2834 VWR-3749 + VWR-4022 VWR-4506 + VWR-4981 VWR-7831 + VWR-8889 + VWR-8310 VWR-4022 Mm Alder VWR-3777 diff --git a/linden/etc/message.xml b/linden/etc/message.xml index 80dc560..d833074 100644 --- a/linden/etc/message.xml +++ b/linden/etc/message.xml @@ -441,6 +441,30 @@ true + EnableSimulator + + flavor + llsd + trusted-sender + true + + + TeleportFinish + + flavor + llsd + trusted-sender + true + + + CrossedRegion + + flavor + llsd + trusted-sender + true + + ScriptRunningReply @@ -564,6 +588,18 @@ true FetchInventoryDescendents + false + + WebFetchInventoryDescendents + true + + FetchInventory + true + + FetchLibDescendents + true + + FetchLib true diff --git a/linden/indra/CMakeLists.txt b/linden/indra/CMakeLists.txt index fac2afa..c473b94 100644 --- a/linden/indra/CMakeLists.txt +++ b/linden/indra/CMakeLists.txt @@ -19,6 +19,10 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") include(Variables) +if (DARWIN) + cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR) +endif (DARWIN) + if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type. One of: Debug Release RelWithDebInfo" FORCE) diff --git a/linden/indra/cmake/00-Common.cmake b/linden/indra/cmake/00-Common.cmake index 240853a..bf2d2c3 100644 --- a/linden/indra/cmake/00-Common.cmake +++ b/linden/indra/cmake/00-Common.cmake @@ -49,6 +49,10 @@ if (WINDOWS) ) if(MSVC80 OR MSVC90) + set(CMAKE_CXX_FLAGS_RELEASE + "${CMAKE_CXX_FLAGS_RELEASE} -D_SECURE_STL=0 -D_HAS_ITERATOR_DEBUGGING=0" + CACHE STRING "C++ compiler release options" FORCE) + add_definitions( /Zc:wchar_t- ) @@ -165,6 +169,10 @@ if (DARWIN) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-branch") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlong-branch") + # NOTE: it's critical that the optimization flag is put in front. + # NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered. + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O0 ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O0 ${CMAKE_C_FLAGS_RELWITHDEBINFO}") endif (DARWIN) diff --git a/linden/indra/cmake/APR.cmake b/linden/indra/cmake/APR.cmake index 2a96d70..523d8ee 100644 --- a/linden/indra/cmake/APR.cmake +++ b/linden/indra/cmake/APR.cmake @@ -15,23 +15,17 @@ if (STANDALONE) else (STANDALONE) use_prebuilt_binary(apr_suite) if (WINDOWS) - set(WINLIBS_PREBUILT_DEBUG_DIR - ${CMAKE_SOURCE_DIR}/../libraries/i686-win32/lib/debug - ) - set(WINLIBS_PREBUILT_RELEASE_DIR - ${CMAKE_SOURCE_DIR}/../libraries/i686-win32/lib/release - ) set(APR_LIBRARIES - debug ${WINLIBS_PREBUILT_DEBUG_DIR}/apr-1.lib - optimized ${WINLIBS_PREBUILT_RELEASE_DIR}/apr-1.lib + debug ${ARCH_PREBUILT_DIRS_DEBUG}/apr-1.lib + optimized ${ARCH_PREBUILT_DIRS_RELEASE}/apr-1.lib ) set(APRUTIL_LIBRARIES - debug ${WINLIBS_PREBUILT_DEBUG_DIR}/aprutil-1.lib - optimized ${WINLIBS_PREBUILT_RELEASE_DIR}/aprutil-1.lib + debug ${ARCH_PREBUILT_DIRS_DEBUG}/aprutil-1.lib + optimized ${ARCH_PREBUILT_DIRS_RELEASE}/aprutil-1.lib ) set(APRICONV_LIBRARIES - debug ${WINLIBS_PREBUILT_DEBUG_DIR}/apriconv-1.lib - optimized ${WINLIBS_PREBUILT_RELEASE_DIR}/apriconv-1.lib + debug ${ARCH_PREBUILT_DIRS_DEBUG}/apriconv-1.lib + optimized ${ARCH_PREBUILT_DIRS_RELEASE}/apriconv-1.lib ) elseif (DARWIN) set(APR_LIBRARIES @@ -42,10 +36,11 @@ else (STANDALONE) debug ${ARCH_PREBUILT_DIRS_DEBUG}/libaprutil-1.a optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.a ) - set(APRICONV_LIBRARIES apriconv-1) + set(APRICONV_LIBRARIES iconv) else (WINDOWS) set(APR_LIBRARIES apr-1) set(APRUTIL_LIBRARIES aprutil-1) + set(APRICONV_LIBRARIES iconv) endif (WINDOWS) set(APR_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/apr-1) diff --git a/linden/indra/cmake/CopyWinLibs.cmake b/linden/indra/cmake/CopyWinLibs.cmake index 345761a..b74ce4f 100644 --- a/linden/indra/cmake/CopyWinLibs.cmake +++ b/linden/indra/cmake/CopyWinLibs.cmake @@ -148,6 +148,61 @@ else(EXISTS ${internal_llkdu_path}) endif (EXISTS ${internal_llkdu_path}) +# Copy MS C runtime dlls, required for packaging. +# *TODO - Adapt this to support VC9 +if (MSVC80) + FIND_PATH(debug_msvc8_redist_path msvcr80d.dll + PATHS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VC;ProductDir]/redist/Debug_NonRedist/x86/Microsoft.VC80.DebugCRT + ) + + if(EXISTS ${debug_msvc8_redist_path}) + set(debug_msvc8_files + msvcr80d.dll + msvcp80d.dll + Microsoft.VC80.DebugCRT.manifest + ) + + copy_if_different( + ${debug_msvc8_redist_path} + "${CMAKE_CURRENT_BINARY_DIR}/Debug" + out_targets + ${debug_msvc8_files} + ) + set(all_targets ${all_targets} ${out_targets}) + endif (EXISTS ${debug_msvc8_redist_path}) + + FIND_PATH(release_msvc8_redist_path msvcr80.dll + PATHS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VC;ProductDir]/redist/x86/Microsoft.VC80.CRT + ) + + if(EXISTS ${release_msvc8_redist_path}) + set(release_msvc8_files + msvcr80.dll + msvcp80.dll + Microsoft.VC80.CRT.manifest + ) + + copy_if_different( + ${release_msvc8_redist_path} + "${CMAKE_CURRENT_BINARY_DIR}/Release" + out_targets + ${release_msvc8_files} + ) + set(all_targets ${all_targets} ${out_targets}) + + copy_if_different( + ${release_msvc8_redist_path} + "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo" + out_targets + ${release_msvc8_files} + ) + set(all_targets ${all_targets} ${out_targets}) + + endif (EXISTS ${release_msvc8_redist_path}) +endif (MSVC80) + add_custom_target(copy_win_libs ALL DEPENDS ${all_targets}) if(EXISTS ${internal_llkdu_path}) diff --git a/linden/indra/cmake/DBusGlib.cmake b/linden/indra/cmake/DBusGlib.cmake new file mode 100644 index 0000000..cfc4ccd --- /dev/null +++ b/linden/indra/cmake/DBusGlib.cmake @@ -0,0 +1,29 @@ +# -*- cmake -*- +include(Prebuilt) + +if (STANDALONE) + include(FindPkgConfig) + + pkg_check_modules(DBUSGLIB REQUIRED dbus-glib-1) + +elseif (LINUX) + use_prebuilt_binary(dbusglib) + set(DBUSGLIB_FOUND ON FORCE BOOL) + set(DBUSGLIB_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/glib-2.0 + ) + # We don't need to explicitly link against dbus-glib itself, because + # the viewer probes for the system's copy at runtime. + set(DBUSGLIB_LIBRARIES + gobject-2.0 + glib-2.0 + ) +endif (STANDALONE) + +if (DBUSGLIB_FOUND) + set(DBUSGLIB ON CACHE BOOL "Build with dbus-glib message bus support.") +endif (DBUSGLIB_FOUND) + +if (DBUSGLIB) + add_definitions(-DLL_DBUS_ENABLED=1) +endif (DBUSGLIB) diff --git a/linden/indra/cmake/DirectX.cmake b/linden/indra/cmake/DirectX.cmake index 4d2d5e0..d406f37 100644 --- a/linden/indra/cmake/DirectX.cmake +++ b/linden/indra/cmake/DirectX.cmake @@ -3,12 +3,13 @@ if (VIEWER AND WINDOWS) find_path(DIRECTX_INCLUDE_DIR dxdiag.h "$ENV{DXSDK_DIR}/Include" - "C:/Program Files/Microsoft DirectX SDK (June 2008)/Include" - "C:/Program Files/Microsoft DirectX SDK (March 2008)/Include" - "C:/Program Files/Microsoft DirectX SDK (November 2007)/Include" - "C:/Program Files/Microsoft DirectX SDK (August 2007)/Include" + "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2008)/Include" + "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2008)/Include" + "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (March 2008)/Include" + "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (November 2007)/Include" + "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2007)/Include" "C:/DX90SDK/Include" - "C:/Program Files/DX90SDK/Include" + "$ENV{PROGRAMFILES}/DX90SDK/Include" ) if (DIRECTX_INCLUDE_DIR) include_directories(${DIRECTX_INCLUDE_DIR}) @@ -22,12 +23,13 @@ if (VIEWER AND WINDOWS) find_path(DIRECTX_LIBRARY_DIR dxguid.lib "$ENV{DXSDK_DIR}/Lib/x86" - "C:/Program Files/Microsoft DirectX SDK (June 2008)/Lib/x86" - "C:/Program Files/Microsoft DirectX SDK (March 2008)/Lib/x86" - "C:/Program Files/Microsoft DirectX SDK (November 2007)/Lib/x86" - "C:/Program Files/Microsoft DirectX SDK (August 2007)/Lib/x86" + "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2008)/Lib/x86" + "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2008)/Lib/x86" + "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (March 2008)/Lib/x86" + "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (November 2007)/Lib/x86" + "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2007)/Lib/x86" "C:/DX90SDK/Lib" - "C:/Program Files/DX90SDK/Lib" + "$ENV{PROGRAMFILES}/DX90SDK/Lib" ) if (DIRECTX_LIBRARY_DIR) if (DIRECTX_FIND_QUIETLY) diff --git a/linden/indra/cmake/FindMono.cmake b/linden/indra/cmake/FindMono.cmake index f0a0705..c36d725 100644 --- a/linden/indra/cmake/FindMono.cmake +++ b/linden/indra/cmake/FindMono.cmake @@ -14,29 +14,29 @@ # Removed the check for gmcs FIND_PROGRAM (MONO_EXECUTABLE mono - "C:/Program Files/Mono-1.9.1/bin" - "C:/Program Files/Mono-1.2.6/bin" + "$ENV{PROGRAMFILES}/Mono-1.9.1/bin" + "$ENV{PROGRAMFILES}/Mono-1.2.6/bin" /bin /usr/bin /usr/local/bin ) FIND_PROGRAM (MCS_EXECUTABLE mcs - "C:/Program Files/Mono-1.9.1/bin" - "C:/Program Files/Mono-1.2.6/bin" + "$ENV{PROGRAMFILES}/Mono-1.9.1/bin" + "$ENV{PROGRAMFILES}/Mono-1.2.6/bin" /bin /usr/bin /usr/local/bin ) FIND_PROGRAM (GMCS_EXECUTABLE gmcs - "C:/Program Files/Mono-1.9.1/bin" - "C:/Program Files/Mono-1.2.6/bin" + "$ENV{PROGRAMFILES}/Mono-1.9.1/bin" + "$ENV{PROGRAMFILES}/Mono-1.2.6/bin" /bin /usr/bin /usr/local/bin ) FIND_PROGRAM (GACUTIL_EXECUTABLE gacutil - "C:/Program Files/Mono-1.9.1/bin" - "C:/Program Files/Mono-1.2.6/bin" + "$ENV{PROGRAMFILES}/Mono-1.9.1/bin" + "$ENV{PROGRAMFILES}/Mono-1.2.6/bin" /bin /usr/bin /usr/local/bin @@ -44,7 +44,7 @@ FIND_PROGRAM (GACUTIL_EXECUTABLE gacutil FIND_PROGRAM (ILASM_EXECUTABLE ilasm NO_DEFAULT_PATH - PATHS "C:/Program Files/Mono-1.9.1/bin" "C:/Apps/Mono-1.2.6/bin" "C:/Program Files/Mono-1.2.6/bin" /bin /usr/bin /usr/local/bin + PATHS "$ENV{PROGRAMFILES}/Mono-1.9.1/bin" "$ENV{PROGRAMFILES}/Mono-1.2.6/bin" /bin /usr/bin /usr/local/bin ) SET (MONO_FOUND FALSE) diff --git a/linden/indra/cmake/GooglePerfTools.cmake b/linden/indra/cmake/GooglePerfTools.cmake index 9b3eca0..25e9f6d 100644 --- a/linden/indra/cmake/GooglePerfTools.cmake +++ b/linden/indra/cmake/GooglePerfTools.cmake @@ -19,10 +19,14 @@ if (GOOGLE_PERFTOOLS_FOUND) set(USE_GOOGLE_PERFTOOLS ON CACHE BOOL "Build with Google PerfTools support.") endif (GOOGLE_PERFTOOLS_FOUND) +# XXX Disable temporarily, until we have compilation issues on 64-bit +# Etch sorted. +set(USE_GOOGLE_PERFTOOLS OFF) + if (USE_GOOGLE_PERFTOOLS) set(TCMALLOC_FLAG -DLL_USE_TCMALLOC=1) include_directories(${GOOGLE_PERFTOOLS_INCLUDE_DIR}) - set(GOOGLE_PERFTOOLS_LIBRARIES ${TCMALLOC_LIBRARIES} ${STACKTRACE_LIBRARIES}) + set(GOOGLE_PERFTOOLS_LIBRARIES ${TCMALLOC_LIBRARIES} ${STACKTRACE_LIBRARIES} ${PROFILER_LIBRARIES}) else (USE_GOOGLE_PERFTOOLS) set(TCMALLOC_FLAG -ULL_USE_TCMALLOC) endif (USE_GOOGLE_PERFTOOLS) diff --git a/linden/indra/cmake/LLAudio.cmake b/linden/indra/cmake/LLAudio.cmake index 7b9f254..eff643d 100644 --- a/linden/indra/cmake/LLAudio.cmake +++ b/linden/indra/cmake/LLAudio.cmake @@ -6,10 +6,4 @@ set(LLAUDIO_INCLUDE_DIRS ${LIBS_OPEN_DIR}/llaudio ) -set(LLAUDIO_LIBRARIES - llaudio - ${VORBISENC_LIBRARIES} - ${VORBISFILE_LIBRARIES} - ${VORBIS_LIBRARIES} - ${OGG_LIBRARIES} - ) +set(LLAUDIO_LIBRARIES llaudio) diff --git a/linden/indra/cmake/LLCharacter.cmake b/linden/indra/cmake/LLCharacter.cmake index c74092c..9b2f5c4 100644 --- a/linden/indra/cmake/LLCharacter.cmake +++ b/linden/indra/cmake/LLCharacter.cmake @@ -4,6 +4,4 @@ set(LLCHARACTER_INCLUDE_DIRS ${LIBS_OPEN_DIR}/llcharacter ) -set(LLCHARACTER_LIBRARIES - llcharacter - ) +set(LLCHARACTER_LIBRARIES llcharacter) diff --git a/linden/indra/cmake/LLCommon.cmake b/linden/indra/cmake/LLCommon.cmake index f4b251e..410766e 100644 --- a/linden/indra/cmake/LLCommon.cmake +++ b/linden/indra/cmake/LLCommon.cmake @@ -12,10 +12,4 @@ set(LLCOMMON_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ) -set(LLCOMMON_LIBRARIES - llcommon - ${APRUTIL_LIBRARIES} - ${APR_LIBRARIES} - ${EXPAT_LIBRARIES} - ${ZLIB_LIBRARIES} - ) +set(LLCOMMON_LIBRARIES llcommon) diff --git a/linden/indra/cmake/LLCrashLogger.cmake b/linden/indra/cmake/LLCrashLogger.cmake index 7b362d0..f2cb83e 100644 --- a/linden/indra/cmake/LLCrashLogger.cmake +++ b/linden/indra/cmake/LLCrashLogger.cmake @@ -4,6 +4,4 @@ set(LLCRASHLOGGER_INCLUDE_DIRS ${LIBS_OPEN_DIR}/llcrashlogger ) -set(LLCRASHLOGGER_LIBRARIES - llcrashlogger - ) +set(LLCRASHLOGGER_LIBRARIES llcrashlogger) diff --git a/linden/indra/cmake/LLDatabase.cmake b/linden/indra/cmake/LLDatabase.cmake index c3cf622..6526101 100644 --- a/linden/indra/cmake/LLDatabase.cmake +++ b/linden/indra/cmake/LLDatabase.cmake @@ -7,7 +7,4 @@ set(LLDATABASE_INCLUDE_DIRS ${MYSQL_INCLUDE_DIR} ) -set(LLDATABASE_LIBRARIES - lldatabase - ${MYSQL_LIBRARIES} - ) +set(LLDATABASE_LIBRARIES lldatabase) diff --git a/linden/indra/cmake/LLImage.cmake b/linden/indra/cmake/LLImage.cmake index 8874fa5..ec3da89 100644 --- a/linden/indra/cmake/LLImage.cmake +++ b/linden/indra/cmake/LLImage.cmake @@ -8,8 +8,4 @@ set(LLIMAGE_INCLUDE_DIRS ${JPEG_INCLUDE_DIRS} ) -set(LLIMAGE_LIBRARIES - llimage - ${JPEG_LIBRARIES} - ${PNG_LIBRARIES} - ) +set(LLIMAGE_LIBRARIES llimage) diff --git a/linden/indra/cmake/LLImageJ2COJ.cmake b/linden/indra/cmake/LLImageJ2COJ.cmake index 91973e0..1bcf205 100644 --- a/linden/indra/cmake/LLImageJ2COJ.cmake +++ b/linden/indra/cmake/LLImageJ2COJ.cmake @@ -2,7 +2,4 @@ include(OpenJPEG) -set(LLIMAGEJ2COJ_LIBRARIES - llimagej2coj - ${OPENJPEG_LIBRARIES} - ) +set(LLIMAGEJ2COJ_LIBRARIES llimagej2coj) diff --git a/linden/indra/cmake/LLInventory.cmake b/linden/indra/cmake/LLInventory.cmake index 7d5f492..c3dc077 100644 --- a/linden/indra/cmake/LLInventory.cmake +++ b/linden/indra/cmake/LLInventory.cmake @@ -4,6 +4,4 @@ set(LLINVENTORY_INCLUDE_DIRS ${LIBS_OPEN_DIR}/llinventory ) -set(LLINVENTORY_LIBRARIES - llinventory - ) +set(LLINVENTORY_LIBRARIES llinventory) diff --git a/linden/indra/cmake/LLKDU.cmake b/linden/indra/cmake/LLKDU.cmake index a02b5d9..f103dcf 100644 --- a/linden/indra/cmake/LLKDU.cmake +++ b/linden/indra/cmake/LLKDU.cmake @@ -5,8 +5,6 @@ if (NOT STANDALONE AND EXISTS ${LIBS_CLOSED_DIR}/llkdu) use_prebuilt_binary(kdu) if (WINDOWS) set(KDU_LIBRARY debug kdu_cored optimized kdu_core) - elseif (LINUX) - set(KDU_LIBRARY kdu_v42R) else (WINDOWS) set(KDU_LIBRARY kdu) endif (WINDOWS) diff --git a/linden/indra/cmake/LLMath.cmake b/linden/indra/cmake/LLMath.cmake index 8afd45e..893920a 100644 --- a/linden/indra/cmake/LLMath.cmake +++ b/linden/indra/cmake/LLMath.cmake @@ -4,6 +4,4 @@ set(LLMATH_INCLUDE_DIRS ${LIBS_OPEN_DIR}/llmath ) -set(LLMATH_LIBRARIES - llmath - ) +set(LLMATH_LIBRARIES llmath) diff --git a/linden/indra/cmake/LLMedia.cmake b/linden/indra/cmake/LLMedia.cmake index b7bf11c..91c7818 100644 --- a/linden/indra/cmake/LLMedia.cmake +++ b/linden/indra/cmake/LLMedia.cmake @@ -7,9 +7,4 @@ set(LLMEDIA_INCLUDE_DIRS ${LIBS_OPEN_DIR}/llmedia ) -set(LLMEDIA_LIBRARIES - llmedia - ${GSTREAMER_LIBRARIES} - ${GSTREAMER_PLUGINS_BASE_LIBRARIES} - ${QUICKTIME_LIBRARY} - ) +set(LLMEDIA_LIBRARIES llmedia) diff --git a/linden/indra/cmake/LLMessage.cmake b/linden/indra/cmake/LLMessage.cmake index 1cea03a..0143d04 100644 --- a/linden/indra/cmake/LLMessage.cmake +++ b/linden/indra/cmake/LLMessage.cmake @@ -12,11 +12,4 @@ set(LLMESSAGE_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIRS} ) -set(LLMESSAGE_LIBRARIES - llmessage - ${CURL_LIBRARIES} - ${CARES_LIBRARIES} - ${OPENSSL_LIBRARIES} - ${CRYPTO_LIBRARIES} - ${XMLRPCEPI_LIBRARIES} - ) +set(LLMESSAGE_LIBRARIES llmessage) diff --git a/linden/indra/cmake/LLPhysics.cmake b/linden/indra/cmake/LLPhysics.cmake deleted file mode 100644 index 3ae390e..0000000 --- a/linden/indra/cmake/LLPhysics.cmake +++ /dev/null @@ -1,76 +0,0 @@ -# -*- cmake -*- -include(Prebuilt) - -use_prebuilt_binary(havok) - -set(HAVOK_VERSION 460) - -set(LLPHYSICS_INCLUDE_DIRS - ${LIBS_SERVER_DIR}/llphysics - ${LIBS_PREBUILT_DIR}/include/havok/hk${HAVOK_VERSION}/common - ${LIBS_PREBUILT_DIR}/include/havok/hk${HAVOK_VERSION}/physics - ) - -add_definitions(-DLL_CURRENT_HAVOK_VERSION=${HAVOK_VERSION}) - -if (LINUX OR DARWIN) - if (DARWIN) - link_directories( - ${LIBS_PREBUILT_DIR}/universal-darwin/lib_release/havok/hk460 - ) - else (DARWIN) - link_directories( - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib_release/havok/hk460 - ) - endif (DARWIN) - - set(LLPHYSICS_LIBRARIES - llphysics - hkcompat - hkutilities - hkvisualize - hkdynamics - hkvehicle - hkcollide - hkinternal - hkconstraintsolver - hkmath - hkscenedata - hkserialize - hkgraphicsogl - hkgraphicsbridge - hkgraphics - hkdemoframework - hkbase - ) -elseif (WINDOWS) - if (MSVC71) - set(HK_DEBUG ${WINLIBS_PREBUILT_DEBUG_DIR}/havok/hk460) - set(HK_RELEASE ${WINLIBS_PREBUILT_RELEASE_DIR}/havok/hk460) - else (MSVC71) - set(HK_DEBUG ${WINLIBS_PREBUILT_DEBUG_DIR}/havok/hk460_net_8-0) - set(HK_RELEASE ${WINLIBS_PREBUILT_RELEASE_DIR}/havok/hk460_net_8-0) - endif (MSVC71) - - set(HAVOK_LIBS - hkbase - hkdynamics - hkmath - hkcollide - hkutilities - hkvisualize - hkinternal - hkconstraintsolver - hkcompat - hkserialize - hkvehicle - hkscenedata - ) - - set(LLPHYSICS_LIBRARIES llphysics) - - foreach(lib ${HAVOK_LIBS}) - list(APPEND LLPHYSICS_LIBRARIES - debug ${HK_DEBUG}/${lib} optimized ${HK_RELEASE}/${lib}) - endforeach(lib) -endif (LINUX OR DARWIN) diff --git a/linden/indra/cmake/LLPrimitive.cmake b/linden/indra/cmake/LLPrimitive.cmake index 0426ae5..d397b78 100644 --- a/linden/indra/cmake/LLPrimitive.cmake +++ b/linden/indra/cmake/LLPrimitive.cmake @@ -4,6 +4,4 @@ set(LLPRIMITIVE_INCLUDE_DIRS ${LIBS_OPEN_DIR}/llprimitive ) -set(LLPRIMITIVE_LIBRARIES - llprimitive - ) +set(LLPRIMITIVE_LIBRARIES llprimitive) diff --git a/linden/indra/cmake/LLScene.cmake b/linden/indra/cmake/LLScene.cmake index d1c32b3..96ad508 100644 --- a/linden/indra/cmake/LLScene.cmake +++ b/linden/indra/cmake/LLScene.cmake @@ -4,6 +4,4 @@ set(LLSCENE_INCLUDE_DIRS ${LIBS_SERVER_DIR}/llscene ) -set(LLSCENE_LIBRARIES - llscene - ) +set(LLSCENE_LIBRARIES llscene) diff --git a/linden/indra/cmake/LLUI.cmake b/linden/indra/cmake/LLUI.cmake index d1287de..34de571 100644 --- a/linden/indra/cmake/LLUI.cmake +++ b/linden/indra/cmake/LLUI.cmake @@ -4,6 +4,4 @@ set(LLUI_INCLUDE_DIRS ${LIBS_OPEN_DIR}/llui ) -set(LLUI_LIBRARIES - llui - ) +set(LLUI_LIBRARIES llui) diff --git a/linden/indra/cmake/LLVFS.cmake b/linden/indra/cmake/LLVFS.cmake index 5ce3d25..0fe87cd 100644 --- a/linden/indra/cmake/LLVFS.cmake +++ b/linden/indra/cmake/LLVFS.cmake @@ -5,9 +5,3 @@ set(LLVFS_INCLUDE_DIRS ) set(LLVFS_LIBRARIES llvfs) - -if (DARWIN) - include(CMakeFindFrameworks) - find_library(CARBON_LIBRARY Carbon) - list(APPEND LLVFS_LIBRARIES ${CARBON_LIBRARY}) -endif (DARWIN) diff --git a/linden/indra/cmake/LLXML.cmake b/linden/indra/cmake/LLXML.cmake index 1ce93c0..64dfdb6 100644 --- a/linden/indra/cmake/LLXML.cmake +++ b/linden/indra/cmake/LLXML.cmake @@ -1,13 +1,12 @@ # -*- cmake -*- +include(Boost) include(EXPAT) set(LLXML_INCLUDE_DIRS ${LIBS_OPEN_DIR}/llxml + ${Boost_INCLUDE_DIRS} ${EXPAT_INCLUDE_DIRS} ) -set(LLXML_LIBRARIES - llxml - ${EXPAT_LIBRARIES} - ) +set(LLXML_LIBRARIES llxml) diff --git a/linden/indra/cmake/Linking.cmake b/linden/indra/cmake/Linking.cmake index c9748e3..167c5dd 100644 --- a/linden/indra/cmake/Linking.cmake +++ b/linden/indra/cmake/Linking.cmake @@ -7,15 +7,15 @@ if (NOT STANDALONE) set(ARCH_PREBUILT_DIRS_DEBUG ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib/debug) elseif (LINUX) if (VIEWER) - set(ARCH_PREBUILT_DIRS - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib_release_client) - set(ARCH_PREBUILT_DIRS_RELEASE ${ARCH_PREBUILT_DIRS}) - set(ARCH_PREBUILT_DIRS_DEBUG ${ARCH_PREBUILT_DIRS}) + set(ARCH_PREBUILT_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib_release_client) else (VIEWER) set(ARCH_PREBUILT_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib_release) endif (VIEWER) + set(ARCH_PREBUILT_DIRS_RELEASE ${ARCH_PREBUILT_DIRS}) + set(ARCH_PREBUILT_DIRS_DEBUG ${ARCH_PREBUILT_DIRS}) elseif (DARWIN) set(ARCH_PREBUILT_DIRS_RELEASE ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib_release) + set(ARCH_PREBUILT_DIRS ${ARCH_PREBUILT_DIRS_RELEASE}) set(ARCH_PREBUILT_DIRS_DEBUG ${ARCH_PREBUILT_DIRS_RELEASE}) endif (WINDOWS) endif (NOT STANDALONE) diff --git a/linden/indra/cmake/Python.cmake b/linden/indra/cmake/Python.cmake index e9505fb..4f86d32 100644 --- a/linden/indra/cmake/Python.cmake +++ b/linden/indra/cmake/Python.cmake @@ -9,6 +9,7 @@ if (WINDOWS) NAMES python25.exe python23.exe python.exe NO_DEFAULT_PATH # added so that cmake does not find cygwin python PATHS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.6\\InstallPath] [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.5\\InstallPath] [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath] [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath] diff --git a/linden/indra/cmake/QuickTime.cmake b/linden/indra/cmake/QuickTime.cmake index b79ac11..4352709 100644 --- a/linden/indra/cmake/QuickTime.cmake +++ b/linden/indra/cmake/QuickTime.cmake @@ -9,13 +9,29 @@ if (DARWIN) include(CMakeFindFrameworks) find_library(QUICKTIME_LIBRARY QuickTime) elseif (WINDOWS) - set(QUICKTIME_SDK_DIR "C:\\Program Files\\QuickTime SDK" + set(QUICKTIME_SDK_DIR "$ENV{PROGRAMFILES}/QuickTime SDK" CACHE PATH "Location of the QuickTime SDK.") - find_library(QUICKTIME_LIBRARY qtmlclient + + find_library(DEBUG_QUICKTIME_LIBRARY qtmlclient + PATHS + ${ARCH_PREBUILT_DIRS_DEBUG} + "${QUICKTIME_SDK_DIR}\\libraries" + ) + + find_library(RELEASE_QUICKTIME_LIBRARY qtmlclient PATHS - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib/release + ${ARCH_PREBUILT_DIRS_RELEASE} "${QUICKTIME_SDK_DIR}\\libraries" ) + + if (DEBUG_QUICKTIME_LIBRARY AND RELEASE_QUICKTIME_LIBRARY) + set(QUICKTIME_LIBRARY + optimized ${RELEASE_QUICKTIME_LIBRARY} + debug ${DEBUG_QUICKTIME_LIBRARY} + ) + + endif (DEBUG_QUICKTIME_LIBRARY AND RELEASE_QUICKTIME_LIBRARY) + include_directories( ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/quicktime "${QUICKTIME_SDK_DIR}\\CIncludes" diff --git a/linden/indra/develop.py b/linden/indra/develop.py index 8edfccc..c4a9d0d 100755 --- a/linden/indra/develop.py +++ b/linden/indra/develop.py @@ -53,6 +53,16 @@ def mkdir(path): if err.errno != errno.EEXIST or not os.path.isdir(path): raise +def getcwd(): + cwd = os.getcwd() + if 'a' <= cwd[0] <= 'z' and cwd[1] == ':': + # CMake wants DOS drive letters to be in uppercase. The above + # condition never asserts on platforms whose full path names + # always begin with a slash, so we don't need to test whether + # we are running on Windows. + cwd = cwd[0].upper() + cwd[1:] + return cwd + def quote(opts): return '"' + '" "'.join([ opt.replace('"', '') for opt in opts ]) + '"' @@ -63,8 +73,8 @@ class PlatformSetup(object): build_types[t.lower()] = t build_type = build_types['relwithdebinfo'] - standalone = 'FALSE' - unattended = 'FALSE' + standalone = 'OFF' + unattended = 'OFF' distcc = True cmake_opts = [] @@ -141,7 +151,7 @@ class PlatformSetup(object): # do a sanity check to make sure we have a generator if not hasattr(self, 'generator'): raise "No generator available for '%s'" % (self.__name__,) - cwd = os.getcwd() + cwd = getcwd() created = [] try: for d in self.build_dirs(): @@ -218,11 +228,15 @@ class UnixSetup(PlatformSetup): elif cpu == 'Power Macintosh': cpu = 'ppc' return cpu - + class LinuxSetup(UnixSetup): def __init__(self): super(LinuxSetup, self).__init__() + try: + self.debian_sarge = open('/etc/debian_version').read().strip() == '3.1' + except: + self.debian_sarge = False def os(self): return 'linux' @@ -230,10 +244,17 @@ class LinuxSetup(UnixSetup): def build_dirs(self): # Only build the server code if (a) we have it and (b) we're # on 32-bit x86. + platform_build = '%s-%s' % (self.platform(), self.build_type.lower()) + if self.arch() == 'i686' and self.is_internal_tree(): - return ['viewer-' + self.platform(), 'server-' + self.platform()] + return ['viewer-' + platform_build, 'server-' + platform_build] + elif self.arch() == 'x86_64' and self.is_internal_tree(): + # the viewer does not build in 64bit -- kdu5 issues + # we can either use openjpeg, or overhaul our viewer to handle kdu5 or higher + # doug knows about kdu issues + return ['server-' + platform_build] else: - return ['viewer-' + self.platform()] + return ['viewer-' + platform_build] def find_in_path(self, name, defval=None, basename=False): for p in os.getenv('PATH', '/usr/bin').split(':'): @@ -254,7 +275,7 @@ class LinuxSetup(UnixSetup): type=self.build_type.upper() ) if not self.is_internal_tree(): - args.update({'cxx':'g++', 'server':'FALSE', 'viewer':'TRUE'}) + args.update({'cxx':'g++', 'server':'OFF', 'viewer':'ON'}) else: if self.distcc: distcc = self.find_in_path('distcc') @@ -263,18 +284,16 @@ class LinuxSetup(UnixSetup): distcc = [] baseonly = False if 'server' in build_dir: - gcc33 = distcc + self.find_in_path('g++-3.3', 'g++', baseonly) - args.update({'cxx':' '.join(gcc33), 'server':'TRUE', - 'viewer':'FALSE'}) + gcc = distcc + self.find_in_path( + self.debian_sarge and 'g++-3.3' or 'g++-4.1', + 'g++', baseonly) + args.update({'cxx': ' '.join(gcc), 'server': 'ON', + 'viewer': 'OFF'}) else: gcc41 = distcc + self.find_in_path('g++-4.1', 'g++', baseonly) - args.update({'cxx': ' '.join(gcc41), 'server':'FALSE', - 'viewer':'TRUE'}) - #if simple: - # return (('cmake %(opts)s ' - # '-DSERVER:BOOL=%(server)s ' - # '-DVIEWER:BOOL=%(viewer)s ' - # '%(dir)r') % args) + args.update({'cxx': ' '.join(gcc41), + 'server': 'OFF', + 'viewer': 'ON'}) cmd = (('cmake -DCMAKE_BUILD_TYPE:STRING=%(type)s ' '-G %(generator)r -DSERVER:BOOL=%(server)s ' '-DVIEWER:BOOL=%(viewer)s -DSTANDALONE:BOOL=%(standalone)s ' @@ -369,7 +388,7 @@ class DarwinSetup(UnixSetup): return 'darwin' def arch(self): - if self.unattended == 'TRUE': + if self.unattended == 'ON': return 'universal' else: return UnixSetup.arch(self) @@ -384,7 +403,7 @@ class DarwinSetup(UnixSetup): universal='', type=self.build_type.upper() ) - if self.unattended == 'TRUE': + if self.unattended == 'ON': args['universal'] = '-DCMAKE_OSX_ARCHITECTURES:STRING=\'i386;ppc\'' #if simple: # return 'cmake %(opts)s %(dir)r' % args @@ -396,7 +415,7 @@ class DarwinSetup(UnixSetup): '%(opts)s %(dir)r' % args) def run_build(self, opts, targets): - cwd = os.getcwd() + cwd = getcwd() if targets: targets = ' '.join(['-target ' + repr(t) for t in targets]) else: @@ -439,7 +458,7 @@ class WindowsSetup(PlatformSetup): def _get_generator(self): if self._generator is None: - for version in 'vc71 vc80 vc90'.split(): + for version in 'vc80 vc90 vc71'.split(): if self.find_visual_studio(version): self._generator = version print 'Building with ', self.gens[version]['gen'] @@ -523,18 +542,30 @@ class WindowsSetup(PlatformSetup): def run_cmake(self, args=[]): '''Override to add the vstool.exe call after running cmake.''' PlatformSetup.run_cmake(self, args) - if self.unattended == 'FALSE': - for build_dir in self.build_dirs(): - vstool_cmd = os.path.join('tools','vstool','VSTool.exe') \ - + ' --solution ' \ - + os.path.join(build_dir,'SecondLife.sln') \ - + ' --config RelWithDebInfo' \ - + ' --startup secondlife-bin' - print 'Running %r in %r' % (vstool_cmd, os.getcwd()) - self.run(vstool_cmd) + if self.unattended == 'OFF': + self.run_vstool() + + def run_vstool(self): + for build_dir in self.build_dirs(): + stamp = os.path.join(build_dir, 'vstool.txt') + try: + prev_build = open(stamp).read().strip() + except IOError: + prev_build = '' + if prev_build == self.build_type: + # Only run vstool if the build type has changed. + continue + vstool_cmd = (os.path.join('tools','vstool','VSTool.exe') + + ' --solution ' + + os.path.join(build_dir,'SecondLife.sln') + + ' --config ' + self.build_type + + ' --startup secondlife-bin') + print 'Running %r in %r' % (vstool_cmd, getcwd()) + self.run(vstool_cmd) + print >> open(stamp, 'w'), self.build_type def run_build(self, opts, targets): - cwd = os.getcwd() + cwd = getcwd() build_cmd = self.get_build_cmd() for d in self.build_dirs(): @@ -555,7 +586,7 @@ class WindowsSetup(PlatformSetup): class CygwinSetup(WindowsSetup): def __init__(self): super(CygwinSetup, self).__init__() - self.generator = 'vc71' + self.generator = 'vc80' def cmake_commandline(self, src_dir, build_dir, opts, simple): dos_dir = commands.getoutput("cygpath -w %s" % src_dir) @@ -601,6 +632,13 @@ Commands: configure configure project by running cmake If you do not specify a command, the default is "configure". + +Examples: + Set up a viewer-only project for your system: + develop.py configure -DSERVER:BOOL=OFF + + Set up a Visual Studio 2005 project with package target (to build installer): + develop.py -G vc80 configure -DPACKAGE:BOOL=ON ''' def main(arguments): @@ -612,6 +650,9 @@ def main(arguments): ['help', 'standalone', 'no-distcc', 'unattended', 'type=', 'incredibuild', 'generator=']) except getopt.GetoptError, err: print >> sys.stderr, 'Error:', err + print >> sys.stderr, """ +Note: You must pass -D options to cmake after the "configure" command +For example: develop.py configure -DSERVER:BOOL=OFF""" sys.exit(1) for o, a in opts: @@ -619,9 +660,9 @@ def main(arguments): print usage_msg.strip() sys.exit(0) elif o in ('--standalone',): - setup.standalone = 'TRUE' + setup.standalone = 'ON' elif o in ('--unattended',): - setup.unattended = 'TRUE' + setup.unattended = 'ON' elif o in ('-t', '--type'): try: setup.build_type = setup.build_types[a.lower()] @@ -664,13 +705,14 @@ def main(arguments): print >> sys.stderr, 'Error: unknown subcommand', repr(cmd) print >> sys.stderr, "(run 'develop.py --help' for help)" sys.exit(1) - except CommandError, err: - print >> sys.stderr, 'Error:', err - sys.exit(1) except getopt.GetoptError, err: print >> sys.stderr, 'Error with %r subcommand: %s' % (cmd, err) sys.exit(1) if __name__ == '__main__': - main(sys.argv[1:]) + try: + main(sys.argv[1:]) + except CommandError, err: + print >> sys.stderr, 'Error:', err + sys.exit(1) diff --git a/linden/indra/lib/python/indra/base/lllog.py b/linden/indra/lib/python/indra/base/lllog.py index 99c50ef..1301894 100644 --- a/linden/indra/lib/python/indra/base/lllog.py +++ b/linden/indra/lib/python/indra/base/lllog.py @@ -59,7 +59,7 @@ class Logger(object): return self._sequence def log(self, msg, llsd): - payload = 'LLLOGMESSAGE (%d) %s %s' % (self.next(), msg, + payload = 'INFO: log: LLLOGMESSAGE (%d) %s %s' % (self.next(), msg, format_notation(llsd)) syslog.syslog(payload) diff --git a/linden/indra/lib/python/indra/base/llsd.py b/linden/indra/lib/python/indra/base/llsd.py index 995ace7..5b8f5d7 100644 --- a/linden/indra/lib/python/indra/base/llsd.py +++ b/linden/indra/lib/python/indra/base/llsd.py @@ -33,19 +33,26 @@ import time import types import re -from indra.util.fastest_elementtree import fromstring +from indra.util.fastest_elementtree import ElementTreeError, fromstring from indra.base import lluuid -int_regex = re.compile("[-+]?\d+") -real_regex = re.compile("[-+]?(\d+(\.\d*)?|\d*\.\d+)([eE][-+]?\d+)?") -alpha_regex = re.compile("[a-zA-Z]+") -date_regex = re.compile("(?P\d{4})-(?P\d{2})-(?P\d{2})T(?P\d{2}):(?P\d{2}):(?P\d{2})(?P\.\d{2})?Z") -#date: d"YYYY-MM-DDTHH:MM:SS.FFZ" +try: + import cllsd +except ImportError: + cllsd = None + +int_regex = re.compile(r"[-+]?\d+") +real_regex = re.compile(r"[-+]?(\d+(\.\d*)?|\d*\.\d+)([eE][-+]?\d+)?") +alpha_regex = re.compile(r"[a-zA-Z]+") +date_regex = re.compile(r"(?P\d{4})-(?P\d{2})-(?P\d{2})T" + r"(?P\d{2}):(?P\d{2}):(?P\d{2})" + r"(?P(\.\d+)?)Z") +#date: d"YYYY-MM-DDTHH:MM:SS.FFFFFFZ" class LLSDParseError(Exception): pass -class LLSDSerializationError(Exception): +class LLSDSerializationError(TypeError): pass @@ -62,14 +69,7 @@ BOOL_FALSE = ('0', '0.0', 'false', '') def format_datestr(v): """ Formats a datetime object into the string format shared by xml and notation serializations.""" - second_str = "" - if v.microsecond > 0: - seconds = v.second + float(v.microsecond) / 1000000 - second_str = "%05.2f" % seconds - else: - second_str = "%d" % v.second - return '%s%sZ' % (v.strftime('%Y-%m-%dT%H:%M:'), second_str) - + return v.isoformat() + 'Z' def parse_datestr(datestr): """Parses a datetime object from the string format shared by xml and notation serializations.""" @@ -89,7 +89,7 @@ def parse_datestr(datestr): seconds_float = match.group('second_float') microsecond = 0 if seconds_float: - microsecond = int(seconds_float[1:]) * 10000 + microsecond = int(float('0' + seconds_float) * 1e6) return datetime.datetime(year, month, day, hour, minute, second, microsecond) @@ -116,7 +116,7 @@ def uuid_to_python(node): return lluuid.UUID(node.text) def str_to_python(node): - return unicode(node.text or '').encode('utf8', 'replace') + return node.text or '' def bin_to_python(node): return binary(base64.decodestring(node.text or '')) @@ -189,9 +189,13 @@ class LLSDXMLFormatter(object): if(contents is None or contents is ''): return "<%s />" % (name,) else: + if type(contents) is unicode: + contents = contents.encode('utf-8') return "<%s>%s" % (name, contents, name) def xml_esc(self, v): + if type(v) is unicode: + v = v.encode('utf-8') return v.replace('&', '&').replace('<', '<').replace('>', '>') def LLSD(self, v): @@ -237,9 +241,14 @@ class LLSDXMLFormatter(object): raise LLSDSerializationError("Cannot serialize unknown type: %s (%s)" % ( t, something)) - def format(self, something): + def _format(self, something): return '' + self.elt("llsd", self.generate(something)) + def format(self, something): + if cllsd: + return cllsd.llsd_to_xml(something) + return self._format(something) + _g_xml_formatter = None def format_xml(something): global _g_xml_formatter @@ -356,8 +365,10 @@ class LLSDNotationFormatter(object): def UUID(self, v): return "u%s" % v def BINARY(self, v): - raise LLSDSerializationError("binary notation not yet supported") + return 'b64"' + base64.encodestring(v) + '"' def STRING(self, v): + if isinstance(v, unicode): + v = v.encode('utf-8') return "'%s'" % v.replace("\\", "\\\\").replace("'", "\\'") def URI(self, v): return 'l"%s"' % str(v).replace("\\", "\\\\").replace('"', '\\"') @@ -366,16 +377,24 @@ class LLSDNotationFormatter(object): def ARRAY(self, v): return "[%s]" % ','.join([self.generate(item) for item in v]) def MAP(self, v): - return "{%s}" % ','.join(["'%s':%s" % (key.replace("\\", "\\\\").replace("'", "\\'"), self.generate(value)) + def fix(key): + if isinstance(key, unicode): + return key.encode('utf-8') + return key + return "{%s}" % ','.join(["'%s':%s" % (fix(key).replace("\\", "\\\\").replace("'", "\\'"), self.generate(value)) for key, value in v.items()]) def generate(self, something): t = type(something) - if self.type_map.has_key(t): - return self.type_map[t](something) + handler = self.type_map.get(t) + if handler: + return handler(something) else: - raise LLSDSerializationError("Cannot serialize unknown type: %s (%s)" % ( - t, something)) + try: + return self.ARRAY(iter(something)) + except TypeError: + raise LLSDSerializationError( + "Cannot serialize unknown type: %s (%s)" % (t, something)) def format(self, something): return self.generate(something) @@ -479,7 +498,6 @@ class LLSDBinaryParser(object): raise LLSDParseError("invalid map key at byte %d." % ( self._index - 1,)) value = self._parse() - #print "kv:",key,value rv[key] = value count += 1 cc = self._buffer[self._index] @@ -636,11 +654,23 @@ class LLSDNotationParser(object): # 'd' = date in seconds since epoch return self._parse_date() elif cc == 'b': - raise LLSDParseError("binary notation not yet supported") + return self._parse_binary() else: raise LLSDParseError("invalid token at index %d: %d" % ( self._index - 1, ord(cc))) + def _parse_binary(self): + i = self._index + if self._buffer[i:i+2] == '64': + q = self._buffer[i+2] + e = self._buffer.find(q, i+3) + try: + return base64.decodestring(self._buffer[i+3:e]) + finally: + self._index = e + 1 + else: + raise LLSDParseError('random horrible binary format not supported') + def _parse_map(self): """ map: { string:object, string:object } """ rv = {} @@ -653,30 +683,23 @@ class LLSDNotationParser(object): if cc in ("'", '"', 's'): key = self._parse_string(cc) found_key = True - #print "key:",key elif cc.isspace() or cc == ',': cc = self._buffer[self._index] self._index += 1 else: raise LLSDParseError("invalid map key at byte %d." % ( self._index - 1,)) + elif cc.isspace() or cc == ':': + cc = self._buffer[self._index] + self._index += 1 + continue else: - if cc.isspace() or cc == ':': - #print "skipping whitespace '%s'" % cc - cc = self._buffer[self._index] - self._index += 1 - continue self._index += 1 value = self._parse() - #print "kv:",key,value rv[key] = value found_key = False cc = self._buffer[self._index] self._index += 1 - #if cc == '}': - # break - #cc = self._buffer[self._index] - #self._index += 1 return rv @@ -840,6 +863,14 @@ def format_binary(something): return '\n' + _format_binary_recurse(something) def _format_binary_recurse(something): + def _format_list(something): + array_builder = [] + array_builder.append('[' + struct.pack('!i', len(something))) + for item in something: + array_builder.append(_format_binary_recurse(item)) + array_builder.append(']') + return ''.join(array_builder) + if something is None: return '!' elif isinstance(something, LLSD): @@ -857,7 +888,10 @@ def _format_binary_recurse(something): return 'u' + something._bits elif isinstance(something, binary): return 'b' + struct.pack('!i', len(something)) + something - elif isinstance(something, (str, unicode)): + elif isinstance(something, str): + return 's' + struct.pack('!i', len(something)) + something + elif isinstance(something, unicode): + something = something.encode('utf-8') return 's' + struct.pack('!i', len(something)) + something elif isinstance(something, uri): return 'l' + struct.pack('!i', len(something)) + something @@ -865,35 +899,50 @@ def _format_binary_recurse(something): seconds_since_epoch = time.mktime(something.timetuple()) return 'd' + struct.pack('!d', seconds_since_epoch) elif isinstance(something, (list, tuple)): - array_builder = [] - array_builder.append('[' + struct.pack('!i', len(something))) - for item in something: - array_builder.append(_format_binary_recurse(item)) - array_builder.append(']') - return ''.join(array_builder) + return _format_list(something) elif isinstance(something, dict): map_builder = [] map_builder.append('{' + struct.pack('!i', len(something))) for key, value in something.items(): + if isinstance(key, unicode): + key = key.encode('utf-8') map_builder.append('k' + struct.pack('!i', len(key)) + key) map_builder.append(_format_binary_recurse(value)) map_builder.append('}') return ''.join(map_builder) else: - raise LLSDSerializationError("Cannot serialize unknown type: %s (%s)" % ( - type(something), something)) + try: + return _format_list(list(something)) + except TypeError: + raise LLSDSerializationError( + "Cannot serialize unknown type: %s (%s)" % + (type(something), something)) + + +def parse_binary(something): + header = '\n' + if not something.startswith(header): + raise LLSDParseError('LLSD binary encoding header not found') + return LLSDBinaryParser().parse(something[len(header):]) + +def parse_xml(something): + try: + return to_python(fromstring(something)[0]) + except ElementTreeError, err: + raise LLSDParseError(*err.args) +def parse_notation(something): + return LLSDNotationParser().parse(something) def parse(something): try: if something.startswith(''): - just_binary = something.split('\n', 1)[1] - return LLSDBinaryParser().parse(just_binary) + return parse_binary(something) # This should be better. elif something.startswith('<'): - return to_python(fromstring(something)[0]) + return parse_xml(something) else: - return LLSDNotationParser().parse(something) + return parse_notation(something) except KeyError, e: raise Exception('LLSD could not be parsed: %s' % (e,)) @@ -913,6 +962,9 @@ class LLSD(object): undef = LLSD(None) +XML_MIME_TYPE = 'application/llsd+xml' +BINARY_MIME_TYPE = 'application/llsd+binary' + # register converters for llsd in mulib, if it is available try: from mulib import stacked, mu @@ -922,7 +974,7 @@ except: # mulib not available, don't print an error message since this is normal pass else: - mu.add_parser(parse, 'application/llsd+xml') + mu.add_parser(parse, XML_MIME_TYPE) mu.add_parser(parse, 'application/llsd+binary') def llsd_convert_xml(llsd_stuff, request): @@ -931,11 +983,58 @@ else: def llsd_convert_binary(llsd_stuff, request): request.write(format_binary(llsd_stuff)) - for typ in [LLSD, dict, list, tuple, str, int, float, bool, unicode, type(None)]: - stacked.add_producer(typ, llsd_convert_xml, 'application/llsd+xml') + for typ in [LLSD, dict, list, tuple, str, int, long, float, bool, unicode, type(None)]: + stacked.add_producer(typ, llsd_convert_xml, XML_MIME_TYPE) stacked.add_producer(typ, llsd_convert_xml, 'application/xml') stacked.add_producer(typ, llsd_convert_xml, 'text/xml') stacked.add_producer(typ, llsd_convert_binary, 'application/llsd+binary') stacked.add_producer(LLSD, llsd_convert_xml, '*/*') + + # in case someone is using the legacy mu.xml wrapper, we need to + # tell mu to produce application/xml or application/llsd+xml + # (based on the accept header) from raw xml. Phoenix 2008-07-21 + stacked.add_producer(mu.xml, mu.produce_raw, XML_MIME_TYPE) + stacked.add_producer(mu.xml, mu.produce_raw, 'application/xml') + + + +# mulib wsgi stuff +# try: +# from mulib import mu, adapters +# +# # try some known attributes from mulib to be ultra-sure we've imported it +# mu.get_current +# adapters.handlers +# except: +# # mulib not available, don't print an error message since this is normal +# pass +# else: +# def llsd_xml_handler(content_type): +# def handle_llsd_xml(env, start_response): +# llsd_stuff, _ = mu.get_current(env) +# result = format_xml(llsd_stuff) +# start_response("200 OK", [('Content-Type', content_type)]) +# env['mu.negotiated_type'] = content_type +# yield result +# return handle_llsd_xml +# +# def llsd_binary_handler(content_type): +# def handle_llsd_binary(env, start_response): +# llsd_stuff, _ = mu.get_current(env) +# result = format_binary(llsd_stuff) +# start_response("200 OK", [('Content-Type', content_type)]) +# env['mu.negotiated_type'] = content_type +# yield result +# return handle_llsd_binary +# +# adapters.DEFAULT_PARSERS[XML_MIME_TYPE] = parse + +# for typ in [LLSD, dict, list, tuple, str, int, float, bool, unicode, type(None)]: +# for content_type in (XML_MIME_TYPE, 'application/xml'): +# adapters.handlers.set_handler(typ, llsd_xml_handler(content_type), content_type) +# +# adapters.handlers.set_handler(typ, llsd_binary_handler(BINARY_MIME_TYPE), BINARY_MIME_TYPE) +# +# adapters.handlers.set_handler(LLSD, llsd_xml_handler(XML_MIME_TYPE), '*/*') diff --git a/linden/indra/lib/python/indra/ipc/llmessage.py b/linden/indra/lib/python/indra/ipc/llmessage.py index 446679d..c2f3fd4 100644 --- a/linden/indra/lib/python/indra/ipc/llmessage.py +++ b/linden/indra/lib/python/indra/ipc/llmessage.py @@ -88,7 +88,7 @@ class Message: UDPDEPRECATED = "UDPDeprecated" UDPBLACKLISTED = "UDPBlackListed" deprecations = [ NOTDEPRECATED, UDPDEPRECATED, UDPBLACKLISTED, DEPRECATED ] - # in order of increasing deprecation + # in order of increasing deprecation def __init__(self, name, number, priority, trust, coding): self.name = name diff --git a/linden/indra/lib/python/indra/ipc/llsdhttp.py b/linden/indra/lib/python/indra/ipc/llsdhttp.py index 1cf1146..ed64899 100644 --- a/linden/indra/lib/python/indra/ipc/llsdhttp.py +++ b/linden/indra/lib/python/indra/ipc/llsdhttp.py @@ -51,6 +51,8 @@ request_ = suite.request_ # import every httpc error exception into our namespace for convenience for x in httpc.status_to_error_map.itervalues(): globals()[x.__name__] = x +ConnectionError = httpc.ConnectionError +Retriable = httpc.Retriable for x in (httpc.ConnectionError,): globals()[x.__name__] = x diff --git a/linden/indra/lib/python/indra/ipc/mysql_pool.py b/linden/indra/lib/python/indra/ipc/mysql_pool.py index 507b185..25a66cf 100644 --- a/linden/indra/lib/python/indra/ipc/mysql_pool.py +++ b/linden/indra/lib/python/indra/ipc/mysql_pool.py @@ -30,8 +30,10 @@ import MySQLdb from eventlet import db_pool class DatabaseConnector(db_pool.DatabaseConnector): - def __init__(self, credentials, min_size = 0, max_size = 4, *args, **kwargs): - super(DatabaseConnector, self).__init__(MySQLdb, credentials, min_size, max_size, conn_pool=db_pool.ConnectionPool, *args, **kwargs) + def __init__(self, credentials, *args, **kwargs): + super(DatabaseConnector, self).__init__(MySQLdb, credentials, + conn_pool=db_pool.ConnectionPool, + *args, **kwargs) # get is extended relative to eventlet.db_pool to accept a port argument def get(self, host, dbname, port=3306): @@ -42,7 +44,7 @@ class DatabaseConnector(db_pool.DatabaseConnector): new_kwargs['host'] = host new_kwargs['port'] = port new_kwargs.update(self.credentials_for(host)) - dbpool = ConnectionPool(self._min_size, self._max_size, *self._args, **new_kwargs) + dbpool = ConnectionPool(*self._args, **new_kwargs) self._databases[key] = dbpool return self._databases[key] @@ -51,8 +53,8 @@ class ConnectionPool(db_pool.TpooledConnectionPool): """A pool which gives out saranwrapped MySQLdb connections from a pool """ - def __init__(self, min_size = 0, max_size = 4, *args, **kwargs): - super(ConnectionPool, self).__init__(MySQLdb, min_size, max_size, *args, **kwargs) + def __init__(self, *args, **kwargs): + super(ConnectionPool, self).__init__(MySQLdb, *args, **kwargs) def get(self): conn = super(ConnectionPool, self).get() @@ -77,14 +79,3 @@ class ConnectionPool(db_pool.TpooledConnectionPool): conn.connection_parameters = converted_kwargs return conn - def clear(self): - """ Close all connections that this pool still holds a reference to, leaving it empty.""" - for conn in self.free_items: - try: - conn.close() - except: - pass # even if stuff happens here, we still want to at least try to close all the other connections - self.free_items.clear() - - def __del__(self): - self.clear() diff --git a/linden/indra/lib/python/indra/ipc/saranwrap.py b/linden/indra/lib/python/indra/ipc/saranwrap.py deleted file mode 100644 index e0205bf..0000000 --- a/linden/indra/lib/python/indra/ipc/saranwrap.py +++ /dev/null @@ -1,651 +0,0 @@ -"""\ -@file saranwrap.py -@author Phoenix -@date 2007-07-13 -@brief A simple, pickle based rpc mechanism which reflects python -objects and callables. - -$LicenseInfo:firstyear=2007&license=mit$ - -Copyright (c) 2007-2008, Linden Research, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -$/LicenseInfo$ - -This file provides classes and exceptions used for simple python level -remote procedure calls. This is achieved by intercepting the basic -getattr and setattr calls in a client proxy, which commnicates those -down to the server which will dispatch them to objects in it's process -space. - -The basic protocol to get and set attributes is for the client proxy -to issue the command: - -getattr $id $name -setattr $id $name $value - -getitem $id $item -setitem $id $item $value -eq $id $rhs -del $id - -When the get returns a callable, the client proxy will provide a -callable proxy which will invoke a remote procedure call. The command -issued from the callable proxy to server is: - -call $id $name $args $kwargs - -If the client supplies an id of None, then the get/set/call is applied -to the object(s) exported from the server. - -The server will parse the get/set/call, take the action indicated, and -return back to the caller one of: - -value $val -callable -object $id -exception $excp - -To handle object expiration, the proxy will instruct the rpc server to -discard objects which are no longer in use. This is handled by -catching proxy deletion and sending the command: - -del $id - -The server will handle this by removing clearing it's own internal -references. This does not mean that the object will necessarily be -cleaned from the server, but no artificial references will remain -after successfully completing. On completion, the server will return -one of: - -value None -exception $excp - -The server also accepts a special command for debugging purposes: - -status - -Which will be intercepted by the server to write back: - -status {...} - -The wire protocol is to pickle the Request class in this file. The -request class is basically an action and a map of parameters' -""" - -import os -import cPickle -import struct -import sys - -try: - set = set - frozenset = frozenset -except NameError: - from sets import Set as set, ImmutableSet as frozenset - -from eventlet.processes import Process -from eventlet import api - -# -# debugging hooks -# -_g_debug_mode = False -if _g_debug_mode: - import traceback - -def pythonpath_sync(): - """ -@brief apply the current sys.path to the environment variable PYTHONPATH, so that child processes have the same paths as the caller does. -""" - pypath = os.pathsep.join(sys.path) - os.environ['PYTHONPATH'] = pypath - -def wrap(obj, dead_callback = None): - """ -@brief wrap in object in another process through a saranwrap proxy -@param object The object to wrap. -@param dead_callback A callable to invoke if the process exits.""" - - if type(obj).__name__ == 'module': - return wrap_module(obj.__name__, dead_callback) - pythonpath_sync() - p = Process('python', [__file__, '--child'], dead_callback) - prox = Proxy(p, p) - prox.obj = obj - return prox.obj - -def wrap_module(fqname, dead_callback = None): - """ -@brief wrap a module in another process through a saranwrap proxy -@param fqname The fully qualified name of the module. -@param dead_callback A callable to invoke if the process exits.""" - pythonpath_sync() - global _g_debug_mode - if _g_debug_mode: - p = Process('python', [__file__, '--module', fqname, '--logfile', '/tmp/saranwrap.log'], dead_callback) - else: - p = Process('python', [__file__, '--module', fqname,], dead_callback) - prox = Proxy(p, p) - return prox - -def status(proxy): - """ -@brief get the status from the server through a proxy -@param proxy a saranwrap.Proxy object connected to a server.""" - _write_request(Request('status', {}), proxy.__local_dict['_out']) - return _read_response(None, None, proxy.__local_dict['_in'], proxy.__local_dict['_out'], None) - -class BadResponse(Exception): - """"This exception is raised by an saranwrap client when it could - parse but cannot understand the response from the server.""" - pass - -class BadRequest(Exception): - """"This exception is raised by a saranwrap server when it could parse - but cannot understand the response from the server.""" - pass - -class UnrecoverableError(Exception): - pass - -class Request(object): - "@brief A wrapper class for proxy requests to the server." - def __init__(self, action, param): - self._action = action - self._param = param - def __str__(self): - return "Request `"+self._action+"` "+str(self._param) - def __getitem__(self, name): - return self._param[name] - def action(self): - return self._action - -def _read_lp_hunk(stream): - len_bytes = stream.read(4) - length = struct.unpack('I', len_bytes)[0] - body = stream.read(length) - return body - -def _read_response(id, attribute, input, output, dead_list): - """@brief local helper method to read respones from the rpc server.""" - try: - str = _read_lp_hunk(input) - _prnt(`str`) - response = cPickle.loads(str) - except AttributeError, e: - raise UnrecoverableError(e) - _prnt("response: %s" % response) - if response[0] == 'value': - return response[1] - elif response[0] == 'callable': - return CallableProxy(id, attribute, input, output, dead_list) - elif response[0] == 'object': - return ObjectProxy(input, output, response[1], dead_list) - elif response[0] == 'exception': - exp = response[1] - raise exp - else: - raise BadResponse(response[0]) - -def _write_lp_hunk(stream, hunk): - write_length = struct.pack('I', len(hunk)) - stream.write(write_length + hunk) - if hasattr(stream, 'flush'): - stream.flush() - -def _write_request(param, output): - _prnt("request: %s" % param) - str = cPickle.dumps(param) - _write_lp_hunk(output, str) - -def _is_local(attribute): - "Return true if the attribute should be handled locally" -# return attribute in ('_in', '_out', '_id', '__getattribute__', '__setattr__', '__dict__') - # good enough for now. :) - if '__local_dict' in attribute: - return True - return False - -def _prnt(message): - global _g_debug_mode - if _g_debug_mode: - print message - -_g_logfile = None -def _log(message): - global _g_logfile - if _g_logfile: - _g_logfile.write(str(os.getpid()) + ' ' + message) - _g_logfile.write('\n') - _g_logfile.flush() - -def _unmunge_attr_name(name): - """ Sometimes attribute names come in with classname prepended, not sure why. - This function removes said classname, because we're huge hackers and we didn't - find out what the true right thing to do is. *FIX: find out. """ - if(name.startswith('_Proxy')): - name = name[len('_Proxy'):] - if(name.startswith('_ObjectProxy')): - name = name[len('_ObjectProxy'):] - return name - - -class Proxy(object): - """\ -@class Proxy -@brief This class wraps a remote python process, presumably available -in an instance of an Server. - -This is the class you will typically use as a client to a child -process. Simply instantiate one around a file-like interface and start -calling methods on the thing that is exported. The dir() builtin is -not supported, so you have to know what has been exported. -""" - def __init__(self, input, output, dead_list = None): - """\ -@param input a file-like object which supports read(). -@param output a file-like object which supports write() and flush(). -@param id an identifier for the remote object. humans do not provide this. -""" - # default dead_list inside the function because all objects in method - # argument lists are init-ed only once globally - if dead_list is None: - dead_list = set() - #_prnt("Proxy::__init__") - self.__local_dict = dict( - _in = input, - _out = output, - _dead_list = dead_list, - _id = None) - - def __getattribute__(self, attribute): - #_prnt("Proxy::__getattr__: %s" % attribute) - if _is_local(attribute): - # call base class getattribute so we actually get the local variable - attribute = _unmunge_attr_name(attribute) - return super(Proxy, self).__getattribute__(attribute) - else: - my_in = self.__local_dict['_in'] - my_out = self.__local_dict['_out'] - my_id = self.__local_dict['_id'] - - _dead_list = self.__local_dict['_dead_list'] - for dead_object in _dead_list.copy(): - request = Request('del', {'id':dead_object}) - _write_request(request, my_out) - response = _read_response(my_id, attribute, my_in, my_out, _dead_list) - _dead_list.remove(dead_object) - - # Pass all public attributes across to find out if it is - # callable or a simple attribute. - request = Request('getattr', {'id':my_id, 'attribute':attribute}) - _write_request(request, my_out) - return _read_response(my_id, attribute, my_in, my_out, _dead_list) - - def __setattr__(self, attribute, value): - #_prnt("Proxy::__setattr__: %s" % attribute) - if _is_local(attribute): - # It must be local to this actual object, so we have to apply - # it to the dict in a roundabout way - attribute = _unmunge_attr_name(attribute) - super(Proxy, self).__getattribute__('__dict__')[attribute]=value - else: - my_in = self.__local_dict['_in'] - my_out = self.__local_dict['_out'] - my_id = self.__local_dict['_id'] - _dead_list = self.__local_dict['_dead_list'] - # Pass the set attribute across - request = Request('setattr', {'id':my_id, 'attribute':attribute, 'value':value}) - _write_request(request, my_out) - return _read_response(my_id, attribute, my_in, my_out, _dead_list) - -class ObjectProxy(Proxy): - """\ -@class ObjectProxy -@brief This class wraps a remote object in the Server - -This class will be created during normal operation, and users should -not need to deal with this class directly.""" - - def __init__(self, input, output, id, dead_list): - """\ -@param input a file-like object which supports read(). -@param output a file-like object which supports write() and flush(). -@param id an identifier for the remote object. humans do not provide this. -""" - Proxy.__init__(self, input, output, dead_list) - self.__local_dict['_id'] = id - #_prnt("ObjectProxy::__init__ %s" % self._id) - - def __del__(self): - my_id = self.__local_dict['_id'] - _prnt("ObjectProxy::__del__ %s" % my_id) - self.__local_dict['_dead_list'].add(my_id) - - def __getitem__(self, key): - my_in = self.__local_dict['_in'] - my_out = self.__local_dict['_out'] - my_id = self.__local_dict['_id'] - _dead_list = self.__local_dict['_dead_list'] - request = Request('getitem', {'id':my_id, 'key':key}) - _write_request(request, my_out) - return _read_response(my_id, key, my_in, my_out, _dead_list) - - def __setitem__(self, key, value): - my_in = self.__local_dict['_in'] - my_out = self.__local_dict['_out'] - my_id = self.__local_dict['_id'] - _dead_list = self.__local_dict['_dead_list'] - request = Request('setitem', {'id':my_id, 'key':key, 'value':value}) - _write_request(request, my_out) - return _read_response(my_id, key, my_in, my_out, _dead_list) - - def __eq__(self, rhs): - my_in = self.__local_dict['_in'] - my_out = self.__local_dict['_out'] - my_id = self.__local_dict['_id'] - _dead_list = self.__local_dict['_dead_list'] - request = Request('eq', {'id':my_id, 'rhs':rhs.__local_dict['_id']}) - _write_request(request, my_out) - return _read_response(my_id, None, my_in, my_out, _dead_list) - - def __repr__(self): - # apparently repr(obj) skips the whole getattribute thing and just calls __repr__ - # directly. Therefore we just pass it through the normal call pipeline, and - # tack on a little header so that you can tell it's an object proxy. - val = self.__repr__() - return "saran:%s" % val - - def __str__(self): - # see description for __repr__, because str(obj) works the same. We don't - # tack anything on to the return value here because str values are used as data. - return self.__str__() - - def __len__(self): - # see description for __repr__, len(obj) is the same. Unfortunately, __len__ is also - # used when determining whether an object is boolean or not, e.g. if proxied_object: - return self.__len__() - -def proxied_type(self): - if type(self) is not ObjectProxy: - return type(self) - - my_in = self.__local_dict['_in'] - my_out = self.__local_dict['_out'] - my_id = self.__local_dict['_id'] - request = Request('type', {'id':my_id}) - _write_request(request, my_out) - # dead list can be none because we know the result will always be - # a value and not an ObjectProxy itself - return _read_response(my_id, None, my_in, my_out, None) - -class CallableProxy(object): - """\ -@class CallableProxy -@brief This class wraps a remote function in the Server - -This class will be created by an Proxy during normal operation, -and users should not need to deal with this class directly.""" - - def __init__(self, object_id, name, input, output, dead_list): - #_prnt("CallableProxy::__init__: %s, %s" % (object_id, name)) - self._object_id = object_id - self._name = name - self._in = input - self._out = output - self._dead_list = dead_list - - def __call__(self, *args, **kwargs): - #_prnt("CallableProxy::__call__: %s, %s" % (args, kwargs)) - - # Pass the call across. We never build a callable without - # having already checked if the method starts with '_' so we - # can safely pass this one to the remote object. - #_prnt("calling %s %s" % (self._object_id, self._name) - request = Request('call', {'id':self._object_id, 'name':self._name, 'args':args, 'kwargs':kwargs}) - _write_request(request, self._out) - return _read_response(self._object_id, self._name, self._in, self._out, self._dead_list) - -class Server(object): - def __init__(self, input, output, export): - """\ -@param input a file-like object which supports read(). -@param output a file-like object which supports write() and flush(). -@param export an object, function, or map which is exported to clients -when the id is None.""" - #_log("Server::__init__") - self._in = input - self._out = output - self._export = export - self._next_id = 1 - self._objects = {} - - def handle_status(self, object, req): - return { - 'object_count':len(self._objects), - 'next_id':self._next_id, - 'pid':os.getpid()} - - def handle_getattr(self, object, req): - try: - return getattr(object, req['attribute']) - except AttributeError, e: - if hasattr(object, "__getitem__"): - return object[req['attribute']] - else: - raise e - #_log('getattr: %s' % str(response)) - - def handle_setattr(self, object, req): - try: - return setattr(object, req['attribute'], req['value']) - except AttributeError, e: - if hasattr(object, "__setitem__"): - return object.__setitem__(req['attribute'], req['value']) - else: - raise e - - def handle_getitem(self, object, req): - return object[req['key']] - - def handle_setitem(self, object, req): - object[req['key']] = req['value'] - return None # *TODO figure out what the actual return value of __setitem__ should be - - def handle_eq(self, object, req): - #_log("__eq__ %s %s" % (object, req)) - rhs = None - try: - rhs = self._objects[req['rhs']] - except KeyError, e: - return False - return (object == rhs) - - def handle_call(self, object, req): - #_log("calling %s " % (req['name'])) - try: - fn = getattr(object, req['name']) - except AttributeError, e: - if hasattr(object, "__setitem__"): - fn = object[req['name']] - else: - raise e - - return fn(*req['args'],**req['kwargs']) - - def handle_del(self, object, req): - id = req['id'] - _log("del %s from %s" % (id, self._objects)) - - # *TODO what does __del__ actually return? - del self._objects[id] - return None - - def handle_type(self, object, req): - return type(object) - - def loop(self): - """@brief Loop forever and respond to all requests.""" - _log("Server::loop") - while True: - try: - try: - str = _read_lp_hunk(self._in) - except EOFError: - sys.exit(0) # normal exit - request = cPickle.loads(str) - _log("request: %s (%s)" % (request, self._objects)) - req = request - id = None - object = None - try: - id = req['id'] - if id: - id = int(id) - object = self._objects[id] - #_log("id, object: %d %s" % (id, object)) - except Exception, e: - #_log("Exception %s" % str(e)) - pass - if object is None or id is None: - id = None - object = self._export - #_log("found object %s" % str(object)) - - # Handle the request via a method with a special name on the server - handler_name = 'handle_%s' % request.action() - - try: - handler = getattr(self, handler_name) - except AttributeError: - raise BadRequest, request.action() - - response = handler(object, request) - - # figure out what to do with the response, and respond - # apprpriately. - if request.action() in ['status', 'type']: - # have to handle these specially since we want to - # pickle up the actual value and not return a proxy - self.respond(['value', response]) - elif callable(response): - #_log("callable %s" % response) - self.respond(['callable']) - elif self.is_value(response): - self.respond(['value', response]) - else: - self._objects[self._next_id] = response - #_log("objects: %s" % str(self._objects)) - self.respond(['object', self._next_id]) - self._next_id += 1 - except SystemExit, e: - raise e - except Exception, e: - self.write_exception(e) - except: - self.write_exception(sys.exc_info()[0]) - - def is_value(self, value): - """\ -@brief Test if value should be serialized as a simple dataset. -@param value The value to test. -@return Returns true if value is a simple serializeable set of data. -""" - return type(value) in (str,unicode,int,float,long,bool,type(None)) - - def respond(self, body): - _log("responding with: %s" % body) - #_log("objects: %s" % self._objects) - s = cPickle.dumps(body) - _log(`s`) - str = _write_lp_hunk(self._out, s) - - def write_exception(self, e): - """@brief Helper method to respond with an exception.""" - #_log("exception: %s" % sys.exc_info()[0]) - # TODO: serialize traceback using generalization of code from mulib.htmlexception - self.respond(['exception', e]) - global _g_debug_mode - if _g_debug_mode: - _log("traceback: %s" % traceback.format_tb(sys.exc_info()[2])) - - -# test function used for testing that final except clause -def raise_a_weird_error(): - raise "oh noes you can raise a string" - -# test function used for testing return of unpicklable exceptions -def raise_an_unpicklable_error(): - class Unpicklable(Exception): - pass - raise Unpicklable() - -# test function used for testing return of picklable exceptions -def raise_standard_error(): - raise FloatingPointError() - -# test function to make sure print doesn't break the wrapper -def print_string(str): - print str - -# test function to make sure printing on stdout doesn't break the -# wrapper -def err_string(str): - print >>sys.stderr, str - -def main(): - import optparse - parser = optparse.OptionParser( - usage="usage: %prog [options]", - description="Simple saranwrap.Server wrapper") - parser.add_option( - '-c', '--child', default=False, action='store_true', - help='Wrap an object serialed via setattr.') - parser.add_option( - '-m', '--module', type='string', dest='module', default=None, - help='a module to load and export.') - parser.add_option( - '-l', '--logfile', type='string', dest='logfile', default=None, - help='file to log to.') - options, args = parser.parse_args() - global _g_logfile - if options.logfile: - _g_logfile = open(options.logfile, 'a') - if options.module: - export = api.named(options.module) - server = Server(sys.stdin, sys.stdout, export) - elif options.child: - server = Server(sys.stdin, sys.stdout, {}) - - # *HACK: some modules may emit on stderr, which breaks everything. - class NullSTDOut(object): - def write(a, b): - pass - sys.stderr = NullSTDOut() - sys.stdout = NullSTDOut() - - # Loop until EOF - server.loop() - if _g_logfile: - _g_logfile.close() - - -if __name__ == "__main__": - main() diff --git a/linden/indra/lib/python/indra/ipc/siesta.py b/linden/indra/lib/python/indra/ipc/siesta.py index 5fbea29..b206f18 100644 --- a/linden/indra/lib/python/indra/ipc/siesta.py +++ b/linden/indra/lib/python/indra/ipc/siesta.py @@ -24,9 +24,9 @@ except ImportError: llsd_parsers = { 'application/json': json_decode, - 'application/llsd+binary': llsd.parse_binary, + llsd.BINARY_MIME_TYPE: llsd.parse_binary, 'application/llsd+notation': llsd.parse_notation, - 'application/llsd+xml': llsd.parse_xml, + llsd.XML_MIME_TYPE: llsd.parse_xml, 'application/xml': llsd.parse_xml, } diff --git a/linden/indra/lib/python/indra/util/fastest_elementtree.py b/linden/indra/lib/python/indra/util/fastest_elementtree.py index 64aed09..2470143 100644 --- a/linden/indra/lib/python/indra/util/fastest_elementtree.py +++ b/linden/indra/lib/python/indra/util/fastest_elementtree.py @@ -2,9 +2,9 @@ @file fastest_elementtree.py @brief Concealing some gnarly import logic in here. This should export the interface of elementtree. -$LicenseInfo:firstyear=2006&license=mit$ +$LicenseInfo:firstyear=2008&license=mit$ -Copyright (c) 2006-2008, Linden Research, Inc. +Copyright (c) 2008, Linden Research, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -26,27 +26,40 @@ THE SOFTWARE. $/LicenseInfo$ """ -# Using celementree might cause some unforeseen problems so here's a +# The parsing exception raised by the underlying library depends +# on the ElementTree implementation we're using, so we provide an +# alias here. +# +# Use ElementTreeError as the exception type for catching parsing +# errors. + + +# Using cElementTree might cause some unforeseen problems, so here's a # convenient off switch. -# *NOTE: turned off cause of problems. :-( *TODO: debug -use_celementree = False +use_celementree = True try: if not use_celementree: raise ImportError() - from cElementTree import * ## This does not work under Windows + # Python 2.3 and 2.4. + from cElementTree import * + ElementTreeError = SyntaxError except ImportError: try: if not use_celementree: raise ImportError() - ## This is the name of cElementTree under python 2.5 + # Python 2.5 and above. from xml.etree.cElementTree import * + ElementTreeError = SyntaxError except ImportError: + # Pure Python code. try: - ## This is the old name of elementtree, for use with 2.3 + # Python 2.3 and 2.4. from elementtree.ElementTree import * except ImportError: - ## This is the name of elementtree under python 2.5 + # Python 2.5 and above. from xml.etree.ElementTree import * + # The pure Python ElementTree module uses Expat for parsing. + from xml.parsers.expat import ExpatError as ElementTreeError diff --git a/linden/indra/lib/python/indra/util/iterators.py b/linden/indra/lib/python/indra/util/iterators.py new file mode 100644 index 0000000..6a98c97 --- /dev/null +++ b/linden/indra/lib/python/indra/util/iterators.py @@ -0,0 +1,63 @@ +"""\ +@file iterators.py +@brief Useful general-purpose iterators. + +$LicenseInfo:firstyear=2008&license=mit$ + +Copyright (c) 2008, Linden Research, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +$/LicenseInfo$ +""" + +from __future__ import nested_scopes + +def iter_chunks(rows, aggregate_size=100): + """ + Given an iterable set of items (@p rows), produces lists of up to @p + aggregate_size items at a time, for example: + + iter_chunks([1,2,3,4,5,6,7,8,9,10], 3) + + Values for @p aggregate_size < 1 will raise ValueError. + + Will return a generator that produces, in the following order: + - [1, 2, 3] + - [4, 5, 6] + - [7, 8, 9] + - [10] + """ + if aggregate_size < 1: + raise ValueError() + + def iter_chunks_inner(): + row_iter = iter(rows) + done = False + agg = [] + while not done: + try: + row = row_iter.next() + agg.append(row) + except StopIteration: + done = True + if agg and (len(agg) >= aggregate_size or done): + yield agg + agg = [] + + return iter_chunks_inner() diff --git a/linden/indra/lib/python/indra/util/iterators_test.py b/linden/indra/lib/python/indra/util/iterators_test.py new file mode 100755 index 0000000..7fd9e73 --- /dev/null +++ b/linden/indra/lib/python/indra/util/iterators_test.py @@ -0,0 +1,72 @@ +"""\ +@file iterators_test.py +@brief Test cases for iterators module. + +$LicenseInfo:firstyear=2008&license=mit$ + +Copyright (c) 2008, Linden Research, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +$/LicenseInfo$ +""" + +import unittest + +from indra.util.iterators import iter_chunks + +class TestIterChunks(unittest.TestCase): + """Unittests for iter_chunks""" + def test_bad_agg_size(self): + rows = [1,2,3,4] + self.assertRaises(ValueError, iter_chunks, rows, 0) + self.assertRaises(ValueError, iter_chunks, rows, -1) + + try: + for i in iter_chunks(rows, 0): + pass + except ValueError: + pass + else: + self.fail() + + try: + result = list(iter_chunks(rows, 0)) + except ValueError: + pass + else: + self.fail() + def test_empty(self): + rows = [] + result = list(iter_chunks(rows)) + self.assertEqual(result, []) + def test_small(self): + rows = [[1]] + result = list(iter_chunks(rows, 2)) + self.assertEqual(result, [[[1]]]) + def test_size(self): + rows = [[1],[2]] + result = list(iter_chunks(rows, 2)) + self.assertEqual(result, [[[1],[2]]]) + def test_multi_agg(self): + rows = [[1],[2],[3],[4],[5]] + result = list(iter_chunks(rows, 2)) + self.assertEqual(result, [[[1],[2]],[[3],[4]],[[5]]]) + +if __name__ == "__main__": + unittest.main() diff --git a/linden/indra/lib/python/indra/util/llmanifest.py b/linden/indra/lib/python/indra/util/llmanifest.py index 4675177..a00d242 100644 --- a/linden/indra/lib/python/indra/util/llmanifest.py +++ b/linden/indra/lib/python/indra/util/llmanifest.py @@ -584,7 +584,7 @@ class LLManifest(object): def wildcard_regex(self, src_glob, dst_glob): src_re = re.escape(src_glob) - src_re = src_re.replace('\*', '([-a-zA-Z0-9._ ]+)') + src_re = src_re.replace('\*', '([-a-zA-Z0-9._ ]*)') dst_temp = dst_glob i = 1 while dst_temp.count("*") > 0: @@ -621,6 +621,7 @@ class LLManifest(object): count = 0 if self.wildcard_pattern.search(src): for s,d in self.expand_globs(src, dst): + assert(s != d) count += self.process_file(s, d) else: # if we're specifying a single path (not a glob), diff --git a/linden/indra/lib/python/indra/util/llperformance.py b/linden/indra/lib/python/indra/util/llperformance.py new file mode 100755 index 0000000..7c52730 --- /dev/null +++ b/linden/indra/lib/python/indra/util/llperformance.py @@ -0,0 +1,158 @@ +#!/usr/bin/python + +# ------------------------------------------------ +# Sim metrics utility functions. + +import glob, os, time, sys, stat, exceptions + +from indra.base import llsd + +gBlockMap = {} #Map of performance metric data with function hierarchy information. +gCurrentStatPath = "" + +gIsLoggingEnabled=False + +class LLPerfStat: + def __init__(self,key): + self.mTotalTime = 0 + self.mNumRuns = 0 + self.mName=key + self.mTimeStamp = int(time.time()*1000) + self.mUTCTime = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()) + + def __str__(self): + return "%f" % self.mTotalTime + + def start(self): + self.mStartTime = int(time.time() * 1000000) + self.mNumRuns += 1 + + def stop(self): + execution_time = int(time.time() * 1000000) - self.mStartTime + self.mTotalTime += execution_time + + def get_map(self): + results={} + results['name']=self.mName + results['utc_time']=self.mUTCTime + results['timestamp']=self.mTimeStamp + results['us']=self.mTotalTime + results['count']=self.mNumRuns + return results + +class PerfError(exceptions.Exception): + def __init__(self): + return + + def __Str__(self): + print "","Unfinished LLPerfBlock" + +class LLPerfBlock: + def __init__( self, key ): + global gBlockMap + global gCurrentStatPath + global gIsLoggingEnabled + + #Check to see if we're running metrics right now. + if gIsLoggingEnabled: + self.mRunning = True #Mark myself as running. + + self.mPreviousStatPath = gCurrentStatPath + gCurrentStatPath += "/" + key + if gCurrentStatPath not in gBlockMap: + gBlockMap[gCurrentStatPath] = LLPerfStat(key) + + self.mStat = gBlockMap[gCurrentStatPath] + self.mStat.start() + + def finish( self ): + global gBlockMap + global gIsLoggingEnabled + + if gIsLoggingEnabled: + self.mStat.stop() + self.mRunning = False + gCurrentStatPath = self.mPreviousStatPath + +# def __del__( self ): +# if self.mRunning: +# #SPATTERS FIXME +# raise PerfError + +class LLPerformance: + #-------------------------------------------------- + # Determine whether or not we want to log statistics + + def __init__( self, process_name = "python" ): + self.process_name = process_name + self.init_testing() + self.mTimeStamp = int(time.time()*1000) + self.mUTCTime = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()) + + def init_testing( self ): + global gIsLoggingEnabled + + host_performance_file = "/dev/shm/simperf/simperf_proc_config.llsd" + + #If file exists, open + if os.path.exists(host_performance_file): + file = open (host_performance_file,'r') + + #Read serialized LLSD from file. + body = llsd.parse(file.read()) + + #Calculate time since file last modified. + stats = os.stat(host_performance_file) + now = time.time() + mod = stats[stat.ST_MTIME] + age = now - mod + + if age < ( body['duration'] ): + gIsLoggingEnabled = True + + + def get ( self ): + global gIsLoggingEnabled + return gIsLoggingEnabled + + #def output(self,ptr,path): + # if 'stats' in ptr: + # stats = ptr['stats'] + # self.mOutputPtr[path] = stats.get_map() + + # if 'children' in ptr: + # children=ptr['children'] + + # curptr = self.mOutputPtr + # curchildren={} + # curptr['children'] = curchildren + + # for key in children: + # curchildren[key]={} + # self.mOutputPtr = curchildren[key] + # self.output(children[key],path + '/' + key) + + def done(self): + global gBlockMap + + if not self.get(): + return + + output_name = "/dev/shm/simperf/%s_proc.%d.llsd" % (self.process_name, os.getpid()) + output_file = open(output_name, 'w') + process_info = { + "name" : self.process_name, + "pid" : os.getpid(), + "ppid" : os.getppid(), + "timestamp" : self.mTimeStamp, + "utc_time" : self.mUTCTime, + } + output_file.write(llsd.format_notation(process_info)) + output_file.write('\n') + + for key in gBlockMap.keys(): + gBlockMap[key] = gBlockMap[key].get_map() + output_file.write(llsd.format_notation(gBlockMap)) + output_file.write('\n') + output_file.close() + diff --git a/linden/indra/lib/python/indra/util/named_query.py b/linden/indra/lib/python/indra/util/named_query.py index 20f2ec7..c5fb498 100644 --- a/linden/indra/lib/python/indra/util/named_query.py +++ b/linden/indra/lib/python/indra/util/named_query.py @@ -63,7 +63,7 @@ def _init_g_named_manager(sql_dir = None): # extra fallback directory in case config doesn't return what we want if sql_dir is None: - sql_dir = os.path.dirname(__file__) + "../../../../web/dataservice/sql" + sql_dir = os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "web", "dataservice", "sql") global _g_named_manager _g_named_manager = NamedQueryManager( @@ -103,11 +103,12 @@ class NamedQuery(object): def __init__(self, name, filename): """ Construct a NamedQuery object. The name argument is an arbitrary name as a handle for the query, and the filename is - a path to a file containing an llsd named query document.""" + a path to a file or a file-like object containing an llsd named + query document.""" self._stat_interval_seconds = 5 # 5 seconds self._name = name - if (filename is not None) \ - and (NQ_FILE_SUFFIX != filename[-NQ_FILE_SUFFIX_LEN:]): + if (filename is not None and isinstance(filename, (str, unicode)) + and NQ_FILE_SUFFIX != filename[-NQ_FILE_SUFFIX_LEN:]): filename = filename + NQ_FILE_SUFFIX self._location = filename self._alternative = dict() @@ -122,8 +123,8 @@ class NamedQuery(object): def get_modtime(self): """ Returns the mtime (last modified time) of the named query - file, if such exists.""" - if self._location: + filename. For file-like objects, expect a modtime of 0""" + if self._location and isinstance(self._location, (str, unicode)): return os.path.getmtime(self._location) return 0 @@ -131,7 +132,12 @@ class NamedQuery(object): """ Loads and parses the named query file into self. Does nothing if self.location is nonexistant.""" if self._location: - self._reference_contents(llsd.parse(open(self._location).read())) + if isinstance(self._location, (str, unicode)): + contents = llsd.parse(open(self._location).read()) + else: + # we probably have a file-like object. Godspeed! + contents = llsd.parse(self._location.read()) + self._reference_contents(contents) # Check for alternative implementations try: for name, alt in self._contents['alternative'].items(): diff --git a/linden/indra/lib/python/indra/util/simperf_host_xml_parser.py b/linden/indra/lib/python/indra/util/simperf_host_xml_parser.py new file mode 100755 index 0000000..b608415 --- /dev/null +++ b/linden/indra/lib/python/indra/util/simperf_host_xml_parser.py @@ -0,0 +1,338 @@ +#!/usr/bin/env python +"""\ +@file simperf_host_xml_parser.py +@brief Digest collector's XML dump and convert to simple dict/list structure + +$LicenseInfo:firstyear=2008&license=mit$ + +Copyright (c) 2008, Linden Research, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +$/LicenseInfo$ +""" + +import sys, os, getopt, time +import simplejson +from xml import sax + + +def usage(): + print "Usage:" + print sys.argv[0] + " [options]" + print " Convert RRD's XML dump to JSON. Script to convert the simperf_host_collector-" + print " generated RRD dump into JSON. Steps include converting selected named" + print " fields from GAUGE type to COUNTER type by computing delta with preceding" + print " values. Top-level named fields are:" + print + print " lastupdate Time (javascript timestamp) of last data sample" + print " step Time in seconds between samples" + print " ds Data specification (name/type) for each column" + print " database Table of data samples, one time step per row" + print + print "Options:" + print " -i, --in Input settings filename. (Default: stdin)" + print " -o, --out Output settings filename. (Default: stdout)" + print " -h, --help Print this message and exit." + print + print "Example: %s -i rrddump.xml -o rrddump.json" % sys.argv[0] + print + print "Interfaces:" + print " class SimPerfHostXMLParser() # SAX content handler" + print " def simperf_host_xml_fixup(parser) # post-parse value fixup" + +class SimPerfHostXMLParser(sax.handler.ContentHandler): + + def __init__(self): + pass + + def startDocument(self): + self.rrd_last_update = 0 # public + self.rrd_step = 0 # public + self.rrd_ds = [] # public + self.rrd_records = [] # public + self._rrd_level = 0 + self._rrd_parse_state = 0 + self._rrd_chars = "" + self._rrd_capture = False + self._rrd_ds_val = {} + self._rrd_data_row = [] + self._rrd_data_row_has_nan = False + + def endDocument(self): + pass + + # Nasty little ad-hoc state machine to extract the elements that are + # necessary from the 'rrdtool dump' XML output. The same element + # name '' is used for two different data sets so we need to pay + # some attention to the actual structure to get the ones we want + # and ignore the ones we don't. + + def startElement(self, name, attrs): + self._rrd_level = self._rrd_level + 1 + self._rrd_capture = False + if self._rrd_level == 1: + if name == "rrd" and self._rrd_parse_state == 0: + self._rrd_parse_state = 1 # In + self._rrd_capture = True + self._rrd_chars = "" + elif self._rrd_level == 2: + if self._rrd_parse_state == 1: + if name == "lastupdate": + self._rrd_parse_state = 2 # In + self._rrd_capture = True + self._rrd_chars = "" + elif name == "step": + self._rrd_parse_state = 3 # In + self._rrd_capture = True + self._rrd_chars = "" + elif name == "ds": + self._rrd_parse_state = 4 # In + self._rrd_ds_val = {} + self._rrd_chars = "" + elif name == "rra": + self._rrd_parse_state = 5 # In + elif self._rrd_level == 3: + if self._rrd_parse_state == 4: + if name == "name": + self._rrd_parse_state = 6 # In + self._rrd_capture = True + self._rrd_chars = "" + elif name == "type": + self._rrd_parse_state = 7 # In + self._rrd_capture = True + self._rrd_chars = "" + elif self._rrd_parse_state == 5: + if name == "database": + self._rrd_parse_state = 8 # In + elif self._rrd_level == 4: + if self._rrd_parse_state == 8: + if name == "row": + self._rrd_parse_state = 9 # In + self._rrd_data_row = [] + self._rrd_data_row_has_nan = False + elif self._rrd_level == 5: + if self._rrd_parse_state == 9: + if name == "v": + self._rrd_parse_state = 10 # In + self._rrd_capture = True + self._rrd_chars = "" + + def endElement(self, name): + self._rrd_capture = False + if self._rrd_parse_state == 10: + self._rrd_capture = self._rrd_level == 6 + if self._rrd_level == 5: + if self._rrd_chars == "NaN": + self._rrd_data_row_has_nan = True + else: + self._rrd_data_row.append(self._rrd_chars) + self._rrd_parse_state = 9 # In + elif self._rrd_parse_state == 9: + if self._rrd_level == 4: + if not self._rrd_data_row_has_nan: + self.rrd_records.append(self._rrd_data_row) + self._rrd_parse_state = 8 # In + elif self._rrd_parse_state == 8: + if self._rrd_level == 3: + self._rrd_parse_state = 5 # In + elif self._rrd_parse_state == 7: + if self._rrd_level == 3: + self._rrd_ds_val["type"] = self._rrd_chars + self._rrd_parse_state = 4 # In + elif self._rrd_parse_state == 6: + if self._rrd_level == 3: + self._rrd_ds_val["name"] = self._rrd_chars + self._rrd_parse_state = 4 # In + elif self._rrd_parse_state == 5: + if self._rrd_level == 2: + self._rrd_parse_state = 1 # In + elif self._rrd_parse_state == 4: + if self._rrd_level == 2: + self.rrd_ds.append(self._rrd_ds_val) + self._rrd_parse_state = 1 # In + elif self._rrd_parse_state == 3: + if self._rrd_level == 2: + self.rrd_step = long(self._rrd_chars) + self._rrd_parse_state = 1 # In + elif self._rrd_parse_state == 2: + if self._rrd_level == 2: + self.rrd_last_update = long(self._rrd_chars) + self._rrd_parse_state = 1 # In + elif self._rrd_parse_state == 1: + if self._rrd_level == 1: + self._rrd_parse_state = 0 # At top + + if self._rrd_level: + self._rrd_level = self._rrd_level - 1 + + def characters(self, content): + if self._rrd_capture: + self._rrd_chars = self._rrd_chars + content.strip() + +def _make_numeric(value): + try: + value = float(value) + except: + value = "" + return value + +def simperf_host_xml_fixup(parser, filter_start_time = None, filter_end_time = None): + # Fixup for GAUGE fields that are really COUNTS. They + # were forced to GAUGE to try to disable rrdtool's + # data interpolation/extrapolation for non-uniform time + # samples. + fixup_tags = [ "cpu_user", + "cpu_nice", + "cpu_sys", + "cpu_idle", + "cpu_waitio", + "cpu_intr", + # "file_active", + # "file_free", + # "inode_active", + # "inode_free", + "netif_in_kb", + "netif_in_pkts", + "netif_in_errs", + "netif_in_drop", + "netif_out_kb", + "netif_out_pkts", + "netif_out_errs", + "netif_out_drop", + "vm_page_in", + "vm_page_out", + "vm_swap_in", + "vm_swap_out", + #"vm_mem_total", + #"vm_mem_used", + #"vm_mem_active", + #"vm_mem_inactive", + #"vm_mem_free", + #"vm_mem_buffer", + #"vm_swap_cache", + #"vm_swap_total", + #"vm_swap_used", + #"vm_swap_free", + "cpu_interrupts", + "cpu_switches", + "cpu_forks" ] + + col_count = len(parser.rrd_ds) + row_count = len(parser.rrd_records) + + # Process the last row separately, just to make all values numeric. + for j in range(col_count): + parser.rrd_records[row_count - 1][j] = _make_numeric(parser.rrd_records[row_count - 1][j]) + + # Process all other row/columns. + last_different_row = row_count - 1 + current_row = row_count - 2 + while current_row >= 0: + # Check for a different value than the previous row. If everything is the same + # then this is probably just a filler/bogus entry. + is_different = False + for j in range(col_count): + parser.rrd_records[current_row][j] = _make_numeric(parser.rrd_records[current_row][j]) + if parser.rrd_records[current_row][j] != parser.rrd_records[last_different_row][j]: + # We're good. This is a different row. + is_different = True + + if not is_different: + # This is a filler/bogus entry. Just ignore it. + for j in range(col_count): + parser.rrd_records[current_row][j] = float('nan') + else: + # Some tags need to be converted into deltas. + for j in range(col_count): + if parser.rrd_ds[j]["name"] in fixup_tags: + parser.rrd_records[last_different_row][j] = \ + parser.rrd_records[last_different_row][j] - parser.rrd_records[current_row][j] + last_different_row = current_row + + current_row -= 1 + + # Set fixup_tags in the first row to 'nan' since they aren't useful anymore. + for j in range(col_count): + if parser.rrd_ds[j]["name"] in fixup_tags: + parser.rrd_records[0][j] = float('nan') + + # Add a timestamp to each row and to the catalog. Format and name + # chosen to match other simulator logging (hopefully). + start_time = parser.rrd_last_update - (parser.rrd_step * (row_count - 1)) + # Build a filtered list of rrd_records if we are limited to a time range. + filter_records = False + if filter_start_time is not None or filter_end_time is not None: + filter_records = True + filtered_rrd_records = [] + if filter_start_time is None: + filter_start_time = start_time * 1000 + if filter_end_time is None: + filter_end_time = parser.rrd_last_update * 1000 + + for i in range(row_count): + record_timestamp = (start_time + (i * parser.rrd_step)) * 1000 + parser.rrd_records[i].insert(0, record_timestamp) + if filter_records: + if filter_start_time <= record_timestamp and record_timestamp <= filter_end_time: + filtered_rrd_records.append(parser.rrd_records[i]) + + if filter_records: + parser.rrd_records = filtered_rrd_records + + parser.rrd_ds.insert(0, {"type": "GAUGE", "name": "javascript_timestamp"}) + + +def main(argv=None): + opts, args = getopt.getopt(sys.argv[1:], "i:o:h", ["in=", "out=", "help"]) + input_file = sys.stdin + output_file = sys.stdout + for o, a in opts: + if o in ("-i", "--in"): + input_file = open(a, 'r') + if o in ("-o", "--out"): + output_file = open(a, 'w') + if o in ("-h", "--help"): + usage() + sys.exit(0) + + # Using the SAX parser as it is at least 4X faster and far, far + # smaller on this dataset than the DOM-based interface in xml.dom.minidom. + # With SAX and a 5.4MB xml file, this requires about seven seconds of + # wall-clock time and 32MB VSZ. With the DOM interface, about 22 seconds + # and over 270MB VSZ. + + handler = SimPerfHostXMLParser() + sax.parse(input_file, handler) + if input_file != sys.stdin: + input_file.close() + + # Various format fixups: string-to-num, gauge-to-counts, add + # a time stamp, etc. + simperf_host_xml_fixup(handler) + + # Create JSONable dict with interesting data and format/print it + print >>output_file, simplejson.dumps({ "step" : handler.rrd_step, + "lastupdate": handler.rrd_last_update * 1000, + "ds" : handler.rrd_ds, + "database" : handler.rrd_records }) + + return 0 + +if __name__ == "__main__": + sys.exit(main()) diff --git a/linden/indra/lib/python/indra/util/simperf_oprof_interface.py b/linden/indra/lib/python/indra/util/simperf_oprof_interface.py new file mode 100755 index 0000000..a7e9a4c --- /dev/null +++ b/linden/indra/lib/python/indra/util/simperf_oprof_interface.py @@ -0,0 +1,160 @@ +#!/usr/bin/env python +"""\ +@file simperf_oprof_interface.py +@brief Manage OProfile data collection on a host + +$LicenseInfo:firstyear=2008&license=internal$ + +Copyright (c) 2008, Linden Research, Inc. + +The following source code is PROPRIETARY AND CONFIDENTIAL. Use of +this source code is governed by the Linden Lab Source Code Disclosure +Agreement ("Agreement") previously entered between you and Linden +Lab. By accessing, using, copying, modifying or distributing this +software, you acknowledge that you have been informed of your +obligations under the Agreement 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$ +""" + +import sys, os, getopt +import simplejson + + +def usage(): + print "Usage:" + print sys.argv[0] + " [options]" + print " Digest the OProfile report forms that come out of the" + print " simperf_oprof_ctl program's -r/--report command. The result" + print " is an array of dictionaires with the following keys:" + print + print " symbol Name of sampled, calling, or called procedure" + print " file Executable or library where symbol resides" + print " percentage Percentage contribution to profile, calls or called" + print " samples Sample count" + print " calls Methods called by the method in question (full only)" + print " called_by Methods calling the method (full only)" + print + print " For 'full' reports the two keys 'calls' and 'called_by' are" + print " themselves arrays of dictionaries based on the first four keys." + print + print "Return Codes:" + print " None. Aggressively digests everything. Will likely mung results" + print " if a program or library has whitespace in its name." + print + print "Options:" + print " -i, --in Input settings filename. (Default: stdin)" + print " -o, --out Output settings filename. (Default: stdout)" + print " -h, --help Print this message and exit." + print + print "Interfaces:" + print " class SimPerfOProfileInterface()" + +class SimPerfOProfileInterface: + def __init__(self): + self.isBrief = True # public + self.isValid = False # public + self.result = [] # public + + def parse(self, input): + in_samples = False + for line in input: + if in_samples: + if line[0:6] == "------": + self.isBrief = False + self._parseFull(input) + else: + self._parseBrief(input, line) + self.isValid = True + return + try: + hd1, remain = line.split(None, 1) + if hd1 == "samples": + in_samples = True + except ValueError: + pass + + def _parseBrief(self, input, line1): + try: + fld1, fld2, fld3, fld4 = line1.split(None, 3) + self.result.append({"samples" : fld1, + "percentage" : fld2, + "file" : fld3, + "symbol" : fld4.strip("\n")}) + except ValueError: + pass + for line in input: + try: + fld1, fld2, fld3, fld4 = line.split(None, 3) + self.result.append({"samples" : fld1, + "percentage" : fld2, + "file" : fld3, + "symbol" : fld4.strip("\n")}) + except ValueError: + pass + + def _parseFull(self, input): + state = 0 # In 'called_by' section + calls = [] + called_by = [] + current = {} + for line in input: + if line[0:6] == "------": + if len(current): + current["calls"] = calls + current["called_by"] = called_by + self.result.append(current) + state = 0 + calls = [] + called_by = [] + current = {} + else: + try: + fld1, fld2, fld3, fld4 = line.split(None, 3) + tmp = {"samples" : fld1, + "percentage" : fld2, + "file" : fld3, + "symbol" : fld4.strip("\n")} + except ValueError: + continue + if line[0] != " ": + current = tmp + state = 1 # In 'calls' section + elif state == 0: + called_by.append(tmp) + else: + calls.append(tmp) + if len(current): + current["calls"] = calls + current["called_by"] = called_by + self.result.append(current) + + +def main(argv=None): + opts, args = getopt.getopt(sys.argv[1:], "i:o:h", ["in=", "out=", "help"]) + input_file = sys.stdin + output_file = sys.stdout + for o, a in opts: + if o in ("-i", "--in"): + input_file = open(a, 'r') + if o in ("-o", "--out"): + output_file = open(a, 'w') + if o in ("-h", "--help"): + usage() + sys.exit(0) + + oprof = SimPerfOProfileInterface() + oprof.parse(input_file) + if input_file != sys.stdin: + input_file.close() + + # Create JSONable dict with interesting data and format/print it + print >>output_file, simplejson.dumps(oprof.result) + + return 0 + +if __name__ == "__main__": + sys.exit(main()) diff --git a/linden/indra/lib/python/indra/util/simperf_proc_interface.py b/linden/indra/lib/python/indra/util/simperf_proc_interface.py new file mode 100755 index 0000000..62a63fa --- /dev/null +++ b/linden/indra/lib/python/indra/util/simperf_proc_interface.py @@ -0,0 +1,164 @@ +#!/usr/bin/python + +# ---------------------------------------------------- +# Utility to extract log messages from *..llsd +# files that contain performance statistics. + +# ---------------------------------------------------- +import sys, os + +if os.path.exists("setup-path.py"): + execfile("setup-path.py") + +from indra.base import llsd + +DEFAULT_PATH="/dev/shm/simperf/" + + +# ---------------------------------------------------- +# Pull out the stats and return a single document +def parse_logfile(filename, target_column=None, verbose=False): + full_doc = [] + # Open source temp log file. Let exceptions percolate up. + sourcefile = open( filename,'r') + + if verbose: + print "Reading " + filename + + # Parse and output all lines from the temp file + for line in sourcefile.xreadlines(): + partial_doc = llsd.parse(line) + if partial_doc is not None: + if target_column is None: + full_doc.append(partial_doc) + else: + trim_doc = { target_column: partial_doc[target_column] } + if target_column != "fps": + trim_doc[ 'fps' ] = partial_doc[ 'fps' ] + trim_doc[ '/total_time' ] = partial_doc[ '/total_time' ] + trim_doc[ 'utc_time' ] = partial_doc[ 'utc_time' ] + full_doc.append(trim_doc) + + sourcefile.close() + return full_doc + +# Extract just the meta info line, and the timestamp of the first/last frame entry. +def parse_logfile_info(filename, verbose=False): + # Open source temp log file. Let exceptions percolate up. + sourcefile = open(filename, 'rU') # U is to open with Universal newline support + + if verbose: + print "Reading " + filename + + # The first line is the meta info line. + info_line = sourcefile.readline() + if not info_line: + sourcefile.close() + return None + + # The rest of the lines are frames. Read the first and last to get the time range. + info = llsd.parse( info_line ) + info['start_time'] = None + info['end_time'] = None + first_frame = sourcefile.readline() + if first_frame: + try: + info['start_time'] = int(llsd.parse(first_frame)['timestamp']) + except: + pass + + # Read the file backwards to find the last two lines. + sourcefile.seek(0, 2) + file_size = sourcefile.tell() + offset = 1024 + num_attempts = 0 + end_time = None + if file_size < offset: + offset = file_size + while 1: + sourcefile.seek(-1*offset, 2) + read_str = sourcefile.read(offset) + # Remove newline at the end + if read_str[offset - 1] == '\n': + read_str = read_str[0:-1] + lines = read_str.split('\n') + full_line = None + if len(lines) > 2: # Got two line + try: + end_time = llsd.parse(lines[-1])['timestamp'] + except: + # We couldn't parse this line. Try once more. + try: + end_time = llsd.parse(lines[-2])['timestamp'] + except: + # Nope. Just move on. + pass + break + if len(read_str) == file_size: # Reached the beginning + break + offset += 1024 + + info['end_time'] = int(end_time) + + sourcefile.close() + return info + + +def parse_proc_filename(filename): + try: + name_as_list = filename.split(".") + cur_stat_type = name_as_list[0].split("_")[0] + cur_pid = name_as_list[1] + except IndexError, ValueError: + return (None, None) + return (cur_pid, cur_stat_type) + +# ---------------------------------------------------- +def get_simstats_list(path=None): + """ Return stats (pid, type) listed in _proc..llsd """ + if path is None: + path = DEFAULT_PATH + simstats_list = [] + for file_name in os.listdir(path): + if file_name.endswith(".llsd") and file_name != "simperf_proc_config.llsd": + simstats_info = parse_logfile_info(path + file_name) + if simstats_info is not None: + simstats_list.append(simstats_info) + return simstats_list + +def get_log_info_list(pid=None, stat_type=None, path=None, target_column=None, verbose=False): + """ Return data from all llsd files matching the pid and stat type """ + if path is None: + path = DEFAULT_PATH + log_info_list = {} + for file_name in os.listdir ( path ): + if file_name.endswith(".llsd") and file_name != "simperf_proc_config.llsd": + (cur_pid, cur_stat_type) = parse_proc_filename(file_name) + if cur_pid is None: + continue + if pid is not None and pid != cur_pid: + continue + if stat_type is not None and stat_type != cur_stat_type: + continue + log_info_list[cur_pid] = parse_logfile(path + file_name, target_column, verbose) + return log_info_list + +def delete_simstats_files(pid=None, stat_type=None, path=None): + """ Delete *..llsd files """ + if path is None: + path = DEFAULT_PATH + del_list = [] + for file_name in os.listdir(path): + if file_name.endswith(".llsd") and file_name != "simperf_proc_config.llsd": + (cur_pid, cur_stat_type) = parse_proc_filename(file_name) + if cur_pid is None: + continue + if pid is not None and pid != cur_pid: + continue + if stat_type is not None and stat_type != cur_stat_type: + continue + del_list.append(cur_pid) + # Allow delete related exceptions to percolate up if this fails. + os.unlink(os.path.join(DEFAULT_PATH, file_name)) + return del_list + diff --git a/linden/indra/linux_crash_logger/CMakeLists.txt b/linden/indra/linux_crash_logger/CMakeLists.txt index 628d4ac..6f6754e 100644 --- a/linden/indra/linux_crash_logger/CMakeLists.txt +++ b/linden/indra/linux_crash_logger/CMakeLists.txt @@ -3,7 +3,6 @@ project(linux_crash_logger) include(00-Common) -include(Boost) include(LLCommon) include(LLCrashLogger) include(LLMath) @@ -52,17 +51,15 @@ target_link_libraries(linux-crash-logger ${LLMATH_LIBRARIES} ${LLCOMMON_LIBRARIES} ${UI_LIBRARIES} - ${BOOST_SIGNALS_LIBRARY} ${DB_LIBRARIES} ) add_custom_command( OUTPUT linux-crash-logger-stripped COMMAND strip - ARGS --strip-debug -o linux-crash-logger-stripped - linux-crash-logger + ARGS --strip-debug -o linux-crash-logger-stripped linux-crash-logger DEPENDS linux-crash-logger ) -add_custom_target(linux-crash-logger-stripped ALL +add_custom_target(linux-crash-logger-strip-target ALL DEPENDS linux-crash-logger-stripped) diff --git a/linden/indra/llaudio/CMakeLists.txt b/linden/indra/llaudio/CMakeLists.txt index b662023..ebedcab 100644 --- a/linden/indra/llaudio/CMakeLists.txt +++ b/linden/indra/llaudio/CMakeLists.txt @@ -65,3 +65,10 @@ set_source_files_properties(${llaudio_HEADER_FILES} list(APPEND llaudio_SOURCE_FILES ${llaudio_HEADER_FILES}) add_library (llaudio ${llaudio_SOURCE_FILES}) +target_link_libraries( + llaudio + ${VORBISENC_LIBRARIES} + ${VORBISFILE_LIBRARIES} + ${VORBIS_LIBRARIES} + ${OGG_LIBRARIES} + ) diff --git a/linden/indra/llaudio/audioengine.cpp b/linden/indra/llaudio/audioengine.cpp index 5dd5b28..298ab1d 100644 --- a/linden/indra/llaudio/audioengine.cpp +++ b/linden/indra/llaudio/audioengine.cpp @@ -96,6 +96,9 @@ void LLAudioEngine::setDefaults() mMasterGain = 1.f; mInternetStreamGain = 0.125f; mNextWindUpdate = 0.f; + + for (U32 i = 0; i < LLAudioEngine::AUDIO_TYPE_COUNT; i++) + mSecondaryGain[i] = 1.0f; } @@ -167,6 +170,13 @@ void LLAudioEngine::updateChannels() { if (mChannels[i]) { + // set secondary gain if type is available + LLAudioSource* source = mChannels[i]->getSource(); + if (source) + { + mChannels[i]->setSecondaryGain(mSecondaryGain[source->getType()]); + } + mChannels[i]->updateBuffer(); mChannels[i]->update3DPosition(); mChannels[i]->updateLoop(); @@ -643,6 +653,18 @@ F32 LLAudioEngine::getMasterGain() return mMasterGain; } +void LLAudioEngine::setSecondaryGain(S32 type, F32 gain) +{ + llassert(type < LLAudioEngine::AUDIO_TYPE_COUNT); + + mSecondaryGain[type] = gain; +} + +F32 LLAudioEngine::getSecondaryGain(S32 type) +{ + return mSecondaryGain[type]; +} + F32 LLAudioEngine::getInternetStreamGain() { return mInternetStreamGain; @@ -718,7 +740,8 @@ F64 LLAudioEngine::mapWindVecToPan(LLVector3 wind_vec) } -void LLAudioEngine::triggerSound(const LLUUID &audio_uuid, const LLUUID& owner_id, const F32 gain, const LLVector3d &pos_global) +void LLAudioEngine::triggerSound(const LLUUID &audio_uuid, const LLUUID& owner_id, const F32 gain, + const S32 type, const LLVector3d &pos_global) { // Create a new source (since this can't be associated with an existing source. //llinfos << "Localized: " << audio_uuid << llendl; @@ -731,7 +754,7 @@ void LLAudioEngine::triggerSound(const LLUUID &audio_uuid, const LLUUID& owner_i LLUUID source_id; source_id.generate(); - LLAudioSource *asp = new LLAudioSource(source_id, owner_id, gain); + LLAudioSource *asp = new LLAudioSource(source_id, owner_id, gain, type); gAudiop->addAudioSource(asp); if (pos_global.isExactlyZero()) { @@ -1180,11 +1203,12 @@ void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::E // -LLAudioSource::LLAudioSource(const LLUUID& id, const LLUUID& owner_id, const F32 gain) +LLAudioSource::LLAudioSource(const LLUUID& id, const LLUUID& owner_id, const F32 gain, const S32 type) : mID(id), mOwnerID(owner_id), mPriority(0.f), mGain(gain), + mType(type), mAmbient(FALSE), mLoop(FALSE), mSyncMaster(FALSE), @@ -1515,7 +1539,8 @@ LLAudioChannel::LLAudioChannel() : mCurrentSourcep(NULL), mCurrentBufferp(NULL), mLoopedThisFrame(FALSE), - mWaiting(FALSE) + mWaiting(FALSE), + mSecondaryGain(1.0f) { } diff --git a/linden/indra/llaudio/audioengine.h b/linden/indra/llaudio/audioengine.h index e38413f..b8153a3 100644 --- a/linden/indra/llaudio/audioengine.h +++ b/linden/indra/llaudio/audioengine.h @@ -78,6 +78,15 @@ class LLAudioBuffer; class LLAudioEngine { public: + enum LLAudioType + { + AUDIO_TYPE_NONE = 0, + AUDIO_TYPE_SFX = 1, + AUDIO_TYPE_UI = 2, + AUDIO_TYPE_AMBIENT = 3, + AUDIO_TYPE_COUNT = 4 // last + }; + LLAudioEngine(); virtual ~LLAudioEngine(); @@ -109,6 +118,9 @@ public: F32 getMasterGain(); void setMasterGain(F32 gain); + F32 getSecondaryGain(S32 type); + void setSecondaryGain(S32 type, F32 gain); + F32 getInternetStreamGain(); virtual void setDopplerFactor(F32 factor); @@ -122,7 +134,9 @@ public: // Methods actually related to setting up and removing sounds // Owner ID is the owner of the object making the request - void triggerSound(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, const LLVector3d &pos_global = LLVector3d::zero); + void triggerSound(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, + const S32 type = LLAudioEngine::AUDIO_TYPE_NONE, + const LLVector3d &pos_global = LLVector3d::zero); BOOL preloadSound(const LLUUID &id); void addAudioSource(LLAudioSource *asp); @@ -222,6 +236,7 @@ protected: LLAudioBuffer *mBuffers[MAX_BUFFERS]; F32 mMasterGain; + F32 mSecondaryGain[AUDIO_TYPE_COUNT]; // Hack! Internet streams are treated differently from other sources! F32 mInternetStreamGain; @@ -247,7 +262,7 @@ class LLAudioSource public: // owner_id is the id of the agent responsible for making this sound // play, for example, the owner of the object currently playing it - LLAudioSource(const LLUUID &id, const LLUUID& owner_id, const F32 gain); + LLAudioSource(const LLUUID &id, const LLUUID& owner_id, const F32 gain, const S32 type = LLAudioEngine::AUDIO_TYPE_NONE); virtual ~LLAudioSource(); virtual void update(); // Update this audio source @@ -274,6 +289,9 @@ public: void setPlayedOnce(const BOOL played_once) { mPlayedOnce = played_once; } + void setType(S32 type) { mType = type; } + S32 getType() { return mType; } + void setPositionGlobal(const LLVector3d &position_global) { mPositionGlobal = position_global; } LLVector3d getPositionGlobal() const { return mPositionGlobal; } LLVector3 getVelocity() const { return mVelocity; } @@ -312,6 +330,7 @@ protected: BOOL mSyncSlave; BOOL mQueueSounds; BOOL mPlayedOnce; + S32 mType; LLVector3d mPositionGlobal; LLVector3 mVelocity; @@ -380,6 +399,9 @@ public: virtual void setSource(LLAudioSource *sourcep); LLAudioSource *getSource() const { return mCurrentSourcep; } + void setSecondaryGain(F32 gain) { mSecondaryGain = gain; } + F32 getSecondaryGain() { return mSecondaryGain; } + friend class LLAudioEngine; friend class LLAudioSource; protected: @@ -398,6 +420,7 @@ protected: LLAudioBuffer *mCurrentBufferp; BOOL mLoopedThisFrame; BOOL mWaiting; // Waiting for sync. + F32 mSecondaryGain; }; diff --git a/linden/indra/llaudio/audioengine_fmod.cpp b/linden/indra/llaudio/audioengine_fmod.cpp index 16d820c..4bf0c95 100644 --- a/linden/indra/llaudio/audioengine_fmod.cpp +++ b/linden/indra/llaudio/audioengine_fmod.cpp @@ -488,7 +488,7 @@ BOOL LLAudioChannelFMOD::updateBuffer() if (mCurrentSourcep) { // SJB: warnings can spam and hurt framerate, disabling - if (!FSOUND_SetVolume(mChannelID, llround(mCurrentSourcep->getGain() * 255.0f))) + if (!FSOUND_SetVolume(mChannelID, llround(getSecondaryGain() * mCurrentSourcep->getGain() * 255.0f))) { // llwarns << "LLAudioChannelFMOD::updateBuffer error: " << FMOD_ErrorString(FSOUND_GetError()) << llendl; } diff --git a/linden/indra/llcharacter/llbvhloader.cpp b/linden/indra/llcharacter/llbvhloader.cpp index cd1f492..938f47d 100644 --- a/linden/indra/llcharacter/llbvhloader.cpp +++ b/linden/indra/llcharacter/llbvhloader.cpp @@ -1133,6 +1133,8 @@ void LLBVHLoader::optimize() F32 rot_threshold = ROTATION_KEYFRAME_THRESHOLD / llmax((F32)joint->mChildTreeMaxDepth * 0.33f, 1.f); + double diff_max = 0; + KeyVector::iterator ki_max = ki; for (; ki != joint->mKeys.end(); ++ki) { if (ki_prev == ki_last_good_pos) @@ -1193,30 +1195,55 @@ void LLBVHLoader::optimize() F32 x_delta; F32 y_delta; F32 rot_test; - + + // Test if the rotation has changed significantly since the very first frame. If false + // for all frames, then we'll just throw out this joint's rotation entirely. x_delta = dist_vec(LLVector3::x_axis * first_frame_rot, LLVector3::x_axis * test_rot); y_delta = dist_vec(LLVector3::y_axis * first_frame_rot, LLVector3::y_axis * test_rot); rot_test = x_delta + y_delta; - if (rot_test > ROTATION_MOTION_THRESHOLD) { rot_changed = TRUE; } - x_delta = dist_vec(LLVector3::x_axis * interp_rot, LLVector3::x_axis * test_rot); y_delta = dist_vec(LLVector3::y_axis * interp_rot, LLVector3::y_axis * test_rot); rot_test = x_delta + y_delta; - if (rot_test < rot_threshold) - { - ki_prev->mIgnoreRot = TRUE; - numRotFramesConsidered++; - } - else + // Draw a line between the last good keyframe and current. Test the distance between the last frame (current-1, i.e. ki_prev) + // and the line. If it's greater than some threshold, then it represents a significant frame and we want to include it. + if (rot_test >= rot_threshold || + (ki+1 == joint->mKeys.end() && numRotFramesConsidered > 2)) { + // Add the current test keyframe (which is technically the previous key, i.e. ki_prev). numRotFramesConsidered = 2; ki_last_good_rot = ki_prev; joint->mNumRotKeys++; + + // Add another keyframe between the last good keyframe and current, at whatever point was the most "significant" (i.e. + // had the largest deviation from the earlier tests). Note that a more robust approach would be test all intermediate + // keyframes against the line between the last good keyframe and current, but we're settling for this other method + // because it's significantly faster. + if (diff_max > 0) + { + if (ki_max->mIgnoreRot == TRUE) + { + ki_max->mIgnoreRot = FALSE; + joint->mNumRotKeys++; + } + diff_max = 0; + } + } + else + { + // This keyframe isn't significant enough, throw it away. + ki_prev->mIgnoreRot = TRUE; + numRotFramesConsidered++; + // Store away the keyframe that has the largest deviation from the interpolated line, for insertion later. + if (rot_test > diff_max) + { + diff_max = rot_test; + ki_max = ki; + } } } diff --git a/linden/indra/llcharacter/lleditingmotion.cpp b/linden/indra/llcharacter/lleditingmotion.cpp index b7539ee..3590097 100644 --- a/linden/indra/llcharacter/lleditingmotion.cpp +++ b/linden/indra/llcharacter/lleditingmotion.cpp @@ -190,7 +190,7 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask) { LLVector3 tmp = mCharacter->getCharacterPosition() ; llerrs << "Non finite focus point in editing motion. focus point: " << focus_pt << " and character position: " << - tmp << " and pointAtPt: " << pointAtPt << llendl; + tmp << " and pointAtPt: " << *pointAtPt << llendl; } // propagate joint positions to kinematic chain @@ -226,7 +226,7 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask) if (!target.isFinite()) { llerrs << "Non finite target in editing motion with target distance of " << target_dist << - " and focus point " << focus_pt << " and pointAtPt: " << pointAtPt << llendl; + " and focus point " << focus_pt << " and pointAtPt: " << *pointAtPt << llendl; } mTarget.setPosition( target + mParentJoint.getPosition()); diff --git a/linden/indra/llcharacter/llmotioncontroller.cpp b/linden/indra/llcharacter/llmotioncontroller.cpp index 90a3d74..fadf1a5 100644 --- a/linden/indra/llcharacter/llmotioncontroller.cpp +++ b/linden/indra/llcharacter/llmotioncontroller.cpp @@ -783,6 +783,11 @@ void LLMotionController::updateLoadingMotions() llinfos << "Motion " << motionp->getID() << " init failed." << llendl; sRegistry.markBad(motionp->getID()); mLoadingMotions.erase(curiter); + motion_set_t::iterator found_it = mDeprecatedMotions.find(motionp); + if (found_it != mDeprecatedMotions.end()) + { + mDeprecatedMotions.erase(found_it); + } mAllMotions.erase(motionp->getID()); delete motionp; } diff --git a/linden/indra/llcommon/CMakeLists.txt b/linden/indra/llcommon/CMakeLists.txt index 8810549..4001e1f 100644 --- a/linden/indra/llcommon/CMakeLists.txt +++ b/linden/indra/llcommon/CMakeLists.txt @@ -187,3 +187,10 @@ set_source_files_properties(${llcommon_HEADER_FILES} list(APPEND llcommon_SOURCE_FILES ${llcommon_HEADER_FILES}) add_library (llcommon ${llcommon_SOURCE_FILES}) +target_link_libraries( + llcommon + ${APRUTIL_LIBRARIES} + ${APR_LIBRARIES} + ${EXPAT_LIBRARIES} + ${ZLIB_LIBRARIES} + ) diff --git a/linden/indra/llcommon/indra_constants.h b/linden/indra/llcommon/indra_constants.h index 1c48a5c..fcb2aaf 100644 --- a/linden/indra/llcommon/indra_constants.h +++ b/linden/indra/llcommon/indra_constants.h @@ -251,6 +251,7 @@ const U8 GOD_NOT = 0; const LLUUID LL_UUID_ALL_AGENTS("44e87126-e794-4ded-05b3-7c42da3d5cdb"); // Governor Linden's agent id. +const LLUUID ALEXANDRIA_LINDEN_ID("ba2a564a-f0f1-4b82-9c61-b7520bfcd09f"); const LLUUID GOVERNOR_LINDEN_ID("3d6181b0-6a4b-97ef-18d8-722652995cf1"); const LLUUID REALESTATE_LINDEN_ID("3d6181b0-6a4b-97ef-18d8-722652995cf1"); // Maintenance's group id. diff --git a/linden/indra/llcommon/llcommon.cpp b/linden/indra/llcommon/llcommon.cpp index b21b687..cdaa7f9 100644 --- a/linden/indra/llcommon/llcommon.cpp +++ b/linden/indra/llcommon/llcommon.cpp @@ -46,7 +46,7 @@ void LLCommon::initClass() sAprInitialized = TRUE; } LLTimer::initClass(); - LLThreadSafeRefCount::initClass(); + LLThreadSafeRefCount::initThreadSafeRefCount(); // LLWorkerThread::initClass(); // LLFrameCallbackManager::initClass(); } @@ -56,7 +56,7 @@ void LLCommon::cleanupClass() { // LLFrameCallbackManager::cleanupClass(); // LLWorkerThread::cleanupClass(); - LLThreadSafeRefCount::cleanupClass(); + LLThreadSafeRefCount::cleanupThreadSafeRefCount(); LLTimer::cleanupClass(); if (sAprInitialized) { diff --git a/linden/indra/llcommon/llfasttimer.h b/linden/indra/llcommon/llfasttimer.h index 8ad2667..80ed26b 100644 --- a/linden/indra/llcommon/llfasttimer.h +++ b/linden/indra/llcommon/llfasttimer.h @@ -165,6 +165,7 @@ public: FTM_FILTER, FTM_REFRESH, FTM_SORT, + FTM_PICK, // Temp FTM_TEMP1, diff --git a/linden/indra/llcommon/llfindlocale.cpp b/linden/indra/llcommon/llfindlocale.cpp index 47da974..344041c 100644 --- a/linden/indra/llcommon/llfindlocale.cpp +++ b/linden/indra/llcommon/llfindlocale.cpp @@ -180,10 +180,10 @@ canonise_fl(FL_Locale *l) { #define ML(pn,sn) MAKELANGID(LANG_##pn, SUBLANG_##pn##_##sn) #define MLN(pn) MAKELANGID(LANG_##pn, SUBLANG_DEFAULT) #define RML(pn,sn) MAKELANGID(LANG_##pn, SUBLANG_##sn) -typedef struct { +struct IDToCode { LANGID id; char* code; -} IDToCode; +}; static const IDToCode both_to_code[] = { {ML(ENGLISH,US), "en_US.ISO_8859-1"}, {ML(ENGLISH,CAN), "en_CA"}, /* english / canadian */ diff --git a/linden/indra/llcommon/llfindlocale.h b/linden/indra/llcommon/llfindlocale.h index 6cc2dbb..bc253c3 100644 --- a/linden/indra/llcommon/llfindlocale.h +++ b/linden/indra/llcommon/llfindlocale.h @@ -36,11 +36,11 @@ typedef const char* FL_Lang; typedef const char* FL_Country; typedef const char* FL_Variant; -typedef struct { +struct FL_Locale { FL_Lang lang; FL_Country country; FL_Variant variant; -} FL_Locale; +}; typedef enum { /* for some reason we failed to even guess: this should never happen */ diff --git a/linden/indra/llcommon/llkeythrottle.h b/linden/indra/llcommon/llkeythrottle.h index eb1519a..25d0fe0 100644 --- a/linden/indra/llcommon/llkeythrottle.h +++ b/linden/indra/llcommon/llkeythrottle.h @@ -243,7 +243,7 @@ public: } // Set the throttling behavior - void setParameters( U32 limit, F32 interval, BOOL realtime ) + void setParameters( U32 limit, F32 interval, BOOL realtime = TRUE ) { // limit is the maximum number of keys // allowed per interval (in seconds or frames) diff --git a/linden/indra/llcommon/llprocessor.h b/linden/indra/llcommon/llprocessor.h index 6abbd96..06dc72a 100644 --- a/linden/indra/llcommon/llprocessor.h +++ b/linden/indra/llcommon/llprocessor.h @@ -58,7 +58,7 @@ #endif -typedef struct ProcessorExtensions +struct ProcessorExtensions { bool FPU_FloatingPointUnit; bool VME_Virtual8086ModeEnhancements; @@ -97,9 +97,9 @@ typedef struct ProcessorExtensions bool _3DNOW_InstructionExtensions; bool _E3DNOW_InstructionExtensions; bool AA64_AMD64BitArchitecture; -} ProcessorExtensions; +}; -typedef struct ProcessorCache +struct ProcessorCache { bool bPresent; char strSize[32]; /* Flawfinder: ignore */ @@ -107,24 +107,24 @@ typedef struct ProcessorCache unsigned int uiLineSize; bool bSectored; char strCache[128]; /* Flawfinder: ignore */ -} ProcessorCache; +}; -typedef struct ProcessorL1Cache +struct ProcessorL1Cache { ProcessorCache Instruction; ProcessorCache Data; -} ProcessorL1Cache; +}; -typedef struct ProcessorTLB +struct ProcessorTLB { bool bPresent; char strPageSize[32]; /* Flawfinder: ignore */ unsigned int uiAssociativeWays; unsigned int uiEntries; char strTLB[128]; /* Flawfinder: ignore */ -} ProcessorTLB; +}; -typedef struct ProcessorInfo +struct ProcessorInfo { char strVendor[16]; /* Flawfinder: ignore */ unsigned int uiFamily; @@ -148,7 +148,7 @@ typedef struct ProcessorInfo ProcessorCache _Trace; ProcessorTLB _Instruction; ProcessorTLB _Data; -} ProcessorInfo; +}; // CProcessor diff --git a/linden/indra/llcommon/llsdserialize.cpp b/linden/indra/llcommon/llsdserialize.cpp index d42842d..f21ff68 100644 --- a/linden/indra/llcommon/llsdserialize.cpp +++ b/linden/indra/llcommon/llsdserialize.cpp @@ -324,7 +324,7 @@ S32 LLSDParser::parse(std::istream& istr, LLSD& data, S32 max_bytes) S32 LLSDParser::parseLines(std::istream& istr, LLSD& data) { mCheckLimits = false; - mParseLines = false; // was true, Emergency fix DEV-17785 parsing newline failure + mParseLines = true; return doParse(istr, data); } diff --git a/linden/indra/llcommon/llsdserialize_xml.cpp b/linden/indra/llcommon/llsdserialize_xml.cpp index 690ab67..9c3f85e 100644 --- a/linden/indra/llcommon/llsdserialize_xml.cpp +++ b/linden/indra/llcommon/llsdserialize_xml.cpp @@ -461,11 +461,11 @@ S32 LLSDXMLParser::Impl::parseLines(std::istream& input, LLSD& data) input.clear(); } - // Don't parse the NULL at the end which might be added if \n was absorbed by getline() + // Re-insert with the \n that was absorbed by getline() char * text = (char *) buffer; if ( text[num_read - 1] == 0) { - num_read--; + text[num_read - 1] = '\n'; } } @@ -808,12 +808,11 @@ void LLSDXMLParser::parsePart(const char *buf, int len) // virtual S32 LLSDXMLParser::doParse(std::istream& input, LLSD& data) const { -// Remove code - emergency fix DEV-17785 parsing newline failure -// if (mParseLines) -// { + if (mParseLines) + { // Use line-based reading (faster code) -// return impl.parseLines(input, data); -// } + return impl.parseLines(input, data); + } return impl.parse(input, data); } diff --git a/linden/indra/llcommon/llstat.cpp b/linden/indra/llcommon/llstat.cpp index 4b79fcb..706acdb 100644 --- a/linden/indra/llcommon/llstat.cpp +++ b/linden/indra/llcommon/llstat.cpp @@ -31,55 +31,288 @@ #include "linden_common.h" #include "llstat.h" +#include "lllivefile.h" +#include "llerrorcontrol.h" #include "llframetimer.h" #include "timing.h" +#include "llsd.h" +#include "llsdserialize.h" +#include "llstl.h" +#include "u64.h" -class LLStatAccum::impl + +// statics +BOOL LLPerfBlock::sStatsEnabled = FALSE; // Flag for detailed information +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" + +//------------------------------------------------------------------------ +// Live config file to trigger stats logging +static const char STATS_CONFIG_FILE_NAME[] = "/dev/shm/simperf/simperf_proc_config.llsd"; +static const F32 STATS_CONFIG_REFRESH_RATE = 5.0; // seconds + +class LLStatsConfigFile : public LLLiveFile { public: - static const TimeScale IMPL_NUM_SCALES = (TimeScale)(SCALE_TWO_MINUTE + 1); - static U64 sScaleTimes[IMPL_NUM_SCALES]; + LLStatsConfigFile() + : LLLiveFile(filename(), STATS_CONFIG_REFRESH_RATE), + mChanged(false), mStatsp(NULL) { } - BOOL mUseFrameTimer; + static std::string filename(); + +protected: + /* virtual */ void loadFile(); - BOOL mRunning; - U64 mLastTime; - - struct Bucket - { - F64 accum; - U64 endTime; +public: + void init(LLPerfStats* statsp); + static LLStatsConfigFile& instance(); + // return the singleton stats config file - BOOL lastValid; - F64 lastAccum; - }; + bool mChanged; - Bucket mBuckets[IMPL_NUM_SCALES]; +protected: + LLPerfStats* mStatsp; +}; - BOOL mLastSampleValid; - F64 mLastSampleValue; +std::string LLStatsConfigFile::filename() +{ + return STATS_CONFIG_FILE_NAME; +} +void LLStatsConfigFile::init(LLPerfStats* statsp) +{ + mStatsp = statsp; +} - impl(bool useFrameTimer); +LLStatsConfigFile& LLStatsConfigFile::instance() +{ + static LLStatsConfigFile the_file; + return the_file; +} - void reset(U64 when); - void sum(F64 value); - void sum(F64 value, U64 when); +/* virtual */ +// Load and parse the stats configuration file +void LLStatsConfigFile::loadFile() +{ + if (!mStatsp) + { + llwarns << "Tries to load performance configure file without initializing LPerfStats" << llendl; + return; + } + mChanged = true; + + LLSD stats_config; + { + llifstream file(filename().c_str()); + if (file.is_open()) + { + LLSDSerialize::fromXML(stats_config, file); + if (stats_config.isUndefined()) + { + llinfos << "Performance statistics configuration file ill-formed, not recording statistics" << llendl; + mStatsp->setReportPerformanceDuration( 0.f ); + return; + } + } + else + { // File went away, turn off stats if it was on + if ( mStatsp->frameStatsIsRunning() ) + { + llinfos << "Performance statistics configuration file deleted, not recording statistics" << llendl; + mStatsp->setReportPerformanceDuration( 0.f ); + } + return; + } + } + + F32 duration = 0.f; + F32 interval = 0.f; + + const char * w = "duration"; + if (stats_config.has(w)) + { + duration = (F32)stats_config[w].asReal(); + } + w = "interval"; + if (stats_config.has(w)) + { + interval = (F32)stats_config[w].asReal(); + } + + mStatsp->setReportPerformanceDuration( duration ); + mStatsp->setReportPerformanceInterval( interval ); + + if ( duration > 0 ) + { + if ( interval == 0.f ) + { + llinfos << "Recording performance stats every frame for " << duration << " sec" << llendl; + } + else + { + llinfos << "Recording performance stats every " << interval << " seconds for " << duration << " seconds" << llendl; + } + } + else + { + llinfos << "Performance stats recording turned off" << llendl; + } +} - F32 meanValue(TimeScale scale) const; - U64 getCurrentUsecs() const; - // Get current microseconds based on timer type -}; +//------------------------------------------------------------------------ +LLPerfStats::LLPerfStats(const std::string& process_name, S32 process_pid) : + mFrameStatsFileFailure(FALSE), + mSkipFirstFrameStats(FALSE), + mProcessName(process_name), + mProcessPID(process_pid), + mReportPerformanceStatInterval(1.f), + mReportPerformanceStatEnd(0.0) +{ } -U64 LLStatAccum::impl::sScaleTimes[IMPL_NUM_SCALES] = +LLPerfStats::~LLPerfStats() +{ + LLPerfBlock::clearDynamicStats(); + mFrameStatsFile.close(); +} + +void LLPerfStats::init() +{ + // Initialize the stats config file instance. + (void) LLStatsConfigFile::instance().init(this); + (void) LLStatsConfigFile::instance().checkAndReload(); +} + +// Open file for statistics +void LLPerfStats::openPerfStatsFile() +{ + if ( !mFrameStatsFile + && !mFrameStatsFileFailure ) + { + std::string stats_file = llformat("/dev/shm/simperf/%s_proc.%d.llsd", mProcessName.c_str(), mProcessPID); + mFrameStatsFile.close(); + mFrameStatsFile.clear(); + mFrameStatsFile.open(stats_file, llofstream::out); + if ( mFrameStatsFile.fail() ) + { + llinfos << "Error opening statistics log file " << stats_file << llendl; + mFrameStatsFileFailure = TRUE; + } + else + { + LLSD process_info = LLSD::emptyMap(); + process_info["name"] = mProcessName; + process_info["pid"] = (LLSD::Integer) mProcessPID; + process_info["stat_rate"] = (LLSD::Integer) mReportPerformanceStatInterval; + // Add process-specific info. + addProcessHeaderInfo(process_info); + + mFrameStatsFile << LLSDNotationStreamer(process_info) << std::endl; + } + } +} + +// Dump out performance metrics over some time interval +void LLPerfStats::dumpIntervalPerformanceStats() +{ + // Ensure output file is OK + openPerfStatsFile(); + + if ( mFrameStatsFile ) + { + LLSD stats = LLSD::emptyMap(); + + LLStatAccum::TimeScale scale; + if ( getReportPerformanceInterval() == 0.f ) + { + scale = LLStatAccum::SCALE_PER_FRAME; + } + else if ( getReportPerformanceInterval() < 0.5f ) + { + scale = LLStatAccum::SCALE_100MS; + } + else + { + scale = LLStatAccum::SCALE_SECOND; + } + + // Write LLSD into log + stats["utc_time"] = (LLSD::String) LLError::utcTime(); + stats["timestamp"] = U64_to_str((totalTime() / 1000) + (gUTCOffset * 1000)); // milliseconds since epoch + stats["frame_number"] = (LLSD::Integer) LLFrameTimer::getFrameCount(); + + // Add process-specific frame info. + addProcessFrameInfo(stats, scale); + LLPerfBlock::addStatsToLLSDandReset( stats, scale ); + + mFrameStatsFile << LLSDNotationStreamer(stats) << std::endl; + } +} + +// Set length of performance stat recording +void LLPerfStats::setReportPerformanceDuration( F32 seconds ) +{ + if ( seconds <= 0.f ) + { + mReportPerformanceStatEnd = 0.0; + LLPerfBlock::setStatsEnabled( FALSE ); + mFrameStatsFile.close(); + LLPerfBlock::clearDynamicStats(); + } + else + { + 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) + } +} + +void LLPerfStats::updatePerFrameStats() +{ + (void) LLStatsConfigFile::instance().checkAndReload(); + static LLFrameTimer performance_stats_timer; + if ( frameStatsIsRunning() ) + { + if ( mReportPerformanceStatInterval == 0 ) + { // Record info every frame + if ( mSkipFirstFrameStats ) + { // Skip the first time - was started this frame + mSkipFirstFrameStats = FALSE; + } + else + { + dumpIntervalPerformanceStats(); + } + } + else + { + performance_stats_timer.setTimerExpirySec( getReportPerformanceInterval() ); + if (performance_stats_timer.checkExpirationAndReset( mReportPerformanceStatInterval )) + { + dumpIntervalPerformanceStats(); + } + } + + if ( LLFrameTimer::getElapsedSeconds() > mReportPerformanceStatEnd ) + { // Reached end of time, clear it to stop reporting + setReportPerformanceDuration(0.f); // Don't set mReportPerformanceStatEnd directly + llinfos << "Recording performance stats completed" << llendl; + } + } +} + + +//------------------------------------------------------------------------ + +U64 LLStatAccum::sScaleTimes[NUM_SCALES] = { USEC_PER_SEC / 10, // 100 millisec USEC_PER_SEC * 1, // seconds USEC_PER_SEC * 60, // minutes - USEC_PER_SEC * 60 * 2 // two minutes #if ENABLE_LONG_TIME_STATS // enable these when more time scales are desired USEC_PER_SEC * 60*60, // hours @@ -89,19 +322,27 @@ U64 LLStatAccum::impl::sScaleTimes[IMPL_NUM_SCALES] = }; -LLStatAccum::impl::impl(bool useFrameTimer) + +LLStatAccum::LLStatAccum(bool useFrameTimer) + : mUseFrameTimer(useFrameTimer), + mRunning(FALSE), + mLastSampleValue(0.0), + mLastSampleValid(FALSE) +{ +} + +LLStatAccum::~LLStatAccum() { - mUseFrameTimer = useFrameTimer; - mRunning = FALSE; - mLastSampleValid = FALSE; } -void LLStatAccum::impl::reset(U64 when) + + +void LLStatAccum::reset(U64 when) { mRunning = TRUE; mLastTime = when; - for (int i = 0; i < IMPL_NUM_SCALES; ++i) + for (int i = 0; i < NUM_SCALES; ++i) { mBuckets[i].accum = 0.0; mBuckets[i].endTime = when + sScaleTimes[i]; @@ -109,12 +350,12 @@ void LLStatAccum::impl::reset(U64 when) } } -void LLStatAccum::impl::sum(F64 value) +void LLStatAccum::sum(F64 value) { sum(value, getCurrentUsecs()); } -void LLStatAccum::impl::sum(F64 value, U64 when) +void LLStatAccum::sum(F64 value, U64 when) { if (!mRunning) { @@ -131,7 +372,10 @@ void LLStatAccum::impl::sum(F64 value, U64 when) return; } - for (int i = 0; i < IMPL_NUM_SCALES; ++i) + // how long is this value for + U64 timeSpan = when - mLastTime; + + for (int i = 0; i < NUM_SCALES; ++i) { Bucket& bucket = mBuckets[i]; @@ -143,8 +387,6 @@ void LLStatAccum::impl::sum(F64 value, U64 when) { U64 timeScale = sScaleTimes[i]; - U64 timeSpan = when - mLastTime; - // how long is this value for U64 timeLeft = when - bucket.endTime; // how much time is left after filling this bucket @@ -173,13 +415,18 @@ void LLStatAccum::impl::sum(F64 value, U64 when) } -F32 LLStatAccum::impl::meanValue(TimeScale scale) const +F32 LLStatAccum::meanValue(TimeScale scale) const { if (!mRunning) { return 0.0; } - if (scale < 0 || scale >= IMPL_NUM_SCALES) + if ( scale == SCALE_PER_FRAME ) + { // Per-frame not supported here + scale = SCALE_100MS; + } + + if (scale < 0 || scale >= NUM_SCALES) { llwarns << "llStatAccum::meanValue called for unsupported scale: " << scale << llendl; @@ -209,7 +456,7 @@ F32 LLStatAccum::impl::meanValue(TimeScale scale) const } -U64 LLStatAccum::impl::getCurrentUsecs() const +U64 LLStatAccum::getCurrentUsecs() const { if (mUseFrameTimer) { @@ -222,25 +469,44 @@ U64 LLStatAccum::impl::getCurrentUsecs() const } +// ------------------------------------------------------------------------ - - -LLStatAccum::LLStatAccum(bool useFrameTimer) - : m(* new impl(useFrameTimer)) +LLStatRate::LLStatRate(bool use_frame_timer) + : LLStatAccum(use_frame_timer) { } -LLStatAccum::~LLStatAccum() +void LLStatRate::count(U32 value) { - delete &m; + sum((F64)value * sScaleTimes[SCALE_SECOND]); } -F32 LLStatAccum::meanValue(TimeScale scale) const -{ - return m.meanValue(scale); -} + +void LLStatRate::mark() + { + // Effectively the same as count(1), but sets mLastSampleValue + U64 when = getCurrentUsecs(); + + if ( mRunning + && (when > mLastTime) ) + { // Set mLastSampleValue to the time from the last mark() + F64 duration = ((F64)(when - mLastTime)) / sScaleTimes[SCALE_SECOND]; + if ( duration > 0.0 ) + { + mLastSampleValue = 1.0 / duration; + } + else + { + mLastSampleValue = 0.0; + } + } + + sum( (F64) sScaleTimes[SCALE_SECOND], when); + } +// ------------------------------------------------------------------------ + LLStatMeasure::LLStatMeasure(bool use_frame_timer) : LLStatAccum(use_frame_timer) @@ -249,53 +515,209 @@ LLStatMeasure::LLStatMeasure(bool use_frame_timer) void LLStatMeasure::sample(F64 value) { - U64 when = m.getCurrentUsecs(); + U64 when = getCurrentUsecs(); - if (m.mLastSampleValid) + if (mLastSampleValid) { - F64 avgValue = (value + m.mLastSampleValue) / 2.0; - F64 interval = (F64)(when - m.mLastTime); + F64 avgValue = (value + mLastSampleValue) / 2.0; + F64 interval = (F64)(when - mLastTime); - m.sum(avgValue * interval, when); + sum(avgValue * interval, when); } else { - m.reset(when); + reset(when); } - m.mLastSampleValid = TRUE; - m.mLastSampleValue = value; + mLastSampleValid = TRUE; + mLastSampleValue = value; } -LLStatRate::LLStatRate(bool use_frame_timer) - : LLStatAccum(use_frame_timer) +// ------------------------------------------------------------------------ + +LLStatTime::LLStatTime(const std::string & key) + : LLStatAccum(false), + mFrameNumber(LLFrameTimer::getFrameCount()), + mTotalTimeInFrame(0), + mKey(key) +#if LL_DEBUG + , mRunning(FALSE) +#endif { } -void LLStatRate::count(U32 value) +void LLStatTime::start() +{ + // Reset frame accumluation if the frame number has changed + U32 frame_number = LLFrameTimer::getFrameCount(); + if ( frame_number != mFrameNumber ) + { + mFrameNumber = frame_number; + mTotalTimeInFrame = 0; + } + + sum(0.0); + +#if LL_DEBUG + // Shouldn't be running already + llassert( !mRunning ); + mRunning = TRUE; +#endif +} + +void LLStatTime::stop() +{ + U64 end_time = getCurrentUsecs(); + U64 duration = end_time - mLastTime; + sum(F64(duration), end_time); + //llinfos << "mTotalTimeInFrame incremented from " << mTotalTimeInFrame << " to " << (mTotalTimeInFrame + duration) << llendl; + mTotalTimeInFrame += duration; + +#if LL_DEBUG + mRunning = FALSE; +#endif +} + +/* virtual */ F32 LLStatTime::meanValue(TimeScale scale) const { - m.sum((F64)value * impl::sScaleTimes[SCALE_SECOND]); + if ( LLStatAccum::SCALE_PER_FRAME == scale ) + { + return mTotalTimeInFrame; + } + else + { + return LLStatAccum::meanValue(scale); + } } -LLStatTime::LLStatTime(bool use_frame_timer) - : LLStatAccum(use_frame_timer) +// ------------------------------------------------------------------------ + + +// Use this constructor for pre-defined LLStatTime objects +LLPerfBlock::LLPerfBlock(LLStatTime* stat ) : mPredefinedStat(stat), mDynamicStat(NULL) { + if (mPredefinedStat) + { + // If dynamic stats are turned on, this will create a separate entry in the stat map. + initDynamicStat(mPredefinedStat->mKey); + + // Start predefined stats. These stats are not part of the stat map. + mPredefinedStat->start(); + } } -void LLStatTime::start() +// 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) { - m.sum(0.0); + if (!sStatsEnabled) return; + + if (NULL == key2 || strlen(key2) == 0) + { + initDynamicStat(key1); + } + else + { + std::ostringstream key; + key << key1 << "_" << key2; + initDynamicStat(key.str()); + } } -void LLStatTime::stop() +void LLPerfBlock::initDynamicStat(const std::string& key) +{ + // Early exit if dynamic stats aren't enabled. + if (!sStatsEnabled) return; + + mLastPath = sCurrentStatPath; // Save and restore current path + sCurrentStatPath += "/" + key; // Add key to current path + + // See if the LLStatTime object already exists + stat_map_t::iterator iter = sStatMap.find(sCurrentStatPath); + if ( iter == sStatMap.end() ) + { + // StatEntry object doesn't exist, so create it + mDynamicStat = new StatEntry( key ); + sStatMap[ sCurrentStatPath ] = mDynamicStat; // Set the entry for this path + } + else + { + // Found this path in the map, use the object there + mDynamicStat = (*iter).second; // Get StatEntry for the current path + } + + if (mDynamicStat) + { + mDynamicStat->mStat.start(); + mDynamicStat->mCount++; + } + else + { + llwarns << "Initialized NULL dynamic stat at '" << sCurrentStatPath << "'" << llendl; + sCurrentStatPath = mLastPath; + } +} + + +// Destructor does the time accounting +LLPerfBlock::~LLPerfBlock() +{ + if (mPredefinedStat) mPredefinedStat->stop(); + if (mDynamicStat) + { + mDynamicStat->mStat.stop(); + sCurrentStatPath = mLastPath; // Restore the path in case sStatsEnabled changed during this block + } +} + + +// Clear the map of any dynamic stats. Static routine +void LLPerfBlock::clearDynamicStats() +{ + std::for_each(sStatMap.begin(), sStatMap.end(), DeletePairedPointer()); + sStatMap.clear(); +} + +// static - Extract the stat info into LLSD +void LLPerfBlock::addStatsToLLSDandReset( LLSD & stats, + LLStatAccum::TimeScale scale ) { - U64 endTime = m.getCurrentUsecs(); - m.sum((F64)(endTime - m.mLastTime), endTime); + // If we aren't in per-frame scale, we need to go from second to microsecond. + U32 scale_adjustment = 1; + if (LLStatAccum::SCALE_PER_FRAME != scale) + { + scale_adjustment = USEC_PER_SEC; + } + stat_map_t::iterator iter = sStatMap.begin(); + for ( ; iter != sStatMap.end(); ++iter ) + { // Put the entry into LLSD "/full/path/to/stat/" = microsecond total time + const std::string & stats_full_path = (*iter).first; + + StatEntry * stat = (*iter).second; + if (stat) + { + if (stat->mCount > 0) + { + stats[stats_full_path] = LLSD::emptyMap(); + stats[stats_full_path]["us"] = (LLSD::Integer) (scale_adjustment * stat->mStat.meanValue(scale)); + if (stat->mCount > 1) + { + stats[stats_full_path]["count"] = (LLSD::Integer) stat->mCount; + } + stat->mCount = 0; + } + } + else + { // WTF? Shouldn't have a NULL pointer in the map. + llwarns << "Unexpected NULL dynamic stat at '" << stats_full_path << "'" << llendl; + } + } } +// ------------------------------------------------------------------------ LLTimer LLStat::sTimer; LLFrameTimer LLStat::sFrameTimer; diff --git a/linden/indra/llcommon/llstat.h b/linden/indra/llcommon/llstat.h index 0a7e014..63813e2 100644 --- a/linden/indra/llcommon/llstat.h +++ b/linden/indra/llcommon/llstat.h @@ -33,9 +33,13 @@ #define LL_LLSTAT_H #include +#include #include "lltimer.h" #include "llframetimer.h" +#include "llfile.h" + +class LLSD; // Set this if longer stats are needed #define ENABLE_LONG_TIME_STATS 0 @@ -58,25 +62,50 @@ public: SCALE_100MS, SCALE_SECOND, SCALE_MINUTE, - SCALE_TWO_MINUTE, #if ENABLE_LONG_TIME_STATS SCALE_HOUR, SCALE_DAY, SCALE_WEEK, #endif - NUM_SCALES + NUM_SCALES, // Use to size storage arrays + SCALE_PER_FRAME // For latest frame information - should be after NUM_SCALES since this doesn't go into the time buckets }; - F32 meanValue(TimeScale scale) const; + static U64 sScaleTimes[NUM_SCALES]; + + virtual F32 meanValue(TimeScale scale) const; // see the subclasses for the specific meaning of value F32 meanValueOverLast100ms() const { return meanValue(SCALE_100MS); } F32 meanValueOverLastSecond() const { return meanValue(SCALE_SECOND); } F32 meanValueOverLastMinute() const { return meanValue(SCALE_MINUTE); } -protected: - class impl; - impl& m; + void reset(U64 when); + + void sum(F64 value); + void sum(F64 value, U64 when); + + U64 getCurrentUsecs() const; + // Get current microseconds based on timer type + + BOOL mUseFrameTimer; + BOOL mRunning; + + U64 mLastTime; + + struct Bucket + { + F64 accum; + U64 endTime; + + BOOL lastValid; + F64 lastAccum; + }; + + Bucket mBuckets[NUM_SCALES]; + + BOOL mLastSampleValid; + F64 mLastSampleValue; }; class LLStatMeasure : public LLStatAccum @@ -105,39 +134,120 @@ public: void count(U32); // used to note that n items have occured - void mark() { count(1); } + void mark(); // used for counting the rate thorugh a point in the code }; -class LLTimeBlock; - class LLStatTime : public LLStatAccum // gathers statistics about time spent in a block of code // measure average duration per second in the block { public: - LLStatTime(bool use_frame_timer = false); + LLStatTime( const std::string & key = "undefined" ); + + U32 mFrameNumber; // Current frame number + U64 mTotalTimeInFrame; // Total time (microseconds) accumulated during the last frame + + void setKey( const std::string & key ) { mKey = key; }; + + virtual F32 meanValue(TimeScale scale) const; private: - void start(); + void start(); // Start and stop measuring time block void stop(); - friend class LLTimeBlock; + + std::string mKey; // Tag representing this time block + +#if LL_DEBUG + BOOL mRunning; // TRUE if start() has been called +#endif + + friend class LLPerfBlock; }; -class LLTimeBlock +// ---------------------------------------------------------------------------- + + +// Use this class on the stack to record statistics about an area of code +class LLPerfBlock { public: - LLTimeBlock(LLStatTime& stat) : mStat(stat) { mStat.start(); } - ~LLTimeBlock() { mStat.stop(); } + struct StatEntry + { + StatEntry(const std::string& key) : mStat(LLStatTime(key)), mCount(0) {} + LLStatTime mStat; + U32 mCount; + }; + typedef std::map stat_map_t; + + // 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); + + + ~LLPerfBlock(); + + static void setStatsEnabled( BOOL enable ) { sStatsEnabled = enable; }; + static S32 getStatsEnabled() { return sStatsEnabled; }; + + static void clearDynamicStats(); // Reset maps to clear out dynamic objects + static void addStatsToLLSDandReset( LLSD & stats, // Get current information and clear time bin + LLStatAccum::TimeScale scale ); + private: - LLStatTime& mStat; + // Initialize dynamically created LLStatTime objects + void initDynamicStat(const std::string& key); + + std::string mLastPath; // Save sCurrentStatPath when this is called + LLStatTime * mPredefinedStat; // LLStatTime object to get data + StatEntry * mDynamicStat; // StatEntryobject to get data + + static BOOL sStatsEnabled; // Normally FALSE + static stat_map_t sStatMap; // Map full path string to LLStatTime objects + static std::string sCurrentStatPath; // Something like "frame/physics/physics step" }; +// ---------------------------------------------------------------------------- +class LLPerfStats +{ +public: + LLPerfStats(const std::string& process_name = "unknown", S32 process_pid = 0); + virtual ~LLPerfStats(); + + virtual void init(); // Reset and start all stat timers + virtual void updatePerFrameStats(); + // Override these function to add process-specific information to the performance log header and per-frame logging. + virtual void addProcessHeaderInfo(LLSD& info) { /* not implemented */ } + virtual void addProcessFrameInfo(LLSD& info, LLStatAccum::TimeScale scale) { /* not implemented */ } + + // High-resolution frame stats + BOOL frameStatsIsRunning() { return (mReportPerformanceStatEnd > 0.); }; + F32 getReportPerformanceInterval() const { return mReportPerformanceStatInterval; }; + void setReportPerformanceInterval( F32 interval ) { mReportPerformanceStatInterval = interval; }; + void setReportPerformanceDuration( F32 seconds ); + void setProcessName(const std::string& process_name) { mProcessName = process_name; } + void setProcessPID(S32 process_pid) { mProcessPID = process_pid; } +protected: + void openPerfStatsFile(); // Open file for high resolution metrics logging + void dumpIntervalPerformanceStats(); + + llofstream mFrameStatsFile; // File for per-frame stats + BOOL mFrameStatsFileFailure; // Flag to prevent repeat opening attempts + BOOL mSkipFirstFrameStats; // Flag to skip one (partial) frame report + std::string mProcessName; + S32 mProcessPID; +private: + F32 mReportPerformanceStatInterval; // Seconds between performance stats + F64 mReportPerformanceStatEnd; // End time (seconds) for performance stats +}; +// ---------------------------------------------------------------------------- class LLStat { public: diff --git a/linden/indra/llcommon/llstatenums.h b/linden/indra/llcommon/llstatenums.h index 6866586..1d9b863 100644 --- a/linden/indra/llcommon/llstatenums.h +++ b/linden/indra/llcommon/llstatenums.h @@ -33,38 +33,41 @@ enum { - LL_SIM_STAT_TIME_DILATION, + LL_SIM_STAT_TIME_DILATION, // 0 LL_SIM_STAT_FPS, LL_SIM_STAT_PHYSFPS, LL_SIM_STAT_AGENTUPS, LL_SIM_STAT_FRAMEMS, - LL_SIM_STAT_NETMS, + LL_SIM_STAT_NETMS, // 5 LL_SIM_STAT_SIMOTHERMS, LL_SIM_STAT_SIMPHYSICSMS, LL_SIM_STAT_AGENTMS, LL_SIM_STAT_IMAGESMS, - LL_SIM_STAT_SCRIPTMS, + LL_SIM_STAT_SCRIPTMS, // 10 LL_SIM_STAT_NUMTASKS, LL_SIM_STAT_NUMTASKSACTIVE, LL_SIM_STAT_NUMAGENTMAIN, LL_SIM_STAT_NUMAGENTCHILD, - LL_SIM_STAT_NUMSCRIPTSACTIVE, + LL_SIM_STAT_NUMSCRIPTSACTIVE, // 15 LL_SIM_STAT_LSLIPS, LL_SIM_STAT_INPPS, LL_SIM_STAT_OUTPPS, LL_SIM_STAT_PENDING_DOWNLOADS, - LL_SIM_STAT_PENDING_UPLOADS, + LL_SIM_STAT_PENDING_UPLOADS, // 20 LL_SIM_STAT_VIRTUAL_SIZE_KB, LL_SIM_STAT_RESIDENT_SIZE_KB, LL_SIM_STAT_PENDING_LOCAL_UPLOADS, LL_SIM_STAT_TOTAL_UNACKED_BYTES, - LL_SIM_STAT_PHYSICS_PINNED_TASKS, + LL_SIM_STAT_PHYSICS_PINNED_TASKS, // 25 LL_SIM_STAT_PHYSICS_LOD_TASKS, LL_SIM_STAT_SIMPHYSICSSTEPMS, LL_SIM_STAT_SIMPHYSICSSHAPEMS, LL_SIM_STAT_SIMPHYSICSOTHERMS, - LL_SIM_STAT_SIMPHYSICSMEMORY, + LL_SIM_STAT_SIMPHYSICSMEMORY, // 30 LL_SIM_STAT_SCRIPT_EPS, + LL_SIM_STAT_SIMSPARETIME, + LL_SIM_STAT_SIMSLEEPTIME, + LL_SIM_STAT_IOPUMPTIME, }; #endif diff --git a/linden/indra/llcommon/llstl.h b/linden/indra/llcommon/llstl.h index 4486727..70a2cc0 100644 --- a/linden/indra/llcommon/llstl.h +++ b/linden/indra/llcommon/llstl.h @@ -79,6 +79,9 @@ struct compare_pointer_contents // The general form is: // // std::for_each(cont.begin(), cont.end(), DeletePointer()); +// somemap.clear(); +// +// Don't forget to clear()! struct DeletePointer { @@ -95,7 +98,7 @@ struct DeletePointerArray } }; -// DeletePointer is a simple helper for deleting all pointers in a map. +// DeletePairedPointer is a simple helper for deleting all pointers in a map. // The general form is: // // std::for_each(somemap.begin(), somemap.end(), DeletePairedPointer()); diff --git a/linden/indra/llcommon/llstring.h b/linden/indra/llcommon/llstring.h index 7b08fd3..5e75188 100644 --- a/linden/indra/llcommon/llstring.h +++ b/linden/indra/llcommon/llstring.h @@ -133,26 +133,32 @@ struct char_traits class LLStringOps { public: - static char toUpper(char elem) { return toupper(elem); } + static char toUpper(char elem) { return toupper((unsigned char)elem); } static llwchar toUpper(llwchar elem) { return towupper(elem); } - static char toLower(char elem) { return tolower(elem); } + static char toLower(char elem) { return tolower((unsigned char)elem); } static llwchar toLower(llwchar elem) { return towlower(elem); } - static BOOL isSpace(char elem) { return isspace(elem) != 0; } - static BOOL isSpace(llwchar elem) { return iswspace(elem) != 0; } + static bool isSpace(char elem) { return isspace((unsigned char)elem) != 0; } + static bool isSpace(llwchar elem) { return iswspace(elem) != 0; } - static BOOL isUpper(char elem) { return isupper(elem) != 0; } - static BOOL isUpper(llwchar elem) { return iswupper(elem) != 0; } + static bool isUpper(char elem) { return isupper((unsigned char)elem) != 0; } + static bool isUpper(llwchar elem) { return iswupper(elem) != 0; } - static BOOL isLower(char elem) { return islower(elem) != 0; } - static BOOL isLower(llwchar elem) { return iswlower(elem) != 0; } + static bool isLower(char elem) { return islower((unsigned char)elem) != 0; } + static bool isLower(llwchar elem) { return iswlower(elem) != 0; } + + static bool isDigit(char a) { return isdigit((unsigned char)a) != 0; } + static bool isDigit(llwchar a) { return iswdigit(a) != 0; } + + static bool isPunct(char a) { return ispunct((unsigned char)a) != 0; } + static bool isPunct(llwchar a) { return iswpunct(a) != 0; } + + static bool isAlnum(char a) { return isalnum((unsigned char)a) != 0; } + static bool isAlnum(llwchar a) { return iswalnum(a) != 0; } static S32 collate(const char* a, const char* b) { return strcoll(a, b); } static S32 collate(const llwchar* a, const llwchar* b); - - static BOOL isDigit(char a) { return isdigit(a) != 0; } - static BOOL isDigit(llwchar a) { return iswdigit(a) != 0; } }; /** @@ -194,7 +200,7 @@ public: typedef std::map format_map_t; static S32 format(std::basic_string& s, const format_map_t& fmt_map); - static BOOL isValidIndex(const std::basic_string& string, size_type i) + static bool isValidIndex(const std::basic_string& string, size_type i) { return !string.empty() && (0 <= i) && (i <= string.size()); } @@ -1155,13 +1161,6 @@ BOOL LLStringUtilBase::convertToU32(const std::basic_string& string, U32& std::basic_istringstream i_stream((std::basic_string)temp); if(i_stream >> v) { - //TODO: figure out overflow reporting here - //if( ULONG_MAX == v ) - //{ - // // Underflow or overflow - // return FALSE; - //} - value = v; return TRUE; } diff --git a/linden/indra/llcommon/llthread.cpp b/linden/indra/llcommon/llthread.cpp index 822adc2..8bc9aac 100644 --- a/linden/indra/llcommon/llthread.cpp +++ b/linden/indra/llcommon/llthread.cpp @@ -359,7 +359,7 @@ void LLCondition::broadcast() LLMutex* LLThreadSafeRefCount::sMutex = 0; //static -void LLThreadSafeRefCount::initClass() +void LLThreadSafeRefCount::initThreadSafeRefCount() { if (!sMutex) { @@ -368,7 +368,7 @@ void LLThreadSafeRefCount::initClass() } //static -void LLThreadSafeRefCount::cleanupClass() +void LLThreadSafeRefCount::cleanupThreadSafeRefCount() { delete sMutex; sMutex = NULL; diff --git a/linden/indra/llcommon/llthread.h b/linden/indra/llcommon/llthread.h index 9da3134..923de56 100644 --- a/linden/indra/llcommon/llthread.h +++ b/linden/indra/llcommon/llthread.h @@ -191,8 +191,8 @@ void LLThread::unlockData() class LLThreadSafeRefCount { public: - static void initClass(); // creates sMutex - static void cleanupClass(); // destroys sMutex + static void initThreadSafeRefCount(); // creates sMutex + static void cleanupThreadSafeRefCount(); // destroys sMutex private: static LLMutex* sMutex; diff --git a/linden/indra/llcommon/lltimer.cpp b/linden/indra/llcommon/lltimer.cpp index 967570d..47edfd0 100644 --- a/linden/indra/llcommon/lltimer.cpp +++ b/linden/indra/llcommon/lltimer.cpp @@ -83,15 +83,20 @@ void ms_sleep(U32 ms) { Sleep(ms); } + +U32 micro_sleep(U64 us, U32 max_yields) +{ + // max_yields is unused; just fiddle with it to avoid warnings. + max_yields = 0; + ms_sleep(us / 1000); + return 0; +} #elif LL_LINUX || LL_SOLARIS || LL_DARWIN -void ms_sleep(U32 ms) +static void _sleep_loop(struct timespec& thiswait) { - long mslong = ms; // tv_nsec is a long - struct timespec thiswait, nextwait; + struct timespec nextwait; bool sleep_more = false; - thiswait.tv_sec = ms / 1000; - thiswait.tv_nsec = (mslong % 1000) * 1000000l; do { int result = nanosleep(&thiswait, &nextwait); @@ -127,6 +132,44 @@ void ms_sleep(U32 ms) } } while (sleep_more); } + +U32 micro_sleep(U64 us, U32 max_yields) +{ + U64 start = get_clock_count(); + // This is kernel dependent. Currently, our kernel generates software clock + // interrupts at 250 Hz (every 4,000 microseconds). + const U64 KERNEL_SLEEP_INTERVAL_US = 4000; + + S32 num_sleep_intervals = (us - (KERNEL_SLEEP_INTERVAL_US >> 1)) / KERNEL_SLEEP_INTERVAL_US; + if (num_sleep_intervals > 0) + { + U64 sleep_time = (num_sleep_intervals * KERNEL_SLEEP_INTERVAL_US) - (KERNEL_SLEEP_INTERVAL_US >> 1); + struct timespec thiswait; + thiswait.tv_sec = sleep_time / 1000000; + thiswait.tv_nsec = (sleep_time % 1000000) * 1000l; + _sleep_loop(thiswait); + } + + U64 current_clock = get_clock_count(); + U32 yields = 0; + while ( (yields < max_yields) + && (current_clock - start < us) ) + { + sched_yield(); + ++yields; + current_clock = get_clock_count(); + } + return yields; +} + +void ms_sleep(U32 ms) +{ + long mslong = ms; // tv_nsec is a long + struct timespec thiswait; + thiswait.tv_sec = ms / 1000; + thiswait.tv_nsec = (mslong % 1000) * 1000000l; + _sleep_loop(thiswait); +} #else # error "architecture not supported" #endif diff --git a/linden/indra/llcommon/lltimer.h b/linden/indra/llcommon/lltimer.h index 8d94276..766645b 100644 --- a/linden/indra/llcommon/lltimer.h +++ b/linden/indra/llcommon/lltimer.h @@ -39,6 +39,8 @@ #include "stdtypes.h" +#include +#include // units conversions #ifndef USEC_PER_SEC const U32 USEC_PER_SEC = 1000000; @@ -115,6 +117,7 @@ void update_clock_frequencies(); // Sleep for milliseconds void ms_sleep(U32 ms); +U32 micro_sleep(U64 us, U32 max_yields = 0xFFFFFFFF); // Returns the correct UTC time in seconds, like time(NULL). // Useful on the viewer, which may have its local clock set wrong. @@ -184,7 +187,7 @@ protected: private: //list of active timers - static std::list sActiveList; + static std::list sActiveList; // TODO should this be a vector }; #endif diff --git a/linden/indra/llcommon/llversionserver.h b/linden/indra/llcommon/llversionserver.h index 0b88ce8..2861428 100644 --- a/linden/indra/llcommon/llversionserver.h +++ b/linden/indra/llcommon/llversionserver.h @@ -34,8 +34,8 @@ const S32 LL_VERSION_MAJOR = 1; const S32 LL_VERSION_MINOR = 24; -const S32 LL_VERSION_PATCH = 0; -const S32 LL_VERSION_BUILD = 93453; +const S32 LL_VERSION_PATCH = 9; +const S32 LL_VERSION_BUILD = 98650; const char * const LL_CHANNEL = "Second Life Server"; diff --git a/linden/indra/llcommon/llversionviewer.h b/linden/indra/llcommon/llversionviewer.h index 66462b3..6e7d6ce 100644 --- a/linden/indra/llcommon/llversionviewer.h +++ b/linden/indra/llcommon/llversionviewer.h @@ -33,8 +33,8 @@ #define LL_LLVERSIONVIEWER_H const S32 LL_VERSION_MAJOR = 1; -const S32 LL_VERSION_MINOR = 21; -const S32 LL_VERSION_PATCH = 6; +const S32 LL_VERSION_MINOR = 22; +const S32 LL_VERSION_PATCH = 0; const S32 LL_VERSION_BUILD = 0; const char * const LL_CHANNEL = "Second Life Release"; diff --git a/linden/indra/llcrashlogger/llcrashlogger.cpp b/linden/indra/llcrashlogger/llcrashlogger.cpp index 77274b0..3abbb2d 100755 --- a/linden/indra/llcrashlogger/llcrashlogger.cpp +++ b/linden/indra/llcrashlogger/llcrashlogger.cpp @@ -154,6 +154,9 @@ void LLCrashLogger::gatherFiles() if (debug_log_file.is_open()) { LLSDSerialize::fromXML(mDebugLog, debug_log_file); + + mCrashInPreviousExec = mDebugLog["CrashNotHandled"].asBoolean(); + mFileMap["SecondLifeLog"] = mDebugLog["SLLog"].asString(); mFileMap["SettingsXml"] = mDebugLog["SettingsFilename"].asString(); if(mDebugLog.has("CAFilename")) @@ -176,6 +179,16 @@ void LLCrashLogger::gatherFiles() mFileMap["SettingsXml"] = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,"settings.xml"); } + if(mCrashInPreviousExec) + { + // Replace the log file ext with .old, since the + // instance that launched this process has overwritten + // SecondLife.log + std::string log_filename = mFileMap["SecondLifeLog"]; + log_filename.replace(log_filename.size() - 4, 4, ".old"); + mFileMap["SecondLifeLog"] = log_filename; + } + gatherPlatformSpecificFiles(); //Use the debug log to reconstruct the URL to send the crash report to @@ -229,12 +242,6 @@ void LLCrashLogger::gatherFiles() LLSD LLCrashLogger::constructPostData() { LLSD ret; - - if(mCrashInPreviousExec) - { - mCrashInfo["CrashInPreviousExecution"] = "Y"; - } - return mCrashInfo; } @@ -338,25 +345,6 @@ bool LLCrashLogger::init() llinfos << "Loading crash behavior setting" << llendl; mCrashBehavior = loadCrashBehaviorSetting(); - //Run through command line options - if(getOption("previous").isDefined()) - { - llinfos << "Previous execution did not remove SecondLife.exec_marker" << llendl; - mCrashInPreviousExec = TRUE; - } - - if(getOption("dialog").isDefined()) - { - llinfos << "Show the user dialog" << llendl; - mCrashBehavior = CRASH_BEHAVIOR_ASK; - } - - LLSD name = getOption("name"); - if(name.isDefined()) - { - mProductName = name.asString(); - } - // If user doesn't want to send, bail out if (mCrashBehavior == CRASH_BEHAVIOR_NEVER_SEND) { diff --git a/linden/indra/llimage/CMakeLists.txt b/linden/indra/llimage/CMakeLists.txt index 5593b4a..1a4d92b 100644 --- a/linden/indra/llimage/CMakeLists.txt +++ b/linden/indra/llimage/CMakeLists.txt @@ -7,6 +7,7 @@ include(LLCommon) include(LLImage) include(LLMath) include(LLVFS) +include(ZLIB) include_directories( ${LLCOMMON_INCLUDE_DIRS} @@ -48,3 +49,9 @@ set_source_files_properties(${llimage_HEADER_FILES} list(APPEND llimage_SOURCE_FILES ${llimage_HEADER_FILES}) add_library (llimage ${llimage_SOURCE_FILES}) +target_link_libraries( + llimage + ${JPEG_LIBRARIES} + ${PNG_LIBRARIES} + ${ZLIB_LIBRARIES} + ) diff --git a/linden/indra/llimage/llimage.cpp b/linden/indra/llimage/llimage.cpp index 814e82f..71e7b41 100644 --- a/linden/indra/llimage/llimage.cpp +++ b/linden/indra/llimage/llimage.cpp @@ -43,6 +43,49 @@ #include "llimagejpeg.h" #include "llimagepng.h" #include "llimagedxt.h" +#include "llimageworker.h" + +//--------------------------------------------------------------------------- +// LLImage +//--------------------------------------------------------------------------- + +//static +std::string LLImage::sLastErrorMessage; +LLMutex* LLImage::sMutex = NULL; + +//static +void LLImage::initClass(LLWorkerThread* workerthread) +{ + sMutex = new LLMutex(NULL); + if (workerthread) + { + LLImageWorker::initImageWorker(workerthread); + } + LLImageJ2C::openDSO(); +} + +//static +void LLImage::cleanupClass() +{ + LLImageJ2C::closeDSO(); + LLImageWorker::cleanupImageWorker(); + delete sMutex; + sMutex = NULL; +} + +//static +const std::string& LLImage::getLastError() +{ + static const std::string noerr("No Error"); + return sLastErrorMessage.empty() ? noerr : sLastErrorMessage; +} + +//static +void LLImage::setLastError(const std::string& message) +{ + LLMutexLock m(sMutex); + sLastErrorMessage = message; +} //--------------------------------------------------------------------------- // LLImageBase @@ -95,21 +138,8 @@ void LLImageBase::sanityCheck() } } -std::string LLImageBase::sLastErrorMessage; BOOL LLImageBase::sSizeOverride = FALSE; -BOOL LLImageBase::setLastError(const std::string& message, const std::string& filename) -{ - sLastErrorMessage = message; - if (!filename.empty()) - { - sLastErrorMessage += " FILE:"; - sLastErrorMessage += filename; - } - llwarns << sLastErrorMessage << llendl; - return FALSE; -} - // virtual void LLImageBase::deleteData() { @@ -136,8 +166,6 @@ U8* LLImageBase::allocateData(S32 size) llerrs << "LLImageBase::allocateData: bad size: " << size << llendl; } - resetLastError(); - if (!mData || size != mDataSize) { deleteData(); // virtual @@ -1269,6 +1297,23 @@ LLImageFormatted::~LLImageFormatted() //---------------------------------------------------------------------------- +//virtual +void LLImageFormatted::resetLastError() +{ + LLImage::setLastError(""); +} + +//virtual +void LLImageFormatted::setLastError(const std::string& message, const std::string& filename) +{ + std::string error = message; + if (!filename.empty()) + error += std::string(" FILE: ") + filename; + LLImage::setLastError(error); +} + +//---------------------------------------------------------------------------- + // static LLImageFormatted* LLImageFormatted::createFromType(S8 codec) { diff --git a/linden/indra/llimage/llimage.h b/linden/indra/llimage/llimage.h index 98a98c2..8a08c89 100644 --- a/linden/indra/llimage/llimage.h +++ b/linden/indra/llimage/llimage.h @@ -59,6 +59,7 @@ const S32 MAX_IMG_PACKET_SIZE = 1000; class LLImageFormatted; class LLImageRaw; class LLColor4U; +class LLWorkerThread; typedef enum e_image_codec { @@ -74,6 +75,24 @@ typedef enum e_image_codec } EImageCodec; //============================================================================ +// library initialization class + +class LLImage +{ +public: + static void initClass(LLWorkerThread* workerthread); + static void cleanupClass(); + + static const std::string& getLastError(); + static void setLastError(const std::string& message); + +protected: + static LLMutex* sMutex; + static std::string sLastErrorMessage; +}; + +//============================================================================ +// Image base class class LLImageBase : public LLThreadSafeRefCount { @@ -113,10 +132,6 @@ protected: void setDataAndSize(U8 *data, S32 size) { mData = data; mDataSize = size; }; public: - static const std::string& getLastError() {return sLastErrorMessage;}; - static void resetLastError() {sLastErrorMessage = "No Error"; }; - static BOOL setLastError(const std::string& message, const std::string& filename = std::string()); // returns FALSE - static void generateMip(const U8 *indata, U8* mipdata, int width, int height, S32 nchannels); // Function for calculating the download priority for textures @@ -141,8 +156,6 @@ private: public: S16 mMemType; // debug - static std::string sLastErrorMessage; - static BOOL sSizeOverride; }; @@ -245,7 +258,6 @@ public: LLImageFormatted(S8 codec); // LLImageBase -public: /*virtual*/ void deleteData(); /*virtual*/ U8* allocateData(S32 size = -1); /*virtual*/ U8* reallocateData(S32 size); @@ -254,7 +266,6 @@ public: /*virtual*/ void sanityCheck(); // New methods -public: // subclasses must return a prefered file extension (lowercase without a leading dot) virtual std::string getExtension() = 0; // calcHeaderSize() returns the maximum size of header; @@ -287,6 +298,10 @@ public: void setDiscardLevel(S8 discard_level) { mDiscardLevel = discard_level; } S8 getDiscardLevel() const { return mDiscardLevel; } + // setLastError needs to be deferred for J2C images since it may be called from a DLL + virtual void resetLastError(); + virtual void setLastError(const std::string& message, const std::string& filename = std::string()); + protected: BOOL copyData(U8 *data, S32 size); // calls updateData() @@ -295,7 +310,7 @@ protected: S8 mDecoding; S8 mDecoded; S8 mDiscardLevel; - + public: static S32 sGlobalFormattedMemory; }; diff --git a/linden/indra/llimage/llimagej2c.cpp b/linden/indra/llimage/llimagej2c.cpp index 510b303..95abbae 100644 --- a/linden/indra/llimage/llimagej2c.cpp +++ b/linden/indra/llimage/llimagej2c.cpp @@ -219,32 +219,54 @@ LLImageJ2C::~LLImageJ2C() } // virtual +void LLImageJ2C::resetLastError() +{ + mLastError.clear(); +} + +//virtual +void LLImageJ2C::setLastError(const std::string& message, const std::string& filename) +{ + mLastError = message; + if (!filename.empty()) + mLastError += std::string(" FILE: ") + filename; +} + +// virtual S8 LLImageJ2C::getRawDiscardLevel() { return mRawDiscardLevel; } BOOL LLImageJ2C::updateData() -{ +{ + BOOL res = TRUE; resetLastError(); // Check to make sure that this instance has been initialized with data if (!getData() || (getDataSize() < 16)) { setLastError("LLImageJ2C uninitialized"); - return FALSE; + res = FALSE; + } + else + { + res = mImpl->getMetadata(*this); } - if (!mImpl->getMetadata(*this)) + if (res) { - return FALSE; + // SJB: override discard based on mMaxBytes elsewhere + S32 max_bytes = getDataSize(); // mMaxBytes ? mMaxBytes : getDataSize(); + S32 discard = calcDiscardLevelBytes(max_bytes); + setDiscardLevel(discard); } - // SJB: override discard based on mMaxBytes elsewhere - S32 max_bytes = getDataSize(); // mMaxBytes ? mMaxBytes : getDataSize(); - S32 discard = calcDiscardLevelBytes(max_bytes); - setDiscardLevel(discard); - return TRUE; + if (!mLastError.empty()) + { + LLImage::setLastError(mLastError); + } + return res; } @@ -258,20 +280,24 @@ BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 fir { LLMemType mt1((LLMemType::EMemType)mMemType); + BOOL res = TRUE; + resetLastError(); // Check to make sure that this instance has been initialized with data if (!getData() || (getDataSize() < 16)) { setLastError("LLImageJ2C uninitialized"); - return FALSE; + res = FALSE; } - - // Update the raw discard level - updateRawDiscardLevel(); - - mDecoding = TRUE; - BOOL res = mImpl->decodeImpl(*this, *raw_imagep, decode_time, first_channel, max_channel_count); + else + { + // Update the raw discard level + updateRawDiscardLevel(); + mDecoding = TRUE; + res = mImpl->decodeImpl(*this, *raw_imagep, decode_time, first_channel, max_channel_count); + } + if (res) { if (!mDecoding) @@ -283,9 +309,14 @@ BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 fir { mDecoding = FALSE; } - return TRUE; // done } - return FALSE; + + if (!mLastError.empty()) + { + LLImage::setLastError(mLastError); + } + + return res; } @@ -298,7 +329,13 @@ BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, F32 encode_time) BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time) { LLMemType mt1((LLMemType::EMemType)mMemType); - return mImpl->encodeImpl(*this, *raw_imagep, comment_text, encode_time, mReversible); + resetLastError(); + BOOL res = mImpl->encodeImpl(*this, *raw_imagep, comment_text, encode_time, mReversible); + if (!mLastError.empty()) + { + LLImage::setLastError(mLastError); + } + return res; } //static @@ -376,6 +413,8 @@ void LLImageJ2C::setReversible(const BOOL reversible) BOOL LLImageJ2C::loadAndValidate(const std::string &filename) { + BOOL res = TRUE; + resetLastError(); S32 file_size = 0; @@ -383,27 +422,38 @@ BOOL LLImageJ2C::loadAndValidate(const std::string &filename) if (!apr_file) { setLastError("Unable to open file for reading", filename); - return FALSE; + res = FALSE; } - if (file_size == 0) + else if (file_size == 0) { setLastError("File is empty",filename); apr_file_close(apr_file); - return FALSE; + res = FALSE; } - - U8 *data = new U8[file_size]; - apr_size_t bytes_read = file_size; - apr_status_t s = apr_file_read(apr_file, data, &bytes_read); // modifies bytes_read - if (s != APR_SUCCESS || (S32)bytes_read != file_size) + else { - delete[] data; - setLastError("Unable to read entire file"); - return FALSE; + U8 *data = new U8[file_size]; + apr_size_t bytes_read = file_size; + apr_status_t s = apr_file_read(apr_file, data, &bytes_read); // modifies bytes_read + apr_file_close(apr_file); + if (s != APR_SUCCESS || (S32)bytes_read != file_size) + { + delete[] data; + setLastError("Unable to read entire file"); + res = FALSE; + } + else + { + res = validate(data, file_size); + } } - apr_file_close(apr_file); - return validate(data, file_size); + if (!mLastError.empty()) + { + LLImage::setLastError(mLastError); + } + + return res; } @@ -411,21 +461,30 @@ BOOL LLImageJ2C::validate(U8 *data, U32 file_size) { LLMemType mt1((LLMemType::EMemType)mMemType); + resetLastError(); + setData(data, file_size); + BOOL res = updateData(); - if ( !res ) + if ( res ) { - return FALSE; + // Check to make sure that this instance has been initialized with data + if (!getData() || (0 == getDataSize())) + { + setLastError("LLImageJ2C uninitialized"); + res = FALSE; + } + else + { + res = mImpl->getMetadata(*this); + } } - - // Check to make sure that this instance has been initialized with data - if (!getData() || (0 == getDataSize())) + + if (!mLastError.empty()) { - setLastError("LLImageJ2C uninitialized"); - return FALSE; + LLImage::setLastError(mLastError); } - - return mImpl->getMetadata(*this); + return res; } void LLImageJ2C::decodeFailed() diff --git a/linden/indra/llimage/llimagej2c.h b/linden/indra/llimage/llimagej2c.h index 2b4a3ec..f4d651f 100644 --- a/linden/indra/llimage/llimagej2c.h +++ b/linden/indra/llimage/llimagej2c.h @@ -54,6 +54,10 @@ public: /*virtual*/ S32 calcDataSize(S32 discard_level = 0); /*virtual*/ S32 calcDiscardLevelBytes(S32 bytes); /*virtual*/ S8 getRawDiscardLevel(); + // Override these so that we don't try to set a global variable from a DLL + /*virtual*/ void resetLastError(); + /*virtual*/ void setLastError(const std::string& message, const std::string& filename = std::string()); + // Encode with comment text BOOL encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time=0.0); @@ -86,6 +90,7 @@ protected: F32 mRate; BOOL mReversible; LLImageJ2CImpl *mImpl; + std::string mLastError; }; // Derive from this class to implement JPEG2000 decoding diff --git a/linden/indra/llimage/llimageworker.cpp b/linden/indra/llimage/llimageworker.cpp index dc6f2e4..93ce19b 100644 --- a/linden/indra/llimage/llimageworker.cpp +++ b/linden/indra/llimage/llimageworker.cpp @@ -41,13 +41,13 @@ LLWorkerThread* LLImageWorker::sWorkerThread = NULL; S32 LLImageWorker::sCount = 0; //static -void LLImageWorker::initClass(LLWorkerThread* workerthread) +void LLImageWorker::initImageWorker(LLWorkerThread* workerthread) { sWorkerThread = workerthread; } //static -void LLImageWorker::cleanupClass() +void LLImageWorker::cleanupImageWorker() { } diff --git a/linden/indra/llimage/llimageworker.h b/linden/indra/llimage/llimageworker.h index bf6c3f2..3ee6b8e 100644 --- a/linden/indra/llimage/llimageworker.h +++ b/linden/indra/llimage/llimageworker.h @@ -38,8 +38,10 @@ class LLImageWorker : public LLWorkerClass { public: - static void initClass(LLWorkerThread* workerthread); - static void cleanupClass(); + static void initImageWorker(LLWorkerThread* workerthread); + static void cleanupImageWorker(); + +public: static LLWorkerThread* getWorkerThread() { return sWorkerThread; } // LLWorkerThread diff --git a/linden/indra/llimagej2coj/CMakeLists.txt b/linden/indra/llimagej2coj/CMakeLists.txt index ed3ff3c..97d22cf 100644 --- a/linden/indra/llimagej2coj/CMakeLists.txt +++ b/linden/indra/llimagej2coj/CMakeLists.txt @@ -29,3 +29,7 @@ set_source_files_properties(${llimagej2coj_HEADER_FILES} list(APPEND llimagej2coj_SOURCE_FILES ${llimagej2coj_HEADER_FILES}) add_library (llimagej2coj ${llimagej2coj_SOURCE_FILES}) +target_link_libraries( + llimagej2coj + ${OPENJPEG_LIBRARIES} + ) diff --git a/linden/indra/llimagej2coj/llimagej2coj.cpp b/linden/indra/llimagej2coj/llimagej2coj.cpp index 983241c..7a62cfd 100644 --- a/linden/indra/llimagej2coj/llimagej2coj.cpp +++ b/linden/indra/llimagej2coj/llimagej2coj.cpp @@ -151,9 +151,11 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod // dereference the array. if(!image || !image->numcomps) { - fprintf(stderr, "ERROR -> decodeImpl: failed to decode image!\n"); + llwarns << "ERROR -> decodeImpl: failed to decode image!" << llendl; if (image) + { opj_image_destroy(image); + } return TRUE; // done } @@ -170,6 +172,17 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod } } + if(image->numcomps <= first_channel) + { + llwarns << "trying to decode more channels than are present in image: numcomps: " << image->numcomps << " first_channel: " << first_channel << llendl; + if (image) + { + opj_image_destroy(image); + } + + return TRUE; + } + // Copy image data into our raw image format (instead of the separate channel format S32 img_components = image->numcomps; @@ -211,7 +224,7 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod } else // Some rare OpenJPEG versions have this bug. { - fprintf(stderr, "ERROR -> decodeImpl: failed to decode image! (NULL comp data - OpenJPEG bug)\n"); + llwarns << "ERROR -> decodeImpl: failed to decode image! (NULL comp data - OpenJPEG bug)" << llendl; opj_image_destroy(image); return TRUE; // done @@ -430,7 +443,7 @@ BOOL LLImageJ2COJ::getMetadata(LLImageJ2C &base) if(!image) { - fprintf(stderr, "ERROR -> getMetadata: failed to decode image!\n"); + llwarns << "ERROR -> getMetadata: failed to decode image!" << llendl; return FALSE; } diff --git a/linden/indra/llinventory/llinventory.cpp b/linden/indra/llinventory/llinventory.cpp index 457a0cb..0c7e0ed 100644 --- a/linden/indra/llinventory/llinventory.cpp +++ b/linden/indra/llinventory/llinventory.cpp @@ -60,6 +60,9 @@ static const std::string INV_SALE_INFO_LABEL("sale_info"); static const std::string INV_FLAGS_LABEL("flags"); static const std::string INV_CREATION_DATE_LABEL("created_at"); +// key used by agent-inventory-service +static const std::string INV_ASSET_TYPE_LABEL_WS("type_default"); +static const std::string INV_FOLDER_ID_LABEL_WS("category_id"); ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs ///---------------------------------------------------------------------------- @@ -949,11 +952,13 @@ LLSD LLInventoryItem::asLLSD() const sd[INV_SHADOW_ID_LABEL] = shadow_id; } sd[INV_ASSET_TYPE_LABEL] = LLAssetType::lookup(mType); + sd[INV_INVENTORY_TYPE_LABEL] = mInventoryType; const char* inv_type_str = LLInventoryType::lookup(mInventoryType); if(inv_type_str) { sd[INV_INVENTORY_TYPE_LABEL] = inv_type_str; } + //sd[INV_FLAGS_LABEL] = (S32)mFlags; sd[INV_FLAGS_LABEL] = ll_sd_from_U32(mFlags); sd[INV_SALE_INFO_LABEL] = mSaleInfo; sd[INV_NAME_LABEL] = mName; @@ -1026,17 +1031,40 @@ bool LLInventoryItem::fromLLSD(LLSD& sd) w = INV_ASSET_TYPE_LABEL; if (sd.has(w)) { - mType = LLAssetType::lookup(sd[w].asString()); + if (sd[w].isString()) + { + mType = LLAssetType::lookup(sd[w].asString().c_str()); + } + else if (sd[w].isInteger()) + { + S8 type = (U8)sd[w].asInteger(); + mType = static_cast(type); + } } w = INV_INVENTORY_TYPE_LABEL; if (sd.has(w)) { - mInventoryType = LLInventoryType::lookup(sd[w].asString()); + if (sd[w].isString()) + { + mInventoryType = LLInventoryType::lookup(sd[w].asString().c_str()); + } + else if (sd[w].isInteger()) + { + S8 type = (U8)sd[w].asInteger(); + mInventoryType = static_cast(type); + } } w = INV_FLAGS_LABEL; if (sd.has(w)) { - mFlags = ll_U32_from_sd(sd[w]); + if (sd[w].isBinary()) + { + mFlags = ll_U32_from_sd(sd[w]); + } + else if(sd[w].isInteger()) + { + mFlags = sd[w].asInteger(); + } } w = INV_NAME_LABEL; if (sd.has(w)) @@ -1394,7 +1422,7 @@ bool LLInventoryCategory::fromLLSD(LLSD& sd) { std::string w; - w = INV_ITEM_ID_LABEL; + w = INV_FOLDER_ID_LABEL_WS; if (sd.has(w)) { mUUID = sd[w]; @@ -1410,6 +1438,13 @@ bool LLInventoryCategory::fromLLSD(LLSD& sd) S8 type = (U8)sd[w].asInteger(); mPreferredType = static_cast(type); } + w = INV_ASSET_TYPE_LABEL_WS; + if (sd.has(w)) + { + S8 type = (U8)sd[w].asInteger(); + mPreferredType = static_cast(type); + } + w = INV_NAME_LABEL; if (sd.has(w)) { diff --git a/linden/indra/llinventory/llparcel.cpp b/linden/indra/llinventory/llparcel.cpp index 2b9c201..911e257 100644 --- a/linden/indra/llinventory/llparcel.cpp +++ b/linden/indra/llinventory/llparcel.cpp @@ -1398,7 +1398,7 @@ void LLParcel::unpackMessage(LLMessageSystem* msg) // New Media Data // Note: the message has been converted to TCP - if(msg->getNumberOfBlocks("MediaData") > 0) + if(msg->has("MediaData")) { msg->getString("MediaData", "MediaDesc", buffer); setMediaDesc(buffer); @@ -1761,7 +1761,11 @@ void LLParcel::startSale(const LLUUID& buyer_id, BOOL is_buyer_group) setCleanOtherTime(0); } -void LLParcel::expireSale(U32& type, U8& flags, LLUUID& from_id, LLUUID& to_id) +void LLParcel::expireSale( + U32& type, + U8& flags, + LLUUID& from_id, + LLUUID& to_id) { mSaleTimerExpires.setTimerExpirySec(0.0); mSaleTimerExpires.stop(); @@ -1777,8 +1781,10 @@ void LLParcel::expireSale(U32& type, U8& flags, LLUUID& from_id, LLUUID& to_id) to_id.setNull(); } -void LLParcel::completeSale(U32& type, U8& flags, - LLUUID& to_id) +void LLParcel::completeSale( + U32& type, + U8& flags, + LLUUID& to_id) { mSaleTimerExpires.setTimerExpirySec(0.0); mSaleTimerExpires.stop(); diff --git a/linden/indra/llinventory/llsaleinfo.cpp b/linden/indra/llinventory/llsaleinfo.cpp index 4895378..fef6b05 100644 --- a/linden/indra/llinventory/llsaleinfo.cpp +++ b/linden/indra/llinventory/llsaleinfo.cpp @@ -114,7 +114,16 @@ bool LLSaleInfo::fromLLSD(LLSD& sd, BOOL& has_perm_mask, U32& perm_mask) { const char *w; - mSaleType = lookup(sd["sale_type"].asString().c_str()); + if (sd["sale_type"].isString()) + { + mSaleType = lookup(sd["sale_type"].asString().c_str()); + } + else if(sd["sale_type"].isInteger()) + { + S8 type = (U8)sd["sale_type"].asInteger(); + mSaleType = static_cast(type); + } + mSalePrice = llclamp(sd["sale_price"].asInteger(), 0, S32_MAX); w = "perm_mask"; if (sd.has(w)) diff --git a/linden/indra/llmath/llmodularmath.h b/linden/indra/llmath/llmodularmath.h new file mode 100644 index 0000000..076f5da --- /dev/null +++ b/linden/indra/llmath/llmodularmath.h @@ -0,0 +1,57 @@ +/** + * @file llmodularmath.h + * @brief Useful modular math functions. + * + * $LicenseInfo:firstyear=2008&license=viewergpl$ + * + * Copyright (c) 2008, 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 LLMODULARMATH_H +#define LLMODULARMATH_H + +namespace LLModularMath +{ + // Return difference between lhs and rhs + // treating the U32 operands and result + // as unsigned values of given width. + template + inline U32 subtract(U32 lhs, U32 rhs) + { + // Generate a bit mask which will truncate + // unsigned values to given width at compile time. + const U32 mask = (1 << width) - 1; + + // Operands are unsigned, so modular + // arithmetic applies. If lhs < rhs, + // difference will wrap in to lower + // bits of result, which is then masked + // to give a value that can be represented + // by an unsigned value of width bits. + return mask & (lhs - rhs); + } +} + +#endif diff --git a/linden/indra/llmath/lloctree.h b/linden/indra/llmath/lloctree.h index 57b359f..c37f887 100644 --- a/linden/indra/llmath/lloctree.h +++ b/linden/indra/llmath/lloctree.h @@ -38,9 +38,9 @@ #include #if LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG -#define OCT_ERRS LL_WARNS("OctreeErrors") -#else #define OCT_ERRS LL_ERRS("OctreeErrors") +#else +#define OCT_ERRS LL_WARNS("OctreeErrors") #endif #define LL_OCTREE_PARANOIA_CHECK 0 diff --git a/linden/indra/llmath/v3color.h b/linden/indra/llmath/v3color.h index b9bc641..111a871 100644 --- a/linden/indra/llmath/v3color.h +++ b/linden/indra/llmath/v3color.h @@ -82,13 +82,23 @@ public: const LLColor3& setToBlack(); // Clears LLColor3 to (0, 0, 0) const LLColor3& setToWhite(); // Zero LLColor3 to (0, 0, 0) - const LLColor3& setVec(F32 x, F32 y, F32 z); // Sets LLColor3 to (x, y, z) - const LLColor3& setVec(const LLColor3 &vec); // Sets LLColor3 to vec - const LLColor3& setVec(const F32 *vec); // Sets LLColor3 to vec + + const LLColor3& setVec(F32 x, F32 y, F32 z); // deprecated + const LLColor3& setVec(const LLColor3 &vec); // deprecated + const LLColor3& setVec(const F32 *vec); // deprecated + + const LLColor3& set(F32 x, F32 y, F32 z); // Sets LLColor3 to (x, y, z) + const LLColor3& set(const LLColor3 &vec); // Sets LLColor3 to vec + const LLColor3& set(const F32 *vec); // Sets LLColor3 to vec + + F32 magVec() const; // deprecated + F32 magVecSquared() const; // deprecated + F32 normVec(); // deprecated + + F32 length() const; // Returns magnitude of LLColor3 + F32 lengthSquared() const; // Returns magnitude squared of LLColor3 + F32 normalize(); // Normalizes and returns the magnitude of LLColor3 - F32 magVec() const; // Returns magnitude of LLColor3 - F32 magVecSquared() const; // Returns magnitude squared of LLColor3 - F32 normVec(); // Normalizes and returns the magnitude of LLColor3 F32 brightness() const; // Returns brightness of LLColor3 const LLColor3& operator=(const LLColor4 &a); @@ -214,6 +224,31 @@ inline const LLColor3& LLColor3::setToWhite(void) return (*this); } +inline const LLColor3& LLColor3::set(F32 r, F32 g, F32 b) +{ + mV[0] = r; + mV[1] = g; + mV[2] = b; + return (*this); +} + +inline const LLColor3& LLColor3::set(const LLColor3 &vec) +{ + mV[0] = vec.mV[0]; + mV[1] = vec.mV[1]; + mV[2] = vec.mV[2]; + return (*this); +} + +inline const LLColor3& LLColor3::set(const F32 *vec) +{ + mV[0] = vec[0]; + mV[1] = vec[1]; + mV[2] = vec[2]; + return (*this); +} + +// deprecated inline const LLColor3& LLColor3::setVec(F32 r, F32 g, F32 b) { mV[0] = r; @@ -222,6 +257,7 @@ inline const LLColor3& LLColor3::setVec(F32 r, F32 g, F32 b) return (*this); } +// deprecated inline const LLColor3& LLColor3::setVec(const LLColor3 &vec) { mV[0] = vec.mV[0]; @@ -230,6 +266,7 @@ inline const LLColor3& LLColor3::setVec(const LLColor3 &vec) return (*this); } +// deprecated inline const LLColor3& LLColor3::setVec(const F32 *vec) { mV[0] = vec[0]; @@ -243,16 +280,44 @@ inline F32 LLColor3::brightness(void) const return (mV[0] + mV[1] + mV[2]) / 3.0f; } +inline F32 LLColor3::length(void) const +{ + return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]); +} + +inline F32 LLColor3::lengthSquared(void) const +{ + return mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]; +} + +inline F32 LLColor3::normalize(void) +{ + F32 mag = fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]); + F32 oomag; + + if (mag) + { + oomag = 1.f/mag; + mV[0] *= oomag; + mV[1] *= oomag; + mV[2] *= oomag; + } + return (mag); +} + +// deprecated inline F32 LLColor3::magVec(void) const { return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]); } +// deprecated inline F32 LLColor3::magVecSquared(void) const { return mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]; } +// deprecated inline F32 LLColor3::normVec(void) { F32 mag = fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]); diff --git a/linden/indra/llmath/v4color.cpp b/linden/indra/llmath/v4color.cpp index 88237a0..b105769 100644 --- a/linden/indra/llmath/v4color.cpp +++ b/linden/indra/llmath/v4color.cpp @@ -161,6 +161,38 @@ LLColor4::LLColor4(const LLVector4& vector4) mV[VW] = vector4.mV[VW]; } +const LLColor4& LLColor4::set(const LLColor4U& color4u) +{ + const F32 SCALE = 1.f/255.f; + mV[VX] = color4u.mV[VX] * SCALE; + mV[VY] = color4u.mV[VY] * SCALE; + mV[VZ] = color4u.mV[VZ] * SCALE; + mV[VW] = color4u.mV[VW] * SCALE; + return (*this); +} + +const LLColor4& LLColor4::set(const LLColor3 &vec) +{ + mV[VX] = vec.mV[VX]; + mV[VY] = vec.mV[VY]; + mV[VZ] = vec.mV[VZ]; + +// no change to alpha! +// mV[VW] = 1.f; + + return (*this); +} + +const LLColor4& LLColor4::set(const LLColor3 &vec, F32 a) +{ + mV[VX] = vec.mV[VX]; + mV[VY] = vec.mV[VY]; + mV[VZ] = vec.mV[VZ]; + mV[VW] = a; + return (*this); +} + +// deprecated -- use set() const LLColor4& LLColor4::setVec(const LLColor4U& color4u) { const F32 SCALE = 1.f/255.f; @@ -171,6 +203,7 @@ const LLColor4& LLColor4::setVec(const LLColor4U& color4u) return (*this); } +// deprecated -- use set() const LLColor4& LLColor4::setVec(const LLColor3 &vec) { mV[VX] = vec.mV[VX]; @@ -183,6 +216,7 @@ const LLColor4& LLColor4::setVec(const LLColor3 &vec) return (*this); } +// deprecated -- use set() const LLColor4& LLColor4::setVec(const LLColor3 &vec, F32 a) { mV[VX] = vec.mV[VX]; @@ -338,270 +372,270 @@ BOOL LLColor4::parseColor(const std::string& buf, LLColor4* color) { v = v * (1.f / 255.f); } - color->setVec( v ); + color->set( v ); } else // Single value. Read as a named color. { // We have a color name if ( "red" == color_name ) { - color->setVec(LLColor4::red); + color->set(LLColor4::red); } else if ( "red1" == color_name ) { - color->setVec(LLColor4::red1); + color->set(LLColor4::red1); } else if ( "red2" == color_name ) { - color->setVec(LLColor4::red2); + color->set(LLColor4::red2); } else if ( "red3" == color_name ) { - color->setVec(LLColor4::red3); + color->set(LLColor4::red3); } else if ( "red4" == color_name ) { - color->setVec(LLColor4::red4); + color->set(LLColor4::red4); } else if ( "red5" == color_name ) { - color->setVec(LLColor4::red5); + color->set(LLColor4::red5); } else if( "green" == color_name ) { - color->setVec(LLColor4::green); + color->set(LLColor4::green); } else if( "green1" == color_name ) { - color->setVec(LLColor4::green1); + color->set(LLColor4::green1); } else if( "green2" == color_name ) { - color->setVec(LLColor4::green2); + color->set(LLColor4::green2); } else if( "green3" == color_name ) { - color->setVec(LLColor4::green3); + color->set(LLColor4::green3); } else if( "green4" == color_name ) { - color->setVec(LLColor4::green4); + color->set(LLColor4::green4); } else if( "green5" == color_name ) { - color->setVec(LLColor4::green5); + color->set(LLColor4::green5); } else if( "green6" == color_name ) { - color->setVec(LLColor4::green6); + color->set(LLColor4::green6); } else if( "blue" == color_name ) { - color->setVec(LLColor4::blue); + color->set(LLColor4::blue); } else if( "blue1" == color_name ) { - color->setVec(LLColor4::blue1); + color->set(LLColor4::blue1); } else if( "blue2" == color_name ) { - color->setVec(LLColor4::blue2); + color->set(LLColor4::blue2); } else if( "blue3" == color_name ) { - color->setVec(LLColor4::blue3); + color->set(LLColor4::blue3); } else if( "blue4" == color_name ) { - color->setVec(LLColor4::blue4); + color->set(LLColor4::blue4); } else if( "blue5" == color_name ) { - color->setVec(LLColor4::blue5); + color->set(LLColor4::blue5); } else if( "blue6" == color_name ) { - color->setVec(LLColor4::blue6); + color->set(LLColor4::blue6); } else if( "black" == color_name ) { - color->setVec(LLColor4::black); + color->set(LLColor4::black); } else if( "white" == color_name ) { - color->setVec(LLColor4::white); + color->set(LLColor4::white); } else if( "yellow" == color_name ) { - color->setVec(LLColor4::yellow); + color->set(LLColor4::yellow); } else if( "yellow1" == color_name ) { - color->setVec(LLColor4::yellow1); + color->set(LLColor4::yellow1); } else if( "yellow2" == color_name ) { - color->setVec(LLColor4::yellow2); + color->set(LLColor4::yellow2); } else if( "yellow3" == color_name ) { - color->setVec(LLColor4::yellow3); + color->set(LLColor4::yellow3); } else if( "yellow4" == color_name ) { - color->setVec(LLColor4::yellow4); + color->set(LLColor4::yellow4); } else if( "yellow5" == color_name ) { - color->setVec(LLColor4::yellow5); + color->set(LLColor4::yellow5); } else if( "yellow6" == color_name ) { - color->setVec(LLColor4::yellow6); + color->set(LLColor4::yellow6); } else if( "magenta" == color_name ) { - color->setVec(LLColor4::magenta); + color->set(LLColor4::magenta); } else if( "magenta1" == color_name ) { - color->setVec(LLColor4::magenta1); + color->set(LLColor4::magenta1); } else if( "magenta2" == color_name ) { - color->setVec(LLColor4::magenta2); + color->set(LLColor4::magenta2); } else if( "magenta3" == color_name ) { - color->setVec(LLColor4::magenta3); + color->set(LLColor4::magenta3); } else if( "magenta4" == color_name ) { - color->setVec(LLColor4::magenta4); + color->set(LLColor4::magenta4); } else if( "purple" == color_name ) { - color->setVec(LLColor4::purple); + color->set(LLColor4::purple); } else if( "purple1" == color_name ) { - color->setVec(LLColor4::purple1); + color->set(LLColor4::purple1); } else if( "purple2" == color_name ) { - color->setVec(LLColor4::purple2); + color->set(LLColor4::purple2); } else if( "purple3" == color_name ) { - color->setVec(LLColor4::purple3); + color->set(LLColor4::purple3); } else if( "purple4" == color_name ) { - color->setVec(LLColor4::purple4); + color->set(LLColor4::purple4); } else if( "purple5" == color_name ) { - color->setVec(LLColor4::purple5); + color->set(LLColor4::purple5); } else if( "purple6" == color_name ) { - color->setVec(LLColor4::purple6); + color->set(LLColor4::purple6); } else if( "pink" == color_name ) { - color->setVec(LLColor4::pink); + color->set(LLColor4::pink); } else if( "pink1" == color_name ) { - color->setVec(LLColor4::pink1); + color->set(LLColor4::pink1); } else if( "pink2" == color_name ) { - color->setVec(LLColor4::pink2); + color->set(LLColor4::pink2); } else if( "cyan" == color_name ) { - color->setVec(LLColor4::cyan); + color->set(LLColor4::cyan); } else if( "cyan1" == color_name ) { - color->setVec(LLColor4::cyan1); + color->set(LLColor4::cyan1); } else if( "cyan2" == color_name ) { - color->setVec(LLColor4::cyan2); + color->set(LLColor4::cyan2); } else if( "cyan3" == color_name ) { - color->setVec(LLColor4::cyan3); + color->set(LLColor4::cyan3); } else if( "cyan4" == color_name ) { - color->setVec(LLColor4::cyan4); + color->set(LLColor4::cyan4); } else if( "cyan5" == color_name ) { - color->setVec(LLColor4::cyan5); + color->set(LLColor4::cyan5); } else if( "cyan6" == color_name ) { - color->setVec(LLColor4::cyan6); + color->set(LLColor4::cyan6); } else if( "smoke" == color_name ) { - color->setVec(LLColor4::smoke); + color->set(LLColor4::smoke); } else if( "grey" == color_name ) { - color->setVec(LLColor4::grey); + color->set(LLColor4::grey); } else if( "grey1" == color_name ) { - color->setVec(LLColor4::grey1); + color->set(LLColor4::grey1); } else if( "grey2" == color_name ) { - color->setVec(LLColor4::grey2); + color->set(LLColor4::grey2); } else if( "grey3" == color_name ) { - color->setVec(LLColor4::grey3); + color->set(LLColor4::grey3); } else if( "grey4" == color_name ) { - color->setVec(LLColor4::grey4); + color->set(LLColor4::grey4); } else if( "orange" == color_name ) { - color->setVec(LLColor4::orange); + color->set(LLColor4::orange); } else if( "orange1" == color_name ) { - color->setVec(LLColor4::orange1); + color->set(LLColor4::orange1); } else if( "orange2" == color_name ) { - color->setVec(LLColor4::orange2); + color->set(LLColor4::orange2); } else if( "orange3" == color_name ) { - color->setVec(LLColor4::orange3); + color->set(LLColor4::orange3); } else if( "orange4" == color_name ) { - color->setVec(LLColor4::orange4); + color->set(LLColor4::orange4); } else if( "orange5" == color_name ) { - color->setVec(LLColor4::orange5); + color->set(LLColor4::orange5); } else if( "orange6" == color_name ) { - color->setVec(LLColor4::orange6); + color->set(LLColor4::orange6); } else if ( "clear" == color_name ) { - color->setVec(0.f, 0.f, 0.f, 0.f); + color->set(0.f, 0.f, 0.f, 0.f); } else { diff --git a/linden/indra/llmath/v4color.h b/linden/indra/llmath/v4color.h index 53e4407..b01e881 100644 --- a/linden/indra/llmath/v4color.h +++ b/linden/indra/llmath/v4color.h @@ -84,20 +84,33 @@ class LLColor4 const LLColor4& setToBlack(); // zero LLColor4 to (0, 0, 0, 1) const LLColor4& setToWhite(); // zero LLColor4 to (0, 0, 0, 1) - const LLColor4& setVec(F32 r, F32 g, F32 b, F32 a); // Sets LLColor4 to (r, g, b, a) - const LLColor4& setVec(F32 r, F32 g, F32 b); // Sets LLColor4 to (r, g, b) (no change in a) - const LLColor4& setVec(const LLColor4 &vec); // Sets LLColor4 to vec - const LLColor4& setVec(const LLColor3 &vec); // Sets LLColor4 to LLColor3 vec (no change in alpha) - const LLColor4& setVec(const LLColor3 &vec, F32 a); // Sets LLColor4 to LLColor3 vec, with alpha specified - const LLColor4& setVec(const F32 *vec); // Sets LLColor4 to vec - const LLColor4& setVec(const LLColor4U& color4u); // Sets LLColor4 to color4u, rescaled. + const LLColor4& setVec(F32 r, F32 g, F32 b, F32 a); // deprecated -- use set() + const LLColor4& setVec(F32 r, F32 g, F32 b); // deprecated -- use set() + const LLColor4& setVec(const LLColor4 &vec); // deprecated -- use set() + const LLColor4& setVec(const LLColor3 &vec); // deprecated -- use set() + const LLColor4& setVec(const LLColor3 &vec, F32 a); // deprecated -- use set() + const LLColor4& setVec(const F32 *vec); // deprecated -- use set() + const LLColor4& setVec(const LLColor4U& color4u); // deprecated -- use set() + + const LLColor4& set(F32 r, F32 g, F32 b, F32 a); // Sets LLColor4 to (r, g, b, a) + const LLColor4& set(F32 r, F32 g, F32 b); // Sets LLColor4 to (r, g, b) (no change in a) + const LLColor4& set(const LLColor4 &vec); // Sets LLColor4 to vec + const LLColor4& set(const LLColor3 &vec); // Sets LLColor4 to LLColor3 vec (no change in alpha) + const LLColor4& set(const LLColor3 &vec, F32 a); // Sets LLColor4 to LLColor3 vec, with alpha specified + const LLColor4& set(const F32 *vec); // Sets LLColor4 to vec + const LLColor4& set(const LLColor4U& color4u); // Sets LLColor4 to color4u, rescaled. const LLColor4& setAlpha(F32 a); - F32 magVec() const; // Returns magnitude of LLColor4 - F32 magVecSquared() const; // Returns magnitude squared of LLColor4 - F32 normVec(); // Normalizes and returns the magnitude of LLColor4 + F32 magVec() const; // deprecated -- use length() + F32 magVecSquared() const; // deprecated -- use lengthSquared() + F32 normVec(); // deprecated -- use normalize() + + F32 length() const; // Returns magnitude of LLColor4 + F32 lengthSquared() const; // Returns magnitude squared of LLColor4 + F32 normalize(); // deprecated -- use normalize() + BOOL isOpaque() { return mV[VALPHA] == 1.f; } F32 operator[](int idx) const { return mV[idx]; } @@ -289,6 +302,47 @@ inline const LLColor4& LLColor4::setToWhite(void) return (*this); } +inline const LLColor4& LLColor4::set(F32 x, F32 y, F32 z) +{ + mV[VX] = x; + mV[VY] = y; + mV[VZ] = z; + +// no change to alpha! +// mV[VW] = 1.f; + + return (*this); +} + +inline const LLColor4& LLColor4::set(F32 x, F32 y, F32 z, F32 a) +{ + mV[VX] = x; + mV[VY] = y; + mV[VZ] = z; + mV[VW] = a; + return (*this); +} + +inline const LLColor4& LLColor4::set(const LLColor4 &vec) +{ + mV[VX] = vec.mV[VX]; + mV[VY] = vec.mV[VY]; + mV[VZ] = vec.mV[VZ]; + mV[VW] = vec.mV[VW]; + return (*this); +} + + +inline const LLColor4& LLColor4::set(const F32 *vec) +{ + mV[VX] = vec[VX]; + mV[VY] = vec[VY]; + mV[VZ] = vec[VZ]; + mV[VW] = vec[VW]; + return (*this); +} + +// deprecated inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z) { mV[VX] = x; @@ -301,6 +355,7 @@ inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z) return (*this); } +// deprecated inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z, F32 a) { mV[VX] = x; @@ -310,6 +365,7 @@ inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z, F32 a) return (*this); } +// deprecated inline const LLColor4& LLColor4::setVec(const LLColor4 &vec) { mV[VX] = vec.mV[VX]; @@ -320,6 +376,7 @@ inline const LLColor4& LLColor4::setVec(const LLColor4 &vec) } +// deprecated inline const LLColor4& LLColor4::setVec(const F32 *vec) { mV[VX] = vec[VX]; @@ -337,16 +394,44 @@ inline const LLColor4& LLColor4::setAlpha(F32 a) // LLColor4 Magnitude and Normalization Functions +inline F32 LLColor4::length(void) const +{ + return fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); +} + +inline F32 LLColor4::lengthSquared(void) const +{ + return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]; +} + +inline F32 LLColor4::normalize(void) +{ + F32 mag = fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); + F32 oomag; + + if (mag) + { + oomag = 1.f/mag; + mV[VX] *= oomag; + mV[VY] *= oomag; + mV[VZ] *= oomag; + } + return (mag); +} + +// deprecated inline F32 LLColor4::magVec(void) const { return fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); } +// deprecated inline F32 LLColor4::magVecSquared(void) const { return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]; } +// deprecated inline F32 LLColor4::normVec(void) { F32 mag = fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); @@ -497,13 +582,13 @@ inline const LLColor4& operator%=(LLColor4 &a, F32 k) inline F32 distVec(const LLColor4 &a, const LLColor4 &b) { LLColor4 vec = a - b; - return (vec.magVec()); + return (vec.length()); } inline F32 distVec_squared(const LLColor4 &a, const LLColor4 &b) { LLColor4 vec = a - b; - return (vec.magVecSquared()); + return (vec.lengthSquared()); } inline LLColor4 lerp(const LLColor4 &a, const LLColor4 &b, F32 u) diff --git a/linden/indra/llmath/v4coloru.cpp b/linden/indra/llmath/v4coloru.cpp index 7ad7eb2..fdad596 100644 --- a/linden/indra/llmath/v4coloru.cpp +++ b/linden/indra/llmath/v4coloru.cpp @@ -120,6 +120,6 @@ BOOL LLColor4U::parseColor4U(const std::string& buf, LLColor4U* value) } } - value->setVec( U8(v[0]), U8(v[1]), U8(v[2]), U8(v[3]) ); + value->set( U8(v[0]), U8(v[1]), U8(v[2]), U8(v[3]) ); return TRUE; } diff --git a/linden/indra/llmath/v4coloru.h b/linden/indra/llmath/v4coloru.h index 910a081..d46ca52 100644 --- a/linden/indra/llmath/v4coloru.h +++ b/linden/indra/llmath/v4coloru.h @@ -97,15 +97,23 @@ public: const LLColor4U& setToBlack(); // zero LLColor4U to (0, 0, 0, 1) const LLColor4U& setToWhite(); // zero LLColor4U to (0, 0, 0, 1) - const LLColor4U& setVec(U8 r, U8 g, U8 b, U8 a); // Sets LLColor4U to (r, g, b, a) - const LLColor4U& setVec(U8 r, U8 g, U8 b); // Sets LLColor4U to (r, g, b) (no change in a) - const LLColor4U& setVec(const LLColor4U &vec); // Sets LLColor4U to vec - const LLColor4U& setVec(const U8 *vec); // Sets LLColor4U to vec + const LLColor4U& set(U8 r, U8 g, U8 b, U8 a);// Sets LLColor4U to (r, g, b, a) + const LLColor4U& set(U8 r, U8 g, U8 b); // Sets LLColor4U to (r, g, b) (no change in a) + const LLColor4U& set(const LLColor4U &vec); // Sets LLColor4U to vec + const LLColor4U& set(const U8 *vec); // Sets LLColor4U to vec + + const LLColor4U& setVec(U8 r, U8 g, U8 b, U8 a); // deprecated -- use set() + const LLColor4U& setVec(U8 r, U8 g, U8 b); // deprecated -- use set() + const LLColor4U& setVec(const LLColor4U &vec); // deprecated -- use set() + const LLColor4U& setVec(const U8 *vec); // deprecated -- use set() const LLColor4U& setAlpha(U8 a); - F32 magVec() const; // Returns magnitude of LLColor4U - F32 magVecSquared() const; // Returns magnitude squared of LLColor4U + F32 magVec() const; // deprecated -- use length() + F32 magVecSquared() const; // deprecated -- use lengthSquared() + + F32 length() const; // Returns magnitude squared of LLColor4U + F32 lengthSquared() const; // Returns magnitude squared of LLColor4U friend std::ostream& operator<<(std::ostream& s, const LLColor4U &a); // Print a friend LLColor4U operator+(const LLColor4U &a, const LLColor4U &b); // Return vector a + b @@ -199,7 +207,7 @@ inline const LLColor4U& LLColor4U::setToWhite(void) return (*this); } -inline const LLColor4U& LLColor4U::setVec(const U8 x, const U8 y, const U8 z) +inline const LLColor4U& LLColor4U::set(const U8 x, const U8 y, const U8 z) { mV[VX] = x; mV[VY] = y; @@ -211,7 +219,7 @@ inline const LLColor4U& LLColor4U::setVec(const U8 x, const U8 y, const U8 z) return (*this); } -inline const LLColor4U& LLColor4U::setVec(const U8 r, const U8 g, const U8 b, U8 a) +inline const LLColor4U& LLColor4U::set(const U8 r, const U8 g, const U8 b, U8 a) { mV[0] = r; mV[1] = g; @@ -220,7 +228,7 @@ inline const LLColor4U& LLColor4U::setVec(const U8 r, const U8 g, const U8 b, U8 return (*this); } -inline const LLColor4U& LLColor4U::setVec(const LLColor4U &vec) +inline const LLColor4U& LLColor4U::set(const LLColor4U &vec) { mV[VX] = vec.mV[VX]; mV[VY] = vec.mV[VY]; @@ -229,17 +237,49 @@ inline const LLColor4U& LLColor4U::setVec(const LLColor4U &vec) return (*this); } -/* -inline const LLColor4U& LLColor4U::setVec(const LLColor4 &vec) +inline const LLColor4U& LLColor4U::set(const U8 *vec) { - mV[VX] = (U8) (llmin(1.f, vec.mV[VX]) * 255.f); - mV[VY] = (U8) (llmin(1.f, vec.mV[VY]) * 255.f); - mV[VZ] = (U8) (llmin(1.f, vec.mV[VZ]) * 255.f); - mV[VW] = (U8) (llmin(1.f, vec.mV[VW]) * 255.f); + mV[VX] = vec[VX]; + mV[VY] = vec[VY]; + mV[VZ] = vec[VZ]; + mV[VW] = vec[VW]; return (*this); } -*/ +// deprecated +inline const LLColor4U& LLColor4U::setVec(const U8 x, const U8 y, const U8 z) +{ + mV[VX] = x; + mV[VY] = y; + mV[VZ] = z; + +// no change to alpha! +// mV[VW] = 255; + + return (*this); +} + +// deprecated +inline const LLColor4U& LLColor4U::setVec(const U8 r, const U8 g, const U8 b, U8 a) +{ + mV[0] = r; + mV[1] = g; + mV[2] = b; + mV[3] = a; + return (*this); +} + +// deprecated +inline const LLColor4U& LLColor4U::setVec(const LLColor4U &vec) +{ + mV[VX] = vec.mV[VX]; + mV[VY] = vec.mV[VY]; + mV[VZ] = vec.mV[VZ]; + mV[VW] = vec.mV[VW]; + return (*this); +} + +// deprecated inline const LLColor4U& LLColor4U::setVec(const U8 *vec) { mV[VX] = vec[VX]; @@ -256,13 +296,24 @@ inline const LLColor4U& LLColor4U::setAlpha(U8 a) } // LLColor4U Magnitude and Normalization Functions -// bookmark +inline F32 LLColor4U::length(void) const +{ + return fsqrtf( ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ] ); +} + +inline F32 LLColor4U::lengthSquared(void) const +{ + return ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ]; +} + +// deprecated inline F32 LLColor4U::magVec(void) const { return fsqrtf( ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ] ); } +// deprecated inline F32 LLColor4U::magVecSquared(void) const { return ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ]; @@ -407,13 +458,13 @@ inline const LLColor4U& operator%=(LLColor4U &a, U8 k) inline F32 distVec(const LLColor4U &a, const LLColor4U &b) { LLColor4U vec = a - b; - return (vec.magVec()); + return (vec.length()); } inline F32 distVec_squared(const LLColor4U &a, const LLColor4U &b) { LLColor4U vec = a - b; - return (vec.magVecSquared()); + return (vec.lengthSquared()); } void LLColor4U::setVecScaleClamp(const LLColor4& color) diff --git a/linden/indra/llmedia/CMakeLists.txt b/linden/indra/llmedia/CMakeLists.txt index 8ef8006..0c892f9 100644 --- a/linden/indra/llmedia/CMakeLists.txt +++ b/linden/indra/llmedia/CMakeLists.txt @@ -11,6 +11,7 @@ include(LLMedia) include(LLMessage) include(LLWindow) include(Mozlib) +include(QuickTime) include_directories( ${GSTREAMER_INCLUDE_DIRS} @@ -92,3 +93,9 @@ set_source_files_properties(${llmedia_HEADER_FILES} list(APPEND llmedia_SOURCE_FILES ${llmedia_HEADER_FILES}) add_library (llmedia ${llmedia_SOURCE_FILES}) +target_link_libraries( + llmedia + ${GSTREAMER_LIBRARIES} + ${GSTREAMER_PLUGINS_BASE_LIBRARIES} + ${QUICKTIME_LIBRARY} + ) diff --git a/linden/indra/llmedia/llmediaimplexample2.cpp b/linden/indra/llmedia/llmediaimplexample2.cpp index 13036f9..dc19f55 100644 --- a/linden/indra/llmedia/llmediaimplexample2.cpp +++ b/linden/indra/llmedia/llmediaimplexample2.cpp @@ -45,7 +45,7 @@ static LLMediaImplRegister sLLMediaImplExample2Reg( "LLMediaImplExample2", new L LLMediaImplExample2Maker::LLMediaImplExample2Maker() { // Register to handle the scheme - mSchema.push_back( "example2" ); + mSchema.push_back( "example2." ); } /////////////////////////////////////////////////////////////////////////////// diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index 51a5bca..b1d36f0 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp @@ -171,6 +171,9 @@ startup ( LLMediaManagerData* init_data ) static bool done_init = false; if (!done_init) { + // Init the glib type system - we need it. + g_type_init(); + // Get symbols! if (! grab_gst_syms("libgstreamer-0.10.so.0", "libgstvideo-0.10.so.0", diff --git a/linden/indra/llmessage/CMakeLists.txt b/linden/indra/llmessage/CMakeLists.txt index ba17265..fd22de9 100644 --- a/linden/indra/llmessage/CMakeLists.txt +++ b/linden/indra/llmessage/CMakeLists.txt @@ -189,3 +189,11 @@ set_source_files_properties(${llmessage_HEADER_FILES} list(APPEND llmessage_SOURCE_FILES ${llmessage_HEADER_FILES}) add_library (llmessage ${llmessage_SOURCE_FILES}) +target_link_libraries( + llmessage + ${CURL_LIBRARIES} + ${CARES_LIBRARIES} + ${OPENSSL_LIBRARIES} + ${CRYPTO_LIBRARIES} + ${XMLRPCEPI_LIBRARIES} + ) diff --git a/linden/indra/llmessage/llcachename.cpp b/linden/indra/llmessage/llcachename.cpp index 70e1ccf..8f02358 100644 --- a/linden/indra/llmessage/llcachename.cpp +++ b/linden/indra/llmessage/llcachename.cpp @@ -41,7 +41,8 @@ #include "llsdserialize.h" #include "lluuid.h" #include "message.h" - +#include "llservicebuilder.h" +#include "llframetimer.h" // Constants static const std::string CN_WAITING("(Loading...)"); // *TODO: translate static const std::string CN_NOBODY("(nobody)"); // *TODO: translate @@ -196,6 +197,8 @@ class LLCacheName::Impl public: LLMessageSystem* mMsg; LLHost mUpstreamHost; + std::string mGroupNameURL; + std::string mAgentNameURL; Cache mCache; // the map of UUIDs to names @@ -221,6 +224,8 @@ public: void processPendingReplies(); void sendRequest(const char* msg_name, const AskQueue& queue); bool isRequestPending(const LLUUID& id); + void getAgentName(const AskQueue&); + void getGroupName(const AskQueue&); // Message system callbacks. void processUUIDRequest(LLMessageSystem* msg, bool isGroup); @@ -234,6 +239,35 @@ public: void notifyObservers(const LLUUID& id, const std::string& first, const std::string& last, BOOL group); }; +class LLHTTPAgentNamesResponse : public LLHTTPClient::Responder +{ +public: + LLHTTPAgentNamesResponse(const LLSD& agent_ids) + : mAgentIDs(agent_ids) + { } + void result(const LLSD& content); +private: + LLHost mSender; + LLSD mAgentIDs; + +}; + +class LLHTTPGroupNamesResponse : public LLHTTPClient::Responder +{ +public: + LLHTTPGroupNamesResponse(const LLSD& group_ids) + : mGroupIDs(group_ids) + { }; + + void result(const LLSD& content); +private: + LLHost mSender; + LLSD mGroupIDs; + +}; + + + /// -------------------------------------------------------------------------- /// class LLCacheName @@ -319,6 +353,57 @@ void LLCacheName::cancelCallback(const LLUUID& id, LLCacheNameCallback callback, } } +void LLCacheName::sendAgentNames(const LLUUID& id, std::string& first, std::string& last) +{ + + LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache, id); + if (!entry) + { + entry = new LLCacheNameEntry; + impl.mCache[id] = entry; + + } + entry->mIsGroup = false; + entry->mCreateTime = (U32)LLFrameTimer::getTotalSeconds(); + //entry->mFirstName = first; + //entry->mLastName = last; + //LLStringUtil::truncate(entry->mFirstName, DB_FIRST_NAME_BUF_SIZE); + //LLStringUtil::truncate(entry->mLastName, DB_LAST_NAME_BUF_SIZE); + entry->mFirstName = std::string(first, DB_FIRST_NAME_BUF_SIZE); + entry->mLastName = std::string(last, DB_LAST_NAME_BUF_SIZE); + + impl.mPendingQueue.erase(id); + impl.notifyObservers(id, + entry->mFirstName, entry->mLastName, + FALSE); + +} + +void LLCacheName::sendGroupNames(const LLUUID& id, std::string& name) +{ + + LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache, id); + if (!entry) + { + entry = new LLCacheNameEntry; + impl.mCache[id] = entry; + + } + + entry->mIsGroup = true; + entry->mCreateTime = (U32)time(NULL); + + entry->mGroupName = std::string(name, DB_GROUP_NAME_BUF_SIZE); + + impl.mPendingQueue.erase(id); + + impl.notifyObservers(id, + entry->mFirstName, entry->mLastName, + FALSE); + + +} + void LLCacheName::importFile(LLFILE* fp) { S32 count = 0; @@ -524,6 +609,16 @@ BOOL LLCacheName::getFullName(const LLUUID& id, std::string& fullname) return res; } +void LLCacheName::setGroupURL(const std::string& group_url) +{ + impl.mGroupNameURL = group_url; +} + +void LLCacheName::setAgentURL(const std::string& agent_url) +{ + impl.mAgentNameURL = agent_url; +} + BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) { if(id.isNull()) @@ -558,6 +653,111 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) } } +void LLCacheName::Impl::getAgentName(const AskQueue &queue) +{ + + // get the names from backbone module + if(queue.empty()) + { + return; + } + + LLSD request; + request["action"] = "GET"; + LLSD id_block = LLSD::emptyArray(); + AskQueue::const_iterator it = queue.begin(); + AskQueue::const_iterator end = queue.end(); + for(;it!=end;++it) + { + id_block.append(*it); + } + lldebugs<(id_block) <(content) <mIsGroup = FALSE; + entry->mCreateTime = (U32)LLFrameTimer::getTotalSeconds(); + std::string first = name["first"]; + std::string last = name["last"]; + entry->mFirstName = std::string(first, DB_FIRST_NAME_BUF_SIZE); + entry->mLastName = std::string(last, DB_LAST_NAME_BUF_SIZE); + + gCacheName->sendAgentNames(id,first,last); + } +} + + +void LLCacheName::Impl::getGroupName(const AskQueue &queue) +{ + // get the group names from backbone module + if(queue.empty()) + { + return; + } + + LLSD request; + request["action"] = "GET"; + LLSD id_block = LLSD::emptyArray(); + AskQueue::const_iterator it = queue.begin(); + AskQueue::const_iterator end = queue.end(); + for(;it!=end;++it) + { + id_block.append(*it); + } + + request["groups"] = id_block; + + if(!mGroupNameURL.empty()) + { + LLHTTPClient::post( + mGroupNameURL, + request, + new LLHTTPGroupNamesResponse(id_block)); + } + lldebugs<<"Service builder call to group-name "<< mGroupNameURL<(content) << llendl; + LLUUID id; + + LLSD::map_const_iterator iter = content.beginMap(); + for ( ; iter != content.endMap(); ++iter) + { + + id.set((*iter).first); + std::string name = (*iter).second.asString(); + LLCacheNameEntry* entry = new LLCacheNameEntry; + entry->mIsGroup = TRUE; + entry->mCreateTime = (U32)time(NULL); + entry->mGroupName = std::string(name, DB_GROUP_NAME_BUF_SIZE); + lldebugs<<"Group Name"<sendGroupNames(id,name); + } +} + // TODO: Make the cache name callback take a SINGLE std::string, // not a separate first and last name. void LLCacheName::get(const LLUUID& id, BOOL is_group, LLCacheNameCallback callback, void* user_data) @@ -606,12 +806,14 @@ void LLCacheName::processPending() return; } + /* if(!impl.mUpstreamHost.isOk()) { lldebugs << "LLCacheName::processPending() - bad upstream host." << llendl; return; } + */ impl.processPendingAsks(); impl.processPendingReplies(); @@ -693,8 +895,16 @@ std::string LLCacheName::getDefaultName() void LLCacheName::Impl::processPendingAsks() { - sendRequest(_PREHASH_UUIDNameRequest, mAskNameQueue); - sendRequest(_PREHASH_UUIDGroupNameRequest, mAskGroupQueue); + if (mUpstreamHost.isOk()) //its the vuewer asking for names send request to simulator + { + sendRequest(_PREHASH_UUIDNameRequest, mAskNameQueue); + sendRequest(_PREHASH_UUIDGroupNameRequest, mAskGroupQueue); + } + else //its simulator asking for names ask the backbone + { + getAgentName(mAskNameQueue); + getGroupName(mAskGroupQueue); + } mAskNameQueue.clear(); mAskGroupQueue.clear(); } @@ -815,12 +1025,15 @@ void LLCacheName::Impl::processUUIDRequest(LLMessageSystem* msg, bool isGroup) { // You should only get this message if the cache is at the simulator // level, hence having an upstream provider. + // 03/31/2008 Simulator is talking to backbone and not dataserver + // This check was for dataserver + /* if (!mUpstreamHost.isOk()) { llwarns << "LLCacheName - got UUID name/group request, but no upstream provider!" << llendl; return; } - + */ LLHost fromHost = msg->getSender(); ReplySender sender(msg); diff --git a/linden/indra/llmessage/llcachename.h b/linden/indra/llmessage/llcachename.h index 965b4ba..af644d0 100644 --- a/linden/indra/llmessage/llcachename.h +++ b/linden/indra/llmessage/llcachename.h @@ -31,7 +31,9 @@ #ifndef LL_LLCACHENAME_H #define LL_LLCACHENAME_H - +#include "llhttpclient.h" +#include "llhost.h" +#include "lluri.h" class LLMessageSystem; class LLHost; class LLUUID; @@ -97,10 +99,15 @@ public: // This method needs to be called from time to time to send out // requests. void processPending(); - + void setAgentURL(const std::string& url); + void setGroupURL(const std::string& url); + // Expire entries created more than "secs" seconds ago. void deleteEntriesOlderThan(S32 secs); + //send the information retrived from backbone + void sendAgentNames(const LLUUID& id, std::string& first, std::string& last); + void sendGroupNames(const LLUUID& id, std::string& name); // Debugging void dump(); // Dumps the contents of the cache void dumpStats(); // Dumps the sizes of the cache and associated queues. @@ -111,9 +118,8 @@ private: class Impl; Impl& impl; -}; - +}; extern LLCacheName* gCacheName; diff --git a/linden/indra/llmessage/llcircuit.cpp b/linden/indra/llmessage/llcircuit.cpp index 12a1520..7b2f241 100644 --- a/linden/indra/llmessage/llcircuit.cpp +++ b/linden/indra/llmessage/llcircuit.cpp @@ -60,6 +60,7 @@ #include "llrand.h" #include "llstl.h" #include "lltransfermanager.h" +#include "llmodularmath.h" const F32 PING_INTERVAL = 5.f; // seconds const S32 PING_START_BLOCK = 3; // How many pings behind we have to be to consider ourself blocked. @@ -676,6 +677,8 @@ void LLCircuitData::checkPacketInID(TPACKETID id, BOOL receive_resent) mPacketsIn++; setPacketInID((id + 1) % LL_MAX_OUT_PACKET_ID); + mLastPacketGap = 0; + mOutOfOrderRate.count(0); return; } @@ -683,6 +686,7 @@ void LLCircuitData::checkPacketInID(TPACKETID id, BOOL receive_resent) // now, check to see if we've got a gap + U32 gap = 0; if ((mPacketsInID == id)) { // nope! bump and wrap the counter, then return @@ -704,6 +708,11 @@ void LLCircuitData::checkPacketInID(TPACKETID id, BOOL receive_resent) // otherwise, walk from mCurrentCircuit->mPacketsInID to id with wrapping, adding the values to the map // and setting mPacketsInID to id + 1 % LL_MAX_OUT_PACKET_ID + // babbage: all operands in expression are unsigned, so modular + // arithmetic will always find correct gap, regardless of wrap arounds. + const U8 width = 24; + gap = LLModularMath::subtract(mPacketsInID, id); + if (mPotentialLostPackets.find(id) != mPotentialLostPackets.end()) { if(gMessageSystem->mVerboseLog) @@ -765,6 +774,8 @@ void LLCircuitData::checkPacketInID(TPACKETID id, BOOL receive_resent) } } + mOutOfOrderRate.count(gap); + mLastPacketGap = gap; } diff --git a/linden/indra/llmessage/llcircuit.h b/linden/indra/llmessage/llcircuit.h index 552b50f..3b9df02 100644 --- a/linden/indra/llmessage/llcircuit.h +++ b/linden/indra/llmessage/llcircuit.h @@ -45,6 +45,7 @@ #include "llpacketack.h" #include "lluuid.h" #include "llthrottle.h" +#include "llstat.h" // // Constants @@ -133,6 +134,10 @@ public: S32 getUnackedPacketCount() const { return mUnackedPacketCount; } S32 getUnackedPacketBytes() const { return mUnackedPacketBytes; } F64 getNextPingSendTime() const { return mNextPingSendTime; } + F32 getOutOfOrderRate(LLStatAccum::TimeScale scale = LLStatAccum::SCALE_MINUTE) + { return mOutOfOrderRate.meanValue(scale); } + U32 getLastPacketGap() const { return mLastPacketGap; } + LLHost getHost() const { return mHost; } LLThrottleGroup &getThrottleGroup() { return mThrottles; } @@ -276,6 +281,8 @@ protected: LLTimer mExistenceTimer; // initialized when circuit created, used to track bandwidth numbers S32 mCurrentResendCount; // Number of resent packets since last spam + LLStatRate mOutOfOrderRate; // Rate of out of order packets coming in. + U32 mLastPacketGap; // Gap in sequence number of last packet. }; diff --git a/linden/indra/llmessage/llcurl.cpp b/linden/indra/llmessage/llcurl.cpp index 834ec4b..167e237 100644 --- a/linden/indra/llmessage/llcurl.cpp +++ b/linden/indra/llmessage/llcurl.cpp @@ -265,6 +265,10 @@ LLCurl::Easy* LLCurl::Easy::getEasy() delete easy; return NULL; } + + // set no DMS caching as default for all easy handles. This prevents them adopting a + // multi handles cache if they are added to one. + curl_easy_setopt(easy->mCurlEasyHandle, CURLOPT_DNS_CACHE_TIMEOUT, 0); ++gCurlEasyCount; return easy; } @@ -747,7 +751,7 @@ bool LLCurlRequest::post(const std::string& url, const LLSD& data, LLCurl::Respo easy->setopt(CURLOPT_POSTFIELDS, (void*)NULL); easy->setopt(CURLOPT_POSTFIELDSIZE, bytes); - easy->slist_append("Content-Type: application/xml"); + easy->slist_append("Content-Type: application/llsd+xml"); easy->setHeaders(); lldebugs << "POSTING: " << bytes << " bytes." << llendl; diff --git a/linden/indra/llmessage/llhttpassetstorage.cpp b/linden/indra/llmessage/llhttpassetstorage.cpp index fdd521f..6d5a716 100644 --- a/linden/indra/llmessage/llhttpassetstorage.cpp +++ b/linden/indra/llmessage/llhttpassetstorage.cpp @@ -256,6 +256,10 @@ void LLHTTPAssetRequest::setupCurlHandle() // disable use of proxy, which can't handle chunked transfers } mHTTPHeaders = curl_slist_append(mHTTPHeaders, "Pragma:"); + + // bug in curl causes DNS to be cached for too long a time, 0 sets it to never cache DNS results internally (to curl) + curl_easy_setopt(mCurlHandle, CURLOPT_DNS_CACHE_TIMEOUT, 0); + // resist the temptation to explicitly add the Transfer-Encoding: chunked // header here - invokes a libCURL bug curl_easy_setopt(mCurlHandle, CURLOPT_HTTPHEADER, mHTTPHeaders); diff --git a/linden/indra/llmessage/llhttpclient.cpp b/linden/indra/llmessage/llhttpclient.cpp index fc2612f..fb43861 100644 --- a/linden/indra/llmessage/llhttpclient.cpp +++ b/linden/indra/llmessage/llhttpclient.cpp @@ -106,7 +106,7 @@ namespace LLSDInjector(const LLSD& sd) : mSD(sd) {} virtual ~LLSDInjector() {} - const char* contentType() { return "application/xml"; } + const char* contentType() { return "application/llsd+xml"; } virtual EStatus process_impl(const LLChannelDescriptors& channels, buffer_ptr_t& buffer, bool& eos, LLSD& context, LLPumpIO* pump) @@ -238,7 +238,8 @@ static void request( //the Pragma header it so gratuitously inserts //Before inserting the header, force libcurl //to not use the proxy (read: llurlrequest.cpp) - if ((iter->first == "Pragma") && (iter->second.asString() == "")) + static const std::string PRAGMA("Pragma"); + if ((iter->first == PRAGMA) && (iter->second.asString().empty())) { req->useProxy(false); } @@ -247,6 +248,19 @@ static void request( req->addHeader(header.str().c_str()); } } + + // Check to see if we have already set Accept or not. If no one + // set it, set it to application/llsd+xml since that's what we + // almost always want. + if( method != LLURLRequest::HTTP_PUT && method != LLURLRequest::HTTP_POST ) + { + static const std::string ACCEPT("Accept"); + if(!headers.has(ACCEPT)) + { + req->addHeader("Accept: application/llsd+xml"); + } + } + req->setCallback(new LLHTTPClientURLAdaptor(responder)); if (method == LLURLRequest::HTTP_POST && gMessageSystem) @@ -254,12 +268,22 @@ static void request( req->addHeader(llformat("X-SecondLife-UDP-Listen-Port: %d", gMessageSystem->mPort).c_str()); } - + if (method == LLURLRequest::HTTP_PUT || method == LLURLRequest::HTTP_POST) { - req->addHeader(llformat("Content-Type: %s", - body_injector->contentType()).c_str()); - + static const std::string CONTENT_TYPE("Content-Type"); + if(!headers.has(CONTENT_TYPE)) + { + // If the Content-Type header was passed in, it has + // already been added as a header through req->addHeader + // in the loop above. We defer to the caller's wisdom, but + // if they did not specify a Content-Type, then ask the + // injector. + req->addHeader( + llformat( + "Content-Type: %s", + body_injector->contentType()).c_str()); + } chain.push_back(LLIOPipe::ptr_t(body_injector)); } diff --git a/linden/indra/llmessage/lliohttpserver.cpp b/linden/indra/llmessage/lliohttpserver.cpp index d4155f6..64222ff 100644 --- a/linden/indra/llmessage/lliohttpserver.cpp +++ b/linden/indra/llmessage/lliohttpserver.cpp @@ -47,6 +47,7 @@ #include "llpumpio.h" #include "llsd.h" #include "llsdserialize_xml.h" +#include "llstat.h" #include "llstl.h" #include "lltimer.h" @@ -171,22 +172,26 @@ LLIOPipe::EStatus LLHTTPPipe::process_impl( std::string verb = context[CONTEXT_REQUEST][CONTEXT_VERB]; if(verb == HTTP_VERB_GET) { + LLPerfBlock getblock("http_get"); mNode.get(LLHTTPNode::ResponsePtr(mResponse), context); } else if(verb == HTTP_VERB_PUT) { + LLPerfBlock putblock("http_put"); LLSD input; LLSDSerialize::fromXML(input, istr); mNode.put(LLHTTPNode::ResponsePtr(mResponse), context, input); } else if(verb == HTTP_VERB_POST) { + LLPerfBlock postblock("http_post"); LLSD input; LLSDSerialize::fromXML(input, istr); mNode.post(LLHTTPNode::ResponsePtr(mResponse), context, input); } else if(verb == HTTP_VERB_DELETE) { + LLPerfBlock delblock("http_delete"); mNode.del(LLHTTPNode::ResponsePtr(mResponse), context); } else if(verb == HTTP_VERB_OPTIONS) @@ -240,7 +245,7 @@ LLIOPipe::EStatus LLHTTPPipe::process_impl( case STATE_GOOD_RESULT: { LLSD headers = mHeaders; - headers["Content-Type"] = "application/xml"; + headers["Content-Type"] = "application/llsd+xml"; context[CONTEXT_RESPONSE][CONTEXT_HEADERS] = headers; LLBufferStream ostr(channels, buffer.get()); LLSDSerialize::toXML(mGoodResult, ostr); diff --git a/linden/indra/llmessage/lliosocket.cpp b/linden/indra/llmessage/lliosocket.cpp index dec83b0..28fee37 100644 --- a/linden/indra/llmessage/lliosocket.cpp +++ b/linden/indra/llmessage/lliosocket.cpp @@ -355,8 +355,11 @@ LLIOPipe::EStatus LLIOSocketReader::process_impl( } else if(APR_STATUS_IS_EAGAIN(status)) { +/*Commented out by Aura 9-9-8 for DEV-19961. // everything is fine, but we can terminate this process pump. + rv = STATUS_BREAK; +*/ } else { diff --git a/linden/indra/llmessage/llmail.cpp b/linden/indra/llmessage/llmail.cpp index 8ae7206..181f378 100644 --- a/linden/indra/llmessage/llmail.cpp +++ b/linden/indra/llmessage/llmail.cpp @@ -51,6 +51,7 @@ #include "llblowfishcipher.h" #include "llerror.h" #include "llhost.h" +#include "llsd.h" #include "llstring.h" #include "lluuid.h" #include "net.h" @@ -111,16 +112,22 @@ void disconnect_smtp() // Returns TRUE on success. // message should NOT be SMTP escaped. // static -BOOL LLMail::send(const char* from_name, const char* from_address, - const char* to_name, const char* to_address, - const char* subject, const char* message) +BOOL LLMail::send( + const char* from_name, + const char* from_address, + const char* to_name, + const char* to_address, + const char* subject, + const char* message, + const LLSD& headers) { std::string header = buildSMTPTransaction( from_name, from_address, to_name, to_address, - subject); + subject, + headers); if(header.empty()) { return FALSE; @@ -192,7 +199,8 @@ std::string LLMail::buildSMTPTransaction( const char* from_address, const char* to_name, const char* to_address, - const char* subject) + const char* subject, + const LLSD& headers) { if(!from_address || !to_address) { @@ -236,8 +244,20 @@ std::string LLMail::buildSMTPTransaction( << "DATA\r\n" << "From: " << from_fmt.str() << "\r\n" << "To: " << to_fmt.str() << "\r\n" - << "Subject: " << subject << "\r\n" - << "\r\n"; + << "Subject: " << subject << "\r\n"; + + if(headers.isMap()) + { + LLSD::map_const_iterator iter = headers.beginMap(); + LLSD::map_const_iterator end = headers.endMap(); + for(; iter != end; ++iter) + { + header << (*iter).first << ": " << ((*iter).second).asString() + << "\r\n"; + } + } + + header << "\r\n"; return header.str(); } @@ -324,7 +344,7 @@ bool LLMail::send( << "when sending messages larger than " << LL_MAX_KNOWN_GOOD_MAIL_SIZE << " bytes. The next log about success is potentially a lie." << llendl; } - llinfos << "send_mail success: " + lldebugs << "send_mail success: " << "to=<" << to_address << ">, from=<" << from_address << ">" << ", bytes=" << original_size diff --git a/linden/indra/llmessage/llmail.h b/linden/indra/llmessage/llmail.h index 86b7793..018e180 100644 --- a/linden/indra/llmessage/llmail.h +++ b/linden/indra/llmessage/llmail.h @@ -34,7 +34,7 @@ typedef struct apr_pool_t apr_pool_t; -class LLUUID; +#include "llsd.h" class LLMail { @@ -45,34 +45,51 @@ public: // Allow all email transmission to be disabled/enabled. static void enable(bool mail_enabled); - // returns TRUE if the call succeeds, FALSE otherwise. - // - // Results in: - // From: "from_name" - // To: "to_name" - // Subject: subject - // message - static BOOL send(const char* from_name, const char* from_address, - const char* to_name, const char* to_address, - const char* subject, const char* message); + /** + * @brief send an email + * @param from_name The name of the email sender + * @param from_address The email address for the sender + * @param to_name The name of the email recipient + * @param to_address The email recipient address + * @param subject The subject of the email + * @param headers optional X-Foo headers in an llsd map. + * @return Returns TRUE if the call succeeds, FALSE otherwise. + * + * Results in: + * From: "from_name" + * To: "to_name" + * Subject: subject + * + * message + */ + static BOOL send( + const char* from_name, + const char* from_address, + const char* to_name, + const char* to_address, + const char* subject, + const char* message, + const LLSD& headers = LLSD()); /** - * @brief build the complete smtp transaction & header for use in an - * mail. - * - * @param from_name The name of the email sender - * @param from_address The email address for the sender - * @param to_name The name of the email recipient - * @param to_name The email recipient address - * @param subject The subject of the email - * @return Returns the complete SMTP transaction mail header. - */ + * @brief build the complete smtp transaction & header for use in an + * mail. + * + * @param from_name The name of the email sender + * @param from_address The email address for the sender + * @param to_name The name of the email recipient + * @param to_address The email recipient address + * @param subject The subject of the email + * @param headers optional X-Foo headers in an llsd map. + * @return Returns the complete SMTP transaction mail header. + */ static std::string buildSMTPTransaction( const char* from_name, const char* from_address, const char* to_name, const char* to_address, - const char* subject); + const char* subject, + const LLSD& headers = LLSD()); /** * @brief send an email with header and body. diff --git a/linden/indra/llmessage/llmessagetemplate.cpp b/linden/indra/llmessage/llmessagetemplate.cpp index 4a560ca..ff44d45 100644 --- a/linden/indra/llmessage/llmessagetemplate.cpp +++ b/linden/indra/llmessage/llmessagetemplate.cpp @@ -50,7 +50,7 @@ void LLMsgVarData::addData(const void *data, S32 size, EMsgVariableType type, S3 } if(size) { - delete mData; // Delete it if it already exists + delete[] mData; // Delete it if it already exists mData = new U8[size]; htonmemcpy(mData, data, mType, size); } @@ -175,3 +175,23 @@ std::ostream& operator<<(std::ostream& s, LLMessageTemplate &msg) return s; } + +void LLMessageTemplate::banUdp() +{ + static const char* deprecation[] = { + "NotDeprecated", + "Deprecated", + "UDPDeprecated", + "UDPBlackListed" + }; + if (mDeprecation != MD_DEPRECATED) + { + llinfos << "Setting " << mName << " to UDPBlackListed was " << deprecation[mDeprecation] << llendl; + mDeprecation = MD_UDPBLACKLISTED; + } + else + { + llinfos << mName << " is already more deprecated than UDPBlackListed" << llendl; + } +} + diff --git a/linden/indra/llmessage/llmessagetemplate.h b/linden/indra/llmessage/llmessagetemplate.h index 716c618..445d1a8 100644 --- a/linden/indra/llmessage/llmessagetemplate.h +++ b/linden/indra/llmessage/llmessagetemplate.h @@ -34,6 +34,7 @@ #include "lldarray.h" #include "message.h" // TODO: babbage: Remove... +#include "llstat.h" #include "llstl.h" class LLMsgVarData @@ -370,20 +371,23 @@ public: { if (mHandlerFunc) { + LLPerfBlock msg_cb_time("msg_cb", mName); mHandlerFunc(msgsystem, mUserData); return TRUE; } return FALSE; } - bool isBanned(bool trustedSource) const + bool isUdpBanned() const { - return trustedSource ? mBanFromTrusted : mBanFromUntrusted; + return mDeprecation == MD_UDPBLACKLISTED; } - bool isUdpBanned() const + void banUdp(); + + bool isBanned(bool trustedSource) const { - return mDeprecation == MD_UDPBLACKLISTED; + return trustedSource ? mBanFromTrusted : mBanFromUntrusted; } friend std::ostream& operator<<(std::ostream& s, LLMessageTemplate &msg); diff --git a/linden/indra/llmessage/llnamevalue.cpp b/linden/indra/llmessage/llnamevalue.cpp index c44f6ce..f661261 100644 --- a/linden/indra/llmessage/llnamevalue.cpp +++ b/linden/indra/llmessage/llnamevalue.cpp @@ -896,7 +896,7 @@ void LLNameValue::setVec3(const LLVector3 &a) } -std::string LLNameValue::printNameValue() +std::string LLNameValue::printNameValue() const { std::string buffer; buffer = llformat("%s %s %s %s ", mName, mStringType, mStringClass, mStringSendto); @@ -905,7 +905,7 @@ std::string LLNameValue::printNameValue() return buffer; } -std::string LLNameValue::printData() +std::string LLNameValue::printData() const { std::string buffer; switch(mType) diff --git a/linden/indra/llmessage/llnamevalue.h b/linden/indra/llmessage/llnamevalue.h index 52beb07..f6c5040 100644 --- a/linden/indra/llmessage/llnamevalue.h +++ b/linden/indra/llmessage/llnamevalue.h @@ -148,8 +148,8 @@ public: BOOL sendToViewer() const; void callCallback(); - std::string printNameValue(); - std::string printData(); + std::string printNameValue() const; + std::string printData() const; ENameValueType getTypeEnum() const { return mType; } ENameValueClass getClassEnum() const { return mClass; } diff --git a/linden/indra/llmessage/llpartdata.h b/linden/indra/llmessage/llpartdata.h index 82757ec..58a1fae 100644 --- a/linden/indra/llmessage/llpartdata.h +++ b/linden/indra/llmessage/llpartdata.h @@ -114,6 +114,7 @@ public: //LL_PART_TRAIL_MASK = 0x400, // Particles have historical "trails" // Viewer side use only! + LL_PART_HUD = 0x40000000, LL_PART_DEAD_MASK = 0x80000000, }; diff --git a/linden/indra/llmessage/llpumpio.cpp b/linden/indra/llmessage/llpumpio.cpp index c92612f..467502b 100644 --- a/linden/indra/llmessage/llpumpio.cpp +++ b/linden/indra/llmessage/llpumpio.cpp @@ -41,6 +41,7 @@ #include "llapr.h" #include "llmemtype.h" #include "llstl.h" +#include "llstat.h" // These should not be enabled in production, but they can be // intensely useful during development for finding certain kinds of @@ -176,7 +177,8 @@ LLPumpIO::LLPumpIO(apr_pool_t* pool) : mCurrentPool(NULL), mCurrentPoolReallocCount(0), mChainsMutex(NULL), - mCallbackMutex(NULL) + mCallbackMutex(NULL), + mCurrentChain(mRunningChains.end()) { LLMemType m1(LLMemType::MTYPE_IO_PUMP); initialize(pool); @@ -269,6 +271,16 @@ bool LLPumpIO::setTimeoutSeconds(F32 timeout) return true; } +void LLPumpIO::adjustTimeoutSeconds(F32 delta) +{ + // If no chain is running, bail + if(mRunningChains.end() == mCurrentChain) + { + return; + } + (*mCurrentChain).adjustTimeoutSeconds(delta); +} + static std::string events_2_string(apr_int16_t events) { std::ostringstream ostr; @@ -514,7 +526,10 @@ void LLPumpIO::pump(const S32& poll_timeout) //llinfos << "polling" << llendl; S32 count = 0; S32 client_id = 0; - apr_pollset_poll(mPollset, poll_timeout, &count, &poll_fd); + { + LLPerfBlock polltime("pump_poll"); + apr_pollset_poll(mPollset, poll_timeout, &count, &poll_fd); + } PUMP_DEBUG; for(S32 ii = 0; ii < count; ++ii) { @@ -1161,3 +1176,14 @@ void LLPumpIO::LLChainInfo::setTimeoutSeconds(F32 timeout) mTimer.stop(); } } + +void LLPumpIO::LLChainInfo::adjustTimeoutSeconds(F32 delta) +{ + LLMemType m1(LLMemType::MTYPE_IO_PUMP); + if(mTimer.getStarted()) + { + F64 expiry = mTimer.expiresAt(); + expiry += delta; + mTimer.setExpiryAt(expiry); + } +} diff --git a/linden/indra/llmessage/llpumpio.h b/linden/indra/llmessage/llpumpio.h index d2392a3..daff723 100644 --- a/linden/indra/llmessage/llpumpio.h +++ b/linden/indra/llmessage/llpumpio.h @@ -166,6 +166,14 @@ public: bool setTimeoutSeconds(F32 timeout); /** + * @brief Adjust the timeout of the running chain. + * + * This method has no effect if there is no timeout on the chain. + * @param delta The number of seconds to add to/remove from the timeout. + */ + void adjustTimeoutSeconds(F32 delta); + + /** * @brief Set up file descriptors for for the running chain. * @see rebuildPollset() * @@ -349,6 +357,7 @@ protected: // methods LLChainInfo(); void setTimeoutSeconds(F32 timeout); + void adjustTimeoutSeconds(F32 delta); // basic member data bool mInit; diff --git a/linden/indra/llmessage/llqueryflags.h b/linden/indra/llmessage/llqueryflags.h index 1d8d500..6740d46 100644 --- a/linden/indra/llmessage/llqueryflags.h +++ b/linden/indra/llmessage/llqueryflags.h @@ -38,7 +38,7 @@ const U32 DFQ_PEOPLE = 0x1 << 0; const U32 DFQ_ONLINE = 0x1 << 1; //const U32 DFQ_PLACES = 0x1 << 2; -const U32 DFQ_EVENTS = 0x1 << 3; +const U32 DFQ_EVENTS = 0x1 << 3; // This is not set by the 1.21 viewer, but I don't know about older versions. JC const U32 DFQ_GROUPS = 0x1 << 4; const U32 DFQ_DATE_EVENTS = 0x1 << 5; diff --git a/linden/indra/llmessage/llurlrequest.cpp b/linden/indra/llmessage/llurlrequest.cpp index ee62798..e561597 100644 --- a/linden/indra/llmessage/llurlrequest.cpp +++ b/linden/indra/llmessage/llurlrequest.cpp @@ -68,6 +68,7 @@ public: LLChannelDescriptors mChannels; U8* mLastRead; U32 mBodyLimit; + S32 mByteAccumulator; bool mIsBodyLimitSet; }; @@ -76,8 +77,8 @@ LLURLRequestDetail::LLURLRequestDetail() : mResponseBuffer(NULL), mLastRead(NULL), mBodyLimit(0), + mByteAccumulator(0), mIsBodyLimitSet(false) - { LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); mCurlRequest = new LLCurlEasyRequest(); @@ -264,8 +265,25 @@ LLIOPipe::EStatus LLURLRequest::process_impl( { CURLcode result; bool newmsg = mDetail->mCurlRequest->getResult(&result); - if (!newmsg) + if(!newmsg) { + // we're still waiting or prcessing, check how many + // bytes we have accumulated. + const S32 MIN_ACCUMULATION = 100000; + if(pump && (mDetail->mByteAccumulator > MIN_ACCUMULATION)) + { + // This is a pretty sloppy calculation, but this + // tries to make the gross assumption that if data + // is coming in at 56kb/s, then this transfer will + // probably succeed. So, if we're accumlated + // 100,000 bytes (MIN_ACCUMULATION) then let's + // give this client another 2s to complete. + const F32 TIMEOUT_ADJUSTMENT = 2.0f; + mDetail->mByteAccumulator = 0; + pump->adjustTimeoutSeconds(TIMEOUT_ADJUSTMENT); + } + + // keep processing break; } @@ -434,6 +452,7 @@ size_t LLURLRequest::downCallback( req->mDetail->mChannels.out(), (U8*)data, bytes); + req->mDetail->mByteAccumulator += bytes; return bytes; } diff --git a/linden/indra/llmessage/message.cpp b/linden/indra/llmessage/message.cpp index b20731a..9ca7211 100644 --- a/linden/indra/llmessage/message.cpp +++ b/linden/indra/llmessage/message.cpp @@ -763,7 +763,7 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count ) clearReceiveState(); valid_packet = FALSE; } - + if( valid_packet ) { logValidMsg(cdp, host, recv_reliable, recv_resent, (BOOL)(acks>0) ); @@ -3956,22 +3956,27 @@ void LLMessageSystem::getString(const char *block, const char *var, blocknum); } -S32 LLMessageSystem::getNumberOfBlocksFast(const char *blockname) +BOOL LLMessageSystem::has(const char *blockname) const +{ + return getNumberOfBlocks(blockname) > 0; +} + +S32 LLMessageSystem::getNumberOfBlocksFast(const char *blockname) const { return mMessageReader->getNumberOfBlocks(blockname); } -S32 LLMessageSystem::getNumberOfBlocks(const char *blockname) +S32 LLMessageSystem::getNumberOfBlocks(const char *blockname) const { return getNumberOfBlocksFast(LLMessageStringTable::getInstance()->getString(blockname)); } -S32 LLMessageSystem::getSizeFast(const char *blockname, const char *varname) +S32 LLMessageSystem::getSizeFast(const char *blockname, const char *varname) const { return mMessageReader->getSize(blockname, varname); } -S32 LLMessageSystem::getSize(const char *blockname, const char *varname) +S32 LLMessageSystem::getSize(const char *blockname, const char *varname) const { return getSizeFast(LLMessageStringTable::getInstance()->getString(blockname), LLMessageStringTable::getInstance()->getString(varname)); @@ -3979,13 +3984,13 @@ S32 LLMessageSystem::getSize(const char *blockname, const char *varname) // size in bytes of variable length data S32 LLMessageSystem::getSizeFast(const char *blockname, S32 blocknum, - const char *varname) + const char *varname) const { return mMessageReader->getSize(blockname, blocknum, varname); } S32 LLMessageSystem::getSize(const char *blockname, S32 blocknum, - const char *varname) + const char *varname) const { return getSizeFast(LLMessageStringTable::getInstance()->getString(blockname), blocknum, LLMessageStringTable::getInstance()->getString(varname)); @@ -4021,3 +4026,18 @@ bool LLMessageSystem::checkAllMessages(S64 frame_count, LLPumpIO* http_pump) http_pump->callback(); return (mPacketsIn - packetsIn) > 0; } + +void LLMessageSystem::banUdpMessage(const std::string& name) +{ + message_template_name_map_t::iterator itt = mMessageTemplates.find( + LLMessageStringTable::getInstance()->getString(name.c_str()) + ); + if(itt != mMessageTemplates.end()) + { + itt->second->banUdp(); + } + else + { + llwarns << "Attempted to ban an unknown message: " << name << "." << llendl; + } +} diff --git a/linden/indra/llmessage/message.h b/linden/indra/llmessage/message.h index 8807521..b72aa9a 100644 --- a/linden/indra/llmessage/message.h +++ b/linden/indra/llmessage/message.h @@ -562,6 +562,9 @@ public: /** Return false true if name is unknown or trusted */ bool isUntrustedMessage(const std::string& name) const; + // Change this message to be UDP black listed. + void banUdpMessage(const std::string& name); + private: // A list of the circuits that need to be sent DenyTrustedCircuit messages. typedef std::set host_set_t; @@ -591,13 +594,14 @@ public: LLHost findHost(const U32 circuit_code); void sanityCheck(); - S32 getNumberOfBlocksFast(const char *blockname); - S32 getNumberOfBlocks(const char *blockname); - S32 getSizeFast(const char *blockname, const char *varname); - S32 getSize(const char *blockname, const char *varname); + BOOL has(const char *blockname) const; + S32 getNumberOfBlocksFast(const char *blockname) const; + S32 getNumberOfBlocks(const char *blockname) const; + S32 getSizeFast(const char *blockname, const char *varname) const; + S32 getSize(const char *blockname, const char *varname) const; S32 getSizeFast(const char *blockname, S32 blocknum, - const char *varname); // size in bytes of data - S32 getSize(const char *blockname, S32 blocknum, const char *varname); + const char *varname) const; // size in bytes of data + S32 getSize(const char *blockname, S32 blocknum, const char *varname) const; void resetReceiveCounts(); // resets receive counts for all message types to 0 void dumpReceiveCounts(); // dumps receive count for each message type to llinfos diff --git a/linden/indra/llprimitive/lltree_common.h b/linden/indra/llprimitive/lltree_common.h index b63e00a..4708c5f 100644 --- a/linden/indra/llprimitive/lltree_common.h +++ b/linden/indra/llprimitive/lltree_common.h @@ -36,6 +36,19 @@ struct LLTree_gene_0 { + LLTree_gene_0() + : scale(0), + branches(0), + twist(0), + droop(0), + species(0), + trunk_depth(0), + branch_thickness(0), + max_depth(0), + scale_step(0) + { + } + // // The genome for a tree, species 0 // diff --git a/linden/indra/llrender/llcubemap.cpp b/linden/indra/llrender/llcubemap.cpp index 563d616..878ae17 100644 --- a/linden/indra/llrender/llcubemap.cpp +++ b/linden/indra/llrender/llcubemap.cpp @@ -92,11 +92,11 @@ void LLCubeMap::initGL() for (int i = 0; i < 6; i++) { mImages[i] = new LLImageGL(64, 64, 4, (use_cube_mipmaps? TRUE : FALSE)); - mImages[i]->setTarget(mTargets[i], GL_TEXTURE_CUBE_MAP_ARB); + mImages[i]->setTarget(mTargets[i], LLTexUnit::TT_CUBE_MAP); mRawImages[i] = new LLImageRaw(64, 64, 4); mImages[i]->createGLTexture(0, mRawImages[i], texname); - glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, texname); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_CUBE_MAP, texname); mImages[i]->setClampCubemap (TRUE, TRUE, TRUE); stop_glerror(); } @@ -180,26 +180,7 @@ GLuint LLCubeMap::getGLName() void LLCubeMap::bind() { - if (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) - { - // We assume that if they have cube mapping, they have multitexturing. - if (mTextureStage > 0) - { - gGL.getTexUnit(mTextureStage)->activate(); - } - glEnable(GL_TEXTURE_CUBE_MAP_ARB); - glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mImages[0]->getTexName()); - - mImages[0]->setMipFilterNearest (FALSE, FALSE); - if (mTextureStage > 0) - { - gGL.getTexUnit(0)->activate(); - } - } - else - { - llwarns << "Using cube map without extension!" << llendl - } + gGL.getTexUnit(mTextureStage)->bind(this); } void LLCubeMap::enable(S32 stage) @@ -213,17 +194,7 @@ void LLCubeMap::enableTexture(S32 stage) mTextureStage = stage; if (gGLManager.mHasCubeMap && stage >= 0 && LLCubeMap::sUseCubeMaps) { - if (stage > 0) - { - gGL.getTexUnit(stage)->activate(); - } - - glEnable(GL_TEXTURE_CUBE_MAP_ARB); - - if (stage > 0) - { - gGL.getTexUnit(0)->activate(); - } + gGL.getTexUnit(stage)->enable(LLTexUnit::TT_CUBE_MAP); } } @@ -262,15 +233,10 @@ void LLCubeMap::disableTexture(void) { if (gGLManager.mHasCubeMap && mTextureStage >= 0 && LLCubeMap::sUseCubeMaps) { - if (mTextureStage > 0) + gGL.getTexUnit(mTextureStage)->disable(); + if (mTextureStage == 0) { - gGL.getTexUnit(mTextureStage)->activate(); - } - glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0); - glDisable(GL_TEXTURE_CUBE_MAP_ARB); - if (mTextureStage > 0) - { - gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); } } } @@ -297,6 +263,8 @@ void LLCubeMap::setMatrix(S32 stage) { mMatrixStage = stage; + if (mMatrixStage < 0) return; + if (stage > 0) { gGL.getTexUnit(stage)->activate(); @@ -324,6 +292,8 @@ void LLCubeMap::setMatrix(S32 stage) void LLCubeMap::restoreMatrix() { + if (mMatrixStage < 0) return; + if (mMatrixStage > 0) { gGL.getTexUnit(mMatrixStage)->activate(); @@ -340,7 +310,7 @@ void LLCubeMap::restoreMatrix() void LLCubeMap::setReflection (void) { - glBindTexture (GL_TEXTURE_CUBE_MAP_ARB, getGLName()); + gGL.getTexUnit(mTextureStage)->bindManual(LLTexUnit::TT_CUBE_MAP, getGLName()); mImages[0]->setMipFilterNearest (FALSE, FALSE); mImages[0]->setClampCubemap (TRUE, TRUE); } diff --git a/linden/indra/llrender/llcubemap.h b/linden/indra/llrender/llcubemap.h index 45bfa16..15ca7db 100644 --- a/linden/indra/llrender/llcubemap.h +++ b/linden/indra/llrender/llcubemap.h @@ -53,6 +53,7 @@ public: void enableTexture(S32 stage); void enableTextureCoords(S32 stage); + S32 getStage(void) { return mTextureStage; } void disable(void); void disableTexture(void); @@ -77,6 +78,7 @@ public: static bool sUseCubeMaps; protected: + friend class LLTexUnit; ~LLCubeMap(); LLGLenum mTargets[6]; LLPointer mImages[6]; diff --git a/linden/indra/llrender/llfont.cpp b/linden/indra/llrender/llfont.cpp index 4b5ee64..bcd0aca 100644 --- a/linden/indra/llrender/llfont.cpp +++ b/linden/indra/llrender/llfont.cpp @@ -92,18 +92,18 @@ LLFontManager::~LLFontManager() LLFontGlyphInfo::LLFontGlyphInfo(U32 index) -{ - mGlyphIndex = index; - mXBitmapOffset = 0; // Offset to the origin in the bitmap - mYBitmapOffset = 0; // Offset to the origin in the bitmap - mXBearing = 0; // Distance from baseline to left in pixels - mYBearing = 0; // Distance from baseline to top in pixels - mWidth = 0; // In pixels - mHeight = 0; // In pixels - mXAdvance = 0.f; // In pixels - mYAdvance = 0.f; // In pixels - mIsRendered = FALSE; -} +: mGlyphIndex(index), + mXBitmapOffset(0), // Offset to the origin in the bitmap + mYBitmapOffset(0), // Offset to the origin in the bitmap + mXBearing(0), // Distance from baseline to left in pixels + mYBearing(0), // Distance from baseline to top in pixels + mWidth(0), // In pixels + mHeight(0), // In pixels + mXAdvance(0.f), // In pixels + mYAdvance(0.f), // In pixels + mIsRendered(FALSE), + mMetricsValid(FALSE) +{} LLFontList::LLFontList() { @@ -303,6 +303,9 @@ void LLFont::resetBitmap() iter != mCharGlyphInfoMap.end(); ++iter) { iter->second->mIsRendered = FALSE; + //FIXME: this is only strictly necessary when resetting the entire font, + //not just flushing the bitmap + iter->second->mMetricsValid = FALSE; } mRawImagep->clear(255, 0); mCurrentOffsetX = 1; @@ -439,6 +442,7 @@ BOOL LLFont::addGlyphFromFont(LLFont *fontp, const llwchar wch, const U32 glyph_ gi->mXAdvance = fontp->mFTFace->glyph->advance.x / 64.f; gi->mYAdvance = fontp->mFTFace->glyph->advance.y / 64.f; gi->mIsRendered = TRUE; + gi->mMetricsValid = TRUE; insertGlyphInfo(wch, gi); @@ -528,7 +532,7 @@ F32 LLFont::getXAdvance(const llwchar wch) const // Return existing info only if it is current LLFontGlyphInfo* gi = getGlyphInfo(wch); - if (gi && gi->mIsRendered) + if (gi && gi->mMetricsValid) { return gi->mXAdvance; } @@ -573,6 +577,7 @@ F32 LLFont::getXAdvance(const llwchar wch) const // Convert these from 26.6 units to float pixels. gi->mXAdvance = fontp->mFTFace->glyph->advance.x / 64.f; gi->mYAdvance = fontp->mFTFace->glyph->advance.y / 64.f; + gi->mMetricsValid = TRUE; return gi->mXAdvance; } else diff --git a/linden/indra/llrender/llfont.h b/linden/indra/llrender/llfont.h index d937dfd..2054832 100644 --- a/linden/indra/llrender/llfont.h +++ b/linden/indra/llrender/llfont.h @@ -72,6 +72,7 @@ public: S32 mHeight; // In pixels F32 mXAdvance; // In pixels F32 mYAdvance; // In pixels + BOOL mMetricsValid; // We have up-to-date metrics for this glyph // Information for actually rendering BOOL mIsRendered; // We actually have rendered this glyph diff --git a/linden/indra/llrender/llfontgl.cpp b/linden/indra/llrender/llfontgl.cpp index a328196..2705516 100644 --- a/linden/indra/llrender/llfontgl.cpp +++ b/linden/indra/llrender/llfontgl.cpp @@ -148,7 +148,7 @@ void LLFontGL::init() { mImageGLp = new LLImageGL(FALSE); //RN: use nearest mipmap filtering to obviate the need to do pixel-accurate positioning - mImageGLp->bind(); + gGL.getTexUnit(0)->bind(mImageGLp); // we allow bilinear filtering to get sub-pixel positioning for drop shadows //mImageGLp->setMipFilterNearest(TRUE, TRUE); } @@ -533,7 +533,7 @@ BOOL LLFontGL::loadFace(const std::string& filename, return FALSE; } mImageGLp->createGLTexture(0, mRawImageGLp); - mImageGLp->bind(); + gGL.getTexUnit(0)->bind(mImageGLp); mImageGLp->setMipFilterNearest(TRUE, TRUE); return TRUE; } @@ -547,7 +547,7 @@ BOOL LLFontGL::addChar(const llwchar wch) stop_glerror(); mImageGLp->setSubImage(mRawImageGLp, 0, 0, mImageGLp->getWidth(), mImageGLp->getHeight()); - mImageGLp->bind(); + gGL.getTexUnit(0)->bind(mImageGLp); mImageGLp->setMipFilterNearest(TRUE, TRUE); stop_glerror(); return TRUE; @@ -583,7 +583,7 @@ S32 LLFontGL::render(const LLWString &wstr, return wstr.length() ; } - LLGLEnable tex(GL_TEXTURE_2D); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); if (wstr.empty()) { @@ -663,7 +663,7 @@ S32 LLFontGL::render(const LLWString &wstr, // Bind the font texture - mImageGLp->bind(0); + gGL.getTexUnit(0)->bind(mImageGLp); // Not guaranteed to be set correctly gGL.setSceneBlendType(LLRender::BT_ALPHA); @@ -761,7 +761,7 @@ S32 LLFontGL::render(const LLWString &wstr, break; } - ext_image->bind(); + gGL.getTexUnit(0)->bind(ext_image); const F32 ext_x = cur_render_x + (EXT_X_BEARING * sScaleX); const F32 ext_y = cur_render_y + (EXT_Y_BEARING * sScaleY + mAscender - mLineHeight); @@ -795,7 +795,7 @@ S32 LLFontGL::render(const LLWString &wstr, cur_render_x = cur_x; // Bind the font texture - mImageGLp->bind(); + gGL.getTexUnit(0)->bind(mImageGLp); } else { @@ -863,8 +863,8 @@ S32 LLFontGL::render(const LLWString &wstr, if (style & UNDERLINE) { - LLGLSNoTexture no_texture; - gGL.begin(LLVertexBuffer::LINES); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.begin(LLRender::LINES); gGL.vertex2f(start_x, cur_y - (mDescender)); gGL.vertex2f(cur_x, cur_y - (mDescender)); gGL.end(); @@ -1359,7 +1359,7 @@ void LLFontGL::drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, con F32 slant_offset; slant_offset = ((style & ITALIC) ? ( -mAscender * 0.2f) : 0.f); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { //FIXME: bold and drop shadow are mutually exclusive only for convenience //Allow both when we need them. diff --git a/linden/indra/llrender/llgl.cpp b/linden/indra/llrender/llgl.cpp index 843bc79..67d258e 100644 --- a/linden/indra/llrender/llgl.cpp +++ b/linden/indra/llrender/llgl.cpp @@ -263,7 +263,6 @@ LLGLManager::LLGLManager() : mHasMultitexture(FALSE), mNumTextureUnits(1), mHasMipMapGeneration(FALSE), - mHasPalettedTextures(FALSE), mHasCompressedTextures(FALSE), mHasFramebufferObject(FALSE), @@ -566,7 +565,6 @@ void LLGLManager::initExtensions() mHasFramebufferObject = FALSE; # endif mHasMipMapGeneration = FALSE; - mHasPalettedTextures = FALSE; mHasSeparateSpecularColor = FALSE; mHasAnisotropic = FALSE; mHasCubeMap = FALSE; @@ -578,7 +576,6 @@ void LLGLManager::initExtensions() #else // LL_MESA_HEADLESS mHasMultitexture = glh_init_extensions("GL_ARB_multitexture"); mHasMipMapGeneration = glh_init_extensions("GL_SGIS_generate_mipmap"); - mHasPalettedTextures = glh_init_extension("GL_EXT_paletted_texture"); mHasSeparateSpecularColor = glh_init_extensions("GL_EXT_separate_specular_color"); mHasAnisotropic = glh_init_extensions("GL_EXT_texture_filter_anisotropic"); glh_init_extensions("GL_ARB_texture_cube_map"); @@ -610,7 +607,6 @@ void LLGLManager::initExtensions() mHasVertexBufferObject = FALSE; mHasFramebufferObject = FALSE; mHasMipMapGeneration = FALSE; - mHasPalettedTextures = FALSE; mHasSeparateSpecularColor = FALSE; mHasAnisotropic = FALSE; mHasCubeMap = FALSE; @@ -628,7 +624,6 @@ void LLGLManager::initExtensions() // bug reports. This should be the default until we get a // proper blacklist/whitelist on Linux. mHasMipMapGeneration = FALSE; - mHasPalettedTextures = FALSE; mHasAnisotropic = FALSE; //mHasCubeMap = FALSE; // apparently fatal on Intel 915 & similar //mHasOcclusionQuery = FALSE; // source of many ATI system hangs @@ -648,7 +643,6 @@ void LLGLManager::initExtensions() if (strchr(blacklist,'b')) mHasCompressedTextures = FALSE; if (strchr(blacklist,'c')) mHasVertexBufferObject = FALSE; if (strchr(blacklist,'d')) mHasMipMapGeneration = FALSE;//S - if (strchr(blacklist,'e')) mHasPalettedTextures = FALSE;//S // if (strchr(blacklist,'f')) mHasNVVertexArrayRange = FALSE;//S // if (strchr(blacklist,'g')) mHasNVFence = FALSE;//S if (strchr(blacklist,'h')) mHasSeparateSpecularColor = FALSE; @@ -663,13 +657,6 @@ void LLGLManager::initExtensions() if (strchr(blacklist,'q')) mHasFramebufferObject = FALSE;//S } #endif // LL_LINUX - -#if LL_DARWIN || LL_LINUX - // MBW -- 12/4/2003 -- Using paletted textures causes a bunch of avatar rendering problems on the Mac. - // Not sure if this is due to driver problems or incorrect use of the extension, but I'm disabling it for now. - // Tofu - 2006-10-03 -- Same problem on Linux. - mHasPalettedTextures = false; -#endif if (!mHasMultitexture) { @@ -683,10 +670,6 @@ void LLGLManager::initExtensions() { LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_texture_env_combine" << LL_ENDL; } - if (!mHasPalettedTextures) - { - LL_INFOS("RenderInit") << "Couldn't initialize GL_EXT_paletted_texture" << LL_ENDL; - } if (!mHasSeparateSpecularColor) { LL_INFOS("RenderInit") << "Couldn't initialize separate specular color" << LL_ENDL; @@ -788,13 +771,7 @@ void LLGLManager::initExtensions() mGLMaxIndexRange = 0; } #endif // !LL_LINUX -#if LL_LINUX - // On Linux we need to get glColorTableEXT dynamically. - if (mHasPalettedTextures) - { - glColorTableEXT = (PFNGLCOLORTABLEEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glColorTableEXT"); - } -#endif // LL_LINUX + if (mHasOcclusionQuery) { glGenQueriesARB = (PFNGLGENQUERIESARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGenQueriesARB"); @@ -960,7 +937,8 @@ void assert_glerror() GLubyte const * gl_error_msg = gluErrorString(error); if (NULL != gl_error_msg) { - LL_WARNS("RenderState") << "GL Error:" << gl_error_msg << LL_ENDL; + LL_WARNS("RenderState") << "GL Error:" << error<< LL_ENDL; + LL_WARNS("RenderState") << "GL Error String:" << gl_error_msg << LL_ENDL; } else { @@ -1001,7 +979,7 @@ GLboolean LLGLDepthTest::sWriteEnabled = GL_TRUE; // OpenGL default void LLGLState::initClass() { sStateMap[GL_DITHER] = GL_TRUE; - sStateMap[GL_TEXTURE_2D] = GL_TRUE; + // sStateMap[GL_TEXTURE_2D] = GL_TRUE; //make sure multisample defaults to disabled sStateMap[GL_MULTISAMPLE_ARB] = GL_FALSE; @@ -1030,7 +1008,7 @@ void LLGLState::resetTextureStates() { gGL.getTexUnit(j)->activate(); glClientActiveTextureARB(GL_TEXTURE0_ARB+j); - j == 0 ? glEnable(GL_TEXTURE_2D) : glDisable(GL_TEXTURE_2D); + j == 0 ? gGL.getTexUnit(j)->enable(LLTexUnit::TT_TEXTURE) : gGL.getTexUnit(j)->disable(); } } @@ -1053,14 +1031,6 @@ void LLGLState::checkStates(const std::string& msg) stop_glerror(); - GLint activeTexture; - glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &activeTexture); - - if (activeTexture != GL_TEXTURE0_ARB) - { - LL_GL_ERRS << "Texture channel corrupted. " << LL_ENDL; - } - GLint src; GLint dst; glGetIntegerv(GL_BLEND_SRC, &src); @@ -1099,17 +1069,7 @@ void LLGLState::checkTextureChannels(const std::string& msg) BOOL error = FALSE; - if (activeTexture != GL_TEXTURE0_ARB) - { - error = TRUE; - LL_WARNS("RenderState") << "Active texture channel corrupted. " << LL_ENDL; - } - else if (!glIsEnabled(GL_TEXTURE_2D)) - { - error = TRUE; - LL_WARNS("RenderState") << "GL_TEXTURE_2D not enabled on texture channel 0." << LL_ENDL; - } - else + if (activeTexture == GL_TEXTURE0_ARB) { GLint tex_env_mode = 0; @@ -1152,7 +1112,7 @@ void LLGLState::checkTextureChannels(const std::string& msg) LLMatrix4 identity; LLMatrix4 matrix; - for (GLint i = 0; i < maxTextureUnits; i++) + for (GLint i = 1; i < maxTextureUnits; i++) { gGL.getTexUnit(i)->activate(); glClientActiveTextureARB(GL_TEXTURE0_ARB+i); @@ -1459,16 +1419,6 @@ void set_binormals(const S32 index, const U32 stride,const LLVector3 *binormals) #endif } - -void set_palette(U8 *palette_data) -{ - if (gGLManager.mHasPalettedTextures) - { - glColorTableEXT(GL_TEXTURE_2D, GL_RGBA8, 256, GL_RGBA, GL_UNSIGNED_BYTE, palette_data); - } -} - - void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor_specific ) { // GL_VERSION returns a null-terminated string with the format: diff --git a/linden/indra/llrender/llgl.h b/linden/indra/llrender/llgl.h index cb368d7..8433348 100644 --- a/linden/indra/llrender/llgl.h +++ b/linden/indra/llrender/llgl.h @@ -74,7 +74,6 @@ public: BOOL mHasMultitexture; S32 mNumTextureUnits; BOOL mHasMipMapGeneration; - BOOL mHasPalettedTextures; BOOL mHasCompressedTextures; BOOL mHasFramebufferObject; @@ -318,11 +317,11 @@ public: class LLGLNamePool { public: - typedef struct + struct NameEntry { GLuint name; BOOL used; - } NameEntry; + }; struct CompareUsed { @@ -370,7 +369,6 @@ void disable_cloth_weights(const S32 index); void set_vertex_weights(const S32 index, const U32 stride, const F32 *weights); void set_vertex_clothing_weights(const S32 index, const U32 stride, const LLVector4 *weights); void set_binormals(const S32 index, const U32 stride, const LLVector3 *binormals); -void set_palette(U8* palette_data); void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor_specific ); extern BOOL gClothRipple; diff --git a/linden/indra/llrender/llglimmediate.h b/linden/indra/llrender/llglimmediate.h index 2d7d768..cd2af8b 100644 --- a/linden/indra/llrender/llglimmediate.h +++ b/linden/indra/llrender/llglimmediate.h @@ -76,12 +76,12 @@ public: void color3fv(const GLfloat* c); void color4ubv(const GLubyte* c); - typedef struct Vertex + typedef struct { GLfloat v[3]; GLubyte c[4]; GLfloat uv[2]; - }; + } Vertex; private: U32 mCount; diff --git a/linden/indra/llrender/llglslshader.cpp b/linden/indra/llrender/llglslshader.cpp index 26984e1..5d7375c 100644 --- a/linden/indra/llrender/llglslshader.cpp +++ b/linden/indra/llrender/llglslshader.cpp @@ -365,7 +365,7 @@ void LLGLSLShader::bindNoShader(void) glUseProgramObjectARB(0); } -S32 LLGLSLShader::enableTexture(S32 uniform, S32 mode) +S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode) { if (uniform < 0 || uniform >= (S32)mTexture.size()) { @@ -376,12 +376,12 @@ S32 LLGLSLShader::enableTexture(S32 uniform, S32 mode) if (index != -1) { gGL.getTexUnit(index)->activate(); - glEnable(mode); + gGL.getTexUnit(index)->enable(mode); } return index; } -S32 LLGLSLShader::disableTexture(S32 uniform, S32 mode) +S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode) { if (uniform < 0 || uniform >= (S32)mTexture.size()) { @@ -392,7 +392,7 @@ S32 LLGLSLShader::disableTexture(S32 uniform, S32 mode) if (index != -1) { gGL.getTexUnit(index)->activate(); - glDisable(mode); + gGL.getTexUnit(index)->disable(); } return index; } diff --git a/linden/indra/llrender/llglslshader.h b/linden/indra/llrender/llglslshader.h index 0fa8e41..cd787cc 100644 --- a/linden/indra/llrender/llglslshader.h +++ b/linden/indra/llrender/llglslshader.h @@ -33,6 +33,7 @@ #define LL_LLGLSLSHADER_H #include "llgl.h" +#include "llrender.h" class LLShaderFeatures { @@ -111,8 +112,8 @@ public: //if given texture uniform is active in the shader, //the corresponding channel will be active upon return //returns channel texture is enabled in from [0-MAX) - S32 enableTexture(S32 uniform, S32 mode = GL_TEXTURE_2D); - S32 disableTexture(S32 uniform, S32 mode = GL_TEXTURE_2D); + S32 enableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE); + S32 disableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE); BOOL link(BOOL suppress_errors = FALSE); void bind(); diff --git a/linden/indra/llrender/llglstates.h b/linden/indra/llrender/llglstates.h index e53640c..bb8b8df 100644 --- a/linden/indra/llrender/llglstates.h +++ b/linden/indra/llrender/llglstates.h @@ -87,13 +87,6 @@ public: { } }; -class LLGLSNoTexture -{ -public: - LLGLSNoTexture() - { LLImageGL::unbindTexture(0); } -}; - class LLGLSObjectSelect { protected: @@ -104,7 +97,7 @@ public: : mBlend(GL_BLEND), mFog(GL_FOG), mAlphaTest(GL_ALPHA_TEST), mCullFace(GL_CULL_FACE) - { LLImageGL::unbindTexture(0); } + { } }; class LLGLSObjectSelectAlpha @@ -143,17 +136,6 @@ public: {} }; -class LLGLSNoTextureNoAlphaTest // : public LLGLSUIDefault -{ -protected: - LLGLDisable mAlphaTest; -public: - LLGLSNoTextureNoAlphaTest() - : mAlphaTest(GL_ALPHA_TEST) - - { LLImageGL::unbindTexture(0); } -}; - //---------------------------------------------------------------------------- class LLGLSFog @@ -251,7 +233,7 @@ public: mBlend(GL_BLEND), mAlphaTest(GL_ALPHA_TEST) - { LLImageGL::unbindTexture(0); } + { } }; //---------------------------------------------------------------------------- diff --git a/linden/indra/llrender/llimagegl.cpp b/linden/indra/llrender/llimagegl.cpp index a871758..d9b22c5 100644 --- a/linden/indra/llrender/llimagegl.cpp +++ b/linden/indra/llrender/llimagegl.cpp @@ -125,49 +125,6 @@ S32 LLImageGL::dataFormatComponents(S32 dataformat) //---------------------------------------------------------------------------- // static -void LLImageGL::bindExternalTexture(LLGLuint gl_name, S32 stage, LLGLenum bind_target ) -{ - gGL.flush(); - if (stage > 0) - { - gGL.getTexUnit(stage)->activate(); - } - glBindTexture(bind_target, gl_name); - sCurrentBoundTextures[stage] = gl_name; - if (stage > 0) - { - gGL.getTexUnit(0)->activate(); - } -} - -// static -void LLImageGL::unbindTexture(S32 stage, LLGLenum bind_target) -{ - // LLGLSLShader can return -1 - if (stage >= 0) - { - gGL.flush(); - if (stage > 0) - { - gGL.getTexUnit(stage)->activate(); - glBindTexture(GL_TEXTURE_2D, 0); - gGL.getTexUnit(0)->activate(); - } - else - { - glBindTexture(GL_TEXTURE_2D, 0); - } - sCurrentBoundTextures[stage] = 0; - } -} - -// static (duplicated for speed and to avoid GL_TEXTURE_2D default argument which requires GL header dependency) -void LLImageGL::unbindTexture(S32 stage) -{ - unbindTexture(stage, GL_TEXTURE_2D); -} - -// static void LLImageGL::updateStats(F32 current_time) { sLastFrameTime = current_time; @@ -189,7 +146,7 @@ void LLImageGL::destroyGL(BOOL save_state) { for (S32 stage = 0; stage < gGLManager.mNumTextureUnits; stage++) { - LLImageGL::unbindTexture(stage, GL_TEXTURE_2D); + gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE); } for (std::set::iterator iter = sImageList.begin(); iter != sImageList.end(); iter++) @@ -284,6 +241,8 @@ LLImageGL::~LLImageGL() { LLImageGL::cleanup(); sImageList.erase(this); + delete [] mPickMask; + mPickMask = NULL; sCount--; } @@ -293,11 +252,12 @@ void LLImageGL::init(BOOL usemipmaps) mMissed = FALSE; #endif + mPickMask = NULL; mTextureMemory = 0; mLastBindTime = 0.f; mTarget = GL_TEXTURE_2D; - mBindTarget = GL_TEXTURE_2D; + mBindTarget = LLTexUnit::TT_TEXTURE; mUseMipMaps = usemipmaps; mHasMipMaps = FALSE; mAutoGenMips = FALSE; @@ -321,6 +281,8 @@ void LLImageGL::init(BOOL usemipmaps) mFormatType = GL_UNSIGNED_BYTE; mFormatSwapBytes = FALSE; mHasExplicitFormat = FALSE; + + mInitialized = true; } void LLImageGL::cleanup() @@ -421,41 +383,14 @@ void LLImageGL::dump() //---------------------------------------------------------------------------- -BOOL LLImageGL::bindTextureInternal(const S32 stage) const +void LLImageGL::updateBindStats(void) const { - if (gGLManager.mIsDisabled) - { - llwarns << "Trying to bind a texture while GL is disabled!" << llendl; - } - - - if (sCurrentBoundTextures[stage] && sCurrentBoundTextures[stage] == mTexName) - { - // already set! - return TRUE; - } - if (mTexName != 0) { #ifdef DEBUG_MISS mMissed = ! getIsResident(TRUE); #endif - - gGL.flush(); - if (stage > 0) - { - gGL.getTexUnit(stage)->activate(); - } - - glBindTexture(mBindTarget, mTexName); - sCurrentBoundTextures[stage] = mTexName; sBindCount++; - - if (stage > 0) - { - gGL.getTexUnit(0)->activate(); - } - if (mLastBindTime != sLastFrameTime) { // we haven't accounted for this texture yet this frame @@ -463,38 +398,22 @@ BOOL LLImageGL::bindTextureInternal(const S32 stage) const updateBoundTexMem(mTextureMemory); mLastBindTime = sLastFrameTime; } - - return TRUE; - } - else - { - gGL.flush(); - if (stage > 0) - { - gGL.getTexUnit(stage)->activate(); - } - glBindTexture(mBindTarget, 0); - if (stage > 0) - { - gGL.getTexUnit(0)->activate(); - } - sCurrentBoundTextures[stage] = 0; - return FALSE; } } //virtual -BOOL LLImageGL::bind(const S32 stage) const +bool LLImageGL::bindError(const S32 stage) const { - if (stage == -1) - { - return FALSE; - } - BOOL res = bindTextureInternal(stage); - //llassert(res); - return res; + return false; +} + +//virtual +bool LLImageGL::bindDefaultImage(const S32 stage) const +{ + return false; } + void LLImageGL::setExplicitFormat( LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, BOOL swap_bytes ) { // Note: must be called before createTexture() @@ -532,7 +451,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) { // LLFastTimer t2(LLFastTimer::FTM_TEMP2); - llverify(bindTextureInternal(0)); + llverify(gGL.getTexUnit(0)->bind(this)); } if (mUseMipMaps) @@ -569,7 +488,8 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) } glTexImage2D(mTarget, gl_level, mFormatInternal, w, h, 0, mFormatPrimary, GL_UNSIGNED_BYTE, (GLvoid*)data_in); - + updatePickMask(w, h, data_in); + if(mFormatSwapBytes) { glPixelStorei(GL_UNPACK_SWAP_BYTES, 0); @@ -585,7 +505,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) { if (mAutoGenMips) { - glTexParameteri(mBindTarget, GL_GENERATE_MIPMAP_SGIS, TRUE); + glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_GENERATE_MIPMAP_SGIS, TRUE); stop_glerror(); { // LLFastTimer t2(LLFastTimer::FTM_TEMP4); @@ -596,12 +516,17 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) stop_glerror(); } + S32 w = getWidth(mCurrentDiscardLevel); + S32 h = getHeight(mCurrentDiscardLevel); + glTexImage2D(mTarget, 0, mFormatInternal, - getWidth(mCurrentDiscardLevel), getHeight(mCurrentDiscardLevel), 0, + w, h, 0, mFormatPrimary, mFormatType, data_in); stop_glerror(); + updatePickMask(w, h, data_in); + if(mFormatSwapBytes) { glPixelStorei(GL_UNPACK_SWAP_BYTES, 0); @@ -651,6 +576,10 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) glTexImage2D(mTarget, m, mFormatInternal, w, h, 0, mFormatPrimary, mFormatType, cur_mip_data); stop_glerror(); + if (m == 0) + { + updatePickMask(w, h, cur_mip_data); + } if(mFormatSwapBytes) { @@ -701,6 +630,8 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) glTexImage2D(mTarget, 0, mFormatInternal, w, h, 0, mFormatPrimary, mFormatType, (GLvoid *)data_in); + updatePickMask(w, h, data_in); + stop_glerror(); if(mFormatSwapBytes) @@ -713,6 +644,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) mHasMipMaps = FALSE; } stop_glerror(); + mInitialized = true; } BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height) @@ -786,12 +718,10 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 datap += (y_pos * data_width + x_pos) * getComponents(); // Update the GL texture - BOOL res = bindTextureInternal(0); + BOOL res = gGL.getTexUnit(0)->bindManual(mBindTarget, mTexName); if (!res) llerrs << "LLImageGL::setSubImage(): bindTexture failed" << llendl; stop_glerror(); - LLGLEnable tex( GL_TEXTURE_2D ); - glTexSubImage2D(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, datap); stop_glerror(); @@ -804,6 +734,7 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); stop_glerror(); + mInitialized = true; } return TRUE; @@ -817,9 +748,10 @@ BOOL LLImageGL::setSubImage(const LLImageRaw* imageraw, S32 x_pos, S32 y_pos, S3 // Copy sub image from frame buffer BOOL LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_pos, S32 width, S32 height) { - if (bindTextureInternal(0)) + if (gGL.getTexUnit(0)->bind(this)) { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, fb_x, fb_y, x_pos, y_pos, width, height); + mInitialized = true; stop_glerror(); return TRUE; } @@ -919,9 +851,9 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ stop_glerror(); { // LLFastTimer t1(LLFastTimer::FTM_TEMP6); - llverify(bindTextureInternal(0)); - glTexParameteri(mBindTarget, GL_TEXTURE_BASE_LEVEL, 0); - glTexParameteri(mBindTarget, GL_TEXTURE_MAX_LEVEL, mMaxDiscardLevel-discard_level); + llverify(gGL.getTexUnit(0)->bind(this)); + glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_BASE_LEVEL, 0); + glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MAX_LEVEL, mMaxDiscardLevel-discard_level); } } if (!mTexName) @@ -949,7 +881,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ setMipFilterNearest(mMagFilterNearest); // things will break if we don't unbind after creation - unbindTexture(0, mBindTarget); + gGL.getTexUnit(0)->unbind(mBindTarget); stop_glerror(); if (old_name != 0) @@ -1050,8 +982,8 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre S32 gl_discard = discard_level - mCurrentDiscardLevel; //explicitly unbind texture - LLImageGL::unbindTexture(0, mTarget); - llverify(bindTextureInternal(0)); + gGL.getTexUnit(0)->unbind(mBindTarget); + llverify(gGL.getTexUnit(0)->bind(this)); if (gDebugGL) { @@ -1148,15 +1080,15 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre void LLImageGL::destroyGLTexture() { - stop_glerror(); - if (mTexName != 0) { + stop_glerror(); + for (int i = 0; i < gGLManager.mNumTextureUnits; i++) { if (sCurrentBoundTextures[i] == mTexName) { - unbindTexture(i, GL_TEXTURE_2D); + gGL.getTexUnit(i)->unbind(LLTexUnit::TT_TEXTURE); stop_glerror(); } } @@ -1184,8 +1116,8 @@ void LLImageGL::glClamp (BOOL clamps, BOOL clampt) { if (mTexName != 0) { - glTexParameteri (mBindTarget, GL_TEXTURE_WRAP_S, clamps ? GL_CLAMP_TO_EDGE : GL_REPEAT); - glTexParameteri (mBindTarget, GL_TEXTURE_WRAP_T, clampt ? GL_CLAMP_TO_EDGE : GL_REPEAT); + glTexParameteri (LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_WRAP_S, clamps ? GL_CLAMP_TO_EDGE : GL_REPEAT); + glTexParameteri (LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_WRAP_T, clampt ? GL_CLAMP_TO_EDGE : GL_REPEAT); } } @@ -1223,23 +1155,23 @@ void LLImageGL::setMipFilterNearest(BOOL mag_nearest, BOOL min_nearest) { if (mMinFilterNearest) { - glTexParameteri(mBindTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MIN_FILTER, GL_NEAREST); } else if (mHasMipMaps) { - glTexParameteri(mBindTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); } else { - glTexParameteri(mBindTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MIN_FILTER, GL_LINEAR); } if (mMagFilterNearest) { - glTexParameteri(mBindTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MAG_FILTER, GL_NEAREST); } else { - glTexParameteri(mBindTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MAG_FILTER, GL_LINEAR); } if (gGLManager.mHasAnisotropic) { @@ -1247,16 +1179,15 @@ void LLImageGL::setMipFilterNearest(BOOL mag_nearest, BOOL min_nearest) { F32 largest_anisotropy; glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_anisotropy); - glTexParameterf(mBindTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_anisotropy); + glTexParameterf(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_anisotropy); } else { - glTexParameterf(mBindTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); + glTexParameterf(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); } } - } - - stop_glerror(); + stop_glerror(); + } } BOOL LLImageGL::getIsResident(BOOL test_now) @@ -1337,14 +1268,93 @@ BOOL LLImageGL::getBoundRecently() const return (BOOL)(sLastFrameTime - mLastBindTime < MIN_TEXTURE_LIFETIME); } -void LLImageGL::setTarget(const LLGLenum target, const LLGLenum bind_target) +void LLImageGL::setTarget(const LLGLenum target, const LLTexUnit::eTextureType bind_target) { mTarget = target; mBindTarget = bind_target; } +void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in) +{ + if (mFormatType != GL_UNSIGNED_BYTE || + mFormatPrimary != GL_RGBA) + { + //cannot generate a pick mask for this texture + delete [] mPickMask; + mPickMask = NULL; + return; + } + + U32 pick_width = width/2; + U32 pick_height = height/2; + + U32 size = llmax(pick_width, (U32) 1) * llmax(pick_height, (U32) 1); + + size = size/8 + 1; + + delete[] mPickMask; + mPickMask = new U8[size]; + + memset(mPickMask, 0, sizeof(U8) * size); + + U32 pick_bit = 0; + + for (S32 y = 0; y < height; y += 2) + { + for (S32 x = 0; x < width; x += 2) + { + U8 alpha = data_in[(y*width+x)*4+3]; + + if (alpha > 32) + { + U32 pick_idx = pick_bit/8; + U32 pick_offset = pick_bit%8; + if (pick_idx >= size) + { + llerrs << "WTF?" << llendl; + } + + mPickMask[pick_idx] |= 1 << pick_offset; + } + + ++pick_bit; + } + } +} + +BOOL LLImageGL::getMask(const LLVector2 &tc) +{ + BOOL res = TRUE; + + if (mPickMask) + { + S32 width = getWidth()/2; + S32 height = getHeight()/2; + + F32 u = tc.mV[0] - floorf(tc.mV[0]); + F32 v = tc.mV[1] - floorf(tc.mV[1]); + + if (u < 0.f || u > 1.f || + v < 0.f || v > 1.f) + { + llerrs << "WTF?" << llendl; + } + + S32 x = (S32)(u * width); + S32 y = (S32)(v * height); + + S32 idx = y*width+x; + S32 offset = idx%8; + + res = mPickMask[idx/8] & (1 << offset) ? TRUE : FALSE; + } + + return res; +} + //---------------------------------------------------------------------------- + // Manual Mip Generation /* S32 width = getWidth(discard_level); diff --git a/linden/indra/llrender/llimagegl.h b/linden/indra/llrender/llimagegl.h index 3f231ee..dbe11da 100644 --- a/linden/indra/llrender/llimagegl.h +++ b/linden/indra/llrender/llimagegl.h @@ -37,6 +37,9 @@ #include "llgltypes.h" #include "llmemory.h" +#include "v2math.h" + +#include "llrender.h" //============================================================================ @@ -48,11 +51,7 @@ public: static S32 dataFormatBytes(S32 dataformat, S32 width, S32 height); static S32 dataFormatComponents(S32 dataformat); - // Wrapper for glBindTexture that keeps LLImageGL in sync. - // Usually you want stage = 0 and bind_target = GL_TEXTURE_2D - static void bindExternalTexture( LLGLuint gl_name, S32 stage, LLGLenum bind_target); - static void unbindTexture(S32 stage, LLGLenum target); - static void unbindTexture(S32 stage); // Uses GL_TEXTURE_2D (not a default arg to avoid gl.h dependency) + void updateBindStats(void) const; // needs to be called every frame static void updateStats(F32 current_time); @@ -79,7 +78,6 @@ public: protected: virtual ~LLImageGL(); - BOOL bindTextureInternal(const S32 stage = 0) const; private: void glClamp (BOOL clamps, BOOL clampt); @@ -87,7 +85,8 @@ private: public: virtual void dump(); // debugging info to llinfos - virtual BOOL bind(const S32 stage = 0) const; + virtual bool bindError(const S32 stage = 0) const; + virtual bool bindDefaultImage(const S32 stage = 0) const; void setSize(S32 width, S32 height, S32 ncomponents); @@ -132,7 +131,11 @@ public: BOOL getIsResident(BOOL test_now = FALSE); // not const - void setTarget(const LLGLenum target, const LLGLenum bind_target); + void setTarget(const LLGLenum target, const LLTexUnit::eTextureType bind_target); + + LLTexUnit::eTextureType getTarget(void) const { return mBindTarget; } + bool isInitialized(void) const { return mInitialized; } + void setInitialized (bool initialized) { mInitialized = initialized; } BOOL getUseMipMaps() const { return mUseMipMaps; } void setUseMipMaps(BOOL usemips) { mUseMipMaps = usemips; } @@ -141,6 +144,9 @@ public: BOOL isValidForSculpt(S32 discard_level, S32 image_width, S32 image_height, S32 ncomponents) ; + void updatePickMask(S32 width, S32 height, const U8* data_in); + BOOL getMask(const LLVector2 &tc); + protected: void init(BOOL usemipmaps); virtual void cleanup(); // Clean up the LLImageGL so it can be reinitialized. Be careful when using this in derived class destructors @@ -152,6 +158,7 @@ public: private: LLPointer mSaveData; // used for destroyGL/restoreGL + U8* mPickMask; //downsampled bitmap approximation of alpha channel. NULL if no alpha channel S8 mUseMipMaps; S8 mHasMipMaps; S8 mHasExplicitFormat; // If false (default), GL format is f(mComponents) @@ -159,7 +166,8 @@ private: protected: LLGLenum mTarget; // Normally GL_TEXTURE2D, sometimes something else (ex. cube maps) - LLGLenum mBindTarget; // NOrmally GL_TEXTURE2D, sometimes something else (ex. cube maps) + LLTexUnit::eTextureType mBindTarget; // Normally TT_TEXTURE, sometimes something else (ex. cube maps) + bool mInitialized; LLGLuint mTexName; diff --git a/linden/indra/llrender/llpostprocess.cpp b/linden/indra/llrender/llpostprocess.cpp index c884951..0f1ad5c 100644 --- a/linden/indra/llrender/llpostprocess.cpp +++ b/linden/indra/llrender/llpostprocess.cpp @@ -220,9 +220,9 @@ void LLPostProcess::applyColorFilterShader(void) gPostColorFilterProgram.bind(); gGL.getTexUnit(0)->activate(); - glEnable(GL_TEXTURE_RECTANGLE_ARB); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, sceneRenderTexture); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture); getShaderUniforms(colorFilterUniforms, gPostColorFilterProgram.mProgramObject); glUniform1iARB(colorFilterUniforms["RenderTexture"], 0); @@ -264,16 +264,16 @@ void LLPostProcess::applyNightVisionShader(void) gPostNightVisionProgram.bind(); gGL.getTexUnit(0)->activate(); - glEnable(GL_TEXTURE_RECTANGLE_ARB); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); getShaderUniforms(nightVisionUniforms, gPostNightVisionProgram.mProgramObject); - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, sceneRenderTexture); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture); glUniform1iARB(nightVisionUniforms["RenderTexture"], 0); gGL.getTexUnit(1)->activate(); - glEnable(GL_TEXTURE_2D); + gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); - glBindTexture(GL_TEXTURE_2D, noiseTexture); + gGL.getTexUnit(1)->bindManual(LLTexUnit::TT_TEXTURE, noiseTexture); glUniform1iARB(nightVisionUniforms["NoiseTexture"], 1); @@ -373,7 +373,7 @@ void LLPostProcess::doEffects(void) void LLPostProcess::copyFrameBuffer(GLuint & texture, unsigned int width, unsigned int height) { - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture); glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 0, 0, width, height, 0); } @@ -487,7 +487,7 @@ void LLPostProcess::createTexture(GLuint & texture, unsigned int width, unsigned std::vector data(width * height * 4, 0); glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture); glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data[0]); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_MIN_FILTER,GL_LINEAR); @@ -509,7 +509,7 @@ void LLPostProcess::createNoiseTexture(GLuint & texture) buffer[(i * NOISE_SIZE) + k] = (GLubyte)((double) rand() / ((double) RAND_MAX + 1.f) * 255.f); } } - glBindTexture(GL_TEXTURE_2D, texture); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, NOISE_SIZE, NOISE_SIZE, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, &buffer[0]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR); diff --git a/linden/indra/llrender/llrender.cpp b/linden/indra/llrender/llrender.cpp index 7be06af..80fed06 100644 --- a/linden/indra/llrender/llrender.cpp +++ b/linden/indra/llrender/llrender.cpp @@ -32,7 +32,11 @@ #include "linden_common.h" #include "llrender.h" + #include "llvertexbuffer.h" +#include "llcubemap.h" +#include "llimagegl.h" +#include "llrendertarget.h" LLRender gGL; @@ -44,6 +48,20 @@ S32 gGLViewport[4]; static const U32 LL_NUM_TEXTURE_LAYERS = 8; +static GLenum sGLTextureType[] = +{ + GL_TEXTURE_2D, + GL_TEXTURE_RECTANGLE_ARB, + GL_TEXTURE_CUBE_MAP_ARB +}; + +static GLint sGLAddressMode[] = +{ + GL_REPEAT, + GL_MIRRORED_REPEAT, + GL_CLAMP_TO_EDGE +}; + static GLenum sGLCompareFunc[] = { GL_NEVER, @@ -72,82 +90,217 @@ static GLenum sGLBlendFactor[] = GL_ONE_MINUS_SRC_ALPHA }; -LLTexUnit::LLTexUnit(U32 index) -: mIsEnabled(false), mCurrBlendType(TB_MULT), +LLTexUnit::LLTexUnit(S32 index) +: mCurrTexType(TT_NONE), mCurrBlendType(TB_MULT), mCurrColorOp(TBO_MULT), mCurrAlphaOp(TBO_MULT), mCurrColorSrc1(TBS_TEX_COLOR), mCurrColorSrc2(TBS_PREV_COLOR), mCurrAlphaSrc1(TBS_TEX_ALPHA), mCurrAlphaSrc2(TBS_PREV_ALPHA), -mCurrColorScale(1), mCurrAlphaScale(1) +mCurrColorScale(1), mCurrAlphaScale(1), mCurrTexture(0) { llassert_always(index < LL_NUM_TEXTURE_LAYERS); mIndex = index; } -U32 LLTexUnit::getIndex(void) +//static +U32 LLTexUnit::getInternalType(eTextureType type) { - return mIndex; + return sGLTextureType[type]; } -void LLTexUnit::enable(void) +void LLTexUnit::refreshState(void) { - if (!mIsEnabled) + // We set dirty to true so that the tex unit knows to ignore caching + // and we reset the cached tex unit state + + glActiveTextureARB(GL_TEXTURE0_ARB + mIndex); + if (mCurrTexType != TT_NONE) { - activate(); - glEnable(GL_TEXTURE_2D); - mIsEnabled = true; + glEnable(sGLTextureType[mCurrTexType]); + glBindTexture(sGLTextureType[mCurrTexType], mCurrTexture); } -} - -void LLTexUnit::disable(void) -{ - if (mIsEnabled) + else { - activate(); glDisable(GL_TEXTURE_2D); - mIsEnabled = false; + glBindTexture(GL_TEXTURE_2D, 0); + } + + if (mCurrBlendType != TB_COMBINE) + { + setTextureBlendType(mCurrBlendType); + } + else + { + setTextureCombiner(mCurrColorOp, mCurrColorSrc1, mCurrColorSrc2, false); + setTextureCombiner(mCurrAlphaOp, mCurrAlphaSrc1, mCurrAlphaSrc2, true); } } void LLTexUnit::activate(void) { - //if (gGL.mCurrTextureUnitIndex != mIndex) + if (mIndex < 0) return; + + if (gGL.mCurrTextureUnitIndex != mIndex || gGL.mDirty) { glActiveTextureARB(GL_TEXTURE0_ARB + mIndex); gGL.mCurrTextureUnitIndex = mIndex; } } -// Useful for debugging that you've manually assigned a texture operation to the correct -// texture unit based on the currently set active texture in opengl. -void LLTexUnit::debugTextureUnit(void) +void LLTexUnit::enable(eTextureType type) { - GLint activeTexture; - glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &activeTexture); - if ((GL_TEXTURE0_ARB + mIndex) != activeTexture) + if (mIndex < 0) return; + + if ( (mCurrTexType != type || gGL.mDirty) && (type != TT_NONE) ) + { + activate(); + if (mCurrTexType != TT_NONE && !gGL.mDirty) + { + disable(); // Force a disable of a previous texture type if it's enabled. + } + mCurrTexType = type; + glEnable(sGLTextureType[type]); + } +} + +void LLTexUnit::disable(void) +{ + if (mIndex < 0) return; + + if (mCurrTexType != TT_NONE) { - llerrs << "Incorrect Texture Unit! Expected: " << (activeTexture - GL_TEXTURE0_ARB) << " Actual: " << mIndex << llendl; + activate(); + unbind(mCurrTexType); + glDisable(sGLTextureType[mCurrTexType]); + mCurrTexType = TT_NONE; } } -void LLTexUnit::bindTexture(const LLImageGL* texture) +bool LLTexUnit::bind(const LLImageGL* texture) { + if (mIndex < 0) return false; + + gGL.flush(); + + if (texture == NULL) + { + return texture->bindError(mIndex); + } + + if (!texture->isInitialized()) + { + return texture->bindDefaultImage(mIndex); + } + + // Disabled caching of binding state. if (texture != NULL) { activate(); - texture->bind(mIndex); + enable(texture->getTarget()); + mCurrTexture = texture->getTexName(); + glBindTexture(sGLTextureType[texture->getTarget()], mCurrTexture); + texture->updateBindStats(); + return true; } + return false; } -void LLTexUnit::unbindTexture(void) +bool LLTexUnit::bind(LLCubeMap* cubeMap) { + if (mIndex < 0) return false; + + gGL.flush(); + + // Disabled caching of binding state. + if (cubeMap != NULL) + { + if (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) + { + activate(); + enable(LLTexUnit::TT_CUBE_MAP); + mCurrTexture = cubeMap->mImages[0]->getTexName(); + glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mCurrTexture); + cubeMap->mImages[0]->updateBindStats(); + cubeMap->mImages[0]->setMipFilterNearest (FALSE, FALSE); + return true; + } + else + { + llwarns << "Using cube map without extension!" << llendl + } + } + return false; +} + +bool LLTexUnit::bind(LLRenderTarget* renderTarget, bool bindDepth) +{ + if (mIndex < 0) return false; + + gGL.flush(); + + if (bindDepth) + { + bindManual(renderTarget->getUsage(), renderTarget->getDepth()); + } + else + { + bindManual(renderTarget->getUsage(), renderTarget->getTexture()); + } + + return true; +} + +bool LLTexUnit::bindManual(eTextureType type, U32 texture) +{ + if (mIndex < 0) return false; + + // Disabled caching of binding state. + gGL.flush(); + activate(); - glBindTexture(GL_TEXTURE_2D, 0); + enable(type); + mCurrTexture = texture; + glBindTexture(sGLTextureType[type], texture); + return true; +} + +void LLTexUnit::unbind(eTextureType type) +{ + if (mIndex < 0) return; + + // Disabled caching of binding state. + if (mCurrTexType == type) + { + gGL.flush(); + + activate(); + mCurrTexture = 0; + glBindTexture(sGLTextureType[type], 0); + } +} + +void LLTexUnit::setTextureAddressMode(eTextureAddressMode mode) +{ + if (mIndex < 0) return; + + if (true) + { + activate(); + + glTexParameteri (sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_S, sGLAddressMode[mode]); + glTexParameteri (sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_T, sGLAddressMode[mode]); + if (mCurrTexType == TT_CUBE_MAP) + { + glTexParameteri (GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, sGLAddressMode[mode]); + } + } } void LLTexUnit::setTextureBlendType(eTextureBlendType type) { + if (mIndex < 0) return; + // Do nothing if it's already correctly set. - if (mCurrBlendType == type) + if (mCurrBlendType == type && !gGL.mDirty) { return; } @@ -262,16 +415,18 @@ GLint LLTexUnit::getTextureSourceType(eTextureBlendSrc src, bool isAlpha) void LLTexUnit::setTextureCombiner(eTextureBlendOp op, eTextureBlendSrc src1, eTextureBlendSrc src2, bool isAlpha) { + if (mIndex < 0) return; + activate(); - if (mCurrBlendType != TB_COMBINE) + if (mCurrBlendType != TB_COMBINE || gGL.mDirty) { mCurrBlendType = TB_COMBINE; glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); } // We want an early out, because this function does a LOT of stuff. - if ( (isAlpha && (mCurrAlphaOp == op) && (mCurrAlphaSrc1 == src1) && (mCurrAlphaSrc2 == src2) ) - || (!isAlpha && (mCurrColorOp == op) && (mCurrColorSrc1 == src1) && (mCurrColorSrc2 == src2) )) + if ( ( (isAlpha && (mCurrAlphaOp == op) && (mCurrAlphaSrc1 == src1) && (mCurrAlphaSrc2 == src2)) + || (!isAlpha && (mCurrColorOp == op) && (mCurrColorSrc1 == src1) && (mCurrColorSrc2 == src2)) ) && !gGL.mDirty) { return; } @@ -304,7 +459,7 @@ void LLTexUnit::setTextureCombiner(eTextureBlendOp op, eTextureBlendSrc src1, eT } else { - // Set enums to ALPHA ones + // Set enums to RGB ones comb_enum = GL_COMBINE_RGB_ARB; src0_enum = GL_SOURCE0_RGB_ARB; src1_enum = GL_SOURCE1_RGB_ARB; @@ -405,7 +560,7 @@ void LLTexUnit::setTextureCombiner(eTextureBlendOp op, eTextureBlendSrc src1, eT void LLTexUnit::setColorScale(S32 scale) { - if (mCurrColorScale != scale) + if (mCurrColorScale != scale || gGL.mDirty) { mCurrColorScale = scale; glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE, scale ); @@ -414,27 +569,52 @@ void LLTexUnit::setColorScale(S32 scale) void LLTexUnit::setAlphaScale(S32 scale) { - if (mCurrAlphaScale != scale) + if (mCurrAlphaScale != scale || gGL.mDirty) { mCurrAlphaScale = scale; glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, scale ); } } +// Useful for debugging that you've manually assigned a texture operation to the correct +// texture unit based on the currently set active texture in opengl. +void LLTexUnit::debugTextureUnit(void) +{ + if (mIndex < 0) return; + + GLint activeTexture; + glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &activeTexture); + if ((GL_TEXTURE0_ARB + mIndex) != activeTexture) + { + U32 set_unit = (activeTexture - GL_TEXTURE0_ARB); + llwarns << "Incorrect Texture Unit! Expected: " << set_unit << " Actual: " << mIndex << llendl; + } +} + + LLRender::LLRender() +: mDirty(false), mCount(0), mMode(LLRender::TRIANGLES) { - mCount = 0; - mMode = LLVertexBuffer::TRIANGLES; mBuffer = new LLVertexBuffer(immediate_mask, 0); mBuffer->allocateBuffer(4096, 0, TRUE); mBuffer->getVertexStrider(mVerticesp); mBuffer->getTexCoordStrider(mTexcoordsp); mBuffer->getColorStrider(mColorsp); - - for (unsigned int i = 0; i < LL_NUM_TEXTURE_LAYERS; i++) + + mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS); + for (U32 i = 0; i < LL_NUM_TEXTURE_LAYERS; i++) { mTexUnits.push_back(new LLTexUnit(i)); } + mDummyTexUnit = new LLTexUnit(-1); + + for (U32 i = 0; i < 4; i++) + { + mCurrColorMask[i] = true; + } + + mCurrAlphaFunc = CF_DEFAULT; + mCurrAlphaFuncVal = 0.01f; } LLRender::~LLRender() @@ -449,6 +629,28 @@ void LLRender::shutdown() delete mTexUnits[i]; } mTexUnits.clear(); + delete mDummyTexUnit; + mDummyTexUnit = NULL; +} + +void LLRender::refreshState(void) +{ + mDirty = true; + + U32 active_unit = mCurrTextureUnitIndex; + + for (U32 i = 0; i < mTexUnits.size(); i++) + { + mTexUnits[i]->refreshState(); + } + + mTexUnits[active_unit]->activate(); + + setColorMask(mCurrColorMask[0], mCurrColorMask[1], mCurrColorMask[2], mCurrColorMask[3]); + + setAlphaRejectSettings(mCurrAlphaFunc, mCurrAlphaFuncVal); + + mDirty = false; } void LLRender::translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z) @@ -483,6 +685,12 @@ void LLRender::setColorMask(bool writeColor, bool writeAlpha) void LLRender::setColorMask(bool writeColorR, bool writeColorG, bool writeColorB, bool writeAlpha) { flush(); + + mCurrColorMask[0] = writeColorR; + mCurrColorMask[1] = writeColorG; + mCurrColorMask[2] = writeColorB; + mCurrColorMask[3] = writeAlpha; + glColorMask(writeColorR, writeColorG, writeColorB, writeAlpha); } @@ -518,6 +726,9 @@ void LLRender::setSceneBlendType(eBlendType type) void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value) { flush(); + + mCurrAlphaFunc = func; + mCurrAlphaFuncVal = value; if (func == CF_DEFAULT) { glAlphaFunc(GL_GREATER, 0.01f); @@ -536,22 +747,38 @@ void LLRender::blendFunc(eBlendFactor sfactor, eBlendFactor dfactor) LLTexUnit* LLRender::getTexUnit(U32 index) { - if (index < mTexUnits.size()) + if ((index >= 0) && (index < mTexUnits.size())) { return mTexUnits[index]; } - llerrs << "Non-existing texture unit layer requested: " << index << llendl; - return NULL; + else + { + lldebugs << "Non-existing texture unit layer requested: " << index << llendl; + return mDummyTexUnit; + } +} + +bool LLRender::verifyTexUnitActive(U32 unitToVerify) +{ + if (mCurrTextureUnitIndex == unitToVerify) + { + return true; + } + else + { + llwarns << "TexUnit currently active: " << mCurrTextureUnitIndex << " (expecting " << unitToVerify << ")" << llendl; + return false; + } } void LLRender::begin(const GLuint& mode) { if (mode != mMode) { - if (mMode == LLVertexBuffer::QUADS || - mMode == LLVertexBuffer::LINES || - mMode == LLVertexBuffer::TRIANGLES || - mMode == LLVertexBuffer::POINTS) + if (mMode == LLRender::QUADS || + mMode == LLRender::LINES || + mMode == LLRender::TRIANGLES || + mMode == LLRender::POINTS) { flush(); } @@ -572,10 +799,10 @@ void LLRender::end() //IMM_ERRS << "GL begin and end called with no vertices specified." << llendl; } - if ((mMode != LLVertexBuffer::QUADS && - mMode != LLVertexBuffer::LINES && - mMode != LLVertexBuffer::TRIANGLES && - mMode != LLVertexBuffer::POINTS) || + if ((mMode != LLRender::QUADS && + mMode != LLRender::LINES && + mMode != LLRender::TRIANGLES && + mMode != LLRender::POINTS) || mCount > 2048) { flush(); @@ -638,7 +865,8 @@ void LLRender::flush() } void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z) { - if (mCount >= 4096) + //the range of mVerticesp, mColorsp and mTexcoordsp is [0, 4095] + if (mCount > 4094) { // llwarns << "GL immediate mode overflow. Some geometry not drawn." << llendl; return; @@ -720,3 +948,35 @@ void LLRender::color3fv(const GLfloat* c) color4f(c[0],c[1],c[2],1); } +void LLRender::debugTexUnits(void) +{ + LL_INFOS("TextureUnit") << "Active TexUnit: " << mCurrTextureUnitIndex << LL_ENDL; + std::string active_enabled = "false"; + for (U32 i = 0; i < mTexUnits.size(); i++) + { + if (getTexUnit(i)->mCurrTexType != LLTexUnit::TT_NONE) + { + if (i == mCurrTextureUnitIndex) active_enabled = "true"; + LL_INFOS("TextureUnit") << "TexUnit: " << i << " Enabled" << LL_ENDL; + LL_INFOS("TextureUnit") << "Enabled As: " ; + switch (getTexUnit(i)->mCurrTexType) + { + case LLTexUnit::TT_TEXTURE: + LL_CONT << "Texture 2D"; + break; + case LLTexUnit::TT_RECT_TEXTURE: + LL_CONT << "Texture Rectangle"; + break; + case LLTexUnit::TT_CUBE_MAP: + LL_CONT << "Cube Map"; + break; + default: + LL_CONT << "ARGH!!! NONE!"; + break; + } + LL_CONT << ", Texture Bound: " << getTexUnit(i)->mCurrTexture << LL_ENDL; + } + } + LL_INFOS("TextureUnit") << "Active TexUnit Enabled : " << active_enabled << LL_ENDL; +} + diff --git a/linden/indra/llrender/llrender.h b/linden/indra/llrender/llrender.h index 15360a3..8c648f3 100644 --- a/linden/indra/llrender/llrender.h +++ b/linden/indra/llrender/llrender.h @@ -37,14 +37,39 @@ #ifndef LL_LLGLRENDER_H #define LL_LLGLRENDER_H -#include "stdtypes.h" -#include "llgltypes.h" +//#include "linden_common.h" + +#include "v2math.h" +#include "v3math.h" +#include "v4coloru.h" +#include "llstrider.h" +#include "llmemory.h" #include "llglheaders.h" -#include "llvertexbuffer.h" + +class LLVertexBuffer; +class LLCubeMap; +class LLImageGL; +class LLRenderTarget; class LLTexUnit { + friend class LLRender; public: + 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_NONE // No texture type is currently enabled + } eTextureType; + + typedef enum + { + TAM_WRAP = 0, // Standard 2D Texture + TAM_MIRROR, // Non power of 2 texture + TAM_CLAMP // No texture type is currently enabled + } eTextureAddressMode; + typedef enum { TB_REPLACE = 0, @@ -93,15 +118,36 @@ public: TBS_ONE_MINUS_CONST_ALPHA } eTextureBlendSrc; - LLTexUnit(U32 index); - U32 getIndex(void); + LLTexUnit(S32 index); + + // Refreshes renderer state of the texture unit to the cached values + // Needed when the render context has changed and invalidated the current state + void refreshState(void); + + // returns the index of this texture unit + S32 getIndex(void) const { return mIndex; } - void enable(void); - void disable(void); - void activate(void); + // Sets this tex unit to be the currently active one + void activate(void); + + // Enables this texture unit for the given texture type (automatically disables any previously enabled texture type) + void enable(eTextureType type); + // Disables the current texture unit + void disable(void); + + // Binds the LLImageGL to this texture unit (automatically enables the unit for the LLImageGL's texture type) + bool bind(const LLImageGL* texture); + // Binds a cubemap to this texture unit (automatically enables the texture unit for cubemaps) + bool bind(LLCubeMap* cubeMap); + // Binds a render target to this texture unit (automatically enables the texture unit for the RT's texture type) + bool bind(LLRenderTarget * renderTarget, bool bindDepth = false); + // Manually binds a texture to the texture unit (automatically enables the tex unit for the given texture type) + bool bindManual(eTextureType type, U32 texture); + + // Unbinds the currently bound texture of the given type (only if there's a texture of the given type currently bound) + void unbind(eTextureType type); - void bindTexture(const LLImageGL* texture); - void unbindTexture(void); + void setTextureAddressMode(eTextureAddressMode mode); void setTextureBlendType(eTextureBlendType type); @@ -110,11 +156,14 @@ public: // NOTE: If *_COLOR enums are passed to src1 or src2, the corresponding *_ALPHA enum will be used instead. inline void setTextureAlphaBlend(eTextureBlendOp op, eTextureBlendSrc src1, eTextureBlendSrc src2 = TBS_PREV_ALPHA) - { setTextureCombiner(op, src1, src2, true); } + { setTextureCombiner(op, src1, src2, true); } -private: - U32 mIndex; - bool mIsEnabled; + static U32 getInternalType(eTextureType type); + +protected: + S32 mIndex; + U32 mCurrTexture; + eTextureType mCurrTexType; eTextureBlendType mCurrBlendType; eTextureBlendOp mCurrColorOp; eTextureBlendSrc mCurrColorSrc1; @@ -137,6 +186,19 @@ class LLRender { friend class LLTexUnit; public: + + typedef enum { + TRIANGLES = 0, + TRIANGLE_STRIP, + TRIANGLE_FAN, + POINTS, + LINES, + LINE_STRIP, + QUADS, + LINE_LOOP, + NUM_MODES + } eGeomModes; + typedef enum { CF_NEVER = 0, @@ -178,6 +240,10 @@ public: ~LLRender(); void shutdown(); + // Refreshes renderer state to the cached values + // Needed when the render context has changed and invalidated the current state + void refreshState(void); + void translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z); void scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z); void pushMatrix(); @@ -214,7 +280,13 @@ public: LLTexUnit* getTexUnit(U32 index); - typedef struct Vertex + U32 getCurrentTexUnitIndex(void) const { return mCurrTextureUnitIndex; } + + bool verifyTexUnitActive(U32 unitToVerify); + + void debugTexUnits(void); + + struct Vertex { GLfloat v[3]; GLubyte c[4]; @@ -224,14 +296,20 @@ public: public: private: - U32 mCount; - U32 mMode; - U32 mCurrTextureUnitIndex; - LLPointer mBuffer; - LLStrider mVerticesp; - LLStrider mTexcoordsp; - LLStrider mColorsp; - std::vector mTexUnits; + bool mDirty; + U32 mCount; + U32 mMode; + U32 mCurrTextureUnitIndex; + bool mCurrColorMask[4]; + eCompareFunc mCurrAlphaFunc; + F32 mCurrAlphaFuncVal; + + LLPointer mBuffer; + LLStrider mVerticesp; + LLStrider mTexcoordsp; + LLStrider mColorsp; + std::vector mTexUnits; + LLTexUnit* mDummyTexUnit; }; extern F64 gGLModelView[16]; diff --git a/linden/indra/llrender/llrendertarget.cpp b/linden/indra/llrender/llrendertarget.cpp index e18ec56..9d693a7 100644 --- a/linden/indra/llrender/llrendertarget.cpp +++ b/linden/indra/llrender/llrendertarget.cpp @@ -47,7 +47,7 @@ LLRenderTarget::LLRenderTarget() : mStencil(0), mUseDepth(FALSE), mRenderDepth(FALSE), - mUsage(GL_TEXTURE_2D) + mUsage(LLTexUnit::TT_TEXTURE) { } @@ -56,7 +56,7 @@ LLRenderTarget::~LLRenderTarget() release(); } -void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage, BOOL use_fbo) +void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, LLTexUnit::eTextureType usage, BOOL use_fbo) { stop_glerror(); mResX = resx; @@ -67,22 +67,22 @@ void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 release(); glGenTextures(1, (GLuint *) &mTex); - glBindTexture(mUsage, mTex); - glTexImage2D(mUsage, 0, color_fmt, mResX, mResY, 0, color_fmt, GL_UNSIGNED_BYTE, NULL); + gGL.getTexUnit(0)->bindManual(mUsage, mTex); + glTexImage2D(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, 0, color_fmt, GL_UNSIGNED_BYTE, NULL); - glTexParameteri(mUsage, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(mUsage, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_MIN_FILTER, GL_LINEAR); - if (mUsage != GL_TEXTURE_RECTANGLE_ARB) + if (mUsage != LLTexUnit::TT_RECT_TEXTURE) { - glTexParameteri(mUsage, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); - glTexParameteri(mUsage, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); + glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); + glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); } else { // ATI doesn't support mirrored repeat for rectangular textures. - glTexParameteri(mUsage, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(mUsage, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } stop_glerror(); @@ -107,14 +107,14 @@ void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 if (mDepth) { - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, mUsage, mDepth, 0); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, LLTexUnit::getInternalType(mUsage), mDepth, 0); stop_glerror(); - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, mUsage, mDepth, 0); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, LLTexUnit::getInternalType(mUsage), mDepth, 0); stop_glerror(); } glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - mUsage, mTex, 0); + LLTexUnit::getInternalType(mUsage), mTex, 0); stop_glerror(); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); @@ -125,10 +125,11 @@ void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 void LLRenderTarget::allocateDepth() { glGenTextures(1, (GLuint *) &mDepth); - glBindTexture(mUsage, mDepth); - glTexParameteri(mUsage, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(mUsage, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexImage2D(mUsage, 0, GL_DEPTH24_STENCIL8_EXT, mResX, mResY, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL); + gGL.getTexUnit(0)->bindManual(mUsage, mDepth); + U32 internal_type = LLTexUnit::getInternalType(mUsage); + glTexParameteri(internal_type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(internal_type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexImage2D(internal_type, 0, GL_DEPTH24_STENCIL8_EXT, mResX, mResY, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL); } void LLRenderTarget::release() @@ -191,24 +192,13 @@ void LLRenderTarget::clear() } } -void LLRenderTarget::bindTexture() -{ - glBindTexture(mUsage, mTex); -} - -void LLRenderTarget::bindDepth() -{ - glBindTexture(mUsage, mDepth); -} - - void LLRenderTarget::flush(BOOL fetch_depth) { gGL.flush(); if (!mFBO) { - bindTexture(); - glCopyTexSubImage2D(mUsage, 0, 0, 0, 0, 0, mResX, mResY); + gGL.getTexUnit(0)->bind(this); + glCopyTexSubImage2D(LLTexUnit::getInternalType(mUsage), 0, 0, 0, 0, 0, mResX, mResY); if (fetch_depth) { @@ -217,8 +207,8 @@ void LLRenderTarget::flush(BOOL fetch_depth) allocateDepth(); } - bindDepth(); - glCopyTexImage2D(mUsage, 0, GL_DEPTH24_STENCIL8_EXT, 0, 0, mResX, mResY, 0); + gGL.getTexUnit(0)->bind(this, true); + glCopyTexImage2D(LLTexUnit::getInternalType(mUsage), 0, GL_DEPTH24_STENCIL8_EXT, 0, 0, mResX, mResY, 0); } } else diff --git a/linden/indra/llrender/llrendertarget.h b/linden/indra/llrender/llrendertarget.h index 5e3c4d9..65bab8b 100644 --- a/linden/indra/llrender/llrendertarget.h +++ b/linden/indra/llrender/llrendertarget.h @@ -33,6 +33,7 @@ #define LL_LLRENDERTARGET_H #include "llgl.h" +#include "llrender.h" /* SAMPLE USAGE: @@ -53,7 +54,7 @@ ... //use target as a texture - target.bindTexture(); + gGL.getTexUnit(INDEX)->bind(&target); ... ... */ @@ -71,7 +72,7 @@ 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, U32 usage = GL_TEXTURE_2D, BOOL use_fbo = FALSE); + void allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, LLTexUnit::eTextureType usage = LLTexUnit::TT_TEXTURE, BOOL use_fbo = FALSE); //allocate a depth texture void allocateDepth(); @@ -100,11 +101,11 @@ public: //get Y resolution U32 getHeight() const { return mResY; } - //bind results of render for sampling - void bindTexture(); + LLTexUnit::eTextureType getUsage(void) const { return mUsage; } - //bind results of render for sampling depth buffer - void bindDepth(); + U32 getTexture(void) const { return mTex; } + + U32 getDepth(void) const { return mDepth; } //flush rendering operations //must be called when rendering is complete @@ -128,7 +129,7 @@ private: U32 mStencil; BOOL mUseDepth; BOOL mRenderDepth; - U32 mUsage; + LLTexUnit::eTextureType mUsage; }; diff --git a/linden/indra/llrender/llshadermgr.cpp b/linden/indra/llrender/llshadermgr.cpp index 4416775..d884c15 100644 --- a/linden/indra/llrender/llshadermgr.cpp +++ b/linden/indra/llrender/llshadermgr.cpp @@ -307,7 +307,7 @@ void LLShaderMgr::dumpObjectLog(GLhandleARB ret, BOOL warns) { LL_DEBUGS("ShaderLoading") << log << LL_ENDL; } -} + } } GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type) diff --git a/linden/indra/llrender/llvertexbuffer.cpp b/linden/indra/llrender/llvertexbuffer.cpp index 547663b..465c4ca 100644 --- a/linden/indra/llrender/llvertexbuffer.cpp +++ b/linden/indra/llrender/llvertexbuffer.cpp @@ -76,7 +76,7 @@ S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] = sizeof(LLVector4), // TYPE_CLOTHWEIGHT, }; -U32 LLVertexBuffer::sGLMode[LLVertexBuffer::NUM_MODES] = +U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] = { GL_TRIANGLES, GL_TRIANGLE_STRIP, @@ -187,7 +187,7 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi llerrs << "Wrong vertex buffer bound." << llendl; } - if (mode > NUM_MODES) + if (mode > LLRender::NUM_MODES) { llerrs << "Invalid draw mode: " << mode << llendl; return; @@ -216,7 +216,7 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const llerrs << "Wrong vertex buffer bound." << llendl; } - if (mode > NUM_MODES) + if (mode > LLRender::NUM_MODES) { llerrs << "Invalid draw mode: " << mode << llendl; return; @@ -240,7 +240,7 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const llerrs << "Wrong vertex buffer bound." << llendl; } - if (mode > NUM_MODES) + if (mode > LLRender::NUM_MODES) { llerrs << "Invalid draw mode: " << mode << llendl; return; diff --git a/linden/indra/llrender/llvertexbuffer.h b/linden/indra/llrender/llvertexbuffer.h index 8edcf69..a97c74e 100644 --- a/linden/indra/llrender/llvertexbuffer.h +++ b/linden/indra/llrender/llvertexbuffer.h @@ -39,6 +39,7 @@ #include "v4coloru.h" #include "llstrider.h" #include "llmemory.h" +#include "llrender.h" #include #include #include @@ -123,19 +124,8 @@ public: MAP_UNMAPPED = 0x8000 // Indicates that buffer has been logically un-mapped }; - enum { - TRIANGLES = 0, - TRIANGLE_STRIP, - TRIANGLE_FAN, - POINTS, - LINES, - LINE_STRIP, - QUADS, - LINE_LOOP, - NUM_MODES - }; protected: - friend class LLGLImmediate; + friend class LLRender; virtual ~LLVertexBuffer(); // use unref() @@ -255,7 +245,7 @@ public: static BOOL sEnableVBOs; static S32 sTypeOffsets[TYPE_MAX]; - static U32 sGLMode[NUM_MODES]; + static U32 sGLMode[LLRender::NUM_MODES]; static U32 sGLRenderBuffer; static U32 sGLRenderIndices; static BOOL sVBOActive; diff --git a/linden/indra/llui/llfloater.cpp b/linden/indra/llui/llfloater.cpp index 9f8cd65..047342f 100644 --- a/linden/indra/llui/llfloater.cpp +++ b/linden/indra/llui/llfloater.cpp @@ -127,6 +127,7 @@ LLFloaterView* gFloaterView = NULL; LLFloater::LLFloater() : //FIXME: we should initialize *all* member variables here + LLPanel(), mAutoFocus(TRUE), mResizable(FALSE), mDragOnLeft(FALSE), mMinWidth(0), @@ -139,6 +140,11 @@ LLFloater::LLFloater() : mButtonsEnabled[i] = FALSE; mButtons[i] = NULL; } + for (S32 i = 0; i < 4; i++) + { + mResizeBar[i] = NULL; + mResizeHandle[i] = NULL; + } mDragHandle = NULL; mHandle.bind(this); } @@ -151,6 +157,11 @@ LLFloater::LLFloater(const std::string& name) mButtonsEnabled[i] = FALSE; mButtons[i] = NULL; } + for (S32 i = 0; i < 4; i++) + { + mResizeBar[i] = NULL; + mResizeHandle[i] = NULL; + } std::string title; // null string initFloater(title, FALSE, DEFAULT_MIN_WIDTH, DEFAULT_MIN_HEIGHT, FALSE, TRUE, TRUE); // defaults } @@ -171,6 +182,11 @@ LLFloater::LLFloater(const std::string& name, const LLRect& rect, const std::str mButtonsEnabled[i] = FALSE; mButtons[i] = NULL; } + for (S32 i = 0; i < 4; i++) + { + mResizeBar[i] = NULL; + mResizeHandle[i] = NULL; + } initFloater( title, resizable, min_width, min_height, drag_on_left, minimizable, close_btn); } @@ -189,6 +205,11 @@ LLFloater::LLFloater(const std::string& name, const std::string& rect_control, c mButtonsEnabled[i] = FALSE; mButtons[i] = NULL; } + for (S32 i = 0; i < 4; i++) + { + mResizeBar[i] = NULL; + mResizeHandle[i] = NULL; + } initFloater( title, resizable, min_width, min_height, drag_on_left, minimizable, close_btn); } @@ -1580,6 +1601,7 @@ void LLFloater::updateButtons() S32 button_count = 0; for (S32 i = 0; i < BUTTON_COUNT; i++) { + if(!mButtons[i]) continue; mButtons[i]->setEnabled(mButtonsEnabled[i]); if (mButtonsEnabled[i] diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp index 12d1929..a0af463 100644 --- a/linden/indra/llui/lllineeditor.cpp +++ b/linden/indra/llui/lllineeditor.cpp @@ -35,6 +35,7 @@ #include "lllineeditor.h" +#include "lltexteditor.h" #include "audioengine.h" #include "llmath.h" #include "llfontgl.h" @@ -450,19 +451,19 @@ BOOL LLLineEditor::handleDoubleClick(S32 x, S32 y, MASK mask) BOOL doSelectAll = TRUE; // Select the word we're on - if( isPartOfWord( wtext[mCursorPos] ) ) + if( LLTextEditor::isPartOfWord( wtext[mCursorPos] ) ) { S32 old_selection_start = mLastSelectionStart; S32 old_selection_end = mLastSelectionEnd; // Select word the cursor is over - while ((mCursorPos > 0) && isPartOfWord( wtext[mCursorPos-1] )) + while ((mCursorPos > 0) && LLTextEditor::isPartOfWord( wtext[mCursorPos-1] )) { // Find the start of the word mCursorPos--; } startSelection(); - while ((mCursorPos < (S32)wtext.length()) && isPartOfWord( wtext[mCursorPos] ) ) + while ((mCursorPos < (S32)wtext.length()) && LLTextEditor::isPartOfWord( wtext[mCursorPos] ) ) { // Find the end of the word mCursorPos++; } @@ -764,7 +765,7 @@ S32 LLLineEditor::prevWordPos(S32 cursorPos) const { cursorPos--; } - while( (cursorPos > 0) && isPartOfWord( wtext[cursorPos-1] ) ) + while( (cursorPos > 0) && LLTextEditor::isPartOfWord( wtext[cursorPos-1] ) ) { cursorPos--; } @@ -774,7 +775,7 @@ S32 LLLineEditor::prevWordPos(S32 cursorPos) const S32 LLLineEditor::nextWordPos(S32 cursorPos) const { const LLWString& wtext = mText.getWString(); - while( (cursorPos < getLength()) && isPartOfWord( wtext[cursorPos] ) ) + while( (cursorPos < getLength()) && LLTextEditor::isPartOfWord( wtext[cursorPos] ) ) { cursorPos++; } @@ -1422,7 +1423,7 @@ void LLLineEditor::draw() #else // the old programmer art. // drawing solids requires texturing be disabled { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // draw background for text if( !mReadOnly ) { @@ -1817,9 +1818,6 @@ BOOL LLLineEditor::prevalidateFloat(const LLWString &str) return success; } -//static -BOOL LLLineEditor::isPartOfWord(llwchar c) { return (c == '_') || isalnum(c); } - // static BOOL LLLineEditor::postvalidateFloat(const std::string &str) { @@ -1993,7 +1991,7 @@ BOOL LLLineEditor::prevalidateAlphaNum(const LLWString &str) if(len == 0) return rv; while(len--) { - if( !isalnum(str[len]) ) + if( !LLStringOps::isAlnum((char)str[len]) ) { rv = FALSE; break; @@ -2012,7 +2010,7 @@ BOOL LLLineEditor::prevalidateAlphaNumSpace(const LLWString &str) if(len == 0) return rv; while(len--) { - if(!(isalnum(str[len]) || (' ' == str[len]))) + if(!(LLStringOps::isAlnum((char)str[len]) || (' ' == str[len]))) { rv = FALSE; break; @@ -2034,7 +2032,7 @@ BOOL LLLineEditor::prevalidatePrintableNotPipe(const LLWString &str) rv = FALSE; break; } - if(!((' ' == str[len]) || isalnum(str[len]) || ispunct(str[len]))) + if(!((' ' == str[len]) || LLStringOps::isAlnum((char)str[len]) || LLStringOps::isPunct((char)str[len]))) { rv = FALSE; break; @@ -2052,12 +2050,13 @@ BOOL LLLineEditor::prevalidatePrintableNoSpace(const LLWString &str) if(len == 0) return rv; while(len--) { - if(iswspace(str[len])) + if(LLStringOps::isSpace(str[len])) { rv = FALSE; break; } - if( !(isalnum(str[len]) || ispunct(str[len]) ) ) + if( !(LLStringOps::isAlnum((char)str[len]) || + LLStringOps::isPunct((char)str[len]) ) ) { rv = FALSE; break; @@ -2282,7 +2281,7 @@ LLView* LLLineEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory } //static -void LLLineEditor::cleanupClass() +void LLLineEditor::cleanupLineEditor() { sImage = NULL; } diff --git a/linden/indra/llui/lllineeditor.h b/linden/indra/llui/lllineeditor.h index 09a240b..bc9e406 100644 --- a/linden/indra/llui/lllineeditor.h +++ b/linden/indra/llui/lllineeditor.h @@ -82,7 +82,7 @@ public: virtual LLXMLNodePtr getXML(bool save_children = true) const; void setColorParameters(LLXMLNodePtr node); static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); - static void cleanupClass(); + static void cleanupLineEditor(); // mousehandler overrides /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); @@ -194,7 +194,6 @@ public: void setMaxTextLength(S32 max_text_length); void setTextPadding(S32 left, S32 right); // Used to specify room for children before or after text. - static BOOL isPartOfWord(llwchar c); // Prevalidation controls which keystrokes can affect the editor void setPrevalidate( BOOL (*func)(const LLWString &) ); static BOOL prevalidateFloat(const LLWString &str ); diff --git a/linden/indra/llui/llmenugl.cpp b/linden/indra/llui/llmenugl.cpp index 24cc47e..4766267 100644 --- a/linden/indra/llui/llmenugl.cpp +++ b/linden/indra/llui/llmenugl.cpp @@ -1309,6 +1309,7 @@ void LLMenuItemBranchGL::openMenu() } mBranch->translate( delta_x, delta_y ); mBranch->setVisible( TRUE ); + mBranch->getParent()->sendChildToFront(mBranch); } } @@ -1427,6 +1428,7 @@ void LLMenuItemBranchDownGL::openMenu( void ) setHighlight(TRUE); branch->setVisible( TRUE ); + branch->getParent()->sendChildToFront(branch); } } } @@ -2958,6 +2960,7 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y) } menu->translate( delta_x, delta_y ); menu->setVisible( TRUE ); + menu->getParent()->sendChildToFront(menu); } //----------------------------------------------------------------------------- diff --git a/linden/indra/llui/llmultislider.cpp b/linden/indra/llui/llmultislider.cpp index 227cf98..11c2cba 100644 --- a/linden/indra/llui/llmultislider.cpp +++ b/linden/indra/llui/llmultislider.cpp @@ -431,7 +431,7 @@ void LLMultiSlider::draw() // Draw background and thumb. // drawing solids requires texturing be disabled - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLRect rect(mDragStartThumbRect); diff --git a/linden/indra/llui/llscrollcontainer.cpp b/linden/indra/llui/llscrollcontainer.cpp index 1ba2923..51face6 100644 --- a/linden/indra/llui/llscrollcontainer.cpp +++ b/linden/indra/llui/llscrollcontainer.cpp @@ -425,7 +425,7 @@ void LLScrollableContainerView::draw() // Draw background if( mIsOpaque ) { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4fv( mBackgroundColor.mV ); gl_rect_2d( mInnerRect ); } diff --git a/linden/indra/llui/llscrolllistctrl.cpp b/linden/indra/llui/llscrolllistctrl.cpp index d342378..92bcb88 100644 --- a/linden/indra/llui/llscrolllistctrl.cpp +++ b/linden/indra/llui/llscrolllistctrl.cpp @@ -435,7 +435,7 @@ void LLScrollListItem::draw(const LLRect& rect, const LLColor4& fg_color, const // draw background rect LLRect bg_rect = rect; { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4fv(bg_color.mV); gl_rect_2d( bg_rect ); } @@ -1758,7 +1758,7 @@ void LLScrollListCtrl::draw() // Draw background if (mBackgroundVisible) { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4fv( getEnabled() ? mBgWriteableColor.mV : mBgReadOnlyColor.mV ); gl_rect_2d(background); } diff --git a/linden/indra/llui/llslider.cpp b/linden/indra/llui/llslider.cpp index 4cc558f..b2438af 100644 --- a/linden/indra/llui/llslider.cpp +++ b/linden/indra/llui/llslider.cpp @@ -253,7 +253,7 @@ void LLSlider::draw() // Draw background and thumb. // drawing solids requires texturing be disabled - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); F32 opacity = getEnabled() ? 1.f : 0.3f; LLColor4 center_color = (mThumbCenterColor % opacity); diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index e56002f..281dbe4 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp @@ -260,7 +260,7 @@ LLTextEditor::LLTextEditor( mIsSelecting( FALSE ), mSelectionStart( 0 ), mSelectionEnd( 0 ), - mScrolledToBottom( FALSE ), + mScrolledToBottom( TRUE ), mOnScrollEndCallback( NULL ), mOnScrollEndData( NULL ), mCursorColor( LLUI::sColorsGroup->getColor( "TextCursorColor" ) ), @@ -277,14 +277,16 @@ LLTextEditor::LLTextEditor( mCommitOnFocusLost( FALSE ), mHideScrollbarForShortDocs( FALSE ), mTakesNonScrollClicks( TRUE ), - mTrackBottom( TRUE ), + mTrackBottom( FALSE ), mAllowEmbeddedItems( allow_embedded_items ), mAcceptCallingCardNames(FALSE), mHandleEditKeysDirectly( FALSE ), mMouseDownX(0), mMouseDownY(0), mLastSelectionX(-1), - mLastSelectionY(-1) + mLastSelectionY(-1), + mReflowNeeded(FALSE), + mScrollNeeded(FALSE) { mSourceID.generate(); @@ -468,6 +470,13 @@ void LLTextEditor::updateLineStartList(S32 startpos) mScrollbar->setVisible(!short_doc); } + // if scrolled to bottom, stay at bottom + // unless user is editing text + // do this after updating page size + if (mScrolledToBottom && mTrackBottom && !hasFocus()) + { + endOfDoc(); + } } //////////////////////////////////////////////////////////// @@ -511,8 +520,7 @@ void LLTextEditor::setText(const LLStringExplicit &utf8str) setCursorPos(0); deselect(); - updateLineStartList(); - updateScrollFromCursor(); + needsReflow(); resetDirty(); } @@ -529,8 +537,7 @@ void LLTextEditor::setWText(const LLWString &wtext) setCursorPos(0); deselect(); - updateLineStartList(); - updateScrollFromCursor(); + needsReflow(); resetDirty(); } @@ -568,8 +575,7 @@ void LLTextEditor::setWordWrap(BOOL b) setCursorPos(0); deselect(); - updateLineStartList(); - updateScrollFromCursor(); + needsReflow(); } @@ -734,6 +740,7 @@ S32 LLTextEditor::getLineStart( S32 line ) const { return 0; } + line = llclamp(line, 0, num_lines-1); S32 segidx = mLineStartList[line].mSegment; S32 segoffset = mLineStartList[line].mOffset; @@ -781,14 +788,14 @@ void LLTextEditor::getSegmentAndOffset( S32 startpos, S32* segidxp, S32* offsetp *offsetp = startpos - (*seg_iter)->getStart(); } -const LLTextSegment* LLTextEditor::getPreviousSegment() +const LLTextSegment* LLTextEditor::getPreviousSegment() const { // find segment index at character to left of cursor (or rightmost edge of selection) S32 idx = llmax(0, getSegmentIdxAtOffset(mCursorPos) - 1); return idx >= 0 ? mSegments[idx] : NULL; } -void LLTextEditor::getSelectedSegments(std::vector& segments) +void LLTextEditor::getSelectedSegments(std::vector& segments) const { S32 left = hasSelection() ? llmin(mSelectionStart, mSelectionEnd) : mCursorPos; S32 right = hasSelection() ? llmax(mSelectionStart, mSelectionEnd) : mCursorPos; @@ -875,13 +882,12 @@ void LLTextEditor::setCursor(S32 row, S32 column) } doc += column; setCursorPos(doc - mWText.c_str()); - updateScrollFromCursor(); } void LLTextEditor::setCursorPos(S32 offset) { mCursorPos = llclamp(offset, 0, (S32)getLength()); - updateScrollFromCursor(); + needsScroll(); // reset desired x cursor position mDesiredXPixel = -1; } @@ -1222,8 +1228,6 @@ BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) setCursorAtLocalPos( x, y, TRUE ); mSelectionEnd = mCursorPos; - - updateScrollFromCursor(); } lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl; @@ -1317,8 +1321,6 @@ BOOL LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask) setCursorAtLocalPos( x, y, TRUE ); endSelection(); - - updateScrollFromCursor(); } if( !hasSelection() ) @@ -1839,8 +1841,7 @@ void LLTextEditor::cut() gClipboard.copyFromSubstring( mWText, left_pos, length, mSourceID ); deleteSelection( FALSE ); - updateLineStartList(); - updateScrollFromCursor(); + needsReflow(); } BOOL LLTextEditor::canCopy() const @@ -1910,8 +1911,7 @@ void LLTextEditor::paste() setCursorPos(mCursorPos + insert(mCursorPos, clean_string, FALSE)); deselect(); - updateLineStartList(); - updateScrollFromCursor(); + needsReflow(); } @@ -2235,9 +2235,9 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask ) if(text_may_have_changed) { - updateLineStartList(); + needsReflow(); } - updateScrollFromCursor(); + needsScroll(); } } @@ -2280,8 +2280,7 @@ BOOL LLTextEditor::handleUnicodeCharHere(llwchar uni_char) // Most keystrokes will make the selection box go away, but not all will. deselect(); - updateLineStartList(); - updateScrollFromCursor(); + needsReflow(); } } @@ -2339,8 +2338,7 @@ void LLTextEditor::doDelete() } } - updateLineStartList(); - updateScrollFromCursor(); + needsReflow(); } //---------------------------------------------------------------------------- @@ -2383,8 +2381,7 @@ void LLTextEditor::undo() setCursorPos(pos); - updateLineStartList(); - updateScrollFromCursor(); + needsReflow(); } BOOL LLTextEditor::canRedo() const @@ -2426,8 +2423,7 @@ void LLTextEditor::redo() setCursorPos(pos); - updateLineStartList(); - updateScrollFromCursor(); + needsReflow(); } void LLTextEditor::onFocusReceived() @@ -2594,7 +2590,7 @@ void LLTextEditor::drawSelectionBackground() BOOL selection_visible = (left_visible_pos <= selection_right) && (selection_left <= right_visible_pos); if( selection_visible ) { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); const LLColor4& color = mReadOnly ? mReadOnlyBgColor : mWriteableBgColor; F32 alpha = hasFocus() ? 1.f : 0.5f; gGL.color4f( 1.f - color.mV[0], 1.f - color.mV[1], 1.f - color.mV[2], alpha ); @@ -2729,7 +2725,7 @@ void LLTextEditor::drawCursor() } } - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4fv( mCursorColor.mV ); @@ -3100,6 +3096,20 @@ void LLTextEditor::drawClippedSegment(const LLWString &text, S32 seg_start, S32 void LLTextEditor::draw() { + // do on-demand reflow + if (mReflowNeeded) + { + updateLineStartList(); + mReflowNeeded = FALSE; + } + + // then update scroll position, as cursor may have moved + if (mScrollNeeded) + { + updateScrollFromCursor(); + mScrollNeeded = FALSE; + } + { LLLocalClipRect clip(LLRect(0, getRect().getHeight(), getRect().getWidth() - (mScrollbar->getVisible() ? SCROLLBAR_SIZE : 0), 0)); @@ -3118,10 +3128,10 @@ void LLTextEditor::draw() mBorder->setKeyboardFocusHighlight( gFocusMgr.getKeyboardFocus() == this);// && !mReadOnly); } + LLView::draw(); // Draw children (scrollbar and border) + // remember if we are supposed to be at the bottom of the buffer mScrolledToBottom = isScrolledToBottom(); - - LLView::draw(); // Draw children (scrollbar and border) } @@ -3311,7 +3321,7 @@ void LLTextEditor::setCursorAndScrollToEnd() { deselect(); endOfDoc(); - updateScrollFromCursor(); + needsScroll(); } void LLTextEditor::getLineAndColumnForPosition( S32 position, S32* line, S32* col, BOOL include_wordwrap ) @@ -3438,7 +3448,7 @@ void LLTextEditor::reshape(S32 width, S32 height, BOOL called_from_parent) // up-to-date mTextRect updateTextRect(); - updateLineStartList(); + needsReflow(); // propagate shape information to scrollbar mScrollbar->setDocSize( getLineCount() ); @@ -3446,14 +3456,6 @@ void LLTextEditor::reshape(S32 width, S32 height, BOOL called_from_parent) S32 line_height = llround( mGLFont->getLineHeight() ); S32 page_lines = mTextRect.getHeight() / line_height; mScrollbar->setPageSize( page_lines ); - - // if scrolled to bottom, stay at bottom - // unless user is editing text - // do this after updating page size - if (mScrolledToBottom && mTrackBottom && !hasFocus()) - { - endOfDoc(); - } } void LLTextEditor::autoIndent() @@ -3500,8 +3502,7 @@ void LLTextEditor::insertText(const std::string &new_text) setCursorPos(mCursorPos + insert( mCursorPos, utf8str_to_wstring(new_text), FALSE )); - updateLineStartList(); - updateScrollFromCursor(); + needsReflow(); setEnabled( enabled ); } @@ -3600,7 +3601,7 @@ void LLTextEditor::appendText(const std::string &new_text, bool allow_undo, bool mSegments.push_back(segment); } - updateLineStartList(old_length); + needsReflow(); // Set the cursor and scroll position // Maintain the scroll position unless the scroll was at the end of the doc (in which @@ -3639,14 +3640,6 @@ void LLTextEditor::appendText(const std::string &new_text, bool allow_undo, bool { blockUndo(); } - - // if scrolled to bottom, stay at bottom - // unless user is editing text - // do this after updating page size - if (mScrolledToBottom && mTrackBottom && !hasFocus()) - { - endOfDoc(); - } } void LLTextEditor::removeTextFromEnd(S32 num_chars) @@ -3661,7 +3654,10 @@ void LLTextEditor::removeTextFromEnd(S32 num_chars) mSelectionEnd = llclamp(mSelectionEnd, 0, len); pruneSegments(); + + // pruneSegments will invalidate mLineStartList. updateLineStartList(); + needsScroll(); } /////////////////////////////////////////////////////////////////// @@ -3759,8 +3755,7 @@ BOOL LLTextEditor::tryToRevertToPristineState() } } - updateLineStartList(); - updateScrollFromCursor(); + needsReflow(); } return isPristine(); // TRUE => success @@ -3808,6 +3803,7 @@ void LLTextEditor::updateSegments() { findEmbeddedItemSegments(); } + // Make sure we have at least one segment if (mSegments.size() == 1 && mSegments[0]->getIsDefault()) { @@ -3824,6 +3820,7 @@ void LLTextEditor::updateSegments() } // Only effective if text was removed from the end of the editor +// *NOTE: Using this will invalidate references to mSegments from mLineStartList. void LLTextEditor::pruneSegments() { S32 len = mWText.length(); @@ -4066,9 +4063,7 @@ BOOL LLTextEditor::importBuffer(const char* buffer, S32 length ) setCursorPos(0); deselect(); - updateLineStartList(); - updateScrollFromCursor(); - + needsReflow(); return success; } @@ -4260,35 +4255,35 @@ S32 LLTextEditor::findHTMLToken(const std::string &line, S32 pos, BOOL reverse) std::string openers=" \t\n('\"[{<>"; std::string closers=" \t\n)'\"]}><;"; - S32 m2 = 0; - S32 retval = 0; + S32 index = 0; if (reverse) { - - for (retval=pos; retval >= 0; retval--) + for (index=pos; index >= 0; index--) { - m2 = openers.find(line.substr(retval,1)); + char c = line[index]; + S32 m2 = openers.find(c); if (m2 >= 0) { - break; + return index+1; } } - return retval+1; } else { - for (retval=pos; retval<(S32)line.length(); retval++) + for (index=pos; index<(S32)line.length(); index++) { - m2 = closers.find(line.substr(retval,1)); + char c = line[index]; + S32 m2 = closers.find(c); if (m2 >= 0) { - break; + return index; } } - return retval; - } + } + + return index; } BOOL LLTextEditor::findHTML(const std::string &line, S32 *begin, S32 *end) const @@ -4476,9 +4471,8 @@ void LLTextEditor::updatePreedit(const LLWString &preedit_string, mPreeditStandouts = preedit_standouts; - updateLineStartList(); + needsReflow(); setCursorPos(insert_preedit_at + caret_position); - // updateScrollFromCursor(); // Update of the preedit should be caused by some key strokes. mKeystrokeTimer.reset(); diff --git a/linden/indra/llui/lltexteditor.h b/linden/indra/llui/lltexteditor.h index 3cff91d..3604cf6 100644 --- a/linden/indra/llui/lltexteditor.h +++ b/linden/indra/llui/lltexteditor.h @@ -245,9 +245,11 @@ public: llwchar getWChar(S32 pos) const { return mWText[pos]; } LLWString getWSubString(S32 pos, S32 len) const { return mWText.substr(pos, len); } - const LLTextSegment* getCurrentSegment() { return getSegmentAtOffset(mCursorPos); } - const LLTextSegment* getPreviousSegment(); - void getSelectedSegments(std::vector& segments); + const LLTextSegment* getCurrentSegment() const { return getSegmentAtOffset(mCursorPos); } + const LLTextSegment* getPreviousSegment() const; + void getSelectedSegments(std::vector& segments) const; + + static bool isPartOfWord(llwchar c) { return (c == '_') || LLStringOps::isAlnum((char)c); } protected: // @@ -266,8 +268,6 @@ protected: void assignEmbedded(const std::string &s); BOOL truncate(); // Returns true if truncation occurs - static BOOL isPartOfWord(llwchar c) { return (c == '_') || isalnum(c); } - void removeCharOrTab(); void setCursorAtLocalPos(S32 x, S32 y, BOOL round); S32 getCursorPosFromLocalCoord( S32 local_x, S32 local_y, BOOL round ) const; @@ -433,6 +433,14 @@ private: void drawText(); void drawClippedSegment(const LLWString &wtext, S32 seg_start, S32 seg_end, F32 x, F32 y, S32 selection_left, S32 selection_right, const LLStyleSP& color, F32* right_x); + void needsReflow() + { + mReflowNeeded = TRUE; + // cursor might have moved, need to scroll + mScrollNeeded = TRUE; + } + void needsScroll() { mScrollNeeded = TRUE; } + // // Data // @@ -489,6 +497,8 @@ private: }; typedef std::vector line_list_t; line_list_t mLineStartList; + BOOL mReflowNeeded; + BOOL mScrollNeeded; LLFrameTimer mKeystrokeTimer; diff --git a/linden/indra/llui/llui.cpp b/linden/indra/llui/llui.cpp index 734aecf..5502246 100644 --- a/linden/indra/llui/llui.cpp +++ b/linden/indra/llui/llui.cpp @@ -143,11 +143,11 @@ void gl_state_for_2d(S32 width, S32 height) void gl_draw_x(const LLRect& rect, const LLColor4& color) { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4fv( color.mV ); - gGL.begin( LLVertexBuffer::LINES ); + gGL.begin( LLRender::LINES ); gGL.vertex2i( rect.mLeft, rect.mTop ); gGL.vertex2i( rect.mRight, rect.mBottom ); gGL.vertex2i( rect.mLeft, rect.mBottom ); @@ -183,12 +183,12 @@ void gl_rect_2d_offset_local( S32 left, S32 top, S32 right, S32 bottom, S32 pixe void gl_rect_2d(S32 left, S32 top, S32 right, S32 bottom, BOOL filled ) { stop_glerror(); - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // Counterclockwise quad will face the viewer if( filled ) { - gGL.begin( LLVertexBuffer::QUADS ); + gGL.begin( LLRender::QUADS ); gGL.vertex2i(left, top); gGL.vertex2i(left, bottom); gGL.vertex2i(right, bottom); @@ -200,7 +200,7 @@ void gl_rect_2d(S32 left, S32 top, S32 right, S32 bottom, BOOL filled ) if( gGLManager.mATIOffsetVerticalLines ) { // Work around bug in ATI driver: vertical lines are offset by (-1,-1) - gGL.begin( LLVertexBuffer::LINES ); + gGL.begin( LLRender::LINES ); // Verticals gGL.vertex2i(left + 1, top); @@ -223,7 +223,7 @@ void gl_rect_2d(S32 left, S32 top, S32 right, S32 bottom, BOOL filled ) { top--; right--; - gGL.begin( LLVertexBuffer::LINE_STRIP ); + gGL.begin( LLRender::LINE_STRIP ); gGL.vertex2i(left, top); gGL.vertex2i(left, bottom); gGL.vertex2i(right, bottom); @@ -254,7 +254,7 @@ void gl_rect_2d( const LLRect& rect, const LLColor4& color, BOOL filled ) void gl_drop_shadow(S32 left, S32 top, S32 right, S32 bottom, const LLColor4 &start_color, S32 lines) { stop_glerror(); - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // HACK: Overlap with the rectangle by a single pixel. right--; @@ -264,7 +264,7 @@ void gl_drop_shadow(S32 left, S32 top, S32 right, S32 bottom, const LLColor4 &st LLColor4 end_color = start_color; end_color.mV[VALPHA] = 0.f; - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); // Right edge, CCW faces screen gGL.color4fv(start_color.mV); @@ -324,9 +324,9 @@ void gl_line_2d(S32 x1, S32 y1, S32 x2, S32 y2 ) y2++; } - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); gGL.vertex2i(x1, y1); gGL.vertex2i(x2, y2); gGL.end(); @@ -343,11 +343,11 @@ void gl_line_2d(S32 x1, S32 y1, S32 x2, S32 y2, const LLColor4 &color ) y2++; } - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4fv( color.mV ); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); gGL.vertex2i(x1, y1); gGL.vertex2i(x2, y2); gGL.end(); @@ -355,17 +355,17 @@ void gl_line_2d(S32 x1, S32 y1, S32 x2, S32 y2, const LLColor4 &color ) void gl_triangle_2d(S32 x1, S32 y1, S32 x2, S32 y2, S32 x3, S32 y3, const LLColor4& color, BOOL filled) { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4fv(color.mV); if (filled) { - gGL.begin(LLVertexBuffer::TRIANGLES); + gGL.begin(LLRender::TRIANGLES); } else { - gGL.begin(LLVertexBuffer::LINE_LOOP); + gGL.begin(LLRender::LINE_LOOP); } gGL.vertex2i(x1, y1); gGL.vertex2i(x2, y2); @@ -375,11 +375,11 @@ void gl_triangle_2d(S32 x1, S32 y1, S32 x2, S32 y2, S32 x3, S32 y3, const LLColo void gl_corners_2d(S32 left, S32 top, S32 right, S32 bottom, S32 length, F32 max_frac) { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); length = llmin((S32)(max_frac*(right - left)), length); length = llmin((S32)(max_frac*(top - bottom)), length); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); gGL.vertex2i(left, top); gGL.vertex2i(left + length, top); @@ -496,11 +496,11 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLIma { gGL.translatef((F32)x, (F32)y, 0.f); - image->bind(); + gGL.getTexUnit(0)->bind(image); gGL.color4fv(color.mV); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { // draw bottom left gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom); @@ -656,11 +656,11 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre gGL.translatef( -offset_x, -offset_y, 0.f ); } - image->bind(); + gGL.getTexUnit(0)->bind(image); gGL.color4fv(color.mV); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop); gGL.vertex2i(width, height ); @@ -694,11 +694,11 @@ void gl_draw_scaled_image_inverted(S32 x, S32 y, S32 width, S32 height, LLImageG { gGL.translatef((F32)x, (F32)y, 0.f); - image->bind(); + gGL.getTexUnit(0)->bind(image); gGL.color4fv(color.mV); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom); gGL.vertex2i(width, height ); @@ -733,7 +733,7 @@ void gl_stippled_line_3d( const LLVector3& start, const LLVector3& end, const LL glLineWidth(2.5f); glLineStipple(2, 0x3333 << shift); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { gGL.vertex3fv( start.mV ); gGL.vertex3fv( end.mV ); @@ -750,7 +750,7 @@ void gl_rect_2d_xor(S32 left, S32 top, S32 right, S32 bottom) glLogicOp( GL_XOR ); stop_glerror(); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); gGL.vertex2i(left, top); gGL.vertex2i(left, bottom); gGL.vertex2i(right, bottom); @@ -782,14 +782,14 @@ void gl_arc_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled, F if (filled) { - gGL.begin(LLVertexBuffer::TRIANGLE_FAN); + gGL.begin(LLRender::TRIANGLE_FAN); gGL.vertex2f(0.f, 0.f); // make sure circle is complete steps += 1; } else { - gGL.begin(LLVertexBuffer::LINE_STRIP); + gGL.begin(LLRender::LINE_STRIP); } while( steps-- ) @@ -809,7 +809,7 @@ void gl_circle_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled { gGL.pushMatrix(); { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.translatef(center_x, center_y, 0.f); // Inexact, but reasonably fast. @@ -821,14 +821,14 @@ void gl_circle_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled if (filled) { - gGL.begin(LLVertexBuffer::TRIANGLE_FAN); + gGL.begin(LLRender::TRIANGLE_FAN); gGL.vertex2f(0.f, 0.f); // make sure circle is complete steps += 1; } else { - gGL.begin(LLVertexBuffer::LINE_LOOP); + gGL.begin(LLRender::LINE_LOOP); } while( steps-- ) @@ -850,7 +850,7 @@ void gl_deep_circle( F32 radius, F32 depth, S32 steps ) F32 x = radius; F32 y = 0.f; F32 angle_delta = F_TWO_PI / (F32)steps; - gGL.begin( LLVertexBuffer::TRIANGLE_STRIP ); + gGL.begin( LLRender::TRIANGLE_STRIP ); { S32 step = steps + 1; // An extra step to close the circle. while( step-- ) @@ -905,7 +905,7 @@ void gl_rect_2d_checkerboard(const LLRect& rect) first = FALSE; } - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // ...white squares gGL.color3f( 1.f, 1.f, 1.f ); @@ -935,9 +935,9 @@ void gl_washer_2d(F32 outer_radius, F32 inner_radius, S32 steps, const LLColor4& F32 x2 = inner_radius; F32 y2 = 0.f; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.begin( LLVertexBuffer::TRIANGLE_STRIP ); + gGL.begin( LLRender::TRIANGLE_STRIP ); { steps += 1; // An extra step to close the circle. while( steps-- ) @@ -972,8 +972,8 @@ void gl_washer_segment_2d(F32 outer_radius, F32 inner_radius, F32 start_radians, F32 x2 = inner_radius * cos( start_radians ); F32 y2 = inner_radius * sin( start_radians ); - LLGLSNoTexture gls_no_texture; - gGL.begin( LLVertexBuffer::TRIANGLE_STRIP ); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.begin( LLRender::TRIANGLE_STRIP ); { steps += 1; // An extra step to close the circle. while( steps-- ) @@ -1008,9 +1008,9 @@ void gl_washer_spokes_2d(F32 outer_radius, F32 inner_radius, S32 count, const LL F32 x2 = inner_radius * cos( HALF_DELTA ); F32 y2 = inner_radius * sin( HALF_DELTA ); - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.begin( LLVertexBuffer::LINES ); + gGL.begin( LLRender::LINES ); { while( count-- ) { @@ -1033,7 +1033,7 @@ void gl_washer_spokes_2d(F32 outer_radius, F32 inner_radius, S32 count, const LL void gl_rect_2d_simple_tex( S32 width, S32 height ) { - gGL.begin( LLVertexBuffer::QUADS ); + gGL.begin( LLRender::QUADS ); gGL.texCoord2f(1.f, 1.f); gGL.vertex2i(width, height); @@ -1052,7 +1052,7 @@ void gl_rect_2d_simple_tex( S32 width, S32 height ) void gl_rect_2d_simple( S32 width, S32 height ) { - gGL.begin( LLVertexBuffer::QUADS ); + gGL.begin( LLRender::QUADS ); gGL.vertex2i(width, height); gGL.vertex2i(0, height); gGL.vertex2i(0, 0); @@ -1094,7 +1094,7 @@ void gl_segmented_rect_2d_tex(const S32 left, LLVector2 width_vec((F32)width, 0.f); LLVector2 height_vec(0.f, (F32)height); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { // draw bottom left gGL.texCoord2f(0.f, 0.f); @@ -1262,7 +1262,7 @@ void gl_segmented_rect_2d_fragment_tex(const S32 left, LLVector2 x_min; LLVector2 x_max; - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { if (start_fragment < middle_start) { @@ -1419,7 +1419,7 @@ void gl_segmented_rect_3d_tex(const LLVector2& border_scale, const LLVector3& bo LLVector3 bottom_border_height = ((edges & (~(U32)ROUNDED_RECT_TOP)) != 0) ? border_height : LLVector3::zero; - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { // draw bottom left gGL.texCoord2f(0.f, 0.f); @@ -1575,7 +1575,7 @@ void LLUI::initClass(LLControlGroup* config, void LLUI::cleanupClass() { sImageProvider->cleanUp(); - LLLineEditor::cleanupClass(); + LLLineEditor::cleanupLineEditor(); } diff --git a/linden/indra/llui/llview.cpp b/linden/indra/llui/llview.cpp index 034c49b..bc6fe7e 100644 --- a/linden/indra/llui/llview.cpp +++ b/linden/indra/llui/llview.cpp @@ -1281,7 +1281,7 @@ void LLView::drawDebugRect() LLUI::pushMatrix(); { // drawing solids requires texturing be disabled - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); if (mUseBoundingRect) { @@ -1303,7 +1303,7 @@ void LLView::drawDebugRect() gGL.color4fv( border_color.mV ); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); gGL.vertex2i(0, debug_rect.getHeight() - 1); gGL.vertex2i(0, 0); diff --git a/linden/indra/llui/llviewborder.cpp b/linden/indra/llui/llviewborder.cpp index 8a5beea..a1c26d6 100644 --- a/linden/indra/llui/llviewborder.cpp +++ b/linden/indra/llui/llviewborder.cpp @@ -111,7 +111,7 @@ void LLViewBorder::draw() void LLViewBorder::drawOnePixelLines() { - LLGLSNoTexture uiNoTexture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLColor4 top_color = mHighlightLight; LLColor4 bottom_color = mHighlightLight; @@ -158,7 +158,7 @@ void LLViewBorder::drawOnePixelLines() void LLViewBorder::drawTwoPixelLines() { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLColor4 focus_color = gFocusMgr.getFocusColor(); @@ -230,7 +230,7 @@ void LLViewBorder::drawTextures() //gGL.color4fv(UI_VERTEX_COLOR.mV); - //mTexture->bind(); + //gGL.getTexUnit(0)->bind(mTexture); //glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); //glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); @@ -248,7 +248,7 @@ void LLViewBorder::drawTextureTrapezoid( F32 degrees, S32 width, S32 length, F32 gGL.translatef(start_x, start_y, 0.f); glRotatef( degrees, 0, 0, 1 ); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { // width, width /---------\ length-width, width // // / \ // diff --git a/linden/indra/llvfs/CMakeLists.txt b/linden/indra/llvfs/CMakeLists.txt index 9f136f7..c3c12ef 100644 --- a/linden/indra/llvfs/CMakeLists.txt +++ b/linden/indra/llvfs/CMakeLists.txt @@ -56,3 +56,9 @@ set_source_files_properties(${llvfs_HEADER_FILES} list(APPEND llvfs_SOURCE_FILES ${llvfs_HEADER_FILES}) add_library (llvfs ${llvfs_SOURCE_FILES}) + +if (DARWIN) + include(CMakeFindFrameworks) + find_library(CARBON_LIBRARY Carbon) + target_link_libraries(llvfs ${CARBON_LIBRARY}) +endif (DARWIN) diff --git a/linden/indra/llvfs/lldir.cpp b/linden/indra/llvfs/lldir.cpp index 0e014d9..5bfe11f 100644 --- a/linden/indra/llvfs/lldir.cpp +++ b/linden/indra/llvfs/lldir.cpp @@ -497,6 +497,29 @@ std::string LLDir::getTempFilename() const return temp_filename; } +// static +std::string LLDir::getScrubbedFileName(const std::string uncleanFileName) +{ + std::string name(uncleanFileName); + const std::string illegalChars(getForbiddenFileChars()); + // replace any illegal file chars with and underscore '_' + for( unsigned int i = 0; i < illegalChars.length(); i++ ) + { + int j = -1; + while((j = name.find(illegalChars[i])) > -1) + { + name[j] = '_'; + } + } + return name; +} + +// static +std::string LLDir::getForbiddenFileChars() +{ + return "\\/:*?\"<>|"; +} + void LLDir::setLindenUserDir(const std::string &first, const std::string &last) { // if both first and last aren't set, assume we're grabbing the cached dir diff --git a/linden/indra/llvfs/lldir.h b/linden/indra/llvfs/lldir.h index dbddf7d..2626d19 100644 --- a/linden/indra/llvfs/lldir.h +++ b/linden/indra/llvfs/lldir.h @@ -64,12 +64,12 @@ class LLDir virtual void initAppDirs(const std::string &app_name) = 0; public: - virtual S32 deleteFilesInDir(const std::string &dirname, const std::string &mask); + virtual S32 deleteFilesInDir(const std::string &dirname, const std::string &mask); // pure virtual functions - virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask) = 0; - virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap) = 0; - virtual void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname) = 0; + virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask) = 0; + virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap) = 0; + virtual void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname) = 0; virtual std::string getCurPath() = 0; virtual BOOL fileExists(const std::string &filename) const = 0; @@ -104,7 +104,7 @@ class LLDir std::string getBaseFileName(const std::string& filepath, bool strip_exten = false) const; std::string getDirName(const std::string& filepath) const; std::string getExtension(const std::string& filepath) const; // Excludes '.', e.g getExtension("foo.wav") == "wav" - + // these methods search the various skin paths for the specified file in the following order: // getUserSkinDir(), getSkinDir(), getDefaultSkinDir() std::string findSkinnedFilename(const std::string &filename) const; @@ -114,6 +114,10 @@ class LLDir // random filename in common temporary directory std::string getTempFilename() const; + // For producing safe download file names from potentially unsafe ones + static std::string getScrubbedFileName(const std::string uncleanFileName); + static std::string getForbiddenFileChars(); + virtual void setChatLogsDir(const std::string &path); // Set the chat logs dir to this user's dir virtual void setPerAccountChatLogsDir(const std::string &first, const std::string &last); // Set the per user chat log directory. virtual void setLindenUserDir(const std::string &first, const std::string &last); // Set the linden user dir to this user's dir diff --git a/linden/indra/llvfs/llvfile.cpp b/linden/indra/llvfs/llvfile.cpp index 61de885..fbdd738 100644 --- a/linden/indra/llvfs/llvfile.cpp +++ b/linden/indra/llvfs/llvfile.cpp @@ -35,6 +35,7 @@ #include "llerror.h" #include "llthread.h" +#include "llstat.h" #include "llvfs.h" const S32 LLVFile::READ = 0x00000001; diff --git a/linden/indra/llvfs/llvfs.cpp b/linden/indra/llvfs/llvfs.cpp index b3d02a5..82d2723 100644 --- a/linden/indra/llvfs/llvfs.cpp +++ b/linden/indra/llvfs/llvfs.cpp @@ -1266,7 +1266,7 @@ void LLVFS::eraseBlockLength(LLVFSBlock *block) } if(!found_block) { - llwarns << "eraseBlock could not find block" << llendl; + llerrs << "eraseBlock could not find block" << llendl; } } diff --git a/linden/indra/llwindow/llwindow.cpp b/linden/indra/llwindow/llwindow.cpp index e8b0a1b..9ce227b 100644 --- a/linden/indra/llwindow/llwindow.cpp +++ b/linden/indra/llwindow/llwindow.cpp @@ -321,6 +321,12 @@ std::string LLWindow::getFontListSans() #endif } +//virtual +void LLWindow::processMiscNativeEvents() +{ + // do nothing unless subclassed +} + #define UTF16_IS_HIGH_SURROGATE(U) ((U16)((U) - 0xD800) < 0x0400) #define UTF16_IS_LOW_SURROGATE(U) ((U16)((U) - 0xDC00) < 0x0400) #define UTF16_SURROGATE_PAIR_TO_UTF32(H,L) (((H) << 10) + (L) - (0xD800 << 10) - 0xDC00 + 0x00010000) diff --git a/linden/indra/llwindow/llwindow.h b/linden/indra/llwindow/llwindow.h index 7e948b9..e2c28a2 100644 --- a/linden/indra/llwindow/llwindow.h +++ b/linden/indra/llwindow/llwindow.h @@ -194,6 +194,7 @@ public: virtual U32 getFSAASamples() = 0; virtual BOOL restoreGamma() = 0; // Restore original gamma table (before updating gamma) virtual ESwapMethod getSwapMethod() { return mSwapMethod; } + virtual void processMiscNativeEvents(); virtual void gatherInput() = 0; virtual void delayInputProcessing() = 0; virtual void swapBuffers() = 0; diff --git a/linden/indra/llwindow/llwindowsdl.cpp b/linden/indra/llwindow/llwindowsdl.cpp index e5d15c4..361126d 100644 --- a/linden/indra/llwindow/llwindowsdl.cpp +++ b/linden/indra/llwindow/llwindowsdl.cpp @@ -104,7 +104,8 @@ void maybe_unlock_display(void) #if LL_GTK // Lazily initialize and check the runtime GTK version for goodness. -BOOL ll_try_gtk_init(void) +// static +bool LLWindowSDL::ll_try_gtk_init(void) { static BOOL done_gtk_diag = FALSE; static BOOL gtk_is_good = FALSE; @@ -166,7 +167,8 @@ BOOL ll_try_gtk_init(void) #if LL_X11 -Window get_SDL_XWindowID(void) +// static +Window LLWindowSDL::get_SDL_XWindowID(void) { if (gWindowImplementation) { return gWindowImplementation->mSDL_XWindowID; @@ -174,7 +176,8 @@ Window get_SDL_XWindowID(void) return None; } -Display* get_SDL_Display(void) +//static +Display* LLWindowSDL::get_SDL_Display(void) { if (gWindowImplementation) { return gWindowImplementation->mSDL_Display; @@ -1235,7 +1238,7 @@ typedef Atom x11clipboard_type; */ static x11clipboard_type get_x11_readwrite_clipboard_type(void) { - return XInternAtom(get_SDL_Display(), "CLIPBOARD", False); + return XInternAtom(LLWindowSDL::get_SDL_Display(), "CLIPBOARD", False); } static x11clipboard_type get_x11_write_clipboard_type(void) @@ -1248,18 +1251,18 @@ static x11clipboard_type get_x11_write_clipboard_type(void) storage because their use isn't really defined for holding UTF8. */ static x11clipboard_type get_x11_cutbuffer_clipboard_type(void) { - return XInternAtom(get_SDL_Display(), "SECONDLIFE_CUTBUFFER", False); + return XInternAtom(LLWindowSDL::get_SDL_Display(), "SECONDLIFE_CUTBUFFER", False); } /* Some X11 atom-generators */ static Atom get_x11_targets_atom(void) { - return XInternAtom(get_SDL_Display(), "TARGETS", False); + return XInternAtom(LLWindowSDL::get_SDL_Display(), "TARGETS", False); } static Atom get_x11_text_atom(void) { - return XInternAtom(get_SDL_Display(), "TEXT", False); + return XInternAtom(LLWindowSDL::get_SDL_Display(), "TEXT", False); } /* These defines, and convert_data/convert_x11clipboard, @@ -1544,7 +1547,7 @@ int clipboard_filter_callback(const SDL_Event *event) sevent.xselection.property = None; sevent.xselection.requestor = req->requestor; sevent.xselection.time = req->time; - if ( XGetWindowProperty(get_SDL_Display(), DefaultRootWindow(get_SDL_Display()), + if ( XGetWindowProperty(LLWindowSDL::get_SDL_Display(), DefaultRootWindow(LLWindowSDL::get_SDL_Display()), get_x11_cutbuffer_clipboard_type(), 0, INT_MAX/4, False, req->target, &sevent.xselection.target, &seln_format, &nbytes, &overflow, &seln_data) == Success ) @@ -1558,7 +1561,7 @@ int clipboard_filter_callback(const SDL_Event *event) if ( seln_data[nbytes-1] == '\0' ) --nbytes; } - XChangeProperty(get_SDL_Display(), req->requestor, req->property, + XChangeProperty(LLWindowSDL::get_SDL_Display(), req->requestor, req->property, req->target, seln_format, PropModeReplace, seln_data, nbytes); sevent.xselection.property = req->property; @@ -1571,7 +1574,7 @@ int clipboard_filter_callback(const SDL_Event *event) get_x11_targets_atom() }; supported[0] = sevent.xselection.target; - XChangeProperty(get_SDL_Display(), req->requestor, + XChangeProperty(LLWindowSDL::get_SDL_Display(), req->requestor, req->property, XA_ATOM, 32, PropModeReplace, (unsigned char*)supported, num_supported); @@ -1584,10 +1587,10 @@ int clipboard_filter_callback(const SDL_Event *event) XFree(seln_data); } int sendret = - XSendEvent(get_SDL_Display(),req->requestor,False,0,&sevent); + XSendEvent(LLWindowSDL::get_SDL_Display(),req->requestor,False,0,&sevent); if ((sendret==BadValue) || (sendret==BadWindow)) llwarns << "Clipboard SendEvent failed" << llendl; - XSync(get_SDL_Display(), False); + XSync(LLWindowSDL::get_SDL_Display(), False); } break; } @@ -1959,17 +1962,14 @@ U32 LLWindowSDL::SDLCheckGrabbyKeys(SDLKey keysym, BOOL gain) return mGrabbyKeyFlags; } -void LLWindowSDL::gatherInput() +// virtual +void LLWindowSDL::processMiscNativeEvents() { - const Uint32 CLICK_THRESHOLD = 300; // milliseconds - static int leftClick = 0; - static int rightClick = 0; - static Uint32 lastLeftDown = 0; - static Uint32 lastRightDown = 0; - SDL_Event event; - -#if LL_GTK && LL_LLMOZLIB_ENABLED - // Pump GTK events so embedded Gecko doesn't starve. +#if LL_GTK && (LL_LLMOZLIB_ENABLED || LL_DBUS_ENABLED) + // Pump GTK events to avoid starvation for: + // * Embedded Gecko + // * DBUS servicing + // * Anything else which quietly hooks into the default glib/GTK loop if (ll_try_gtk_init()) { // Yuck, Mozilla's GTK callbacks play with the locale - push/pop @@ -1992,7 +1992,17 @@ void LLWindowSDL::gatherInput() setlocale(LC_ALL, saved_locale.c_str() ); } -#endif // LL_GTK && LL_LLMOZLIB_ENABLED +#endif // LL_GTK && (LL_LLMOZLIB_ENABLED || LL_DBUS_ENABLED) +} + +void LLWindowSDL::gatherInput() +{ + const Uint32 CLICK_THRESHOLD = 300; // milliseconds + static int leftClick = 0; + static int rightClick = 0; + static Uint32 lastLeftDown = 0; + static Uint32 lastRightDown = 0; + SDL_Event event; // Handle all outstanding SDL events while (SDL_PollEvent(&event)) @@ -2497,12 +2507,10 @@ S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 typ { S32 rtn = OSBTN_CANCEL; - ll_try_gtk_init(); - if(gWindowImplementation != NULL) gWindowImplementation->beforeDialog(); - if (ll_try_gtk_init() + if (LLWindowSDL::ll_try_gtk_init() // We can NOT expect to combine GTK and SDL's aggressive fullscreen && ((NULL==gWindowImplementation) || (!was_fullscreen)) ) @@ -2530,7 +2538,8 @@ S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 typ buttons = GTK_BUTTONS_YES_NO; break; } - win = gtk_message_dialog_new(NULL,flags, messagetype, buttons, text.c_str()); + win = gtk_message_dialog_new(NULL, flags, messagetype, buttons, "%s", + text.c_str()); # if LL_X11 // Make GTK tell the window manager to associate this @@ -2754,7 +2763,7 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url) void *LLWindowSDL::getPlatformWindow() { #if LL_GTK && LL_LLMOZLIB_ENABLED - if (ll_try_gtk_init()) + if (LLWindowSDL::ll_try_gtk_init()) { maybe_lock_display(); diff --git a/linden/indra/llwindow/llwindowsdl.h b/linden/indra/llwindow/llwindowsdl.h index a395ccd..547fe12 100644 --- a/linden/indra/llwindow/llwindowsdl.h +++ b/linden/indra/llwindow/llwindowsdl.h @@ -89,6 +89,7 @@ public: /*virtual*/ void setFSAASamples(const U32 samples); /*virtual*/ BOOL restoreGamma(); // Restore original gamma table (before updating gamma) /*virtual*/ ESwapMethod getSwapMethod() { return mSwapMethod; } + /*virtual*/ void processMiscNativeEvents(); /*virtual*/ void gatherInput(); /*virtual*/ void swapBuffers(); @@ -129,6 +130,16 @@ public: void (*Lock_Display)(void); void (*Unlock_Display)(void); +#if LL_GTK + // Lazily initialize and check the runtime GTK version for goodness. + static bool ll_try_gtk_init(void); +#endif // LL_GTK + +#if LL_X11 + static Window get_SDL_XWindowID(void); + static Display* get_SDL_Display(void); +#endif // LL_X11 + protected: LLWindowSDL( const std::string& title, int x, int y, int width, int height, U32 flags, @@ -205,8 +216,6 @@ private: BOOL mFlashing; LLTimer mFlashTimer; #endif //LL_X11 - - }; @@ -223,16 +232,4 @@ public: S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 type); -void load_url_external(const char* url); - -#if LL_GTK -// Lazily initialize and check the runtime GTK version for goodness. -BOOL ll_try_gtk_init(void); -#endif // LL_GTK - -#if LL_X11 -Window get_SDL_XWindowID(void); -Display* get_SDL_Display(void); -#endif // LL_X11 - #endif //LL_LLWINDOWSDL_H diff --git a/linden/indra/llxml/CMakeLists.txt b/linden/indra/llxml/CMakeLists.txt index d86bc0d..9febd97 100644 --- a/linden/indra/llxml/CMakeLists.txt +++ b/linden/indra/llxml/CMakeLists.txt @@ -34,3 +34,8 @@ set_source_files_properties(${llxml_HEADER_FILES} list(APPEND llxml_SOURCE_FILES ${llxml_HEADER_FILES}) add_library (llxml ${llxml_SOURCE_FILES}) +target_link_libraries( + llxml + ${BOOST_SIGNALS_LIBRARY} + ${EXPAT_LIBRARIES} + ) diff --git a/linden/indra/llxml/llcontrol.cpp b/linden/indra/llxml/llcontrol.cpp index 8fa58e8..e7bac77 100644 --- a/linden/indra/llxml/llcontrol.cpp +++ b/linden/indra/llxml/llcontrol.cpp @@ -50,9 +50,9 @@ #include "llsdserialize.h" #if LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG -#define CONTROL_ERRS LL_WARNS("ControlErrors") -#else #define CONTROL_ERRS LL_ERRS("ControlErrors") +#else +#define CONTROL_ERRS LL_WARNS("ControlErrors") #endif //this defines the current version of the settings file diff --git a/linden/indra/lscript/lscript_byteconvert.h b/linden/indra/lscript/lscript_byteconvert.h index 9530b63..664a25e 100644 --- a/linden/indra/lscript/lscript_byteconvert.h +++ b/linden/indra/lscript/lscript_byteconvert.h @@ -250,7 +250,7 @@ inline void bytestream2vector(LLVector3 &vector, const U8 *stream, S32 &offset) } } -inline void vector2bytestream(U8 *stream, S32 &offset, LLVector3 &vector) +inline void vector2bytestream(U8 *stream, S32 &offset, const LLVector3 &vector) { S32 value = *(S32 *)&vector.mV[VZ]; integer2bytestream(stream, offset, value); @@ -292,7 +292,7 @@ inline void bytestream2quaternion(LLQuaternion &quat, const U8 *stream, S32 &off } } -inline void quaternion2bytestream(U8 *stream, S32 &offset, LLQuaternion &quat) +inline void quaternion2bytestream(U8 *stream, S32 &offset, const LLQuaternion &quat) { S32 value = *(S32 *)&quat.mQ[VS]; integer2bytestream(stream, offset, value); @@ -528,7 +528,7 @@ inline void lscript_push(U8 *stream, F32 value) } } -inline void lscript_push(U8 *stream, LLVector3 &value) +inline void lscript_push(U8 *stream, const LLVector3 &value) { S32 sp = get_register(stream, LREG_SP); sp -= LSCRIPTDataSize[LST_VECTOR]; @@ -539,7 +539,7 @@ inline void lscript_push(U8 *stream, LLVector3 &value) } } -inline void lscript_push(U8 *stream, LLQuaternion &value) +inline void lscript_push(U8 *stream, const LLQuaternion &value) { S32 sp = get_register(stream, LREG_SP); sp -= LSCRIPTDataSize[LST_QUATERNION]; @@ -679,13 +679,13 @@ inline void lscript_local_store(U8 *stream, S32 address, F32 value) float2bytestream(stream, address, value); } -inline void lscript_local_store(U8 *stream, S32 address, LLVector3 value) +inline void lscript_local_store(U8 *stream, S32 address, const LLVector3 value) { if (lscript_check_local(stream, address, LSCRIPTDataSize[LST_VECTOR])) vector2bytestream(stream, address, value); } -inline void lscript_local_store(U8 *stream, S32 address, LLQuaternion value) +inline void lscript_local_store(U8 *stream, S32 address, const LLQuaternion value) { if (lscript_check_local(stream, address, LSCRIPTDataSize[LST_QUATERNION])) quaternion2bytestream(stream, address, value); @@ -703,13 +703,13 @@ inline void lscript_global_store(U8 *stream, S32 address, F32 value) float2bytestream(stream, address, value); } -inline void lscript_global_store(U8 *stream, S32 address, LLVector3 value) +inline void lscript_global_store(U8 *stream, S32 address, const LLVector3 value) { if (lscript_check_global(stream, address, LSCRIPTDataSize[LST_VECTOR])) vector2bytestream(stream, address, value); } -inline void lscript_global_store(U8 *stream, S32 address, LLQuaternion value) +inline void lscript_global_store(U8 *stream, S32 address, const LLQuaternion value) { if (lscript_check_global(stream, address, LSCRIPTDataSize[LST_QUATERNION])) quaternion2bytestream(stream, address, value); @@ -1125,7 +1125,7 @@ inline void safe_instruction_bytestream2vector(LLVector3 &value, U8 *stream, S32 } } -inline void safe_instruction_vector2bytestream(U8 *stream, S32 &offset, LLVector3 &value) +inline void safe_instruction_vector2bytestream(U8 *stream, S32 &offset, const LLVector3 &value) { if (safe_instruction_check_address(stream, offset, LSCRIPTDataSize[LST_VECTOR])) { @@ -1141,7 +1141,7 @@ inline void safe_instruction_bytestream2quaternion(LLQuaternion &value, U8 *stre } } -inline void safe_instruction_quaternion2bytestream(U8 *stream, S32 &offset, LLQuaternion &value) +inline void safe_instruction_quaternion2bytestream(U8 *stream, S32 &offset, const LLQuaternion &value) { if (safe_instruction_check_address(stream, offset, LSCRIPTDataSize[LST_QUATERNION])) { diff --git a/linden/indra/lscript/lscript_byteformat.h b/linden/indra/lscript/lscript_byteformat.h index 1f201d8..fa82e6b 100644 --- a/linden/indra/lscript/lscript_byteformat.h +++ b/linden/indra/lscript/lscript_byteformat.h @@ -470,6 +470,7 @@ const U8 LSCRIPTTypeHi4Bits[LST_EOF] = LST_VECTOR << 4, LST_QUATERNION << 4, LST_LIST << 4, + LST_UNDEFINED << 4, }; const char * const LSCRIPTTypeNames[LST_EOF] = /*Flawfinder: ignore*/ diff --git a/linden/indra/lscript/lscript_compile/lscript_tree.cpp b/linden/indra/lscript/lscript_compile/lscript_tree.cpp index 71e7f19..f62b4e7 100644 --- a/linden/indra/lscript/lscript_compile/lscript_tree.cpp +++ b/linden/indra/lscript/lscript_compile/lscript_tree.cpp @@ -46,7 +46,8 @@ static void print_cil_box(LLFILE* fp, LSCRIPTType type) { - switch(type) + +switch(type) { case LST_INTEGER: fprintf(fp, "box [mscorlib]System.Int32\n"); @@ -1257,10 +1258,10 @@ static void print_cil_init_variable(LLFILE* fp, LSCRIPTType type) fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateVector'(float32, float32, float32)\n"); break; case LST_QUATERNION: - fprintf(fp, "ldc.r8 1\n"); fprintf(fp, "ldc.r8 0\n"); fprintf(fp, "ldc.r8 0\n"); fprintf(fp, "ldc.r8 0\n"); + fprintf(fp, "ldc.r8 1\n"); fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateQuaternion'(float32, float32, float32, float32)\n"); break; case LST_LIST: @@ -3517,7 +3518,7 @@ void LLScriptRezEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompile fprintf(fp, " )\n"); break; case LSCP_SCOPE_PASS1: - checkForDuplicateHandler(fp, this, scope, "rez"); + checkForDuplicateHandler(fp, this, scope, "on_rez"); if (scope->checkEntry(mStartParam->mName)) { gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); @@ -7885,10 +7886,10 @@ void LLScriptFunctionCall::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom { // Prefix function name with g to distinguish from // event handlers. - fprintf(fp, gScriptp->getClassName()); + fprintf(fp, "%s", gScriptp->getClassName()); fprintf(fp, "::'g"); } - fprintf(fp, mIdentifier->mName); + fprintf(fp, "%s", mIdentifier->mName); fprintf(fp, "'("); print_cil_arg_list(fp, mIdentifier->mScopeEntry->mFunctionArgs); fprintf(fp, ")\n"); @@ -8689,8 +8690,12 @@ void LLScriptIf::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass p break; case LSCP_TYPE: mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + if (type == LST_NULL) + { + gErrorToText.writeError(fp, mExpression, LSERROR_TYPE_MISMATCH); + } mType = type; - mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; case LSCP_EMIT_BYTE_CODE: { @@ -8770,6 +8775,10 @@ void LLScriptIfElse::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePa break; case LSCP_TYPE: mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + if (type == LST_NULL) + { + gErrorToText.writeError(fp, mExpression, LSERROR_TYPE_MISMATCH); + } mType = type; mStatement1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mStatement2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -8869,6 +8878,10 @@ void LLScriptFor::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass if(mSequence) mSequence->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + if (type == LST_NULL) + { + gErrorToText.writeError(fp, mExpression, LSERROR_TYPE_MISMATCH); + } mType = type; if(mExpressionList) mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -8968,6 +8981,10 @@ void LLScriptDoWhile::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompileP case LSCP_TYPE: mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + if (type == LST_NULL) + { + gErrorToText.writeError(fp, mExpression, LSERROR_TYPE_MISMATCH); + } mType = type; break; case LSCP_EMIT_BYTE_CODE: @@ -9039,6 +9056,10 @@ void LLScriptWhile::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePas break; case LSCP_TYPE: mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + if (type == LST_NULL) + { + gErrorToText.writeError(fp, mExpression, LSERROR_TYPE_MISMATCH); + } mType = type; mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -9720,7 +9741,7 @@ void LLScriptEventHandler::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom // Allows state changing by finding handlers prefixed with new // state name. Prefix disambiguates functions and event handlers. fprintf(fp, "e"); - fprintf(fp, entry->mIdentifier); + fprintf(fp, "%s", entry->mIdentifier); // Handler name and arguments. mEventp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -10152,7 +10173,7 @@ void LLScriptGlobalFunctions::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPT fprintf(fp, ".method public hidebysig instance default "); print_cil_type(fp, mType ? mType->mType : LST_NULL); fprintf(fp, " 'g"); - fprintf(fp, mIdentifier->mName); + fprintf(fp, "%s", mIdentifier->mName); fprintf(fp, "'"); if (mParameters) { diff --git a/linden/indra/lscript/lscript_execute.h b/linden/indra/lscript/lscript_execute.h index ac23ff3..77e9c21 100644 --- a/linden/indra/lscript/lscript_execute.h +++ b/linden/indra/lscript/lscript_execute.h @@ -370,7 +370,7 @@ public: LLScriptExecute(); virtual ~LLScriptExecute() {;} - virtual S32 getVersion() = 0; + virtual S32 getVersion() const = 0; virtual void deleteAllEvents() = 0; virtual void addEvent(LLScriptDataCollection* event) = 0; virtual U32 getEventCount() = 0; @@ -384,12 +384,12 @@ public: virtual void setSleep(F32 value) = 0; virtual F32 getEnergy() const = 0; virtual void setEnergy(F32 value) = 0; - virtual U64 getCurrentEvents(S32 version) = 0; - virtual void setCurrentEvents(U64 value, S32 version) = 0; - virtual U64 getEventHandlers(S32 version) = 0; - virtual void setEventHandlers(U64 value, S32 version) = 0; - virtual U64 getCurrentHandler(S32 version) = 0; - virtual void setCurrentHandler(U64 value, S32 version) = 0; + virtual U64 getCurrentEvents() = 0; + virtual void setCurrentEvents(U64 value) = 0; + virtual U64 getEventHandlers() = 0; + virtual void setEventHandlers(U64 value) = 0; + virtual U64 getCurrentHandler() = 0; + virtual void setCurrentHandler(U64 value) = 0; virtual BOOL isFinished() const = 0; virtual BOOL isStateChangePending() const = 0; virtual S32 writeState(U8 **dest, U32 header_size, U32 footer_size) = 0; // Allocate memory for header, state and footer return size of state. @@ -409,17 +409,17 @@ public: // Run handler for event for a maximum of time_slice seconds. // Updates current handler and current events registers. - virtual void callEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice) = 0;; + virtual void callEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice) = 0;; // Run handler for next queued event for maximum of time_slice seconds. // Updates current handler and current events registers. // Removes processed event from queue. - virtual void callNextQueuedEventHandler(U64 event_register, S32 major_version, const LLUUID &id, F32 time_slice) = 0; + virtual void callNextQueuedEventHandler(U64 event_register, const LLUUID &id, F32 time_slice) = 0; // Run handler for event for a maximum of time_slice seconds. // Updates current handler and current events registers. // Removes processed event from queue. - virtual void callQueuedEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice) = 0; + virtual void callQueuedEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice) = 0; // Switch to next state. // Returns new set of handled events. @@ -428,14 +428,14 @@ public: // Returns time taken. virtual F32 runQuanta(BOOL b_print, const LLUUID &id, const char **errorstr, - BOOL &state_transition, F32 quanta, + F32 quanta, U32& events_processed, LLTimer& timer); // Run smallest possible amount of code: an instruction for LSL2, a segment // between save tests for Mono void runInstructions(BOOL b_print, const LLUUID &id, const char **errorstr, - BOOL &state_transition, U32& events_processed, + U32& events_processed, F32 quanta); bool isYieldDue() const; @@ -443,6 +443,12 @@ public: void setReset(BOOL b) {mReset = b;} BOOL getReset() const { return mReset; } + // Called when the script is scheduled to be run from newsim/LLScriptData + virtual void startRunning() = 0; + + // Called when the script is scheduled to be stopped from newsim/LLScriptData + virtual void stopRunning() = 0; + private: BOOL mReset; @@ -455,7 +461,7 @@ public: LLScriptExecuteLSL2(const U8* bytecode, U32 bytecode_size); virtual ~LLScriptExecuteLSL2(); - virtual S32 getVersion() {return get_register(mBuffer, LREG_VN);} + virtual S32 getVersion() const {return get_register(mBuffer, LREG_VN);} virtual void deleteAllEvents() {mEventData.mEventDataList.deleteAllData();} virtual void addEvent(LLScriptDataCollection* event); virtual U32 getEventCount() {return mEventData.mEventDataList.getLength();} @@ -469,12 +475,12 @@ public: virtual void setSleep(F32 value); virtual F32 getEnergy() const; virtual void setEnergy(F32 value); - virtual U64 getCurrentEvents(S32 version) {return get_event_register(mBuffer, LREG_CE, version);} - virtual void setCurrentEvents(U64 value, S32 version) {return set_event_register(mBuffer, LREG_CE, value, version);} - virtual U64 getEventHandlers(S32 version) {return get_event_register(mBuffer, LREG_ER, version);} - virtual void setEventHandlers(U64 value, S32 version) {set_event_register(mBuffer, LREG_ER, value, version);} - virtual U64 getCurrentHandler(S32 version); - virtual void setCurrentHandler(U64 value, S32 version) {return set_event_register(mBuffer, LREG_IE, value, version);} + virtual U64 getCurrentEvents() {return get_event_register(mBuffer, LREG_CE, getMajorVersion());} + virtual void setCurrentEvents(U64 value) {return set_event_register(mBuffer, LREG_CE, value, getMajorVersion());} + virtual U64 getEventHandlers() {return get_event_register(mBuffer, LREG_ER, getMajorVersion());} + virtual void setEventHandlers(U64 value) {set_event_register(mBuffer, LREG_ER, value, getMajorVersion());} + virtual U64 getCurrentHandler(); + virtual void setCurrentHandler(U64 value) {return set_event_register(mBuffer, LREG_IE, value, getMajorVersion());} virtual BOOL isFinished() const {return get_register(mBuffer, LREG_IP) == 0;} virtual BOOL isStateChangePending() const {return get_register(mBuffer, LREG_CS) != get_register(mBuffer, LREG_NS);} virtual S32 writeState(U8 **dest, U32 header_size, U32 footer_size); // Not including Events. @@ -494,17 +500,17 @@ public: // Run handler for event for a maximum of time_slice seconds. // Updates current handler and current events registers. - virtual void callEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice); + virtual void callEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice); // Run handler for next queued event for maximum of time_slice seconds. // Updates current handler and current events registers. // Removes processed event from queue. - virtual void callNextQueuedEventHandler(U64 event_register, S32 major_version, const LLUUID &id, F32 time_slice); + virtual void callNextQueuedEventHandler(U64 event_register, const LLUUID &id, F32 time_slice); // Run handler for event for a maximum of time_slice seconds. // Updates current handler and current events registers. // Removes processed event from queue. - virtual void callQueuedEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice); + virtual void callQueuedEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice); // Switch to next state. // Returns new set of handled events. @@ -521,8 +527,15 @@ public: U32 mBytecodeSize; private: + S32 getMajorVersion() const; void recordBoundaryError( const LLUUID &id ); void setStateEventOpcoodeStartSafely( S32 state, LSCRIPTStateEventType event, const LLUUID &id ); + + // Called when the script is scheduled to be run from newsim/LLScriptData + virtual void startRunning(); + + // Called when the script is scheduled to be stopped from newsim/LLScriptData + virtual void stopRunning(); }; #endif diff --git a/linden/indra/lscript/lscript_execute/lscript_execute.cpp b/linden/indra/lscript/lscript_execute/lscript_execute.cpp index 3adfe32..2a6f7e3 100644 --- a/linden/indra/lscript/lscript_execute/lscript_execute.cpp +++ b/linden/indra/lscript/lscript_execute/lscript_execute.cpp @@ -60,6 +60,9 @@ const char* LSCRIPTRunTimeFaultStrings[LSRF_EOF] = /*Flawfinder: ignore*/ "CLI Exception" // LSRF_CLI }; +void LLScriptExecuteLSL2::startRunning() {} +void LLScriptExecuteLSL2::stopRunning() {} + LLScriptExecuteLSL2::LLScriptExecuteLSL2(LLFILE *fp) { U8 sizearray[4]; @@ -327,8 +330,9 @@ void LLScriptExecuteLSL2::resumeEventHandler(BOOL b_print, const LLUUID &id, F32 // NOTE: Babbage: all mExecuteFuncs return false. } -void LLScriptExecuteLSL2::callEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice) +void LLScriptExecuteLSL2::callEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice) { + S32 major_version = getMajorVersion(); // push a zero to be popped lscript_push(mBuffer, 0); // push sp as current bp @@ -403,8 +407,9 @@ void LLScriptExecuteLSL2::callEventHandler(LSCRIPTStateEventType event, S32 majo // set_ip(mBuffer, opcode_start); //} -void LLScriptExecuteLSL2::callQueuedEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice) +void LLScriptExecuteLSL2::callQueuedEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice) { + S32 major_version = getMajorVersion(); LLScriptDataCollection* eventdata; for (eventdata = mEventData.mEventDataList.getFirstData(); eventdata; eventdata = mEventData.mEventDataList.getNextData()) @@ -452,8 +457,9 @@ void LLScriptExecuteLSL2::callQueuedEventHandler(LSCRIPTStateEventType event, S3 } } -void LLScriptExecuteLSL2::callNextQueuedEventHandler(U64 event_register, S32 major_version, const LLUUID &id, F32 time_slice) +void LLScriptExecuteLSL2::callNextQueuedEventHandler(U64 event_register, const LLUUID &id, F32 time_slice) { + S32 major_version = getMajorVersion(); LLScriptDataCollection* eventdata = mEventData.getNextEvent(); if (eventdata) { @@ -541,9 +547,9 @@ void LLScriptExecuteLSL2::setSleep(F32 value) } //virtual -U64 LLScriptExecuteLSL2::getCurrentHandler(S32 version) +U64 LLScriptExecuteLSL2::getCurrentHandler() { - return get_event_register(mBuffer, LREG_IE, version); + return get_event_register(mBuffer, LREG_IE, getMajorVersion()); } //virtual @@ -724,6 +730,20 @@ void LLScriptExecuteLSL2::reset() bytestream2bytestream(mBuffer, dest_offset, src, src_offset, size); } +S32 LLScriptExecuteLSL2::getMajorVersion() const +{ + S32 version = getVersion(); + S32 major_version = 0; + if (version == LSL2_VERSION1_END_NUMBER){ + major_version = 1; + } + else if (version == LSL2_VERSION_NUMBER) + { + major_version = 2; + } + return major_version; +} + LLScriptExecute::LLScriptExecute() : mReset(FALSE) { @@ -751,6 +771,10 @@ bool LLScriptExecute::isYieldDue() const return true; } + // State changes can occur within a single time slice, + // but LLScriptData's clean up is required. Yield here + // to allow LLScriptData to perform cleanup and then call + // runQuanta again. if(isStateChangePending()) { return true; @@ -763,7 +787,6 @@ bool LLScriptExecute::isYieldDue() const // a single instruction for LSL2, a segment between save tests for Mono void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id, const char **errorstr, - BOOL &state_transition, U32& events_processed, F32 quanta) { @@ -806,17 +829,15 @@ void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id, else { // make sure that IE is zero - setCurrentHandler(0, major_version); + setCurrentHandler(0); // if no, we're in a state and waiting for an event - U64 current_events = getCurrentEvents(major_version); - U64 event_register = getEventHandlers(major_version); + U64 current_events = getCurrentEvents(); + U64 event_register = getEventHandlers(); // check NS to see if need to switch states (NS != CS) if (isStateChangePending()) { - state_transition = TRUE; - // ok, blow away any pending events deleteAllEvents(); @@ -824,16 +845,16 @@ void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id, if (current_events & LSCRIPTStateBitField[LSTT_STATE_EXIT]) { // if yes, clear state exit flag - setCurrentHandler(LSCRIPTStateBitField[LSTT_STATE_EXIT], major_version); + setCurrentHandler(LSCRIPTStateBitField[LSTT_STATE_EXIT]); current_events &= ~LSCRIPTStateBitField[LSTT_STATE_EXIT]; - setCurrentEvents(current_events, major_version); + setCurrentEvents(current_events); // check state exit event handler // if there is a handler, call it if (event_register & LSCRIPTStateBitField[LSTT_STATE_EXIT]) { ++events_processed; - callEventHandler(LSTT_STATE_EXIT, major_version, id, quanta); + callEventHandler(LSTT_STATE_EXIT, id, quanta); return; } } @@ -841,32 +862,32 @@ void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id, // if no handler or no state exit flag switch to new state // set state entry flag and clear other CE flags current_events = LSCRIPTStateBitField[LSTT_STATE_ENTRY]; - setCurrentEvents(current_events, major_version); + setCurrentEvents(current_events); U64 handled_events = nextState(); - setEventHandlers(handled_events, major_version); + setEventHandlers(handled_events); } // try to get next event from stack BOOL b_done = FALSE; LSCRIPTStateEventType event = LSTT_NULL; - current_events = getCurrentEvents(major_version); - event_register = getEventHandlers(major_version); + current_events = getCurrentEvents(); + event_register = getEventHandlers(); // first, check to see if state_entry or onrez are raised and handled if ((current_events & LSCRIPTStateBitField[LSTT_STATE_ENTRY]) &&(current_events & event_register)) { ++events_processed; - callEventHandler(LSTT_STATE_ENTRY, major_version, id, quanta); + callEventHandler(LSTT_STATE_ENTRY, id, quanta); b_done = TRUE; } else if ((current_events & LSCRIPTStateBitField[LSTT_REZ]) &&(current_events & event_register)) { ++events_processed; - callQueuedEventHandler(LSTT_REZ, major_version, id, quanta); + callQueuedEventHandler(LSTT_REZ, id, quanta); b_done = TRUE; } @@ -876,7 +897,7 @@ void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id, if(getEventCount() > 0) { ++events_processed; - callNextQueuedEventHandler(event_register, major_version, id, quanta); + callNextQueuedEventHandler(event_register, id, quanta); b_done = TRUE; } else @@ -887,7 +908,7 @@ void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id, { event = return_first_event((S32)handled_current); ++events_processed; - callEventHandler(event, major_version, id, quanta); + callEventHandler(event, id, quanta); } b_done = TRUE; } @@ -895,8 +916,8 @@ void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id, } } -// Run for a single timeslice, or until a yield is due -F32 LLScriptExecute::runQuanta(BOOL b_print, const LLUUID &id, const char **errorstr, BOOL &state_transition, F32 quanta, U32& events_processed, LLTimer& timer) +// Run for a single timeslice, or until a yield or state transition is due +F32 LLScriptExecute::runQuanta(BOOL b_print, const LLUUID &id, const char **errorstr, F32 quanta, U32& events_processed, LLTimer& timer) { U32 timer_checks = 0; F32 inloop = 0; @@ -907,7 +928,7 @@ F32 LLScriptExecute::runQuanta(BOOL b_print, const LLUUID &id, const char **erro // on current execution speed. while(true) { - runInstructions(b_print, id, errorstr, state_transition, + runInstructions(b_print, id, errorstr, events_processed, quanta); static const S32 lsl_timer_check_skip = 4; @@ -3277,7 +3298,7 @@ BOOL run_state(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) { major_version = 2; } - + S32 current_state = get_register(buffer, LREG_CS); if (state != current_state) { @@ -3985,7 +4006,6 @@ void lscript_run(const std::string& filename, BOOL b_debug) LLTimer timer; const char *error; - BOOL b_state; LLScriptExecuteLSL2 *execute = NULL; if (filename.empty()) @@ -4009,7 +4029,7 @@ void lscript_run(const std::string& filename, BOOL b_debug) do { LLTimer timer2; - execute->runQuanta(b_debug, LLUUID::null, &error, b_state, + execute->runQuanta(b_debug, LLUUID::null, &error, time_slice, events_processed, timer2); } while (!execute->isFinished()); @@ -4044,7 +4064,8 @@ void lscript_pop_variable(LLScriptLibData *data, U8 *buffer, char type) break; case 'k': data->mType = LST_KEY; - + data->mKey = NULL; + base_address = lscript_pop_int(buffer); // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization // and function clean up of ref counts isn't based on scope (a mistake, I know) @@ -4063,7 +4084,7 @@ void lscript_pop_variable(LLScriptLibData *data, U8 *buffer, char type) } lsa_decrease_ref_count(buffer, base_address); } - else + if (data->mKey == NULL) { data->mKey = new char[1]; data->mKey[0] = 0; @@ -4071,6 +4092,7 @@ void lscript_pop_variable(LLScriptLibData *data, U8 *buffer, char type) break; case 's': data->mType = LST_STRING; + data->mString = NULL; base_address = lscript_pop_int(buffer); // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization @@ -4090,7 +4112,7 @@ void lscript_pop_variable(LLScriptLibData *data, U8 *buffer, char type) } lsa_decrease_ref_count(buffer, base_address); } - else + if (data->mString == NULL) { data->mString = new char[1]; data->mString[0] = 0; diff --git a/linden/indra/lscript/lscript_library/lscript_library.cpp b/linden/indra/lscript/lscript_library/lscript_library.cpp index e7d8284..505b123 100644 --- a/linden/indra/lscript/lscript_library/lscript_library.cpp +++ b/linden/indra/lscript/lscript_library/lscript_library.cpp @@ -448,6 +448,7 @@ void LLScriptLibrary::init() addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llDetectedTouchBinormal", "v", "i", "vector llDetectedTouchBinormal(integer number)\nreturns the surface binormal for a triggered touch event")); addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llDetectedTouchST", "v", "i", "vector llDetectedTouchST(integer number)\nreturns the s and t coordinates in the first two components of a vector, for a triggered touch event")); + addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSHA1String", "s", "s", "string llSHA1String(string sr)\nPerforms a SHA1 security Hash. Returns a 40 character hex string.")); // energy, sleep, dummy_func, name, return type, parameters, help text, gods-only diff --git a/linden/indra/mac_crash_logger/CMakeLists.txt b/linden/indra/mac_crash_logger/CMakeLists.txt index 9cddb56..daf3e10 100644 --- a/linden/indra/mac_crash_logger/CMakeLists.txt +++ b/linden/indra/mac_crash_logger/CMakeLists.txt @@ -3,7 +3,6 @@ project(mac_crash_logger) include(00-Common) -include(Boost) include(LLCommon) include(LLCrashLogger) include(LLMath) @@ -36,7 +35,6 @@ set_source_files_properties(${mac_crash_logger_HEADER_FILES} list(APPEND mac_crash_logger_SOURCE_FILES ${mac_crash_logger_HEADER_FILES}) set(mac_crash_logger_RESOURCE_FILES - Info.plist CrashReporter.nib/ ) set_source_files_properties( @@ -44,11 +42,6 @@ set_source_files_properties( PROPERTIES HEADER_FILE_ONLY TRUE ) -set_source_files_properties( - Info.plist - PROPERTIES - MACOSX_PACKAGE_LOCATION . # will it blend? + poppy - ) SOURCE_GROUP("Resources" FILES ${mac_crash_logger_RESOURCE_FILES}) list(APPEND mac_crash_logger_SOURCE_FILES ${mac_crash_logger_RESOURCE_FILES}) @@ -56,6 +49,11 @@ add_executable(mac-crash-logger MACOSX_BUNDLE ${mac_crash_logger_SOURCE_FILES}) +set_target_properties(mac-crash-logger + PROPERTIES + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist + ) + target_link_libraries(mac-crash-logger ${LLCRASHLOGGER_LIBRARIES} ${LLVFS_LIBRARIES} @@ -64,7 +62,6 @@ target_link_libraries(mac-crash-logger ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} ${LLCOMMON_LIBRARIES} - ${BOOST_SIGNALS_LIBRARY} ) add_custom_command( diff --git a/linden/indra/mac_crash_logger/CrashReporter.nib/info.nib b/linden/indra/mac_crash_logger/CrashReporter.nib/info.nib index b541744..06805c0 100644 --- a/linden/indra/mac_crash_logger/CrashReporter.nib/info.nib +++ b/linden/indra/mac_crash_logger/CrashReporter.nib/info.nib @@ -5,15 +5,13 @@ IBFramework Version 629 IBLastKnownRelativeProjectPath - ../macview.xcodeproj + ../../build-darwin-i386/SecondLife.xcodeproj IBOldestOS 5 IBOpenObjects - - 193 - + IBSystem Version - 9B18 + 9E17 targetFramework IBCarbonFramework diff --git a/linden/indra/mac_updater/CMakeLists.txt b/linden/indra/mac_updater/CMakeLists.txt index 3ac5aee..0eac76f 100644 --- a/linden/indra/mac_updater/CMakeLists.txt +++ b/linden/indra/mac_updater/CMakeLists.txt @@ -42,7 +42,6 @@ list(APPEND mac_updater_SOURCE_FILES ${mac_updater_HEADER_FILES}) set(mac_updater_RESOURCE_FILES - Info.plist AutoUpdater.nib/ ) set_source_files_properties( @@ -50,19 +49,18 @@ set_source_files_properties( PROPERTIES HEADER_FILE_ONLY TRUE ) -set_source_files_properties( - Info.plist - PROPERTIES - MACOSX_PACKAGE_LOCATION . # will it blend? + poppy - ) SOURCE_GROUP("Resources" FILES ${mac_updater_RESOURCE_FILES}) list(APPEND mac_updater_SOURCE_FILES ${mac_updater_RESOURCE_FILES}) - add_executable(mac-updater MACOSX_BUNDLE ${mac_updater_SOURCE_FILES}) +set_target_properties(mac-updater + PROPERTIES + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist + ) + target_link_libraries(mac-updater ${LLVFS_LIBRARIES} ${CURL_LIBRARIES} @@ -79,4 +77,3 @@ add_custom_command( ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/mac-updater.app/Contents/Resources/AutoUpdater.nib ) - diff --git a/linden/indra/newview/CMakeLists.txt b/linden/indra/newview/CMakeLists.txt index e93ea57..4dd4c74 100644 --- a/linden/indra/newview/CMakeLists.txt +++ b/linden/indra/newview/CMakeLists.txt @@ -5,6 +5,7 @@ project(viewer) include(00-Common) include(Boost) include(BuildVersion) +include(DBusGlib) include(DirectX) include(ELFIO) include(FMOD) @@ -123,6 +124,7 @@ set(viewer_SOURCE_FILES llfloateravatarinfo.cpp llfloateravatarpicker.cpp llfloateravatartextures.cpp + llfloaterbeacons.cpp llfloaterbuildoptions.cpp llfloaterbump.cpp llfloaterbuycontents.cpp @@ -198,6 +200,7 @@ set(viewer_SOURCE_FILES llglsandbox.cpp llgroupmgr.cpp llgroupnotify.cpp + llhomelocationresponder.cpp llhoverview.cpp llhudeffectbeam.cpp llhudeffect.cpp @@ -429,6 +432,9 @@ set(viewer_SOURCE_FILES pipeline.cpp ) +set(VIEWER_BINARY_NAME "secondlife-bin" CACHE STRING + "The name of the viewer executable to create.") + if (LINUX) # We can't set these flags for Darwin, because they get passed to # the PPC compiler. Ugh. @@ -513,6 +519,7 @@ set(viewer_HEADER_FILES llfloateravatarinfo.h llfloateravatarpicker.h llfloateravatartextures.h + llfloaterbeacons.h llfloaterbuildoptions.h llfloaterbump.h llfloaterbuy.h @@ -587,6 +594,7 @@ set(viewer_HEADER_FILES llgivemoney.h llgroupmgr.h llgroupnotify.h + llhomelocationresponder.h llhoverview.h llhudeffect.h llhudeffectbeam.h @@ -869,6 +877,7 @@ endif (DARWIN) if (LINUX) LIST(APPEND viewer_SOURCE_FILES llappviewerlinux.cpp) + LIST(APPEND viewer_SOURCE_FILES llappviewerlinux_api_dbus.cpp) LIST(APPEND CMAKE_EXE_LINKER_FLAGS -Wl,--as-needed) set(viewer_LIBRARIES @@ -1018,6 +1027,7 @@ set(viewer_XUI_FILES skins/default/xui/en-us/floater_audio_volume.xml skins/default/xui/en-us/floater_avatar_picker.xml skins/default/xui/en-us/floater_avatar_textures.xml + skins/default/xui/en-us/floater_beacons.xml skins/default/xui/en-us/floater_build_options.xml skins/default/xui/en-us/floater_bumps.xml skins/default/xui/en-us/floater_buy_contents.xml @@ -1236,6 +1246,17 @@ set_source_files_properties(${viewer_CHARACTER_FILES} list(APPEND viewer_SOURCE_FILES ${viewer_CHARACTER_FILES}) +if (WINDOWS) + file(GLOB viewer_INSTALLER_FILES installers/windows/*.nsi) + + source_group("Installer Files" FILES ${viewer_INSTALLER_FILES}) + + set_source_files_properties(${viewer_INSTALLER_FILES} + PROPERTIES HEADER_FILE_ONLY TRUE) + + list(APPEND viewer_SOURCE_FILES ${viewer_INSTALLER_FILES}) +endif (WINDOWS) + if (FMOD) set_source_files_properties(llstartup.cpp PROPERTIES COMPILE_FLAGS -DLL_FMOD) @@ -1262,15 +1283,15 @@ list(APPEND viewer_SOURCE_FILES ${viewer_HEADER_FILES}) set_source_files_properties(${viewer_HEADER_FILES} PROPERTIES HEADER_FILE_ONLY TRUE) -add_executable(secondlife-bin +add_executable(${VIEWER_BINARY_NAME} WIN32 MACOSX_BUNDLE ${viewer_SOURCE_FILES} ) -check_message_template(secondlife-bin) +check_message_template(${VIEWER_BINARY_NAME}) if (LLKDU_LIBRARY) - add_dependencies(secondlife-bin ${LLKDU_LIBRARY}) + add_dependencies(${VIEWER_BINARY_NAME} ${LLKDU_LIBRARY}) endif (LLKDU_LIBRARY) set(PACKAGE OFF CACHE BOOL @@ -1278,12 +1299,12 @@ set(PACKAGE OFF CACHE BOOL if (WINDOWS) if(MSVC71) - set(release_flags "/MAP:Release/secondlife-bin.map /MAPINFO:LINES") + set(release_flags "/MAP:Release/${VIEWER_BINARY_NAME}.map /MAPINFO:LINES") else(MSVC71) - set(release_flags "/MAP:Release/secondlife-bin.map") + set(release_flags "/MAP:Release/${VIEWER_BINARY_NAME}.map") endif(MSVC71) - set_target_properties(secondlife-bin + set_target_properties(${VIEWER_BINARY_NAME} PROPERTIES LINK_FLAGS "/debug /NODEFAULTLIB:MSVCRT /SUBSYSTEM:WINDOWS" LINK_FLAGS_DEBUG "/NODEFAULTLIB:LIBCMT /NODEFAULTLIB:MSVCRTD" @@ -1293,20 +1314,20 @@ if (WINDOWS) # sets the 'working directory' for debugging from visual studio. if (NOT UNATTENDED) add_custom_command( - TARGET secondlife-bin PRE_BUILD + TARGET ${VIEWER_BINARY_NAME} PRE_BUILD COMMAND ${CMAKE_SOURCE_DIR}/tools/vstool/vstool.exe ARGS --solution ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.sln --workingdir - secondlife-bin + ${VIEWER_BINARY_NAME} ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Setting the secondlife-bin working directory for debugging." + COMMENT "Setting the ${VIEWER_BINARY_NAME} working directory for debugging." ) endif (NOT UNATTENDED) add_custom_command( - TARGET secondlife-bin PRE_BUILD + TARGET ${VIEWER_BINARY_NAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E @@ -1317,7 +1338,7 @@ if (WINDOWS) ) add_custom_command( - TARGET secondlife-bin PRE_BUILD + TARGET ${VIEWER_BINARY_NAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E @@ -1327,10 +1348,10 @@ if (WINDOWS) COMMENT "Copying message.xml to the runtime folder." ) - add_dependencies(secondlife-bin copy_win_libs) + add_dependencies(${VIEWER_BINARY_NAME} copy_win_libs) if (EXISTS ${CMAKE_SOURCE_DIR}/copy_win_scripts) - add_dependencies(secondlife-bin copy_win_scripts) + add_dependencies(${VIEWER_BINARY_NAME} copy_win_scripts) endif (EXISTS ${CMAKE_SOURCE_DIR}/copy_win_scripts) add_custom_command( @@ -1340,14 +1361,14 @@ if (WINDOWS) ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py --configuration=${CMAKE_CFG_INTDIR} --channel=${VIEWER_CHANNEL} - --login_channel=${VIEWER_CHANNEL} + --login_channel=${VIEWER_LOGIN_CHANNEL} --grid=${GRID} --source=${CMAKE_CURRENT_SOURCE_DIR} --artwork=${ARTWORK_DIR} --build=${CMAKE_CURRENT_BINARY_DIR} --dest=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR} --touch=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/touched.bat - DEPENDS secondlife-bin ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py + DEPENDS ${VIEWER_BINARY_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py ) if (PACKAGE) add_custom_target(package ALL DEPENDS ${CMAKE_CFG_INTDIR}/touched.bat) @@ -1355,7 +1376,7 @@ if (WINDOWS) endif (PACKAGE) endif (WINDOWS) -target_link_libraries(secondlife-bin +target_link_libraries(${VIEWER_BINARY_NAME} ${LLAUDIO_LIBRARIES} ${LLCHARACTER_LIBRARIES} ${LLIMAGE_LIBRARIES} @@ -1376,7 +1397,7 @@ target_link_libraries(secondlife-bin ${viewer_LIBRARIES} ${BOOST_PROGRAM_OPTIONS_LIBRARY} ${BOOST_REGEX_LIBRARY} - ${BOOST_SIGNALS_LIBRARY} + ${DBUSGLIB_LIBRARIES} ${OPENGL_LIBRARIES} ${FMODWRAPPER_LIBRARY} ${OPENGL_LIBRARIES} @@ -1388,7 +1409,6 @@ target_link_libraries(secondlife-bin ${QUICKTIME_LIBRARY} ${WINDOWS_LIBRARIES} ${XMLRPCEPI_LIBRARIES} - ${ZLIB_LIBRARIES} ${ELFIO_LIBRARIES} ) @@ -1402,8 +1422,8 @@ if (LINUX) add_custom_command( OUTPUT secondlife-stripped COMMAND strip - ARGS --strip-debug -o secondlife-stripped secondlife-bin - DEPENDS secondlife-bin + ARGS --strip-debug -o secondlife-stripped ${VIEWER_BINARY_NAME} + DEPENDS ${VIEWER_BINARY_NAME} ) set(product SecondLife-${ARCH}-${viewer_VERSION}) @@ -1415,7 +1435,7 @@ if (LINUX) ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py --grid=${GRID} --channel=${VIEWER_CHANNEL} - --login_channel=${VIEWER_CHANNEL} + --login_channel=${VIEWER_LOGIN_CHANNEL} --installer_name=${product} --arch=${ARCH} --source=${CMAKE_CURRENT_SOURCE_DIR} @@ -1435,7 +1455,7 @@ endif (LINUX) if (DARWIN) set(product "Second Life") set_target_properties( - secondlife-bin + ${VIEWER_BINARY_NAME} PROPERTIES OUTPUT_NAME "${product}" MACOSX_BUNDLE_INFO_STRING "info string - localize me" @@ -1449,7 +1469,7 @@ if (DARWIN) ) add_custom_command( - TARGET secondlife-bin POST_BUILD + TARGET ${VIEWER_BINARY_NAME} POST_BUILD COMMAND ${PYTHON_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py @@ -1460,28 +1480,31 @@ if (DARWIN) --artwork=${ARTWORK_DIR} --build=${CMAKE_CURRENT_BINARY_DIR} --dest=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${product}.app - DEPENDS secondlife-bin ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py + DEPENDS ${VIEWER_BINARY_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py ) if (PACKAGE) - add_custom_target(package - COMMAND - ${PYTHON_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py - --grid=${GRID} - --configuration=${CMAKE_CFG_INTDIR} - --channel=${VIEWER_CHANNEL} - --login_channel=${VIEWER_CHANNEL} - --source=${CMAKE_CURRENT_SOURCE_DIR} - --artwork=${ARTWORK_DIR} - --build=${CMAKE_CURRENT_BINARY_DIR} - --dest=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${product}.app - --touch=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/.${product}.touched - DEPENDS - secondlife-bin - ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py - ) + add_custom_target(package ALL DEPENDS ${VIEWER_BINARY_NAME}) add_dependencies(package mac-updater mac-crash-logger) + + add_custom_command( + TARGET package POST_BUILD + COMMAND ${PYTHON_EXECUTABLE} + ARGS + ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py + --grid=${GRID} + --configuration=${CMAKE_CFG_INTDIR} + --channel=${VIEWER_CHANNEL} + --login_channel=${VIEWER_LOGIN_CHANNEL} + --source=${CMAKE_CURRENT_SOURCE_DIR} + --artwork=${ARTWORK_DIR} + --build=${CMAKE_CURRENT_BINARY_DIR} + --dest=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${product}.app + --touch=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/.${product}.touched + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py + ) + endif (PACKAGE) endif (DARWIN) diff --git a/linden/indra/newview/English.lproj/InfoPlist.strings b/linden/indra/newview/English.lproj/InfoPlist.strings index 881483e..90646be 100644 --- a/linden/indra/newview/English.lproj/InfoPlist.strings +++ b/linden/indra/newview/English.lproj/InfoPlist.strings @@ -1,6 +1,6 @@ /* Localized versions of Info.plist keys */ CFBundleName = "Second Life"; -CFBundleShortVersionString = "Second Life version 1.20.9.87416"; -CFBundleGetInfoString = "Second Life version 1.20.9.87416, Copyright 2004-2008 Linden Research, Inc."; +CFBundleShortVersionString = "Second Life version 1.20.15.97417"; +CFBundleGetInfoString = "Second Life version 1.20.15.97417, Copyright 2004-2008 Linden Research, Inc."; diff --git a/linden/indra/newview/Info-SecondLife.plist b/linden/indra/newview/Info-SecondLife.plist index b889d45..3c55bad 100644 --- a/linden/indra/newview/Info-SecondLife.plist +++ b/linden/indra/newview/Info-SecondLife.plist @@ -32,7 +32,7 @@ CFBundleVersion - 1.20.9.87416 + 1.20.15.97417 CSResourcesFileMapped diff --git a/linden/indra/newview/app_settings/keywords.ini b/linden/indra/newview/app_settings/keywords.ini index 3679c38..0ab977d 100644 --- a/linden/indra/newview/app_settings/keywords.ini +++ b/linden/indra/newview/app_settings/keywords.ini @@ -332,11 +332,11 @@ REMOTE_DATA_REQUEST Value of event_type in remote_event if XML-RPC request is re REMOTE_DATA_REPLY Value of event_type in remote_event if XML-RPC reply is received -PRIM_TYPE Followed by PRIM_TYPE_BOX, PRIM_TYPE_CYLINDER, PRIM_TYPE_PRISM, PRIM_TYPE_SPHERE,:PRIM_TYPE_TORUS, or PRIM_TYPE_TUBE and their arguments -PRIM_MATERIAL Sets material to PRIM_MATERIAL_STONE, PRIM_MATERIAL_METAL, PRIM_MATERIAL_GLASS,:PRIM_MATERIAL_WOOD, PRIM_MATERIAL_FLESH, PRIM_MATERIAL_PLASTIC,:PRIM_MATERIAL_RUBBER, or PRIM_MATERIAL_LIGHT +PRIM_TYPE Followed by PRIM_TYPE_BOX, PRIM_TYPE_CYLINDER, PRIM_TYPE_PRISM, PRIM_TYPE_SPHERE, PRIM_TYPE_TORUS, PRIM_TYPE_TUBE, or PRIM_TYPE_SCULPT and their arguments +PRIM_MATERIAL Followed by PRIM_MATERIAL_STONE, PRIM_MATERIAL_METAL, PRIM_MATERIAL_GLASS, PRIM_MATERIAL_WOOD, PRIM_MATERIAL_FLESH, PRIM_MATERIAL_PLASTIC, or PRIM_MATERIAL_RUBBER PRIM_PHYSICS Sets physics to TRUE or FALSE -PRIM_FLEXIBLE Sets primitive flexibility to TRUE or FALSE -PRIM_POINT_LIGHT Sets light emission to TRUE or FALSE +PRIM_FLEXIBLE Followed by TRUE or FALSE, integer softness, float gravity, float friction, float wind, float tension, and vector force +PRIM_POINT_LIGHT Followed by TRUE or FALSE, vector color, float intensity, float radius, float falloff PRIM_TEMP_ON_REZ Sets temporay on rez to TRUE or FALSE PRIM_PHANTOM Sets phantom to TRUE or FALSE PRIM_CAST_SHADOWS DEPRECATED. Takes 1 parameter, an integer, but has no effect when set and always returns 0 if used in llGetPrimitiveParams. @@ -357,7 +357,7 @@ PRIM_TYPE_SPHERE Followed by integer hole shape, vector cut, float hollow, vecto PRIM_TYPE_TORUS Followed by integer hole shape, vector cut, float hollow, vector twist,:vector hole size, vector top shear, vector advanced cut, vector taper,:float revolutions, float radius offset, and float skew PRIM_TYPE_TUBE Followed by integer hole shape, vector cut, float hollow, vector twist,:vector hole size, vector top shear, vector advanced cut, vector taper,:float revolutions, float radius offset, and float skew PRIM_TYPE_RING Followed by integer hole shape, vector cut, float hollow, vector twist,:vector hole size, vector top shear, vector advanced cut, vector taper,:float revolutions, float radius offset, and float skew -PRIM_TYPE_SCULPT Followed by a key or string texture uuid. +PRIM_TYPE_SCULPT Followed by a key/string texture uuid, and one of PRIM_SCULPT_TYPE_SPHERE, PRIM_SCULPT_TYPE_TORUS, PRIM_SCULPT_TYPE_PLANE, or PRIM_SCULPT_TYPE_CYLINDER PRIM_HOLE_DEFAULT Sets hole type to match the prim type. PRIM_HOLE_SQUARE Sets hole type to square. diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index 07fa71c..9dac926 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -1838,17 +1838,6 @@ 0 - CompressSnapshotsToDisk - - Comment - Compress snapshots saved to disk (Using JPEG 2000) - Persist - 1 - Type - Boolean - Value - 0 - ConnectAsGod Comment @@ -2660,6 +2649,22 @@ 0 + FloaterBeaconsRect + + Comment + Rectangle for beacon and highlight controls + Persist + 1 + Type + Rect + Value + + 200 + 250 + 250 + 200 + + FloaterBuildOptionsRect Comment @@ -3595,6 +3600,17 @@ Value 0 + ForceMandatoryUpdate + + Comment + For QA: On next startup, forces the auto-updater to run + Persist + 1 + Type + Boolean + Value + 0 + ForwardBtnRect Comment @@ -4178,7 +4194,7 @@ Type String Value - https://wiki.secondlife.com/wiki/[LSL_STRING] + http://wiki.secondlife.com/wiki/[LSL_STRING] LagMeterShrunk @@ -4268,10 +4284,11 @@ Value 0.0.0 - LastSnapshotHeight + + LastSnapshotToEmailHeight Comment - The height of the last snapshot, in px + The height of the last email snapshot, in px Persist 1 Type @@ -4279,21 +4296,32 @@ Value 768 - LastSnapshotType + LastSnapshotToEmailWidth Comment - Select this as next type of snapshot to take (0 = postcard, 1 = texture, 2 = local image) + The width of the last email snapshot, in px Persist 1 Type S32 Value - 0 + 1024 - LastSnapshotWidth + LastSnapshotToDiskHeight Comment - The width of the last snapshot, in px + The height of the last disk snapshot, in px + Persist + 1 + Type + S32 + Value + 768 + + LastSnapshotToDiskWidth + + Comment + The width of the last disk snapshot, in px Persist 1 Type @@ -4301,6 +4329,39 @@ Value 1024 + LastSnapshotToInventoryHeight + + Comment + The height of the last texture snapshot, in px + Persist + 1 + Type + S32 + Value + 512 + + LastSnapshotToInventoryWidth + + Comment + The width of the last texture snapshot, in px + Persist + 1 + Type + S32 + Value + 512 + + LastSnapshotType + + Comment + Select this as next type of snapshot to take (0 = postcard, 1 = texture, 2 = local image) + Persist + 1 + Type + S32 + Value + 0 + LeftClickShowMenu Comment @@ -4477,17 +4538,6 @@ Value 20.0 - MainloopTimeoutDefault - - Comment - Timeout duration for mainloop lock detection, in seconds. - Persist - 1 - Type - F32 - Value - 10.0 - MapOverlayIndex Comment @@ -6055,6 +6105,17 @@ Value 1.3 + RenderGround + + Comment + Determines whether we can render the ground pool or not + Persist + 1 + Type + Boolean + Value + 1 + RenderHUDInSnapshot Comment @@ -10039,7 +10100,7 @@ Type Boolean Value - 0 + 1 WaterEditPresets diff --git a/linden/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl b/linden/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl index 0df89c8..78b96b3 100644 --- a/linden/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl @@ -11,7 +11,7 @@ void calcAtmospherics(vec3 inPositionEye); void main() { //transform vertex - gl_Position = ftransform(); //gl_ModelViewProjectionMatrix * gl_Vertex; + gl_Position = ftransform(); gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; vec4 pos = (gl_ModelViewMatrix * gl_Vertex); diff --git a/linden/indra/newview/featuretable.txt b/linden/indra/newview/featuretable.txt index b227043..7af05a5 100644 --- a/linden/indra/newview/featuretable.txt +++ b/linden/indra/newview/featuretable.txt @@ -1,4 +1,4 @@ -version 17 +version 18 // NOTE: This is mostly identical to featuretable_mac.txt with a few differences // Should be combined into one table @@ -33,6 +33,7 @@ RenderFlexTimeFactor 1 1.0 RenderFogRatio 1 4.0 RenderGamma 1 0 RenderGlowResolutionPow 1 9 +RenderGround 1 1 RenderLightingDetail 1 1 RenderMaxPartCount 1 8192 RenderNightBrightness 1 1.0 @@ -347,21 +348,7 @@ RenderVBOEnable 0 0 list ATI_All-in-Wonder_7500 RenderVBOEnable 0 0 - -list ATI_Mobility_Radeon_9800 -RenderAvatarCloth 0 0 -VertexShaderEnable 0 0 -WindLightUseAtmosShaders 0 0 - -list ATI_Mobility_Radeon_9700 -RenderAvatarCloth 0 0 -VertexShaderEnable 0 0 -WindLightUseAtmosShaders 0 0 - list ATI_Mobility_Radeon_9600 -RenderAvatarCloth 0 0 -VertexShaderEnable 0 0 -WindLightUseAtmosShaders 0 0 Disregard96DefaultDrawDistance 1 0 diff --git a/linden/indra/newview/featuretable_linux.txt b/linden/indra/newview/featuretable_linux.txt index 3eaa781..0036f11 100644 --- a/linden/indra/newview/featuretable_linux.txt +++ b/linden/indra/newview/featuretable_linux.txt @@ -1,4 +1,4 @@ -version 17 +version 18 // NOTE: This is mostly identical to featuretable_mac.txt with a few differences // Should be combined into one table @@ -33,6 +33,7 @@ RenderFlexTimeFactor 1 1.0 RenderFogRatio 1 4.0 RenderGamma 1 0 RenderGlowResolutionPow 1 9 +RenderGround 1 1 RenderLightingDetail 1 1 RenderMaxPartCount 1 8192 RenderNightBrightness 1 1.0 @@ -343,21 +344,7 @@ RenderVBOEnable 0 0 list ATI_All-in-Wonder_7500 RenderVBOEnable 0 0 - -list ATI_Mobility_Radeon_9800 -RenderAvatarCloth 0 0 -VertexShaderEnable 0 0 -WindLightUseAtmosShaders 0 0 - -list ATI_Mobility_Radeon_9700 -RenderAvatarCloth 0 0 -VertexShaderEnable 0 0 -WindLightUseAtmosShaders 0 0 - list ATI_Mobility_Radeon_9600 -RenderAvatarCloth 0 0 -VertexShaderEnable 0 0 -WindLightUseAtmosShaders 0 0 Disregard96DefaultDrawDistance 1 0 diff --git a/linden/indra/newview/featuretable_mac.txt b/linden/indra/newview/featuretable_mac.txt index fab8ea9..54a7c11 100644 --- a/linden/indra/newview/featuretable_mac.txt +++ b/linden/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 16 +version 18 // NOTE: This is mostly identical to featuretable_mac.txt with a few differences // Should be combined into one table @@ -33,6 +33,7 @@ RenderFlexTimeFactor 1 1.0 RenderFogRatio 1 4.0 RenderGamma 1 0 RenderGlowResolutionPow 1 9 +RenderGround 1 1 RenderLightingDetail 1 1 RenderMaxPartCount 1 8192 RenderNightBrightness 1 1.0 @@ -291,6 +292,7 @@ RenderVBOEnable 1 0 list Intel_950 RenderTerrainDetail 1 0 RenderVBOEnable 1 0 +RenderGround 1 0 list Intel_965 RenderTerrainDetail 1 0 @@ -324,20 +326,7 @@ list Intel_Springdale RenderTerrainDetail 1 0 RenderVBOEnable 1 0 -list ATI_Mobility_Radeon_9800 -RenderAvatarCloth 0 0 -VertexShaderEnable 0 0 -WindLightUseAtmosShaders 0 0 - -list ATI_Mobility_Radeon_9700 -RenderAvatarCloth 0 0 -VertexShaderEnable 0 0 -WindLightUseAtmosShaders 0 0 - list ATI_Mobility_Radeon_9600 -RenderAvatarCloth 0 0 -VertexShaderEnable 0 0 -WindLightUseAtmosShaders 0 0 Disregard96DefaultDrawDistance 1 0 list NVIDIA_GeForce_8600 diff --git a/linden/indra/newview/gpu_table.txt b/linden/indra/newview/gpu_table.txt index 48af543..eee1831 100644 --- a/linden/indra/newview/gpu_table.txt +++ b/linden/indra/newview/gpu_table.txt @@ -26,6 +26,7 @@ ATI All-in-Wonder 7500 .*ATI.*All-in-Wonder 75.* 0 1 ATI All-in-Wonder 8500 .*ATI.*All-in-Wonder 85.* 0 1 ATI All-in-Wonder 9200 .*ATI.*All-in-Wonder 92.* 0 1 ATI All-in-Wonder 9xxx .*ATI.*All-in-Wonder 9.* 1 1 +ATI All-in-Wonder HD .*ATI.*All-in-Wonder HD.* 1 1 ATI All-in-Wonder X600 .*ATI.*All-in-Wonder X6.* 1 1 ATI All-in-Wonder X800 .*ATI.*All-in-Wonder X8.* 2 1 ATI All-in-Wonder X1800 .*ATI.*All-in-Wonder X18.* 3 1 @@ -35,7 +36,9 @@ ATI All-in-Wonder Radeon .*ATI.*All-in-Wonder Radeon.* 0 1 ATI ASUS A9xxx .*ATI.*ASUS.*A9.* 1 1 ATI ASUS AH24xx .*ATI.*ASUS.*AH24.* 1 1 ATI ASUS AH26xx .*ATI.*ASUS.*AH26.* 3 1 +ATI ASUS AH34xx .*ATI.*ASUS.*AH34.* 1 1 ATI ASUS AH36xx .*ATI.*ASUS.*AH36.* 3 1 +ATI ASUS AH46xx .*ATI.*ASUS.*AH46.* 3 1 ATI ASUS AX3xx .*ATI.*ASUS.*AX3.* 1 1 ATI ASUS AX5xx .*ATI.*ASUS.*AX5.* 1 1 ATI ASUS AX8xx .*ATI.*ASUS.*AX8.* 2 1 @@ -51,6 +54,7 @@ ATI Diamond X550 .*ATI.*Diamond X550.* 1 1 ATI Diamond X13xx .*ATI.*Diamond X13.* 1 1 ATI Diamond X16xx .*ATI.*Diamond X16.* 1 1 ATI Diamond X19xx .*ATI.*Diamond X19.* 1 1 +ATI Display Adapter .*ATI.*display adapter.* 0 1 ATI FireGL 5200 .*ATI.*FireGL V52.* 0 1 ATI FireGL 5xxx .*ATI.*FireGL V5.* 1 1 ATI FireGL .*ATI.*Fire.*GL.* 0 1 @@ -61,6 +65,8 @@ ATI IGP 340M .*ATI.*IGP.*340M.* 0 0 ATI M52 .*ATI.*M52.* 1 1 ATI M54 .*ATI.*M54.* 1 1 ATI M56 .*ATI.*M56.* 1 1 +ATI M71 .*ATI.*M71.* 1 1 +ATI M72 .*ATI.*M72.* 1 1 ATI M76 .*ATI.*M76.* 3 1 ATI Mobility Radeon 7xxx .*ATI.*Mobility.*Radeon 7.* 0 1 ATI Mobility Radeon 8xxx .*ATI.*Mobility.*Radeon 8.* 0 1 @@ -84,9 +90,13 @@ ATI Radeon HD 2300 .*ATI.*Radeon HD 23.* 0 1 ATI Radeon HD 2400 .*ATI.*Radeon HD.*24.* 1 1 ATI Radeon HD 2600 .*ATI.*Radeon HD 26.* 2 1 ATI Radeon HD 2900 .*ATI.*Radeon HD 29.* 3 1 +ATI Radeon HD 3200 .*ATI.*Radeon HD.*32.* 1 1 +ATI Radeon HD 3300 .*ATI.*Radeon HD.*33.* 1 1 ATI Radeon HD 3400 .*ATI.*Radeon HD.*34.* 1 1 ATI Radeon HD 3600 .*ATI.*Radeon HD.*36.* 3 1 ATI Radeon HD 3800 .*ATI.*Radeon HD.*38.* 3 1 +ATI Radeon HD 4300 .*ATI.*Radeon HD 43.* 1 1 +ATI Radeon HD 4600 .*ATI.*Radeon HD 46.* 3 1 ATI Radeon HD 4800 .*ATI.*Radeon HD.*48.* 3 1 ATI Radeon OpenGL .*ATI.*Radeon OpenGL.* 0 0 ATI Radeon 2100 .*ATI.*Radeon 21.* 0 1 @@ -104,13 +114,14 @@ ATI Radeon RV250 .*ATI.*RV250.* 0 1 ATI Radeon RV600 .*ATI.*RV6.* 1 1 ATI Radeon RX700 .*ATI.*RX70.* 1 1 ATI Radeon RX800 .*ATI.*Radeon *RX80.* 2 1 +ATI Radeon RX9550 .*ATI.*RX9550.* 1 1 ATI Radeon VE .*ATI.*Radeon.*VE.* 0 0 ATI Radeon X1000 .*ATI.*Radeon *X10.* 0 1 ATI Radeon X1200 .*ATI.*Radeon *X12.* 0 1 ATI Radeon X1300 .*ATI.*Radeon *X13.* 1 1 ATI Radeon X1400 .*ATI.*Radeon X14.* 1 1 ATI Radeon X1500 .*ATI.*Radeon X15.* 1 1 -ATI Radeon X1600 .*ATI.*Radeon X16.* 1 1 +ATI Radeon X1600 .*ATI.*Radeon *X16.* 1 1 ATI Radeon X1700 .*ATI.*Radeon X17.* 1 1 ATI Radeon X1800 .*ATI.*Radeon X18.* 3 1 ATI Radeon X1900 .*ATI.*Radeon X19.* 3 1 @@ -134,8 +145,8 @@ Intel 865G .*Intel.*865G 0 0 Intel 900 .*Intel.*900.*900 0 0 Intel 915GM .*Intel.*915GM 0 0 Intel 915G .*Intel.*915G 0 0 -Intel 945GM .*Intel.*945GM 0 1 -Intel 945G .*Intel.*945G 0 1 +Intel 945GM .*Intel.*945GM.* 0 1 +Intel 945G .*Intel.*945G.* 0 1 Intel 950 .*Intel.*950.* 0 1 Intel 965 .*Intel.*965.* 0 1 Intel G33 .*Intel.*G33.* 0 0 @@ -143,15 +154,20 @@ Intel G45 .*Intel.*G45.* 0 1 Intel Bear Lake .*Intel.*Bear Lake.* 0 0 Intel Broadwater .*Intel.*Broadwater.* 0 0 Intel Brookdale .*Intel.*Brookdale.* 0 0 -Intel Eaglelake .*Intel.*Eaglelake.* 0 1 +Intel Cantiga .*Intel.*Cantiga.* 0 0 +Intel Eaglelake .*Intel.*Eaglelake.* 0 0 Intel Montara .*Intel.*Montara.* 0 0 Intel Springdale .*Intel.*Springdale.* 0 0 Matrox .*Matrox.* 0 0 Mesa .*Mesa.* 0 0 NVIDIA GTX 260 .*NVIDIA.*GeForce.*GTX.*260.* 3 1 NVIDIA GTX 280 .*NVIDIA.*GeForce.*GTX.*280.* 3 1 +NVIDIA C51 .*NVIDIA.*C51.* 0 1 NVIDIA G72 .*NVIDIA.*G72.* 1 1 NVIDIA G73 .*NVIDIA.*G73.* 1 1 +NVIDIA G84 .*NVIDIA.*G84.* 3 1 +NVIDIA G86 .*NVIDIA.*G86.* 3 1 +NVIDIA G92 .*NVIDIA.*G92.* 3 1 NVIDIA GeForce .*GeForce 256.* 0 0 NVIDIA GeForce 2 .*GeForce2.* 0 1 NVIDIA GeForce 3 .*GeForce3.* 0 1 @@ -170,17 +186,24 @@ NVIDIA GeForce 7200 .*NVIDIA.*GeForce 72.* 1 1 NVIDIA GeForce 7300 .*NVIDIA.*GeForce 73.* 1 1 NVIDIA GeForce 7500 .*NVIDIA.*GeForce 75.* 1 1 NVIDIA GeForce 7600 .*NVIDIA.*GeForce 76.* 2 1 -NVIDIA GeForce 7800 .*NVIDIA.*GeForce 78.* 2 1 +NVIDIA GeForce 7800 .*NVIDIA.*GeForce.*78.* 2 1 NVIDIA GeForce 7900 .*NVIDIA.*GeForce 79.* 2 1 +NVIDIA GeForce 8100 .*NVIDIA.*GeForce 81.* 1 1 NVIDIA GeForce 8200 .*NVIDIA.*GeForce 82.* 1 1 NVIDIA GeForce 8300 .*NVIDIA.*GeForce 83.* 1 1 NVIDIA GeForce 8400 .*NVIDIA.*GeForce 84.* 1 1 -NVIDIA GeForce 8500 .*NVIDIA.*GeForce 85.* 3 1 +NVIDIA GeForce 8500 .*GeForce 85.* 3 1 NVIDIA GeForce 8600 .*NVIDIA.*GeForce 86.* 3 1 NVIDIA GeForce 8700 .*NVIDIA.*GeForce 87.* 3 1 NVIDIA GeForce 8800 .*NVIDIA.*GeForce 88.* 3 1 NVIDIA GeForce 9300M .*NVIDIA.*GeForce 9300M.* 1 1 +NVIDIA GeForce 9400M .*NVIDIA.*GeForce 9400M.* 1 1 NVIDIA GeForce 9500M .*NVIDIA.*GeForce 9500M.* 2 1 +NVIDIA GeForce 9600M .*NVIDIA.*GeForce 9600M.* 2 1 +NVIDIA GeForce 9700M .*NVIDIA.*GeForce 9700M.* 2 1 +NVIDIA GeForce 9300 .*NVIDIA.*GeForce 93.* 1 1 +NVIDIA GeForce 9400 .*GeForce 94.* 1 1 +NVIDIA GeForce 9500 .*NVIDIA.*GeForce 95.* 2 1 NVIDIA GeForce 9600 .*NVIDIA.*GeForce 96.* 3 1 NVIDIA GeForce 9800 .*NVIDIA.*GeForce 98.* 3 1 NVIDIA GeForce FX 5100 .*NVIDIA.*GeForce FX 51.* 0 1 @@ -212,11 +235,23 @@ NVIDIA GeForce Go 7600 .*NVIDIA.*GeForce Go 76.* 2 1 NVIDIA GeForce Go 7700 .*NVIDIA.*GeForce Go 77.* 2 1 NVIDIA GeForce Go 7800 .*NVIDIA.*GeForce Go 78.* 2 1 NVIDIA GeForce Go 7900 .*NVIDIA.*GeForce Go 79.* 2 1 +NVIDIA GeForce GTX 260 .*NVIDIA.*GeForce GTX 26.* 3 1 +NVIDIA GeForce GTX 280 .*NVIDIA.*GeForce GTX 28.* 3 1 +NVIDIA D9M .*D9M.* 1 1 +NVIDIA G84 .*G84.* 1 1 +NVIDIA G92 .*G92.* 3 1 +NVIDIA G94 .*G94.* 3 1 NVIDIA GeForce Go 6 .*GeForce Go 6.* 1 1 +NVIDIA NB9M .*GeForce NB9M.* 1 1 +NVIDIA NB9P .*GeForce NB9P.* 1 1 NVIDIA GeForce PCX .*GeForce PCX.* 0 1 NVIDIA Generic .*NVIDIA.*Unknown.* 0 0 +NVIDIA NV17 .*GeForce NV17.* 0 1 NVIDIA NV34 .*NVIDIA.*NV34.* 0 1 +NVIDIA NV36 .*GeForce NV36.* 1 1 NVIDIA NV43 .*NVIDIA.*NV43.* 1 1 +NVIDIA NV44 .*NVIDIA.*NV44.* 1 1 +NVIDIA nForce .*NVIDIA.*nForce.* 0 0 NVIDIA MCP78 .*NVIDIA.*MCP78.* 1 1 NVIDIA Quadro2 .*Quadro2.* 0 1 NVIDIA Quadro4 .*Quadro4.* 0 1 @@ -225,10 +260,12 @@ NVIDIA Quadro FX 4500 .*Quadro.*FX.*4500.* 3 1 NVIDIA Quadro FX .*Quadro FX.* 1 1 NVIDIA Quadro NVS .*Quadro NVS.* 0 1 NVIDIA RIVA TNT .*RIVA TNT.* 0 0 +NVIDIA PCI .*NVIDIA.*/PCI/SSE2 0 0 S3 .*S3 Graphics.* 0 0 SiS SiS.* 0 0 Trident Trident.* 0 0 Tungsten Graphics Tungsten.* 0 0 XGI XGI.* 0 0 VIA VIA.* 0 0 - +Apple Generic Apple.*Generic.* 0 0 +Apple Software Renderer Apple.*Software Renderer.* 0 0 diff --git a/linden/indra/newview/installers/darwin/releasecandidate-dmg/_DS_Store b/linden/indra/newview/installers/darwin/releasecandidate-dmg/_DS_Store index c73ba24..a8b7573 100644 Binary files a/linden/indra/newview/installers/darwin/releasecandidate-dmg/_DS_Store and b/linden/indra/newview/installers/darwin/releasecandidate-dmg/_DS_Store differ diff --git a/linden/indra/newview/installers/windows/FILES_ARE_UNICODE_UTF-16LE.txt b/linden/indra/newview/installers/windows/FILES_ARE_UNICODE_UTF-16LE.txt new file mode 100644 index 0000000..185c018 --- /dev/null +++ b/linden/indra/newview/installers/windows/FILES_ARE_UNICODE_UTF-16LE.txt @@ -0,0 +1,6 @@ +The language files in this directory are Unicode (Little-Endian) format, also known as UTF-16 LE. + +This is the format required for NSIS Unicode. See http://www.scratchpaper.com/ for details. + +James Cook +September 2008 diff --git a/linden/indra/newview/installers/windows/installer_template.nsi b/linden/indra/newview/installers/windows/installer_template.nsi index c795507..01bd98f 100644 --- a/linden/indra/newview/installers/windows/installer_template.nsi +++ b/linden/indra/newview/installers/windows/installer_template.nsi @@ -1,30 +1,22 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; secondlife setup.nsi -;; Copyright 2004-2007, Linden Research, Inc. -;; For info, see http://www.nullsoft.com/free/nsis/ +;; Copyright 2004-2008, Linden Research, Inc. +;; +;; NSIS Unicode 2.38.1 or higher required +;; http://www.scratchpaper.com/ ;; -;; NSIS 2.22 or higher required ;; Author: James Cook, Don Kjer, Callum Prentice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Detect NSIS compiler version -!define "NSIS${NSIS_VERSION}" -!ifdef "NSISv2.02" | "NSISv2.03" | "NSISv2.04" | "NSISv2.05" | "NSISv2.06" - ;; before 2.07 defaulted lzma to solid (whole file) - SetCompressor lzma -!else - ;; after 2.07 required /solid for whole file compression - SetCompressor /solid lzma -!endif - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Compiler flags ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SetOverwrite on ; overwrite files SetCompress auto ; compress iff saves space +SetCompressor /solid lzma ; compress whole installer as one block SetDatablockOptimize off ; only saves us 0.1%, not worth it XPStyle on ; add an XP manifest to the installer +RequestExecutionLevel admin ; on Vista we must be admin because we write to Program Files ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Project flags @@ -41,9 +33,22 @@ XPStyle on ; add an XP manifest to the installer !include "%%SOURCE%%\installers\windows\lang_en-us.nsi" !include "%%SOURCE%%\installers\windows\lang_ja.nsi" !include "%%SOURCE%%\installers\windows\lang_ko.nsi" +!include "%%SOURCE%%\installers\windows\lang_pt-br.nsi" +!include "%%SOURCE%%\installers\windows\lang_fr.nsi" +!include "%%SOURCE%%\installers\windows\lang_es.nsi" +!include "%%SOURCE%%\installers\windows\lang_it.nsi" +!include "%%SOURCE%%\installers\windows\lang_nl.nsi" +!include "%%SOURCE%%\installers\windows\lang_zh.nsi" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Tweak for different servers/builds (this placeholder is replaced by viewer_manifest.py) +;; For example: +;; !define INSTFLAGS "%(flags)s" +;; !define INSTNAME "SecondLife%(grid_caps)s" +;; !define SHORTCUT "Second Life (%(grid_caps)s)" +;; !define URLNAME "secondlife%(grid)s" +;; !define UNINSTALL_SETTINGS 1 + %%GRID_VARS%% Name ${INSTNAME} @@ -63,11 +68,7 @@ AutoCloseWindow true ; after all files install, close window InstallDir "$PROGRAMFILES\${INSTNAME}" InstallDirRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\${INSTNAME}" "" -!ifdef UPDATE -DirText $(DirectoryChooseTitle) $(DirectoryChooseUpdate) -!else DirText $(DirectoryChooseTitle) $(DirectoryChooseSetup) -!endif ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -76,145 +77,41 @@ DirText $(DirectoryChooseTitle) $(DirectoryChooseSetup) Var INSTPROG Var INSTEXE Var INSTFLAGS -Var LANGFLAGS Var INSTSHORTCUT +Var COMMANDLINE ; command line passed to this installer, set in .onInit -;;; Function definitions should go before file includes, because the NSIS package -;;; is a single stream of bytecodes + file data. So if your function definitions are at -;;; the end of the file it has to decompress the whole thing before it can call a function. JC - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; PostInstallExe -; This just runs any post installation scripts. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -Function PostInstallExe -push $0 - ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "PostInstallExe" - ;MessageBox MB_OK '$0' - ExecWait '$0' -pop $0 -FunctionEnd +;;; Function definitions should go before file includes, because calls to +;;; DLLs like LangDLL trigger an implicit file include, so if that call is at +;;; the end of this script NSIS has to decompress the whole installer before +;;; it can call the DLL function. JC -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; CheckStartupParameters -; Sets INSTFLAGS, INSTPROG, and INSTEXE. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -Function CheckStartupParams -push $0 -push $R0 - - ; Look for a registry entry with info about where to update. - Call GetProgramName - pop $R0 - StrCpy $INSTPROG "$R0" - StrCpy $INSTEXE "$R0.exe" - - ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "" - ; If key doesn't exist, skip install - IfErrors ABORT - StrCpy $INSTDIR "$0" - - ; We now have a directory to install to. Get the startup parameters and shortcut as well. - ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "Flags" - IfErrors +2 - StrCpy $INSTFLAGS "$0" - ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "Shortcut" - IfErrors +2 - StrCpy $INSTSHORTCUT "$0" - ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "Exe" - IfErrors +2 - StrCpy $INSTEXE "$0" - Goto FINISHED - -ABORT: - MessageBox MB_OK $(CheckStartupParamsMB) - Quit - -FINISHED: - ;MessageBox MB_OK "INSTPROG: $INSTPROG, INSTEXE: $INSTEXE, INSTFLAGS: $INSTFLAGS" -pop $R0 -pop $0 -FunctionEnd - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -Function un.CheckStartupParams -push $0 -push $R0 - - ; Look for a registry entry with info about where to update. - Call un.GetProgramName - pop $R0 - StrCpy $INSTPROG "$R0" - StrCpy $INSTEXE "$R0.exe" - - ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "" - ; If key doesn't exist, skip install - IfErrors ABORT - StrCpy $INSTDIR "$0" - - ; We now have a directory to install to. Get the startup parameters and shortcut as well. - ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "Flags" - IfErrors +2 - StrCpy $INSTFLAGS "$0" - ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "Shortcut" - IfErrors +2 - StrCpy $INSTSHORTCUT "$0" - ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "Exe" - IfErrors +2 - StrCpy $INSTEXE "$0" - Goto FINISHED - -ABORT: - MessageBox MB_OK $(CheckStartupParamsMB) - Quit - -FINISHED: - ;MessageBox MB_OK "INSTPROG: $INSTPROG, INSTEXE: $INSTEXE, INSTFLAGS: $INSTFLAGS" -pop $R0 -pop $0 -FunctionEnd +!include "FileFunc.nsh" ; For GetParameters, GetOptions +!insertmacro GetParameters +!insertmacro GetOptions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; After install completes, offer readme file +;;; After install completes, launch app ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Function .onInstSuccess - MessageBox MB_YESNO \ - $(InstSuccesssQuestion) /SD IDYES IDNO NoReadme - ; Assumes SetOutPath $INSTDIR - Exec '"$INSTDIR\$INSTEXE" $INSTFLAGS' - NoReadme: + Push $R0 # Option value, unused + ${GetOptions} $COMMANDLINE "/AUTOSTART" $R0 + # If parameter was there (no error) just launch + # Otherwise ask + IfErrors label_ask_launch label_launch + +label_ask_launch: + # Don't launch by default when silent + IfSilent label_no_launch + MessageBox MB_YESNO $(InstSuccesssQuestion) \ + IDYES label_launch IDNO label_no_launch + +label_launch: + # Assumes SetOutPath $INSTDIR + Exec '"$INSTDIR\$INSTEXE" $INSTFLAGS' +label_no_launch: + Pop $R0 FunctionEnd -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Remove old NSIS version. Modifies no variables. -; Does NOT delete the LindenWorld directory, or any -; user files in that directory. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -Function RemoveNSIS - Push $0 - ; Grab the installation directory of the old version - DetailPrint $(RemoveOldNSISVersion) - ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "" - - ; If key doesn't exist, skip uninstall - IfErrors NO_NSIS - - ; Clean up legacy beta shortcuts - Delete "$SMPROGRAMS\Second Life Beta.lnk" - Delete "$DESKTOP\Second Life Beta.lnk" - Delete "$SMPROGRAMS\Second Life.lnk" - - ; Clean up old newview.exe file - Delete "$INSTDIR\newview.exe" - - ; Intentionally don't delete the stuff in - ; Documents and Settings, so we keep the user's settings - - NO_NSIS: - Pop $0 -FunctionEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Make sure we're not on Windows 98 / ME @@ -242,28 +139,28 @@ FunctionEnd ; Make sure the user can install/uninstall ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Function CheckIfAdministrator - DetailPrint $(CheckAdministratorInstDP) - UserInfo::GetAccountType - Pop $R0 - StrCmp $R0 "Admin" is_admin - MessageBox MB_OK $(CheckAdministratorInstMB) - Quit -is_admin: - Return + DetailPrint $(CheckAdministratorInstDP) + UserInfo::GetAccountType + Pop $R0 + StrCmp $R0 "Admin" lbl_is_admin + MessageBox MB_OK $(CheckAdministratorInstMB) + Quit +lbl_is_admin: + Return FunctionEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Function un.CheckIfAdministrator - DetailPrint $(CheckAdministratorUnInstDP) - UserInfo::GetAccountType - Pop $R0 - StrCmp $R0 "Admin" is_admin - MessageBox MB_OK $(CheckAdministratorUnInstMB) - Quit -is_admin: - Return + DetailPrint $(CheckAdministratorUnInstDP) + UserInfo::GetAccountType + Pop $R0 + StrCmp $R0 "Admin" lbl_is_admin + MessageBox MB_OK $(CheckAdministratorUnInstMB) + Quit +lbl_is_admin: + Return FunctionEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -310,6 +207,33 @@ Function CloseSecondLife Return FunctionEnd +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Test our connection to secondlife.com +; Also allows us to count attempted installs by examining web logs. +; *TODO: Return current SL version info and have installer check +; if it is up to date. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +Function CheckNetworkConnection + Push $0 + Push $1 + DetailPrint $(CheckNetworkConnectionDP) + GetTempFileName $0 + !define HTTP_TIMEOUT 5000 ; milliseconds + ; Don't show secondary progress bar, this will be quick. + NSISdl::download_quiet \ + /TIMEOUT=${HTTP_TIMEOUT} \ + "http://join.secondlife.com/installer-check/?v=${VERSION_LONG}" \ + $0 + Pop $1 ; Return value, either "success", "cancel" or an error message + ; MessageBox MB_OK "Download result: $1" + ; Result ignored for now + ; StrCmp $1 "success" +2 + ; DetailPrint "Connection failed: $1" + Delete $0 ; temporary file + Pop $1 + Pop $0 + Return +FunctionEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Delete files in Documents and Settings\\SecondLife\cache @@ -577,7 +501,6 @@ StrCpy $INSTFLAGS "" StrCpy $INSTPROG "${INSTNAME}" StrCpy $INSTEXE "${INSTEXE}" StrCpy $INSTSHORTCUT "${SHORTCUT}" -Call un.CheckStartupParams ; Figure out where, what and how to uninstall. Call un.CheckIfAdministrator ; Make sure the user can install/uninstall ; uninstall for all users (if you change this, change it in the install as well) @@ -586,10 +509,9 @@ SetShellVarContext all ; Make sure we're not running Call un.CloseSecondLife -; Clean up registry keys (these should all be !defines somewhere) +; Clean up registry keys and subkeys (these should all be !defines somewhere) DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$INSTPROG" -DeleteRegKey HKEY_LOCAL_MACHINE "Software\Linden Research, Inc.\Installer Language" ; Clean up shortcuts Delete "$SMPROGRAMS\$INSTSHORTCUT\*.*" @@ -613,123 +535,6 @@ Call un.ProgramFiles SectionEnd ; end of uninstall section -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; (From the NSIS wiki, DK) -; GetParameterValue -; -; Usage: -; !insertmacro GetParameterValue "/L=" "1033" -; pop $R0 -; -; Returns on top of stack -; -; Example command lines: -; foo.exe /S /L=1033 /D=C:\Program Files\Foo -; or: -; foo.exe /S "/L=1033" /D="C:\Program Files\Foo" -; gpv "/L=" "1033" -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - !macro GetParameterValue SWITCH DEFAULT - Push $0 - Push $1 - Push $2 - Push $3 - Push $4 - - ;$CMDLINE='"My Setup\Setup.exe" /L=1033 /S' - Push "$CMDLINE" - Push '${SWITCH}"' - !insertmacro StrStr - Pop $0 - StrCmp "$0" "" gpv_notquoted - ;$0='/L="1033" /S' - StrLen $2 "$0" - Strlen $1 "${SWITCH}" - IntOp $1 $1 + 1 - StrCpy $0 "$0" $2 $1 - ;$0='1033" /S' - Push "$0" - Push '"' - !insertmacro StrStr - Pop $1 - StrLen $2 "$0" - StrLen $3 "$1" - IntOp $4 $2 - $3 - StrCpy $0 $0 $4 0 - Goto gpv_done - - gpv_notquoted: - Push "$CMDLINE" - Push "${SWITCH}" - !insertmacro StrStr - Pop $0 - StrCmp "$0" "" gpv_done - ;$0='/L="1033" /S' - StrLen $2 "$0" - Strlen $1 "${SWITCH}" - StrCpy $0 "$0" $2 $1 - ;$0=1033 /S' - Push "$0" - Push ' ' - !insertmacro StrStr - Pop $1 - StrLen $2 "$0" - StrLen $3 "$1" - IntOp $4 $2 - $3 - StrCpy $0 $0 $4 0 - Goto gpv_done - - gpv_done: - StrCmp "$0" "" 0 +2 - StrCpy $0 "${DEFAULT}" - - Pop $4 - Pop $3 - Pop $2 - Pop $1 - Exch $0 - !macroend - -; And I had to modify StrStr a tiny bit. -; Possible upgrade switch the goto's to use ${__LINE__} - -!macro STRSTR - Exch $R1 ; st=haystack,old$R1, $R1=needle - Exch ; st=old$R1,haystack - Exch $R2 ; st=old$R1,old$R2, $R2=haystack - Push $R3 - Push $R4 - Push $R5 - StrLen $R3 $R1 - StrCpy $R4 0 - ; $R1=needle - ; $R2=haystack - ; $R3=len(needle) - ; $R4=cnt - ; $R5=tmp - ; loop; - StrCpy $R5 $R2 $R3 $R4 - StrCmp $R5 $R1 +4 - StrCmp $R5 "" +3 - IntOp $R4 $R4 + 1 - Goto -4 - ; done; - StrCpy $R1 $R2 "" $R4 - Pop $R5 - Pop $R4 - Pop $R3 - Pop $R2 - Exch $R1 -!macroend - -Function GetProgramName - !insertmacro GetParameterValue "/P=" "SecondLife" -FunctionEnd - -Function un.GetProgramName - !insertmacro GetParameterValue "/P=" "SecondLife" -FunctionEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; (From the NSIS documentation, JC) @@ -827,42 +632,59 @@ FunctionEnd ;; entry to the language ID selector below ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Function .onInit - - ; read the language from registry (ok if not there) and set langauge menu + Push $0 + ${GetParameters} $COMMANDLINE ; get our command line + ${GetOptions} $COMMANDLINE "/LANGID=" $0 ; /LANGID=1033 implies US English + ; If no language (error), then proceed + IfErrors lbl_check_silent + ; No error means we got a language, so use it + StrCpy $LANGUAGE $0 + Goto lbl_return + +lbl_check_silent: + ; For silent installs, no language prompt, use default + IfSilent lbl_return + + ; If we currently have a version of SL installed, default to the language of that install + ; Otherwise don't change $LANGUAGE and it will default to the OS UI language. ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\${INSTNAME}" "InstallerLanguage" + IfErrors lbl_build_menu StrCpy $LANGUAGE $0 +lbl_build_menu: Push "" - Push ${LANG_ENGLISH} - Push English - Push ${LANG_GERMAN} - Push German - Push ${LANG_JAPANESE} - Push Japanese - Push ${LANG_KOREAN} - Push Korean + # Use separate file so labels can be UTF-16 but we can still merge changes + # into this ASCII file. JC + !include "%%SOURCE%%\installers\windows\language_menu.nsi" + Push A ; A means auto count languages for the auto count to work the first empty push (Push "") must remain - LangDLL::LangDialog "Installer Language" "Please select the language of the installer" - Pop $LANGUAGE - StrCmp $LANGUAGE "cancel" 0 +2 + LangDLL::LangDialog $(InstallerLanguageTitle) $(SelectInstallerLanguage) + Pop $0 + StrCmp $0 "cancel" 0 +2 Abort + StrCpy $LANGUAGE $0 ; save language in registry WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\${INSTNAME}" "InstallerLanguage" $LANGUAGE +lbl_return: + Pop $0 + Return FunctionEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Function un.onInit - - ; read language from registry and set for ininstaller + ; read language from registry and set for uninstaller + ; Key will be removed on successful uninstall ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\${INSTNAME}" "InstallerLanguage" + IfErrors lbl_end StrCpy $LANGUAGE $0 - +lbl_end: + Return FunctionEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Sections +;;; MAIN SECTION ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Section "" ; (default section) @@ -874,15 +696,11 @@ StrCpy $INSTPROG "${INSTNAME}" StrCpy $INSTEXE "${INSTEXE}" StrCpy $INSTSHORTCUT "${SHORTCUT}" -IfSilent +2 -Goto NOT_SILENT - Call CheckStartupParams ; Figure out where, what and how to install. -NOT_SILENT: Call CheckWindowsVersion ; warn if on Windows 98/ME Call CheckIfAdministrator ; Make sure the user can install/uninstall Call CheckIfAlreadyCurrent ; Make sure that we haven't already installed this version Call CloseSecondLife ; Make sure we're not running -Call RemoveNSIS ; Check for old NSIS install to remove +Call CheckNetworkConnection ; ping secondlife.com ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Don't remove cache files during a regular install, removing the inventory cache on upgrades results in lots of damage to the servers. @@ -907,9 +725,6 @@ Call RemoveOldReleaseNotes ;; This placeholder is replaced by the complete list of all the files in the installer, by viewer_manifest.py %%INSTALL_FILES%% -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; If this is a silent update, we don't need to re-create these shortcuts or registry entries. -IfSilent POST_INSTALL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Shortcuts in start menu @@ -918,25 +733,18 @@ SetOutPath "$INSTDIR" CreateShortCut "$SMPROGRAMS\$INSTSHORTCUT\$INSTSHORTCUT.lnk" \ "$INSTDIR\$INSTEXE" "$INSTFLAGS" -!ifdef MUSEUM -CreateShortCut "$SMPROGRAMS\$INSTSHORTCUT\$INSTSHORTCUT Museum.lnk" \ - "$INSTDIR\$INSTEXE" "$INSTFLAGS -simple" -CreateShortCut "$SMPROGRAMS\$INSTSHORTCUT\$INSTSHORTCUT Museum Spanish.lnk" \ - - "$INSTDIR\$INSTEXE" "$INSTFLAGS -simple -spanish" -!endif - -WriteINIStr "$SMPROGRAMS\$INSTSHORTCUT\SL Create Trial Account.url" \ +WriteINIStr "$SMPROGRAMS\$INSTSHORTCUT\SL Create Account.url" \ "InternetShortcut" "URL" \ "http://www.secondlife.com/registration/" WriteINIStr "$SMPROGRAMS\$INSTSHORTCUT\SL Your Account.url" \ "InternetShortcut" "URL" \ "http://www.secondlife.com/account/" -CreateShortCut "$SMPROGRAMS\$INSTSHORTCUT\SL Scripting Language Help.lnk" \ - "$INSTDIR\lsl_guide.html" +WriteINIStr "$SMPROGRAMS\$INSTSHORTCUT\SL Scripting Language Help.url" \ + "InternetShortcut" "URL" \ + "http://wiki.secondlife.com/wiki/LSL_Portal" CreateShortCut "$SMPROGRAMS\$INSTSHORTCUT\Uninstall $INSTSHORTCUT.lnk" \ - '"$INSTDIR\uninst.exe"' '/P="$INSTPROG"' + '"$INSTDIR\uninst.exe"' '' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Other shortcuts @@ -944,18 +752,8 @@ SetOutPath "$INSTDIR" CreateShortCut "$DESKTOP\$INSTSHORTCUT.lnk" "$INSTDIR\$INSTEXE" "$INSTFLAGS" CreateShortCut "$INSTDIR\$INSTSHORTCUT.lnk" "$INSTDIR\$INSTEXE" "$INSTFLAGS" CreateShortCut "$INSTDIR\Uninstall $INSTSHORTCUT.lnk" \ - '"$INSTDIR\uninst.exe"' '/P="$INSTPROG"' - -!ifdef MUSEUM -CreateShortCut "$DESKTOP\$INSTSHORTCUT Museum.lnk" "$INSTDIR\$INSTEXE" "$INSTFLAGS -simple" + '"$INSTDIR\uninst.exe"' '' -CreateShortCut "$DESKTOP\$INSTSHORTCUT Museum Spanish.lnk" "$INSTDIR\$INSTEXE" "$INSTFLAGS -simple -spanish" - -CreateShortCut "$INSTDIR\$INSTSHORTCUT Museum.lnk" "$INSTDIR\$INSTEXE" "$INSTFLAGS -simple" - -CreateShortCut "$INSTDIR\$INSTSHORTCUT Museum Spanish.lnk" "$INSTDIR\$INSTEXE" "$INSTFLAGS -simple -spanish" - -!endif ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Write registry @@ -965,22 +763,17 @@ WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "Flags WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "Shortcut" "$INSTSHORTCUT" WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "Exe" "$INSTEXE" WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\$INSTPROG" "DisplayName" "$INSTPROG (remove only)" -WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\$INSTPROG" "UninstallString" '"$INSTDIR\uninst.exe" /P="$INSTPROG"' +WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\$INSTPROG" "UninstallString" '"$INSTDIR\uninst.exe"' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Write URL registry info WriteRegStr HKEY_CLASSES_ROOT "${URLNAME}" "(default)" "URL:Second Life" WriteRegStr HKEY_CLASSES_ROOT "${URLNAME}" "URL Protocol" "" WriteRegStr HKEY_CLASSES_ROOT "${URLNAME}\DefaultIcon" "" '"$INSTDIR\$INSTEXE"' +;; URL param must be last item passed to viewer, it ignores subsequent params +;; to avoid parameter injection attacks. WriteRegExpandStr HKEY_CLASSES_ROOT "${URLNAME}\shell\open\command" "" '"$INSTDIR\$INSTEXE" $INSTFLAGS -url "%1"' -Goto WRITE_UNINST - -POST_INSTALL: -; Run a post-executable script if necessary. -Call PostInstallExe - -WRITE_UNINST: ; write out uninstaller WriteUninstaller "$INSTDIR\uninst.exe" diff --git a/linden/indra/newview/installers/windows/lang_de.nsi b/linden/indra/newview/installers/windows/lang_de.nsi index c410128..911ed74 100644 Binary files a/linden/indra/newview/installers/windows/lang_de.nsi and b/linden/indra/newview/installers/windows/lang_de.nsi differ diff --git a/linden/indra/newview/installers/windows/lang_en-us.nsi b/linden/indra/newview/installers/windows/lang_en-us.nsi index 218f1c6..a015413 100644 Binary files a/linden/indra/newview/installers/windows/lang_en-us.nsi and b/linden/indra/newview/installers/windows/lang_en-us.nsi differ diff --git a/linden/indra/newview/installers/windows/lang_es.nsi b/linden/indra/newview/installers/windows/lang_es.nsi new file mode 100644 index 0000000..3340a12 Binary files /dev/null and b/linden/indra/newview/installers/windows/lang_es.nsi differ diff --git a/linden/indra/newview/installers/windows/lang_fr.nsi b/linden/indra/newview/installers/windows/lang_fr.nsi new file mode 100644 index 0000000..5c17ad0 Binary files /dev/null and b/linden/indra/newview/installers/windows/lang_fr.nsi differ diff --git a/linden/indra/newview/installers/windows/lang_it.nsi b/linden/indra/newview/installers/windows/lang_it.nsi new file mode 100644 index 0000000..9f18013 Binary files /dev/null and b/linden/indra/newview/installers/windows/lang_it.nsi differ diff --git a/linden/indra/newview/installers/windows/lang_ja.nsi b/linden/indra/newview/installers/windows/lang_ja.nsi index 5e0496e..f564291 100644 Binary files a/linden/indra/newview/installers/windows/lang_ja.nsi and b/linden/indra/newview/installers/windows/lang_ja.nsi differ diff --git a/linden/indra/newview/installers/windows/lang_ko.nsi b/linden/indra/newview/installers/windows/lang_ko.nsi index b570315..5162b7d 100644 Binary files a/linden/indra/newview/installers/windows/lang_ko.nsi and b/linden/indra/newview/installers/windows/lang_ko.nsi differ diff --git a/linden/indra/newview/installers/windows/lang_nl.nsi b/linden/indra/newview/installers/windows/lang_nl.nsi new file mode 100644 index 0000000..42453ba Binary files /dev/null and b/linden/indra/newview/installers/windows/lang_nl.nsi differ diff --git a/linden/indra/newview/installers/windows/lang_pt-br.nsi b/linden/indra/newview/installers/windows/lang_pt-br.nsi new file mode 100644 index 0000000..6524cc7 Binary files /dev/null and b/linden/indra/newview/installers/windows/lang_pt-br.nsi differ diff --git a/linden/indra/newview/installers/windows/lang_zh.nsi b/linden/indra/newview/installers/windows/lang_zh.nsi new file mode 100644 index 0000000..e644e63 Binary files /dev/null and b/linden/indra/newview/installers/windows/lang_zh.nsi differ diff --git a/linden/indra/newview/installers/windows/language_menu.nsi b/linden/indra/newview/installers/windows/language_menu.nsi new file mode 100644 index 0000000..473f9e0 Binary files /dev/null and b/linden/indra/newview/installers/windows/language_menu.nsi differ diff --git a/linden/indra/newview/llagent.cpp b/linden/indra/newview/llagent.cpp index d268397..2237d67 100644 --- a/linden/indra/newview/llagent.cpp +++ b/linden/indra/newview/llagent.cpp @@ -80,6 +80,7 @@ #include "llfloatertools.h" #include "llfloaterworldmap.h" #include "llgroupmgr.h" +#include "llhomelocationresponder.h" #include "llhudeffectlookat.h" #include "llhudmanager.h" #include "llinventorymodel.h" @@ -90,6 +91,7 @@ #include "llmoveview.h" #include "llnotify.h" #include "llquantize.h" +#include "llsdutil.h" #include "llselectmgr.h" #include "llsky.h" #include "llrendersphere.h" @@ -445,7 +447,7 @@ void LLAgent::init() mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild")); mCameraOffsetDefault = gSavedSettings.getVector3("CameraOffsetDefault"); // mCameraOffsetNorm = mCameraOffsetDefault; -// mCameraOffsetNorm.normVec(); +// mCameraOffsetNorm.normalize(); mCameraCollidePlane.clearVec(); mCurrentCameraDistance = mCameraOffsetDefault.magVec(); mTargetCameraDistance = mCurrentCameraDistance; @@ -490,7 +492,7 @@ LLAgent::~LLAgent() //----------------------------------------------------------------------------- // resetView() //----------------------------------------------------------------------------- -void LLAgent::resetView(BOOL reset_camera) +void LLAgent::resetView(BOOL reset_camera, BOOL change_camera) { if (mAutoPilot) { @@ -515,6 +517,30 @@ void LLAgent::resetView(BOOL reset_camera) gMenuHolder->hideMenus(); } + if (change_camera && !gSavedSettings.getBOOL("FreezeTime")) + { + changeCameraToDefault(); + + if (LLViewerJoystick::getInstance()->getOverrideCamera()) + { + handle_toggle_flycam(); + } + + // reset avatar mode from eventual residual motion + if (LLToolMgr::getInstance()->inBuildMode()) + { + LLViewerJoystick::getInstance()->moveAvatar(true); + } + + gFloaterTools->close(); + + gViewerWindow->showCursor(); + + // Switch back to basic toolset + LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); + } + + if (reset_camera && !gSavedSettings.getBOOL("FreezeTime")) { if (!gViewerWindow->getLeftMouseDown() && cameraThirdPerson()) @@ -522,7 +548,7 @@ void LLAgent::resetView(BOOL reset_camera) // leaving mouse-steer mode LLVector3 agent_at_axis = getAtAxis(); agent_at_axis -= projected_vec(agent_at_axis, getReferenceUpVector()); - agent_at_axis.normVec(); + agent_at_axis.normalize(); gAgent.resetAxes(lerp(getAtAxis(), agent_at_axis, LLCriticalDamp::getInterpolant(0.3f))); } @@ -1033,7 +1059,7 @@ void LLAgent::slamLookAt(const LLVector3 &look_at) { LLVector3 look_at_norm = look_at; look_at_norm.mV[VZ] = 0.f; - look_at_norm.normVec(); + look_at_norm.normalize(); resetAxes(look_at_norm); } @@ -1294,7 +1320,7 @@ LLQuaternion LLAgent::getQuat() const //----------------------------------------------------------------------------- // calcFocusOffset() //----------------------------------------------------------------------------- -LLVector3 LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) +LLVector3 LLAgent::calcFocusOffset(LLViewerObject *object, LLVector3 pos_agent, S32 x, S32 y) { // calculate offset based on view direction BOOL is_avatar = object->isAvatar(); @@ -1305,7 +1331,7 @@ LLVector3 LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) LLVector3 obj_dir_abs = obj_pos - LLViewerCamera::getInstance()->getOrigin(); obj_dir_abs.rotVec(inv_obj_rot); - obj_dir_abs.normVec(); + obj_dir_abs.normalize(); obj_dir_abs.abs(); LLVector3 object_extents = object->getScale(); @@ -1330,7 +1356,7 @@ LLVector3 LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) { normal.setVec(obj_matrix.getUpRow4()); } - normal.normVec(); + normal.normalize(); LLVector3d focus_pt_global; // RN: should we check return value for valid pick? @@ -1397,7 +1423,7 @@ LLVector3 LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) if (!is_avatar) { //unproject relative clicked coordinate from window coordinate using GL - GLint viewport[4]; + /*GLint viewport[4]; GLdouble modelview[16]; GLdouble projection[16]; GLfloat winX, winY, winZ; @@ -1419,11 +1445,9 @@ LLVector3 LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) winY = ((F32)y) * gViewerWindow->getDisplayScale().mV[VY]; glReadPixels( llfloor(winX), llfloor(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ ); - gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ); + gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);*/ - LLVector3 obj_rel((F32)posX, (F32)posY, (F32)posZ); - obj_rel = obj_rel * object->getRenderMatrix(); - obj_rel -= object->getRenderPosition(); + LLVector3 obj_rel = pos_agent - object->getRenderPosition(); LLVector3 obj_center = LLVector3(0, 0, 0) * object->getRenderMatrix(); @@ -1534,7 +1558,7 @@ BOOL LLAgent::calcCameraMinDistance(F32 &obj_min_distance) camera_offset_target_abs_norm.abs(); // make sure offset is non-zero camera_offset_target_abs_norm.clamp(0.001f, F32_MAX); - camera_offset_target_abs_norm.normVec(); + camera_offset_target_abs_norm.normalize(); // find camera position relative to normalized object extents LLVector3 camera_offset_target_scaled = camera_offset_target_abs_norm; @@ -1580,7 +1604,7 @@ BOOL LLAgent::calcCameraMinDistance(F32 &obj_min_distance) LLVector3 object_split_axis; LLVector3 target_offset_scaled = target_offset_origin; target_offset_scaled.abs(); - target_offset_scaled.normVec(); + target_offset_scaled.normalize(); target_offset_scaled.mV[VX] /= object_extents.mV[VX]; target_offset_scaled.mV[VY] /= object_extents.mV[VY]; target_offset_scaled.mV[VZ] /= object_extents.mV[VZ]; @@ -1703,7 +1727,7 @@ void LLAgent::setCameraZoomFraction(F32 fraction) else if (cameraCustomizeAvatar()) { LLVector3d camera_offset_dir = mCameraFocusOffsetTarget; - camera_offset_dir.normVec(); + camera_offset_dir.normalize(); mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, APPEARANCE_MAX_ZOOM, APPEARANCE_MIN_ZOOM); } else @@ -1730,7 +1754,7 @@ void LLAgent::setCameraZoomFraction(F32 fraction) } LLVector3d camera_offset_dir = mCameraFocusOffsetTarget; - camera_offset_dir.normVec(); + camera_offset_dir.normalize(); mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, max_zoom, min_zoom); } startCameraAnimation(); @@ -1777,7 +1801,7 @@ void LLAgent::cameraOrbitOver(const F32 angle) else { LLVector3 camera_offset_unit(mCameraFocusOffsetTarget); - camera_offset_unit.normVec(); + camera_offset_unit.normalize(); F32 angle_from_up = acos( camera_offset_unit * getReferenceUpVector() ); @@ -1812,7 +1836,7 @@ void LLAgent::cameraZoomIn(const F32 fraction) LLVector3d camera_offset(mCameraFocusOffsetTarget); LLVector3d camera_offset_unit(mCameraFocusOffsetTarget); F32 min_zoom = LAND_MIN_ZOOM; - F32 current_distance = (F32)camera_offset_unit.normVec(); + F32 current_distance = (F32)camera_offset_unit.normalize(); F32 new_distance = current_distance * fraction; // Don't move through focus point @@ -1881,7 +1905,7 @@ void LLAgent::cameraOrbitIn(const F32 meters) { LLVector3d camera_offset(mCameraFocusOffsetTarget); LLVector3d camera_offset_unit(mCameraFocusOffsetTarget); - F32 current_distance = (F32)camera_offset_unit.normVec(); + F32 current_distance = (F32)camera_offset_unit.normalize(); F32 new_distance = current_distance - meters; F32 min_zoom = LAND_MIN_ZOOM; @@ -1938,6 +1962,8 @@ void LLAgent::cameraPanIn(F32 meters) mFocusGlobal = mFocusTargetGlobal; // don't enforce zoom constraints as this is the only way for users to get past them easily updateFocusOffset(); + // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx + mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); } //----------------------------------------------------------------------------- @@ -1956,6 +1982,8 @@ void LLAgent::cameraPanLeft(F32 meters) cameraZoomIn(1.f); updateFocusOffset(); + // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind - Nyx + mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); } //----------------------------------------------------------------------------- @@ -1974,6 +2002,8 @@ void LLAgent::cameraPanUp(F32 meters) cameraZoomIn(1.f); updateFocusOffset(); + // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx + mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); } //----------------------------------------------------------------------------- @@ -2246,7 +2276,7 @@ void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::s mAutoPilotUseRotation = TRUE; mAutoPilotTargetFacing = LLVector3::x_axis * *target_rotation; mAutoPilotTargetFacing.mV[VZ] = 0.f; - mAutoPilotTargetFacing.normVec(); + mAutoPilotTargetFacing.normalize(); } else { @@ -2369,8 +2399,8 @@ void LLAgent::autoPilot(F32 *delta_yaw) at.mV[VZ] = 0.f; direction.mV[VZ] = 0.f; - at.normVec(); - F32 xy_distance = direction.normVec(); + at.normalize(); + F32 xy_distance = direction.normalize(); F32 yaw = 0.f; if (mAutoPilotTargetDist > mAutoPilotStopDistance) @@ -3529,7 +3559,7 @@ void LLAgent::setupSitCamera() // slam agent coordinate frame to proper parent local version LLVector3 at_axis = mFrameAgent.getAtAxis(); at_axis.mV[VZ] = 0.f; - at_axis.normVec(); + at_axis.normalize(); resetAxes(at_axis * ~parent_rot); } } @@ -3665,7 +3695,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) // slam agent coordinate frame to proper parent local version LLVector3 at_axis = mFrameAgent.getAtAxis() * parent_rot; at_axis.mV[VZ] = 0.f; - at_axis.normVec(); + at_axis.normalize(); resetAxes(at_axis * ~parent_rot); local_camera_offset = local_camera_offset * mFrameAgent.getQuaternion() * parent_rot; @@ -3686,7 +3716,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) offset_dot_norm = 0.001f; } - camera_distance = local_camera_offset.normVec(); + camera_distance = local_camera_offset.normalize(); F32 pos_dot_norm = getPosAgentFromGlobal(frame_center_global + head_offset) * plane_normal; @@ -3710,7 +3740,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) } else { - camera_distance = local_camera_offset.normVec(); + camera_distance = local_camera_offset.normalize(); } mTargetCameraDistance = llmax(camera_distance, MIN_CAMERA_DISTANCE); @@ -3745,7 +3775,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) { LLVector3 frame_at_axis = mFrameAgent.getAtAxis(); frame_at_axis -= projected_vec(frame_at_axis, getReferenceUpVector()); - frame_at_axis.normVec(); + frame_at_axis.normalize(); //transition smoothly in air mode, to avoid camera pop F32 u = (time_in_air - GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) / GROUND_TO_AIR_CAMERA_TRANSITION_TIME; @@ -3932,7 +3962,7 @@ void LLAgent::resetCamera() // Remove any pitch from the avatar LLVector3 at = mFrameAgent.getAtAxis(); at.mV[VZ] = 0.f; - at.normVec(); + at.normalize(); gAgent.resetAxes(at); // have to explicitly clear field of view zoom now mCameraFOVZoomFactor = 0.f; @@ -4101,7 +4131,10 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate) if (mAvatarObject) { - mAvatarObject->mPelvisp->setPosition(LLVector3::zero); + if (!mAvatarObject->mIsSitting) + { + mAvatarObject->mPelvisp->setPosition(LLVector3::zero); + } mAvatarObject->startMotion( ANIM_AGENT_BODY_NOISE ); mAvatarObject->startMotion( ANIM_AGENT_BREATHE_ROT ); } @@ -4147,14 +4180,14 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate) LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); at_axis = LLViewerCamera::getInstance()->getAtAxis(); at_axis.mV[VZ] = 0.f; - at_axis.normVec(); + at_axis.normalize(); resetAxes(at_axis * ~obj_rot); } else { at_axis = mFrameAgent.getAtAxis(); at_axis.mV[VZ] = 0.f; - at_axis.normVec(); + at_axis.normalize(); resetAxes(at_axis); } @@ -4201,7 +4234,7 @@ void LLAgent::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL camera_ani // Remove any pitch from the avatar //LLVector3 at = mFrameAgent.getAtAxis(); //at.mV[VZ] = 0.f; - //at.normVec(); + //at.normalize(); //gAgent.resetAxes(at); if( mCameraMode != CAMERA_MODE_CUSTOMIZE_AVATAR ) @@ -4228,7 +4261,7 @@ void LLAgent::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL camera_ani // Remove any pitch from the avatar LLVector3 at = mFrameAgent.getAtAxis(); at.mV[VZ] = 0.f; - at.normVec(); + at.normalize(); gAgent.resetAxes(at); sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START); @@ -4508,14 +4541,14 @@ void LLAgent::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); at_axis = LLViewerCamera::getInstance()->getAtAxis(); at_axis.mV[VZ] = 0.f; - at_axis.normVec(); + at_axis.normalize(); resetAxes(at_axis * ~obj_rot); } else { at_axis = LLViewerCamera::getInstance()->getAtAxis(); at_axis.mV[VZ] = 0.f; - at_axis.normVec(); + at_axis.normalize(); resetAxes(at_axis); } } @@ -4578,7 +4611,7 @@ void LLAgent::lookAtLastChat() { delta_pos = chatter->getPositionAgent() - getPositionAgent(); } - delta_pos.normVec(); + delta_pos.normalize(); setControlFlags(AGENT_CONTROL_STOP); @@ -4586,9 +4619,9 @@ void LLAgent::lookAtLastChat() LLVector3 new_camera_pos = mAvatarObject->mHeadp->getWorldPosition(); LLVector3 left = delta_pos % LLVector3::z_axis; - left.normVec(); + left.normalize(); LLVector3 up = left % delta_pos; - up.normVec(); + up.normalize(); new_camera_pos -= delta_pos * 0.4f; new_camera_pos += left * 0.3f; new_camera_pos += up * 0.2f; @@ -4607,7 +4640,7 @@ void LLAgent::lookAtLastChat() else { delta_pos = chatter->getRenderPosition() - getPositionAgent(); - delta_pos.normVec(); + delta_pos.normalize(); setControlFlags(AGENT_CONTROL_STOP); @@ -4615,9 +4648,9 @@ void LLAgent::lookAtLastChat() LLVector3 new_camera_pos = mAvatarObject->mHeadp->getWorldPosition(); LLVector3 left = delta_pos % LLVector3::z_axis; - left.normVec(); + left.normalize(); LLVector3 up = left % delta_pos; - up.normVec(); + up.normalize(); new_camera_pos -= delta_pos * 0.4f; new_camera_pos += left * 0.3f; new_camera_pos += up * 0.2f; @@ -4631,68 +4664,107 @@ void LLAgent::lookAtLastChat() const F32 SIT_POINT_EXTENTS = 0.2f; -// Grabs current position -void LLAgent::setStartPosition(U32 location_id) -{ - LLViewerObject *object; - - if ( !(gAgentID == LLUUID::null) ) - { - // we've got an ID for an agent viewerobject - object = gObjectList.findObject(gAgentID); - if (object) - { - // we've got the viewer object - // Sometimes the agent can be velocity interpolated off of - // this simulator. Clamp it to the region the agent is - // in, a little bit in on each side. - const F32 INSET = 0.5f; //meters - const F32 REGION_WIDTH = LLWorld::getInstance()->getRegionWidthInMeters(); - - LLVector3 agent_pos = getPositionAgent(); - - if (mAvatarObject) - { - // the z height is at the agent's feet - agent_pos.mV[VZ] -= 0.5f * mAvatarObject->mBodySize.mV[VZ]; - } - - agent_pos.mV[VX] = llclamp( agent_pos.mV[VX], INSET, REGION_WIDTH - INSET ); - agent_pos.mV[VY] = llclamp( agent_pos.mV[VY], INSET, REGION_WIDTH - INSET ); - - // Don't let them go below ground, or too high. - agent_pos.mV[VZ] = llclamp( agent_pos.mV[VZ], - mRegionp->getLandHeightRegion( agent_pos ), - LLWorld::getInstance()->getRegionMaxHeight() ); - - LLMessageSystem* msg = gMessageSystem; - msg->newMessageFast(_PREHASH_SetStartLocationRequest); - msg->nextBlockFast( _PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, getID()); - msg->addUUIDFast(_PREHASH_SessionID, getSessionID()); - msg->nextBlockFast( _PREHASH_StartLocationData); - // corrected by sim - msg->addStringFast(_PREHASH_SimName, ""); - msg->addU32Fast(_PREHASH_LocationID, location_id); - msg->addVector3Fast(_PREHASH_LocationPos, agent_pos); - msg->addVector3Fast(_PREHASH_LocationLookAt,mFrameAgent.getAtAxis()); - - // Reliable only helps when setting home location. Last - // location is sent on quit, and we don't have time to ack - // the packets. - msg->sendReliable(mRegionp->getHost()); - - const U32 HOME_INDEX = 1; - if( HOME_INDEX == location_id ) - { - setHomePosRegion( mRegionp->getHandle(), getPositionAgent() ); - } - } - else - { - llinfos << "setStartPosition - Can't find agent viewerobject id " << gAgentID << llendl; - } - } +void LLAgent::setStartPosition( U32 location_id ) +{ + LLViewerObject *object; + + if ( !(gAgentID == LLUUID::null) ) + { + // we've got an ID for an agent viewerobject + object = gObjectList.findObject(gAgentID); + if (object) + { + // we've got the viewer object + // Sometimes the agent can be velocity interpolated off of + // this simulator. Clamp it to the region the agent is + // in, a little bit in on each side. + const F32 INSET = 0.5f; //meters + const F32 REGION_WIDTH = LLWorld::getInstance()->getRegionWidthInMeters(); + + LLVector3 agent_pos = getPositionAgent(); + LLVector3 agent_look_at = mFrameAgent.getAtAxis(); + + if (mAvatarObject) + { + // the z height is at the agent's feet + agent_pos.mV[VZ] -= 0.5f * mAvatarObject->mBodySize.mV[VZ]; + } + + agent_pos.mV[VX] = llclamp( agent_pos.mV[VX], INSET, REGION_WIDTH - INSET ); + agent_pos.mV[VY] = llclamp( agent_pos.mV[VY], INSET, REGION_WIDTH - INSET ); + + // Don't let them go below ground, or too high. + agent_pos.mV[VZ] = llclamp( agent_pos.mV[VZ], + mRegionp->getLandHeightRegion( agent_pos ), + LLWorld::getInstance()->getRegionMaxHeight() ); + // Send the CapReq + + LLSD body; + + std::string url = gAgent.getRegion()->getCapability("HomeLocation"); + std::ostringstream strBuffer; + if( url.empty() ) + { + LLMessageSystem* msg = gMessageSystem; + msg->newMessageFast(_PREHASH_SetStartLocationRequest); + msg->nextBlockFast( _PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, getID()); + msg->addUUIDFast(_PREHASH_SessionID, getSessionID()); + msg->nextBlockFast( _PREHASH_StartLocationData); + // corrected by sim + msg->addStringFast(_PREHASH_SimName, ""); + msg->addU32Fast(_PREHASH_LocationID, location_id); + msg->addVector3Fast(_PREHASH_LocationPos, agent_pos); + msg->addVector3Fast(_PREHASH_LocationLookAt,mFrameAgent.getAtAxis()); + + // Reliable only helps when setting home location. Last + // location is sent on quit, and we don't have time to ack + // the packets. + msg->sendReliable(mRegionp->getHost()); + + const U32 HOME_INDEX = 1; + if( HOME_INDEX == location_id ) + { + setHomePosRegion( mRegionp->getHandle(), getPositionAgent() ); + } + } + else + { + strBuffer << location_id; + body["HomeLocation"]["LocationId"] = strBuffer.str(); + + strBuffer.str(""); + strBuffer << agent_pos.mV[VX]; + body["HomeLocation"]["LocationPos"]["X"] = strBuffer.str(); + + strBuffer.str(""); + strBuffer << agent_pos.mV[VY]; + body["HomeLocation"]["LocationPos"]["Y"] = strBuffer.str(); + + strBuffer.str(""); + strBuffer << agent_pos.mV[VZ]; + body["HomeLocation"]["LocationPos"]["Z"] = strBuffer.str(); + + strBuffer.str(""); + strBuffer << agent_look_at.mV[VX]; + body["HomeLocation"]["LocationLookAt"]["X"] = strBuffer.str(); + + strBuffer.str(""); + strBuffer << agent_look_at.mV[VY]; + body["HomeLocation"]["LocationLookAt"]["Y"] = strBuffer.str(); + + strBuffer.str(""); + strBuffer << agent_look_at.mV[VZ]; + body["HomeLocation"]["LocationLookAt"]["Z"] = strBuffer.str(); + + LLHTTPClient::post( url, body, new LLHomeLocationResponder() ); + } + } + else + { + llinfos << "setStartPosition - Can't find agent viewerobject id " << gAgentID << llendl; + } + } } void LLAgent::requestStopMotion( LLMotion* motion ) diff --git a/linden/indra/newview/llagent.h b/linden/indra/newview/llagent.h index 97f9aed..2befeb0 100644 --- a/linden/indra/newview/llagent.h +++ b/linden/indra/newview/llagent.h @@ -139,7 +139,7 @@ public: // Called whenever the agent moves. Puts camera back in default position, // deselects items, etc. - void resetView(BOOL reset_camera = TRUE); + void resetView(BOOL reset_camera = TRUE, BOOL change_camera = FALSE); // Called on camera movement, to allow the camera to be unlocked from the // default position behind the avatar. @@ -378,7 +378,7 @@ public: void sendAnimationRequests(LLDynamicArray &anim_ids, EAnimRequest request); void sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request); - LLVector3 calcFocusOffset(LLViewerObject *object, S32 x, S32 y); + LLVector3 calcFocusOffset(LLViewerObject *object, LLVector3 pos_agent, S32 x, S32 y); BOOL calcCameraMinDistance(F32 &obj_min_distance); void startCameraAnimation(); diff --git a/linden/indra/newview/llappviewer.cpp b/linden/indra/newview/llappviewer.cpp index f1b2e32..49991b4 100644 --- a/linden/indra/newview/llappviewer.cpp +++ b/linden/indra/newview/llappviewer.cpp @@ -191,18 +191,11 @@ //---------------------------------------------------------------------------- // viewer.cpp - these are only used in viewer, should be easily moved. -extern void disable_win_error_reporting(); #if LL_DARWIN -#include extern void init_apple_menu(const char* product); -extern OSErr AEGURLHandler(const AppleEvent *messagein, AppleEvent *reply, long refIn); -extern OSErr AEQuitHandler(const AppleEvent *messagein, AppleEvent *reply, long refIn); -extern OSStatus simpleDialogHandler(EventHandlerCallRef handler, EventRef event, void *userdata); -#include #endif // LL_DARWIN - extern BOOL gRandomizeFramerate; extern BOOL gPeriodicSlowFrame; extern BOOL gDebugGL; @@ -216,10 +209,6 @@ const F32 DEFAULT_AFK_TIMEOUT = 5.f * 60.f; // time with no input before user fl F32 gSimLastTime; // Used in LLAppViewer::init and send_stats() F32 gSimFrames; -std::string gDisabledMessage; // Set in LLAppViewer::initConfiguration used in idle_startup - -BOOL gHideLinks = FALSE; // Set in LLAppViewer::initConfiguration, used externally - BOOL gAllowIdleAFK = TRUE; BOOL gAllowTapTapHoldRun = TRUE; BOOL gShowObjectUpdates = FALSE; @@ -307,14 +296,13 @@ const char *VFS_INDEX_FILE_BASE = "index.db2.x."; static std::string gSecondLife; static std::string gWindowTitle; -#ifdef LL_WINDOWS - static char sWindowClass[] = "Second Life"; -#endif std::string gLoginPage; std::vector gLoginURIs; static std::string gHelperURI; +LLAppViewer::LLUpdaterInfo *LLAppViewer::sUpdaterInfo = NULL ; + void idle_afk_check() { // check idle timers @@ -329,8 +317,7 @@ static void ui_audio_callback(const LLUUID& uuid) { if (gAudiop) { - F32 volume = gSavedSettings.getBOOL("MuteUI") ? 0.f : gSavedSettings.getF32("AudioLevelUI"); - gAudiop->triggerSound(uuid, gAgent.getID(), volume); + gAudiop->triggerSound(uuid, gAgent.getID(), 1.0f, LLAudioEngine::AUDIO_TYPE_UI); } } @@ -496,30 +483,17 @@ void LLAppViewer::initGridChoice() } } -bool send_url_to_other_instance(const std::string& url) +//virtual +bool LLAppViewer::initSLURLHandler() { -#if LL_WINDOWS - wchar_t window_class[256]; /* Flawfinder: ignore */ // Assume max length < 255 chars. - mbstowcs(window_class, sWindowClass, 255); - window_class[255] = 0; - // Use the class instead of the window name. - HWND other_window = FindWindow(window_class, NULL); - - if (other_window != NULL) - { - lldebugs << "Found other window with the name '" << gWindowTitle << "'" << llendl; - COPYDATASTRUCT cds; - const S32 SLURL_MESSAGE_TYPE = 0; - cds.dwData = SLURL_MESSAGE_TYPE; - cds.cbData = url.length() + 1; - cds.lpData = (void*)url.c_str(); - - LRESULT msg_result = SendMessage(other_window, WM_COPYDATA, NULL, (LPARAM)&cds); - lldebugs << "SendMessage(WM_COPYDATA) to other window '" - << gWindowTitle << "' returned " << msg_result << llendl; - return true; - } -#endif + // does nothing unless subclassed + return false; +} + +//virtual +bool LLAppViewer::sendURLToOtherInstance(const std::string& url) +{ + // does nothing unless subclassed return false; } @@ -683,6 +657,7 @@ bool LLAppViewer::init() ui_audio_callback, &LLUI::sGLScaleFactor); LLWeb::initClass(); // do this after LLUI + LLTextEditor::setURLCallbacks(&LLWeb::loadURL, &LLURLDispatcher::dispatchFromTextEditor, &LLURLDispatcher::dispatchFromTextEditor); @@ -703,7 +678,6 @@ bool LLAppViewer::init() // load MIME type -> media impl mappings LLMIMETypes::parseMIMETypes( std::string("mime_types.xml") ); - // Copy settings to globals. *TODO: Remove or move to appropriage class initializers settings_to_globals(); // Setup settings listeners @@ -714,6 +688,9 @@ bool LLAppViewer::init() // Find partition serial number (Windows) or hardware serial (Mac) mSerialNumber = generateSerialNumber(); + // do any necessary set-up for accepting incoming SLURLs from apps + initSLURLHandler(); + if(false == initHardwareTest()) { // Early out from user choice. @@ -844,7 +821,10 @@ bool LLAppViewer::init() } } - + + // save the graphics card + gDebugInfo["GraphicsCard"] = LLFeatureManager::getInstance()->getGPUString(); + // Save the current version to the prefs file gSavedSettings.setString("LastRunVersion", gCurrentVersion); @@ -889,16 +869,21 @@ bool LLAppViewer::mainLoop() { LLFastTimer t(LLFastTimer::FTM_FRAME); + pingMainloopTimeout("Main:MiscNativeWindowEvents"); + + { + LLFastTimer t2(LLFastTimer::FTM_MESSAGES); + gViewerWindow->mWindow->processMiscNativeEvents(); + } + pingMainloopTimeout("Main:GatherInput"); { LLFastTimer t2(LLFastTimer::FTM_MESSAGES); - #if LL_WINDOWS - if (!LLWinDebug::checkExceptionHandler()) + if (!restoreErrorTrap()) { - llwarns << " Someone took over my exception handler (post messagehandling)!" << llendl; + llwarns << " Someone took over my signal/exception handler (post messagehandling)!" << llendl; } - #endif gViewerWindow->mWindow->gatherInput(); } @@ -954,7 +939,7 @@ bool LLAppViewer::mainLoop() resumeMainloopTimeout(); } - + if (gDoDisconnect && (LLStartUp::getStartupState() == STATE_STARTED)) { pauseMainloopTimeout(); @@ -1365,12 +1350,15 @@ bool LLAppViewer::cleanup() delete sImageDecodeThread; sImageDecodeThread = NULL; + //Note: + //LLViewerMedia::cleanupClass() has to be put before gImageList.shutdown() + //because some new image might be generated during cleaning up media. --bao + LLViewerMedia::cleanupClass(); gImageList.shutdown(); // shutdown again in case a callback added something LLUIImageList::getInstance()->cleanUp(); // This should eventually be done in LLAppViewer - LLImageJ2C::closeDSO(); - LLImageFormatted::cleanupClass(); + LLImage::cleanupClass(); LLVFSThread::cleanupClass(); LLLFSThread::cleanupClass(); @@ -1409,8 +1397,6 @@ bool LLAppViewer::cleanup() LLWeb::loadURLExternal( gLaunchFileOnQuit ); } - - LLViewerMedia::cleanupClass(); llinfos << "Goodbye" << llendflush; @@ -1440,8 +1426,7 @@ bool LLAppViewer::initThreads() LLAppViewer::sImageDecodeThread = new LLWorkerThread("ImageDecode", enable_threads && true); LLAppViewer::sTextureCache = new LLTextureCache(enable_threads && true); LLAppViewer::sTextureFetch = new LLTextureFetch(LLAppViewer::getTextureCache(), enable_threads && false); - LLImageWorker::initClass(LLAppViewer::getImageDecodeThread()); - LLImageJ2C::openDSO(); + LLImage::initClass(LLAppViewer::getImageDecodeThread()); // *FIX: no error handling here! return true; @@ -1878,22 +1863,6 @@ bool LLAppViewer::initConfiguration() // llerrs << "Failed to parse skin definition." << llendl; // } - // LLXmlTreeNode* rootp = skin_def_tree.getRoot(); - // LLXmlTreeNode* disabled_message_node = rootp->getChildByName("disabled_message"); - // if (disabled_message_node) - // { - // gDisabledMessage = disabled_message_node->getContents(); - // } - - // static LLStdStringHandle hide_links_string = LLXmlTree::addAttributeString("hide_links"); - // rootp->getFastAttributeBOOL(hide_links_string, gHideLinks); - - // // Legacy string. This flag really meant we didn't want to expose references to "Second Life". - // // Just set gHideLinks instead. - // static LLStdStringHandle silent_string = LLXmlTree::addAttributeString("silent_update"); - // BOOL silent_update; - // rootp->getFastAttributeBOOL(silent_string, silent_update); - // gHideLinks = (gHideLinks || silent_update); //} #if LL_DARWIN @@ -1946,7 +1915,7 @@ bool LLAppViewer::initConfiguration() #endif LLStringUtil::truncate(gWindowTitle, 255); - //RN: if we received a URL, hand it off to the existing instance + //RN: if we received a URL, hand it off to the existing instance. // don't call anotherInstanceRunning() when doing URL handoff, as // it relies on checking a marker file which will not work when running // out of different directories @@ -1961,7 +1930,7 @@ bool LLAppViewer::initConfiguration() } if (!slurl.empty()) { - if (send_url_to_other_instance(slurl)) + if (sendURLToOtherInstance(slurl)) { // successfully handed off URL to existing instance, exit return false; @@ -1992,7 +1961,7 @@ bool LLAppViewer::initConfiguration() } initMarkerFile(); - + #if LL_SEND_CRASH_REPORTS if (gLastExecEvent == LAST_EXEC_FROZE) { @@ -2014,52 +1983,8 @@ bool LLAppViewer::initConfiguration() { llinfos << "Sending crash report." << llendl; -#if LL_WINDOWS - std::string exe_path = gDirUtilp->getAppRODataDir(); - exe_path += gDirUtilp->getDirDelimiter(); - exe_path += "win_crash_logger.exe"; - - std::string arg_string = "-previous "; - // Spawn crash logger. - // NEEDS to wait until completion, otherwise log files will get smashed. - _spawnl(_P_WAIT, exe_path.c_str(), exe_path.c_str(), arg_string.c_str(), NULL); -#elif LL_DARWIN - std::string command_str; - command_str = "mac-crash-logger.app/Contents/MacOS/mac-crash-logger "; - command_str += "-previous"; - // XXX -- We need to exit fullscreen mode for this to work. - // XXX -- system() also doesn't wait for completion. Hmm... - system(command_str.c_str()); /* Flawfinder: Ignore */ -#elif LL_LINUX || LL_SOLARIS - std::string cmd =gDirUtilp->getAppRODataDir(); - cmd += gDirUtilp->getDirDelimiter(); -#if LL_LINUX - cmd += "linux-crash-logger.bin"; -#else // LL_SOLARIS - cmd += "bin/solaris-crash-logger"; -#endif // LL_LINUX - char* const cmdargv[] = - {(char*)cmd.c_str(), - (char*)"-previous", - NULL}; - fflush(NULL); // flush all buffers before the child inherits them - pid_t pid = fork(); - if (pid == 0) - { // child - execv(cmd.c_str(), cmdargv); /* Flawfinder: Ignore */ - llwarns << "execv failure when trying to start " << cmd << llendl; - _exit(1); // avoid atexit() - } else { - if (pid > 0) - { - // wait for child proc to die - int childExitStatus; - waitpid(pid, &childExitStatus, 0); - } else { - llwarns << "fork failure." << llendl; - } - } -#endif + bool report_freeze = true; + handleCrashReporting(report_freeze); } else { @@ -2262,7 +2187,7 @@ void LLAppViewer::writeSystemInfo() gDebugInfo["RAMInfo"]["Physical"] = (LLSD::Integer)(gSysMemory.getPhysicalMemoryKB()); gDebugInfo["RAMInfo"]["Allocated"] = (LLSD::Integer)(gMemoryAllocated>>10); // MB -> KB gDebugInfo["OSInfo"] = getOSInfo().getOSStringSimple(); - + // The user is not logged on yet, but record the current grid choice login url // which may have been the intended grid. This can b gDebugInfo["GridName"] = LLViewerLogin::getInstance()->getGridLabel(); @@ -2273,6 +2198,13 @@ void LLAppViewer::writeSystemInfo() gDebugInfo["MainloopThreadID"] = (S32)thread_id; #endif + // "CrashNotHandled" is set here, while things are running well, + // in case of a freeze. If there is a freeze, the crash logger will be launched + // and can read this value from the debug_info.log. + // If the crash is handled by LLAppViewer::handleViewerCrash, ie not a freeze, + // then the value of "CrashNotHandled" will be set to true. + gDebugInfo["CrashNotHandled"] = (LLSD::Boolean)true; + // Dump some debugging info LL_INFOS("SystemInfo") << gSecondLife << " version " << LL_VERSION_MAJOR << "." << LL_VERSION_MINOR << "." << LL_VERSION_PATCH @@ -2347,6 +2279,8 @@ void LLAppViewer::handleViewerCrash() gDebugInfo["CAFilename"] = gDirUtilp->getCAFile(); gDebugInfo["ViewerExePath"] = gDirUtilp->getExecutablePathAndName(); gDebugInfo["CurrentPath"] = gDirUtilp->getCurPath(); + gDebugInfo["SessionLength"] = F32(LLFrameTimer::getElapsedSeconds()); + if(gLogoutInProgress) { gDebugInfo["LastExecEvent"] = LAST_EXEC_LOGOUT_CRASH; @@ -2372,6 +2306,9 @@ void LLAppViewer::handleViewerCrash() gDebugInfo["MainloopTimeoutState"] = LLAppViewer::instance()->mMainloopTimeout->getState(); } + // The crash is being handled here so set this value to false. + // Otherwise the crash logger will think this crash was a freeze. + gDebugInfo["CrashNotHandled"] = (LLSD::Boolean)false; //Write out the crash status file //Use marker file style setup, as that's the simplest, especially since @@ -2455,24 +2392,23 @@ bool LLAppViewer::anotherInstanceRunning() { // Another instance is running. Skip the rest of these operations. LL_INFOS("MarkerFile") << "Marker file is locked." << LL_ENDL; - return TRUE; + return true; } if (apr_file_lock(fMarker, APR_FLOCK_NONBLOCK | APR_FLOCK_EXCLUSIVE) != APR_SUCCESS) //flock(fileno(fMarker), LOCK_EX | LOCK_NB) == -1) { apr_file_close(fMarker); LL_INFOS("MarkerFile") << "Marker file is locked." << LL_ENDL; - return TRUE; + return true; } // No other instances; we'll lock this file now & delete on quit. apr_file_close(fMarker); } LL_DEBUGS("MarkerFile") << "Marker file isn't locked." << LL_ENDL; - return FALSE; + return false; } void LLAppViewer::initMarkerFile() { - //First, check for the existence of other files. //There are marker files for two different types of crashes @@ -2727,7 +2663,7 @@ bool LLAppViewer::initCache() // Init the texture cache // Allocate 80% of the cache size for textures - BOOL read_only = mSecondInstance ? true : false; + BOOL read_only = mSecondInstance ? TRUE : FALSE; const S32 MB = 1024*1024; S64 cache_size = (S64)(gSavedSettings.getU32("CacheSize")) * MB; const S64 MAX_CACHE_SIZE = 1024*MB; @@ -3796,6 +3732,11 @@ void LLAppViewer::pauseMainloopTimeout() void LLAppViewer::pingMainloopTimeout(const std::string& state, F32 secs) { +// if(!restoreErrorTrap()) +// { +// llwarns << "!!!!!!!!!!!!! Its an error trap!!!!" << state << llendl; +// } + if(mMainloopTimeout) { if(secs < 0.0f) @@ -3808,3 +3749,42 @@ void LLAppViewer::pingMainloopTimeout(const std::string& state, F32 secs) } } +void LLAppViewer::handleLoginComplete() +{ + initMainloopTimeout("Mainloop Init"); + + // Store some data to DebugInfo in case of a freeze. + gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("VersionChannelName"); + + gDebugInfo["ClientInfo"]["MajorVersion"] = LL_VERSION_MAJOR; + gDebugInfo["ClientInfo"]["MinorVersion"] = LL_VERSION_MINOR; + gDebugInfo["ClientInfo"]["PatchVersion"] = LL_VERSION_PATCH; + gDebugInfo["ClientInfo"]["BuildVersion"] = LL_VERSION_BUILD; + + LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); + if ( parcel && parcel->getMusicURL()[0]) + { + gDebugInfo["ParcelMusicURL"] = parcel->getMusicURL(); + } + if ( parcel && parcel->getMediaURL()[0]) + { + gDebugInfo["ParcelMediaURL"] = parcel->getMediaURL(); + } + + gDebugInfo["SettingsFilename"] = gSavedSettings.getString("ClientSettingsFile"); + gDebugInfo["CAFilename"] = gDirUtilp->getCAFile(); + gDebugInfo["ViewerExePath"] = gDirUtilp->getExecutablePathAndName(); + gDebugInfo["CurrentPath"] = gDirUtilp->getCurPath(); + + if(gAgent.getRegion()) + { + gDebugInfo["CurrentSimHost"] = gAgent.getRegionHost().getHostName(); + gDebugInfo["CurrentRegion"] = gAgent.getRegion()->getName(); + } + + if(LLAppViewer::instance()->mMainloopTimeout) + { + gDebugInfo["MainloopTimeoutState"] = LLAppViewer::instance()->mMainloopTimeout->getState(); + } + writeDebugInfo(); +} diff --git a/linden/indra/newview/llappviewer.h b/linden/indra/newview/llappviewer.h index 801deb1..6545a61 100644 --- a/linden/indra/newview/llappviewer.h +++ b/linden/indra/newview/llappviewer.h @@ -77,7 +77,9 @@ public: // Report true if under the control of a debugger. A null-op default. virtual bool beingDebugged() { return false; } - virtual void handleCrashReporting() = 0; // What to do with crash report? + virtual bool restoreErrorTrap() = 0; // Require platform specific override to reset error handling mechanism. + // return false if the error trap needed restoration. + virtual void handleCrashReporting(bool reportFreeze = false) = 0; // What to do with crash report? virtual void handleSyncCrashTrace() = 0; // any low-level crash-prep that has to happen in the context of the crashing thread before the crash report is delivered. static void handleViewerCrash(); // Hey! The viewer crashed. Do this, soon. static void handleSyncViewerCrash(); // Hey! The viewer crashed. Do this right NOW in the context of the crashing thread. @@ -136,15 +138,21 @@ public: void resumeMainloopTimeout(const std::string& state = "", F32 secs = -1.0f); void pingMainloopTimeout(const std::string& state, F32 secs = -1.0f); + // Handle the 'login completed' event. + // *NOTE:Mani Fix this for login abstraction!! + void handleLoginComplete(); + protected: virtual bool initWindow(); // Initialize the viewer's window. virtual bool initLogging(); // Initialize log files, logging system, return false on failure. virtual void initConsole() {}; // Initialize OS level debugging console. virtual bool initHardwareTest() { return true; } // A false result indicates the app should quit. + virtual bool initSLURLHandler(); + virtual bool sendURLToOtherInstance(const std::string& url); - virtual bool initParseCommandLine(LLCommandLineParser& clp) + virtual bool initParseCommandLine(LLCommandLineParser& clp) { return true; } // Allow platforms to specify the command line args. - + virtual std::string generateSerialNumber() = 0; // Platforms specific classes generate this. @@ -211,6 +219,15 @@ private: // for tracking viewer<->region circuit death bool mAgentRegionLastAlive; LLUUID mAgentRegionLastID; + +public: + //some information for updater + typedef struct + { + std::string mUpdateExePath; + std::ostringstream mParams; + }LLUpdaterInfo ; + static LLUpdaterInfo *sUpdaterInfo ; }; // consts from viewer.h @@ -222,8 +239,6 @@ const S32 AGENT_UPDATES_PER_SECOND = 10; // "// llstartup" indicates that llstartup is the only client for this global. extern BOOL gHandleKeysAsync; // gSavedSettings used by llviewerdisplay.cpp & llviewermenu.cpp -extern std::string gDisabledMessage; // llstartup -extern BOOL gHideLinks; // used by llpanellogin, lllfloaterbuycurrency, llstartup extern LLSD gDebugInfo; extern BOOL gAllowIdleAFK; diff --git a/linden/indra/newview/llappviewerlinux.cpp b/linden/indra/newview/llappviewerlinux.cpp index 0a4a9cf..643013b 100644 --- a/linden/indra/newview/llappviewerlinux.cpp +++ b/linden/indra/newview/llappviewerlinux.cpp @@ -1,6 +1,6 @@ /** * @file llappviewerlinux.cpp - * @brief The LLAppViewerWin32 class definitions + * @brief The LLAppViewerLinux class definitions * * $LicenseInfo:firstyear=2007&license=viewergpl$ * @@ -36,8 +36,10 @@ #include "llcommandlineparser.h" #include "llmemtype.h" +#include "llurldispatcher.h" // SLURL from other app instance #include "llviewernetwork.h" #include "llviewercontrol.h" +#include "llwindowsdl.h" #include "llmd5.h" #include "llfindlocale.h" @@ -60,6 +62,17 @@ # include "ELFIO/ELFIO.h" // for better backtraces #endif +#if LL_DBUS_ENABLED +# include "llappviewerlinux_api_dbus.h" + +// regrettable hacks to give us better runtime compatibility with older systems inside llappviewerlinux_api.h: +#define llg_return_if_fail(COND) do{if (!(COND)) return;}while(0) +#undef g_return_if_fail +#define g_return_if_fail(COND) llg_return_if_fail(COND) +// The generated API +# include "llappviewerlinux_api.h" +#endif + namespace { int gArgC = 0; @@ -321,6 +334,193 @@ bool LLAppViewerLinux::init() return LLAppViewer::init(); } +bool LLAppViewerLinux::restoreErrorTrap() +{ + // *NOTE:Mani there is a case for implementing this or the mac. + // Linux doesn't need it to my knowledge. + return true; +} + +///////////////////////////////////////// +#if LL_DBUS_ENABLED + +typedef struct +{ + GObjectClass parent_class; +} ViewerAppAPIClass; + +static void viewerappapi_init(ViewerAppAPI *server); +static void viewerappapi_class_init(ViewerAppAPIClass *klass); + +/// + +// regrettable hacks to give us better runtime compatibility with older systems in general +static GType llg_type_register_static_simple_ONCE(GType parent_type, + const gchar *type_name, + guint class_size, + GClassInitFunc class_init, + guint instance_size, + GInstanceInitFunc instance_init, + GTypeFlags flags) +{ + static GTypeInfo type_info; + memset(&type_info, 0, sizeof(type_info)); + + type_info.class_size = class_size; + type_info.class_init = class_init; + type_info.instance_size = instance_size; + type_info.instance_init = instance_init; + + return g_type_register_static(parent_type, type_name, &type_info, flags); +} +#define llg_intern_static_string(S) (S) +#define g_intern_static_string(S) llg_intern_static_string(S) +#define g_type_register_static_simple(parent_type, type_name, class_size, class_init, instance_size, instance_init, flags) llg_type_register_static_simple_ONCE(parent_type, type_name, class_size, class_init, instance_size, instance_init, flags) + +G_DEFINE_TYPE(ViewerAppAPI, viewerappapi, G_TYPE_OBJECT); + +void viewerappapi_class_init(ViewerAppAPIClass *klass) +{ +} + +static bool dbus_server_init = false; + +void viewerappapi_init(ViewerAppAPI *server) +{ + // Connect to the default DBUS, register our service/API. + + if (!dbus_server_init) + { + GError *error = NULL; + + server->connection = lldbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (server->connection) + { + lldbus_g_object_type_install_info(viewerappapi_get_type(), &dbus_glib_viewerapp_object_info); + + lldbus_g_connection_register_g_object(server->connection, VIEWERAPI_PATH, G_OBJECT(server)); + + DBusGProxy *serverproxy = lldbus_g_proxy_new_for_name(server->connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); + + guint request_name_ret_unused; + // akin to org_freedesktop_DBus_request_name + if (lldbus_g_proxy_call(serverproxy, "RequestName", &error, G_TYPE_STRING, VIEWERAPI_SERVICE, G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, &request_name_ret_unused, G_TYPE_INVALID)) + { + // total success. + dbus_server_init = true; + } + else + { + llwarns << "Unable to register service name: " << error->message << llendl; + } + + g_object_unref(serverproxy); + } + else + { + g_warning("Unable to connect to dbus: %s", error->message); + } + + if (error) + g_error_free(error); + } +} + +gboolean viewer_app_api_GoSLURL(ViewerAppAPI *obj, gchar *slurl, gboolean **success_rtn, GError **error) +{ + bool success = false; + + llinfos << "Was asked to go to slurl: " << slurl << llendl; + + const bool from_external_browser = true; + if (LLURLDispatcher::dispatch(slurl, from_external_browser)) + { + // bring window to foreground, as it has just been "launched" from a URL + // todo: hmm, how to get there from here? + //xxx->mWindow->bringToFront(); + success = true; + } + + *success_rtn = g_new (gboolean, 1); + (*success_rtn)[0] = (gboolean)success; + + return TRUE; // the invokation succeeded, even if the actual dispatch didn't. +} + +/// + +//virtual +bool LLAppViewerLinux::initSLURLHandler() +{ + if (!grab_dbus_syms(DBUSGLIB_DYLIB_DEFAULT_NAME)) + { + return false; // failed + } + + g_type_init(); + + //ViewerAppAPI *api_server = (ViewerAppAPI*) + g_object_new(viewerappapi_get_type(), NULL); + + return true; +} + +//virtual +bool LLAppViewerLinux::sendURLToOtherInstance(const std::string& url) +{ + if (!grab_dbus_syms(DBUSGLIB_DYLIB_DEFAULT_NAME)) + { + return false; // failed + } + + bool success = false; + DBusGConnection *bus; + GError *error = NULL; + + g_type_init(); + + bus = lldbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (bus) + { + gboolean rtn = FALSE; + DBusGProxy *remote_object = + lldbus_g_proxy_new_for_name(bus, VIEWERAPI_SERVICE, VIEWERAPI_PATH, VIEWERAPI_INTERFACE); + + if (lldbus_g_proxy_call(remote_object, "GoSLURL", &error, + G_TYPE_STRING, url.c_str(), G_TYPE_INVALID, + G_TYPE_BOOLEAN, &rtn, G_TYPE_INVALID)) + { + success = rtn; + } + else + { + llinfos << "Call-out to other instance failed (perhaps not running): " << error->message << llendl; + } + + g_object_unref(G_OBJECT(remote_object)); + } + else + { + llwarns << "Couldn't connect to session bus: " << error->message << llendl; + } + + if (error) + g_error_free(error); + + return success; +} + +#else // LL_DBUS_ENABLED +bool LLAppViewerLinux::initSLURLHandler() +{ + return false; // not implemented without dbus +} +bool LLAppViewerLinux::sendURLToOtherInstance(const std::string& url) +{ + return false; // not implemented without dbus +} +#endif // LL_DBUS_ENABLED + void LLAppViewerLinux::handleSyncCrashTrace() { // This backtrace writes into stack_trace.log @@ -331,57 +531,90 @@ void LLAppViewerLinux::handleSyncCrashTrace() # endif // LL_ELFBIN } -void LLAppViewerLinux::handleCrashReporting() +void LLAppViewerLinux::handleCrashReporting(bool reportFreeze) { - const S32 cb = gCrashSettings.getS32(CRASH_BEHAVIOR_SETTING); - - // Always generate the report, have the logger do the asking, and - // don't wait for the logger before exiting (-> total cleanup). - if (CRASH_BEHAVIOR_NEVER_SEND != cb) - { - // launch the actual crash logger - const char* ask_dialog = "-dialog"; - if (CRASH_BEHAVIOR_ASK != cb) - ask_dialog = ""; // omit '-dialog' option - std::string cmd =gDirUtilp->getAppRODataDir(); - cmd += gDirUtilp->getDirDelimiter(); - cmd += "linux-crash-logger.bin"; - const char * cmdargv[] = - {cmd.c_str(), - ask_dialog, - "-user", - (char*)LLViewerLogin::getInstance()->getGridLabel().c_str(), - "-name", - LLAppViewer::instance()->getSecondLifeTitle().c_str(), + std::string cmd =gDirUtilp->getAppRODataDir(); + cmd += gDirUtilp->getDirDelimiter(); +#if LL_LINUX + cmd += "linux-crash-logger.bin"; +#else // LL_SOLARIS + cmd += "bin/solaris-crash-logger"; +#endif // LL_LINUX + + if(reportFreeze) + { + char* const cmdargv[] = + {(char*)cmd.c_str(), + (char*)"-previous", NULL}; - fflush(NULL); + + fflush(NULL); // flush all buffers before the child inherits them pid_t pid = fork(); if (pid == 0) { // child - execv(cmd.c_str(), (char* const*) cmdargv); /* Flawfinder: ignore */ + execv(cmd.c_str(), cmdargv); /* Flawfinder: Ignore */ llwarns << "execv failure when trying to start " << cmd << llendl; _exit(1); // avoid atexit() - } - else - { + } else { if (pid > 0) { - // DO NOT wait for child proc to die; we want - // the logger to outlive us while we quit to - // free up the screen/keyboard/etc. - ////int childExitStatus; - ////waitpid(pid, &childExitStatus, 0); + // wait for child proc to die + int childExitStatus; + waitpid(pid, &childExitStatus, 0); + } else { + llwarns << "fork failure." << llendl; + } + } + } + else + { + const S32 cb = gCrashSettings.getS32(CRASH_BEHAVIOR_SETTING); + + // Always generate the report, have the logger do the asking, and + // don't wait for the logger before exiting (-> total cleanup). + if (CRASH_BEHAVIOR_NEVER_SEND != cb) + { + // launch the actual crash logger + const char* ask_dialog = "-dialog"; + if (CRASH_BEHAVIOR_ASK != cb) + ask_dialog = ""; // omit '-dialog' option + const char * cmdargv[] = + {cmd.c_str(), + ask_dialog, + "-user", + (char*)LLViewerLogin::getInstance()->getGridLabel().c_str(), + "-name", + LLAppViewer::instance()->getSecondLifeTitle().c_str(), + NULL}; + fflush(NULL); + pid_t pid = fork(); + if (pid == 0) + { // child + execv(cmd.c_str(), (char* const*) cmdargv); /* Flawfinder: ignore */ + llwarns << "execv failure when trying to start " << cmd << llendl; + _exit(1); // avoid atexit() } else { - llwarns << "fork failure." << llendl; + if (pid > 0) + { + // DO NOT wait for child proc to die; we want + // the logger to outlive us while we quit to + // free up the screen/keyboard/etc. + ////int childExitStatus; + ////waitpid(pid, &childExitStatus, 0); + } + else + { + llwarns << "fork failure." << llendl; + } } } + // Sometimes signals don't seem to quit the viewer. Also, we may + // have been called explicitly instead of from a signal handler. + // Make sure we exit so as to not totally confuse the user. + _exit(1); // avoid atexit(), else we may re-crash in dtors. } - // Sometimes signals don't seem to quit the viewer. Also, we may - // have been called explicitly instead of from a signal handler. - // Make sure we exit so as to not totally confuse the user. - _exit(1); // avoid atexit(), else we may re-crash in dtors. } bool LLAppViewerLinux::beingDebugged() diff --git a/linden/indra/newview/llappviewerlinux.h b/linden/indra/newview/llappviewerlinux.h index a180b4d..7b6d75c 100644 --- a/linden/indra/newview/llappviewerlinux.h +++ b/linden/indra/newview/llappviewerlinux.h @@ -32,6 +32,14 @@ #ifndef LL_LLAPPVIEWERLINUX_H #define LL_LLAPPVIEWERLINUX_H +#if LL_DBUS_ENABLED +extern "C" { +# include +# include +# include +} +#endif + #ifndef LL_LLAPPVIEWER_H #include "llappviewer.h" #endif @@ -49,15 +57,37 @@ public: // virtual bool init(); // Override to do application initialization std::string generateSerialNumber(); + bool setupSLURLHandler(); protected: virtual bool beingDebugged(); - - virtual void handleCrashReporting(); + + virtual bool restoreErrorTrap(); + virtual void handleCrashReporting(bool reportFreeze); virtual void handleSyncCrashTrace(); virtual bool initLogging(); virtual bool initParseCommandLine(LLCommandLineParser& clp); + + virtual bool initSLURLHandler(); + virtual bool sendURLToOtherInstance(const std::string& url); }; +#if LL_DBUS_ENABLED +typedef struct +{ + GObject parent; + DBusGConnection *connection; +} ViewerAppAPI; + +extern "C" { + gboolean viewer_app_api_GoSLURL(ViewerAppAPI *obj, gchar *slurl, gboolean **success_rtn, GError **error); +} + +#define VIEWERAPI_SERVICE "com.secondlife.ViewerAppAPIService" +#define VIEWERAPI_PATH "/com/secondlife/ViewerAppAPI" +#define VIEWERAPI_INTERFACE "com.secondlife.ViewerAppAPI" + +#endif // LL_DBUS_ENABLED + #endif // LL_LLAPPVIEWERLINUX_H diff --git a/linden/indra/newview/llappviewerlinux_api.h b/linden/indra/newview/llappviewerlinux_api.h new file mode 100644 index 0000000..bd17599 --- /dev/null +++ b/linden/indra/newview/llappviewerlinux_api.h @@ -0,0 +1,148 @@ +/* Generated by dbus-binding-tool; do not edit! */ +/** + * $LicenseInfo:firstyear=2008&license=viewergpl$ + * + * Copyright (c) 2008, 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 __dbus_glib_marshal_viewerapp_MARSHAL_H__ +#define __dbus_glib_marshal_viewerapp_MARSHAL_H__ + +#include + +G_BEGIN_DECLS + +#ifdef G_ENABLE_DEBUG +#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v) +#define g_marshal_value_peek_char(v) g_value_get_char (v) +#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v) +#define g_marshal_value_peek_int(v) g_value_get_int (v) +#define g_marshal_value_peek_uint(v) g_value_get_uint (v) +#define g_marshal_value_peek_long(v) g_value_get_long (v) +#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v) +#define g_marshal_value_peek_int64(v) g_value_get_int64 (v) +#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v) +#define g_marshal_value_peek_enum(v) g_value_get_enum (v) +#define g_marshal_value_peek_flags(v) g_value_get_flags (v) +#define g_marshal_value_peek_float(v) g_value_get_float (v) +#define g_marshal_value_peek_double(v) g_value_get_double (v) +#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v) +#define g_marshal_value_peek_param(v) g_value_get_param (v) +#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v) +#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v) +#define g_marshal_value_peek_object(v) g_value_get_object (v) +#else /* !G_ENABLE_DEBUG */ +/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API. + * Do not access GValues directly in your code. Instead, use the + * g_value_get_*() functions + */ +#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int +#define g_marshal_value_peek_char(v) (v)->data[0].v_int +#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint +#define g_marshal_value_peek_int(v) (v)->data[0].v_int +#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint +#define g_marshal_value_peek_long(v) (v)->data[0].v_long +#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong +#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64 +#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64 +#define g_marshal_value_peek_enum(v) (v)->data[0].v_long +#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong +#define g_marshal_value_peek_float(v) (v)->data[0].v_float +#define g_marshal_value_peek_double(v) (v)->data[0].v_double +#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer +#endif /* !G_ENABLE_DEBUG */ + + +/* BOOLEAN:STRING,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.5XXD8T:1) */ +extern void dbus_glib_marshal_viewerapp_BOOLEAN__STRING_POINTER_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +void +dbus_glib_marshal_viewerapp_BOOLEAN__STRING_POINTER_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data) +{ + typedef gboolean (*GMarshalFunc_BOOLEAN__STRING_POINTER_POINTER) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + gpointer arg_3, + gpointer data2); + register GMarshalFunc_BOOLEAN__STRING_POINTER_POINTER callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + gboolean v_return; + + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 4); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_BOOLEAN__STRING_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback); + + v_return = callback (data1, + g_marshal_value_peek_string (param_values + 1), + g_marshal_value_peek_pointer (param_values + 2), + g_marshal_value_peek_pointer (param_values + 3), + data2); + + g_value_set_boolean (return_value, v_return); +} + +G_END_DECLS + +#endif /* __dbus_glib_marshal_viewerapp_MARSHAL_H__ */ + +#include +static const DBusGMethodInfo dbus_glib_viewerapp_methods[] = { + { (GCallback) viewer_app_api_GoSLURL, dbus_glib_marshal_viewerapp_BOOLEAN__STRING_POINTER_POINTER, 0 }, +}; + +const DBusGObjectInfo dbus_glib_viewerapp_object_info = { + 0, + dbus_glib_viewerapp_methods, + 1, +"com.secondlife.ViewerAppAPI\0GoSLURL\0S\0slurl\0I\0s\0success_ret\0O\0F\0N\0b\0\0\0", +"\0", +"\0" +}; + diff --git a/linden/indra/newview/llappviewerlinux_api.xml b/linden/indra/newview/llappviewerlinux_api.xml new file mode 100644 index 0000000..fac35b7 --- /dev/null +++ b/linden/indra/newview/llappviewerlinux_api.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/linden/indra/newview/llappviewerlinux_api_dbus.cpp b/linden/indra/newview/llappviewerlinux_api_dbus.cpp new file mode 100644 index 0000000..806714f --- /dev/null +++ b/linden/indra/newview/llappviewerlinux_api_dbus.cpp @@ -0,0 +1,131 @@ +/** + * @file llappviewerlinux_api_dbus.cpp + * @brief dynamic DBus symbol-grabbing code + * + * $LicenseInfo:firstyear=2008&license=viewergpl$ + * + * Copyright (c) 2008, 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$ + */ + +#if LL_DBUS_ENABLED + +#include "linden_common.h" + +extern "C" { +#include + +#include "apr_pools.h" +#include "apr_dso.h" +} + +#define DEBUGMSG(...) lldebugs << llformat(__VA_ARGS__) << llendl +#define INFOMSG(...) llinfos << llformat(__VA_ARGS__) << llendl +#define WARNMSG(...) llwarns << llformat(__VA_ARGS__) << llendl + +#define LL_DBUS_SYM(REQUIRED, DBUSSYM, RTN, ...) RTN (*ll##DBUSSYM)(__VA_ARGS__) = NULL +#include "llappviewerlinux_api_dbus_syms_raw.inc" +#undef LL_DBUS_SYM + +static bool sSymsGrabbed = false; +static apr_pool_t *sSymDBUSDSOMemoryPool = NULL; +static apr_dso_handle_t *sSymDBUSDSOHandleG = NULL; + +bool grab_dbus_syms(std::string dbus_dso_name) +{ + if (sSymsGrabbed) + { + // already have grabbed good syms + return TRUE; + } + + bool sym_error = false; + bool rtn = false; + apr_status_t rv; + apr_dso_handle_t *sSymDBUSDSOHandle = NULL; + +#define LL_DBUS_SYM(REQUIRED, DBUSSYM, RTN, ...) do{rv = apr_dso_sym((apr_dso_handle_sym_t*)&ll##DBUSSYM, sSymDBUSDSOHandle, #DBUSSYM); if (rv != APR_SUCCESS) {INFOMSG("Failed to grab symbol: %s", #DBUSSYM); if (REQUIRED) sym_error = true;} else DEBUGMSG("grabbed symbol: %s from %p", #DBUSSYM, (void*)ll##DBUSSYM);}while(0) + + //attempt to load the shared library + apr_pool_create(&sSymDBUSDSOMemoryPool, NULL); + + if ( APR_SUCCESS == (rv = apr_dso_load(&sSymDBUSDSOHandle, + dbus_dso_name.c_str(), + sSymDBUSDSOMemoryPool) )) + { + INFOMSG("Found DSO: %s", dbus_dso_name.c_str()); + +#include "llappviewerlinux_api_dbus_syms_raw.inc" + + if ( sSymDBUSDSOHandle ) + { + sSymDBUSDSOHandleG = sSymDBUSDSOHandle; + sSymDBUSDSOHandle = NULL; + } + + rtn = !sym_error; + } + else + { + INFOMSG("Couldn't load DSO: %s", dbus_dso_name.c_str()); + rtn = false; // failure + } + + if (sym_error) + { + WARNMSG("Failed to find necessary symbols in DBUS-GLIB libraries."); + } +#undef LL_DBUS_SYM + + sSymsGrabbed = rtn; + return rtn; +} + + +void ungrab_dbus_syms() +{ + // should be safe to call regardless of whether we've + // actually grabbed syms. + + if ( sSymDBUSDSOHandleG ) + { + apr_dso_unload(sSymDBUSDSOHandleG); + sSymDBUSDSOHandleG = NULL; + } + + if ( sSymDBUSDSOMemoryPool ) + { + apr_pool_destroy(sSymDBUSDSOMemoryPool); + sSymDBUSDSOMemoryPool = NULL; + } + + // NULL-out all of the symbols we'd grabbed +#define LL_DBUS_SYM(REQUIRED, DBUSSYM, RTN, ...) do{ll##DBUSSYM = NULL;}while(0) +#include "llappviewerlinux_api_dbus_syms_raw.inc" +#undef LL_DBUS_SYM + + sSymsGrabbed = false; +} + +#endif // LL_DBUS_ENABLED diff --git a/linden/indra/newview/llappviewerlinux_api_dbus.h b/linden/indra/newview/llappviewerlinux_api_dbus.h new file mode 100644 index 0000000..6d6c1b0 --- /dev/null +++ b/linden/indra/newview/llappviewerlinux_api_dbus.h @@ -0,0 +1,49 @@ +/** + * @file llappviewerlinux_api_dbus.h + * @brief DBus-glib symbol handling + * + * $LicenseInfo:firstyear=2008&license=viewergpl$ + * + * Copyright (c) 2008, 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 "linden_common.h" + +#if LL_DBUS_ENABLED + +extern "C" { +#include +} + +#define DBUSGLIB_DYLIB_DEFAULT_NAME "libdbus-glib-1.so.2" + +bool grab_dbus_syms(std::string dbus_dso_name); +void ungrab_dbus_syms(); + +#define LL_DBUS_SYM(REQUIRED, DBUSSYM, RTN, ...) extern RTN (*ll##DBUSSYM)(__VA_ARGS__) +#include "llappviewerlinux_api_dbus_syms_raw.inc" +#undef LL_DBUS_SYM + +#endif // LL_DBUS_ENABLED diff --git a/linden/indra/newview/llappviewerlinux_api_dbus_syms_raw.inc b/linden/indra/newview/llappviewerlinux_api_dbus_syms_raw.inc new file mode 100644 index 0000000..c0548e2 --- /dev/null +++ b/linden/indra/newview/llappviewerlinux_api_dbus_syms_raw.inc @@ -0,0 +1,9 @@ + +// required symbols to grab +LL_DBUS_SYM(true, dbus_g_bus_get, DBusGConnection*, DBusBusType, GError**); +LL_DBUS_SYM(true, dbus_g_proxy_new_for_name, DBusGProxy*, DBusGConnection*, const char *, const char*, const char*); +LL_DBUS_SYM(true, dbus_g_proxy_call, gboolean, DBusGProxy*, const char*, GError**, GType, ...); +LL_DBUS_SYM(true, dbus_g_object_type_install_info, void, GType, const DBusGObjectInfo*); +LL_DBUS_SYM(true, dbus_g_connection_register_g_object, void, DBusGConnection*, const char*, GObject*); + +// optional symbols to grab diff --git a/linden/indra/newview/llappviewermacosx.cpp b/linden/indra/newview/llappviewermacosx.cpp index 68c3a16..e3fd425 100644 --- a/linden/indra/newview/llappviewermacosx.cpp +++ b/linden/indra/newview/llappviewermacosx.cpp @@ -48,6 +48,7 @@ #include "llurldispatcher.h" #include #include "lldir.h" +#include namespace { // The command line args stored. @@ -193,22 +194,106 @@ bool LLAppViewerMacOSX::initParseCommandLine(LLCommandLineParser& clp) return true; } +// *FIX:Mani It would be nice to provide a clean interface to get the +// default_unix_signal_handler for the LLApp class. +extern void default_unix_signal_handler(int, siginfo_t *, void *); +bool LLAppViewerMacOSX::restoreErrorTrap() +{ + // This method intends to reinstate signal handlers. + // *NOTE:Mani It was found that the first execution of a shader was overriding + // our initial signal handlers somehow. + // This method will be called (at least) once per mainloop execution. + // *NOTE:Mani The signals used below are copied over from the + // setup_signals() func in LLApp.cpp + // LLApp could use some way of overriding that func, but for this viewer + // fix I opt to avoid affecting the server code. + + // Set up signal handlers that may result in program termination + // + struct sigaction act; + struct sigaction old_act; + act.sa_sigaction = default_unix_signal_handler; + sigemptyset( &act.sa_mask ); + act.sa_flags = SA_SIGINFO; + + unsigned int reset_count = 0; + +#define SET_SIG(S) sigaction(SIGABRT, &act, &old_act); \ + if((unsigned int)act.sa_sigaction != (unsigned int) old_act.sa_sigaction) \ + ++reset_count; + // Synchronous signals + SET_SIG(SIGABRT) + SET_SIG(SIGALRM) + SET_SIG(SIGBUS) + SET_SIG(SIGFPE) + SET_SIG(SIGHUP) + SET_SIG(SIGILL) + SET_SIG(SIGPIPE) + SET_SIG(SIGSEGV) + SET_SIG(SIGSYS) + + SET_SIG(LL_HEARTBEAT_SIGNAL) + SET_SIG(LL_SMACKDOWN_SIGNAL) + + // Asynchronous signals that are normally ignored + SET_SIG(SIGCHLD) + SET_SIG(SIGUSR2) + + // Asynchronous signals that result in attempted graceful exit + SET_SIG(SIGHUP) + SET_SIG(SIGTERM) + SET_SIG(SIGINT) + + // Asynchronous signals that result in core + SET_SIG(SIGQUIT) +#undef SET_SIG + + return reset_count == 0; +} + void LLAppViewerMacOSX::handleSyncCrashTrace() { // do nothing } -void LLAppViewerMacOSX::handleCrashReporting() +void LLAppViewerMacOSX::handleCrashReporting(bool reportFreeze) { - // Macintosh std::string command_str; - command_str += "open mac-crash-logger.app"; + //command_str = "open Second Life.app/Contents/Resources/mac-crash-logger.app"; + command_str = "mac-crash-logger.app/Contents/MacOS/mac-crash-logger"; - clear_signals(); - llinfos << "Launching crash reporter using: '" << command_str << "'" << llendl; - system(command_str.c_str()); /* Flawfinder: ignore */ - llinfos << "returned from crash reporter... dying" << llendl; - _exit(1); + FSRef appRef; + Boolean isDir = 0; + OSStatus os_result = FSPathMakeRef((UInt8*)command_str.c_str(), + &appRef, + &isDir); + if(os_result >= 0) + { + LSApplicationParameters appParams; + memset(&appParams, 0, sizeof(appParams)); + appParams.version = 0; + appParams.flags = kLSLaunchNoParams | kLSLaunchStartClassic; + appParams.application = &appRef; + + if(reportFreeze) + { + // Make sure freeze reporting launches the crash logger synchronously, lest + // Log files get changed by SL while the logger is running. + } + else + { + appParams.flags |= kLSLaunchAsync; + clear_signals(); + } + + ProcessSerialNumber o_psn; + os_result = LSOpenApplication(&appParams, &o_psn); + } + + if(!reportFreeze) + { + _exit(1); + } } std::string LLAppViewerMacOSX::generateSerialNumber() diff --git a/linden/indra/newview/llappviewermacosx.h b/linden/indra/newview/llappviewermacosx.h index 0d8c460..85193a8 100644 --- a/linden/indra/newview/llappviewermacosx.h +++ b/linden/indra/newview/llappviewermacosx.h @@ -49,7 +49,8 @@ public: protected: - virtual void handleCrashReporting(); + virtual bool restoreErrorTrap(); + virtual void handleCrashReporting(bool reportFreeze); virtual void handleSyncCrashTrace(); std::string generateSerialNumber(); diff --git a/linden/indra/newview/llappviewerwin32.cpp b/linden/indra/newview/llappviewerwin32.cpp index 9f37534..bf02087 100644 --- a/linden/indra/newview/llappviewerwin32.cpp +++ b/linden/indra/newview/llappviewerwin32.cpp @@ -64,7 +64,7 @@ #include "llcommandlineparser.h" -//*FIX:Mani - This hack is to fix a linker issue with libndofdev.lib +// *FIX:Mani - This hack is to fix a linker issue with libndofdev.lib // The lib was compiled under VS2005 - in VS2003 we need to remap assert #ifdef LL_DEBUG #ifdef LL_MSVC7 @@ -77,6 +77,8 @@ extern "C" { #endif #endif +const std::string LLAppViewerWin32::sWindowClass = "Second Life"; + LONG WINAPI viewer_windows_exception_handler(struct _EXCEPTION_POINTERS *exception_infop) { // *NOTE:Mani - this code is stolen from LLApp, where its never actually used. @@ -91,6 +93,7 @@ LONG WINAPI viewer_windows_exception_handler(struct _EXCEPTION_POINTERS *excepti if (LLApp::isError()) { llwarns << "Got another fatal signal while in the error handler, die now!" << llendl; + retval = EXCEPTION_EXECUTE_HANDLER; return retval; } @@ -119,7 +122,6 @@ LONG WINAPI viewer_windows_exception_handler(struct _EXCEPTION_POINTERS *excepti return retval; } - #if DEBUGGING_SEH_FILTER # define WINMAIN DebuggingWinMain #else @@ -195,6 +197,19 @@ int APIENTRY WINMAIN(HINSTANCE hInstance, } delete viewer_app_ptr; viewer_app_ptr = NULL; + + //start updater + if(LLAppViewer::sUpdaterInfo) + { +#if LL_WINDOWS + _spawnl(_P_NOWAIT, LLAppViewer::sUpdaterInfo->mUpdateExePath.c_str(), LLAppViewer::sUpdaterInfo->mUpdateExePath.c_str(), LLAppViewer::sUpdaterInfo->mParams.str().c_str(), NULL); +#elif LL_DARWIN + system(LLAppViewer::sUpdaterInfo->mUpdateExePath.c_str()); /* Flawfinder: ignore */ +#endif + delete LLAppViewer::sUpdaterInfo ; + LLAppViewer::sUpdaterInfo = NULL ; + } + return 0; } @@ -324,6 +339,17 @@ bool LLAppViewerWin32::cleanup() return result; } +bool LLAppViewerWin32::initLogging() +{ + // Remove the crash stack log from previous executions. + // Since we've started logging a new instance of the app, we can assume + // *NOTE: This should happen before the we send a 'previous instance froze' + // crash report, but it must happen after we initialize the DirUtil. + LLWinDebug::clearCrashStacks(); + + return LLAppViewer::initLogging(); +} + void LLAppViewerWin32::initConsole() { // pop up debug console @@ -405,7 +431,7 @@ bool LLAppViewerWin32::initHardwareTest() LLSplashScreen::update(splash_msg.str()); } - if (!LLWinDebug::checkExceptionHandler()) + if (!restoreErrorTrap()) { LL_WARNS("AppInit") << " Someone took over my exception handler (post hardware probe)!" << LL_ENDL; } @@ -445,39 +471,69 @@ bool LLAppViewerWin32::initParseCommandLine(LLCommandLineParser& clp) return true; } +bool LLAppViewerWin32::restoreErrorTrap() +{ + return LLWinDebug::checkExceptionHandler(); +} + void LLAppViewerWin32::handleSyncCrashTrace() { // do nothing } -void LLAppViewerWin32::handleCrashReporting() +void LLAppViewerWin32::handleCrashReporting(bool reportFreeze) { - // Windows only behaivor. Spawn win crash reporter. - std::string exe_path = gDirUtilp->getAppRODataDir(); + const char* logger_name = "win_crash_logger.exe"; + std::string exe_path = gDirUtilp->getExecutableDir(); exe_path += gDirUtilp->getDirDelimiter(); - exe_path += "win_crash_logger.exe"; + exe_path += logger_name; - std::string arg_string = "-user "; - arg_string += LLViewerLogin::getInstance()->getGridLabel(); - - S32 cb = gCrashSettings.getS32(CRASH_BEHAVIOR_SETTING); - switch(cb) + const char* arg_str = logger_name; + + // *NOTE:Mani - win_crash_logger.exe no longer parses command line options. + if(reportFreeze) + { + // Spawn crash logger. + // NEEDS to wait until completion, otherwise log files will get smashed. + _spawnl(_P_WAIT, exe_path.c_str(), arg_str, NULL); + } + else + { + S32 cb = gCrashSettings.getS32(CRASH_BEHAVIOR_SETTING); + if(cb != CRASH_BEHAVIOR_NEVER_SEND) + { + _spawnl(_P_NOWAIT, exe_path.c_str(), arg_str, NULL); + } + } +} + +//virtual +bool LLAppViewerWin32::sendURLToOtherInstance(const std::string& url) +{ + wchar_t window_class[256]; /* Flawfinder: ignore */ // Assume max length < 255 chars. + mbstowcs(window_class, sWindowClass.c_str(), 255); + window_class[255] = 0; + // Use the class instead of the window name. + HWND other_window = FindWindow(window_class, NULL); + + if (other_window != NULL) { - case CRASH_BEHAVIOR_ASK: - default: - arg_string += " -dialog "; - _spawnl(_P_NOWAIT, exe_path.c_str(), exe_path.c_str(), arg_string.c_str(), NULL); - break; - - case CRASH_BEHAVIOR_ALWAYS_SEND: - _spawnl(_P_NOWAIT, exe_path.c_str(), exe_path.c_str(), arg_string.c_str(), NULL); - break; - - case CRASH_BEHAVIOR_NEVER_SEND: - break; + lldebugs << "Found other window with the name '" << getWindowTitle() << "'" << llendl; + COPYDATASTRUCT cds; + const S32 SLURL_MESSAGE_TYPE = 0; + cds.dwData = SLURL_MESSAGE_TYPE; + cds.cbData = url.length() + 1; + cds.lpData = (void*)url.c_str(); + + LRESULT msg_result = SendMessage(other_window, WM_COPYDATA, NULL, (LPARAM)&cds); + lldebugs << "SendMessage(WM_COPYDATA) to other window '" + << getWindowTitle() << "' returned " << msg_result << llendl; + return true; } + return false; } + std::string LLAppViewerWin32::generateSerialNumber() { char serial_md5[MD5HEX_STR_SIZE]; // Flawfinder: ignore diff --git a/linden/indra/newview/llappviewerwin32.h b/linden/indra/newview/llappviewerwin32.h index fe16ec4..6a5b0b1 100644 --- a/linden/indra/newview/llappviewerwin32.h +++ b/linden/indra/newview/llappviewerwin32.h @@ -49,15 +49,21 @@ public: virtual bool cleanup(); protected: + virtual bool initLogging(); // Override to clean stack_trace info. virtual void initConsole(); // Initialize OS level debugging console. virtual bool initHardwareTest(); // Win32 uses DX9 to test hardware. virtual bool initParseCommandLine(LLCommandLineParser& clp); - virtual void handleCrashReporting(); + virtual bool restoreErrorTrap(); + virtual void handleCrashReporting(bool reportFreeze); virtual void handleSyncCrashTrace(); + virtual bool sendURLToOtherInstance(const std::string& url); + std::string generateSerialNumber(); + static const std::string sWindowClass; + private: void disableWinErrorReporting(); diff --git a/linden/indra/newview/llaudiosourcevo.cpp b/linden/indra/newview/llaudiosourcevo.cpp index e668078..50cd8cd 100644 --- a/linden/indra/newview/llaudiosourcevo.cpp +++ b/linden/indra/newview/llaudiosourcevo.cpp @@ -39,7 +39,7 @@ #include "llviewerparcelmgr.h" LLAudioSourceVO::LLAudioSourceVO(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, LLViewerObject *objectp) -: LLAudioSource(sound_id, owner_id, gain), + : LLAudioSource(sound_id, owner_id, gain, LLAudioEngine::AUDIO_TYPE_SFX), mObjectp(objectp), mActualGain(gain) { diff --git a/linden/indra/newview/llbox.cpp b/linden/indra/newview/llbox.cpp index 1e6d282..1bcec7a 100644 --- a/linden/indra/newview/llbox.cpp +++ b/linden/indra/newview/llbox.cpp @@ -81,7 +81,7 @@ void LLBox::renderface(S32 which_face) {7, 4, 0, 3} }; - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); //gGL.normal3fv(&normals[which_face][0]); gGL.texCoord2f(1,0); gGL.vertex3fv(&mVertex[ faces[which_face][0] ][0]); diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index 31fa653..2d9d356 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.cpp @@ -553,15 +553,17 @@ void LLChatBar::onInputEditorGainFocus( LLFocusableElement* caller, void* userda // static void LLChatBar::onClickSay( LLUICtrl* ctrl, void* userdata ) { - LLChatBar* self = (LLChatBar*) userdata; + e_chat_type chat_type = CHAT_TYPE_NORMAL; if (ctrl->getValue().asString() == "shout") { - self->sendChat( CHAT_TYPE_SHOUT ); + chat_type = CHAT_TYPE_SHOUT; } - else + else if (ctrl->getValue().asString() == "whisper") { - self->sendChat( CHAT_TYPE_NORMAL ); + chat_type = CHAT_TYPE_WHISPER; } + LLChatBar* self = (LLChatBar*) userdata; + self->sendChat(chat_type); } void LLChatBar::sendChatFromViewer(const std::string &utf8text, EChatType type, BOOL animate) diff --git a/linden/indra/newview/llcommandlineparser.cpp b/linden/indra/newview/llcommandlineparser.cpp index dc6a1e2..5dafe78 100644 --- a/linden/indra/newview/llcommandlineparser.cpp +++ b/linden/indra/newview/llcommandlineparser.cpp @@ -416,11 +416,6 @@ void setControlValueCB(const LLCommandLineParser::token_vector_t& value, const std::string& opt_name, LLControlGroup* ctrlGroup) { - if(value.size() > 1) - { - llwarns << "Ignoring extra tokens mapped to the setting: " << opt_name << "." << llendl; - } - // *FIX: Do sematic conversion here. // LLSD (ImplString) Is no good for doing string to type conversion for... // booleans @@ -457,7 +452,7 @@ void setControlValueCB(const LLCommandLineParser::token_vector_t& value, default: { // For the default types, let llsd do the conversion. - if(value.size() > 1) + if(value.size() > 1 && ctrl->isType(TYPE_LLSD)) { // Assume its an array... LLSD llsdArray; @@ -472,6 +467,11 @@ void setControlValueCB(const LLCommandLineParser::token_vector_t& value, } else if(value.size() > 0) { + if(value.size() > 1) + { + llwarns << "Ignoring extra tokens mapped to the setting: " << opt_name << "." << llendl; + } + LLSD llsdValue; llsdValue.assign(LLSD::String(value[0])); ctrl->setValue(llsdValue, false); diff --git a/linden/indra/newview/llcompilequeue.cpp b/linden/indra/newview/llcompilequeue.cpp index fc2742f..00ca833 100644 --- a/linden/indra/newview/llcompilequeue.cpp +++ b/linden/indra/newview/llcompilequeue.cpp @@ -60,6 +60,8 @@ #include "llviewerstats.h" #include "lluictrlfactory.h" +#include "llselectmgr.h" + ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs ///---------------------------------------------------------------------------- @@ -194,7 +196,20 @@ BOOL LLFloaterScriptQueue::start() { //llinfos << "LLFloaterCompileQueue::start()" << llendl; std::string buffer; - buffer = llformat("Starting %s of %d items.", mStartString.c_str(), mObjectIDs.count()); // *TODO: Translate + + LLSelectMgr *mgr = LLSelectMgr::getInstance(); + LLObjectSelectionHandle selectHandle = mgr->getSelection(); + U32 n_objects = 0; + if (gSavedSettings.getBOOL("EditLinkedParts")) + { + n_objects = selectHandle->getObjectCount(); + } + else + { + n_objects = selectHandle->getRootObjectCount(); + } + + buffer = llformat("Starting %s of %d items.", mStartString.c_str(), n_objects); // *TODO: Translate LLScrollListCtrl* list = getChild("queue output"); list->addCommentText(buffer); diff --git a/linden/indra/newview/llcontainerview.cpp b/linden/indra/newview/llcontainerview.cpp index dbec409..4a09265 100644 --- a/linden/indra/newview/llcontainerview.cpp +++ b/linden/indra/newview/llcontainerview.cpp @@ -88,7 +88,7 @@ BOOL LLContainerView::handleMouseUp(S32 x, S32 y, MASK mask) void LLContainerView::draw() { { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); } diff --git a/linden/indra/newview/lldrawable.cpp b/linden/indra/newview/lldrawable.cpp index 0f89585..ac90fdf 100644 --- a/linden/indra/newview/lldrawable.cpp +++ b/linden/indra/newview/lldrawable.cpp @@ -362,6 +362,7 @@ void LLDrawable::makeActive() if (pcode == LLViewerObject::LL_VO_WATER || pcode == LLViewerObject::LL_VO_SURFACE_PATCH || pcode == LLViewerObject::LL_VO_PART_GROUP || + pcode == LLViewerObject::LL_VO_HUD_PART_GROUP || pcode == LLViewerObject::LL_VO_CLOUDS || pcode == LLViewerObject::LL_VO_GROUND || pcode == LLViewerObject::LL_VO_SKY) @@ -951,6 +952,9 @@ BOOL LLDrawable::isVisible() const return TRUE; } +#if 0 + //disabling this code fixes DEV-20105. Leaving in place in case some other bug pops up as a a result. + //should be safe to just always ask the spatial group for visibility. if (isActive()) { if (isRoot()) @@ -973,6 +977,7 @@ BOOL LLDrawable::isVisible() const } } else +#endif { LLSpatialGroup* group = getSpatialGroup(); if (group && group->isVisible()) @@ -1380,7 +1385,10 @@ BOOL LLDrawable::isAnimating() const { return TRUE; } - + if (mVObjp->getPCode() == LLViewerObject::LL_VO_HUD_PART_GROUP) + { + return TRUE; + } if (mVObjp->getPCode() == LLViewerObject::LL_VO_CLOUDS) { return TRUE; diff --git a/linden/indra/newview/lldrawpool.cpp b/linden/indra/newview/lldrawpool.cpp index 9d8bd0a..196f8c1 100644 --- a/linden/indra/newview/lldrawpool.cpp +++ b/linden/indra/newview/lldrawpool.cpp @@ -194,7 +194,8 @@ S32 LLFacePool::drawLoopSetTex(face_array_t& face_list, S32 stage) iter != face_list.end(); iter++) { LLFace *facep = *iter; - facep->bindTexture(stage); + gGL.getTexUnit(stage)->bind(facep->getTexture()); + gGL.getTexUnit(0)->activate(); res += facep->renderIndexed(); } } @@ -395,7 +396,7 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) { if (params.mTexture.notNull()) { - params.mTexture->bind(); + gGL.getTexUnit(0)->bind(params.mTexture.get()); if (params.mTextureMatrix) { glMatrixMode(GL_TEXTURE); @@ -406,14 +407,14 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) } else { - LLImageGL::unbindTexture(0); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } } if (params.mVertexBuffer.notNull()) { params.mVertexBuffer->setBuffer(mask); - params.mVertexBuffer->drawRange(LLVertexBuffer::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); gPipeline.addTrianglesDrawn(params.mCount/3); } diff --git a/linden/indra/newview/lldrawpoolalpha.cpp b/linden/indra/newview/lldrawpoolalpha.cpp index 28263b2..d997c30 100644 --- a/linden/indra/newview/lldrawpoolalpha.cpp +++ b/linden/indra/newview/lldrawpoolalpha.cpp @@ -129,7 +129,7 @@ void LLDrawPoolAlpha::render(S32 pass) gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); glColor4f(1,0,0,1); LLViewerImage::sSmokeImagep->addTextureStats(1024.f*1024.f); - LLViewerImage::sSmokeImagep->bind(); + gGL.getTexUnit(0)->bind(LLViewerImage::sSmokeImagep.get()); renderAlphaHighlight(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD); } @@ -170,7 +170,7 @@ void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask) LLRenderPass::applyModelMatrix(params); params.mVertexBuffer->setBuffer(mask); - params.mVertexBuffer->drawRange(LLVertexBuffer::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); gPipeline.addTrianglesDrawn(params.mCount/3); } } @@ -231,7 +231,7 @@ void LLDrawPoolAlpha::renderGroupAlpha(LLSpatialGroup* group, U32 type, U32 mask if (texture && params.mTexture.notNull()) { gGL.getTexUnit(0)->activate(); - params.mTexture->bind(); + gGL.getTexUnit(0)->bind(params.mTexture.get()); params.mTexture->addTextureStats(params.mVSize); if (params.mTextureMatrix) { @@ -288,7 +288,7 @@ void LLDrawPoolAlpha::renderGroupAlpha(LLSpatialGroup* group, U32 type, U32 mask } params.mVertexBuffer->setBuffer(mask); - params.mVertexBuffer->drawRange(LLVertexBuffer::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); gPipeline.addTrianglesDrawn(params.mCount/3); if (params.mTextureMatrix && texture && params.mTexture.notNull()) diff --git a/linden/indra/newview/lldrawpoolavatar.cpp b/linden/indra/newview/lldrawpoolavatar.cpp index 97ff072..a5231dd 100644 --- a/linden/indra/newview/lldrawpoolavatar.cpp +++ b/linden/indra/newview/lldrawpoolavatar.cpp @@ -396,7 +396,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) { /* // debug code to draw a cube in place of avatar - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLVector3 pos = avatarp->getPositionAgent(); gGL.color4f(1.0f, 0.0f, 0.0f, 0.8f); @@ -495,17 +495,17 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) { if (LLVOAvatar::sShowCollisionVolumes) { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); avatarp->renderCollisionVolumes(); } if (avatarp->mIsSelf && LLAgent::sDebugDisplayTarget) { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLVector3 pos = avatarp->getPositionAgent(); gGL.color4f(1.0f, 0.0f, 0.0f, 0.8f); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { gGL.vertex3fv((pos - LLVector3(0.2f, 0.f, 0.f)).mV); gGL.vertex3fv((pos + LLVector3(0.2f, 0.f, 0.f)).mV); @@ -517,7 +517,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) pos = avatarp->mDrawable->getPositionAgent(); gGL.color4f(1.0f, 0.0f, 0.0f, 0.8f); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { gGL.vertex3fv((pos - LLVector3(0.2f, 0.f, 0.f)).mV); gGL.vertex3fv((pos + LLVector3(0.2f, 0.f, 0.f)).mV); @@ -529,7 +529,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) pos = avatarp->mRoot.getWorldPosition(); gGL.color4f(1.0f, 1.0f, 1.0f, 0.8f); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { gGL.vertex3fv((pos - LLVector3(0.2f, 0.f, 0.f)).mV); gGL.vertex3fv((pos + LLVector3(0.2f, 0.f, 0.f)).mV); @@ -541,7 +541,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) pos = avatarp->mPelvisp->getWorldPosition(); gGL.color4f(0.0f, 0.0f, 1.0f, 0.8f); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { gGL.vertex3fv((pos - LLVector3(0.2f, 0.f, 0.f)).mV); gGL.vertex3fv((pos + LLVector3(0.2f, 0.f, 0.f)).mV); diff --git a/linden/indra/newview/lldrawpoolbump.cpp b/linden/indra/newview/lldrawpoolbump.cpp index 0dd11d6..6593547 100644 --- a/linden/indra/newview/lldrawpoolbump.cpp +++ b/linden/indra/newview/lldrawpoolbump.cpp @@ -349,27 +349,29 @@ void LLDrawPoolBump::beginShiny(bool invisible) cube_map->setMatrix(1); // Make sure that texture coord generation happens for tex unit 1, as that's the one we use for // the cube map in the one pass shiny shaders - cube_channel = shader->enableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); + cube_channel = shader->enableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); cube_map->enableTexture(cube_channel); cube_map->enableTextureCoords(1); diffuse_channel = shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); } else { - cube_channel = 0; + cube_channel = shader->enableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); diffuse_channel = -1; cube_map->setMatrix(0); - cube_map->enable(shader->enableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB)); + cube_map->enable(cube_channel); } - cube_map->bind(); + gGL.getTexUnit(cube_channel)->bind(cube_map); + gGL.getTexUnit(0)->activate(); } else { cube_channel = 0; diffuse_channel = -1; + gGL.getTexUnit(0)->disable(); cube_map->enable(0); cube_map->setMatrix(0); - cube_map->bind(); + gGL.getTexUnit(0)->bind(cube_map); gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_COLOR); gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_VERT_ALPHA); @@ -423,7 +425,7 @@ void LLDrawPoolBump::endShiny(bool invisible) if (!invisible && mVertexShaderLevel > 1) { - shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); + shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 0) { @@ -435,18 +437,20 @@ void LLDrawPoolBump::endShiny(bool invisible) shader->unbind(); gGL.getTexUnit(0)->activate(); - glEnable(GL_TEXTURE_2D); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); } if (cube_channel >= 0) { + gGL.getTexUnit(cube_channel)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(cube_channel)->setTextureBlendType(LLTexUnit::TB_MULT); } } - - gGL.getTexUnit(0)->activate(); - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(diffuse_channel)->disable(); + gGL.getTexUnit(cube_channel)->disable(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); - + diffuse_channel = -1; cube_channel = 0; mShiny = FALSE; @@ -489,12 +493,14 @@ void LLDrawPoolBump::beginFullbrightShiny() cube_map->setMatrix(1); // Make sure that texture coord generation happens for tex unit 1, as that's the one we use for // the cube map in the one pass shiny shaders - cube_channel = shader->enableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); + gGL.getTexUnit(1)->disable(); + cube_channel = shader->enableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); cube_map->enableTexture(cube_channel); cube_map->enableTextureCoords(1); diffuse_channel = shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); - cube_map->bind(); + gGL.getTexUnit(cube_channel)->bind(cube_map); + gGL.getTexUnit(0)->activate(); } mShiny = TRUE; } @@ -535,14 +541,13 @@ void LLDrawPoolBump::endFullbrightShiny() shader->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); } gGL.getTexUnit(0)->activate(); - glEnable(GL_TEXTURE_2D); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); shader->unbind(); - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); } - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); diffuse_channel = -1; @@ -561,7 +566,7 @@ void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL applyModelMatrix(params); params.mVertexBuffer->setBuffer(mask); - params.mVertexBuffer->drawRange(LLVertexBuffer::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); gPipeline.addTrianglesDrawn(params.mCount/3); } } @@ -599,8 +604,8 @@ BOOL LLDrawPoolBump::bindBumpMap(LLDrawInfo& params) if (bump) { - bump->bind(1); - bump->bind(0); + gGL.getTexUnit(1)->bind(bump); + gGL.getTexUnit(0)->bind(bump); return TRUE; } return FALSE; @@ -629,7 +634,7 @@ void LLDrawPoolBump::beginBump() // TEXTURE UNIT 1 gGL.getTexUnit(1)->activate(); - glEnable(GL_TEXTURE_2D); // Texture unit 1 + 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); @@ -648,7 +653,7 @@ void LLDrawPoolBump::beginBump() gGL.getTexUnit(0)->activate(); stop_glerror(); - LLViewerImage::unbindTexture(1, GL_TEXTURE_2D); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); } //static @@ -680,7 +685,7 @@ void LLDrawPoolBump::endBump() // Disable texture unit 1 gGL.getTexUnit(1)->activate(); - glDisable(GL_TEXTURE_2D); // Texture unit 1 + gGL.getTexUnit(1)->disable(); gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT); // Disable texture unit 0 @@ -1083,17 +1088,17 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) { if (params.mTexture.notNull()) { - params.mTexture->bind(diffuse_channel); + gGL.getTexUnit(diffuse_channel)->bind(params.mTexture.get()); params.mTexture->addTextureStats(params.mVSize); } else { - LLImageGL::unbindTexture(0); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } } params.mVertexBuffer->setBuffer(mask); - params.mVertexBuffer->drawRange(LLVertexBuffer::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); gPipeline.addTrianglesDrawn(params.mCount/3); if (params.mTextureMatrix) { diff --git a/linden/indra/newview/lldrawpoolground.cpp b/linden/indra/newview/lldrawpoolground.cpp index 5698027..c8d110b 100644 --- a/linden/indra/newview/lldrawpoolground.cpp +++ b/linden/indra/newview/lldrawpoolground.cpp @@ -63,13 +63,14 @@ void LLDrawPoolGround::prerender() void LLDrawPoolGround::render(S32 pass) { - if (mDrawFace.empty()) + if (mDrawFace.empty() || !gSavedSettings.getBOOL("RenderGround")) { return; } LLGLSPipelineSkyBox gls_skybox; - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); LLGLClampToFarClip far_clip(glh_get_current_projection()); diff --git a/linden/indra/newview/lldrawpoolsky.cpp b/linden/indra/newview/lldrawpoolsky.cpp index e1dbf95..573061d 100644 --- a/linden/indra/newview/lldrawpoolsky.cpp +++ b/linden/indra/newview/lldrawpoolsky.cpp @@ -186,7 +186,7 @@ void LLDrawPoolSky::renderHeavenlyBody(U8 hb, LLFace* face) if (! face->getGeomCount()) return; LLImageGL* tex = face->getTexture(); - tex->bind(); + gGL.getTexUnit(0)->bind(tex); LLColor4 color(mHB[hb]->getInterpColor()); LLOverrideFaceColor override(this, color); face->renderIndexed(); @@ -200,7 +200,7 @@ void LLDrawPoolSky::renderSunHalo(LLFace* face) if (! face->getGeomCount()) return; LLImageGL* tex = face->getTexture(); - tex->bind(); + gGL.getTexUnit(0)->bind(tex); LLColor4 color(mHB[0]->getInterpColor()); color.mV[3] = llclamp(mHB[0]->getHaloBrighness(), 0.f, 1.f); diff --git a/linden/indra/newview/lldrawpoolterrain.cpp b/linden/indra/newview/lldrawpoolterrain.cpp index ccfbd2d..e99fc91 100644 --- a/linden/indra/newview/lldrawpoolterrain.cpp +++ b/linden/indra/newview/lldrawpoolterrain.cpp @@ -72,19 +72,19 @@ LLDrawPoolTerrain::LLDrawPoolTerrain(LLViewerImage *texturep) : TRUE, TRUE, GL_ALPHA8, GL_ALPHA, LLUUID("e97cf410-8e61-7005-ec06-629eba4cd1fb")); - mAlphaRampImagep->bind(0); + gGL.getTexUnit(0)->bind(mAlphaRampImagep.get()); mAlphaRampImagep->setClamp(TRUE, TRUE); m2DAlphaRampImagep = gImageList.getImageFromFile("alpha_gradient_2d.j2c", TRUE, TRUE, GL_ALPHA8, GL_ALPHA, LLUUID("38b86f85-2575-52a9-a531-23108d8da837")); - m2DAlphaRampImagep->bind(0); + gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get()); m2DAlphaRampImagep->setClamp(TRUE, TRUE); mTexturep->setBoostLevel(LLViewerImage::BOOST_TERRAIN); - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } LLDrawPoolTerrain::~LLDrawPoolTerrain() @@ -240,7 +240,7 @@ void LLDrawPoolTerrain::renderFullShader() // detail texture 0 // S32 detail0 = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_DETAIL0); - LLViewerImage::bindTexture(detail_texture0p,detail0); + gGL.getTexUnit(detail0)->bind(detail_texture0p); gGL.getTexUnit(0)->activate(); glEnable(GL_TEXTURE_GEN_S); @@ -258,7 +258,7 @@ void LLDrawPoolTerrain::renderFullShader() // detail texture 1 // S32 detail1 = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_DETAIL1); - LLViewerImage::bindTexture(detail_texture1p,detail1); + gGL.getTexUnit(detail1)->bind(detail_texture1p); /// ALPHA TEXTURE COORDS 0: gGL.getTexUnit(1)->activate(); @@ -269,11 +269,11 @@ void LLDrawPoolTerrain::renderFullShader() // detail texture 2 // S32 detail2 = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_DETAIL2); - LLViewerImage::bindTexture(detail_texture2p,detail2); - glEnable(GL_TEXTURE_2D); + gGL.getTexUnit(detail2)->bind(detail_texture2p); + + gGL.getTexUnit(2)->activate(); /// ALPHA TEXTURE COORDS 1: - gGL.getTexUnit(2)->activate(); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glTranslatef(-2.f, 0.f, 0.f); @@ -283,7 +283,7 @@ void LLDrawPoolTerrain::renderFullShader() // detail texture 3 // S32 detail3 = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_DETAIL3); - LLViewerImage::bindTexture(detail_texture3p,detail3); + gGL.getTexUnit(detail3)->bind(detail_texture3p); /// ALPHA TEXTURE COORDS 2: gGL.getTexUnit(3)->activate(); @@ -296,7 +296,7 @@ void LLDrawPoolTerrain::renderFullShader() // Alpha Ramp // S32 alpha_ramp = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_ALPHARAMP); - LLViewerImage::bindTexture(m2DAlphaRampImagep,alpha_ramp); + gGL.getTexUnit(alpha_ramp)->bind(m2DAlphaRampImagep.get()); // GL_BLEND disabled by default drawLoop(); @@ -308,36 +308,36 @@ void LLDrawPoolTerrain::renderFullShader() sShader->disableTexture(LLViewerShaderMgr::TERRAIN_DETAIL2); sShader->disableTexture(LLViewerShaderMgr::TERRAIN_DETAIL3); - LLImageGL::unbindTexture(alpha_ramp, GL_TEXTURE_2D); + gGL.getTexUnit(alpha_ramp)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(4)->disable(); gGL.getTexUnit(4)->activate(); - glDisable(GL_TEXTURE_2D); // Texture unit 4 glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); - LLImageGL::unbindTexture(detail3, GL_TEXTURE_2D); + gGL.getTexUnit(detail3)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(3)->disable(); gGL.getTexUnit(3)->activate(); - glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); - LLImageGL::unbindTexture(detail2, GL_TEXTURE_2D); + gGL.getTexUnit(detail2)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(2)->disable(); gGL.getTexUnit(2)->activate(); - glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); - LLImageGL::unbindTexture(detail1, GL_TEXTURE_2D); + gGL.getTexUnit(detail1)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->disable(); gGL.getTexUnit(1)->activate(); - glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glMatrixMode(GL_TEXTURE); @@ -347,9 +347,9 @@ void LLDrawPoolTerrain::renderFullShader() //---------------------------------------------------------------------------- // Restore Texture Unit 0 defaults - LLImageGL::unbindTexture(detail0, GL_TEXTURE_2D); + gGL.getTexUnit(detail0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(0)->activate(); - glEnable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glMatrixMode(GL_TEXTURE); @@ -388,7 +388,7 @@ void LLDrawPoolTerrain::renderFull4TU() // Stage 0: detail texture 0 // gGL.getTexUnit(0)->activate(); - LLViewerImage::bindTexture(detail_texture0p,0); + gGL.getTexUnit(0)->bind(detail_texture0p); glClientActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_GEN_S); @@ -405,9 +405,9 @@ void LLDrawPoolTerrain::renderFull4TU() // Stage 1: Generate alpha ramp for detail0/detail1 transition // - LLViewerImage::bindTexture(m2DAlphaRampImagep,1); + gGL.getTexUnit(1)->bind(m2DAlphaRampImagep.get()); + gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(1)->activate(); - glEnable(GL_TEXTURE_2D); // Texture unit 1 glClientActiveTextureARB(GL_TEXTURE1_ARB); glEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -418,12 +418,13 @@ void LLDrawPoolTerrain::renderFull4TU() // // Stage 2: Interpolate detail1 with existing based on ramp // - LLViewerImage::bindTexture(detail_texture1p,2); + gGL.getTexUnit(2)->bind(detail_texture1p); + gGL.getTexUnit(2)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(2)->activate(); - glEnable(GL_TEXTURE_2D); // Texture unit 2 - glClientActiveTextureARB(GL_TEXTURE2_ARB); + glClientActiveTextureARB(GL_TEXTURE2_ARB); glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); @@ -436,9 +437,9 @@ void LLDrawPoolTerrain::renderFull4TU() // // Stage 3: Modulate with primary (vertex) color for lighting // - LLViewerImage::bindTexture(detail_texture1p,3); // bind any texture + gGL.getTexUnit(3)->bind(detail_texture1p); + gGL.getTexUnit(3)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(3)->activate(); - glEnable(GL_TEXTURE_2D); // Texture unit 3 glClientActiveTextureARB(GL_TEXTURE3_ARB); // Set alpha texture and do lighting modulation @@ -456,7 +457,7 @@ void LLDrawPoolTerrain::renderFull4TU() // Stage 0: Write detail3 into base // gGL.getTexUnit(0)->activate(); - LLViewerImage::bindTexture(detail_texture3p,0); + gGL.getTexUnit(0)->bind(detail_texture3p); glClientActiveTextureARB(GL_TEXTURE0_ARB); glDisableClientState(GL_TEXTURE_COORD_ARRAY); @@ -472,9 +473,9 @@ void LLDrawPoolTerrain::renderFull4TU() // // Stage 1: Generate alpha ramp for detail2/detail3 transition // - LLViewerImage::bindTexture(m2DAlphaRampImagep,1); + gGL.getTexUnit(1)->bind(m2DAlphaRampImagep.get()); + gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(1)->activate(); - glEnable(GL_TEXTURE_2D); // Texture unit 1 glClientActiveTextureARB(GL_TEXTURE1_ARB); glEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -492,9 +493,9 @@ void LLDrawPoolTerrain::renderFull4TU() // // Stage 2: Interpolate detail2 with existing based on ramp // - LLViewerImage::bindTexture(detail_texture2p,2); + gGL.getTexUnit(2)->bind(detail_texture2p); + gGL.getTexUnit(2)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(2)->activate(); - glEnable(GL_TEXTURE_2D); // Texture unit 2 glClientActiveTextureARB(GL_TEXTURE2_ARB); glDisableClientState(GL_TEXTURE_COORD_ARRAY); @@ -511,9 +512,9 @@ void LLDrawPoolTerrain::renderFull4TU() // // Stage 3: Generate alpha ramp for detail1/detail2 transition // - LLViewerImage::bindTexture(m2DAlphaRampImagep,3); + gGL.getTexUnit(3)->bind(m2DAlphaRampImagep.get()); + gGL.getTexUnit(3)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(3)->activate(); - glEnable(GL_TEXTURE_2D); // Texture unit 3 glClientActiveTextureARB(GL_TEXTURE3_ARB); glEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -536,21 +537,21 @@ void LLDrawPoolTerrain::renderFull4TU() LLVertexBuffer::unbind(); // Disable multitexture - LLImageGL::unbindTexture(3, GL_TEXTURE_2D); + gGL.getTexUnit(3)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(3)->disable(); gGL.getTexUnit(3)->activate(); glClientActiveTextureARB(GL_TEXTURE3_ARB); glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisable(GL_TEXTURE_2D); // Texture unit 3 glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); - LLImageGL::unbindTexture(2, GL_TEXTURE_2D); + gGL.getTexUnit(2)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(2)->disable(); gGL.getTexUnit(2)->activate(); glClientActiveTextureARB(GL_TEXTURE2_ARB); glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisable(GL_TEXTURE_2D); // Texture unit 2 glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); @@ -558,11 +559,11 @@ void LLDrawPoolTerrain::renderFull4TU() glLoadIdentity(); glMatrixMode(GL_MODELVIEW); - LLImageGL::unbindTexture(1, GL_TEXTURE_2D); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->disable(); gGL.getTexUnit(1)->activate(); glClientActiveTextureARB(GL_TEXTURE1_ARB); glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisable(GL_TEXTURE_2D); // Texture unit 1 glMatrixMode(GL_TEXTURE); glLoadIdentity(); @@ -575,9 +576,9 @@ void LLDrawPoolTerrain::renderFull4TU() // Restore Texture Unit 0 defaults gGL.getTexUnit(0)->activate(); - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + glClientActiveTextureARB(GL_TEXTURE0_ARB); - gGL.getTexUnit(0)->activate(); glDisableClientState(GL_NORMAL_ARRAY); glDisable(GL_TEXTURE_GEN_S); @@ -616,7 +617,7 @@ void LLDrawPoolTerrain::renderFull2TU() // // Stage 0: Render detail 0 into base // - LLViewerImage::bindTexture(detail_texture0p,0); + gGL.getTexUnit(0)->bind(detail_texture0p); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); @@ -635,7 +636,7 @@ void LLDrawPoolTerrain::renderFull2TU() // // Stage 0: Generate alpha ramp for detail0/detail1 transition // - LLViewerImage::bindTexture(m2DAlphaRampImagep,0); + gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get()); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); @@ -648,9 +649,9 @@ void LLDrawPoolTerrain::renderFull2TU() // // Stage 1: Write detail1 // - LLViewerImage::bindTexture(detail_texture1p,1); // Texture unit 1 + gGL.getTexUnit(1)->bind(detail_texture1p); + gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(1)->activate(); - glEnable(GL_TEXTURE_2D); // Texture unit 1 glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); @@ -673,7 +674,7 @@ void LLDrawPoolTerrain::renderFull2TU() // // Stage 0: Generate alpha ramp for detail1/detail2 transition // - LLViewerImage::bindTexture(m2DAlphaRampImagep,0); + gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get()); // Set the texture matrix glMatrixMode(GL_TEXTURE); @@ -687,9 +688,9 @@ void LLDrawPoolTerrain::renderFull2TU() // // Stage 1: Write detail2 // - LLViewerImage::bindTexture(detail_texture2p,1); + gGL.getTexUnit(1)->bind(detail_texture2p); + gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(1)->activate(); - glEnable(GL_TEXTURE_2D); // Texture unit 1 glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); @@ -713,7 +714,7 @@ void LLDrawPoolTerrain::renderFull2TU() // Stage 0: Generate alpha ramp for detail2/detail3 transition // gGL.getTexUnit(0)->activate(); - LLViewerImage::bindTexture(m2DAlphaRampImagep,0); + gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get()); // Set the texture matrix glMatrixMode(GL_TEXTURE); glLoadIdentity(); @@ -724,9 +725,9 @@ void LLDrawPoolTerrain::renderFull2TU() gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); // Stage 1: Write detail3 - LLViewerImage::bindTexture(detail_texture3p,1); + gGL.getTexUnit(1)->bind(detail_texture3p); + gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(1)->activate(); - glEnable(GL_TEXTURE_2D); // Texture unit 1 glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); @@ -749,9 +750,9 @@ void LLDrawPoolTerrain::renderFull2TU() // Disable multitexture - LLImageGL::unbindTexture(1, GL_TEXTURE_2D); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->disable(); gGL.getTexUnit(1)->activate(); - glDisable(GL_TEXTURE_2D); // Texture unit 1 glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); @@ -763,9 +764,8 @@ void LLDrawPoolTerrain::renderFull2TU() // Restore Texture Unit 0 defaults gGL.getTexUnit(0)->activate(); - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->activate(); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glMatrixMode(GL_TEXTURE); @@ -784,10 +784,10 @@ void LLDrawPoolTerrain::renderSimple() // Stage 0: Base terrain texture pass mTexturep->addTextureStats(1024.f*1024.f); - mTexturep->bind(0); gGL.getTexUnit(0)->activate(); - glEnable(GL_TEXTURE_2D); // Texture unit 2 + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->bind(mTexturep.get()); LLVector3 origin_agent = mDrawFace[0]->getDrawable()->getVObj()->getRegion()->getOriginAgent(); F32 tscale = 1.f/256.f; @@ -808,8 +808,8 @@ void LLDrawPoolTerrain::renderSimple() //---------------------------------------------------------------------------- // Restore Texture Unit 0 defaults - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glMatrixMode(GL_TEXTURE); @@ -839,7 +839,7 @@ void LLDrawPoolTerrain::renderOwnership() LLViewerParcelOverlay *overlayp = regionp->getParcelOverlay(); LLImageGL *texturep = overlayp->getTexture(); - LLViewerImage::bindTexture(texturep); + gGL.getTexUnit(0)->bind(texturep); // *NOTE: Because the region is 256 meters wide, but has 257 pixels, the // texture coordinates for pixel 256x256 is not 1,1. This makes the @@ -872,7 +872,7 @@ void LLDrawPoolTerrain::renderForSelect() } - LLImageGL::unbindTexture(0); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); for (std::vector::iterator iter = mDrawFace.begin(); iter != mDrawFace.end(); iter++) diff --git a/linden/indra/newview/lldrawpooltree.cpp b/linden/indra/newview/lldrawpooltree.cpp index fd178dc..40ba54a 100644 --- a/linden/indra/newview/lldrawpooltree.cpp +++ b/linden/indra/newview/lldrawpooltree.cpp @@ -50,7 +50,7 @@ LLDrawPoolTree::LLDrawPoolTree(LLViewerImage *texturep) : LLFacePool(POOL_TREE), mTexturep(texturep) { - mTexturep->bind(0); + gGL.getTexUnit(0)->bind(mTexturep.get()); mTexturep->setClamp(FALSE, FALSE); } @@ -124,6 +124,7 @@ void LLDrawPoolTree::renderForSelect() 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); @@ -144,7 +145,7 @@ void LLDrawPoolTree::renderTree(BOOL selecting) LLGLState normalize(GL_NORMALIZE, TRUE); // Bind the texture for this tree. - LLViewerImage::bindTexture(mTexturep,sDiffTex); + gGL.getTexUnit(sDiffTex)->bind(mTexturep.get()); U32 indices_drawn = 0; diff --git a/linden/indra/newview/lldrawpoolwater.cpp b/linden/indra/newview/lldrawpoolwater.cpp index d8303bd..6e2c42a 100644 --- a/linden/indra/newview/lldrawpoolwater.cpp +++ b/linden/indra/newview/lldrawpoolwater.cpp @@ -68,11 +68,11 @@ LLDrawPoolWater::LLDrawPoolWater() : LLFacePool(POOL_WATER) { mHBTex[0] = gImageList.getImage(gSunTextureID, TRUE, TRUE); - mHBTex[0]->bind(); + gGL.getTexUnit(0)->bind(mHBTex[0].get()); mHBTex[0]->setClamp(TRUE, TRUE); mHBTex[1] = gImageList.getImage(gMoonTextureID, TRUE, TRUE); - mHBTex[1]->bind(); + gGL.getTexUnit(0)->bind(mHBTex[1].get()); mHBTex[1]->setClamp(TRUE, TRUE); mWaterImagep = gImageList.getImage(WATER_TEST); @@ -166,10 +166,9 @@ void LLDrawPoolWater::render(S32 pass) // Set up second pass first mWaterImagep->addTextureStats(1024.f*1024.f); - mWaterImagep->bind(1); gGL.getTexUnit(1)->activate(); - - glEnable(GL_TEXTURE_2D); // Texture unit 1 + gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->bind(mWaterImagep.get()); LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis(); F32 up_dot = camera_up * LLVector3::z_axis; @@ -218,20 +217,20 @@ void LLDrawPoolWater::render(S32 pass) { continue; } - face->bindTexture(); + gGL.getTexUnit(0)->bind(face->getTexture()); face->renderIndexed(); } // Now, disable texture coord generation on texture state 1 gGL.getTexUnit(1)->activate(); - glDisable(GL_TEXTURE_2D); // Texture unit 1 + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->disable(); glDisable(GL_TEXTURE_GEN_S); //texture unit 1 glDisable(GL_TEXTURE_GEN_T); //texture unit 1 - LLImageGL::unbindTexture(1, GL_TEXTURE_2D); // Disable texture coordinate and color arrays gGL.getTexUnit(0)->activate(); - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); stop_glerror(); @@ -275,8 +274,9 @@ void LLDrawPoolWater::render(S32 pass) { gSky.mVOSkyp->getCubeMap()->disable(); } - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); - glEnable(GL_TEXTURE_2D); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); @@ -316,7 +316,7 @@ void LLDrawPoolWater::renderReflection(LLFace* face) LLGLSNoFog noFog; - LLViewerImage::bindTexture(mHBTex[dr]); + gGL.getTexUnit(0)->bind(mHBTex[dr].get()); LLOverrideFaceColor override(this, face->getFaceColor().mV); face->renderIndexed(); @@ -390,7 +390,7 @@ void LLDrawPoolWater::shade() if (reftex > -1) { gGL.getTexUnit(reftex)->activate(); - gPipeline.mWaterRef.bindTexture(); + gGL.getTexUnit(reftex)->bind(&gPipeline.mWaterRef); gGL.getTexUnit(0)->activate(); } @@ -406,7 +406,7 @@ void LLDrawPoolWater::shade() } mWaterNormp->addTextureStats(1024.f*1024.f); - mWaterNormp->bind(bumpTex); + gGL.getTexUnit(bumpTex)->bind(mWaterNormp.get()); mWaterNormp->setMipFilterNearest (mWaterNormp->getMipFilterNearest(), !gSavedSettings.getBOOL("RenderWaterMipNormal")); @@ -421,8 +421,8 @@ void LLDrawPoolWater::shade() shader->uniform1f(LLViewerShaderMgr::WATER_FOGDENSITY, param_mgr->getFogDensity()); } - - gPipeline.mWaterDis.bindTexture(); + + gGL.getTexUnit(screentex)->bind(&gPipeline.mWaterDis); if (mVertexShaderLevel == 1) { @@ -502,7 +502,7 @@ void LLDrawPoolWater::shade() } LLVOWater* water = (LLVOWater*) face->getViewerObject(); - face->bindTexture(diffTex); + gGL.getTexUnit(diffTex)->bind(face->getTexture()); sNeedsReflectionUpdate = TRUE; @@ -527,7 +527,7 @@ void LLDrawPoolWater::shade() } } - shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); + shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); shader->disableTexture(LLViewerShaderMgr::WATER_SCREENTEX); shader->disableTexture(LLViewerShaderMgr::BUMP_MAP); shader->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); @@ -536,7 +536,7 @@ void LLDrawPoolWater::shade() shader->unbind(); gGL.getTexUnit(0)->activate(); - glEnable(GL_TEXTURE_2D); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); gGL.setColorMask(true, false); } diff --git a/linden/indra/newview/lldrawpoolwlsky.cpp b/linden/indra/newview/lldrawpoolwlsky.cpp index 8802c1f..a8495d5 100644 --- a/linden/indra/newview/lldrawpoolwlsky.cpp +++ b/linden/indra/newview/lldrawpoolwlsky.cpp @@ -159,7 +159,7 @@ void LLDrawPoolWLSky::renderStars(void) const // *NOTE: have to have bound the cloud noise texture already since register // combiners blending below requires something to be bound // and we might as well only bind once. - //LLGLEnable gl_texture_2d(GL_TEXTURE_2D); + //gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); gPipeline.disableLights(); @@ -202,7 +202,8 @@ void LLDrawPoolWLSky::renderSkyClouds(F32 camHeightLocal) const LLGLSBlendFunc blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); - sCloudNoiseTexture->bind(); + gGL.getTexUnit(0)->bind(sCloudNoiseTexture); + shader->bind(); /// Render the skydome @@ -223,7 +224,7 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() if (gSky.mVOSkyp->getSun().getDraw() && face->getGeomCount()) { LLImageGL * tex = face->getTexture(); - tex->bind(); + gGL.getTexUnit(0)->bind(tex); LLColor4 color(gSky.mVOSkyp->getSun().getInterpColor()); LLFacePool::LLOverrideFaceColor color_override(this, color); face->renderIndexed(); @@ -238,7 +239,7 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() // stars register combiners, we bind again here for defensive reasons, // since LLImageGL::bind detects that it's a noop, and optimizes it out. LLImageGL * tex = face->getTexture(); - tex->bind(); + gGL.getTexUnit(0)->bind(tex); LLColor4 color(gSky.mVOSkyp->getMoon().getInterpColor()); F32 a = gSky.mVOSkyp->getMoon().getDirection().mV[2]; if (a > 0.f) @@ -280,7 +281,7 @@ void LLDrawPoolWLSky::render(S32 pass) // renderStars() requires something to be bound and we might as well only // bind the moon's texture once. LLImageGL * tex = gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]->getTexture(); - tex->bind(); + gGL.getTexUnit(0)->bind(tex); renderHeavenlyBodies(); @@ -291,7 +292,7 @@ void LLDrawPoolWLSky::render(S32 pass) renderSkyClouds(camHeightLocal); - LLImageGL::unbindTexture(0); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } void LLDrawPoolWLSky::prerender() diff --git a/linden/indra/newview/lldynamictexture.cpp b/linden/indra/newview/lldynamictexture.cpp index ad0cdec..9ce4515 100644 --- a/linden/indra/newview/lldynamictexture.cpp +++ b/linden/indra/newview/lldynamictexture.cpp @@ -32,7 +32,6 @@ #include "llviewerprecompiledheaders.h" #include "lldynamictexture.h" -#include "llimagegl.h" #include "llglheaders.h" #include "llviewerwindow.h" #include "llviewercamera.h" @@ -105,7 +104,7 @@ void LLDynamicTexture::generateGLTexture(LLGLint internal_format, LLGLenum prima } releaseGLTexture(); LLPointer raw_image = new LLImageRaw(mWidth, mHeight, mComponents); - mTexture = new LLImageGL(mWidth, mHeight, mComponents, FALSE); + mTexture = new LLViewerImage(mWidth, mHeight, mComponents, FALSE); if (internal_format >= 0) { mTexture->setExplicitFormat(internal_format, primary_format, type_format, swap_bytes); @@ -113,6 +112,7 @@ void LLDynamicTexture::generateGLTexture(LLGLint internal_format, LLGLenum prima // llinfos << "ALLOCATING " << (mWidth*mHeight*mComponents)/1024 << "K" << llendl; mTexture->createGLTexture(0, raw_image); mTexture->setClamp(mClamp, mClamp); + mTexture->setInitialized(false); } //----------------------------------------------------------------------------- @@ -144,7 +144,7 @@ void LLDynamicTexture::preRender(BOOL clear_depth) mOrigin.mY = llmax(mOrigin.mY, 0) ; } - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } // Set up camera mCamera.setOrigin(*LLViewerCamera::getInstance()); @@ -184,19 +184,6 @@ void LLDynamicTexture::postRender(BOOL success) } //----------------------------------------------------------------------------- -// bindTexture() -//----------------------------------------------------------------------------- -void LLDynamicTexture::bindTexture() -{ - LLViewerImage::bindTexture(mTexture,0); -} - -void LLDynamicTexture::unbindTexture() -{ - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); -} - -//----------------------------------------------------------------------------- // static // updateDynamicTextures() // Calls update on each dynamic texture. Calls each group in order: "first," then "middle," then "last." diff --git a/linden/indra/newview/lldynamictexture.h b/linden/indra/newview/lldynamictexture.h index 6069940..ff3e5c1 100644 --- a/linden/indra/newview/lldynamictexture.h +++ b/linden/indra/newview/lldynamictexture.h @@ -60,8 +60,8 @@ public: virtual void preRender(BOOL clear_depth = TRUE); virtual BOOL render(); virtual void postRender(BOOL success); - virtual void bindTexture(); - virtual void unbindTexture(); + + LLImageGL* getTexture(void) const { return mTexture; } static BOOL updateAllInstances(); diff --git a/linden/indra/newview/llface.cpp b/linden/indra/newview/llface.cpp index 5b43fcd..3b5f8ab 100644 --- a/linden/indra/newview/llface.cpp +++ b/linden/indra/newview/llface.cpp @@ -362,10 +362,10 @@ void LLFace::renderForSelect(U32 data_mask) switch (getPoolType()) { case LLDrawPool::POOL_ALPHA: - getTexture()->bind(); + gGL.getTexUnit(0)->bind(getTexture()); break; default: - LLImageGL::unbindTexture(0); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); break; } } @@ -390,19 +390,19 @@ void LLFace::renderForSelect(U32 data_mask) { glPushMatrix(); glMultMatrixf((float*) mDrawablep->getRegion()->mRenderMatrix.mMatrix); - mVertexBuffer->draw(LLVertexBuffer::TRIANGLES, mIndicesCount, mIndicesIndex); + mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); glPopMatrix(); } else { - mVertexBuffer->draw(LLVertexBuffer::TRIANGLES, mIndicesCount, mIndicesIndex); + mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); } } else { glPushMatrix(); glMultMatrixf((float*)getRenderMatrix().mMatrix); - mVertexBuffer->draw(LLVertexBuffer::TRIANGLES, mIndicesCount, mIndicesIndex); + mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); glPopMatrix(); } } @@ -419,7 +419,7 @@ void LLFace::renderSelected(LLImageGL *imagep, const LLColor4& color) if (mGeomCount > 0 && mIndicesCount > 0) { - LLViewerImage::bindTexture(imagep); + gGL.getTexUnit(0)->bind(imagep); gGL.pushMatrix(); if (mDrawablep->isActive()) @@ -438,7 +438,7 @@ void LLFace::renderSelected(LLImageGL *imagep, const LLColor4& color) #if !LL_RELEASE_FOR_DOWNLOAD LLGLState::checkClientArrays("", LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD); #endif - mVertexBuffer->draw(LLVertexBuffer::TRIANGLES, mIndicesCount, mIndicesIndex); + mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); unsetFaceColor(); gGL.popMatrix(); @@ -1203,7 +1203,7 @@ S32 LLFace::pushVertices(const U16* index_array) const { if (mIndicesCount) { - mVertexBuffer->drawRange(LLVertexBuffer::TRIANGLES, mGeomIndex, mGeomIndex+mGeomCount-1, mIndicesCount, mIndicesIndex); + mVertexBuffer->drawRange(LLRender::TRIANGLES, mGeomIndex, mGeomIndex+mGeomCount-1, mIndicesCount, mIndicesIndex); gPipeline.addTrianglesDrawn(mIndicesCount/3); } diff --git a/linden/indra/newview/llface.h b/linden/indra/newview/llface.h index 0501dcc..497b93c 100644 --- a/linden/indra/newview/llface.h +++ b/linden/indra/newview/llface.h @@ -101,7 +101,6 @@ public: void setPixelArea(F32 area) { mPixelArea = area; } F32 getVirtualSize() const { return mVSize; } F32 getPixelArea() const { return mPixelArea; } - void bindTexture(S32 stage = 0) const { LLViewerImage::bindTexture(mTexture, stage); } void renderSetColor() const; S32 renderElements(const U16 *index_array) const; @@ -120,6 +119,7 @@ public: LLVertexBuffer* getVertexBuffer() const { return mVertexBuffer; } void setPoolType(U32 type) { mPoolType = type; } S32 getTEOffset() { return mTEOffset; } + LLViewerImage* getTexture() { return mTexture; } void setViewerObject(LLViewerObject* object); void setPool(LLFacePool *pool, LLViewerImage *texturep); diff --git a/linden/indra/newview/llface.inl b/linden/indra/newview/llface.inl index 8f8cfaf..7e9c9c1 100644 --- a/linden/indra/newview/llface.inl +++ b/linden/indra/newview/llface.inl @@ -33,6 +33,7 @@ #define LL_LLFACE_INL #include "llglheaders.h" +#include "llrender.h" inline BOOL LLFace::getDirty() const { diff --git a/linden/indra/newview/llfasttimerview.cpp b/linden/indra/newview/llfasttimerview.cpp index f1ca99f..4449adf 100644 --- a/linden/indra/newview/llfasttimerview.cpp +++ b/linden/indra/newview/llfasttimerview.cpp @@ -116,6 +116,7 @@ static struct ft_display_info ft_display_table[] = { LLFastTimer::FTM_VFILE_WAIT, " VFile Wait", &LLColor4::cyan6, 0 }, // { LLFastTimer::FTM_IDLE_CB, " Callbacks", &LLColor4::pink1, 0 }, { LLFastTimer::FTM_RENDER, " Render", &green0, 1 }, + { LLFastTimer::FTM_PICK, " Pick", &LLColor4::purple, 1 }, { LLFastTimer::FTM_HUD_EFFECTS, " HUD Effects", &LLColor4::orange1, 0 }, { LLFastTimer::FTM_HUD_UPDATE, " HUD Update", &LLColor4::orange2, 0 }, { LLFastTimer::FTM_UPDATE_SKY, " Sky Update", &LLColor4::cyan1, 0 }, @@ -463,7 +464,7 @@ void LLFastTimerView::draw() // Draw the window background { - LLGLSNoTexture gls_ui_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); } @@ -755,7 +756,7 @@ void LLFastTimerView::draw() LLRect graph_rect; // Draw borders { - LLGLSNoTexture gls_ui_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f(0.5f,0.5f,0.5f,0.5f); S32 by = y + 2; @@ -792,7 +793,7 @@ void LLFastTimerView::draw() // Draw bars for each history entry // Special: -1 = show running average - LLViewerImage::bindTexture(box_imagep->getImage()); + gGL.getTexUnit(0)->bind(box_imagep->getImage()); for (S32 j=-1; j LINE_GRAPH_HEIGHT; j++) { int sublevel_dx[FTV_DISPLAY_NUM+1]; @@ -936,7 +937,7 @@ void LLFastTimerView::draw() //draw line graph history { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLLocalClipRect clip(graph_rect); //normalize based on last frame's maximum @@ -980,7 +981,7 @@ void LLFastTimerView::draw() gGL.color4f(0.5f,0.5f,0.5f,1); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); gGL.vertex2i((S32)bar, graph_rect.mBottom); gGL.vertex2i((S32)bar, graph_rect.mTop); gGL.end(); @@ -1016,7 +1017,7 @@ void LLFastTimerView::draw() } gGL.color4f(col[0], col[1], col[2], alpha); - gGL.begin(LLVertexBuffer::LINE_STRIP); + gGL.begin(LLRender::LINE_STRIP); for (U32 j = 0; j < LLFastTimer::FTM_HISTORY_NUM; j++) { U64 ticks = ticks_sum[j+1][idx]; diff --git a/linden/indra/newview/llfeaturemanager.cpp b/linden/indra/newview/llfeaturemanager.cpp index a3da4f5..7883953 100644 --- a/linden/indra/newview/llfeaturemanager.cpp +++ b/linden/indra/newview/llfeaturemanager.cpp @@ -447,8 +447,6 @@ void LLFeatureManager::applyRecommendedSettings() { gSavedSettings.setF32("RenderFarClip", 128.0f); } - - } void LLFeatureManager::applyFeatures(bool skipFeatures) diff --git a/linden/indra/newview/llfilepicker.cpp b/linden/indra/newview/llfilepicker.cpp index bbcfba6..088da4b 100644 --- a/linden/indra/newview/llfilepicker.cpp +++ b/linden/indra/newview/llfilepicker.cpp @@ -933,7 +933,7 @@ void LLFilePicker::chooser_responder(GtkWidget *widget, gint response, gpointer GtkWindow* LLFilePicker::buildFilePicker(bool is_save, bool is_folder, std::string context) { - if (ll_try_gtk_init() && + if (LLWindowSDL::ll_try_gtk_init() && ! gViewerWindow->getWindow()->getFullscreen()) { GtkWidget *win = NULL; @@ -974,7 +974,7 @@ GtkWindow* LLFilePicker::buildFilePicker(bool is_save, bool is_folder, std::stri // Make GTK tell the window manager to associate this // dialog with our non-GTK raw X11 window, which should try // to keep it on top etc. - Window XWindowID = get_SDL_XWindowID(); + Window XWindowID = LLWindowSDL::get_SDL_XWindowID(); if (None != XWindowID) { gtk_widget_realize(GTK_WIDGET(win)); // so we can get its gdkwin diff --git a/linden/indra/newview/llfloateractivespeakers.cpp b/linden/indra/newview/llfloateractivespeakers.cpp index 2352be3..bee6155 100644 --- a/linden/indra/newview/llfloateractivespeakers.cpp +++ b/linden/indra/newview/llfloateractivespeakers.cpp @@ -47,6 +47,7 @@ #include "llsdutil.h" #include "llimview.h" #include "llviewerwindow.h" +#include "llappviewer.h" const F32 SPEAKER_TIMEOUT = 10.f; // seconds of not being on voice channel before removed from list of active speakers const F32 RESORT_TIMEOUT = 5.f; // seconds of mouse inactivity before it's ok to sort regardless of mouse-in-view. @@ -1358,6 +1359,11 @@ void LLLocalSpeakerMgr::updateSpeakerList() // pull speakers from voice channel LLSpeakerMgr::updateSpeakerList(); + if (gDisconnected)//the world is cleared. + { + return ; + } + // add non-voice speakers in chat range std::vector< LLCharacter* >::iterator avatar_it; for(avatar_it = LLCharacter::sInstances.begin(); avatar_it != LLCharacter::sInstances.end(); ++avatar_it) diff --git a/linden/indra/newview/llfloateranimpreview.cpp b/linden/indra/newview/llfloateranimpreview.cpp index 66b7a56..95c18df 100644 --- a/linden/indra/newview/llfloateranimpreview.cpp +++ b/linden/indra/newview/llfloateranimpreview.cpp @@ -384,9 +384,10 @@ void LLFloaterAnimPreview::draw() if (mMotionID.notNull() && mAnimPreview) { gGL.color3f(1.f, 1.f, 1.f); - mAnimPreview->bindTexture(); - gGL.begin( LLVertexBuffer::QUADS ); + gGL.getTexUnit(0)->bind(mAnimPreview->getTexture()); + + gGL.begin( LLRender::QUADS ); { gGL.texCoord2f(0.f, 1.f); gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT); @@ -399,7 +400,7 @@ void LLFloaterAnimPreview::draw() } gGL.end(); - mAnimPreview->unbindTexture(); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar(); if (!avatarp->areAnimationsPaused()) @@ -1068,7 +1069,7 @@ BOOL LLPreviewAnimation::render() glLoadIdentity(); LLGLSUIDefault def; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f(0.15f, 0.2f, 0.3f, 1.f); gl_rect_2d_simple( mWidth, mHeight ); diff --git a/linden/indra/newview/llfloaterauction.cpp b/linden/indra/newview/llfloaterauction.cpp index 80c43ab..a5929fd 100644 --- a/linden/indra/newview/llfloaterauction.cpp +++ b/linden/indra/newview/llfloaterauction.cpp @@ -148,7 +148,7 @@ void LLFloaterAuction::draw() if (childGetRect("snapshot_icon", rect)) { { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gl_rect_2d(rect, LLColor4(0.f, 0.f, 0.f, 1.f)); rect.stretch(-1); } @@ -205,7 +205,7 @@ void LLFloaterAuction::onClickSnapshot(void* data) LLVFile::writeFile(j2c->getData(), j2c->getDataSize(), gVFS, self->mImageID, LLAssetType::AT_TEXTURE); self->mImage = new LLImageGL((LLImageRaw*)raw, FALSE); - self->mImage->bind(); + gGL.getTexUnit(0)->bind(self->mImage); self->mImage->setClamp(TRUE, TRUE); } else diff --git a/linden/indra/newview/llfloaterbeacons.cpp b/linden/indra/newview/llfloaterbeacons.cpp new file mode 100644 index 0000000..0b73186 --- /dev/null +++ b/linden/indra/newview/llfloaterbeacons.cpp @@ -0,0 +1,150 @@ +/** + * @file llfloaterbeacons.cpp + * @brief Front-end to LLPipeline controls for highlighting various kinds of objects. + * @author Coco + * + * $LicenseInfo:firstyear=2001&license=viewergpl$ + * + * Copyright (c) 2001-2008, 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" +#include "llfloaterbeacons.h" +#include "llviewercontrol.h" +#include "lluictrlfactory.h" +#include "llcheckboxctrl.h" +#include "pipeline.h" + + +LLFloaterBeacons::LLFloaterBeacons(const LLSD& seed) +{ + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_beacons.xml"); + + // Initialize pipeline states from saved settings. + // OK to do at floater constructor time because beacons do not display unless the floater is open + // therefore it is OK to not initialize the pipeline state before needed. + // Note also that we should replace those pipeline statics with direct lookup of the saved settings + // eliminating the need to keep these states in sync. + LLPipeline::setRenderScriptedTouchBeacons(gSavedSettings.getBOOL("scripttouchbeacon")); + LLPipeline::setRenderScriptedBeacons( gSavedSettings.getBOOL("scriptsbeacon")); + LLPipeline::setRenderPhysicalBeacons( gSavedSettings.getBOOL("physicalbeacon")); + LLPipeline::setRenderSoundBeacons( gSavedSettings.getBOOL("soundsbeacon")); + LLPipeline::setRenderParticleBeacons( gSavedSettings.getBOOL("particlesbeacon")); + LLPipeline::setRenderHighlights( gSavedSettings.getBOOL("renderhighlights")); + LLPipeline::setRenderBeacons( gSavedSettings.getBOOL("renderbeacons")); +} + +BOOL LLFloaterBeacons::postBuild() +{ + childSetCommitCallback("touch_only", onClickUICheck, this); + childSetCommitCallback("scripted", onClickUICheck, this); + childSetCommitCallback("physical", onClickUICheck, this); + childSetCommitCallback("sounds", onClickUICheck, this); + childSetCommitCallback("particles", onClickUICheck, this); + childSetCommitCallback("highlights", onClickUICheck, this); + childSetCommitCallback("beacons", onClickUICheck, this); + return TRUE; +} + +// Needed to make the floater visibility toggle the beacons. +// Too bad we can't just add control_name="BeaconAlwaysOn" to the XML. +void LLFloaterBeacons::open() +{ + LLFloater::open(); + gSavedSettings.setBOOL( "BeaconAlwaysOn", TRUE); +} +void LLFloaterBeacons::close(bool app_quitting) +{ + LLFloater::close(app_quitting); + if(!app_quitting) + { + gSavedSettings.setBOOL( "BeaconAlwaysOn", FALSE); + } +} + +// Callback attached to each check box control to both affect their main purpose +// and to implement the couple screwy interdependency rules that some have. +//static +void LLFloaterBeacons::onClickUICheck(LLUICtrl *ctrl, void* data) +{ + LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl; + std::string name = check->getName(); + LLFloaterBeacons* view = (LLFloaterBeacons*)data; + if( name == "touch_only") + { + LLPipeline::toggleRenderScriptedTouchBeacons(NULL); + // Don't allow both to be ON at the same time. Toggle the other one off if both now on. + if ( + LLPipeline::getRenderScriptedTouchBeacons(NULL) && + LLPipeline::getRenderScriptedBeacons(NULL) ) + { + LLPipeline::setRenderScriptedBeacons(FALSE); + view->getChild("scripted")->setControlValue(LLSD(FALSE)); + view->getChild("touch_only")->setControlValue(LLSD(TRUE)); // just to be sure it's in sync with llpipeline + } + } + else if(name == "scripted") + { + LLPipeline::toggleRenderScriptedBeacons(NULL); + // Don't allow both to be ON at the same time. Toggle the other one off if both now on. + if ( + LLPipeline::getRenderScriptedTouchBeacons(NULL) && + LLPipeline::getRenderScriptedBeacons(NULL) ) + { + LLPipeline::setRenderScriptedTouchBeacons(FALSE); + view->getChild("touch_only")->setControlValue(LLSD(FALSE)); + view->getChild("scripted")->setControlValue(LLSD(TRUE)); // just to be sure it's in sync with llpipeline + } + } + else if(name == "physical") LLPipeline::setRenderPhysicalBeacons(check->get()); + else if(name == "sounds") LLPipeline::setRenderSoundBeacons(check->get()); + else if(name == "particles") LLPipeline::setRenderParticleBeacons(check->get()); + else if(name == "highlights") + { + LLPipeline::toggleRenderHighlights(NULL); + // Don't allow both to be OFF at the same time. Toggle the other one on if both now off. + if ( + !LLPipeline::getRenderBeacons(NULL) && + !LLPipeline::getRenderHighlights(NULL) ) + { + LLPipeline::setRenderBeacons(TRUE); + view->getChild("beacons")->setControlValue(LLSD(TRUE)); + view->getChild("highlights")->setControlValue(LLSD(FALSE)); // just to be sure it's in sync with llpipeline + } + } + else if(name == "beacons") + { + LLPipeline::toggleRenderBeacons(NULL); + // Don't allow both to be OFF at the same time. Toggle the other one on if both now off. + if ( + !LLPipeline::getRenderBeacons(NULL) && + !LLPipeline::getRenderHighlights(NULL) ) + { + LLPipeline::setRenderHighlights(TRUE); + view->getChild("highlights")->setControlValue(LLSD(TRUE)); + view->getChild("beacons")->setControlValue(LLSD(FALSE)); // just to be sure it's in sync with llpipeline + } + } +} diff --git a/linden/indra/newview/llfloaterbeacons.h b/linden/indra/newview/llfloaterbeacons.h new file mode 100644 index 0000000..e608dab --- /dev/null +++ b/linden/indra/newview/llfloaterbeacons.h @@ -0,0 +1,56 @@ +/** + * @file llfloaterbeacons.h + * @brief Front-end to LLPipeline controls for highlighting various kinds of objects. + * @author Coco + * + * $LicenseInfo:firstyear=2002&license=viewergpl$ + * + * Copyright (c) 2002-2008, 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_LLFLOATERBEACONS_H +#define LL_LLFLOATERBEACONS_H + +#include "llfloater.h" + +class LLFloaterBeacons : public LLFloater, public LLFloaterSingleton +{ + friend class LLUISingleton >; + +public: + /*virtual*/ BOOL postBuild(); + + // Needed to make the floater visibility toggle the beacons. + // Too bad we can't just add control_name="BeaconAlwaysOn" to the XML. + /*virtual*/ void open(); + /*virtual*/ void close(bool app_quitting); + +private: + LLFloaterBeacons(const LLSD& seed); + + static void onClickUICheck(LLUICtrl *ctrl, void* data); +}; + +#endif diff --git a/linden/indra/newview/llfloaterbuy.cpp b/linden/indra/newview/llfloaterbuy.cpp index 5d815fa..9e8556f 100644 --- a/linden/indra/newview/llfloaterbuy.cpp +++ b/linden/indra/newview/llfloaterbuy.cpp @@ -289,11 +289,6 @@ void LLFloaterBuy::inventoryChanged(LLViewerObject* obj, removeVOInventoryListener(); } -void LLFloaterBuy::close(bool app_quitting) -{ - LLSelectMgr::getInstance()->deselectAll(); - LLFloater::close(app_quitting); -} // static void LLFloaterBuy::onClickBuy(void*) @@ -325,3 +320,10 @@ void LLFloaterBuy::onClickCancel(void*) sInstance->close(); } } + +void LLFloaterBuy::onClose(bool app_quitting) +{ + // drop reference to current selection so selection goes away + mObjectSelection = NULL; + LLFloater::onClose(app_quitting); +} diff --git a/linden/indra/newview/llfloaterbuy.h b/linden/indra/newview/llfloaterbuy.h index 0eef41b..8c0e144 100644 --- a/linden/indra/newview/llfloaterbuy.h +++ b/linden/indra/newview/llfloaterbuy.h @@ -57,6 +57,7 @@ protected: LLFloaterBuy(); ~LLFloaterBuy(); + /*virtual*/ void onClose(bool app_quitting); void reset(); void requestObjectInventories(); @@ -65,8 +66,6 @@ protected: S32 serial_num, void* data); - /*virtual*/ void close(bool app_quitting = false); - static void onClickBuy(void*); static void onClickCancel(void*); diff --git a/linden/indra/newview/llfloaterbuycurrency.cpp b/linden/indra/newview/llfloaterbuycurrency.cpp index cbd41f4..1cbf314 100644 --- a/linden/indra/newview/llfloaterbuycurrency.cpp +++ b/linden/indra/newview/llfloaterbuycurrency.cpp @@ -358,11 +358,6 @@ void LLFloaterBuyCurrencyUI::onClickErrorWeb(void* data) // static void LLFloaterBuyCurrency::buyCurrency() { - if (gHideLinks) - { - return; - } - LLFloaterBuyCurrencyUI* ui = LLFloaterBuyCurrencyUI::soleInstance(true); ui->noTarget(); ui->updateUI(); @@ -371,15 +366,6 @@ void LLFloaterBuyCurrency::buyCurrency() void LLFloaterBuyCurrency::buyCurrency(const std::string& name, S32 price) { - if (gHideLinks) - { - LLStringUtil::format_map_t args; - args["[NAME]"] = name; - args["[PRICE]"] = llformat("%d", price); - gViewerWindow->alertXml("NotEnoughCurrency", args); - return; - } - LLFloaterBuyCurrencyUI* ui = LLFloaterBuyCurrencyUI::soleInstance(true); ui->target(name, price); ui->updateUI(); diff --git a/linden/indra/newview/llfloatercolorpicker.cpp b/linden/indra/newview/llfloatercolorpicker.cpp index 1ffbeb3..9b2a5f6 100644 --- a/linden/indra/newview/llfloatercolorpicker.cpp +++ b/linden/indra/newview/llfloatercolorpicker.cpp @@ -165,7 +165,7 @@ createUI () } } mRGBImage = new LLImageGL ( (LLImageRaw*)raw, FALSE ); - mRGBImage->bind(); + gGL.getTexUnit(0)->bind(mRGBImage); mRGBImage->setClamp(TRUE, TRUE); // create palette @@ -543,9 +543,9 @@ void LLFloaterColorPicker::draw() LLRect local_rect = getLocalRect(); if (gFocusMgr.childHasKeyboardFocus(this) && mSwatch->isInVisibleChain() && mContextConeOpacity > 0.001f) { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLEnable(GL_CULL_FACE); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity); gGL.vertex2i(swatch_rect.mLeft, swatch_rect.mTop); diff --git a/linden/indra/newview/llfloaterimagepreview.cpp b/linden/indra/newview/llfloaterimagepreview.cpp index 912a4fc..8f592b2 100644 --- a/linden/indra/newview/llfloaterimagepreview.cpp +++ b/linden/indra/newview/llfloaterimagepreview.cpp @@ -232,14 +232,14 @@ void LLFloaterImagePreview::draw() if (mGLName) { - LLImageGL::bindExternalTexture( mGLName, 0, GL_TEXTURE_2D ); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mGLName); } else { glGenTextures(1, &mGLName ); stop_glerror(); - LLImageGL::bindExternalTexture( mGLName, 0, GL_TEXTURE_2D ); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mGLName); stop_glerror(); glTexImage2D( @@ -251,8 +251,7 @@ void LLFloaterImagePreview::draw() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); if (mAvatarPreview) { mAvatarPreview->setTexture(mGLName); @@ -261,7 +260,7 @@ void LLFloaterImagePreview::draw() } gGL.color3f(1.f, 1.f, 1.f); - gGL.begin( LLVertexBuffer::QUADS ); + gGL.begin( LLRender::QUADS ); { gGL.texCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mTop); gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT); @@ -274,7 +273,7 @@ void LLFloaterImagePreview::draw() } gGL.end(); - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); stop_glerror(); } @@ -285,11 +284,15 @@ void LLFloaterImagePreview::draw() gGL.color3f(1.f, 1.f, 1.f); if (selected == 9) - mSculptedPreview->bindTexture(); + { + gGL.getTexUnit(0)->bind(mSculptedPreview->getTexture()); + } else - mAvatarPreview->bindTexture(); + { + gGL.getTexUnit(0)->bind(mAvatarPreview->getTexture()); + } - gGL.begin( LLVertexBuffer::QUADS ); + gGL.begin( LLRender::QUADS ); { gGL.texCoord2f(0.f, 1.f); gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT); @@ -302,10 +305,7 @@ void LLFloaterImagePreview::draw() } gGL.end(); - if (selected == 9) - mSculptedPreview->unbindTexture(); - else - mAvatarPreview->unbindTexture(); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } } } @@ -774,7 +774,9 @@ LLImagePreviewSculpted::LLImagePreviewSculpted(S32 width, S32 height) : LLDynami LLVolumeParams volume_params; volume_params.setType(LL_PCODE_PROFILE_CIRCLE, LL_PCODE_PATH_CIRCLE); volume_params.setSculptID(LLUUID::null, LL_SCULPT_TYPE_SPHERE); - mVolume = new LLVolume(volume_params, (F32) MAX_LOD); + + F32 const HIGHEST_LOD = 4.0f; + mVolume = new LLVolume(volume_params, HIGHEST_LOD); /* mDummyAvatar = new LLVOAvatar(LLUUID::null, LL_PCODE_LEGACY_AVATAR, gAgent.getRegion()); @@ -811,7 +813,36 @@ void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance) { mVolume->sculpt(imagep->getWidth(), imagep->getHeight(), imagep->getComponents(), imagep->getData(), 0); } - + + const LLVolumeFace &vf = mVolume->getVolumeFace(0); + U32 num_indices = vf.mIndices.size(); + U32 num_vertices = vf.mVertices.size(); + + mVertexBuffer = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL, 0); + mVertexBuffer->allocateBuffer(num_vertices, num_indices, TRUE); + + LLStrider vertex_strider; + LLStrider normal_strider; + LLStrider index_strider; + + mVertexBuffer->getVertexStrider(vertex_strider); + mVertexBuffer->getNormalStrider(normal_strider); + mVertexBuffer->getIndexStrider(index_strider); + + // build vertices and normals + for (U32 i = 0; (S32)i < num_vertices; i++) + { + *(vertex_strider++) = vf.mVertices[i].mPosition; + LLVector3 normal = vf.mVertices[i].mNormal; + normal.normalize(); + *(normal_strider++) = normal; + } + + // build indices + for (U16 i = 0; i < num_indices; i++) + { + *(index_strider++) = vf.mIndices[i]; + } } @@ -846,7 +877,7 @@ BOOL LLImagePreviewSculpted::render() glMatrixMode(GL_MODELVIEW); gGL.popMatrix(); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_DEPTH_BUFFER_BIT); LLVector3 target_pos(0, 0, 0); @@ -865,55 +896,21 @@ BOOL LLImagePreviewSculpted::render() LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / mCameraZoom); LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mWidth, mHeight, FALSE); - gPipeline.enableLightsAvatar(); - - gGL.pushMatrix(); - glScalef(0.5, 0.5, 0.5); - const LLVolumeFace &vf = mVolume->getVolumeFace(0); U32 num_indices = vf.mIndices.size(); - U32 num_vertices = vf.mVertices.size(); - - if (num_vertices > 0 && num_indices > 0) - { - glEnableClientState(GL_NORMAL_ARRAY); - // build vertices and normals - F32* vertices = new F32[num_vertices * 3]; - F32* normals = new F32[num_vertices * 3]; - - for (U32 i = 0; (S32)i < num_vertices; i++) - { - LLVector3 position = vf.mVertices[i].mPosition; - vertices[i*3] = position.mV[VX]; - vertices[i*3+1] = position.mV[VY]; - vertices[i*3+2] = position.mV[VZ]; - - LLVector3 normal = vf.mVertices[i].mNormal; - normals[i*3] = normal.mV[VX]; - normals[i*3+1] = normal.mV[VY]; - normals[i*3+2] = normal.mV[VZ]; - } + + mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL); - // build indices - U16* indices = new U16[num_indices]; - for (U16 i = 0; i < num_indices; i++) - { - indices[i] = vf.mIndices[i]; - } + gPipeline.enableLightsAvatar(); + gGL.pushMatrix(); + const F32 SCALE = 1.25f; + gGL.scalef(SCALE, SCALE, SCALE); + const F32 BRIGHTNESS = 0.9f; + gGL.color3f(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS); + mVertexBuffer->draw(LLRender::TRIANGLES, num_indices, 0); - gGL.color3f(0.4f, 0.4f, 0.4f); - glVertexPointer(3, GL_FLOAT, 0, (void *)vertices); - glNormalPointer(GL_FLOAT, 0, (void *)normals); - glDrawRangeElements(GL_TRIANGLES, 0, num_vertices-1, num_indices, GL_UNSIGNED_SHORT, (void *)indices); + gGL.popMatrix(); - gGL.popMatrix(); - glDisableClientState(GL_NORMAL_ARRAY); - - delete [] indices; - delete [] vertices; - delete [] normals; - } - return TRUE; } diff --git a/linden/indra/newview/llfloaterimagepreview.h b/linden/indra/newview/llfloaterimagepreview.h index 9d80f09..3e72736 100644 --- a/linden/indra/newview/llfloaterimagepreview.h +++ b/linden/indra/newview/llfloaterimagepreview.h @@ -41,6 +41,7 @@ class LLJoint; class LLViewerJointMesh; class LLVOAvatar; class LLTextBox; +class LLVertexBuffer; class LLImagePreviewSculpted : public LLDynamicTexture { @@ -67,6 +68,7 @@ class LLImagePreviewSculpted : public LLDynamicTexture F32 mCameraZoom; LLVector3 mCameraOffset; LLPointer mVolume; + LLPointer mVertexBuffer; }; diff --git a/linden/indra/newview/llfloaterjoystick.cpp b/linden/indra/newview/llfloaterjoystick.cpp index 172da1d..8f938ed 100644 --- a/linden/indra/newview/llfloaterjoystick.cpp +++ b/linden/indra/newview/llfloaterjoystick.cpp @@ -46,7 +46,7 @@ #include "llviewerjoystick.h" LLFloaterJoystick::LLFloaterJoystick(const LLSD& data) - : LLFloater(std::string("floater_joystick")) + : LLFloater("floater_joystick") { LLUICtrlFactory::getInstance()->buildFloater(this, "floater_joystick.xml"); center(); diff --git a/linden/indra/newview/llfloaterland.cpp b/linden/indra/newview/llfloaterland.cpp index 891cde7..a459d4d 100644 --- a/linden/indra/newview/llfloaterland.cpp +++ b/linden/indra/newview/llfloaterland.cpp @@ -1448,7 +1448,7 @@ void LLPanelLandObjects::processParcelObjectOwnersReply(LLMessageSystem *msg, vo msg->getBOOLFast(_PREHASH_Data, _PREHASH_IsGroupOwned, is_group_owned, i); msg->getS32Fast (_PREHASH_Data, _PREHASH_Count, object_count, i); msg->getBOOLFast(_PREHASH_Data, _PREHASH_OnlineStatus, is_online, i); - if(msg->getNumberOfBlocks("DataExtended")) + if(msg->has("DataExtended")) { msg->getU32("DataExtended", "TimeStamp", most_recent_time, i); } diff --git a/linden/indra/newview/llfloaterlandmark.cpp b/linden/indra/newview/llfloaterlandmark.cpp index 71e35e8..a8c08bb 100644 --- a/linden/indra/newview/llfloaterlandmark.cpp +++ b/linden/indra/newview/llfloaterlandmark.cpp @@ -34,73 +34,28 @@ #include "llfloaterlandmark.h" #include "llagent.h" -#include "llviewerimagelist.h" #include "llcheckboxctrl.h" -#include "llcombobox.h" -#include "llbutton.h" -#include "lldraghandle.h" -#include "llfocusmgr.h" -#include "llviewerimage.h" #include "llviewerparcelmgr.h" #include "llfolderview.h" #include "llinventory.h" #include "llinventorymodel.h" #include "llinventoryview.h" -#include "lllineeditor.h" -#include "llui.h" #include "llviewerinventory.h" #include "llpermissions.h" #include "llsaleinfo.h" -#include "llassetstorage.h" -#include "lltextbox.h" #include "llparcel.h" -#include "llresizehandle.h" -#include "llscrollcontainer.h" -#include "lltoolmgr.h" -#include "lltoolpipette.h" - -#include "lltool.h" -#include "llviewerwindow.h" -#include "llviewerobject.h" + +#include "llviewerwindow.h" // alertXml #include "llviewercontrol.h" -#include "llglheaders.h" #include "lluictrlfactory.h" -#include "roles_constants.h" - - - -static const S32 CLOSE_BTN_WIDTH = 100; -const S32 PIPETTE_BTN_WIDTH = 32; -static const S32 HPAD = 4; -static const S32 VPAD = 4; -static const S32 LINE = 16; -static const S32 SMALL_BTN_WIDTH = 64; -static const S32 TEX_PICKER_MIN_WIDTH = - (HPAD + - CLOSE_BTN_WIDTH + - HPAD + - CLOSE_BTN_WIDTH + - HPAD + - SMALL_BTN_WIDTH + - HPAD + - SMALL_BTN_WIDTH + - HPAD + - 30 + - RESIZE_HANDLE_WIDTH * 2); -static const S32 CLEAR_BTN_WIDTH = 50; -static const S32 TEX_PICKER_MIN_HEIGHT = 290; -static const S32 FOOTER_HEIGHT = 100; -static const S32 BORDER_PAD = HPAD; -static const S32 TEXTURE_INVENTORY_PADDING = 30; +#include "roles_constants.h" // GP_LAND_ALLOW_LANDMARK + + static const F32 CONTEXT_CONE_IN_ALPHA = 0.0f; static const F32 CONTEXT_CONE_OUT_ALPHA = 1.f; static const F32 CONTEXT_FADE_TIME = 0.08f; -//static const char CURRENT_IMAGE_NAME[] = "Current Landmark"; -//static const char WHITE_IMAGE_NAME[] = "Blank Landmark"; -//static const char NO_IMAGE_NAME[] = "None"; - LLFloaterLandmark::LLFloaterLandmark(const LLSD& data) : @@ -167,6 +122,7 @@ LLFloaterLandmark::LLFloaterLandmark(const LLSD& data) LLFloaterLandmark::~LLFloaterLandmark() { delete mSavedFolderState; + mSavedFolderState = NULL; } void LLFloaterLandmark::setActive( BOOL active ) diff --git a/linden/indra/newview/llfloaterlandmark.h b/linden/indra/newview/llfloaterlandmark.h index cf71138..27139a7 100644 --- a/linden/indra/newview/llfloaterlandmark.h +++ b/linden/indra/newview/llfloaterlandmark.h @@ -32,9 +32,7 @@ #ifndef LL_LLFLOATERLANDMARK_H #define LL_LLFLOATERLANDMARK_H -#include "llcoord.h" #include "llfloater.h" -#include "llstring.h" #include "lluictrl.h" #include "llpermissionsflags.h" diff --git a/linden/indra/newview/llfloaterpostcard.cpp b/linden/indra/newview/llfloaterpostcard.cpp index b4bcdb7..4be8145 100644 --- a/linden/indra/newview/llfloaterpostcard.cpp +++ b/linden/indra/newview/llfloaterpostcard.cpp @@ -63,6 +63,8 @@ #include "llassetuploadresponders.h" +#include //boost.regex lib + ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs ///---------------------------------------------------------------------------- @@ -180,7 +182,7 @@ void LLFloaterPostcard::draw() rect.mBottom = (S32)((F32)rect.mTop - ((F32)rect.getWidth() / ratio)); } { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gl_rect_2d(rect, LLColor4(0.f, 0.f, 0.f, 1.f)); rect.stretch(-1); } @@ -242,14 +244,16 @@ void LLFloaterPostcard::onClickSend(void* data) std::string from(self->childGetValue("from_form").asString()); std::string to(self->childGetValue("to_form").asString()); - - if (to.empty() || to.find('@') == std::string::npos) + + boost::regex emailFormat("[A-Za-z0-9.%+-_]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + + if (to.empty() || !boost::regex_match(to, emailFormat)) { gViewerWindow->alertXml("PromptRecipientEmail"); return; } - if (from.empty() || from.find('@') == std::string::npos) + if (from.empty() || !boost::regex_match(from, emailFormat)) { gViewerWindow->alertXml("PromptSelfEmail"); return; diff --git a/linden/indra/newview/llfloaterpreference.cpp b/linden/indra/newview/llfloaterpreference.cpp index 82d8cc9..b907aed 100644 --- a/linden/indra/newview/llfloaterpreference.cpp +++ b/linden/indra/newview/llfloaterpreference.cpp @@ -424,8 +424,6 @@ void LLFloaterPreference::onClickAbout(void*) // static void LLFloaterPreference::onBtnOK( void* userdata ) { - LLPanelLogin::refreshLocation( false ); - LLFloaterPreference *fp =(LLFloaterPreference *)userdata; // commit any outstanding text entry if (fp->hasFocus()) @@ -453,6 +451,8 @@ void LLFloaterPreference::onBtnOK( void* userdata ) // Show beep, pop up dialog, etc. llinfos << "Can't close preferences!" << llendl; } + + LLPanelLogin::refreshLocation( false ); } diff --git a/linden/indra/newview/llfloatersnapshot.cpp b/linden/indra/newview/llfloatersnapshot.cpp index 954bf9f..afa0785 100644 --- a/linden/indra/newview/llfloatersnapshot.cpp +++ b/linden/indra/newview/llfloatersnapshot.cpp @@ -151,7 +151,8 @@ public: void resetThumbnailImage() { mThumbnailImage = NULL ; } void drawPreviewRect(S32 offset_x, S32 offset_y) ; - static void onIdle( void* snapshot_preview ); + // Returns TRUE when snapshot generated, FALSE otherwise. + static BOOL onIdle( void* snapshot_preview ); private: LLColor4 mColor; @@ -203,6 +204,8 @@ LLSnapshotLivePreview::LLSnapshotLivePreview (const LLRect& rect) : mCurImageIndex(0), mPreviewImage(NULL), mThumbnailImage(NULL) , + mThumbnailWidth(0), + mThumbnailHeight(0), mPreviewImageEncoded(NULL), mFormattedImage(NULL), mShineCountdown(0), @@ -342,14 +345,11 @@ void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail mSnapshotDelayTimer.start(); mSnapshotDelayTimer.setTimerExpirySec(delay); } - else if(new_thumbnail) + if(new_thumbnail) { mThumbnailUpToDate = FALSE ; } - else - { - setThumbnailImageSize() ; - } + setThumbnailImageSize(); } void LLSnapshotLivePreview::setSnapshotQuality(S32 quality) @@ -417,14 +417,14 @@ void LLSnapshotLivePreview::draw() LLColor4 image_color(1.f, 1.f, 1.f, 1.f); gGL.color4fv(image_color.mV); - LLViewerImage::bindTexture(mViewerImage[mCurImageIndex]); + gGL.getTexUnit(0)->bind(mViewerImage[mCurImageIndex]); // calculate UV scale F32 uv_width = mImageScaled[mCurImageIndex] ? 1.f : llmin((F32)mWidth[mCurImageIndex] / (F32)mViewerImage[mCurImageIndex]->getWidth(), 1.f); F32 uv_height = mImageScaled[mCurImageIndex] ? 1.f : llmin((F32)mHeight[mCurImageIndex] / (F32)mViewerImage[mCurImageIndex]->getHeight(), 1.f); glPushMatrix(); { glTranslatef((F32)rect.mLeft, (F32)rect.mBottom, 0.f); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { gGL.texCoord2f(uv_width, uv_height); gGL.vertex2i(rect.getWidth(), rect.getHeight() ); @@ -486,8 +486,8 @@ void LLSnapshotLivePreview::draw() S32 y1 = 0; S32 y2 = gViewerWindow->getWindowHeight(); - LLGLSNoTexture no_texture; - gGL.begin(LLVertexBuffer::QUADS); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.begin(LLRender::QUADS); { gGL.color4f(1.f, 1.f, 1.f, 0.f); gGL.vertex2i(x1, y1); @@ -515,10 +515,10 @@ void LLSnapshotLivePreview::draw() // draw framing rectangle { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f(1.f, 1.f, 1.f, 1.f); LLRect outline_rect = mImageRect[mCurImageIndex]; - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { gGL.vertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH); gGL.vertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH); @@ -553,7 +553,7 @@ void LLSnapshotLivePreview::draw() F32 alpha = clamp_rescale(fall_interp, 0.f, 1.f, 0.8f, 0.4f); LLColor4 image_color(1.f, 1.f, 1.f, alpha); gGL.color4fv(image_color.mV); - LLViewerImage::bindTexture(mViewerImage[old_image_index]); + gGL.getTexUnit(0)->bind(mViewerImage[old_image_index]); // calculate UV scale // *FIX get this to work with old image BOOL rescale = !mImageScaled[old_image_index] && mViewerImage[mCurImageIndex].notNull(); @@ -564,7 +564,7 @@ void LLSnapshotLivePreview::draw() LLRect& rect = mImageRect[old_image_index]; glTranslatef((F32)rect.mLeft, (F32)rect.mBottom - llround(getRect().getHeight() * 2.f * (fall_interp * fall_interp)), 0.f); glRotatef(-45.f * fall_interp, 0.f, 0.f, 1.f); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { gGL.texCoord2f(uv_width, uv_height); gGL.vertex2i(rect.getWidth(), rect.getHeight() ); @@ -719,8 +719,11 @@ void LLSnapshotLivePreview::generateThumbnailImage(BOOL force_update) mThumbnailUpdateLock = FALSE ; } + +// Called often. Checks whether it's time to grab a new snapshot and if so, does it. +// Returns TRUE if new snapshot generated, FALSE otherwise. //static -void LLSnapshotLivePreview::onIdle( void* snapshot_preview ) +BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview ) { LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)snapshot_preview; @@ -733,7 +736,10 @@ void LLSnapshotLivePreview::onIdle( void* snapshot_preview ) previewp->mCameraRot = new_camera_rot; // request a new snapshot whenever the camera moves, with a time delay BOOL autosnap = gSavedSettings.getBOOL("AutoSnapshot"); - previewp->updateSnapshot(autosnap, FALSE, autosnap ? AUTO_SNAPSHOT_TIME_DELAY : 0.f); + previewp->updateSnapshot( + autosnap, // whether a new snapshot is needed or merely invalidate the existing one + FALSE, // or if 1st arg is false, whether to produce a new thumbnail image. + autosnap ? AUTO_SNAPSHOT_TIME_DELAY : 0.f); // shutter delay if 1st arg is true. } // see if it's time yet to snap the shot and bomb out otherwise. @@ -742,7 +748,7 @@ void LLSnapshotLivePreview::onIdle( void* snapshot_preview ) && !LLToolCamera::getInstance()->hasMouseCapture(); // don't take snapshots while ALT-zoom active if ( ! previewp->mSnapshotActive) { - return; + return FALSE; } // time to produce a snapshot @@ -819,6 +825,7 @@ void LLSnapshotLivePreview::onIdle( void* snapshot_preview ) } if (previewp->mFormattedImage->encode(previewp->mPreviewImage, 0)) { + previewp->mDataSize = previewp->mFormattedImage->getDataSize(); // special case BMP to copy instead of decode otherwise decode will crash. if(format == LLFloaterSnapshot::SNAPSHOT_FORMAT_BMP) { @@ -826,7 +833,6 @@ void LLSnapshotLivePreview::onIdle( void* snapshot_preview ) } else { - previewp->mDataSize = previewp->mFormattedImage->getDataSize(); previewp->mFormattedImage->decode(previewp->mPreviewImageEncoded, 0); } } @@ -855,7 +861,7 @@ void LLSnapshotLivePreview::onIdle( void* snapshot_preview ) previewp->mViewerImage[previewp->mCurImageIndex] = new LLImageGL(scaled, FALSE); previewp->mViewerImage[previewp->mCurImageIndex]->setMipFilterNearest(previewp->getSnapshotType() != SNAPSHOT_TEXTURE); - LLViewerImage::bindTexture(previewp->mViewerImage[previewp->mCurImageIndex]); + gGL.getTexUnit(0)->bind(previewp->mViewerImage[previewp->mCurImageIndex]); previewp->mViewerImage[previewp->mCurImageIndex]->setClamp(TRUE, TRUE); previewp->mSnapshotUpToDate = TRUE; @@ -875,6 +881,8 @@ void LLSnapshotLivePreview::onIdle( void* snapshot_preview ) { previewp->generateThumbnailImage() ; } + + return TRUE; } void LLSnapshotLivePreview::setSize(S32 w, S32 h) @@ -952,7 +960,7 @@ void LLSnapshotLivePreview::saveTexture() llwarns << "Error encoding snapshot" << llendl; } - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_SNAPSHOT_COUNT ); + LLViewerStats::getInstance()->incStat(LLViewerStats::ST_SNAPSHOT_COUNT ); } BOOL LLSnapshotLivePreview::saveLocal() @@ -996,7 +1004,8 @@ public: static void onClickKeepOpenCheck(LLUICtrl *ctrl, void* data); static void onClickKeepAspectCheck(LLUICtrl *ctrl, void* data); static void onCommitQuality(LLUICtrl* ctrl, void* data); - static void onCommitResolution(LLUICtrl* ctrl, void* data); + static void onCommitResolution(LLUICtrl* ctrl, void* data) { updateResolution(ctrl, data); } + static void updateResolution(LLUICtrl* ctrl, void* data, BOOL do_update = TRUE); static void onCommitFreezeFrame(LLUICtrl* ctrl, void* data); static void onCommitLayerTypes(LLUICtrl* ctrl, void*data); static void onCommitSnapshotType(LLUICtrl* ctrl, void* data); @@ -1093,11 +1102,8 @@ LLViewerWindow::ESnapshotType LLFloaterSnapshot::Impl::getLayerType(LLFloaterSna void LLFloaterSnapshot::Impl::setResolution(LLFloaterSnapshot* floater, const std::string& comboname) { LLComboBox* combo = floater->getChild(comboname); - if (combo) - { combo->setVisible(TRUE); - onCommitResolution(combo, floater); - } + updateResolution(combo, floater, FALSE); // to sync spinners with combo } //static @@ -1107,22 +1113,18 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) S32 delta_height = gSavedSettings.getBOOL("AdvanceSnapshot") ? 0 : floaterp->getUIWinHeightShort() - floaterp->getUIWinHeightLong() ; - LLComboBox* combo; if(!gSavedSettings.getBOOL("AdvanceSnapshot")) //set to original window resolution { - previewp->mKeepAspectRatio = TRUE ; + previewp->mKeepAspectRatio = TRUE; - combo = floaterp->getChild("postcard_size_combo"); - combo->setCurrentByIndex(0) ; - gSavedSettings.setS32("SnapshotPostcardLastResolution", 0) ; + floaterp->getChild("postcard_size_combo")->setCurrentByIndex(0); + gSavedSettings.setS32("SnapshotPostcardLastResolution", 0); - combo = floaterp->getChild("texture_size_combo"); - combo->setCurrentByIndex(0) ; - gSavedSettings.setS32("SnapshotTextureLastResolution", 0) ; + floaterp->getChild("texture_size_combo")->setCurrentByIndex(0); + gSavedSettings.setS32("SnapshotTextureLastResolution", 0); - combo = floaterp->getChild("local_size_combo"); - combo->setCurrentByIndex(0) ; - gSavedSettings.setS32("SnapshotLocalLastResolution", 0) ; + floaterp->getChild("local_size_combo")->setCurrentByIndex(0); + gSavedSettings.setS32("SnapshotLocalLastResolution", 0); LLSnapshotLivePreview* previewp = getPreviewView(floaterp); previewp->setSize(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()); @@ -1187,7 +1189,11 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) } } - +// This is the main function that keeps all the GUI controls in sync with the saved settings. +// It should be called anytime a setting is changed that could affect the controls. +// No other methods should be changing any of the controls directly except for helpers called by this method. +// The basic pattern for programmatically changing the GUI settings is to first set the +// appropriate saved settings and then call this method to sync the GUI with them. // static void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) { @@ -1201,15 +1207,10 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) floater->childSetVisible("texture_size_combo", FALSE); floater->childSetVisible("local_size_combo", FALSE); - LLComboBox* combo; - combo = floater->getChild("postcard_size_combo"); - if (combo) combo->selectNthItem(gSavedSettings.getS32("SnapshotPostcardLastResolution")); - combo = floater->getChild("texture_size_combo"); - if (combo) combo->selectNthItem(gSavedSettings.getS32("SnapshotTextureLastResolution")); - combo = floater->getChild("local_size_combo"); - if (combo) combo->selectNthItem(gSavedSettings.getS32("SnapshotLocalLastResolution")); - combo = floater->getChild("local_format_combo"); - if (combo) combo->selectNthItem(gSavedSettings.getS32("SnapshotFormat")); + floater->getChild("postcard_size_combo")->selectNthItem(gSavedSettings.getS32("SnapshotPostcardLastResolution")); + floater->getChild("texture_size_combo")->selectNthItem(gSavedSettings.getS32("SnapshotTextureLastResolution")); + floater->getChild("local_size_combo")->selectNthItem(gSavedSettings.getS32("SnapshotLocalLastResolution")); + floater->getChild("local_format_combo")->selectNthItem(gSavedSettings.getS32("SnapshotFormat")); floater->childSetVisible("upload_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_TEXTURE); floater->childSetVisible("send_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD); @@ -1240,6 +1241,23 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) floater->childSetVisible("auto_snapshot_check", is_advance); floater->childSetVisible("image_quality_slider", is_advance && show_slider); + LLSnapshotLivePreview* previewp = getPreviewView(floater); + BOOL got_bytes = previewp && previewp->getDataSize() > 0; + BOOL got_snap = previewp->getSnapshotUpToDate(); + + floater->childSetEnabled("send_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD && got_bytes && got_snap && previewp->getDataSize() <= MAX_POSTCARD_DATASIZE); + floater->childSetEnabled("upload_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_TEXTURE && got_bytes && got_snap); + floater->childSetEnabled("save_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL && got_bytes && got_snap); + + LLLocale locale(LLLocale::USER_LOCALE); + std::string bytes_string; + LLResMgr::getInstance()->getIntegerString(bytes_string, (previewp->getDataSize()) >> 10 ); + floater->childSetTextArg("file_size_label", "[SIZE]", got_snap ? bytes_string : got_bytes ? floater->getString("unknown") : std::string("???")); + floater->childSetColor("file_size_label", + shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD + && got_bytes + && previewp->getDataSize() > MAX_POSTCARD_DATASIZE ? LLColor4::red : gColors.getColor( "LabelTextColor" )); + switch(shot_type) { case LLSnapshotLivePreview::SNAPSHOT_POSTCARD: @@ -1270,7 +1288,6 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) updateResolutionTextEntry(floater); - LLSnapshotLivePreview* previewp = getPreviewView(floater); if (previewp) { previewp->setSnapshotType(shot_type); @@ -1389,6 +1406,7 @@ void LLFloaterSnapshot::Impl::onClickAutoSnap(LLUICtrl *ctrl, void* data) if (view) { checkAutoSnapshot(getPreviewView(view)); + updateControls(view); } } @@ -1401,9 +1419,12 @@ void LLFloaterSnapshot::Impl::onClickMore(void* data) { view->translate( 0, view->getUIWinHeightShort() - view->getUIWinHeightLong() ); view->reshape(view->getRect().getWidth(), view->getUIWinHeightLong()); - updateControls(view) ; updateLayout(view) ; + if(getPreviewView(view)) + { + getPreviewView(view)->setThumbnailImageSize() ; + } } } void LLFloaterSnapshot::Impl::onClickLess(void* data) @@ -1415,10 +1436,8 @@ void LLFloaterSnapshot::Impl::onClickLess(void* data) { view->translate( 0, view->getUIWinHeightLong() - view->getUIWinHeightShort() ); view->reshape(view->getRect().getWidth(), view->getUIWinHeightShort()); - updateControls(view) ; updateLayout(view) ; - if(getPreviewView(view)) { getPreviewView(view)->setThumbnailImageSize() ; @@ -1436,6 +1455,7 @@ void LLFloaterSnapshot::Impl::onClickUICheck(LLUICtrl *ctrl, void* data) if (view) { checkAutoSnapshot(getPreviewView(view), TRUE); + updateControls(view); } } @@ -1449,6 +1469,7 @@ void LLFloaterSnapshot::Impl::onClickHUDCheck(LLUICtrl *ctrl, void* data) if (view) { checkAutoSnapshot(getPreviewView(view), TRUE); + updateControls(view); } } @@ -1482,6 +1503,7 @@ void LLFloaterSnapshot::Impl::onClickKeepAspectCheck(LLUICtrl* ctrl, void* data) } previewp->setSize(w, h) ; + previewp->updateSnapshot(FALSE, TRUE); checkAutoSnapshot(previewp, TRUE); } } @@ -1531,7 +1553,7 @@ void LLFloaterSnapshot::Impl::checkAspectRatio(LLFloaterSnapshot *view, S32 inde } #endif - if(!index) //current window size + if(0 == index) //current window size { sAspectRatioCheckOff = TRUE ; view->childSetEnabled("keep_aspect_check", FALSE) ; @@ -1568,8 +1590,27 @@ void LLFloaterSnapshot::Impl::checkAspectRatio(LLFloaterSnapshot *view, S32 inde return ; } +static std::string lastSnapshotWidthName() +{ + switch(gSavedSettings.getS32("LastSnapshotType")) + { + case LLSnapshotLivePreview::SNAPSHOT_POSTCARD: return "LastSnapshotToEmailWidth"; + case LLSnapshotLivePreview::SNAPSHOT_TEXTURE: return "LastSnapshotToInventoryWidth"; + default: return "LastSnapshotToDiskWidth"; + } +} +static std::string lastSnapshotHeightName() +{ + switch(gSavedSettings.getS32("LastSnapshotType")) + { + case LLSnapshotLivePreview::SNAPSHOT_POSTCARD: return "LastSnapshotToEmailHeight"; + case LLSnapshotLivePreview::SNAPSHOT_TEXTURE: return "LastSnapshotToInventoryHeight"; + default: return "LastSnapshotToDiskHeight"; + } +} + // static -void LLFloaterSnapshot::Impl::onCommitResolution(LLUICtrl* ctrl, void* data) +void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL do_update) { LLComboBox* combobox = (LLComboBox*)ctrl; LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; @@ -1580,13 +1621,9 @@ void LLFloaterSnapshot::Impl::onCommitResolution(LLUICtrl* ctrl, void* data) } // save off all selected resolution values - LLComboBox* combo; - combo = view->getChild("postcard_size_combo"); - gSavedSettings.setS32("SnapshotPostcardLastResolution", combo->getCurrentIndex()); - combo = view->getChild("texture_size_combo"); - gSavedSettings.setS32("SnapshotTextureLastResolution", combo->getCurrentIndex()); - combo = view->getChild("local_size_combo"); - gSavedSettings.setS32("SnapshotLocalLastResolution", combo->getCurrentIndex()); + gSavedSettings.setS32("SnapshotPostcardLastResolution", view->getChild("postcard_size_combo")->getCurrentIndex()); + gSavedSettings.setS32("SnapshotTextureLastResolution", view->getChild("texture_size_combo")->getCurrentIndex()); + gSavedSettings.setS32("SnapshotLocalLastResolution", view->getChild("local_size_combo")->getCurrentIndex()); std::string sdstring = combobox->getSelectedValue(); LLSD sdres; @@ -1601,15 +1638,17 @@ void LLFloaterSnapshot::Impl::onCommitResolution(LLUICtrl* ctrl, void* data) { if (width == 0 || height == 0) { + // take resolution from current window size previewp->setSize(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()); } else if (width == -1 || height == -1) { // load last custom value - previewp->setSize(gSavedSettings.getS32("LastSnapshotWidth"), gSavedSettings.getS32("LastSnapshotHeight")); + previewp->setSize(gSavedSettings.getS32(lastSnapshotWidthName()), gSavedSettings.getS32(lastSnapshotHeightName())); } else { + // use the resolution from the selected pre-canned drop-down choice previewp->setSize(width, height); } @@ -1623,10 +1662,18 @@ void LLFloaterSnapshot::Impl::onCommitResolution(LLUICtrl* ctrl, void* data) } previewp->setSize(width, height); + if(view->childGetValue("snapshot_width").asInteger() != width || view->childGetValue("snapshot_height").asInteger() != height) + { view->childSetValue("snapshot_width", width); view->childSetValue("snapshot_height", height); // hide old preview as the aspect ratio could be wrong checkAutoSnapshot(previewp, FALSE); + getPreviewView(view)->updateSnapshot(FALSE, TRUE); + if(do_update) + { + updateControls(view); + } + } } } @@ -1675,17 +1722,28 @@ void LLFloaterSnapshot::Impl::onCommitSnapshotFormat(LLUICtrl* ctrl, void* data) - +// Sets the named size combo to "custom" mode. // static void LLFloaterSnapshot::Impl::comboSetCustom(LLFloaterSnapshot* floater, const std::string& comboname) { LLComboBox* combo = floater->getChild(comboname); - if (combo) - { - combo->setCurrentByIndex(combo->getItemCount() - 1); - checkAspectRatio(floater, -1);//combo->getCurrentIndex()) ; + combo->setCurrentByIndex(combo->getItemCount() - 1); // "custom" is always the last index + + if(comboname == "postcard_size_combo") + { + gSavedSettings.setS32("SnapshotPostcardLastResolution", combo->getCurrentIndex()); + } + else if(comboname == "texture_size_combo") + { + gSavedSettings.setS32("SnapshotTextureLastResolution", combo->getCurrentIndex()); } + else if(comboname == "local_size_combo") + { + gSavedSettings.setS32("SnapshotLocalLastResolution", combo->getCurrentIndex()); + } + + checkAspectRatio(floater, -1); // -1 means custom } @@ -1711,8 +1769,8 @@ BOOL LLFloaterSnapshot::Impl::checkImageSize(LLSnapshotLivePreview* previewp, S3 //round to nearest power of 2 based on the direction of movement // i.e. higher power of two if increasing texture resolution - if(gSavedSettings.getS32("LastSnapshotWidth") < width || - gSavedSettings.getS32("LastSnapshotHeight") < height) + if(gSavedSettings.getS32("LastSnapshotToInventoryWidth") < width || + gSavedSettings.getS32("LastSnapshotToInventoryHeight") < height) { // Up arrow pressed width = get_next_power_two(width, MAX_TEXTURE_SIZE) ; @@ -1772,20 +1830,10 @@ BOOL LLFloaterSnapshot::Impl::checkImageSize(LLSnapshotLivePreview* previewp, S3 //static void LLFloaterSnapshot::Impl::resetSnapshotSizeOnUI(LLFloaterSnapshot *view, S32 width, S32 height) { - LLSpinCtrl *sctrl = view->getChild("snapshot_width") ; - if(sctrl) - { - sctrl->forceSetValue(width) ; - } - - sctrl = view->getChild("snapshot_height") ; - if(sctrl) - { - sctrl->forceSetValue(height) ; - } - - gSavedSettings.setS32("LastSnapshotWidth", width); - gSavedSettings.setS32("LastSnapshotHeight", height); + view->getChild("snapshot_width")->forceSetValue(width); + view->getChild("snapshot_height")->forceSetValue(height); + gSavedSettings.setS32(lastSnapshotWidthName(), width); + gSavedSettings.setS32(lastSnapshotHeightName(), height); } //static @@ -1839,15 +1887,17 @@ void LLFloaterSnapshot::Impl::onCommitCustomResolution(LLUICtrl *ctrl, void* dat previewp->setSize(w,h); checkAutoSnapshot(previewp, FALSE); + previewp->updateSnapshot(FALSE, TRUE); comboSetCustom(view, "postcard_size_combo"); comboSetCustom(view, "texture_size_combo"); comboSetCustom(view, "local_size_combo"); } } - gSavedSettings.setS32("LastSnapshotWidth", w); - gSavedSettings.setS32("LastSnapshotHeight", h); + gSavedSettings.setS32(lastSnapshotWidthName(), w); + gSavedSettings.setS32(lastSnapshotHeightName(), h); + updateControls(view); } } @@ -1883,6 +1933,7 @@ LLFloaterSnapshot::~LLFloaterSnapshot() delete &impl; } + BOOL LLFloaterSnapshot::postBuild() { childSetCommitCallback("snapshot_type_radio", Impl::onCommitSnapshotType, this); @@ -1890,11 +1941,6 @@ BOOL LLFloaterSnapshot::postBuild() childSetAction("new_snapshot_btn", Impl::onClickNewSnapshot, this); - childSetValue("auto_snapshot_check", gSavedSettings.getBOOL("AutoSnapshot")); - childSetCommitCallback("auto_snapshot_check", Impl::onClickAutoSnap, this); - - //childSetValue("advance_snapshot_check", gSavedSettings.getBOOL("AdvanceSnapshot")); - //childSetCommitCallback("advance_snapshot_check", Impl::onClickAdvanceSnap, this); childSetAction("more_btn", Impl::onClickMore, this); childSetAction("less_btn", Impl::onClickLess, this); @@ -1907,10 +1953,10 @@ BOOL LLFloaterSnapshot::postBuild() childSetValue("image_quality_slider", gSavedSettings.getS32("SnapshotQuality")); childSetCommitCallback("snapshot_width", Impl::onCommitCustomResolution, this); - childSetCommitCallback("snapshot_height", Impl::onCommitCustomResolution, this); childSetCommitCallback("ui_check", Impl::onClickUICheck, this); + childSetValue("ui_check", gSavedSettings.getBOOL("RenderUIInSnapshot")); childSetCommitCallback("hud_check", Impl::onClickHUDCheck, this); childSetValue("hud_check", gSavedSettings.getBOOL("RenderHUDInSnapshot")); @@ -1925,12 +1971,15 @@ BOOL LLFloaterSnapshot::postBuild() childSetValue("layer_types", "colors"); childSetEnabled("layer_types", FALSE); - childSetValue("snapshot_width", gSavedSettings.getS32("LastSnapshotWidth")); - childSetValue("snapshot_height", gSavedSettings.getS32("LastSnapshotHeight")); + childSetValue("snapshot_width", gSavedSettings.getS32(lastSnapshotWidthName())); + childSetValue("snapshot_height", gSavedSettings.getS32(lastSnapshotHeightName())); childSetValue("freeze_frame_check", gSavedSettings.getBOOL("UseFreezeFrame")); childSetCommitCallback("freeze_frame_check", Impl::onCommitFreezeFrame, this); + childSetValue("auto_snapshot_check", gSavedSettings.getBOOL("AutoSnapshot")); + childSetCommitCallback("auto_snapshot_check", Impl::onClickAutoSnap, this); + childSetCommitCallback("postcard_size_combo", Impl::onCommitResolution, this); childSetCommitCallback("texture_size_combo", Impl::onCommitResolution, this); childSetCommitCallback("local_size_combo", Impl::onCommitResolution, this); @@ -1960,53 +2009,6 @@ void LLFloaterSnapshot::draw() return; } - if(!isMinimized()) - { - if (previewp && previewp->getDataSize() > 0) - { - LLLocale locale(LLLocale::USER_LOCALE); - - std::string bytes_string; - if (previewp->getSnapshotType() == LLSnapshotLivePreview::SNAPSHOT_POSTCARD && - previewp->getDataSize() > MAX_POSTCARD_DATASIZE) - { - childSetColor("file_size_label", LLColor4::red); - childSetEnabled("send_btn", FALSE); - } - else - { - childSetColor("file_size_label", gColors.getColor( "LabelTextColor" )); - childSetEnabled("send_btn", previewp->getSnapshotUpToDate()); - } - - if (previewp->getSnapshotUpToDate()) - { - std::string bytes_string; - LLResMgr::getInstance()->getIntegerString(bytes_string, (previewp->getDataSize()) >> 10 ); - childSetTextArg("file_size_label", "[SIZE]", bytes_string); - } - else - { - childSetTextArg("file_size_label", "[SIZE]", getString("unknown")); - childSetColor("file_size_label", gColors.getColor( "LabelTextColor" )); - } - childSetEnabled("upload_btn", previewp->getSnapshotUpToDate()); - childSetEnabled("save_btn", previewp->getSnapshotUpToDate()); - - } - else - { - childSetTextArg("file_size_label", "[SIZE]", std::string("???")); - childSetEnabled("upload_btn", FALSE); - childSetEnabled("send_btn", FALSE); - childSetEnabled("save_btn", FALSE); - } - - BOOL ui_in_snapshot = gSavedSettings.getBOOL("RenderUIInSnapshot"); - childSetValue("ui_check", ui_in_snapshot); - childSetToolTip("ui_check", std::string("If selected shows the UI in the snapshot")); - } - LLFloater::draw(); if (previewp) @@ -2071,10 +2073,15 @@ void LLFloaterSnapshot::hide(void*) //static void LLFloaterSnapshot::update() { + BOOL changed = FALSE; for (std::set::iterator iter = LLSnapshotLivePreview::sList.begin(); iter != LLSnapshotLivePreview::sList.end(); ++iter) { - LLSnapshotLivePreview::onIdle(*iter); + changed |= LLSnapshotLivePreview::onIdle(*iter); + } + if(changed) + { + sInstance->impl.updateControls(sInstance); } } diff --git a/linden/indra/newview/llfloatertopobjects.cpp b/linden/indra/newview/llfloatertopobjects.cpp index ada5c68..96492e8 100644 --- a/linden/indra/newview/llfloatertopobjects.cpp +++ b/linden/indra/newview/llfloatertopobjects.cpp @@ -180,7 +180,7 @@ void LLFloaterTopObjects::handleReply(LLMessageSystem *msg, void** data) msg->getF32Fast(_PREHASH_ReportData, _PREHASH_Score, score, block); msg->getStringFast(_PREHASH_ReportData, _PREHASH_TaskName, name_buf, block); msg->getStringFast(_PREHASH_ReportData, _PREHASH_OwnerName, owner_buf, block); - if(msg->getNumberOfBlocks("DataExtended")) + if(msg->has("DataExtended")) { have_extended_data = true; msg->getU32("DataExtended", "TimeStamp", time_stamp, block); diff --git a/linden/indra/newview/llfolderview.cpp b/linden/indra/newview/llfolderview.cpp index 8cefd5b..932addb 100644 --- a/linden/indra/newview/llfolderview.cpp +++ b/linden/indra/newview/llfolderview.cpp @@ -821,7 +821,7 @@ void LLFolderViewItem::draw() // mShowSingleSelection is FALSE if( mIsSelected ) { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLColor4 bg_color = sHighlightBgColor; //const S32 TRAILING_PAD = 5; // It just looks better with this. if (!mIsCurSelection) @@ -876,7 +876,7 @@ void LLFolderViewItem::draw() } if (mDragAndDropTarget) { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gl_rect_2d( 0, getRect().getHeight(), diff --git a/linden/indra/newview/llframestatview.cpp b/linden/indra/newview/llframestatview.cpp index 752c6c4..a7d08cf 100644 --- a/linden/indra/newview/llframestatview.cpp +++ b/linden/indra/newview/llframestatview.cpp @@ -98,7 +98,7 @@ void LLFrameStatView::draw() S32 j; LLStat *statp; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); statp = mStats[0]; if (!statp) @@ -159,7 +159,7 @@ void LLFrameStatView::draw() for (i = 0; i < mNumStats; i++) { // Draw the color key. - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gl_rect_2d(left, top - 2, left + 10, top - 12, mColors[i]); left = left + 15; @@ -203,7 +203,7 @@ void LLFrameStatView::draw() bottom = bottom - 4; for (tick_value = 0; tick_value <= 100; tick_value += 20) { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); left = 10 + llfloor(tick_value*(total_width/100.f)); right = left + 1; gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 1.f, 1.f, 0.2f)); @@ -253,7 +253,7 @@ void LLFrameStatView::draw() bottom = top - graph_height - 4; for (tick_value = 0; tick_value <= 100; tick_value += 20) { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); left = 10 + llfloor(tick_value*(total_width/100.f)); right = left + 1; gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 1.f, 1.f, 0.25f)); @@ -278,7 +278,7 @@ void LLFrameStatView::draw() bottom = top - graph_height - 4; for (tick_value = 0; tick_value <= mTotalTime; tick_value += mLabelSpacing) { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); left = 10 + llfloor(tick_value*time_scale); right = left + 1; gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 1.f, 1.f, 0.25f)); diff --git a/linden/indra/newview/llglsandbox.cpp b/linden/indra/newview/llglsandbox.cpp index 45f674d..c5a626f 100644 --- a/linden/indra/newview/llglsandbox.cpp +++ b/linden/indra/newview/llglsandbox.cpp @@ -142,7 +142,7 @@ void LLAgent::renderAutoPilotTarget() gGL.pushMatrix(); // not textured - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // lovely green glColor4f(0.f, 1.f, 1.f, 1.f); @@ -355,10 +355,11 @@ void LLCompass::draw() if (mBkgndTexture) { - mBkgndTexture->bind(); + gGL.getTexUnit(0)->bind(mBkgndTexture.get()); + gGL.color4f(1.0f, 1.0f, 1.0f, 1.0f); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); gGL.texCoord2f(1.f, 1.f); gGL.vertex2i(width, height); @@ -381,10 +382,10 @@ void LLCompass::draw() if (mTexture) { - mTexture->bind(); + gGL.getTexUnit(0)->bind(mTexture.get()); gGL.color4f(1.0f, 1.0f, 1.0f, 1.0f); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); gGL.texCoord2f(1.f, 1.f); gGL.vertex2i(width, height); @@ -426,9 +427,9 @@ void LLHorizontalCompass::draw() F32 left = center - COMPASS_RANGE; F32 right = center + COMPASS_RANGE; - mTexture->bind(); + gGL.getTexUnit(0)->bind(mTexture.get()); gGL.color4f(1.0f, 1.0f, 1.0f, 1.0f ); - gGL.begin( LLVertexBuffer::QUADS ); + gGL.begin( LLRender::QUADS ); gGL.texCoord2f(right, 1.f); gGL.vertex2i(width, height); @@ -447,7 +448,7 @@ void LLHorizontalCompass::draw() // Draw the focus line { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4fv( mFocusColor.mV ); gl_line_2d( half_width, 0, half_width, height ); } @@ -465,7 +466,7 @@ void LLWind::renderVectors() F32 region_width_meters = LLWorld::getInstance()->getRegionWidthInMeters(); - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.pushMatrix(); LLVector3 origin_agent; origin_agent = gAgent.getPosAgentFromGlobal(mOriginGlobal); @@ -479,11 +480,11 @@ void LLWind::renderVectors() gGL.pushMatrix(); gGL.translatef((F32)i * region_width_meters/mSize, (F32)j * region_width_meters/mSize, 0.0); gGL.color3f(0,1,0); - gGL.begin(LLVertexBuffer::POINTS); + gGL.begin(LLRender::POINTS); gGL.vertex3f(0,0,0); gGL.end(); gGL.color3f(1,0,0); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); gGL.vertex3f(x * 0.1f, y * 0.1f ,0.f); gGL.vertex3f(x, y, 0.f); gGL.end(); @@ -501,7 +502,7 @@ void LLViewerParcelMgr::renderRect(const LLVector3d &west_south_bottom_global, const LLVector3d &east_north_top_global ) { LLGLSUIDefault gls_ui; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest gls_depth(GL_TRUE); LLVector3 west_south_bottom_agent = gAgent.getPosAgentFromGlobal(west_south_bottom_global); @@ -532,7 +533,7 @@ void LLViewerParcelMgr::renderRect(const LLVector3d &west_south_bottom_global, gGL.color4f(1.f, 1.f, 0.f, 1.f); // Cheat and give this the same pick-name as land - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); gGL.vertex3f(west, north, nw_bottom); gGL.vertex3f(west, north, nw_top); @@ -549,7 +550,7 @@ void LLViewerParcelMgr::renderRect(const LLVector3d &west_south_bottom_global, gGL.end(); gGL.color4f(1.f, 1.f, 0.f, 0.2f); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); gGL.vertex3f(west, north, nw_bottom); gGL.vertex3f(west, north, nw_top); @@ -609,14 +610,14 @@ void LLViewerParcelMgr::renderParcel(LLParcel* parcel ) F32 ne_top = ne_bottom + POST_HEIGHT; F32 nw_top = nw_bottom + POST_HEIGHT; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest gls_depth(GL_TRUE); LLUI::setLineWidth(2.f); gGL.color4f(0.f, 1.f, 1.f, 1.f); // Cheat and give this the same pick-name as land - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); gGL.vertex3f(west, north, nw_bottom); gGL.vertex3f(west, north, nw_top); @@ -633,7 +634,7 @@ void LLViewerParcelMgr::renderParcel(LLParcel* parcel ) gGL.end(); gGL.color4f(0.f, 1.f, 1.f, 0.2f); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); gGL.vertex3f(west, north, nw_bottom); gGL.vertex3f(west, north, nw_top); @@ -759,7 +760,7 @@ void LLViewerParcelMgr::renderHighlightSegments(const U8* segments, LLViewerRegi bool has_segments = false; LLGLSUIDefault gls_ui; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest gls_depth(GL_TRUE); gGL.color4f(1.f, 1.f, 0.f, 0.2f); @@ -786,7 +787,7 @@ void LLViewerParcelMgr::renderHighlightSegments(const U8* segments, LLViewerRegi if (!has_segments) { has_segments = true; - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); } renderOneSegment(x1, y1, x2, y2, PARCEL_POST_HEIGHT, SOUTH_MASK, regionp); } @@ -802,7 +803,7 @@ void LLViewerParcelMgr::renderHighlightSegments(const U8* segments, LLViewerRegi if (!has_segments) { has_segments = true; - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); } renderOneSegment(x1, y1, x2, y2, PARCEL_POST_HEIGHT, WEST_MASK, regionp); } @@ -850,14 +851,14 @@ void LLViewerParcelMgr::renderCollisionSegments(U8* segments, BOOL use_pass, LLV if (use_pass && (mCollisionBanned == BA_NOT_ON_LIST)) { - LLViewerImage::bindTexture(mPassImage); + gGL.getTexUnit(0)->bind(mPassImage); } else { - LLViewerImage::bindTexture(mBlockedImage); + gGL.getTexUnit(0)->bind(mBlockedImage); } - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); for (y = 0; y < STRIDE; y++) { @@ -1011,10 +1012,10 @@ void LLViewerObjectList::renderObjectBeacons() LLGLSUIDefault gls_ui; { - LLGLSNoTexture gls_ui_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); S32 last_line_width = -1; - // gGL.begin(LLVertexBuffer::LINES); // Always happens in (line_width != last_line_width) + // gGL.begin(LLRender::LINES); // Always happens in (line_width != last_line_width) for (S32 i = 0; i < mDebugBeacons.count(); i++) { @@ -1031,7 +1032,7 @@ void LLViewerObjectList::renderObjectBeacons() } glLineWidth( (F32)line_width ); last_line_width = line_width; - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); } const LLVector3 &thisline = debug_beacon.mPositionAgent; @@ -1049,11 +1050,11 @@ void LLViewerObjectList::renderObjectBeacons() } { - LLGLSNoTexture gls_ui_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest gls_depth(GL_TRUE); S32 last_line_width = -1; - // gGL.begin(LLVertexBuffer::LINES); // Always happens in (line_width != last_line_width) + // gGL.begin(LLRender::LINES); // Always happens in (line_width != last_line_width) for (S32 i = 0; i < mDebugBeacons.count(); i++) { @@ -1069,7 +1070,7 @@ void LLViewerObjectList::renderObjectBeacons() } glLineWidth( (F32)line_width ); last_line_width = line_width; - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); } const LLVector3 &thisline = debug_beacon.mPositionAgent; diff --git a/linden/indra/newview/llgroupmgr.cpp b/linden/indra/newview/llgroupmgr.cpp index 30b7cbd..35d408b 100644 --- a/linden/indra/newview/llgroupmgr.cpp +++ b/linden/indra/newview/llgroupmgr.cpp @@ -52,6 +52,7 @@ #include "llfloaterdirectory.h" #include "llfloatergroupinfo.h" #include "lluictrlfactory.h" +#include const U32 MAX_CACHED_GROUPS = 10; @@ -791,6 +792,20 @@ LLGroupMgrGroupData* LLGroupMgr::getGroupData(const LLUUID& id) return NULL; } +// Helper function for LLGroupMgr::processGroupMembersReply +// This reformats date strings from MM/DD/YYYY to YYYY/MM/DD ( e.g. 1/27/2008 -> 2008/1/27 ) +// so that the sorter can sort by year before month before day. +static void formatDateString(std::string &date_string) +{ + using namespace boost; + cmatch result; + const regex expression("([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})"); + if (regex_match(date_string.c_str(), result, expression)) + { + date_string = result[3]+"/"+result[1]+"/"+result[2]; + } +} + // static void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data) { @@ -840,6 +855,8 @@ void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data) if (member_id.notNull()) { + formatDateString(online_status); // reformat for sorting, e.g. 12/25/2008 -> 2008/12/25 + //llinfos << "Member " << member_id << " has powers " << std::hex << agent_powers << std::dec << llendl; LLGroupMemberData* newdata = new LLGroupMemberData(member_id, contribution, diff --git a/linden/indra/newview/llhomelocationresponder.cpp b/linden/indra/newview/llhomelocationresponder.cpp new file mode 100644 index 0000000..9b69310 --- /dev/null +++ b/linden/indra/newview/llhomelocationresponder.cpp @@ -0,0 +1,108 @@ +/** + * @file llhomelocationresponder.cpp + * @author Meadhbh Hamrick + * @brief Processes responses to the HomeLocation CapReq + * + * $LicenseInfo:firstyear=2008&license=viewergpl$ + * + * Copyright (c) 2008, 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$ + */ + +/* File Inclusions */ +#include "llviewerprecompiledheaders.h" + +#include "llhomelocationresponder.h" +#include "llsdutil.h" +#include "llagent.h" +#include "llviewerregion.h" + +void LLHomeLocationResponder::result( const LLSD& content ) +{ + LLVector3 agent_pos; + bool error = true; + + do { + + // was the call to /agent//home-location successful? + // If not, we keep error set to true + if( ! content.has("success") ) + { + break; + } + + if( 0 != strncmp("true", content["success"].asString().c_str(), 4 ) ) + { + break; + } + + // did the simulator return a "justified" home location? + // If no, we keep error set to true + if( ! content.has( "HomeLocation" ) ) + { + break; + } + + if( ! content["HomeLocation"].has("LocationPos") ) + { + break; + } + + if( ! content["HomeLocation"]["LocationPos"].has("X") ) + { + break; + } + + agent_pos.mV[VX] = content["HomeLocation"]["LocationPos"]["X"].asInteger(); + + if( ! content["HomeLocation"]["LocationPos"].has("Y") ) + { + break; + } + + agent_pos.mV[VY] = content["HomeLocation"]["LocationPos"]["Y"].asInteger(); + + if( ! content["HomeLocation"]["LocationPos"].has("Z") ) + { + break; + } + + agent_pos.mV[VZ] = content["HomeLocation"]["LocationPos"]["Z"].asInteger(); + + error = false; + } while( 0 ); + + if( ! error ) + { + llinfos << "setting home position" << llendl; + + LLViewerRegion *viewer_region = gAgent.getRegion(); + gAgent.setHomePosRegion( viewer_region->getHandle(), agent_pos ); + } +} + +void LLHomeLocationResponder::error( const LLSD& content ) +{ + llinfos << "received error(" << ll_pretty_print_sd( content ) << ")" << llendl; +} diff --git a/linden/indra/newview/llhomelocationresponder.h b/linden/indra/newview/llhomelocationresponder.h new file mode 100644 index 0000000..08291b8 --- /dev/null +++ b/linden/indra/newview/llhomelocationresponder.h @@ -0,0 +1,47 @@ +/** + * @file llhomelocationresponder.h + * @author Meadhbh Hamrick + * @brief Processes responses to the HomeLocation CapReq + * + * $LicenseInfo:firstyear=2008&license=viewergpl$ + * + * Copyright (c) 2008, 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$ + */ + + /* Macro Definitions */ +#ifndef LL_LLHOMELOCATIONRESPONDER_H +#define LL_LLHOMELOCATIONRESPONDER_H + +/* File Inclusions */ +#include "llhttpclient.h" + +/* Typedef, Enum, Class, Struct, etc. */ +class LLHomeLocationResponder : public LLHTTPClient::Responder +{ + virtual void result( const LLSD& content ); + virtual void error( const LLSD& content ); +}; + +#endif diff --git a/linden/indra/newview/llhudeffectbeam.cpp b/linden/indra/newview/llhudeffectbeam.cpp index d6c38d3..2b5fd79 100644 --- a/linden/indra/newview/llhudeffectbeam.cpp +++ b/linden/indra/newview/llhudeffectbeam.cpp @@ -251,7 +251,7 @@ void LLHUDEffectBeam::render() } LLGLSPipelineAlpha gls_pipeline_alpha; - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // Interpolate the global fade alpha diff --git a/linden/indra/newview/llhudeffectlookat.cpp b/linden/indra/newview/llhudeffectlookat.cpp index b5f6ec7..5f0bb90 100644 --- a/linden/indra/newview/llhudeffectlookat.cpp +++ b/linden/indra/newview/llhudeffectlookat.cpp @@ -499,14 +499,14 @@ void LLHUDEffectLookAt::render() { if (sDebugLookAt && mSourceObject.notNull()) { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLVector3 target = mTargetPos + ((LLVOAvatar*)(LLViewerObject*)mSourceObject)->mHeadp->getWorldPosition(); glMatrixMode(GL_MODELVIEW); gGL.pushMatrix(); gGL.translatef(target.mV[VX], target.mV[VY], target.mV[VZ]); glScalef(0.3f, 0.3f, 0.3f); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { LLColor3 color = (*mAttentions)[mTargetType].mColor; gGL.color3f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE]); diff --git a/linden/indra/newview/llhudeffectpointat.cpp b/linden/indra/newview/llhudeffectpointat.cpp index 7ab03f2..2396e1a 100644 --- a/linden/indra/newview/llhudeffectpointat.cpp +++ b/linden/indra/newview/llhudeffectpointat.cpp @@ -328,13 +328,13 @@ void LLHUDEffectPointAt::render() update(); if (sDebugPointAt && mTargetType != POINTAT_TARGET_NONE) { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLVector3 target = mTargetPos + mSourceObject->getRenderPosition(); gGL.pushMatrix(); gGL.translatef(target.mV[VX], target.mV[VY], target.mV[VZ]); glScalef(0.3f, 0.3f, 0.3f); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { gGL.color3f(1.f, 0.f, 0.f); gGL.vertex3f(-1.f, 0.f, 0.f); diff --git a/linden/indra/newview/llhudicon.cpp b/linden/indra/newview/llhudicon.cpp index 85cc996..5d5c6a1 100644 --- a/linden/indra/newview/llhudicon.cpp +++ b/linden/indra/newview/llhudicon.cpp @@ -86,7 +86,7 @@ void LLHUDIcon::renderIcon(BOOL for_select) LLGLDepthTest gls_depth(GL_TRUE); if (for_select) { - LLViewerImage::unbindTexture(0); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } if (mHidden) @@ -163,10 +163,10 @@ void LLHUDIcon::renderIcon(BOOL for_select) LLColor4 icon_color = LLColor4::white; icon_color.mV[VALPHA] = alpha_factor; gGL.color4fv(icon_color.mV); - LLViewerImage::bindTexture(mImagep); + gGL.getTexUnit(0)->bind(mImagep.get()); } - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { gGL.texCoord2f(0.f, 1.f); gGL.vertex3fv(upper_left.mV); diff --git a/linden/indra/newview/llhudtext.cpp b/linden/indra/newview/llhudtext.cpp index c45c284..c5e5419 100644 --- a/linden/indra/newview/llhudtext.cpp +++ b/linden/indra/newview/llhudtext.cpp @@ -120,6 +120,111 @@ LLHUDText::~LLHUDText() } +BOOL LLHUDText::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, LLVector3& intersection, BOOL debug_render) +{ + if (!mVisible || mHidden) + { + return FALSE; + } + + // don't pick text that isn't bound to a viewerobject or isn't in a bubble + if (!mSourceObject || mSourceObject->mDrawable.isNull() || !mUseBubble) + { + return FALSE; + } + + F32 alpha_factor = 1.f; + LLColor4 text_color = mColor; + if (mDoFade) + { + if (mLastDistance > mFadeDistance) + { + alpha_factor = llmax(0.f, 1.f - (mLastDistance - mFadeDistance)/mFadeRange); + text_color.mV[3] = text_color.mV[3]*alpha_factor; + } + } + if (text_color.mV[3] < 0.01f) + { + return FALSE; + } + + mOffsetY = lltrunc(mHeight * ((mVertAlignment == ALIGN_VERT_CENTER) ? 0.5f : 1.f)); + + // scale screen size of borders down + //RN: for now, text on hud objects is never occluded + + LLVector3 x_pixel_vec; + LLVector3 y_pixel_vec; + + if (mOnHUDAttachment) + { + x_pixel_vec = LLVector3::y_axis / (F32)gViewerWindow->getWindowWidth(); + y_pixel_vec = LLVector3::z_axis / (F32)gViewerWindow->getWindowHeight(); + } + else + { + LLViewerCamera::getInstance()->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec); + } + + LLVector3 width_vec = mWidth * x_pixel_vec; + LLVector3 height_vec = mHeight * y_pixel_vec; + + LLCoordGL screen_pos; + LLViewerCamera::getInstance()->projectPosAgentToScreen(mPositionAgent, screen_pos, FALSE); + + LLVector2 screen_offset; + screen_offset = updateScreenPos(mPositionOffset); + + LLVector3 render_position = mPositionAgent + + (x_pixel_vec * screen_offset.mV[VX]) + + (y_pixel_vec * screen_offset.mV[VY]); + + + if (mUseBubble) + { + LLVector3 bg_pos = render_position + + (F32)mOffsetY * y_pixel_vec + - (width_vec / 2.f) + - (height_vec); + //LLUI::translate(bg_pos.mV[VX], bg_pos.mV[VY], bg_pos.mV[VZ]); + + LLVector3 v[] = + { + bg_pos, + bg_pos + width_vec, + bg_pos + width_vec + height_vec, + bg_pos + height_vec, + }; + + if (debug_render) + { + gGL.begin(LLRender::LINE_STRIP); + gGL.vertex3fv(v[0].mV); + gGL.vertex3fv(v[1].mV); + gGL.vertex3fv(v[2].mV); + gGL.vertex3fv(v[3].mV); + gGL.vertex3fv(v[0].mV); + gGL.vertex3fv(v[2].mV); + gGL.end(); + } + + LLVector3 dir = end-start; + F32 t = 0.f; + + if (LLTriangleRayIntersect(v[0], v[1], v[2], start, dir, NULL, NULL, &t, FALSE) || + LLTriangleRayIntersect(v[2], v[3], v[0], start, dir, NULL, NULL, &t, FALSE) ) + { + if (t <= 1.f) + { + intersection = start + dir*t; + return TRUE; + } + } + } + + return FALSE; +} + void LLHUDText::render() { if (!mOnHUDAttachment && sDisplayText) @@ -152,7 +257,15 @@ void LLHUDText::renderText(BOOL for_select) return; } - LLGLState gls_tex(GL_TEXTURE_2D, for_select ? FALSE : TRUE); + if (for_select) + { + gGL.getTexUnit(0)->disable(); + } + else + { + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + } + LLGLState gls_blend(GL_BLEND, for_select ? FALSE : TRUE); LLGLState gls_alpha(GL_ALPHA_TEST, for_select ? FALSE : TRUE); @@ -261,7 +374,7 @@ void LLHUDText::renderText(BOOL for_select) if (for_select) { - LLGLSNoTexture no_texture_state; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); S32 name = mSourceObject->mGLName; LLColor4U coloru((U8)(name >> 16), (U8)(name >> 8), (U8)name); gGL.color4ubv(coloru.mV); @@ -271,7 +384,7 @@ void LLHUDText::renderText(BOOL for_select) } else { - LLViewerImage::bindTexture(imagep->getImage()); + gGL.getTexUnit(0)->bind(imagep->getImage()); gGL.color4fv(bg_color.mV); gl_segmented_rect_3d_tex(border_scale_vec, scaled_border_width, scaled_border_height, width_vec, height_vec); @@ -309,7 +422,7 @@ void LLHUDText::renderText(BOOL for_select) } LLUI::popMatrix(); - LLImageGL::unbindTexture(0); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest gls_depth(mZCompare ? GL_TRUE : GL_FALSE, GL_FALSE); LLVector3 box_center_offset; @@ -317,7 +430,7 @@ void LLHUDText::renderText(BOOL for_select) LLUI::translate(box_center_offset.mV[VX], box_center_offset.mV[VY], box_center_offset.mV[VZ]); gGL.color4fv(bg_color.mV); LLUI::setLineWidth(2.0); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { if (outside_width) { @@ -444,6 +557,10 @@ void LLHUDText::renderText(BOOL for_select) } /// Reset the default color to white. The renderer expects this to be the default. glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + if (for_select) + { + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + } } void LLHUDText::setStringUTF8(const std::string &wtext) diff --git a/linden/indra/newview/llhudtext.h b/linden/indra/newview/llhudtext.h index 5719a19..6403622 100644 --- a/linden/indra/newview/llhudtext.h +++ b/linden/indra/newview/llhudtext.h @@ -123,6 +123,8 @@ public: void setOnHUDAttachment(BOOL on_hud) { mOnHUDAttachment = on_hud; } void shift(const LLVector3& offset); + BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, LLVector3& intersection, BOOL debug_render = FALSE); + static void shiftAll(const LLVector3& offset); static void renderAllHUD(); static void addPickable(std::set &pick_list); diff --git a/linden/indra/newview/llinventorymodel.cpp b/linden/indra/newview/llinventorymodel.cpp index b1e3017..c3392ce 100644 --- a/linden/indra/newview/llinventorymodel.cpp +++ b/linden/indra/newview/llinventorymodel.cpp @@ -73,7 +73,6 @@ F32 LLInventoryModel::sMinTimeBetweenFetches = 0.3f; F32 LLInventoryModel::sMaxTimeBetweenFetches = 10.f; BOOL LLInventoryModel::sTimelyFetchPending = FALSE; LLFrameTimer LLInventoryModel::sFetchTimer; -LLInventoryModel::cat_map_t LLInventoryModel::sBulkFetchMap; S16 LLInventoryModel::sBulkFetchCount = 0; // RN: for some reason, using std::queue in the header file confuses the compiler which things it's an xmlrpc_queue @@ -85,7 +84,7 @@ static std::deque sFetchQueue; //BOOL decompress_file(const char* src_filename, const char* dst_filename); const F32 MAX_TIME_FOR_SINGLE_FETCH = 10.f; -const S32 MAX_FETCH_RETRIES = 5; +const S32 MAX_FETCH_RETRIES = 10; const char CACHE_FORMAT_STRING[] = "%s.inv"; const char* NEW_CATEGORY_NAME = "New Folder"; const char* NEW_CATEGORY_NAMES[LLAssetType::AT_COUNT] = @@ -990,13 +989,24 @@ BOOL LLInventoryModel::containsObserver(LLInventoryObserver* observer) // Call this method when it's time to update everyone on a new state, // by default, the inventory model will not update observers // automatically. -void LLInventoryModel::notifyObservers() +// The optional argument 'service_name' is used by Agent Inventory Service [DEV-20328] +void LLInventoryModel::notifyObservers(const std::string service_name) { for (observer_list_t::iterator iter = mObservers.begin(); iter != mObservers.end(); ) { LLInventoryObserver* observer = *iter; - observer->changed(mModifyMask); + + if (service_name.empty()) + { + observer->changed(mModifyMask); + } + else + { + observer->mMessageName = service_name; + observer->changed(mModifyMask); + } + // safe way to incrament since changed may delete entries! (@!##%@!@&*!) iter = mObservers.upper_bound(observer); } @@ -1038,6 +1048,79 @@ void LLInventoryModel::mock(const LLUUID& root_id) } */ +//If we get back a normal response, handle it here +void LLInventoryModel::fetchInventoryResponder::result(const LLSD& content) +{ + start_new_inventory_observer(); + + /*LLUUID agent_id; + agent_id = content["agent_id"].asUUID(); + if(agent_id != gAgent.getID()) + { + llwarns << "Got a inventory update for the wrong agent: " << agent_id + << llendl; + return; + }*/ + item_array_t items; + update_map_t update; + S32 count = content["items"].size(); + bool all_one_folder = true; + LLUUID folder_id; + // Does this loop ever execute more than once? -Gigs + for(S32 i = 0; i < count; ++i) + { + LLPointer titem = new LLViewerInventoryItem; + titem->unpackMessage(content["items"][i]); + + lldebugs << "LLInventoryModel::messageUpdateCore() item id:" + << titem->getUUID() << llendl; + items.push_back(titem); + // examine update for changes. + LLViewerInventoryItem* itemp = gInventory.getItem(titem->getUUID()); + if(itemp) + { + if(titem->getParentUUID() == itemp->getParentUUID()) + { + update[titem->getParentUUID()]; + } + else + { + ++update[titem->getParentUUID()]; + --update[itemp->getParentUUID()]; + } + } + else + { + ++update[titem->getParentUUID()]; + } + if (folder_id.isNull()) + { + folder_id = titem->getParentUUID(); + } + else + { + all_one_folder = false; + } + } + + U32 changes = 0x0; + //as above, this loop never seems to loop more than once per call + for (item_array_t::iterator it = items.begin(); it != items.end(); ++it) + { + changes |= gInventory.updateItem(*it); + } + gInventory.notifyObservers("fetchinventory"); + gViewerWindow->getWindow()->decBusyCount(); +} + +//If we get back an error (not found, etc...), handle it here +void LLInventoryModel::fetchInventoryResponder::error(U32 status, const std::string& reason) +{ + llinfos << "fetchInventory::error " + << status << ": " << reason << llendl; + gInventory.notifyObservers("fetchinventory"); +} + void LLInventoryModel::fetchDescendentsOf(const LLUUID& folder_id) { LLViewerInventoryCategory* cat = getCategory(folder_id); @@ -1065,21 +1148,31 @@ void LLInventoryModel::fetchDescendentsOf(const LLUUID& folder_id) } //Initialize statics. -LLAlertDialog* LLInventoryModel::fetchDescendentsResponder::sRetryDialog=NULL; -LLSD LLInventoryModel::fetchDescendentsResponder::sRetrySD; - bool LLInventoryModel::isBulkFetchProcessingComplete() { return ( (sFetchQueue.empty() - && sBulkFetchMap.empty() - && sBulkFetchCount==0) ? TRUE : FALSE ) ; + && sBulkFetchCount<=0) ? TRUE : FALSE ) ; } +class fetchDescendentsResponder: public LLHTTPClient::Responder +{ + public: + fetchDescendentsResponder(const LLSD& request_sd) : mRequestSD(request_sd) {}; + //fetchDescendentsResponder() {}; + void result(const LLSD& content); + void error(U32 status, const std::string& reason); + public: + typedef std::vector folder_ref_t; + protected: + LLSD mRequestSD; +}; + //If we get back a normal response, handle it here -void LLInventoryModel::fetchDescendentsResponder::result(const LLSD& content) -{ +void fetchDescendentsResponder::result(const LLSD& content) +{ if (content.has("folders")) { + for(LLSD::array_const_iterator folder_it = content["folders"].beginArray(); folder_it != content["folders"].endArray(); ++folder_it) @@ -1087,19 +1180,54 @@ void LLInventoryModel::fetchDescendentsResponder::result(const LLSD& content) LLSD folder_sd = *folder_it; - LLUUID agent_id = folder_sd["agent-id"]; + //LLUUID agent_id = folder_sd["agent_id"]; - if(agent_id != gAgent.getID()) //This should never happen. - { - llwarns << "Got a UpdateInventoryItem for the wrong agent." - << llendl; - break; - } - LLUUID parent_id = folder_sd["folder-id"]; - LLUUID owner_id = folder_sd["owner-id"]; + //if(agent_id != gAgent.getID()) //This should never happen. + //{ + // llwarns << "Got a UpdateInventoryItem for the wrong agent." + // << llendl; + // break; + //} + + LLUUID parent_id = folder_sd["folder_id"]; + LLUUID owner_id = folder_sd["owner_id"]; S32 version = (S32)folder_sd["version"].asInteger(); S32 descendents = (S32)folder_sd["descendents"].asInteger(); LLPointer tcategory = new LLViewerInventoryCategory(owner_id); + + if (parent_id.isNull()) + { + LLPointer titem = new LLViewerInventoryItem; + for(LLSD::array_const_iterator item_it = folder_sd["items"].beginArray(); + item_it != folder_sd["items"].endArray(); + ++item_it) + { + LLUUID lost_uuid = gInventory.findCategoryUUIDForType(LLAssetType::AT_LOST_AND_FOUND); + if (lost_uuid.notNull()) + { + LLSD item = *item_it; + titem->unpackMessage(item); + + LLInventoryModel::update_list_t update; + LLInventoryModel::LLCategoryUpdate new_folder(lost_uuid, 1); + update.push_back(new_folder); + gInventory.accountForUpdate(update); + + titem->setParent(lost_uuid); + titem->updateParentOnServer(FALSE); + gInventory.updateItem(titem); + gInventory.notifyObservers("fetchDescendents"); + + } + } + } + + LLViewerInventoryCategory* pcat = gInventory.getCategory(parent_id); + if (!pcat) + { + continue; + } + for(LLSD::array_const_iterator category_it = folder_sd["categories"].beginArray(); category_it != folder_sd["categories"].endArray(); ++category_it) @@ -1107,7 +1235,7 @@ void LLInventoryModel::fetchDescendentsResponder::result(const LLSD& content) LLSD category = *category_it; tcategory->fromLLSD(category); - if (sFullFetchStarted) + if (LLInventoryModel::sFullFetchStarted) { sFetchQueue.push_back(tcategory->getUUID()); } @@ -1139,37 +1267,37 @@ void LLInventoryModel::fetchDescendentsResponder::result(const LLSD& content) } } - if (content.has("bad-folders")) + if (content.has("bad_folders")) { - for(LLSD::array_const_iterator folder_it = content["bad-folders"].beginArray(); - folder_it != content["bad-folders"].endArray(); + for(LLSD::array_const_iterator folder_it = content["bad_folders"].beginArray(); + folder_it != content["bad_folders"].endArray(); ++folder_it) { LLSD folder_sd = *folder_it; //These folders failed on the dataserver. We probably don't want to retry them. - llinfos << "Folder " << folder_sd["folder-id"].asString() + llinfos << "Folder " << folder_sd["folder_id"].asString() << "Error: " << folder_sd["error"].asString() << llendl; } } LLInventoryModel::incrBulkFetch(-1); - if (isBulkFetchProcessingComplete()) + if (LLInventoryModel::isBulkFetchProcessingComplete()) { llinfos << "Inventory fetch completed" << llendl; - if (sFullFetchStarted) + if (LLInventoryModel::sFullFetchStarted) { - sAllFoldersFetched = TRUE; + LLInventoryModel::sAllFoldersFetched = TRUE; } - stopBackgroundFetch(); + LLInventoryModel::stopBackgroundFetch(); } - gInventory.notifyObservers(); + gInventory.notifyObservers("fetchDescendents"); } //If we get back an error (not found, etc...), handle it here -void LLInventoryModel::fetchDescendentsResponder::error(U32 status, const std::string& reason) +void fetchDescendentsResponder::error(U32 status, const std::string& reason) { llinfos << "fetchDescendentsResponder::error " << status << ": " << reason << llendl; @@ -1183,61 +1311,22 @@ void LLInventoryModel::fetchDescendentsResponder::error(U32 status, const std::s ++folder_it) { LLSD folder_sd = *folder_it; - sRetrySD["folders"].append(folder_sd); - } - sMinTimeBetweenFetches = 10.0f; //Add 10 seconds for every time out in this sequence. - - if (!sRetryDialog) //The dialog isn't up. Prompt the resident. - { - sRetryDialog = gViewerWindow->alertXml("RetryFetchInventoryDescendents", onClickRetry, this); + LLUUID folder_id = folder_sd["folder_id"]; + sFetchQueue.push_front(folder_id); } } else { - if (isBulkFetchProcessingComplete()) + if (LLInventoryModel::isBulkFetchProcessingComplete()) { - if (sFullFetchStarted) + if (LLInventoryModel::sFullFetchStarted) { - sAllFoldersFetched = TRUE; + LLInventoryModel::sAllFoldersFetched = TRUE; } - stopBackgroundFetch(); + LLInventoryModel::stopBackgroundFetch(); } } - gInventory.notifyObservers(); -} - -void LLInventoryModel::fetchDescendentsResponder::onClickRetry(S32 option, void* userdata) -{ - if (option == 0) - { - std::string url; - - LLViewerRegion * agent_region = gAgent.getRegion(); - if (agent_region) - { - url = agent_region->getCapability("FetchInventoryDescendents"); - } - - if (!url.empty()) //Capability found. Build up LLSD and use it. - { - LLSD body = sRetrySD; - LLInventoryModel::incrBulkFetch(1); - LLHTTPClient::post(url, body, new LLInventoryModel::fetchDescendentsResponder(body),300); - } - } - else - { - if (isBulkFetchProcessingComplete()) - { - if (sFullFetchStarted) - { - sAllFoldersFetched = TRUE; - } - stopBackgroundFetch(); - } - } - sRetryDialog=NULL; - sRetrySD.clear(); + gInventory.notifyObservers("fetchDescendents"); } //static Bundle up a bunch of requests to send all at once. @@ -1250,7 +1339,7 @@ void LLInventoryModel::bulkFetch(std::string url) S16 max_concurrent_fetches=8; F32 new_min_time = 0.5f; //HACK! Clean this up when old code goes away entirely. - if (sMinTimeBetweenFetches <= new_min_time) sMinTimeBetweenFetches=new_min_time; //HACK! See above. + if (sMinTimeBetweenFetches < new_min_time) sMinTimeBetweenFetches=new_min_time; //HACK! See above. if(gDisconnected || sBulkFetchCount > max_concurrent_fetches @@ -1259,88 +1348,84 @@ void LLInventoryModel::bulkFetch(std::string url) return; // just bail if we are disconnected. } - //HACK. This is inelegant. We're shuffling a dequeue to a map to get rid of - //redundant requests. When we get rid of the old code entirely, we can change - //the dequeue to a map. In the new model, there is no benefit to queue order. U32 folder_count=0; - U32 max_batch_size=10; - while( !(sFetchQueue.empty() ) ) - { - LLViewerInventoryCategory* cat = gInventory.getCategory(sFetchQueue.front()); - - if (cat) - { - if ( !gInventory.isCategoryComplete(cat->getUUID()) ) //grab this folder. - { - sBulkFetchMap[(cat->getUUID())] = cat; - } - else if (sFullFetchStarted) - { //Already have this folder but append child folders to list. - // add all children to queue - parent_cat_map_t::iterator cat_it = gInventory.mParentChildCategoryTree.find(cat->getUUID()); - if (cat_it != gInventory.mParentChildCategoryTree.end()) - { - cat_array_t* child_categories = cat_it->second; - - for (S32 child_num = 0; child_num < child_categories->count(); child_num++) - { - sFetchQueue.push_back(child_categories->get(child_num)->getUUID()); - } - } + U32 max_batch_size=5; + + U32 sort_order = gSavedSettings.getU32("InventorySortOrder") & 0x1; + + LLSD body; + LLSD body_lib; + while( !(sFetchQueue.empty() ) && (folder_count < max_batch_size) ) + { + if (sFetchQueue.front().isNull()) //DEV-17797 + { + LLSD folder_sd; + folder_sd["folder_id"] = LLUUID::null.asString(); + folder_sd["owner_id"] = gAgent.getID(); + folder_sd["sort_order"] = (LLSD::Integer)sort_order; + folder_sd["fetch_folders"] = (LLSD::Boolean)FALSE; + folder_sd["fetch_items"] = (LLSD::Boolean)TRUE; + body["folders"].append(folder_sd); + folder_count++; + } + else + { + - } - } + LLViewerInventoryCategory* cat = gInventory.getCategory(sFetchQueue.front()); + + if (cat) + { + if ( LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion()) + { + LLSD folder_sd; + folder_sd["folder_id"] = cat->getUUID(); + folder_sd["owner_id"] = cat->getOwnerID(); + folder_sd["sort_order"] = (LLSD::Integer)sort_order; + folder_sd["fetch_folders"] = TRUE; //(LLSD::Boolean)sFullFetchStarted; + folder_sd["fetch_items"] = (LLSD::Boolean)TRUE; + + if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) + body_lib["folders"].append(folder_sd); + else + body["folders"].append(folder_sd); + folder_count++; + } + if (sFullFetchStarted) + { //Already have this folder but append child folders to list. + // add all children to queue + parent_cat_map_t::iterator cat_it = gInventory.mParentChildCategoryTree.find(cat->getUUID()); + if (cat_it != gInventory.mParentChildCategoryTree.end()) + { + cat_array_t* child_categories = cat_it->second; + + for (S32 child_num = 0; child_num < child_categories->count(); child_num++) + { + sFetchQueue.push_back(child_categories->get(child_num)->getUUID()); + } + } + + } + } + } sFetchQueue.pop_front(); } - - if (!sBulkFetchMap.empty()) //There's stuff to fetch. - { - U32 sort_order = gSavedSettings.getU32("InventorySortOrder") & 0x1; - - LLSD body; - - cat_map_t::iterator iter=sBulkFetchMap.begin(); - while( iter!=sBulkFetchMap.end() && (folder_count < max_batch_size) ) - { - LLViewerInventoryCategory* cat = iter->second; - - if (cat && !gInventory.isCategoryComplete(cat->getUUID()) ) //Category exists - { - BOOL fetchItems=TRUE; - if ( sFullFetchStarted - && gInventory.isCategoryComplete(cat->getUUID()) ) - { - fetchItems=FALSE; - } - - LLSD folder_sd; - folder_sd["folder-id"] = cat->getUUID(); - folder_sd["owner-id"] = cat->getOwnerID(); - folder_sd["sort-order"] = (LLSD::Integer)sort_order; - folder_sd["fetch-folders"] = (LLSD::Boolean)sFullFetchStarted; - folder_sd["fetch-items"] = (LLSD::Boolean)fetchItems; - body["folders"].append(folder_sd); - - folder_count++; - } - sBulkFetchMap.erase(iter); - iter=sBulkFetchMap.begin(); - } - - if (iter == sBulkFetchMap.end()) sBulkFetchMap.clear(); - if (folder_count > 0) { sBulkFetchCount++; - - LLHTTPClient::post(url, body, new LLInventoryModel::fetchDescendentsResponder(body)); + if (body["folders"].size()) + { + LLHTTPClient::post(url, body, new fetchDescendentsResponder(body),300.0); + } + if (body_lib["folders"].size()) + { + std::string url_lib = gAgent.getRegion()->getCapability("FetchLibDescendents"); + LLHTTPClient::post(url_lib, body_lib, new fetchDescendentsResponder(body_lib),300.0); + } sFetchTimer.reset(); } - - } - - if (isBulkFetchProcessingComplete()) + else if (isBulkFetchProcessingComplete()) { if (sFullFetchStarted) { @@ -1391,6 +1476,14 @@ void LLInventoryModel::startBackgroundFetch(const LLUUID& cat_id) } //static +void LLInventoryModel::findLostItems() +{ + sBackgroundFetchActive = TRUE; + sFetchQueue.push_back(LLUUID::null); + gIdleCallbacks.addFunction(&LLInventoryModel::backgroundFetch, NULL); +} + +//static void LLInventoryModel::stopBackgroundFetch() { if (sBackgroundFetchActive) @@ -1409,14 +1502,7 @@ void LLInventoryModel::backgroundFetch(void*) if (sBackgroundFetchActive) { //If we'll be using the capability, we'll be sending batches and the background thing isn't as important. - std::string url; - - LLViewerRegion * agent_region = gAgent.getRegion(); - if (agent_region) - { - url = agent_region->getCapability("FetchInventoryDescendents"); - } - + std::string url = gAgent.getRegion()->getCapability("WebFetchInventoryDescendents"); if (!url.empty()) { bulkFetch(url); @@ -3373,12 +3459,72 @@ bool LLInventoryFetchObserver::isEverythingComplete() const return mIncomplete.empty(); } +void fetch_items_from_llsd(const LLSD& items_llsd) +{ + if (!items_llsd.size()) return; + LLSD body; + body[0]["cap_name"] = "FetchInventory"; + body[1]["cap_name"] = "FetchLib"; + for (S32 i=0; i= body[i].size()) continue; + std::string url = gAgent.getRegion()->getCapability(body[i]["cap_name"].asString()); + + if (!url.empty()) + { + body[i]["agent_id"] = gAgent.getID(); + LLHTTPClient::post(url, body[i], new LLInventoryModel::fetchInventoryResponder(body[i])); + break; + } + + LLMessageSystem* msg = gMessageSystem; + BOOL start_new_message = TRUE; + for (S32 j=0; jnewMessageFast(_PREHASH_FetchInventory); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + } + msg->nextBlockFast(_PREHASH_InventoryData); + msg->addUUIDFast(_PREHASH_OwnerID, item_entry["owner_id"].asUUID()); + msg->addUUIDFast(_PREHASH_ItemID, item_entry["item_id"].asUUID()); + if(msg->isSendFull(NULL)) + { + start_new_message = TRUE; + gAgent.sendReliableMessage(); + } + } + if(!start_new_message) + { + gAgent.sendReliableMessage(); + } + } +} + void LLInventoryFetchObserver::fetchItems( const LLInventoryFetchObserver::item_ref_t& ids) { - LLMessageSystem* msg = gMessageSystem; - BOOL start_new_message = TRUE; LLUUID owner_id; + LLSD items_llsd; for(item_ref_t::const_iterator it = ids.begin(); it < ids.end(); ++it) { LLViewerInventoryItem* item = gInventory.getItem(*it); @@ -3400,31 +3546,18 @@ void LLInventoryFetchObserver::fetchItems( // assume it's agent inventory. owner_id = gAgent.getID(); } - + // It's incomplete, so put it on the incomplete container, and // pack this on the message. mIncomplete.push_back(*it); - if(start_new_message) - { - start_new_message = FALSE; - msg->newMessageFast(_PREHASH_FetchInventory); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - } - msg->nextBlockFast(_PREHASH_InventoryData); - msg->addUUIDFast(_PREHASH_OwnerID, owner_id); - msg->addUUIDFast(_PREHASH_ItemID, (*it)); - if(msg->isSendFull(NULL)) - { - start_new_message = TRUE; - gAgent.sendReliableMessage(); - } - } - if(!start_new_message) - { - gAgent.sendReliableMessage(); + + // Prepare the data to fetch + LLSD item_entry; + item_entry["owner_id"] = owner_id; + item_entry["item_id"] = (*it); + items_llsd.append(item_entry); } + fetch_items_from_llsd(items_llsd); } // virtual @@ -3579,9 +3712,8 @@ void LLInventoryFetchComboObserver::fetch( // descendent of an incomplete folder because the item will show // up in an inventory descendents message soon enough so we do not // have to fetch it individually. + LLSD items_llsd; LLUUID owner_id; - LLMessageSystem* msg = gMessageSystem; - bool start_new_message = true; for(item_ref_t::const_iterator iit = item_ids.begin(); iit != item_ids.end(); ++iit) { LLViewerInventoryItem* item = gInventory.getItem(*iit); @@ -3604,33 +3736,17 @@ void LLInventoryFetchComboObserver::fetch( } if(std::find(mIncompleteFolders.begin(), mIncompleteFolders.end(), item->getParentUUID()) == mIncompleteFolders.end()) { - lldebugs << "fetching item " << *iit << llendl; - if(start_new_message) - { - start_new_message = false; - msg->newMessageFast(_PREHASH_FetchInventory); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - } - msg->nextBlockFast(_PREHASH_InventoryData); - msg->addUUIDFast(_PREHASH_OwnerID, owner_id); - msg->addUUIDFast(_PREHASH_ItemID, (*iit)); - if(msg->isSendFullFast(_PREHASH_InventoryData)) - { - start_new_message = true; - gAgent.sendReliableMessage(); - } + LLSD item_entry; + item_entry["owner_id"] = owner_id; + item_entry["item_id"] = (*iit); + items_llsd.append(item_entry); } else { lldebugs << "not worrying about " << *iit << llendl; } } - if(!start_new_message) - { - gAgent.sendReliableMessage(); - } + fetch_items_from_llsd(items_llsd); } void LLInventoryExistenceObserver::watchItem(const LLUUID& id) @@ -3676,7 +3792,17 @@ void LLInventoryAddedObserver::changed(U32 mask) // the network, figure out which item was updated. // Code from Gigs Taggert, sin allowed by JC. LLMessageSystem* msg = gMessageSystem; - std::string msg_name = msg->getMessageName(); + + std::string msg_name; + if (mMessageName.empty()) + { + msg_name = msg->getMessageName(); + } + else + { + msg_name = mMessageName; + } + if (msg_name.empty()) { return; diff --git a/linden/indra/newview/llinventorymodel.h b/linden/indra/newview/llinventorymodel.h index 8017410..d2be761 100644 --- a/linden/indra/newview/llinventorymodel.h +++ b/linden/indra/newview/llinventorymodel.h @@ -69,6 +69,7 @@ public: }; virtual ~LLInventoryObserver() {}; virtual void changed(U32 mask) = 0; + std::string mMessageName; // used by Agent Inventory Service only. [DEV-20328] }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -110,20 +111,17 @@ public: LLInventoryModel(); ~LLInventoryModel(); - class fetchDescendentsResponder: public LLHTTPClient::Responder + class fetchInventoryResponder: public LLHTTPClient::Responder { - public: - fetchDescendentsResponder(const LLSD& request_sd) : mRequestSD(request_sd) {}; - void result(const LLSD& content); - void error(U32 status, const std::string& reason); - static void onClickRetry(S32 option, void* userdata); - static void appendRetryList(LLSD retry_sd); - public: - typedef std::vector folder_ref_t; - protected: - LLSD mRequestSD; - static LLSD sRetrySD; - static LLAlertDialog *sRetryDialog; + public: + fetchInventoryResponder(const LLSD& request_sd) : mRequestSD(request_sd) {}; + void result(const LLSD& content); + void error(U32 status, const std::string& reason); + + public: + typedef std::vector folder_ref_t; + protected: + LLSD mRequestSD; }; // @@ -268,7 +266,8 @@ public: // Call this method when it's time to update everyone on a new // state, by default, the inventory model will not update // observers automatically. - void notifyObservers(); + // The optional argument 'service_name' is used by Agent Inventory Service [DEV-20328] + void notifyObservers(const std::string service_name=""); // This allows outsiders to tell the inventory if something has // been changed 'under the hood', but outside the control of the @@ -370,7 +369,7 @@ public: // start and stop background breadth-first fetching of inventory contents // this gets triggered when performing a filter-search static void startBackgroundFetch(const LLUUID& cat_id = LLUUID::null); // start fetch process - static void stopBackgroundFetch(); // stop fetch process + static void findLostItems(); static BOOL backgroundFetchActive(); static bool isEverythingFetched(); static void backgroundFetch(void*); // background fetch idle function @@ -419,7 +418,6 @@ protected: static void processInventoryDescendents(LLMessageSystem* msg, void**); static void processMoveInventoryItem(LLMessageSystem* msg, void**); static void processFetchInventoryReply(LLMessageSystem* msg, void**); - static bool isBulkFetchProcessingComplete(); bool messageUpdateCore(LLMessageSystem* msg, bool do_accounting); @@ -460,11 +458,8 @@ protected: observer_list_t mObservers; // completing the fetch once per session should be sufficient - static cat_map_t sBulkFetchMap; static BOOL sBackgroundFetchActive; static BOOL sTimelyFetchPending; - static BOOL sAllFoldersFetched; - static BOOL sFullFetchStarted; static S32 sNumFetchRetries; static LLFrameTimer sFetchTimer; static F32 sMinTimeBetweenFetches; @@ -477,6 +472,11 @@ protected: public: // *NOTE: DEBUG functionality void dumpInventory(); + static bool isBulkFetchProcessingComplete(); + static void stopBackgroundFetch(); // stop fetch process + + static BOOL sFullFetchStarted; + static BOOL sAllFoldersFetched; }; // a special inventory model for the agent diff --git a/linden/indra/newview/llinventoryview.cpp b/linden/indra/newview/llinventoryview.cpp index f9dd70d..418578e 100644 --- a/linden/indra/newview/llinventoryview.cpp +++ b/linden/indra/newview/llinventoryview.cpp @@ -1329,6 +1329,16 @@ LLView* LLInventoryPanel::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac return panel; } +void LLInventoryPanel::draw() +{ + // select the desired item (in case it wasn't loaded when the selection was requested) + if (mSelectThisID.notNull()) + { + setSelection(mSelectThisID, false); + } + LLPanel::draw(); +} + void LLInventoryPanel::setFilterTypes(U32 filter_types) { mFolders->getFilter()->setFilterTypes(filter_types); @@ -1701,15 +1711,21 @@ void LLInventoryPanel::setSelection(const LLUUID& obj_id, BOOL take_keyboard_foc LLFolderViewItem* itemp = mFolders->getItemByID(obj_id); if(itemp && itemp->getListener()) { - itemp->getListener()->arrangeAndSet(itemp, - TRUE, - take_keyboard_focus); + itemp->getListener()->arrangeAndSet(itemp, TRUE, take_keyboard_focus); + mSelectThisID.setNull(); + return; + } + else + { + // save the desired item to be selected later (if/when ready) + mSelectThisID = obj_id; } } void LLInventoryPanel::clearSelection() { mFolders->clearSelection(); + mSelectThisID.setNull(); } void LLInventoryPanel::createNewItem(const std::string& name, diff --git a/linden/indra/newview/llinventoryview.h b/linden/indra/newview/llinventoryview.h index a37d370..1cf8b8f 100644 --- a/linden/indra/newview/llinventoryview.h +++ b/linden/indra/newview/llinventoryview.h @@ -86,6 +86,7 @@ public: static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); // LLView methods + void draw(); BOOL handleHover(S32 x, S32 y, MASK mask); BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, @@ -150,7 +151,8 @@ protected: LLFolderView* mFolders; LLScrollableContainerView* mScroller; BOOL mAllowMultiSelect; - const std::string mSortOrderSetting; + const std::string mSortOrderSetting; + LLUUID mSelectThisID; // if non null, select this item }; class LLInventoryView; diff --git a/linden/indra/newview/lljoystickbutton.cpp b/linden/indra/newview/lljoystickbutton.cpp index 773c57e..ff54569 100644 --- a/linden/indra/newview/lljoystickbutton.cpp +++ b/linden/indra/newview/lljoystickbutton.cpp @@ -651,11 +651,11 @@ void LLJoystickCameraRotate::drawRotatedImage( const LLImageGL* image, S32 rotat { 1.f, 0.f } }; - image->bind(); + gGL.getTexUnit(0)->bind(image); gGL.color4fv(UI_VERTEX_COLOR.mV); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { gGL.texCoord2fv( uv[ (rotations + 0) % 4]); gGL.vertex2i(width, height ); diff --git a/linden/indra/newview/llmanip.cpp b/linden/indra/newview/llmanip.cpp index 89f13fe..87e7a13 100644 --- a/linden/indra/newview/llmanip.cpp +++ b/linden/indra/newview/llmanip.cpp @@ -388,13 +388,13 @@ void LLManip::renderGuidelines(BOOL draw_x, BOOL draw_y, BOOL draw_z) const F32 LINE_ALPHA = 0.33f; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLUI::setLineWidth(1.5f); if (draw_x) { gGL.color4f(1.f, 0.f, 0.f, LINE_ALPHA); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); gGL.vertex3f( -region_size, 0.f, 0.f ); gGL.vertex3f( region_size, 0.f, 0.f ); gGL.end(); @@ -403,7 +403,7 @@ void LLManip::renderGuidelines(BOOL draw_x, BOOL draw_y, BOOL draw_z) if (draw_y) { gGL.color4f(0.f, 1.f, 0.f, LINE_ALPHA); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); gGL.vertex3f( 0.f, -region_size, 0.f ); gGL.vertex3f( 0.f, region_size, 0.f ); gGL.end(); @@ -412,7 +412,7 @@ void LLManip::renderGuidelines(BOOL draw_x, BOOL draw_y, BOOL draw_z) if (draw_z) { gGL.color4f(0.f, 0.f, 1.f, LINE_ALPHA); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); gGL.vertex3f( 0.f, 0.f, -region_size ); gGL.vertex3f( 0.f, 0.f, region_size ); gGL.end(); diff --git a/linden/indra/newview/llmaniprotate.cpp b/linden/indra/newview/llmaniprotate.cpp index 11b5e8c..ade07b4 100644 --- a/linden/indra/newview/llmaniprotate.cpp +++ b/linden/indra/newview/llmaniprotate.cpp @@ -115,7 +115,7 @@ void LLManipRotate::handleSelect() void LLManipRotate::render() { LLGLSUIDefault gls_ui; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest gls_depth(GL_TRUE); LLGLEnable gl_blend(GL_BLEND); LLGLEnable gls_alpha_test(GL_ALPHA_TEST); @@ -838,7 +838,7 @@ void LLManipRotate::renderSnapGuides() LLVector3 outer_point; LLVector3 text_point; LLQuaternion rot(deg * DEG_TO_RAD, constraint_axis); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { inner_point = (projected_snap_axis * mRadiusMeters * SNAP_GUIDE_INNER_RADIUS * rot) + center; F32 tick_length = 0.f; @@ -1017,7 +1017,7 @@ void LLManipRotate::renderSnapGuides() object_axis = object_axis * SNAP_GUIDE_INNER_RADIUS * mRadiusMeters + center; LLVector3 line_start = center; - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { gGL.vertex3fv(line_start.mV); gGL.vertex3fv(object_axis.mV); @@ -1025,7 +1025,7 @@ void LLManipRotate::renderSnapGuides() gGL.end(); // draw snap guide arrow - gGL.begin(LLVertexBuffer::TRIANGLES); + gGL.begin(LLRender::TRIANGLES); { LLVector3 arrow_dir; LLVector3 arrow_span = (object_axis - line_start) % getConstraintAxis(); @@ -1045,7 +1045,7 @@ void LLManipRotate::renderSnapGuides() { LLGLDepthTest gls_depth(GL_TRUE); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { gGL.vertex3fv(line_start.mV); gGL.vertex3fv(object_axis.mV); @@ -1053,7 +1053,7 @@ void LLManipRotate::renderSnapGuides() gGL.end(); // draw snap guide arrow - gGL.begin(LLVertexBuffer::TRIANGLES); + gGL.begin(LLRender::TRIANGLES); { LLVector3 arrow_dir; LLVector3 arrow_span = (object_axis - line_start) % getConstraintAxis(); diff --git a/linden/indra/newview/llmanipscale.cpp b/linden/indra/newview/llmanipscale.cpp index 0fa5fa5..5c9c889 100644 --- a/linden/indra/newview/llmanipscale.cpp +++ b/linden/indra/newview/llmanipscale.cpp @@ -197,7 +197,7 @@ LLManipScale::~LLManipScale() void LLManipScale::render() { LLGLSUIDefault gls_ui; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest gls_depth(GL_TRUE); LLGLEnable gl_blend(GL_BLEND); LLGLEnable gls_alpha_test(GL_ALPHA_TEST); @@ -590,7 +590,7 @@ void LLManipScale::renderFaces( const LLBBox& bbox ) { gGL.color4fv( default_normal_color.mV ); LLGLDepthTest gls_depth(GL_FALSE); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { // Face 0 gGL.vertex3f(min.mV[VX], max.mV[VY], max.mV[VZ]); @@ -751,7 +751,7 @@ void LLManipScale::renderCorners( const LLBBox& bbox ) void LLManipScale::renderBoxHandle( F32 x, F32 y, F32 z ) { - LLImageGL::unbindTexture(0); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest gls_depth(GL_FALSE); glPushMatrix(); @@ -1528,7 +1528,7 @@ void LLManipScale::renderSnapGuides(const LLBBox& bbox) { LLColor4 tick_color = setupSnapGuideRenderPass(pass); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); LLVector3 line_mid = mScaleCenter + (mScaleSnapValue * mScaleDir) + (mSnapGuideDir1 * mSnapRegimeOffset); LLVector3 line_start = line_mid - (mScaleDir * (llmin(mScaleSnapValue, mSnapGuideLength * 0.5f))); LLVector3 line_end = line_mid + (mScaleDir * llmin(max_point_on_scale_line - mScaleSnapValue, mSnapGuideLength * 0.5f)); @@ -1579,7 +1579,7 @@ void LLManipScale::renderSnapGuides(const LLBBox& bbox) if (mInSnapRegime) { // draw snap guide line - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); LLVector3 snap_line_center = mScaleCenter + (mScaleSnapValue * mScaleDir); LLVector3 snap_line_start = snap_line_center + (mSnapGuideDir1 * mSnapRegimeOffset); @@ -1593,7 +1593,7 @@ void LLManipScale::renderSnapGuides(const LLBBox& bbox) gGL.end(); // draw snap guide arrow - gGL.begin(LLVertexBuffer::TRIANGLES); + gGL.begin(LLRender::TRIANGLES); { //gGLSNoCullFaces.set(); gGL.color4f(1.f, 1.f, 1.f, grid_alpha); @@ -1628,7 +1628,7 @@ void LLManipScale::renderSnapGuides(const LLBBox& bbox) start_tick = -(llmin(ticks_from_scale_center_1, num_ticks_per_side1)); stop_tick = llmin(max_ticks1, num_ticks_per_side1); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); // draw first row of ticks for (S32 i = start_tick; i <= stop_tick; i++) { diff --git a/linden/indra/newview/llmaniptranslate.cpp b/linden/indra/newview/llmaniptranslate.cpp index 2278453..30fa745 100644 --- a/linden/indra/newview/llmaniptranslate.cpp +++ b/linden/indra/newview/llmaniptranslate.cpp @@ -134,7 +134,7 @@ void LLManipTranslate::restoreGL() GLuint* d = new GLuint[rez*rez]; glGenTextures(1, &sGridTex); - glBindTexture(GL_TEXTURE_2D, sGridTex); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, sGridTex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -1052,7 +1052,7 @@ void LLManipTranslate::renderSnapGuides() F32 max_subdivisions = sGridMaxSubdivisionLevel;//(F32)gSavedSettings.getS32("GridSubdivision"); F32 line_alpha = gSavedSettings.getF32("GridOpacity"); - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest gls_depth(GL_TRUE); LLGLDisable gls_cull(GL_CULL_FACE); LLVector3 translate_axis; @@ -1223,7 +1223,7 @@ void LLManipTranslate::renderSnapGuides() { LLColor4 line_color = setupSnapGuideRenderPass(pass); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { LLVector3 line_start = selection_center + (mSnapOffsetMeters * mSnapOffsetAxis) + (translate_axis * (guide_size_meters * 0.5f + offset_nearest_grid_unit)); LLVector3 line_end = selection_center + (mSnapOffsetMeters * mSnapOffsetAxis) - (translate_axis * (guide_size_meters * 0.5f + offset_nearest_grid_unit)); @@ -1299,7 +1299,7 @@ void LLManipTranslate::renderSnapGuides() LLVector3 line_start = selection_center - mSnapOffsetAxis * mSnapOffsetMeters; LLVector3 line_end = selection_center + mSnapOffsetAxis * mSnapOffsetMeters; - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { gGL.color4f(line_color.mV[VX], line_color.mV[VY], line_color.mV[VZ], line_color.mV[VW]); @@ -1309,7 +1309,7 @@ void LLManipTranslate::renderSnapGuides() gGL.end(); // draw snap guide arrow - gGL.begin(LLVertexBuffer::TRIANGLES); + gGL.begin(LLRender::TRIANGLES); { gGL.color4f(line_color.mV[VX], line_color.mV[VY], line_color.mV[VZ], line_color.mV[VW]); @@ -1463,7 +1463,7 @@ void LLManipTranslate::renderSnapGuides() break; } - LLImageGL::unbindTexture(0); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); highlightIntersection(normal, selection_center, grid_rotation, inner_color); gGL.pushMatrix(); @@ -1503,7 +1503,7 @@ void LLManipTranslate::renderSnapGuides() LLGLDisable stencil(GL_STENCIL_TEST); { LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GREATER); - glBindTexture(GL_TEXTURE_2D, sGridTex); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, sGridTex); gGL.flush(); gGL.blendFunc(LLRender::BF_ZERO, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); renderGrid(u,v,tiles,0.9f, 0.9f, 0.9f,a*0.15f); @@ -1514,11 +1514,11 @@ void LLManipTranslate::renderSnapGuides() { LLGLDisable alpha_test(GL_ALPHA_TEST); //draw black overlay - LLImageGL::unbindTexture(0); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); renderGrid(u,v,tiles,0.0f, 0.0f, 0.0f,a*0.16f); //draw grid top - glBindTexture(GL_TEXTURE_2D, sGridTex); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, sGridTex); renderGrid(u,v,tiles,1,1,1,a); gGL.popMatrix(); @@ -1564,7 +1564,7 @@ void LLManipTranslate::renderGrid(F32 x, F32 y, F32 size, F32 r, F32 g, F32 b, F for (F32 xx = -size-d; xx < size+d; xx += d) { - gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); + gGL.begin(LLRender::TRIANGLE_STRIP); for (F32 yy = -size-d; yy < size+d; yy += d) { float dx, dy, da; @@ -1620,7 +1620,7 @@ void LLManipTranslate::highlightIntersection(LLVector3 normal, LLGLDepthTest depth (GL_TRUE, GL_FALSE, GL_ALWAYS); glStencilFunc(GL_ALWAYS, 0, stencil_mask); gGL.setColorMask(false, false); - LLImageGL::unbindTexture(0); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); glColor4f(1,1,1,1); //setup clip plane @@ -1686,7 +1686,7 @@ void LLManipTranslate::highlightIntersection(LLVector3 normal, //draw volume/plane intersections { - LLImageGL::unbindTexture(0); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest depth(GL_FALSE); LLGLEnable stencil(GL_STENCIL_TEST); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); @@ -1834,7 +1834,7 @@ void LLManipTranslate::renderTranslationHandles() relative_camera_dir.normVec(); { - LLGLSNoTexture gls_ui_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDisable cull_face(GL_CULL_FACE); LLColor4 color1; @@ -1877,7 +1877,7 @@ void LLManipTranslate::renderTranslationHandles() color1.setVec(0.f, 1.f, 0.f, 0.6f); color2.setVec(0.f, 0.f, 1.f, 0.6f); } - gGL.begin(LLVertexBuffer::TRIANGLES); + gGL.begin(LLRender::TRIANGLES); { gGL.color4fv(color1.mV); gGL.vertex3f(0.f, mPlaneManipOffsetMeters * (-PLANE_TICK_SIZE * 0.25f), mPlaneManipOffsetMeters * (-PLANE_TICK_SIZE * 0.25f)); @@ -1892,7 +1892,7 @@ void LLManipTranslate::renderTranslationHandles() gGL.end(); LLUI::setLineWidth(3.0f); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { gGL.color4f(0.f, 0.f, 0.f, 0.3f); gGL.vertex3f(0.f, mPlaneManipOffsetMeters * -PLANE_TICK_SIZE * 0.25f, mPlaneManipOffsetMeters * -PLANE_TICK_SIZE * 0.25f); @@ -1932,7 +1932,7 @@ void LLManipTranslate::renderTranslationHandles() color2.setVec(1.f, 0.f, 0.f, 0.6f); } - gGL.begin(LLVertexBuffer::TRIANGLES); + gGL.begin(LLRender::TRIANGLES); { gGL.color4fv(color1.mV); gGL.vertex3f(mPlaneManipOffsetMeters * (PLANE_TICK_SIZE * 0.25f), 0.f, mPlaneManipOffsetMeters * (PLANE_TICK_SIZE * 0.25f)); @@ -1947,7 +1947,7 @@ void LLManipTranslate::renderTranslationHandles() gGL.end(); LLUI::setLineWidth(3.0f); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { gGL.color4f(0.f, 0.f, 0.f, 0.3f); gGL.vertex3f(mPlaneManipOffsetMeters * -PLANE_TICK_SIZE * 0.25f, 0.f, mPlaneManipOffsetMeters * -PLANE_TICK_SIZE * 0.25f); @@ -2011,7 +2011,7 @@ void LLManipTranslate::renderTranslationHandles() color2.setVec(0.f, 0.8f, 0.f, 0.6f); } - gGL.begin(LLVertexBuffer::TRIANGLES); + gGL.begin(LLRender::TRIANGLES); { gGL.color4fv(color1.mV); gGL.vertex3fv(v0.mV); @@ -2026,7 +2026,7 @@ void LLManipTranslate::renderTranslationHandles() gGL.end(); LLUI::setLineWidth(3.0f); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { gGL.color4f(0.f, 0.f, 0.f, 0.3f); LLVector3 v12 = (v1 + v2) * .5f; @@ -2052,7 +2052,7 @@ void LLManipTranslate::renderTranslationHandles() } } { - LLGLSNoTexture gls_ui_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // Since we draw handles with depth testing off, we need to draw them in the // proper depth order. @@ -2126,7 +2126,7 @@ void LLManipTranslate::renderTranslationHandles() void LLManipTranslate::renderArrow(S32 which_arrow, S32 selected_arrow, F32 box_size, F32 arrow_size, F32 handle_size, BOOL reverse_direction) { - LLGLSNoTexture gls_ui_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLEnable gls_blend(GL_BLEND); LLGLEnable gls_color_material(GL_COLOR_MATERIAL); @@ -2160,7 +2160,7 @@ void LLManipTranslate::renderArrow(S32 which_arrow, S32 selected_arrow, F32 box_ { LLUI::setLineWidth(2.0f); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); vec.mV[index] = box_size; gGL.vertex3f(vec.mV[0], vec.mV[1], vec.mV[2]); diff --git a/linden/indra/newview/llmapresponders.cpp b/linden/indra/newview/llmapresponders.cpp index d16bc78..898ac58 100644 --- a/linden/indra/newview/llmapresponders.cpp +++ b/linden/indra/newview/llmapresponders.cpp @@ -66,7 +66,7 @@ void LLMapLayerResponder::result(const LLSD& result) new_layer.LayerDefined = TRUE; new_layer.LayerImageID = layer_data["ImageID"]; new_layer.LayerImage = gImageList.getImage(new_layer.LayerImageID, MIPMAP_TRUE, FALSE); - new_layer.LayerImage->bindTexture(0); + gGL.getTexUnit(0)->bind(new_layer.LayerImage.get()); new_layer.LayerImage->setClamp(TRUE, TRUE); new_layer.LayerExtents.mLeft = layer_data["Left"]; @@ -163,7 +163,7 @@ void LLMapLayerResponder::result(const LLSD& result) siminfo->mWaterHeight = (F32) water_height; siminfo->mMapImageID[agent_flags] = image_id; siminfo->mCurrentImage = gImageList.getImage(siminfo->mMapImageID[LLWorldMap::getInstance()->mCurrentMap], MIPMAP_TRUE, FALSE); - siminfo->mCurrentImage->bindTexture(0); + gGL.getTexUnit(0)->bind(siminfo->mCurrentImage.get()); siminfo->mCurrentImage->setClamp(TRUE, TRUE); if (siminfo->mMapImageID[2].notNull()) diff --git a/linden/indra/newview/llmemoryview.cpp b/linden/indra/newview/llmemoryview.cpp index c814e2b..89001d4 100644 --- a/linden/indra/newview/llmemoryview.cpp +++ b/linden/indra/newview/llmemoryview.cpp @@ -146,7 +146,7 @@ void LLMemoryView::draw() S32 height = getRect().getHeight(); LLGLSUIDefault gls_ui; - LLGLSNoTexture gls_no_tex; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gl_rect_2d(0, height, width, 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); #if MEM_TRACK_TYPE diff --git a/linden/indra/newview/llmutelist.cpp b/linden/indra/newview/llmutelist.cpp index 0cdfe83..fe42608 100644 --- a/linden/indra/newview/llmutelist.cpp +++ b/linden/indra/newview/llmutelist.cpp @@ -97,6 +97,26 @@ const char AGENT_SUFFIX[] = " (resident)"; const char OBJECT_SUFFIX[] = " (object)"; const char GROUP_SUFFIX[] = " (group)"; + +LLMute::LLMute(const LLUUID& id, const std::string& name, EType type, U32 flags) + : mID(id), + mName(name), + mType(type), + mFlags(flags) +{ + // muting is done by root objects only - try to find this objects root + LLViewerObject *objectp = gObjectList.findObject(mID); + if ((objectp) && (!objectp->isAvatar())) + { + LLViewerObject *parentp = (LLViewerObject *)objectp->getParent(); + if (parentp) + { + mID = parentp->getID(); + } + } +} + + std::string LLMute::getDisplayName() const { std::string name_with_suffix = mName; @@ -216,17 +236,24 @@ void LLMuteList::loadUserVolumes() //----------------------------------------------------------------------------- LLMuteList::~LLMuteList() { - std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "volume_settings.xml"); - LLSD settings_llsd; - - for(user_volume_map_t::iterator iter = mUserVolumeSettings.begin(); iter != mUserVolumeSettings.end(); ++iter) + // If we quit from the login screen we will not have an SL account + // name. Don't try to save, otherwise we'll dump a file in + // C:\Program Files\SecondLife\ JC + std::string user_dir = gDirUtilp->getLindenUserDir(); + if (!user_dir.empty()) { - settings_llsd[iter->first.asString()] = iter->second; - } + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "volume_settings.xml"); + LLSD settings_llsd; - llofstream file; - file.open(filename); - LLSDSerialize::toPrettyXML(settings_llsd, file); + for(user_volume_map_t::iterator iter = mUserVolumeSettings.begin(); iter != mUserVolumeSettings.end(); ++iter) + { + settings_llsd[iter->first.asString()] = iter->second; + } + + llofstream file; + file.open(filename); + LLSDSerialize::toPrettyXML(settings_llsd, file); + } } BOOL LLMuteList::isLinden(const std::string& name) const diff --git a/linden/indra/newview/llmutelist.h b/linden/indra/newview/llmutelist.h index 400f13e..af9c498 100644 --- a/linden/indra/newview/llmutelist.h +++ b/linden/indra/newview/llmutelist.h @@ -60,8 +60,7 @@ public: flagAll = 0x0000000F // Mask of all currently defined flags }; - LLMute(const LLUUID& id, const std::string& name = std::string(), EType type = BY_NAME, U32 flags = 0) - : mID(id), mName(name), mType(type),mFlags(flags) { } + LLMute(const LLUUID& id, const std::string& name = std::string(), EType type = BY_NAME, U32 flags = 0); // Returns name + suffix based on type // For example: "James Tester (resident)" diff --git a/linden/indra/newview/llnetmap.cpp b/linden/indra/newview/llnetmap.cpp index b277998..36b6863 100644 --- a/linden/indra/newview/llnetmap.cpp +++ b/linden/indra/newview/llnetmap.cpp @@ -226,7 +226,7 @@ void LLNetMap::draw() LLGLEnable scissor(GL_SCISSOR_TEST); { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLLocalClipRect clip(getLocalRect()); glMatrixMode(GL_MODELVIEW); @@ -286,8 +286,8 @@ void LLNetMap::draw() // Draw using texture. - LLViewerImage::bindTexture(regionp->getLand().getSTexture()); - gGL.begin(LLVertexBuffer::QUADS); + gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture()); + gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); @@ -303,8 +303,8 @@ void LLNetMap::draw() { if (regionp->getLand().getWaterTexture()) { - LLViewerImage::bindTexture(regionp->getLand().getWaterTexture()); - gGL.begin(LLVertexBuffer::QUADS); + gGL.getTexUnit(0)->bind(regionp->getLand().getWaterTexture()); + gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); @@ -350,11 +350,11 @@ void LLNetMap::draw() map_center_agent.mV[VX] *= gMiniMapScale/region_width; map_center_agent.mV[VY] *= gMiniMapScale/region_width; - LLViewerImage::bindTexture(mObjectImagep); + gGL.getTexUnit(0)->bind(mObjectImagep); F32 image_half_width = 0.5f*mObjectMapPixels; F32 image_half_height = 0.5f*mObjectMapPixels; - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, image_half_height + map_center_agent.mV[VY]); gGL.texCoord2f(0.f, 0.f); @@ -457,13 +457,13 @@ void LLNetMap::draw() F32 ctr_y = (F32)center_sw_bottom; - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); if( LLNetMap::sRotateMap ) { gGL.color4fv(gFrustumMapColor.mV); - gGL.begin( LLVertexBuffer::TRIANGLES ); + gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( ctr_x, ctr_y ); gGL.vertex2f( ctr_x - half_width_pixels, ctr_y + far_clip_pixels ); gGL.vertex2f( ctr_x + half_width_pixels, ctr_y + far_clip_pixels ); @@ -477,7 +477,7 @@ void LLNetMap::draw() gGL.pushMatrix(); gGL.translatef( ctr_x, ctr_y, 0 ); glRotatef( atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ) * RAD_TO_DEG, 0.f, 0.f, -1.f); - gGL.begin( LLVertexBuffer::TRIANGLES ); + gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( 0, 0 ); gGL.vertex2f( -half_width_pixels, far_clip_pixels ); gGL.vertex2f( half_width_pixels, far_clip_pixels ); @@ -642,7 +642,11 @@ void LLNetMap::renderScaledPointGlobal( const LLVector3d& pos, const LLColor4U & LLVector3 local_pos; local_pos.setVec( pos - mObjectImageCenterGlobal ); - S32 diameter_pixels = llround(2 * radius_meters * mObjectMapTPM); + // DEV-17370 - megaprims of size > 4096 cause lag. (go figger.) + const F32 MAX_RADIUS = 256.0f; + F32 radius_clamped = llmin(radius_meters, MAX_RADIUS); + + S32 diameter_pixels = llround(2 * radius_clamped * mObjectMapTPM); renderPoint( local_pos, color, diameter_pixels ); } diff --git a/linden/indra/newview/llnotify.cpp b/linden/indra/newview/llnotify.cpp index f703736..9c1f7a0 100644 --- a/linden/indra/newview/llnotify.cpp +++ b/linden/indra/newview/llnotify.cpp @@ -509,7 +509,7 @@ void LLNotifyBox::drawBackground() const LLUIImagePtr imagep = LLUI::getUIImage("rounded_square.tga"); if (imagep) { - LLViewerImage::bindTexture(imagep->getImage()); + gGL.getTexUnit(0)->bind(imagep->getImage()); // set proper background color depending on whether notify box is a caution or not LLColor4 color = mIsCaution? gColors.getColor("NotifyCautionBoxColor") : gColors.getColor("NotifyBoxColor"); if(gFocusMgr.childHasKeyboardFocus( this )) diff --git a/linden/indra/newview/llpaneldisplay.cpp b/linden/indra/newview/llpaneldisplay.cpp index 3e60745..26e6fda 100644 --- a/linden/indra/newview/llpaneldisplay.cpp +++ b/linden/indra/newview/llpaneldisplay.cpp @@ -753,6 +753,8 @@ void LLPanelDisplay::onApplyResolution(LLUICtrl* src, void* user_data) void LLPanelDisplay::applyResolution() { + + gGL.flush(); char aspect_ratio_text[ASPECT_RATIO_STR_LEN]; /*Flawfinder: ignore*/ if (mCtrlAspectRatio->getCurrentIndex() == -1) { @@ -787,75 +789,15 @@ void LLPanelDisplay::applyResolution() { mAspectRatio = (F32)mCtrlAspectRatio->getValue().asReal(); } - + // presumably, user entered a non-numeric value if aspect_ratio == 0.f if (mAspectRatio != 0.f) { mAspectRatio = llclamp(mAspectRatio, 0.2f, 5.f); gSavedSettings.setF32("FullScreenAspectRatio", mAspectRatio); - if (gSavedSettings.getBOOL("FullScreenAutoDetectAspectRatio")) - { - gViewerWindow->getWindow()->setNativeAspectRatio(0.f); - } - else - { - gViewerWindow->getWindow()->setNativeAspectRatio(mAspectRatio); - } } - gViewerWindow->reshape(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()); - - // Screen resolution - S32 num_resolutions; - LLWindow::LLWindowResolution* supported_resolutions = gViewerWindow->getWindow()->getSupportedResolutions(num_resolutions); - - // switching to windowed - BOOL fullscreen = !mCtrlWindowed->get(); - - // check if resolution has changed - BOOL targetFullscreen; - S32 targetWidth; - S32 targetHeight; - gViewerWindow->getTargetWindow(targetFullscreen, targetWidth, targetHeight); - - if ((fullscreen != targetFullscreen) || - (fullscreen && - (supported_resolutions[mCtrlFullScreen->getCurrentIndex()].mWidth != targetWidth || - supported_resolutions[mCtrlFullScreen->getCurrentIndex()].mHeight != targetHeight) - )) - { - // change fullscreen resolution or switch in/out of windowed mode - BOOL result; - - BOOL logged_in = (LLStartUp::getStartupState() >= STATE_STARTED); - if (fullscreen) - { - result = gViewerWindow->changeDisplaySettings(TRUE, - LLCoordScreen( supported_resolutions[mCtrlFullScreen->getCurrentIndex()].mWidth, - supported_resolutions[mCtrlFullScreen->getCurrentIndex()].mHeight), - gSavedSettings.getBOOL("DisableVerticalSync"), - logged_in); - } - else - { - result = gViewerWindow->changeDisplaySettings(FALSE, - LLCoordScreen(gSavedSettings.getS32("WindowWidth"), gSavedSettings.getS32("WindowHeight")), - TRUE, - logged_in); - } - if (!result) - { - - // GL is non-existent at this point, so we can't continue. - llerrs << "LLPanelDisplay::apply() failed" << llendl; - } - } - - // force aspect ratio - if (fullscreen) - { - LLViewerCamera::getInstance()->setAspect( gViewerWindow->getDisplayAspectRatio() ); - } + gViewerWindow->requestResolutionUpdate(!mCtrlWindowed->get(), mCtrlFullScreen->getCurrentIndex()); send_agent_update(TRUE); diff --git a/linden/indra/newview/llpanelgeneral.cpp b/linden/indra/newview/llpanelgeneral.cpp index 256f02a..43b0f4c 100644 --- a/linden/indra/newview/llpanelgeneral.cpp +++ b/linden/indra/newview/llpanelgeneral.cpp @@ -31,75 +31,15 @@ #include "llviewerprecompiledheaders.h" +//file include #include "llpanelgeneral.h" -// linden library includes -#include "llerror.h" -#include "llrect.h" -#include "llfontgl.h" -#include "message.h" -#include "lluictrlfactory.h" - // project includes -#include "llagent.h" -#include "llviewerwindow.h" #include "llcolorswatch.h" #include "llcombobox.h" -#include "llconsole.h" -#include "lllineeditor.h" -#include "llpanellogin.h" -#include "llnetmap.h" -#include "llresmgr.h" -#include "llspinctrl.h" -#include "lltextbox.h" -#include "llui.h" +#include "lluictrlfactory.h" #include "llurlsimstring.h" #include "llviewercontrol.h" -#include "llurlsimstring.h" - -#include "llcheckboxctrl.h" -#include "llradiogroup.h" -// -// Imported globals -// - -void set_crash_behavior(LLUICtrl* ctrl, void* data); -void set_start_location(LLUICtrl* ctrl, void* data); - - -// -// Globals -// - -// -// Static functions -// -static void set_render_name_fade_out(LLUICtrl* ctrl, void* data) -{ - LLComboBox* combo = (LLComboBox*)ctrl; - if (!combo) return; - gSavedSettings.setS32("RenderName", combo->getCurrentIndex() ); -} - -void set_crash_behavior(LLUICtrl* ctrl, void* data) -{ - gCrashSettings.setS32(CRASH_BEHAVIOR_SETTING, ((LLComboBox*) ctrl)->getCurrentIndex()); -} - -void set_language(LLUICtrl* ctrl, void* data) -{ - gSavedSettings.setString("Language", ctrl->getValue().asString()); -} - -void LLPanelGeneral::set_start_location(LLUICtrl* ctrl, void* data) -{ - LLURLSimString::setString(ctrl->getValue().asString()); -} - -void LLPanelGeneral::set_specific_start_location(LLLineEditor* line_editor, void* data) -{ - LLURLSimString::setString(line_editor->getValue().asString()); -} LLPanelGeneral::LLPanelGeneral() { @@ -108,50 +48,33 @@ LLPanelGeneral::LLPanelGeneral() BOOL LLPanelGeneral::postBuild() { - childSetCommitCallback("fade_out_combobox", set_render_name_fade_out); - - std::string region_name_prompt = getString("region_name_prompt"); - - - // location combobox - LLComboBox* combo = getChild( "location_combobox"); - if (combo) - { - if (!LLURLSimString::sInstance.mSimString.empty()) - { - combo->setTextEntry(LLURLSimString::sInstance.mSimString); - } - - BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation"); - if (!LLURLSimString::sInstance.mSimString.empty()) - { - combo->add( LLURLSimString::sInstance.mSimString ); - combo->setCurrentByIndex( 2 ); - } - else - { - combo->add( region_name_prompt ); - combo->setCurrentByIndex( login_last ? 1 : 0 ); - } - combo->setCommitCallback( &set_start_location ); - combo->setTextEntryCallback( &set_specific_start_location ); - } - - // Show location on login screen - childSetCommitCallback("show_location_checkbox", &LLPanelGeneral::clickShowStartLocation); - - combo = getChild( "crash_behavior_combobox"); - if (combo) - { - combo->setCurrentByIndex( gCrashSettings.getS32(CRASH_BEHAVIOR_SETTING) ); - combo->setCommitCallback( &set_crash_behavior ); - } + LLComboBox* fade_out_combobox = getChild("fade_out_combobox"); + fade_out_combobox->setCurrentByIndex(gSavedSettings.getS32("RenderName")); + + childSetValue("default_start_location", gSavedSettings.getBOOL("LoginLastLocation") ? "MyLastLocation" : "MyHome"); + childSetValue("show_location_checkbox", gSavedSettings.getBOOL("ShowStartLocation")); + childSetValue("show_all_title_checkbox", gSavedSettings.getBOOL("RenderHideGroupTitleAll")); + childSetValue("language_is_public", gSavedSettings.getBOOL("LanguageIsPublic")); + + childSetValue("show_my_name_checkbox", gSavedSettings.getBOOL("RenderNameHideSelf")); + childSetValue("small_avatar_names_checkbox", gSavedSettings.getBOOL("SmallAvatarNames")); + childSetValue("show_my_title_checkbox", gSavedSettings.getBOOL("RenderHideGroupTitle")); + childSetValue("afk_timeout_spinner", gSavedSettings.getF32("AFKTimeout")); + childSetValue("rotate_mini_map_checkbox", gSavedSettings.getBOOL("MiniMapRotate")); + childSetValue("notify_money_change_checkbox", gSavedSettings.getBOOL("NotifyMoneyChange")); + childSetValue("use_system_color_picker_checkbox", gSavedSettings.getBOOL("UseDefaultColorPicker")); + childSetValue("show_search_panel", gSavedSettings.getBOOL("ShowSearchBar")); + + getChild("effect_color_swatch")->set(gSavedSettings.getColor4("EffectColor")); + + childSetValue("ui_scale_slider", gSavedSettings.getF32("UIScaleFactor")); + childSetValue("ui_auto_scale", gSavedSettings.getBOOL("UIAutoScale")); + + LLComboBox* crash_behavior_combobox = getChild("crash_behavior_combobox"); + crash_behavior_combobox->setCurrentByIndex(gCrashSettings.getS32(CRASH_BEHAVIOR_SETTING)); - childSetCommitCallback("language_combobox", set_language ); childSetValue("language_combobox", gSavedSettings.getString("Language")); - refresh(); - return TRUE; } @@ -160,83 +83,34 @@ LLPanelGeneral::~LLPanelGeneral() // Children all cleaned up by default view destructor. } -void LLPanelGeneral::refresh() -{ - LLPanel::refresh(); - BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation"); - LLComboBox* combo = getChild( "location_combobox"); - if (combo) - { - if (!LLURLSimString::sInstance.mSimString.empty()) - { - combo->setCurrentByIndex( 2 ); - } - else - { - combo->setCurrentByIndex( login_last ? 1 : 0 ); - } - //save current settings in case cancel is clicked - mLoginLocation = combo->getValue().asString(); - } - - mOldCrashBehavior = gCrashSettings.getS32(CRASH_BEHAVIOR_SETTING); - combo = getChild( "crash_behavior_combobox"); - if (combo) - { - combo->setCurrentByIndex( mOldCrashBehavior ); - } - - mRenderName = gSavedSettings.getS32("RenderName"); - combo = getChild("fade_out_combobox"); - if (combo) - { - combo->setCurrentByIndex( mRenderName ); - } - - mRenderNameHideSelf = gSavedSettings.getBOOL("RenderNameHideSelf"); - mSmallAvatarNames = gSavedSettings.getBOOL("SmallAvatarNames"); - mRenderHideGroupTitle = gSavedSettings.getBOOL("RenderHideGroupTitle"); - mChatOnlineNotification = gSavedSettings.getBOOL("ChatOnlineNotification"); - mAFKTimeout = gSavedSettings.getF32("AFKTimeout"); - mMiniMapRotate = gSavedSettings.getBOOL("MiniMapRotate"); - mNotifyMoney = gSavedSettings.getBOOL("NotifyMoneyChange"); - mUseDefaultColor = gSavedSettings.getBOOL("UseDefaultColorPicker"); - mEffectColor = gSavedSettings.getColor4("EffectColor"); - mShowSearch = gSavedSettings.getBOOL("ShowSearchBar"); - - mUIScaleFactor = gSavedSettings.getF32("UIScaleFactor"); - mUIAutoScale = gSavedSettings.getBOOL("UIAutoScale"); - - mLanguage = gSavedSettings.getString("Language"); -} - void LLPanelGeneral::apply() { -} - -void LLPanelGeneral::cancel() -{ - gSavedSettings.setS32("RenderName", mRenderName); - gSavedSettings.setBOOL("RenderNameHideSelf", mRenderNameHideSelf ); - gSavedSettings.setBOOL("SmallAvatarNames", mSmallAvatarNames ); - gSavedSettings.setBOOL("RenderHideGroupTitle", mRenderHideGroupTitle ); - gSavedSettings.setBOOL("ChatOnlineNotification", mChatOnlineNotification ); - gSavedSettings.setF32("AFKTimeout", mAFKTimeout ); - gSavedSettings.setBOOL("MiniMapRotate", mMiniMapRotate ); - gSavedSettings.setBOOL("NotifyMoneyChange", mNotifyMoney ); - gSavedSettings.setBOOL("UseDefaultColorPicker", mUseDefaultColor ); - gSavedSettings.setBOOL("ShowSearchBar", mShowSearch); - gSavedSettings.setColor4("EffectColor", mEffectColor ); - gSavedSettings.setF32("UIScaleFactor", mUIScaleFactor); - gSavedSettings.setBOOL("UIAutoScale", mUIAutoScale); - gSavedSettings.setString("Language", mLanguage); + LLComboBox* fade_out_combobox = getChild("fade_out_combobox"); + gSavedSettings.setS32("RenderName", fade_out_combobox->getCurrentIndex()); - LLURLSimString::setString(mLoginLocation); - - gCrashSettings.setS32(CRASH_BEHAVIOR_SETTING, mOldCrashBehavior); + gSavedSettings.setBOOL("LoginLastLocation", childGetValue("default_start_location").asString() == "MyLastLocation"); + gSavedSettings.setBOOL("ShowStartLocation", childGetValue("show_location_checkbox")); + gSavedSettings.setBOOL("RenderHideGroupTitleAll", childGetValue("show_all_title_checkbox")); + gSavedSettings.setBOOL("LanguageIsPublic", childGetValue("language_is_public")); + gSavedSettings.setBOOL("RenderNameHideSelf", childGetValue("show_my_name_checkbox")); + gSavedSettings.setBOOL("SmallAvatarNames", childGetValue("small_avatar_names_checkbox")); + gSavedSettings.setBOOL("RenderHideGroupTitle", childGetValue("show_my_title_checkbox")); + gSavedSettings.setF32("AFKTimeout", childGetValue("afk_timeout_spinner").asReal()); + gSavedSettings.setBOOL("MiniMapRotate", childGetValue("rotate_mini_map_checkbox")); + gSavedSettings.setBOOL("NotifyMoneyChange", childGetValue("notify_money_change_checkbox")); + gSavedSettings.setBOOL("UseDefaultColorPicker", childGetValue("use_system_color_picker_checkbox")); + gSavedSettings.setBOOL("ShowSearchBar", childGetValue("show_search_panel")); + gSavedSettings.setColor4("EffectColor", childGetValue("effect_color_swatch")); + gSavedSettings.setF32("UIScaleFactor", childGetValue("ui_scale_slider").asReal()); + gSavedSettings.setBOOL("UIAutoScale", childGetValue("ui_auto_scale")); + gSavedSettings.setString("Language", childGetValue("language_combobox")); + + LLURLSimString::setString(childGetValue("location_combobox")); + + LLComboBox* crash_behavior_combobox = getChild("crash_behavior_combobox"); + gCrashSettings.setS32(CRASH_BEHAVIOR_SETTING, crash_behavior_combobox->getCurrentIndex()); } -void LLPanelGeneral::clickShowStartLocation(LLUICtrl*, void* user_data) +void LLPanelGeneral::cancel() { - LLPanelLogin::refreshLocation( false ); // in case LLPanelLogin is visible } diff --git a/linden/indra/newview/llpanelgeneral.h b/linden/indra/newview/llpanelgeneral.h index a7b526d..5492a52 100644 --- a/linden/indra/newview/llpanelgeneral.h +++ b/linden/indra/newview/llpanelgeneral.h @@ -35,45 +35,16 @@ #include "llpanel.h" -class LLCheckBoxCtrl; -class LLRadioGroup; -class LLColorSwatchCtrl; -class LLSpinCtrl; -class LLTextBox; -class LLComboBox; - class LLPanelGeneral : public LLPanel { public: LLPanelGeneral(); - virtual ~LLPanelGeneral(); + /*virtual*/ ~LLPanelGeneral(); + + BOOL postBuild(); - virtual BOOL postBuild(); - void refresh(); void apply(); void cancel(); - - static void clickShowStartLocation(LLUICtrl*, void* user_data); - static void set_start_location(LLUICtrl* ctrl, void* data); - static void set_specific_start_location(LLLineEditor* line_editor, void* data); - -protected: - S32 mRenderName; - BOOL mRenderNameHideSelf; - BOOL mSmallAvatarNames; - BOOL mRenderHideGroupTitle; - BOOL mChatOnlineNotification; - BOOL mShowSearch; - F32 mAFKTimeout; - BOOL mNotifyMoney; - BOOL mUseDefaultColor; - LLColor4 mEffectColor; - F32 mUIScaleFactor; - BOOL mUIAutoScale; - BOOL mMiniMapRotate; - S32 mOldCrashBehavior; - std::string mLoginLocation; - std::string mLanguage; }; #endif diff --git a/linden/indra/newview/llpanelgrouplandmoney.cpp b/linden/indra/newview/llpanelgrouplandmoney.cpp index b8c9e69..6eb44e1 100644 --- a/linden/indra/newview/llpanelgrouplandmoney.cpp +++ b/linden/indra/newview/llpanelgrouplandmoney.cpp @@ -705,12 +705,13 @@ BOOL LLPanelGroupLandMoney::postBuild() textp = getChild("group_money_planning_text", true); panelp = getChild("group_money_planning_tab", true); - if ( !can_view ) + if ( 1 ) //!can_view { textp->setText(mImplementationp->mCantViewAccountsText); } else { + //Temporally disabled for DEV-11287. mImplementationp->mMoneyPlanningTabEHp = new LLGroupMoneyPlanningTabEventHandler(textp, tabcp, diff --git a/linden/indra/newview/llpanelinput.cpp b/linden/indra/newview/llpanelinput.cpp index 7034b1c..026dd71 100644 --- a/linden/indra/newview/llpanelinput.cpp +++ b/linden/indra/newview/llpanelinput.cpp @@ -30,46 +30,10 @@ */ #include "llviewerprecompiledheaders.h" - #include "llpanelinput.h" - -// linden library includes -#include "llerror.h" -#include "llrect.h" -#include "llfontgl.h" -#include "message.h" #include "lluictrlfactory.h" - -// project includes -#include "llviewerwindow.h" -#include "llcheckboxctrl.h" -#include "llfloaterjoystick.h" -#include "llradiogroup.h" -#include "llresmgr.h" -#include "llspinctrl.h" -#include "llslider.h" -#include "llsliderctrl.h" -#include "lltextbox.h" -#include "llui.h" -#include "llappviewer.h" #include "llviewercontrol.h" - -//Ventrella -#include "llagent.h" -//end Ventrella - - -// -// Imported globals -// - -// -// Globals -// - -// -// Static functions -// +#include "llfloaterjoystick.h" LLPanelInput::LLPanelInput() @@ -79,50 +43,41 @@ LLPanelInput::LLPanelInput() BOOL LLPanelInput::postBuild() { - childSetAction("joystic_setup_button", onClickJoystickSetup, (void*)this); - - refresh(); + childSetAction("joystick_setup_button", onClickJoystickSetup, (void*)this); + + childSetValue("mouse_sensitivity", gSavedSettings.getF32("MouseSensitivity")); + childSetValue("automatic_fly", gSavedSettings.getBOOL("AutomaticFly")); + childSetValue("invert_mouse", gSavedSettings.getBOOL("InvertMouse")); + childSetValue("edit_camera_movement", gSavedSettings.getBOOL("EditCameraMovement")); + childSetValue("appearance_camera_movement", gSavedSettings.getBOOL("AppearanceCameraMovement")); + childSetValue("dynamic_camera_strength", gSavedSettings.getF32("DynamicCameraStrength")); + childSetValue("zoom_time", gSavedSettings.getF32("ZoomTime")); + childSetValue("camera_position_smoothing", gSavedSettings.getF32("CameraPositionSmoothing")); + childSetValue("first_person_avatar_visible", gSavedSettings.getBOOL("FirstPersonAvatarVisible")); return TRUE; } - LLPanelInput::~LLPanelInput() { // Children all cleaned up by default view destructor. } -void LLPanelInput::refresh() -{ - LLPanel::refresh(); - - mMouseSensitivityVal = gSavedSettings.getF32("MouseSensitivity"); - mAutomaticFly =gSavedSettings.getBOOL("AutomaticFly"); - mInvertMouse = gSavedSettings.getBOOL("InvertMouse"); - mEditCameraMovement = gSavedSettings.getBOOL("EditCameraMovement"); - mAppearanceCameraMovement = gSavedSettings.getBOOL("AppearanceCameraMovement"); - mDynamicCameraStrengthVal = gSavedSettings.getF32("DynamicCameraStrength"); - mNumpadControlVal = gSavedSettings.getS32("NumpadControl"); - - // First Person Visibility - mFirstPersonAvatarVisible = gSavedSettings.getBOOL("FirstPersonAvatarVisible"); -} - void LLPanelInput::apply() { - + gSavedSettings.setF32("MouseSensitivity", childGetValue("mouse_sensitivity").asReal()); + gSavedSettings.setBOOL("AutomaticFly", childGetValue("automatic_fly")); + gSavedSettings.setBOOL("InvertMouse", childGetValue("invert_mouse")); + gSavedSettings.setBOOL("EditCameraMovement", childGetValue("edit_camera_movement")); + gSavedSettings.setBOOL("AppearanceCameraMovement", childGetValue("appearance_camera_movement")); + gSavedSettings.setF32("DynamicCameraStrength", childGetValue("dynamic_camera_strength").asReal()); + gSavedSettings.setF32("ZoomTime", childGetValue("zoom_time").asReal()); + gSavedSettings.setF32("CameraPositionSmoothing", childGetValue("camera_position_smoothing").asReal()); + gSavedSettings.setBOOL("FirstPersonAvatarVisible", childGetValue("first_person_avatar_visible")); } void LLPanelInput::cancel() { - gSavedSettings.setF32("MouseSensitivity", mMouseSensitivityVal); - gSavedSettings.setBOOL("AutomaticFly", mAutomaticFly); - gSavedSettings.setBOOL("InvertMouse", mInvertMouse); - gSavedSettings.setBOOL("EditCameraMovement", mEditCameraMovement); - gSavedSettings.setBOOL("AppearanceCameraMovement", mAppearanceCameraMovement); - gSavedSettings.setF32("DynamicCameraStrength", mDynamicCameraStrengthVal); - gSavedSettings.setS32("NumpadControl", mNumpadControlVal); - gSavedSettings.setBOOL("FirstPersonAvatarVisible", mFirstPersonAvatarVisible); } //static diff --git a/linden/indra/newview/llpanelinput.h b/linden/indra/newview/llpanelinput.h index e73e0ed..2f99f99 100644 --- a/linden/indra/newview/llpanelinput.h +++ b/linden/indra/newview/llpanelinput.h @@ -34,11 +34,6 @@ #include "llpanel.h" -class LLCheckBoxCtrl; -class LLSlider; -class LLSliderCtrl; -class LLSpinCtrl; - class LLPanelInput : public LLPanel { public: @@ -46,23 +41,11 @@ public: virtual ~LLPanelInput(); virtual BOOL postBuild(); - virtual void refresh(); void apply(); void cancel(); private: static void onClickJoystickSetup(void* user_data); - -protected: - F32 mMouseSensitivityVal; - BOOL mAutomaticFly; - BOOL mInvertMouse; - BOOL mEditCameraMovement; - BOOL mAppearanceCameraMovement; - BOOL mFirstPersonAvatarVisible; - F32 mDynamicCameraStrengthVal; - S32 mNumpadControlVal; - }; #endif diff --git a/linden/indra/newview/llpanellogin.cpp b/linden/indra/newview/llpanellogin.cpp index ffee058..c1c8949 100644 --- a/linden/indra/newview/llpanellogin.cpp +++ b/linden/indra/newview/llpanellogin.cpp @@ -63,7 +63,6 @@ #include "llviewernetwork.h" #include "llviewerwindow.h" // to link into child list #include "llnotify.h" -#include "llappviewer.h" // for gHideLinks #include "llurlsimstring.h" #include "lluictrlfactory.h" #include "llhttpclient.h" @@ -202,6 +201,26 @@ void LLLoginHandler::parse(const LLSD& queryMap) { grid_choice = GRID_INFO_ARUNA; } + else if (queryMap["grid"].asString() == "bharati") + { + grid_choice = GRID_INFO_BHARATI; + } + else if (queryMap["grid"].asString() == "chandra") + { + grid_choice = GRID_INFO_CHANDRA; + } + else if (queryMap["grid"].asString() == "danu") + { + grid_choice = GRID_INFO_DANU; + } + else if (queryMap["grid"].asString() == "parvati") + { + grid_choice = GRID_INFO_PARVATI; + } + else if (queryMap["grid"].asString() == "skanda") + { + grid_choice = GRID_INFO_SKANDA; + } if(grid_choice != GRID_INFO_NONE) { @@ -321,6 +340,11 @@ namespace { boost::intrusive_ptr< LLIamHereLogin > gResponsePtr = 0; }; +void set_start_location(LLUICtrl* ctrl, void* data) +{ + LLURLSimString::setString(ctrl->getValue().asString()); +} + //--------------------------------------------------------------------------- // Public methods //--------------------------------------------------------------------------- @@ -407,7 +431,7 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, combo->setCurrentByIndex( 0 ); } - combo->setCommitCallback( &LLPanelGeneral::set_start_location ); + combo->setCommitCallback( &set_start_location ); LLComboBox* server_choice_combo = sInstance->getChild("server_combo"); server_choice_combo->setCommitCallback(onSelectServer); @@ -1066,15 +1090,8 @@ void LLPanelLogin::onClickConnect(void *) } else { - if (gHideLinks) - { - gViewerWindow->alertXml("MustHaveAccountToLogInNoLinks"); - } - else - { - gViewerWindow->alertXml("MustHaveAccountToLogIn", - LLPanelLogin::newAccountAlertCallback); - } + gViewerWindow->alertXml("MustHaveAccountToLogIn", + LLPanelLogin::newAccountAlertCallback); } } } diff --git a/linden/indra/newview/llpanelmsgs.cpp b/linden/indra/newview/llpanelmsgs.cpp index cc3579e..4d2ff54 100644 --- a/linden/indra/newview/llpanelmsgs.cpp +++ b/linden/indra/newview/llpanelmsgs.cpp @@ -39,17 +39,6 @@ #include "lluictrlfactory.h" #include "llfirstuse.h" -class LLPopupData -{ -public: - LLPopupData() : mShowNewInventory(FALSE), mAutoAcceptNewInventory(FALSE) { } - - BOOL mShowNewInventory; - BOOL mAutoAcceptNewInventory; -}; - -LLPopupData sPopupData; - //----------------------------------------------------------------------------- LLPanelMsgs::LLPanelMsgs() : LLPanel(std::string("Messages Panel")), @@ -75,8 +64,9 @@ BOOL LLPanelMsgs::postBuild() childSetAction("skip_dialogs_btn", onClickSkipDialogs, this); buildLists(); - sPopupData.mAutoAcceptNewInventory = gSavedSettings.getBOOL("AutoAcceptNewInventory"); - sPopupData.mShowNewInventory = gSavedSettings.getBOOL("ShowNewInventory"); + childSetValue("accept_new_inventory", gSavedSettings.getBOOL("AutoAcceptNewInventory")); + childSetValue("show_new_inventory", gSavedSettings.getBOOL("ShowNewInventory")); + childSetValue("show_in_inventory", gSavedSettings.getBOOL("ShowInInventory")); return TRUE; } @@ -159,13 +149,13 @@ void LLPanelMsgs::draw() void LLPanelMsgs::apply() { + gSavedSettings.setBOOL("AutoAcceptNewInventory", childGetValue("accept_new_inventory")); + gSavedSettings.setBOOL("ShowNewInventory", childGetValue("show_new_inventory")); + gSavedSettings.setBOOL("ShowInInventory", childGetValue("show_in_inventory")); } - void LLPanelMsgs::cancel() { - gSavedSettings.setBOOL("ShowNewInventory", sPopupData.mShowNewInventory); - gSavedSettings.setBOOL("AutoAcceptNewInventory", sPopupData.mAutoAcceptNewInventory); } void LLPanelMsgs::resetAllIgnored() diff --git a/linden/indra/newview/llpanelnetwork.cpp b/linden/indra/newview/llpanelnetwork.cpp index e324c3b..f13f63a 100644 --- a/linden/indra/newview/llpanelnetwork.cpp +++ b/linden/indra/newview/llpanelnetwork.cpp @@ -31,29 +31,14 @@ #include "llviewerprecompiledheaders.h" -// file include +//file include #include "llpanelnetwork.h" -// linden library includes -#include "llerror.h" -#include "llrect.h" -#include "llstring.h" - // project includes -#include "llbutton.h" +#include "llcheckboxctrl.h" #include "lldirpicker.h" -#include "llui.h" #include "lluictrlfactory.h" -#include "llresmgr.h" -#include "llsliderctrl.h" -#include "llspinctrl.h" -#include "llcheckboxctrl.h" -#include "lltextbox.h" -#include "llviewerregion.h" -#include "llviewerthrottle.h" -#include "llworld.h" #include "llviewercontrol.h" -#include "lluictrlfactory.h" #include "llviewerwindow.h" LLPanelNetwork::LLPanelNetwork() @@ -70,12 +55,13 @@ BOOL LLPanelNetwork::postBuild() childSetAction("set_cache", onClickSetCache, this); childSetAction("reset_cache", onClickResetCache, this); - childSetEnabled("connection_port", - gSavedSettings.getBOOL("ConnectionPortEnabled")); + childSetEnabled("connection_port", gSavedSettings.getBOOL("ConnectionPortEnabled")); childSetCommitCallback("connection_port_enabled", onCommitPort, this); - - refresh(); + childSetValue("cache_size", (F32)gSavedSettings.getU32("CacheSize")); + childSetValue("max_bandwidth", gSavedSettings.getF32("ThrottleBandwidthKBPS")); + childSetValue("connection_port_enabled", gSavedSettings.getBOOL("ConnectionPortEnabled")); + childSetValue("connection_port", (F32)gSavedSettings.getU32("ConnectionPort")); return TRUE; } @@ -88,24 +74,14 @@ LLPanelNetwork::~LLPanelNetwork() void LLPanelNetwork::apply() { -} - -void LLPanelNetwork::refresh() -{ - LLPanel::refresh(); - - mCacheSetting = gSavedSettings.getU32("CacheSize"); - mBandwidthBPS = gSavedSettings.getF32("ThrottleBandwidthKBPS")*1024; - mConnectionPortEnabled = gSavedSettings.getBOOL("ConnectionPortEnabled"); - mConnectionPort = gSavedSettings.getU32("ConnectionPort"); + gSavedSettings.setU32("CacheSize", childGetValue("cache_size").asInteger()); + gSavedSettings.setF32("ThrottleBandwidthKBPS", childGetValue("max_bandwidth").asReal()); + gSavedSettings.setBOOL("ConnectionPortEnabled", childGetValue("connection_port_enabled")); + gSavedSettings.setU32("ConnectionPort", childGetValue("connection_port").asInteger()); } void LLPanelNetwork::cancel() { - gSavedSettings.setU32("CacheSize", mCacheSetting); - gSavedSettings.setF32("ThrottleBandwidthKBPS", mBandwidthBPS/1024); - gSavedSettings.setBOOL("ConnectionPortEnabled", mConnectionPortEnabled); - gSavedSettings.setU32("ConnectionPort", mConnectionPort); } // static diff --git a/linden/indra/newview/llpanelnetwork.h b/linden/indra/newview/llpanelnetwork.h index 9848461..e4b11d9 100644 --- a/linden/indra/newview/llpanelnetwork.h +++ b/linden/indra/newview/llpanelnetwork.h @@ -33,37 +33,23 @@ #define LL_LLPANELNETWORK_H #include "llpanel.h" -#include "llviewerthrottle.h" - -class LLSliderCtrl; -class LLCheckBoxCtrl; -class LLLineEditor; -class LLTextBox; -class LLRadioGroup; -class LLButton; class LLPanelNetwork : public LLPanel { public: LLPanelNetwork(); - virtual ~LLPanelNetwork(); + ~LLPanelNetwork(); + + BOOL postBuild(); - virtual BOOL postBuild(); - virtual void refresh(); - virtual void apply(); // Apply the changed values. - virtual void cancel(); // Cancel the changed values. + void apply(); + void cancel(); private: static void onClickClearCache(void*); static void onClickSetCache(void*); static void onClickResetCache(void*); static void onCommitPort(LLUICtrl* ctrl, void*); - -private: - U32 mCacheSetting; - F32 mBandwidthBPS; - BOOL mConnectionPortEnabled; - U32 mConnectionPort; }; #endif diff --git a/linden/indra/newview/llpanelobject.cpp b/linden/indra/newview/llpanelobject.cpp index 9022c14..1f386bf 100644 --- a/linden/indra/newview/llpanelobject.cpp +++ b/linden/indra/newview/llpanelobject.cpp @@ -365,6 +365,17 @@ void LLPanelObject::getState( ) BOOL enable_scale = objectp->permMove() && objectp->permModify(); BOOL enable_rotate = objectp->permMove() && ( (objectp->permModify() && !objectp->isAttachment()) || !gSavedSettings.getBOOL("EditLinkedParts")); + S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); + BOOL single_volume = (LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME )) + && (selected_count == 1); + + if (LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() > 1) + { + enable_move = FALSE; + enable_scale = FALSE; + enable_rotate = FALSE; + } + LLVector3 vec; if (enable_move) { @@ -438,9 +449,6 @@ void LLPanelObject::getState( ) // BUG? Check for all objects being editable? S32 roots_selected = LLSelectMgr::getInstance()->getSelection()->getRootObjectCount(); BOOL editable = root_objectp->permModify(); - S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); - BOOL single_volume = (LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME )) - && (selected_count == 1); // Select Single Message childSetVisible("select_single", FALSE); diff --git a/linden/indra/newview/llpanelweb.cpp b/linden/indra/newview/llpanelweb.cpp index 13ed9bf..101decd 100644 --- a/linden/indra/newview/llpanelweb.cpp +++ b/linden/indra/newview/llpanelweb.cpp @@ -34,22 +34,12 @@ // file include #include "llpanelweb.h" -// linden library includes -#include "llerror.h" -#include "llrect.h" -#include "llstring.h" - // project includes -#include "llbutton.h" #include "llcheckboxctrl.h" -#include "lllineeditor.h" -#include "llui.h" +#include "llmediamanager.h" #include "lluictrlfactory.h" #include "llviewercontrol.h" -#include "lluictrlfactory.h" #include "llviewerwindow.h" -#include "llmediamanager.h" - // helper functions for getting/freeing the web browser media // if creating/destroying these is too slow, we'll need to create @@ -97,23 +87,21 @@ LLPanelWeb::LLPanelWeb() BOOL LLPanelWeb::postBuild() { - childSetAction( "clear_cache", onClickClearCache, this ); - childSetAction( "clear_cookies", onClickClearCookies, this ); - childSetCommitCallback("use_external_browser", onSelectBrowser, this ); -// childSetEnabled( "connection_port", gSavedSettings.getBOOL( "CookiesEnabled" ) ); - childSetCommitCallback( "cookies_enabled", onCommitCookies, this ); - childSetCommitCallback( "web_proxy_editor", onCommitWebProxyAddress, this); - childSetCommitCallback( "web_proxy_port", onCommitWebProxyPort, this); - - childSetEnabled("web_proxy_editor", - gSavedSettings.getBOOL("BrowserProxyEnabled")); - childSetEnabled("web_proxy_port", - gSavedSettings.getBOOL("BrowserProxyEnabled")); - childSetEnabled("proxy_text_label", - gSavedSettings.getBOOL("BrowserProxyEnabled")); + childSetAction("clear_cache", onClickClearCache, this); childSetCommitCallback("web_proxy_enabled", onCommitWebProxyEnabled, this); - refresh(); + std::string value = gSavedSettings.getBOOL("UseExternalBrowser") ? "external" : "internal"; + childSetValue("use_external_browser", value); + + childSetValue("cookies_enabled", gSavedSettings.getBOOL("CookiesEnabled")); + + childSetValue("web_proxy_enabled", gSavedSettings.getBOOL("BrowserProxyEnabled")); + childSetValue("web_proxy_editor", gSavedSettings.getString("BrowserProxyAddress")); + childSetValue("web_proxy_port", gSavedSettings.getS32("BrowserProxyPort")); + + childSetEnabled("proxy_text_label", gSavedSettings.getBOOL("BrowserProxyEnabled")); + childSetEnabled("web_proxy_editor", gSavedSettings.getBOOL("BrowserProxyEnabled")); + childSetEnabled("web_proxy_port", gSavedSettings.getBOOL("BrowserProxyEnabled")); return TRUE; } @@ -127,50 +115,29 @@ LLPanelWeb::~LLPanelWeb() void LLPanelWeb::apply() { -} - -void LLPanelWeb::refresh() -{ - LLPanel::refresh(); + gSavedSettings.setBOOL("CookiesEnabled", childGetValue("cookies_enabled")); + gSavedSettings.setBOOL("BrowserProxyEnabled", childGetValue("web_proxy_enabled")); + gSavedSettings.setString("BrowserProxyAddress", childGetValue("web_proxy_editor")); + gSavedSettings.setS32("BrowserProxyPort", childGetValue("web_proxy_port")); - mCookiesEnabled = gSavedSettings.getBOOL("CookiesEnabled"); - mWebProxyEnabled = gSavedSettings.getBOOL("BrowserProxyEnabled"); - mWebProxyAddress = gSavedSettings.getString("BrowserProxyAddress"); - mWebProxyPort = gSavedSettings.getS32("BrowserProxyPort"); + bool value = childGetValue("use_external_browser").asString() == "external" ? true : false; + gSavedSettings.setBOOL("UseExternalBrowser", value); - LLLineEditor* web_proxy_editor = getChild("web_proxy_editor"); - if (web_proxy_editor) - { - web_proxy_editor->setText( gSavedSettings.getString("BrowserProxyAddress") ); - } - mExternalBrowser = gSavedSettings.getBOOL("UseExternalBrowser"); - - childSetValue("use_external_browser", mExternalBrowser ? "external" : "internal"); - LLMediaBase *media_source = get_web_media(); if (media_source) - media_source->enableCookies(mCookiesEnabled); - free_web_media(media_source); + { + media_source->enableCookies(childGetValue("cookies_enabled")); + bool proxy_enable = childGetValue("web_proxy_enabled"); + std::string proxy_address = childGetValue("web_proxy_editor"); + int proxy_port = childGetValue("web_proxy_port"); + media_source->enableProxy(proxy_enable, proxy_address, proxy_port); + } + free_web_media(media_source); } void LLPanelWeb::cancel() { - - gSavedSettings.setBOOL( "CookiesEnabled", mCookiesEnabled ); - gSavedSettings.setBOOL( "BrowserProxyEnabled", mWebProxyEnabled ); - gSavedSettings.setString( "BrowserProxyAddress", mWebProxyAddress ); - gSavedSettings.setS32( "BrowserProxyPort", mWebProxyPort ); - - gSavedSettings.setBOOL("UseExternalBrowser", mExternalBrowser); - LLMediaBase *media_source = get_web_media(); - if (media_source) - { - media_source->enableCookies(mCookiesEnabled); - media_source->enableProxy( mWebProxyEnabled, mWebProxyAddress, mWebProxyPort ); - } - free_web_media(media_source); - } // static @@ -192,94 +159,15 @@ void LLPanelWeb::callback_clear_browser_cache(S32 option, void* userdata) } // static -void LLPanelWeb::onClickClearCookies(void*) -{ - gViewerWindow->alertXml("ConfirmClearCookies", callback_clear_cookies, 0); -} - -//static -void LLPanelWeb::callback_clear_cookies(S32 option, void* userdata) -{ - if ( option == 0 ) // YES - { - LLMediaBase *media_source = get_web_media(); - if (media_source) - media_source->clearCookies(); - free_web_media(media_source); - } -} - -// static -void LLPanelWeb::onCommitCookies(LLUICtrl* ctrl, void* data) -{ - LLPanelWeb* self = (LLPanelWeb*)data; - LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl; - - if (!self || !check) return; - - LLMediaBase *media_source = get_web_media(); - if (media_source) - media_source->enableCookies(check->get()); - free_web_media(media_source); -} -// static void LLPanelWeb::onCommitWebProxyEnabled(LLUICtrl* ctrl, void* data) { LLPanelWeb* self = (LLPanelWeb*)data; LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl; if (!self || !check) return; - self->childSetEnabled("web_proxy_editor", - check->get()); - self->childSetEnabled("web_proxy_port", - check->get()); - self->childSetEnabled("proxy_text_label", - check->get()); - - LLMediaBase *media_source = get_web_media(); - if (media_source) - { - media_source->enableProxy( gSavedSettings.getBOOL("BrowserProxyEnabled"), - gSavedSettings.getString("BrowserProxyAddress"), - gSavedSettings.getS32("BrowserProxyPort") ); - } - free_web_media(media_source); - -} - -void LLPanelWeb::onCommitWebProxyAddress(LLUICtrl *ctrl, void *userdata) -{ - LLLineEditor* web_proxy = (LLLineEditor*)ctrl; - - if (web_proxy) - { - gSavedSettings.setString("BrowserProxyAddress", web_proxy->getText()); - } - LLMediaBase *media_source = get_web_media(); - if (media_source) - { - media_source->enableProxy( gSavedSettings.getBOOL("BrowserProxyEnabled"), - gSavedSettings.getString("BrowserProxyAddress"), - gSavedSettings.getS32("BrowserProxyPort") ); - } - free_web_media(media_source); -} + self->childSetEnabled("web_proxy_editor", check->get()); + self->childSetEnabled("web_proxy_port", check->get()); + self->childSetEnabled("proxy_text_label", check->get()); -void LLPanelWeb::onCommitWebProxyPort(LLUICtrl *ctrl, void *userdata) -{ - LLMediaBase *media_source = get_web_media(); - if (media_source) - { - media_source->enableProxy( gSavedSettings.getBOOL("BrowserProxyEnabled"), - gSavedSettings.getString("BrowserProxyAddress"), - gSavedSettings.getS32("BrowserProxyPort") ); - } - free_web_media(media_source); -} -// static -void LLPanelWeb::onSelectBrowser(LLUICtrl* ctrl, void* data) -{ - // "external" or "internal" - gSavedSettings.setBOOL("UseExternalBrowser", ctrl->getValue().asString() == "external"); } diff --git a/linden/indra/newview/llpanelweb.h b/linden/indra/newview/llpanelweb.h index 34d7b3d..fc8cf28 100644 --- a/linden/indra/newview/llpanelweb.h +++ b/linden/indra/newview/llpanelweb.h @@ -33,39 +33,22 @@ #define LL_LLPANELWEB_H #include "llpanel.h" -#include "llviewerthrottle.h" - -class LLCheckBoxCtrl; -class LLButton; class LLPanelWeb : public LLPanel { public: LLPanelWeb(); - virtual ~LLPanelWeb(); + ~LLPanelWeb(); + + BOOL postBuild(); - virtual BOOL postBuild(); - virtual void refresh(); - virtual void apply(); // Apply the changed values. - virtual void cancel(); // Cancel the changed values. + void apply(); + void cancel(); private: - static void onClickClearCache(void*); - static void onClickClearCookies(void*); + static void onClickClearCache(void* data); static void callback_clear_browser_cache(S32 option, void* userdata); - static void callback_clear_cookies(S32 option, void* userdata); - static void onCommitCookies(LLUICtrl* ctrl, void* data); static void onCommitWebProxyEnabled(LLUICtrl* ctrl, void* data); - static void onCommitWebProxyAddress(LLUICtrl *ctrl, void *userdata); - static void onCommitWebProxyPort(LLUICtrl *ctrl, void *userdata); - static void onSelectBrowser(LLUICtrl* ctrl, void* data); - -private: - BOOL mCookiesEnabled; - BOOL mWebProxyEnabled; - std::string mWebProxyAddress; - S32 mWebProxyPort; - BOOL mExternalBrowser; }; #endif diff --git a/linden/indra/newview/llpolymesh.h b/linden/indra/newview/llpolymesh.h index 7f4f087..671bf03 100644 --- a/linden/indra/newview/llpolymesh.h +++ b/linden/indra/newview/llpolymesh.h @@ -150,7 +150,7 @@ public: class LLJointRenderData { public: - LLJointRenderData(const LLMatrix4* world_matrix, LLSkinJoint* skin_joint) : mWorldMatrix(world_matrix), mSkinJoint(skin_joint){} + LLJointRenderData(const LLMatrix4* world_matrix, LLSkinJoint* skin_joint) : mWorldMatrix(world_matrix), mSkinJoint(skin_joint) {} ~LLJointRenderData(){} const LLMatrix4* mWorldMatrix; diff --git a/linden/indra/newview/llprefschat.cpp b/linden/indra/newview/llprefschat.cpp index e045e61..139a365 100644 --- a/linden/indra/newview/llprefschat.cpp +++ b/linden/indra/newview/llprefschat.cpp @@ -36,6 +36,8 @@ #include "lltexteditor.h" #include "llviewercontrol.h" #include "lluictrlfactory.h" +#include "llcolorswatch.h" +#include "llradiogroup.h" #include "llstylemap.h" class LLPrefsChatImpl : public LLPanel @@ -43,8 +45,6 @@ class LLPrefsChatImpl : public LLPanel public: LLPrefsChatImpl(); /*virtual*/ ~LLPrefsChatImpl(){}; - - virtual void refresh(); void apply(); void cancel(); @@ -79,12 +79,30 @@ LLPrefsChatImpl::LLPrefsChatImpl() { LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_chat.xml"); - refresh(); -} + getChild("chat_font_size")->setSelectedIndex(gSavedSettings.getS32("ChatFontSize")); + childSetValue("fade_chat_time", gSavedSettings.getF32("ChatPersistTime")); + childSetValue("max_chat_count", gSavedSettings.getS32("ConsoleMaxLines")); + + getChild("system")->set(gSavedSettings.getColor4("SystemChatColor")); + getChild("user")->set(gSavedSettings.getColor4("UserChatColor")); + getChild("agent")->set(gSavedSettings.getColor4("AgentChatColor")); + getChild("im")->set(gSavedSettings.getColor4("IMChatColor")); + getChild("script_error")->set(gSavedSettings.getColor4("ScriptErrorColor")); + getChild("objects")->set(gSavedSettings.getColor4("ObjectChatColor")); + getChild("owner")->set(gSavedSettings.getColor4("llOwnerSayChatColor")); + getChild("background")->set(gSavedSettings.getColor4("BackgroundChatColor")); + getChild("links")->set(gSavedSettings.getColor4("HTMLLinkColor")); + + childSetValue("arrow_keys_move_avatar_check", gSavedSettings.getBOOL("ArrowKeysMoveAvatar")); + childSetValue("show_timestamps_check", gSavedSettings.getBOOL("ChatShowTimestamps")); + childSetValue("script_errors_as_chat", gSavedSettings.getBOOL("ScriptErrorsAsChat")); -void LLPrefsChatImpl::refresh() -{ - LLPanel::refresh(); + childSetValue("bubble_text_chat", gSavedSettings.getBOOL("UseChatBubbles")); + childSetValue("chat_full_width_check", gSavedSettings.getBOOL("ChatFullWidth")); + childSetValue("close_chat_on_return_check", gSavedSettings.getBOOL("CloseChatOnReturn")); + childSetValue("play_typing_animation", gSavedSettings.getBOOL("PlayTypingAnim")); + childSetValue("console_opacity", gSavedSettings.getF32("ConsoleBackgroundOpacity")); + childSetValue("bubble_chat_opacity", gSavedSettings.getF32("ChatBubbleOpacity")); //set values mChatSize = gSavedSettings.getS32("ChatFontSize"); @@ -137,7 +155,32 @@ void LLPrefsChatImpl::cancel() void LLPrefsChatImpl::apply() { - + gSavedSettings.setS32("ChatFontSize", getChild("chat_font_size")->getSelectedIndex()); + gSavedSettings.setF32("ChatPersistTime", childGetValue("fade_chat_time").asReal()); + gSavedSettings.setS32("ConsoleMaxLines", childGetValue("max_chat_count")); + + gSavedSettings.setColor4("SystemChatColor", childGetValue("system")); + gSavedSettings.setColor4("UserChatColor", childGetValue("user")); + gSavedSettings.setColor4("AgentChatColor", childGetValue("agent")); + gSavedSettings.setColor4("IMChatColor", childGetValue("im")); + gSavedSettings.setColor4("ScriptErrorColor", childGetValue("script_error")); + gSavedSettings.setColor4("ObjectChatColor", childGetValue("objects")); + gSavedSettings.setColor4("llOwnerSayChatColor", childGetValue("owner")); + gSavedSettings.setColor4("BackgroundChatColor", childGetValue("background")); + + gSavedSettings.setColor4("HTMLLinkColor", childGetValue("links")); + LLTextEditor::setLinkColor(childGetValue("links")); + + gSavedSettings.setBOOL("ArrowKeysMoveAvatar", childGetValue("arrow_keys_move_avatar_check")); + gSavedSettings.setBOOL("ChatShowTimestamps", childGetValue("show_timestamps_check")); + gSavedSettings.setBOOL("ScriptErrorsAsChat", childGetValue("script_errors_as_chat")); + gSavedSettings.setBOOL("UseChatBubbles", childGetValue("bubble_text_chat")); + gSavedSettings.setBOOL("ChatFullWidth", childGetValue("chat_full_width_check")); + gSavedSettings.setBOOL("CloseChatOnReturn", childGetValue("close_chat_on_return_check")); + gSavedSettings.setBOOL("PlayTypingAnim", childGetValue("play_typing_animation")); + + gSavedSettings.setF32("ConsoleBackgroundOpacity", childGetValue("console_opacity").asReal()); + gSavedSettings.setF32("ChatBubbleOpacity", childGetValue("bubble_chat_opacity").asReal()); } //--------------------------------------------------------------------------- @@ -154,7 +197,6 @@ LLPrefsChat::~LLPrefsChat() void LLPrefsChat::apply() { impl.apply(); - LLTextEditor::setLinkColor( gSavedSettings.getColor4("HTMLLinkColor") ); LLStyleMap::instance().update(); } diff --git a/linden/indra/newview/llprefsim.cpp b/linden/indra/newview/llprefsim.cpp index 5333df8..6673a4e 100644 --- a/linden/indra/newview/llprefsim.cpp +++ b/linden/indra/newview/llprefsim.cpp @@ -55,34 +55,18 @@ public: /*virtual*/ BOOL postBuild(); void apply(); - void refresh(); void cancel(); - void setPersonalInfo( - const std::string& visibility, - bool im_via_email, - const std::string& email); + void setPersonalInfo(const std::string& visibility, bool im_via_email, const std::string& email); void enableHistory(); + static void onClickLogPath(void* user_data); - static void onCommitLogging( LLUICtrl* ctrl, void* user_data); + static void onCommitLogging(LLUICtrl* ctrl, void* user_data); protected: - BOOL mIMInChatHistory; - BOOL mLogInstantMessages; - BOOL mLogChat; - BOOL mLogShowHistory; - BOOL mShowTimestamps; - BOOL mIMLogTimestamp; - BOOL mLogChatTimestamp; - BOOL mLogIMChat; - BOOL mLogTimestampDate; - - std::string mIMBusyResponse; - std::string mLogPath; - + bool mGotPersonalInfo; bool mOriginalIMViaEmail; - // online status info bool mOriginalHideOnlineStatus; std::string mDirectoryVisibility; }; @@ -94,34 +78,8 @@ LLPrefsIMImpl::LLPrefsIMImpl() LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_im.xml"); } -void LLPrefsIMImpl::refresh() -{ - mIMInChatHistory = gSavedSettings.getBOOL("IMInChatHistory"); - mShowTimestamps = gSavedSettings.getBOOL("IMShowTimestamps"); - mIMBusyResponse = gSavedPerAccountSettings.getString("BusyModeResponse"); - mLogPath = gSavedPerAccountSettings.getString("InstantMessageLogPath"); - mLogInstantMessages= gSavedPerAccountSettings.getBOOL("LogInstantMessages"); - mLogChat = gSavedPerAccountSettings.getBOOL("LogChat"); - mLogShowHistory = gSavedPerAccountSettings.getBOOL("LogShowHistory"); - mIMLogTimestamp = gSavedPerAccountSettings.getBOOL("IMLogTimestamp"); - mLogChatTimestamp = gSavedPerAccountSettings.getBOOL("LogChatTimestamp"); - mLogIMChat = gSavedPerAccountSettings.getBOOL("LogChatIM"); - mLogTimestampDate = gSavedPerAccountSettings.getBOOL("LogTimestampDate"); -} - void LLPrefsIMImpl::cancel() { - gSavedSettings.setBOOL("IMInChatHistory", mIMInChatHistory); - gSavedSettings.setBOOL("IMShowTimestamps", mShowTimestamps); - gSavedPerAccountSettings.setString("BusyModeResponse", mIMBusyResponse); - gSavedPerAccountSettings.setString("InstantMessageLogPath",mLogPath); - gSavedPerAccountSettings.setBOOL("LogInstantMessages",mLogInstantMessages); - gSavedPerAccountSettings.setBOOL("LogChat",mLogChat); - gSavedPerAccountSettings.setBOOL("LogShowHistory",mLogShowHistory); - gSavedPerAccountSettings.setBOOL("IMLogTimestamp",mIMLogTimestamp); - gSavedPerAccountSettings.setBOOL("LogChatTimestamp",mLogChatTimestamp); - gSavedPerAccountSettings.setBOOL("LogChatIM",mLogIMChat); - gSavedPerAccountSettings.setBOOL("LogTimestampDate",mLogTimestampDate); } BOOL LLPrefsIMImpl::postBuild() @@ -133,12 +91,13 @@ BOOL LLPrefsIMImpl::postBuild() return FALSE; } - mGotPersonalInfo = false; - mOriginalIMViaEmail = false; - mOriginalHideOnlineStatus = true; childSetLabelArg("send_im_to_email", "[EMAIL]", getString("log_in_to_change")); // Don't enable this until we get personal data + childDisable("include_im_in_chat_history"); + childDisable("show_timestamps_check"); + childDisable("friends_online_notify_checkbox"); + childDisable("online_visibility"); childDisable("send_im_to_email"); childDisable("log_instant_messages"); @@ -152,17 +111,20 @@ BOOL LLPrefsIMImpl::postBuild() childDisable("log_date_timestamp"); childSetText("busy_response", getString("log_in_to_change")); - - refresh(); - - childSetText("log_path_string", mLogPath); - childSetValue("log_instant_messages", mLogInstantMessages); - childSetValue("log_chat", mLogChat); - childSetValue("log_show_history", mLogShowHistory); - childSetValue("log_instant_messages_timestamp", mIMLogTimestamp); - childSetValue("log_chat_timestamp", mLogChatTimestamp); - childSetValue("log_chat_IM", mLogIMChat); - childSetValue("log_date_timestamp",mLogTimestampDate); + + childSetValue("include_im_in_chat_history", gSavedSettings.getBOOL("IMInChatHistory")); + childSetValue("show_timestamps_check", gSavedSettings.getBOOL("IMShowTimestamps")); + childSetValue("friends_online_notify_checkbox", gSavedSettings.getBOOL("ChatOnlineNotification")); + + childSetText("log_path_string", gSavedPerAccountSettings.getString("InstantMessageLogPath")); + childSetValue("log_instant_messages", gSavedPerAccountSettings.getBOOL("LogInstantMessages")); + childSetValue("log_chat", gSavedPerAccountSettings.getBOOL("LogChat")); + childSetValue("log_show_history", gSavedPerAccountSettings.getBOOL("LogShowHistory")); + childSetValue("log_instant_messages_timestamp", gSavedPerAccountSettings.getBOOL("IMLogTimestamp")); + childSetValue("log_chat_timestamp", gSavedPerAccountSettings.getBOOL("LogChatTimestamp")); + childSetValue("log_chat_IM", gSavedPerAccountSettings.getBOOL("LogChatIM")); + childSetValue("log_date_timestamp", gSavedPerAccountSettings.getBOOL("LogTimestampDate")); + childSetAction("log_path_button", onClickLogPath, this); childSetCommitCallback("log_chat",onCommitLogging,this); childSetCommitCallback("log_instant_messages",onCommitLogging,this); @@ -199,6 +161,10 @@ void LLPrefsIMImpl::apply() gSavedPerAccountSettings.setString("BusyModeResponse", std::string(wstring_to_utf8str(busy_response))); + gSavedSettings.setBOOL("IMInChatHistory", childGetValue("include_im_in_chat_history").asBoolean()); + gSavedSettings.setBOOL("IMShowTimestamps", childGetValue("show_timestamps_check").asBoolean()); + gSavedSettings.setBOOL("ChatOnlineNotification", childGetValue("friends_online_notify_checkbox").asBoolean()); + gSavedPerAccountSettings.setString("InstantMessageLogPath", childGetText("log_path_string")); gSavedPerAccountSettings.setBOOL("LogInstantMessages",childGetValue("log_instant_messages").asBoolean()); gSavedPerAccountSettings.setBOOL("LogChat",childGetValue("log_chat").asBoolean()); @@ -245,14 +211,12 @@ void LLPrefsIMImpl::apply() } } -void LLPrefsIMImpl::setPersonalInfo( - const std::string& visibility, - bool im_via_email, - const std::string& email) +void LLPrefsIMImpl::setPersonalInfo(const std::string& visibility, bool im_via_email, const std::string& email) { mGotPersonalInfo = true; mOriginalIMViaEmail = im_via_email; mDirectoryVisibility = visibility; + if(visibility == VISIBILITY_DEFAULT) { mOriginalHideOnlineStatus = false; @@ -267,6 +231,11 @@ void LLPrefsIMImpl::setPersonalInfo( { mOriginalHideOnlineStatus = true; } + + childEnable("include_im_in_chat_history"); + childEnable("show_timestamps_check"); + childEnable("friends_online_notify_checkbox"); + childSetValue("online_visibility", mOriginalHideOnlineStatus); childSetLabelArg("online_visibility", "[DIR_VIS]", mDirectoryVisibility); childEnable("send_im_to_email"); @@ -308,7 +277,7 @@ void LLPrefsIMImpl::onClickLogPath(void* user_data) std::string proposed_name(self->childGetText("log_path_string")); LLDirPicker& picker = LLDirPicker::instance(); - if (! picker.getDir(&proposed_name ) ) + if (!picker.getDir(&proposed_name ) ) { return; //Canceled! } diff --git a/linden/indra/newview/llprefsvoice.cpp b/linden/indra/newview/llprefsvoice.cpp index 6661f08..1421c3e 100644 --- a/linden/indra/newview/llprefsvoice.cpp +++ b/linden/indra/newview/llprefsvoice.cpp @@ -35,245 +35,164 @@ #include "llprefsvoice.h" #include "llcheckboxctrl.h" -#include "llcombobox.h" - +#include "llfloatervoicedevicesettings.h" +#include "llfocusmgr.h" +#include "llkeyboard.h" +#include "llmodaldialog.h" #include "llviewercontrol.h" #include "lluictrlfactory.h" -#include "llmodaldialog.h" -#include "llkeyboard.h" -#include "llfocusmgr.h" -#include "llfloatervoicedevicesettings.h" - -#include "llappviewer.h" - -#include "llvoiceclient.h" -class LLVoiceHotkeySelectDialog : public LLModalDialog +class LLVoiceSetKeyDialog : public LLModalDialog { -private: - LLPrefsVoiceLogic *mParent; - LLFloater *mOldFrontmost; - public: - LLVoiceHotkeySelectDialog( LLPrefsVoiceLogic *parent ) - : LLModalDialog( LLStringUtil::null, 240, 100 ), - mParent( parent ) - { - mOldFrontmost = gFloaterView->getFrontmost(); - - LLUICtrlFactory::getInstance()->buildFloater(this, "floater_select_key.xml"); - - childSetAction("Cancel", LLVoiceHotkeySelectDialog::onCancel, this ); - childSetFocus("Cancel"); - } - - /*virtual*/ void setFocus( BOOL b ) - { - LLFloater::setFocus(b); - - // This forces keyboard processing to happen at the raw key level instead of going through handleUnicodeChar. - if (b) - { - gFocusMgr.setKeystrokesOnly(TRUE); - } - } - - static void onCancel( void* userdata ); + LLVoiceSetKeyDialog(LLPrefsVoice* parent); + ~LLVoiceSetKeyDialog(); BOOL handleKeyHere(KEY key, MASK mask); -}; - -LLPrefsVoiceLogic::LLPrefsVoiceLogic(LLPanel* panelp) : - mPanel(panelp) -{ - init(); -} - -void LLPrefsVoiceLogic::init() -{ - mEnableVoice = gSavedSettings.getBOOL("EnableVoiceChat"); - - mVoiceCallsFriendsOnly = gSavedSettings.getBOOL("VoiceCallsFriendsOnly"); - mModifier = gSavedSettings.getString("PushToTalkButton"); - mPushToTalkToggle = gSavedSettings.getBOOL("PushToTalkToggle"); - mEarLocation = gSavedSettings.getS32("VoiceEarLocation"); - - LLUICtrl* ear_location = mPanel->getChild("ear_location"); - mCtrlEarLocation = ear_location->getSelectionInterface(); - if (mCtrlEarLocation) - { - mCtrlEarLocation->selectByValue(LLSD(gSavedSettings.getS32("VoiceEarLocation"))); - } - mPanel->childSetCommitCallback("ear_location", onEarLocationCommit, this ); - - mPanel->childSetAction("set_voice_hotkey_button", onClickSetKey, this); - mPanel->childSetAction("set_voice_middlemouse_button", onClickSetMiddleMouse, this); - - refresh(); - mEatNextSetKeyClick = FALSE; -} + static void onCancel(void* user_data); -void LLPrefsVoiceLogic::refresh() -{ - BOOL voiceDisabled = gSavedSettings.getBOOL("CmdLineDisableVoice"); - mPanel->childSetVisible("voice_unavailable", voiceDisabled); - mPanel->childSetVisible("enable_voice_check", !voiceDisabled); - mPanel->childSetEnabled("enable_voice_check", !voiceDisabled); - - bool enable = !voiceDisabled && gSavedSettings.getBOOL("EnableVoiceChat"); - - mPanel->childSetEnabled("friends_only_check", enable); - mPanel->childSetEnabled("push_to_talk_check", enable); - mPanel->childSetEnabled("push_to_talk_label", enable); - mPanel->childSetEnabled("voice_call_friends_only_check", enable); - mPanel->childSetEnabled("push_to_talk_toggle_check", enable); - mPanel->childSetEnabled("ear_location", enable); - mPanel->childSetEnabled("set_voice_hotkey_button", enable); - mPanel->childSetEnabled("set_voice_middlemouse_button", enable); -} +private: + LLPrefsVoice* mParent; +}; -void LLPrefsVoiceLogic::cancel() +LLVoiceSetKeyDialog::LLVoiceSetKeyDialog(LLPrefsVoice* parent) + : LLModalDialog(LLStringUtil::null, 240, 100), mParent(parent) { - gSavedSettings.setBOOL("EnableVoiceChat", mEnableVoice); - gSavedSettings.setBOOL("VoiceCallsFriendsOnly", mVoiceCallsFriendsOnly); - gSavedSettings.setString("PushToTalkButton", mModifier); - gSavedSettings.setBOOL("PushToTalkToggle", mPushToTalkToggle ); - gSavedSettings.setS32("VoiceEarLocation", mEarLocation); -} + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_select_key.xml"); + childSetAction("Cancel", onCancel, this); + childSetFocus("Cancel"); -void LLPrefsVoiceLogic::apply() -{ + gFocusMgr.setKeystrokesOnly(TRUE); } -//static -void LLPrefsVoiceLogic::onEarLocationCommit(LLUICtrl* ctrl, void* user_data) +LLVoiceSetKeyDialog::~LLVoiceSetKeyDialog() { - LLCtrlSelectionInterface* interfacep = ctrl->getSelectionInterface(); - if (interfacep) - { - gSavedSettings.setS32("VoiceEarLocation", interfacep->getSelectedValue().asInteger()); - } } -// static -void LLPrefsVoiceLogic::onClickSetKey(void* user_data) +BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask) { - LLPrefsVoiceLogic* self=(LLPrefsVoiceLogic*)user_data; - if(self->mEatNextSetKeyClick) + BOOL result = TRUE; + + if(key == 'Q' && mask == MASK_CONTROL) { - self->mEatNextSetKeyClick = false; + result = FALSE; } else { - LLVoiceHotkeySelectDialog* dialog = new LLVoiceHotkeySelectDialog( self ); - dialog->startModal(); - // dialog will delete itself + mParent->setKey(key); } -} + close(); + return result; +} -// static -void LLPrefsVoiceLogic::onClickSetMiddleMouse(void* user_data) +//static +void LLVoiceSetKeyDialog::onCancel(void* user_data) { -// LLPrefsVoiceLogic* self=(LLPrefsVoiceLogic*)user_data; - - gSavedSettings.setString("PushToTalkButton", "MiddleMouse"); + LLVoiceSetKeyDialog* self = (LLVoiceSetKeyDialog*)user_data; + self->close(); } -void LLPrefsVoiceLogic::setKey(KEY key, MASK mask) -{ - std::string keystring = LLKeyboard::stringFromKey(key); - gSavedSettings.setString("PushToTalkButton", keystring); - - if(key == ' ') - { - // This will cause the select dialog to immediately reopen. - // Eat the next click event. - mEatNextSetKeyClick = TRUE; - } +//-------------------------------------------------------------------- +//LLPrefsVoice +LLPrefsVoice::LLPrefsVoice() + : LLPanel(std::string("Voice Chat Panel")) +{ + LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_voice.xml"); } -void LLVoiceHotkeySelectDialog::onCancel( void* userdata ) +LLPrefsVoice::~LLPrefsVoice() { - LLVoiceHotkeySelectDialog* self = (LLVoiceHotkeySelectDialog*) userdata; - self->close(); // destroys this object - self->mOldFrontmost->setFrontmost(TRUE); } -BOOL LLVoiceHotkeySelectDialog::handleKeyHere(KEY key, MASK mask) +BOOL LLPrefsVoice::postBuild() { - BOOL result = TRUE; - - // Suck up all keystokes except CTRL-Q. - BOOL is_quit = ('Q' == key) && (MASK_CONTROL == mask); - if(is_quit) - { - result = FALSE; - } - else - { - mParent->setKey(key, mask); - } + childSetCommitCallback("enable_voice_check", onCommitEnableVoiceChat, this); + childSetAction("set_voice_hotkey_button", onClickSetKey, this); + childSetAction("set_voice_middlemouse_button", onClickSetMiddleMouse, this); + childSetAction("device_settings_btn", onClickVoiceDeviceSettings, NULL); - close(); // destroys this object - mOldFrontmost->setFrontmost(TRUE); - - return result; -} + BOOL voice_disabled = gSavedSettings.getBOOL("CmdLineDisableVoice"); + childSetVisible("voice_unavailable", voice_disabled); + childSetVisible("enable_voice_check", !voice_disabled); + childSetEnabled("enable_voice_check", !voice_disabled); -//--------------------------------------------------------------------------- + bool enable = !voice_disabled && gSavedSettings.getBOOL("EnableVoiceChat"); + childSetValue("enable_voice_check", enable); + onCommitEnableVoiceChat(getChild("enable_voice_check"), this); + childSetValue("modifier_combo", gSavedSettings.getString("PushToTalkButton")); + childSetValue("voice_call_friends_only_check", gSavedSettings.getBOOL("VoiceCallsFriendsOnly")); + childSetValue("push_to_talk_toggle_check", gSavedSettings.getBOOL("PushToTalkToggle")); + childSetValue("ear_location", gSavedSettings.getS32("VoiceEarLocation")); -LLPrefsVoice::LLPrefsVoice() - : LLPanel(std::string("Voice Chat Panel")) -{ - LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_voice.xml"); - mLogic = new LLPrefsVoiceLogic(this); - childSetAction("device_settings_btn", onClickVoiceDeviceSettingsBtn, this); + return TRUE; +} - // create floater immediately and keep it hidden - // since it stores preference state for audio devices - mVoiceDeviceSettings = LLFloaterVoiceDeviceSettings::getInstance(); +void LLPrefsVoice::apply() +{ + gSavedSettings.setBOOL("EnableVoiceChat", childGetValue("enable_voice_check")); + + gSavedSettings.setString("PushToTalkButton", childGetValue("modifier_combo")); + gSavedSettings.setBOOL("VoiceCallsFriendsOnly", childGetValue("voice_call_friends_only_check")); + gSavedSettings.setBOOL("PushToTalkToggle", childGetValue("push_to_talk_toggle_check")); + gSavedSettings.setS32("VoiceEarLocation", childGetValue("ear_location")); } -LLPrefsVoice::~LLPrefsVoice() +void LLPrefsVoice::cancel() +{ +} + +void LLPrefsVoice::setKey(KEY key) { - delete mLogic; + childSetValue("modifier_combo", LLKeyboard::stringFromKey(key)); } -void LLPrefsVoice::draw() +//static +void LLPrefsVoice::onCommitEnableVoiceChat(LLUICtrl* ctrl, void* user_data) { - bool enable = !gSavedSettings.getBOOL("CmdLineDisableVoice") - && gSavedSettings.getBOOL("EnableVoiceChat"); - childSetEnabled("device_settings_btn", enable); + LLPrefsVoice* self = (LLPrefsVoice*)user_data; + LLCheckBoxCtrl* enable_voice_chat = (LLCheckBoxCtrl*)ctrl; + + bool enable = enable_voice_chat->getValue(); - mLogic->refresh(); - mVoiceDeviceSettings->refresh(); - LLPanel::draw(); + self->childSetEnabled("modifier_combo", enable); + self->childSetEnabled("friends_only_check", enable); + self->childSetEnabled("push_to_talk_label", enable); + self->childSetEnabled("voice_call_friends_only_check", enable); + self->childSetEnabled("push_to_talk_toggle_check", enable); + self->childSetEnabled("ear_location", enable); + self->childSetEnabled("set_voice_hotkey_button", enable); + self->childSetEnabled("set_voice_middlemouse_button", enable); + self->childSetEnabled("device_settings_btn", enable); } -void LLPrefsVoice::apply() +//static +void LLPrefsVoice::onClickSetKey(void* user_data) { - mLogic->apply(); - mVoiceDeviceSettings->apply(); + LLPrefsVoice* self = (LLPrefsVoice*)user_data; + LLVoiceSetKeyDialog* dialog = new LLVoiceSetKeyDialog(self); + dialog->startModal(); } -void LLPrefsVoice::cancel() +//static +void LLPrefsVoice::onClickSetMiddleMouse(void* user_data) { - mLogic->cancel(); - mVoiceDeviceSettings->cancel(); + LLPrefsVoice* self = (LLPrefsVoice*)user_data; + self->childSetValue("modifier_combo", "MiddleMouse"); } -//static -void LLPrefsVoice::onClickVoiceDeviceSettingsBtn(void* user_data) +//static +void LLPrefsVoice::onClickVoiceDeviceSettings(void* user_data) { - LLPrefsVoice* prefs = (LLPrefsVoice*)user_data; - prefs->mVoiceDeviceSettings->open(); - LLFloater* parent_floater = gFloaterView->getParentFloater(prefs); - if (parent_floater) + LLPrefsVoice* voice_prefs = (LLPrefsVoice*)user_data; + LLFloaterVoiceDeviceSettings* device_settings_floater = LLFloaterVoiceDeviceSettings::showInstance(); + LLFloater* parent_floater = gFloaterView->getParentFloater(voice_prefs); + if(parent_floater) { - parent_floater->addDependentFloater(prefs->mVoiceDeviceSettings, FALSE); + parent_floater->addDependentFloater(device_settings_floater, FALSE); } } + diff --git a/linden/indra/newview/llprefsvoice.h b/linden/indra/newview/llprefsvoice.h index 836108d..a7cba73 100644 --- a/linden/indra/newview/llprefsvoice.h +++ b/linden/indra/newview/llprefsvoice.h @@ -34,55 +34,24 @@ #include "llpanel.h" -class LLFloaterVoiceDeviceSettings; - -class LLPrefsVoiceLogic -{ -public: - LLPrefsVoiceLogic(LLPanel* panelp); - virtual ~LLPrefsVoiceLogic(){}; - - virtual void init(); - - void apply(); - void cancel(); - void refresh(); - - void setKey(KEY key, MASK mask); - -protected: - - static void onClickSetKey(void* user_data); - static void onClickSetMiddleMouse(void* user_data); - static void onEarLocationCommit(LLUICtrl* ctrl, void* user_data); - - BOOL mEnableVoice; - BOOL mVoiceCallsFriendsOnly; - std::string mModifier; - BOOL mPushToTalkToggle; - S32 mEarLocation; - LLCtrlSelectionInterface *mCtrlEarLocation; - - BOOL mEatNextSetKeyClick; - - LLPanel* mPanel; -}; - class LLPrefsVoice : public LLPanel { public: LLPrefsVoice(); ~LLPrefsVoice(); - /*virtual*/ void draw(); + BOOL postBuild(); + void apply(); void cancel(); -protected: - static void onClickVoiceDeviceSettingsBtn(void* user_data); + void setKey(KEY key); - LLPrefsVoiceLogic* mLogic; - LLFloaterVoiceDeviceSettings* mVoiceDeviceSettings; +private: + static void onCommitEnableVoiceChat(LLUICtrl* ctrl, void* user_data); + static void onClickSetKey(void* user_data); + static void onClickSetMiddleMouse(void* user_data); + static void onClickVoiceDeviceSettings(void* user_data); }; #endif // LLPREFSVOICE_H diff --git a/linden/indra/newview/llpreviewscript.cpp b/linden/indra/newview/llpreviewscript.cpp index 52fca27..2b87128 100644 --- a/linden/indra/newview/llpreviewscript.cpp +++ b/linden/indra/newview/llpreviewscript.cpp @@ -101,7 +101,7 @@ const std::string HELLO_LSL = " llSay(0, \"Touched.\");\n" " }\n" "}\n"; -const std::string HELP_LSL = "lsl_guide.html"; +const std::string HELP_LSL_URL = "http://wiki.secondlife.com/wiki/LSL_Portal"; const std::string DEFAULT_SCRIPT_NAME = "New Script"; // *TODO:Translate? const std::string DEFAULT_SCRIPT_DESC = "(No Description)"; // *TODO:Translate? @@ -294,7 +294,7 @@ LLScriptEdCore::LLScriptEdCore( const std::string& name, const LLRect& rect, const std::string& sample, - const std::string& help, + const std::string& help_url, const LLHandle& floater_handle, void (*load_callback)(void*), void (*save_callback)(void*, BOOL), @@ -304,7 +304,7 @@ LLScriptEdCore::LLScriptEdCore( : LLPanel( std::string("name"), rect ), mSampleText(sample), - mHelpFile ( help ), + mHelpURL(help_url), mEditor( NULL ), mLoadCallback( load_callback ), mSaveCallback( save_callback ), @@ -547,7 +547,6 @@ void LLScriptEdCore::setHelpPage(const std::string& help_string) if (!history_combo) return; LLUIString url_string = gSavedSettings.getString("LSLHelpURL"); - url_string.setArg("[APP_DIRECTORY]", gDirUtilp->getWorkingDir()); url_string.setArg("[LSL_STRING]", help_string); addHelpItemToHistory(help_string); @@ -556,6 +555,7 @@ void LLScriptEdCore::setHelpPage(const std::string& help_string) } + void LLScriptEdCore::addHelpItemToHistory(const std::string& help_string) { if (help_string.empty()) return; @@ -647,7 +647,7 @@ void LLScriptEdCore::onHelpWebDialog(S32 option, void* userdata) switch(option) { case 0: - load_url_local_file(corep->mHelpFile); + LLWeb::loadURL(corep->mHelpURL); break; default: break; @@ -773,7 +773,6 @@ void LLScriptEdCore::onHelpComboCommit(LLUICtrl* ctrl, void* userdata) LLWebBrowserCtrl* web_browser = live_help_floater->getChild("lsl_guide_html"); LLUIString url_string = gSavedSettings.getString("LSLHelpURL"); - url_string.setArg("[APP_DIRECTORY]", gDirUtilp->getWorkingDir()); url_string.setArg("[LSL_STRING]", help_string); web_browser->navigateTo(url_string); } @@ -1072,7 +1071,7 @@ void* LLPreviewLSL::createScriptEdPanel(void* userdata) self->mScriptEd = new LLScriptEdCore("script panel", LLRect(), HELLO_LSL, - HELP_LSL, + HELP_LSL_URL, self->getHandle(), LLPreviewLSL::onLoad, LLPreviewLSL::onSave, @@ -1590,7 +1589,7 @@ void* LLLiveLSLEditor::createScriptEdPanel(void* userdata) self->mScriptEd = new LLScriptEdCore("script ed panel", LLRect(), HELLO_LSL, - HELP_LSL, + HELP_LSL_URL, self->getHandle(), &LLLiveLSLEditor::onLoad, &LLLiveLSLEditor::onSave, diff --git a/linden/indra/newview/llpreviewscript.h b/linden/indra/newview/llpreviewscript.h index 977b9ce..58de041 100644 --- a/linden/indra/newview/llpreviewscript.h +++ b/linden/indra/newview/llpreviewscript.h @@ -65,7 +65,7 @@ public: const std::string& name, const LLRect& rect, const std::string& sample, - const std::string& help, + const std::string& help_url, const LLHandle& floater_handle, void (*load_callback)(void* userdata), void (*save_callback)(void* userdata, BOOL close_after_save), @@ -132,7 +132,7 @@ protected: private: std::string mSampleText; - std::string mHelpFile; + std::string mHelpURL; LLTextEditor* mEditor; void (*mLoadCallback)(void* userdata); void (*mSaveCallback)(void* userdata, BOOL close_after_save); diff --git a/linden/indra/newview/llpreviewsound.cpp b/linden/indra/newview/llpreviewsound.cpp index 9ba6fd5..6b79bfb 100644 --- a/linden/indra/newview/llpreviewsound.cpp +++ b/linden/indra/newview/llpreviewsound.cpp @@ -106,7 +106,6 @@ void LLPreviewSound::auditionSound( void *userdata ) if(item && gAudiop) { LLVector3d lpos_global = gAgent.getPositionGlobal(); - F32 volume = gSavedSettings.getBOOL("MuteSounds") ? 0.f : SOUND_GAIN * gSavedSettings.getF32("AudioLevelSFX"); - gAudiop->triggerSound(item->getAssetUUID(), gAgent.getID(), volume, lpos_global); + gAudiop->triggerSound(item->getAssetUUID(), gAgent.getID(), SOUND_GAIN, LLAudioEngine::AUDIO_TYPE_UI, lpos_global); } } diff --git a/linden/indra/newview/llpreviewtexture.cpp b/linden/indra/newview/llpreviewtexture.cpp index 0a204dc..47a2cbc 100644 --- a/linden/indra/newview/llpreviewtexture.cpp +++ b/linden/indra/newview/llpreviewtexture.cpp @@ -200,7 +200,7 @@ void LLPreviewTexture::draw() if (!isMinimized()) { LLGLSUIDefault gls_ui; - LLGLSNoTexture gls_notex; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); const LLRect& border = mClientRect; LLRect interior = mClientRect; @@ -299,20 +299,20 @@ BOOL LLPreviewTexture::canSaveAs() const // virtual void LLPreviewTexture::saveAs() { - if( !mLoadingFullImage ) + if( mLoadingFullImage ) return; + + LLFilePicker& file_picker = LLFilePicker::instance(); + if( !file_picker.getSaveFile( LLFilePicker::FFSAVE_TGA, LLDir::getScrubbedFileName(getItem()->getName())) ) { - LLFilePicker& file_picker = LLFilePicker::instance(); - if( !file_picker.getSaveFile( LLFilePicker::FFSAVE_TGA ) ) - { - // User canceled save. - return; - } - mSaveFileName = file_picker.getFirstFile(); - mLoadingFullImage = TRUE; - getWindow()->incBusyCount(); - mImage->setLoadedCallback( LLPreviewTexture::onFileLoadedForSave, - 0, TRUE, FALSE, new LLUUID( mItemUUID ) ); + // User canceled or we failed to acquire save file. + return; } + // remember the user-approved/edited file name. + mSaveFileName = file_picker.getFirstFile(); + mLoadingFullImage = TRUE; + getWindow()->incBusyCount(); + mImage->setLoadedCallback( LLPreviewTexture::onFileLoadedForSave, + 0, TRUE, FALSE, new LLUUID( mItemUUID ) ); } diff --git a/linden/indra/newview/llprogressview.cpp b/linden/indra/newview/llprogressview.cpp index 123c583..4354254 100644 --- a/linden/indra/newview/llprogressview.cpp +++ b/linden/indra/newview/llprogressview.cpp @@ -208,7 +208,7 @@ void LLProgressView::draw() if (gStartImageGL) { LLGLSUIDefault gls_ui; - LLViewerImage::bindTexture(gStartImageGL); + gGL.getTexUnit(0)->bind(gStartImageGL); gGL.color4f(1.f, 1.f, 1.f, mFadeTimer.getStarted() ? clamp_rescale(mFadeTimer.getElapsedTimeF32(), 0.f, FADE_IN_TIME, 1.f, 0.f) : 1.f); F32 image_aspect = (F32)gStartImageWidth / (F32)gStartImageHeight; F32 view_aspect = (F32)width / (F32)height; @@ -224,11 +224,11 @@ void LLProgressView::draw() glScalef(1.f, view_aspect / image_aspect, 1.f); } gl_rect_2d_simple_tex( getRect().getWidth(), getRect().getHeight() ); - gStartImageGL->unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } else { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f(0.f, 0.f, 0.f, 1.f); gl_rect_2d(getRect()); } diff --git a/linden/indra/newview/llselectmgr.cpp b/linden/indra/newview/llselectmgr.cpp index 2e4983c..e3b57b8 100644 --- a/linden/indra/newview/llselectmgr.cpp +++ b/linden/indra/newview/llselectmgr.cpp @@ -4828,7 +4828,7 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) return; } - LLViewerImage::bindTexture(mSilhouetteImagep); + gGL.getTexUnit(0)->bind(mSilhouetteImagep.get()); LLGLSPipelineSelection gls_select; gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.f); LLGLEnable blend(GL_BLEND); @@ -4936,7 +4936,7 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) stop_glerror(); } - mSilhouetteImagep->unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } @@ -5313,7 +5313,7 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color) LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GEQUAL); gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { S32 i = 0; for (S32 seg_num = 0; seg_num < (S32)mSilhouetteSegments.size(); seg_num++) @@ -5334,7 +5334,7 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color) gGL.flush(); gGL.setSceneBlendType(LLRender::BT_ALPHA); - gGL.begin(LLVertexBuffer::TRIANGLES); + gGL.begin(LLRender::TRIANGLES); { S32 i = 0; for (S32 seg_num = 0; seg_num < (S32)mSilhouetteSegments.size(); seg_num++) @@ -5940,9 +5940,9 @@ S32 LLObjectSelection::getRootObjectCount() return count; } -bool LLObjectSelection::applyToObjects(LLSelectedObjectFunctor* func, bool firstonly) +bool LLObjectSelection::applyToObjects(LLSelectedObjectFunctor* func) { - bool result = firstonly ? false : true; + bool result = true; for (iterator iter = begin(); iter != end(); ) { iterator nextiter = iter++; @@ -5950,10 +5950,7 @@ bool LLObjectSelection::applyToObjects(LLSelectedObjectFunctor* func, bool first if (!object) continue; bool r = func->apply(object); - if (firstonly && r) - return true; - else - result = result && r; + result = result && r; } return result; } diff --git a/linden/indra/newview/llselectmgr.h b/linden/indra/newview/llselectmgr.h index d85ba04..a59b1c8 100644 --- a/linden/indra/newview/llselectmgr.h +++ b/linden/indra/newview/llselectmgr.h @@ -316,7 +316,7 @@ public: // If firstonly is FALSE, returns the AND of all apply() calls. // Else returns TRUE immediately if any apply() call succeeds (i.e. OR with early exit) bool applyToRootObjects(LLSelectedObjectFunctor* func, bool firstonly = false); - bool applyToObjects(LLSelectedObjectFunctor* func, bool firstonly = false); + bool applyToObjects(LLSelectedObjectFunctor* func); bool applyToTEs(LLSelectedTEFunctor* func, bool firstonly = false); bool applyToRootNodes(LLSelectedNodeFunctor* func, bool firstonly = false); bool applyToNodes(LLSelectedNodeFunctor* func, bool firstonly = false); diff --git a/linden/indra/newview/llsky.cpp b/linden/indra/newview/llsky.cpp index 8265d9d..18029a7 100644 --- a/linden/indra/newview/llsky.cpp +++ b/linden/indra/newview/llsky.cpp @@ -284,16 +284,16 @@ LLColor4U LLSky::getFadeColor() const void LLSky::init(const LLVector3 &sun_direction) { - mVOWLSkyp = static_cast(gObjectList.createObjectViewer(LLViewerObject::LL_VO_WL_SKY, gAgent.getRegion())); + mVOWLSkyp = static_cast(gObjectList.createObjectViewer(LLViewerObject::LL_VO_WL_SKY, NULL)); mVOWLSkyp->initSunDirection(sun_direction, LLVector3::zero); gPipeline.addObject(mVOWLSkyp.get()); - mVOSkyp = (LLVOSky *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_SKY, gAgent.getRegion()); + mVOSkyp = (LLVOSky *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_SKY, NULL); mVOSkyp->initSunDirection(sun_direction, LLVector3()); gPipeline.addObject((LLViewerObject *)mVOSkyp); - mVOGroundp = (LLVOGround*)gObjectList.createObjectViewer(LLViewerObject::LL_VO_GROUND, gAgent.getRegion()); + mVOGroundp = (LLVOGround*)gObjectList.createObjectViewer(LLViewerObject::LL_VO_GROUND, NULL); LLVOGround *groundp = mVOGroundp; gPipeline.addObject((LLViewerObject *)groundp); diff --git a/linden/indra/newview/llspatialpartition.cpp b/linden/indra/newview/llspatialpartition.cpp index 9f5d115..6247686 100644 --- a/linden/indra/newview/llspatialpartition.cpp +++ b/linden/indra/newview/llspatialpartition.cpp @@ -46,6 +46,7 @@ #include "pipeline.h" #include "llrender.h" #include "lloctree.h" +#include "llvoavatar.h" const F32 SG_OCCLUSION_FUDGE = 1.01f; #define SG_DISCARD_TOLERANCE 0.01f @@ -1624,7 +1625,7 @@ public: void drawBox(const LLVector3& c, const LLVector3& r) { - gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); + gGL.begin(LLRender::TRIANGLE_STRIP); //left front gGL.vertex3fv((c+r.scaledVec(LLVector3(-1,1,-1))).mV); gGL.vertex3fv((c+r.scaledVec(LLVector3(-1,1,1))).mV); @@ -1643,7 +1644,7 @@ void drawBox(const LLVector3& c, const LLVector3& r) gGL.end(); //bottom - gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); + gGL.begin(LLRender::TRIANGLE_STRIP); gGL.vertex3fv((c+r.scaledVec(LLVector3(1,1,-1))).mV); gGL.vertex3fv((c+r.scaledVec(LLVector3(1,-1,-1))).mV); gGL.vertex3fv((c+r.scaledVec(LLVector3(-1,1,-1))).mV); @@ -1651,7 +1652,7 @@ void drawBox(const LLVector3& c, const LLVector3& r) gGL.end(); //top - gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); + gGL.begin(LLRender::TRIANGLE_STRIP); gGL.vertex3fv((c+r.scaledVec(LLVector3(1,1,1))).mV); gGL.vertex3fv((c+r.scaledVec(LLVector3(-1,1,1))).mV); gGL.vertex3fv((c+r.scaledVec(LLVector3(1,-1,1))).mV); @@ -1666,7 +1667,7 @@ void drawBoxOutline(const LLVector3& pos, const LLVector3& size) LLVector3 v3 = size.scaledVec(LLVector3(-1,-1,1)); LLVector3 v4 = size.scaledVec(LLVector3( 1,-1,1)); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); //top gGL.vertex3fv((pos+v1).mV); @@ -1814,7 +1815,7 @@ void pushVerts(LLDrawInfo* params, U32 mask) { LLRenderPass::applyModelMatrix(*params); params->mVertexBuffer->setBuffer(mask); - params->mVertexBuffer->drawRange(params->mParticle ? LLVertexBuffer::POINTS : LLVertexBuffer::TRIANGLES, + params->mVertexBuffer->drawRange(params->mParticle ? LLRender::POINTS : LLRender::TRIANGLES, params->mStart, params->mEnd, params->mCount, params->mOffset); } @@ -1843,7 +1844,7 @@ void pushVerts(LLFace* face, U32 mask) U16 end = start + face->getGeomCount()-1; U32 count = face->getIndicesCount(); U16 offset = face->getIndicesStart(); - buffer->drawRange(LLVertexBuffer::TRIANGLES, start, end, count, offset); + buffer->drawRange(LLRender::TRIANGLES, start, end, count, offset); } } @@ -1853,7 +1854,7 @@ void pushBufferVerts(LLVertexBuffer* buffer, U32 mask) if (buffer) { buffer->setBuffer(mask); - buffer->drawRange(LLVertexBuffer::TRIANGLES, 0, buffer->getRequestedVerts()-1, buffer->getRequestedIndices(), 0); + buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getRequestedVerts()-1, buffer->getRequestedIndices(), 0); } } @@ -1902,7 +1903,7 @@ void pushVertsColorCoded(LLSpatialGroup* group, U32 mask) LLRenderPass::applyModelMatrix(*params); glColor4f(colors[col].mV[0], colors[col].mV[1], colors[col].mV[2], 0.5f); params->mVertexBuffer->setBuffer(mask); - params->mVertexBuffer->drawRange(params->mParticle ? LLVertexBuffer::POINTS : LLVertexBuffer::TRIANGLES, + params->mVertexBuffer->drawRange(params->mParticle ? LLRender::POINTS : LLRender::TRIANGLES, params->mStart, params->mEnd, params->mCount, params->mOffset); col = (col+1)%col_count; } @@ -1972,7 +1973,7 @@ void renderOctree(LLSpatialGroup* group) face->mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX); //drawBox((face->mExtents[0] + face->mExtents[1])*0.5f, // (face->mExtents[1]-face->mExtents[0])*0.5f); - face->mVertexBuffer->draw(LLVertexBuffer::TRIANGLES, face->getIndicesCount(), face->getIndicesStart()); + face->mVertexBuffer->draw(LLRender::TRIANGLES, face->getIndicesCount(), face->getIndicesStart()); } } @@ -2103,6 +2104,7 @@ void renderBoundingBox(LLDrawable* drawable) gGL.color4f(0.5f,0.5f,0.5f,1.0f); break; case LLViewerObject::LL_VO_PART_GROUP: + case LLViewerObject::LL_VO_HUD_PART_GROUP: gGL.color4f(0,0,1,1); break; case LLViewerObject::LL_VO_WATER: @@ -2222,7 +2224,7 @@ void renderPoints(LLDrawable* drawablep) LLGLDepthTest depth(GL_FALSE, GL_FALSE); if (drawablep->getNumFaces()) { - gGL.begin(LLVertexBuffer::POINTS); + gGL.begin(LLRender::POINTS); gGL.color3f(1,1,1); LLVector3 center(drawablep->getPositionGroup()); for (S32 i = 0; i < drawablep->getNumFaces(); i++) @@ -2298,9 +2300,17 @@ void renderRaycast(LLDrawable* drawablep) LLGLEnable blend(GL_BLEND); gGL.color4f(0,1,1,0.5f); - for (S32 i = 0; i < drawablep->getNumFaces(); i++) + if (drawablep->getVOVolume() && gDebugRaycastFaceHit != -1) { - pushVerts(drawablep->getFace(i), LLVertexBuffer::MAP_VERTEX); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + pushVerts(drawablep->getFace(gDebugRaycastFaceHit), LLVertexBuffer::MAP_VERTEX); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } + else if (drawablep->isAvatar()) + { + LLGLDepthTest depth(GL_FALSE); + LLVOAvatar* av = (LLVOAvatar*) drawablep->getVObj().get(); + av->renderCollisionVolumes(); } // draw intersection point @@ -2468,7 +2478,7 @@ void LLSpatialPartition::renderDebug() LLGLDisable cullface(GL_CULL_FACE); LLGLEnable blend(GL_BLEND); gGL.setSceneBlendType(LLRender::BT_ALPHA); - LLImageGL::unbindTexture(0); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gPipeline.disableLights(); LLSpatialBridge* bridge = asBridge(); @@ -2508,8 +2518,9 @@ public: LLVector3 *mNormal; LLVector3 *mBinormal; LLDrawable* mHit; - - LLOctreeIntersect(LLVector3 start, LLVector3 end, + BOOL mPickTransparent; + + LLOctreeIntersect(LLVector3 start, LLVector3 end, BOOL pick_transparent, S32* face_hit, LLVector3* intersection, LLVector2* tex_coord, LLVector3* normal, LLVector3* binormal) : mStart(start), mEnd(end), @@ -2518,14 +2529,15 @@ public: mTexCoord(tex_coord), mNormal(normal), mBinormal(binormal), - mHit(NULL) + mHit(NULL), + mPickTransparent(pick_transparent) { } virtual void visit(const LLSpatialGroup::OctreeNode* branch) { for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i) - { + { check(*i); } } @@ -2570,25 +2582,35 @@ public: virtual bool check(LLDrawable* drawable) { + LLVector3 local_start = mStart; + LLVector3 local_end = mEnd; + + if (!gPipeline.hasRenderType(drawable->getRenderType()) || !drawable->isVisible()) + { + return false; + } + if (drawable->isSpatialBridge()) { LLSpatialPartition *part = drawable->asPartition(); - - check(part->mOctree); - } - + LLSpatialBridge* bridge = part->asBridge(); + if (bridge && gPipeline.hasRenderType(bridge->mDrawableType)) + { + check(part->mOctree); + } + } else - { - LLViewerObject* vobj = drawable->getVObj(); + { + LLViewerObject* vobj = drawable->getVObj(); if (vobj) { LLVector3 intersection; - if (vobj->lineSegmentIntersect(mStart, mEnd, -1, mFaceHit, &intersection, mTexCoord, mNormal, mBinormal)) + if (vobj->lineSegmentIntersect(mStart, mEnd, -1, mPickTransparent, mFaceHit, &intersection, mTexCoord, mNormal, mBinormal)) { mEnd = intersection; // shorten ray so we only find CLOSER hits if (mIntersection) - { + { *mIntersection = intersection; } @@ -2596,12 +2618,13 @@ public: } } } - + return false; } }; LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, + BOOL pick_transparent, S32* face_hit, // return the face hit LLVector3* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -2610,7 +2633,7 @@ LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector3& start, con ) { - LLOctreeIntersect intersect(start, end, face_hit, intersection, tex_coord, normal, bi_normal); + LLOctreeIntersect intersect(start, end, pick_transparent, face_hit, intersection, tex_coord, normal, bi_normal); LLDrawable* drawable = intersect.check(mOctree); return drawable; diff --git a/linden/indra/newview/llspatialpartition.h b/linden/indra/newview/llspatialpartition.h index bd09da2..f42d55b 100644 --- a/linden/indra/newview/llspatialpartition.h +++ b/linden/indra/newview/llspatialpartition.h @@ -301,6 +301,7 @@ public: BOOL remove(LLDrawable *drawablep, LLSpatialGroup *curp); LLDrawable* lineSegmentIntersect(const LLVector3& start, const LLVector3& end, + BOOL pick_transparent, S32* face_hit, // return the face hit LLVector3* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -482,6 +483,12 @@ protected: U32 mRenderPass; }; +class LLHUDParticlePartition : public LLParticlePartition +{ +public: + LLHUDParticlePartition(); +}; + //spatial partition for grass (implemented in LLVOGrass.cpp) class LLGrassPartition : public LLParticlePartition { diff --git a/linden/indra/newview/llsprite.cpp b/linden/indra/newview/llsprite.cpp index 7da1d48..0032ee8 100644 --- a/linden/indra/newview/llsprite.cpp +++ b/linden/indra/newview/llsprite.cpp @@ -126,8 +126,8 @@ void LLSprite::updateFace(LLFace &face) LLVector3 camera_vec = mPosition - sCameraPosition; mScaledRight = camera_vec % LLVector3(0.f, 0.f, 1.f); mScaledUp = -(camera_vec % mScaledRight); - mScaledUp.normVec(); - mScaledRight.normVec(); + mScaledUp.normalize(); + mScaledRight.normalize(); mScaledUp *= mHeightDiv2; mScaledRight *= mWidthDiv2; @@ -156,7 +156,7 @@ void LLSprite::updateFace(LLFace &face) else { x_axis = sNormal % LLVector3(0.f, -1.f, 0.f); - x_axis.normVec(); + x_axis.normalize(); y_axis = sNormal % x_axis; } diff --git a/linden/indra/newview/llsprite.h b/linden/indra/newview/llsprite.h index 7170cb2..e721bef 100644 --- a/linden/indra/newview/llsprite.h +++ b/linden/indra/newview/llsprite.h @@ -73,7 +73,7 @@ public: void setColor(const LLColor4 &color); void setColor(const F32 r, const F32 g, const F32 b, const F32 a); void setAlpha(const F32 alpha) { mColor.mV[VALPHA] = alpha; } - void setNormal(const LLVector3 &normal) { sNormal = normal; sNormal.normVec();} + void setNormal(const LLVector3 &normal) { sNormal = normal; sNormal.normalize();} F32 getAlpha(); diff --git a/linden/indra/newview/llstartup.cpp b/linden/indra/newview/llstartup.cpp index 0978fbb..2ce111f 100644 --- a/linden/indra/newview/llstartup.cpp +++ b/linden/indra/newview/llstartup.cpp @@ -89,6 +89,7 @@ #include "llfeaturemanager.h" #include "llfirstuse.h" #include "llfloateractivespeakers.h" +#include "llfloaterbeacons.h" #include "llfloatercamera.h" #include "llfloaterchat.h" #include "llfloatergesture.h" @@ -244,6 +245,7 @@ void callback_choose_gender(S32 option, void* userdata); void init_start_screen(S32 location_id); void release_start_screen(); void reset_login(); +void apply_udp_blacklist(const std::string& csv); void callback_cache_name(const LLUUID& id, const std::string& firstname, const std::string& lastname, BOOL is_group, void* data) { @@ -750,6 +752,12 @@ bool idle_startup() gLoginMenuBarView->setVisible( TRUE ); gLoginMenuBarView->setEnabled( TRUE ); + // DEV-16927. The following code removes errant keystrokes that happen while the window is being + // first made visible. +#ifdef _WIN32 + MSG msg; + while( PeekMessage( &msg, /*All hWnds owned by this thread */ NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE ) ); +#endif timeout.reset(); return FALSE; } @@ -842,6 +850,20 @@ bool idle_startup() LLFile::mkdir(gDirUtilp->getChatLogsDir()); LLFile::mkdir(gDirUtilp->getPerAccountChatLogsDir()); + //good as place as any to create user windlight directories + std::string user_windlight_path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight", "")); + LLFile::mkdir(user_windlight_path_name.c_str()); + + std::string user_windlight_skies_path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", "")); + LLFile::mkdir(user_windlight_skies_path_name.c_str()); + + std::string user_windlight_water_path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", "")); + LLFile::mkdir(user_windlight_water_path_name.c_str()); + + std::string user_windlight_days_path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/days", "")); + LLFile::mkdir(user_windlight_days_path_name.c_str()); + + if (show_connect_box) { if ( LLPanelLogin::isGridComboDirty() ) @@ -1094,6 +1116,7 @@ bool idle_startup() LL_DEBUGS("AppInit") << "STATE_LOGIN_PROCESS_RESPONSE" << LL_ENDL; std::ostringstream emsg; bool quit = false; + bool update = false; std::string login_response; std::string reason_response; std::string message_response; @@ -1137,11 +1160,7 @@ bool idle_startup() reason_response = LLUserAuth::getInstance()->getResponse("reason"); message_response = LLUserAuth::getInstance()->getResponse("message"); - if (gHideLinks && reason_response == "disabled") - { - emsg << gDisabledMessage; - } - else if (!message_response.empty()) + if (!message_response.empty()) { // XUI: fix translation for strings returned during login // We need a generic table for translations @@ -1199,16 +1218,7 @@ bool idle_startup() if(reason_response == "update") { auth_message = LLUserAuth::getInstance()->getResponse("message"); - if (show_connect_box) - { - update_app(TRUE, auth_message); - LLStartUp::setStartupState( STATE_UPDATE_CHECK ); - return false; - } - else - { - quit = true; - } + update = true; } if(reason_response == "optional") { @@ -1246,6 +1256,21 @@ bool idle_startup() break; } + if (update || gSavedSettings.getBOOL("ForceMandatoryUpdate")) + { + gSavedSettings.setBOOL("ForceMandatoryUpdate", FALSE); + if (show_connect_box) + { + update_app(TRUE, auth_message); + LLStartUp::setStartupState( STATE_UPDATE_CHECK ); + return false; + } + else + { + quit = true; + } + } + // Version update and we're not showing the dialog if(quit) { @@ -1256,8 +1281,14 @@ bool idle_startup() if(successful_login) { - // unpack login data needed by the application std::string text; + text = LLUserAuth::getInstance()->getResponse("udp_blacklist"); + if(!text.empty()) + { + apply_udp_blacklist(text); + } + + // unpack login data needed by the application text = LLUserAuth::getInstance()->getResponse("agent_id"); if(!text.empty()) gAgentID.set(text); gDebugInfo["AgentID"] = text; @@ -1630,6 +1661,11 @@ bool idle_startup() LLFloaterActiveSpeakers::showInstance(); } + if (gSavedSettings.getBOOL("BeaconAlwaysOn")) + { + LLFloaterBeacons::showInstance(); + } + if (!gNoRender) { // Move the progress view in front of the UI @@ -2251,6 +2287,9 @@ bool idle_startup() } } + //DEV-17797. get null folder. Any items found here moved to Lost and Found + LLInventoryModel::findLostItems(); + LLStartUp::setStartupState( STATE_PRECACHE ); timeout.reset(); return FALSE; @@ -2428,7 +2467,7 @@ bool idle_startup() gDebugView->mFastTimerView->setVisible(TRUE); #endif - LLAppViewer::instance()->initMainloopTimeout("Mainloop Init"); + LLAppViewer::instance()->handleLoginComplete(); return TRUE; } @@ -2744,7 +2783,6 @@ void update_app(BOOL mandatory, const std::string& auth_msg) void update_dialog_callback(S32 option, void *userdata) { - std::string update_exe_path; bool mandatory = userdata != NULL; #if !LL_RELEASE_FOR_DOWNLOAD @@ -2787,29 +2825,41 @@ void update_dialog_callback(S32 option, void *userdata) // *TODO constantize this guy LLURI update_url = LLURI::buildHTTP("secondlife.com", 80, "update.php", query_map); + if(LLAppViewer::sUpdaterInfo) + { + delete LLAppViewer::sUpdaterInfo ; + } + LLAppViewer::sUpdaterInfo = new LLAppViewer::LLUpdaterInfo() ; + #if LL_WINDOWS - update_exe_path = gDirUtilp->getTempFilename(); - if (update_exe_path.empty()) + LLAppViewer::sUpdaterInfo->mUpdateExePath = gDirUtilp->getTempFilename(); + if (LLAppViewer::sUpdaterInfo->mUpdateExePath.empty()) { + delete LLAppViewer::sUpdaterInfo ; + LLAppViewer::sUpdaterInfo = NULL ; + // We're hosed, bail LL_WARNS("AppInit") << "LLDir::getTempFilename() failed" << LL_ENDL; LLAppViewer::instance()->forceQuit(); return; } - update_exe_path += ".exe"; + LLAppViewer::sUpdaterInfo->mUpdateExePath += ".exe"; std::string updater_source = gDirUtilp->getAppRODataDir(); updater_source += gDirUtilp->getDirDelimiter(); updater_source += "updater.exe"; LL_DEBUGS("AppInit") << "Calling CopyFile source: " << updater_source - << " dest: " << update_exe_path + << " dest: " << LLAppViewer::sUpdaterInfo->mUpdateExePath << LL_ENDL; - if (!CopyFileA(updater_source.c_str(), update_exe_path.c_str(), FALSE)) + if (!CopyFileA(updater_source.c_str(), LLAppViewer::sUpdaterInfo->mUpdateExePath.c_str(), FALSE)) { + delete LLAppViewer::sUpdaterInfo ; + LLAppViewer::sUpdaterInfo = NULL ; + LL_WARNS("AppInit") << "Unable to copy the updater!" << LL_ENDL; LLAppViewer::instance()->forceQuit(); return; @@ -2822,41 +2872,13 @@ void update_dialog_callback(S32 option, void *userdata) gSavedSettings.setString( "NextLoginLocation", LLURLSimString::sInstance.mSimString ); }; - std::ostringstream params; - params << "-url \"" << update_url.asString() << "\""; - if (gHideLinks) - { - // Figure out the program name. - const std::string& data_dir = gDirUtilp->getAppRODataDir(); - // Roll back from the end, stopping at the first '\' - const char* program_name = data_dir.c_str() + data_dir.size(); /* Flawfinder: ignore */ - while ( (data_dir != --program_name) && - *(program_name) != '\\'); - - if ( *(program_name) == '\\') - { - // We found a '\'. - program_name++; - } - else - { - // Oops. - program_name = "SecondLife"; - } + LLAppViewer::sUpdaterInfo->mParams << "-url \"" << update_url.asString() << "\""; - params << " -silent -name \"" << LLAppViewer::instance()->getSecondLifeTitle() << "\""; - params << " -program \"" << program_name << "\""; - } - - LL_DEBUGS("AppInit") << "Calling updater: " << update_exe_path << " " << params.str() << LL_ENDL; + LL_DEBUGS("AppInit") << "Calling updater: " << LLAppViewer::sUpdaterInfo->mUpdateExePath << " " << LLAppViewer::sUpdaterInfo->mParams.str() << LL_ENDL; //Explicitly remove the marker file, otherwise we pass the lock onto the child process and things get weird. LLAppViewer::instance()->removeMarkerFile(); // In case updater fails - // Use spawn() to run asynchronously - int retval = _spawnl(_P_NOWAIT, update_exe_path.c_str(), update_exe_path.c_str(), params.str().c_str(), NULL); - LL_DEBUGS("AppInit") << "Spawn returned " << retval << LL_ENDL; - #elif LL_DARWIN // if a sim name was passed in via command line parameter (typically through a SLURL) if ( LLURLSimString::sInstance.mSimString.length() ) @@ -2865,18 +2887,15 @@ void update_dialog_callback(S32 option, void *userdata) gSavedSettings.setString( "NextLoginLocation", LLURLSimString::sInstance.mSimString ); }; - update_exe_path = "'"; - update_exe_path += gDirUtilp->getAppRODataDir(); - update_exe_path += "/mac-updater.app/Contents/MacOS/mac-updater' -url \""; - update_exe_path += update_url.asString(); - update_exe_path += "\" -name \""; - update_exe_path += LLAppViewer::instance()->getSecondLifeTitle(); - update_exe_path += "\" &"; - - LL_DEBUGS("AppInit") << "Calling updater: " << update_exe_path << LL_ENDL; - - // Run the auto-updater. - system(update_exe_path.c_str()); /* Flawfinder: ignore */ + LLAppViewer::sUpdaterInfo->mUpdateExePath = "'"; + LLAppViewer::sUpdaterInfo->mUpdateExePath += gDirUtilp->getAppRODataDir(); + LLAppViewer::sUpdaterInfo->mUpdateExePath += "/mac-updater.app/Contents/MacOS/mac-updater' -url \""; + LLAppViewer::sUpdaterInfo->mUpdateExePath += update_url.asString(); + LLAppViewer::sUpdaterInfo->mUpdateExePath += "\" -name \""; + LLAppViewer::sUpdaterInfo->mUpdateExePath += LLAppViewer::instance()->getSecondLifeTitle(); + LLAppViewer::sUpdaterInfo->mUpdateExePath += "\" &"; + + LL_DEBUGS("AppInit") << "Calling updater: " << LLAppViewer::sUpdaterInfo->mUpdateExePath << LL_ENDL; #elif LL_LINUX OSMessageBox("Automatic updating is not yet implemented for Linux.\n" @@ -3533,7 +3552,7 @@ void init_stat_view() stat_barp->mDisplayBar = FALSE; stat_barp->mDisplayMean = FALSE; - stat_barp = sim_time_viewp->addStat("Sim Time (Physics)", &(LLViewerStats::getInstance()->mSimSimPhysicsMsec)); + stat_barp = sim_time_viewp->addStat("Physics Time", &(LLViewerStats::getInstance()->mSimSimPhysicsMsec)); stat_barp->setUnitLabel("ms"); stat_barp->mPrecision = 1; stat_barp->mMinBar = 0.f; @@ -3544,45 +3563,7 @@ void init_stat_view() stat_barp->mDisplayBar = FALSE; stat_barp->mDisplayMean = FALSE; - LLStatView *physics_time_viewp; - physics_time_viewp = new LLStatView("physics perf view", "Physics Details (ms)", "", rect); - sim_time_viewp->addChildAtEnd(physics_time_viewp); - { - stat_barp = physics_time_viewp->addStat("Physics Step", &(LLViewerStats::getInstance()->mSimSimPhysicsStepMsec)); - stat_barp->setUnitLabel("ms"); - stat_barp->mPrecision = 1; - stat_barp->mMinBar = 0.f; - stat_barp->mMaxBar = 40.f; - stat_barp->mTickSpacing = 10.f; - stat_barp->mLabelSpacing = 20.f; - stat_barp->mPerSec = FALSE; - stat_barp->mDisplayBar = FALSE; - stat_barp->mDisplayMean = FALSE; - - stat_barp = physics_time_viewp->addStat("Update Shapes", &(LLViewerStats::getInstance()->mSimSimPhysicsShapeUpdateMsec)); - stat_barp->setUnitLabel("ms"); - stat_barp->mPrecision = 1; - stat_barp->mMinBar = 0.f; - stat_barp->mMaxBar = 40.f; - stat_barp->mTickSpacing = 10.f; - stat_barp->mLabelSpacing = 20.f; - stat_barp->mPerSec = FALSE; - stat_barp->mDisplayBar = FALSE; - stat_barp->mDisplayMean = FALSE; - - stat_barp = physics_time_viewp->addStat("Other", &(LLViewerStats::getInstance()->mSimSimPhysicsOtherMsec)); - stat_barp->setUnitLabel("ms"); - stat_barp->mPrecision = 1; - stat_barp->mMinBar = 0.f; - stat_barp->mMaxBar = 40.f; - stat_barp->mTickSpacing = 10.f; - stat_barp->mLabelSpacing = 20.f; - stat_barp->mPerSec = FALSE; - stat_barp->mDisplayBar = FALSE; - stat_barp->mDisplayMean = FALSE; - } - - stat_barp = sim_time_viewp->addStat("Sim Time (Other)", &(LLViewerStats::getInstance()->mSimSimOtherMsec)); + stat_barp = sim_time_viewp->addStat("Simulation Time", &(LLViewerStats::getInstance()->mSimSimOtherMsec)); stat_barp->setUnitLabel("ms"); stat_barp->mPrecision = 1; stat_barp->mMinBar = 0.f; @@ -3626,6 +3607,79 @@ void init_stat_view() stat_barp->mDisplayBar = FALSE; stat_barp->mDisplayMean = FALSE; + stat_barp = sim_time_viewp->addStat("Spare Time", &(LLViewerStats::getInstance()->mSimSpareMsec)); + stat_barp->setUnitLabel("ms"); + stat_barp->mPrecision = 1; + stat_barp->mMinBar = 0.f; + stat_barp->mMaxBar = 40.f; + stat_barp->mTickSpacing = 10.f; + stat_barp->mLabelSpacing = 20.f; + stat_barp->mPerSec = FALSE; + stat_barp->mDisplayBar = FALSE; + stat_barp->mDisplayMean = FALSE; + + + // 2nd level time blocks under 'Details' second + LLStatView *detailed_time_viewp; + detailed_time_viewp = new LLStatView("sim perf view", "Time Details (ms)", "", rect); + sim_time_viewp->addChildAtEnd(detailed_time_viewp); + { + stat_barp = detailed_time_viewp->addStat(" Physics Step", &(LLViewerStats::getInstance()->mSimSimPhysicsStepMsec)); + stat_barp->setUnitLabel("ms"); + stat_barp->mPrecision = 1; + stat_barp->mMinBar = 0.f; + stat_barp->mMaxBar = 40.f; + stat_barp->mTickSpacing = 10.f; + stat_barp->mLabelSpacing = 20.f; + stat_barp->mPerSec = FALSE; + stat_barp->mDisplayBar = FALSE; + stat_barp->mDisplayMean = FALSE; + + stat_barp = detailed_time_viewp->addStat(" Update Physics Shapes", &(LLViewerStats::getInstance()->mSimSimPhysicsShapeUpdateMsec)); + stat_barp->setUnitLabel("ms"); + stat_barp->mPrecision = 1; + stat_barp->mMinBar = 0.f; + stat_barp->mMaxBar = 40.f; + stat_barp->mTickSpacing = 10.f; + stat_barp->mLabelSpacing = 20.f; + stat_barp->mPerSec = FALSE; + stat_barp->mDisplayBar = FALSE; + stat_barp->mDisplayMean = FALSE; + + stat_barp = detailed_time_viewp->addStat(" Physics Other", &(LLViewerStats::getInstance()->mSimSimPhysicsOtherMsec)); + stat_barp->setUnitLabel("ms"); + stat_barp->mPrecision = 1; + stat_barp->mMinBar = 0.f; + stat_barp->mMaxBar = 40.f; + stat_barp->mTickSpacing = 10.f; + stat_barp->mLabelSpacing = 20.f; + stat_barp->mPerSec = FALSE; + stat_barp->mDisplayBar = FALSE; + stat_barp->mDisplayMean = FALSE; + + stat_barp = detailed_time_viewp->addStat(" Sleep Time", &(LLViewerStats::getInstance()->mSimSleepMsec)); + stat_barp->setUnitLabel("ms"); + stat_barp->mPrecision = 1; + stat_barp->mMinBar = 0.f; + stat_barp->mMaxBar = 40.f; + stat_barp->mTickSpacing = 10.f; + stat_barp->mLabelSpacing = 20.f; + stat_barp->mPerSec = FALSE; + stat_barp->mDisplayBar = FALSE; + stat_barp->mDisplayMean = FALSE; + + stat_barp = detailed_time_viewp->addStat(" Pump IO", &(LLViewerStats::getInstance()->mSimPumpIOMsec)); + stat_barp->setUnitLabel("ms"); + stat_barp->mPrecision = 1; + stat_barp->mMinBar = 0.f; + stat_barp->mMaxBar = 40.f; + stat_barp->mTickSpacing = 10.f; + stat_barp->mLabelSpacing = 20.f; + stat_barp->mPerSec = FALSE; + stat_barp->mDisplayBar = FALSE; + stat_barp->mDisplayMean = FALSE; + } + LLRect r = gDebugView->mFloaterStatsp->getRect(); // Reshape based on the parameters we set. @@ -3887,3 +3941,28 @@ void login_alert_done(S32 option, void* user_data) LLPanelLogin::giveFocus(); } + +void apply_udp_blacklist(const std::string& csv) +{ + + std::string::size_type start = 0; + std::string::size_type comma = 0; + do + { + comma = csv.find(",", start); + if (comma == std::string::npos) + { + comma = csv.length(); + } + std::string item(csv, start, comma-start); + + lldebugs << "udp_blacklist " << item << llendl; + gMessageSystem->banUdpMessage(item); + + start = comma + 1; + + } + while(comma < csv.length()); + +} + diff --git a/linden/indra/newview/llstatbar.cpp b/linden/indra/newview/llstatbar.cpp index 19a9442..d88e89f 100644 --- a/linden/indra/newview/llstatbar.cpp +++ b/linden/indra/newview/llstatbar.cpp @@ -166,7 +166,7 @@ void LLStatBar::draw() bottom = bar_top - bar_height - tick_height/2; LLGLSUIDefault gls_ui; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); for (tick_value = mMinBar; tick_value <= mMaxBar; tick_value += mTickSpacing) { left = llfloor((tick_value - mMinBar)*value_scale); diff --git a/linden/indra/newview/llsurface.cpp b/linden/indra/newview/llsurface.cpp index 017517c..b046f97 100644 --- a/linden/indra/newview/llsurface.cpp +++ b/linden/indra/newview/llsurface.cpp @@ -33,6 +33,8 @@ #include "llsurface.h" +#include "llrender.h" + #include "llviewerimagelist.h" #include "llpatchvertexarray.h" #include "patch_dct.h" @@ -249,7 +251,7 @@ void LLSurface::createSTexture() mSTexturep = new LLViewerImage(raw, FALSE); mSTexturep->dontDiscard(); - mSTexturep->bind(); + gGL.getTexUnit(0)->bind(mSTexturep.get()); mSTexturep->setClamp(TRUE, TRUE); gImageList.addImage(mSTexturep); } @@ -274,7 +276,7 @@ void LLSurface::createWaterTexture() } mWaterTexturep = new LLViewerImage(raw, FALSE); mWaterTexturep->dontDiscard(); - mWaterTexturep->bind(); + gGL.getTexUnit(0)->bind(mWaterTexturep.get()); mWaterTexturep->setClamp(TRUE, TRUE); gImageList.addImage(mWaterTexturep); } diff --git a/linden/indra/newview/lltexlayer.cpp b/linden/indra/newview/lltexlayer.cpp index e331146..a687344 100644 --- a/linden/indra/newview/lltexlayer.cpp +++ b/linden/indra/newview/lltexlayer.cpp @@ -60,8 +60,6 @@ // SJB: We really always want to use the GL cache; // let GL page textures in and out of video RAM instead of trying to do so by hand. -LLGradientPaletteList gGradientPaletteList; - // static S32 LLTexLayerSetBuffer::sGLByteCount = 0; S32 LLTexLayerSetBuffer::sGLBumpByteCount = 0; @@ -96,7 +94,6 @@ LLTexLayerSetBuffer::LLTexLayerSetBuffer( LLTexLayerSet* owner, S32 width, S32 h mNeedsUpload( FALSE ), mUploadPending( FALSE ), // Not used for any logic here, just to sync sending of updates mTexLayerSet( owner ), - mInitialized( FALSE ), mBumpTexName(0) { LLTexLayerSetBuffer::sGLByteCount += getSize(); @@ -106,11 +103,10 @@ LLTexLayerSetBuffer::LLTexLayerSetBuffer( LLTexLayerSet* owner, S32 width, S32 h LLGLSUIDefault gls_ui; glGenTextures(1, (GLuint*) &mBumpTexName); - LLImageGL::bindExternalTexture(mBumpTexName, 0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mBumpTexName); stop_glerror(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -118,7 +114,7 @@ LLTexLayerSetBuffer::LLTexLayerSetBuffer( LLTexLayerSet* owner, S32 width, S32 h glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); stop_glerror(); - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLImageGL::sGlobalTextureMemory += mWidth * mHeight * 4; LLTexLayerSetBuffer::sGLBumpByteCount += mWidth * mHeight * 4; @@ -259,7 +255,7 @@ BOOL LLTexLayerSetBuffer::render() LLGLSUIDefault gls_ui; // read back into texture (this is done externally for the color data) - LLImageGL::bindExternalTexture( mBumpTexName, 0, GL_TEXTURE_2D ); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mBumpTexName); stop_glerror(); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, mOrigin.mX, mOrigin.mY, mWidth, mHeight); @@ -299,12 +295,17 @@ BOOL LLTexLayerSetBuffer::render() gGL.setSceneBlendType(LLRender::BT_ALPHA); // we have valid texture data now - mInitialized = TRUE; + mTexture->setInitialized(true); mNeedsUpdate = FALSE; return success; } +bool LLTexLayerSetBuffer::isInitialized(void) const +{ + return mTexture->isInitialized(); +} + BOOL LLTexLayerSetBuffer::updateImmediate() { mNeedsUpdate = TRUE; @@ -551,24 +552,12 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, void* user delete baked_upload_data; } - -void LLTexLayerSetBuffer::bindTexture() -{ - if( mInitialized ) - { - LLDynamicTexture::bindTexture(); - } - else - { - gImageList.getImage(IMG_DEFAULT)->bind(); - } -} - void LLTexLayerSetBuffer::bindBumpTexture( U32 stage ) { if( mBumpTexName ) { - LLImageGL::bindExternalTexture(mBumpTexName, stage, GL_TEXTURE_2D); + gGL.getTexUnit(stage)->bindManual(LLTexUnit::TT_TEXTURE, mBumpTexName); + gGL.getTexUnit(0)->activate(); if( mLastBindTime != LLImageGL::sLastFrameTime ) { @@ -578,7 +567,8 @@ void LLTexLayerSetBuffer::bindBumpTexture( U32 stage ) } else { - LLImageGL::unbindTexture(stage, GL_TEXTURE_2D); + gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->activate(); } } @@ -786,7 +776,7 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) if( image_gl ) { LLGLSUIDefault gls_ui; - image_gl->bind(); + gGL.getTexUnit(0)->bind(image_gl); gl_rect_2d_simple_tex( width, height ); } else @@ -794,7 +784,7 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) success = FALSE; } } - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.flush(); gGL.setColorMask(true, true); @@ -804,7 +794,8 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) if( getInfo()->mClearAlpha ) { // Set the alpha channel to one (clean up after previous blending) - LLGLSNoTextureNoAlphaTest gls_no_alpha; + LLGLDisable no_alpha(GL_ALPHA_TEST); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f( 0.f, 0.f, 0.f, 1.f ); gGL.flush(); gGL.setColorMask(false, true); @@ -838,7 +829,8 @@ BOOL LLTexLayerSet::renderBump( S32 x, S32 y, S32 width, S32 height ) } // Set the alpha channel to one (clean up after previous blending) - LLGLSNoTextureNoAlphaTest gls_no_texture_no_alpha; + LLGLDisable no_alpha(GL_ALPHA_TEST); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f( 0.f, 0.f, 0.f, 1.f ); gGL.setColorMask(false, true); @@ -1358,13 +1350,13 @@ BOOL LLTexLayer::render( S32 x, S32 y, S32 width, S32 height ) BOOL old_clamps = image_gl->getClampS(); BOOL old_clampt = image_gl->getClampT(); - image_gl->bind(); + gGL.getTexUnit(0)->bind(image_gl); image_gl->setClamp(TRUE, TRUE); gl_rect_2d_simple_tex( width, height ); image_gl->setClamp(old_clamps, old_clampt); - image_gl->unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } } else @@ -1380,9 +1372,9 @@ BOOL LLTexLayer::render( S32 x, S32 y, S32 width, S32 height ) LLImageGL* image_gl = gTexStaticImageList.getImageGL( getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask ); if( image_gl ) { - image_gl->bind(); + gGL.getTexUnit(0)->bind(image_gl); gl_rect_2d_simple_tex( width, height ); - image_gl->unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } else { @@ -1396,7 +1388,8 @@ BOOL LLTexLayer::render( S32 x, S32 y, S32 width, S32 height ) getInfo()->mStaticImageFileName.empty() && color_specified ) { - LLGLSNoTextureNoAlphaTest gls; + LLGLDisable no_alpha(GL_ALPHA_TEST); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4fv( net_color.mV); gl_rect_2d_simple( width, height ); } @@ -1518,7 +1511,8 @@ BOOL LLTexLayer::renderAlphaMasks( S32 x, S32 y, S32 width, S32 height, LLColor4 // Note: if the first param is a mulitply, multiply against the current buffer's alpha if( !first_param || !first_param->getMultiplyBlend() ) { - LLGLSNoTextureNoAlphaTest gls_no_texture_no_alpha_test; + LLGLDisable no_alpha(GL_ALPHA_TEST); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // Clear the alpha gGL.flush(); @@ -1555,13 +1549,13 @@ BOOL LLTexLayer::renderAlphaMasks( S32 x, S32 y, S32 width, S32 height, LLColor4 BOOL old_clamps = image_gl->getClampS(); BOOL old_clampt = image_gl->getClampT(); - image_gl->bind(); + gGL.getTexUnit(0)->bind(image_gl); image_gl->setClamp(TRUE, TRUE); gl_rect_2d_simple_tex( width, height ); image_gl->setClamp(old_clamps, old_clampt); - image_gl->unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } } else @@ -1581,9 +1575,9 @@ BOOL LLTexLayer::renderAlphaMasks( S32 x, S32 y, S32 width, S32 height, LLColor4 ( (image_gl->getComponents() == 1) && getInfo()->mStaticImageIsMask ) ) { LLGLSNoAlphaTest gls_no_alpha_test; - image_gl->bind(); + gGL.getTexUnit(0)->bind(image_gl); gl_rect_2d_simple_tex( width, height ); - image_gl->unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } } else @@ -1597,7 +1591,8 @@ BOOL LLTexLayer::renderAlphaMasks( S32 x, S32 y, S32 width, S32 height, LLColor4 // Note: we're still using gGL.blendFunc( GL_DST_ALPHA, GL_ZERO ); if( colorp->mV[VW] != 1.f ) { - LLGLSNoTextureNoAlphaTest gls_no_texture_no_alpha_test; + LLGLDisable no_alpha(GL_ALPHA_TEST); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4fv( colorp->mV ); gl_rect_2d_simple( width, height ); } @@ -1700,7 +1695,7 @@ BOOL LLTexLayer::renderImageRaw( U8* in_data, S32 in_width, S32 in_height, S32 i glGenTextures(1, &name ); stop_glerror(); - LLImageGL::bindExternalTexture( name, 0, GL_TEXTURE_2D ); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, name); stop_glerror(); glTexImage2D( @@ -1712,12 +1707,11 @@ BOOL LLTexLayer::renderImageRaw( U8* in_data, S32 in_width, S32 in_height, S32 i glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); gl_rect_2d_simple_tex( width, height ); - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); glDeleteTextures(1, &name ); stop_glerror(); @@ -1736,7 +1730,7 @@ BOOL LLTexLayer::renderImageRaw( U8* in_data, S32 in_width, S32 in_height, S32 i gl_rect_2d_simple_tex( width, height ); - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } return TRUE; @@ -1800,8 +1794,6 @@ BOOL LLTexLayerParamAlphaInfo::parseXml(LLXmlTreeNode* node) static LLStdStringHandle domain_string = LLXmlTree::addAttributeString("domain"); param_alpha_node->getFastAttributeF32( domain_string, mDomain ); - gGradientPaletteList.initPalette(mDomain); - return TRUE; } @@ -1996,7 +1988,7 @@ BOOL LLTexLayerParamAlpha::render( S32 x, S32 y, S32 width, S32 height ) if( !mCachedProcessedImageGL || (mCachedProcessedImageGL->getWidth() != image_tga_width) || (mCachedProcessedImageGL->getHeight() != image_tga_height) || - (weight_changed && !(gGLManager.mHasPalettedTextures && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_PALETTE))) ) + (weight_changed )) { // llinfos << "Building Cached Alpha: " << mName << ": (" << mStaticImageRaw->getWidth() << ", " << mStaticImageRaw->getHeight() << ") " << effective_weight << llendl; mCachedEffectiveWeight = effective_weight; @@ -2008,71 +2000,34 @@ BOOL LLTexLayerParamAlpha::render( S32 x, S32 y, S32 width, S32 height ) // We now have something in one of our caches LLTexLayerSet::sHasCaches |= mCachedProcessedImageGL ? TRUE : FALSE; - if (gGLManager.mHasPalettedTextures && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_PALETTE)) - { - // interpret luminance values as color index table - mCachedProcessedImageGL->setExplicitFormat( GL_COLOR_INDEX8_EXT, GL_COLOR_INDEX ); - } - else - { - mCachedProcessedImageGL->setExplicitFormat( GL_ALPHA8, GL_ALPHA ); - } + + mCachedProcessedImageGL->setExplicitFormat( GL_ALPHA8, GL_ALPHA ); } // Applies domain and effective weight to data as it is decoded. Also resizes the raw image if needed. - if (gGLManager.mHasPalettedTextures && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_PALETTE)) - { - mStaticImageRaw = NULL; - mStaticImageRaw = new LLImageRaw; - mStaticImageTGA->decode(mStaticImageRaw); - mNeedsCreateTexture = TRUE; - } - else - { - mStaticImageRaw = NULL; - mStaticImageRaw = new LLImageRaw; - mStaticImageTGA->decodeAndProcess( mStaticImageRaw, getInfo()->mDomain, effective_weight ); - mNeedsCreateTexture = TRUE; - } + mStaticImageRaw = NULL; + mStaticImageRaw = new LLImageRaw; + mStaticImageTGA->decodeAndProcess( mStaticImageRaw, getInfo()->mDomain, effective_weight ); + mNeedsCreateTexture = TRUE; } if( mCachedProcessedImageGL ) { { - if (gGLManager.mHasPalettedTextures && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_PALETTE)) - { - if( mNeedsCreateTexture ) - { - mCachedProcessedImageGL->createGLTexture(0, mStaticImageRaw); - mNeedsCreateTexture = FALSE; - - mCachedProcessedImageGL->bind(); - mCachedProcessedImageGL->setClamp(TRUE, TRUE); - } - - LLGLSNoAlphaTest gls_no_alpha_test; - mCachedProcessedImageGL->bind(); - gGradientPaletteList.setHardwarePalette( getInfo()->mDomain, effective_weight ); - gl_rect_2d_simple_tex( width, height ); - mCachedProcessedImageGL->unbindTexture(0, GL_TEXTURE_2D); - } - else + // Create the GL texture, and then hang onto it for future use. + if( mNeedsCreateTexture ) { - // Create the GL texture, and then hang onto it for future use. - if( mNeedsCreateTexture ) - { - mCachedProcessedImageGL->createGLTexture(0, mStaticImageRaw); - mNeedsCreateTexture = FALSE; - - mCachedProcessedImageGL->bind(); - mCachedProcessedImageGL->setClamp(TRUE, TRUE); - } - - LLGLSNoAlphaTest gls_no_alpha_test; - mCachedProcessedImageGL->bind(); - gl_rect_2d_simple_tex( width, height ); - mCachedProcessedImageGL->unbindTexture(0, GL_TEXTURE_2D); + mCachedProcessedImageGL->createGLTexture(0, mStaticImageRaw); + mNeedsCreateTexture = FALSE; + + gGL.getTexUnit(0)->bind(mCachedProcessedImageGL); + mCachedProcessedImageGL->setClamp(TRUE, TRUE); } + + LLGLSNoAlphaTest gls_no_alpha_test; + gGL.getTexUnit(0)->bind(mCachedProcessedImageGL); + gl_rect_2d_simple_tex( width, height ); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); stop_glerror(); } } @@ -2086,7 +2041,8 @@ BOOL LLTexLayerParamAlpha::render( S32 x, S32 y, S32 width, S32 height ) } else { - LLGLSNoTextureNoAlphaTest gls_no_texture_no_alpha_test; + LLGLDisable no_alpha(GL_ALPHA_TEST); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f( 0.f, 0.f, 0.f, effective_weight ); gl_rect_2d_simple( width, height ); } @@ -2519,7 +2475,7 @@ LLImageGL* LLTexStaticImageList::getImageGL(const std::string& file_name, BOOL i } image_gl->createGLTexture(0, image_raw); - image_gl->bind(); + gGL.getTexUnit(0)->bind(image_gl); image_gl->setClamp(TRUE, TRUE); mStaticImageListGL [ namekey ] = image_gl; @@ -2559,68 +2515,3 @@ LLMaskedMorph::LLMaskedMorph( LLPolyMorphTarget *morph_target, BOOL invert ) : m morph_target->addPendingMorphMask(); } - -//----------------------------------------------------------------------------- -// LLGradientPaletteList -//----------------------------------------------------------------------------- - -LLGradientPaletteList::~LLGradientPaletteList() -{ - // Note: can't just call deleteAllData() because the data values are arrays. - for( palette_map_t::iterator iter = mPaletteMap.begin(); - iter != mPaletteMap.end(); iter++ ) - { - U8* data = iter->second; - delete []data; - } -} - -void LLGradientPaletteList::initPalette(F32 domain) -{ - palette_map_t::iterator iter = mPaletteMap.find( domain ); - if( iter == mPaletteMap.end() ) - { - U8 *palette = new U8[512 * 4]; - mPaletteMap[domain] = palette; - S32 ramp_start = 255 - llfloor(domain * 255.f); - S32 ramp_end = 255; - F32 ramp_factor = (ramp_end == ramp_start) ? 0.f : (255.f / ((F32)ramp_end - (F32)ramp_start)); - - // *TODO: move conditionals outside of loop, since this really - // is just a sequential process. - for (S32 i = 0; i < 512; i++) - { - palette[(i * 4) + 1] = 0; - palette[(i * 4) + 2] = 0; - if (i <= ramp_start) - { - palette[(i * 4)] = 0; - palette[(i * 4) + 3] = 0; - } - else if (i < ramp_end) - { - palette[(i * 4)] = llfloor(((F32)i - (F32)ramp_start) * ramp_factor); - palette[(i * 4) + 3] = llfloor(((F32)i - (F32)ramp_start) * ramp_factor); - } - else - { - palette[(i * 4)] = 255; - palette[(i * 4) + 3] = 255; - } - } - } -} - -void LLGradientPaletteList::setHardwarePalette( F32 domain, F32 effective_weight ) -{ - palette_map_t::iterator iter = mPaletteMap.find( domain ); - if( iter != mPaletteMap.end() ) - { - U8* palette = iter->second; - set_palette( palette + llfloor(effective_weight * (255.f * (1.f - domain))) * 4); - } - else - { - llwarns << "LLGradientPaletteList::setHardwarePalette() missing domain " << domain << llendl; - } -} diff --git a/linden/indra/newview/lltexlayer.h b/linden/indra/newview/lltexlayer.h index 742b484..bd59c66 100644 --- a/linden/indra/newview/lltexlayer.h +++ b/linden/indra/newview/lltexlayer.h @@ -211,9 +211,8 @@ public: virtual void postRender(BOOL success); virtual BOOL render(); BOOL updateImmediate(); - virtual void bindTexture(); void bindBumpTexture( U32 stage ); - BOOL isInitialized() { return mInitialized; } // Initialized here means that we've done at least one render + bool isInitialized(void) const; BOOL needsRender(); void requestUpdate(); void requestUpload(); @@ -236,7 +235,6 @@ private: BOOL mUploadPending; LLUUID mUploadID; // Identifys the current upload process (null if none). Used to avoid overlaps (eg, when the user rapidly makes two changes outside of Face Edit) LLTexLayerSet* mTexLayerSet; - BOOL mInitialized; LLGLuint mBumpTexName; // zero if none static S32 sGLByteCount; @@ -529,41 +527,6 @@ public: }; -//----------------------------------------------------------------------------- -// LLGradientPaletteList -// A static set of ramp grayscale palettes. The "effective_weight" is used -// to determine the x position of the ramp (offset) -// -// "Domain" isn't really the right word. It refers to the width of the -// ramp portion of the function that relates input and output pixel values. -// A domain of 0 gives a step function. -// -// | /---------------- -// O| / | -// u| / | -// t| / | -// p|------------------/ | -// u| | | -// t|<---------------->|<-->| -// | "offset" "domain" -// | -// --+---Input-------------------------------- -// | -//----------------------------------------------------------------------------- -class LLGradientPaletteList -{ -public: - LLGradientPaletteList() {} - ~LLGradientPaletteList(); - - void initPalette(F32 domain); - void setHardwarePalette(F32 domain, F32 effective_weight); - -private: - typedef std::map palette_map_t; - palette_map_t mPaletteMap; -}; - // Used by LLTexLayerSetBuffer for a callback. class LLBakedUploadData { diff --git a/linden/indra/newview/lltexturectrl.cpp b/linden/indra/newview/lltexturectrl.cpp index 382a4f3..38ca3b7 100644 --- a/linden/indra/newview/lltexturectrl.cpp +++ b/linden/indra/newview/lltexturectrl.cpp @@ -483,9 +483,9 @@ void LLFloaterTexturePicker::draw() LLRect local_rect = getLocalRect(); if (gFocusMgr.childHasKeyboardFocus(this) && mOwner->isInVisibleChain() && mContextConeOpacity > 0.001f) { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLEnable(GL_CULL_FACE); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity); gGL.vertex2i(owner_rect.mLeft, owner_rect.mTop); diff --git a/linden/indra/newview/lltextureview.cpp b/linden/indra/newview/lltextureview.cpp index 49bc968..c5da2cf 100644 --- a/linden/indra/newview/lltextureview.cpp +++ b/linden/indra/newview/lltextureview.cpp @@ -247,7 +247,7 @@ void LLTextureBar::draw() LLFontGL::sMonospace->renderUTF8(fetch_state_desc[state].desc, 0, title_x2, getRect().getHeight(), fetch_state_desc[state].color, LLFontGL::LEFT, LLFontGL::TOP); - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // Draw the progress bar. S32 bar_width = 100; @@ -383,9 +383,9 @@ private: void LLGLTexMemBar::draw() { - S32 bound_mem = LLViewerImage::sBoundTextureMemory; + S32 bound_mem = (LLViewerImage::sBoundTextureMemory >> 20); S32 max_bound_mem = LLViewerImage::sMaxBoundTextureMem; - S32 total_mem = LLViewerImage::sTotalTextureMemory; + S32 total_mem = (LLViewerImage::sTotalTextureMemory >> 20); S32 max_total_mem = LLViewerImage::sMaxTotalTextureMem; F32 discard_bias = LLViewerImage::sDesiredDiscardBias; S32 line_height = (S32)(LLFontGL::sMonospace->getLineHeight() + .5f); @@ -396,10 +396,10 @@ void LLGLTexMemBar::draw() std::string text; text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB Discard Bias: %.2f", - total_mem/(1024*1024), - max_total_mem/(1024*1024), - bound_mem/(1024*1024), - max_bound_mem/(1024*1024), + total_mem, + max_total_mem, + bound_mem, + max_bound_mem, discard_bias); LLFontGL::sMonospace->renderUTF8(text, 0, 0, line_height*3, @@ -415,7 +415,7 @@ void LLGLTexMemBar::draw() F32 bar_scale = (F32)bar_width / (max_bound_mem * 1.5f); - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f(0.5f, 0.5f, 0.5f, 0.75f); gl_rect_2d(left, top, right, bottom); diff --git a/linden/indra/newview/lltool.cpp b/linden/indra/newview/lltool.cpp index cb0d3b1..b807276 100644 --- a/linden/indra/newview/lltool.cpp +++ b/linden/indra/newview/lltool.cpp @@ -42,6 +42,7 @@ #include "lltoolfocus.h" #include "llfocusmgr.h" #include "llagent.h" +#include "llviewerjoystick.h" extern BOOL gDebugClicks; @@ -160,6 +161,11 @@ BOOL LLTool::handleKey(KEY key, MASK mask) LLTool* LLTool::getOverrideTool(MASK mask) { + // NOTE: if in flycam mode, ALT-ZOOM camera should be disabled + if (LLViewerJoystick::getInstance()->getOverrideCamera()) + { + return NULL; + } if (mask & MASK_ALT) { return LLToolCamera::getInstance(); diff --git a/linden/indra/newview/lltoolbrush.cpp b/linden/indra/newview/lltoolbrush.cpp index 0869cf3..6391789 100644 --- a/linden/indra/newview/lltoolbrush.cpp +++ b/linden/indra/newview/lltoolbrush.cpp @@ -491,7 +491,7 @@ void LLToolBrushLand::renderOverlay(LLSurface& land, const LLVector3& pos_region const LLVector3& pos_world) { glMatrixMode(GL_MODELVIEW); - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest mDepthTest(GL_TRUE); glPushMatrix(); gGL.color4fv(OVERLAY_COLOR.mV); @@ -503,7 +503,7 @@ void LLToolBrushLand::renderOverlay(LLSurface& land, const LLVector3& pos_region S32 radioAction = gSavedSettings.getS32("RadioLandBrushAction"); F32 force = gSavedSettings.getF32("LandBrushForce"); // .1 to 100? - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); for(S32 di = -half_edge; di <= half_edge; di++) { if((i+di) < 0 || (i+di) >= (S32)land.mGridsPerEdge) continue; diff --git a/linden/indra/newview/lltoolmorph.cpp b/linden/indra/newview/lltoolmorph.cpp index 2fbf4ae..9666e66 100644 --- a/linden/indra/newview/lltoolmorph.cpp +++ b/linden/indra/newview/lltoolmorph.cpp @@ -240,6 +240,7 @@ BOOL LLVisualParamHint::render() } avatarp->setVisualParamWeight(mVisualParam, mLastParamWeight); gGL.color4f(1,1,1,1); + mTexture->setInitialized(true); return TRUE; } @@ -251,12 +252,12 @@ void LLVisualParamHint::draw() { if (!mIsVisible) return; - bindTexture(); + gGL.getTexUnit(0)->bind(getTexture()); gGL.color4f(1.f, 1.f, 1.f, 1.f); LLGLSUIDefault gls_ui; - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { gGL.texCoord2i(0, 1); gGL.vertex2i(0, mHeight); @@ -269,7 +270,7 @@ void LLVisualParamHint::draw() } gGL.end(); - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } //----------------------------------------------------------------------------- diff --git a/linden/indra/newview/lltoolplacer.cpp b/linden/indra/newview/lltoolplacer.cpp index 30347be..721e59e 100644 --- a/linden/indra/newview/lltoolplacer.cpp +++ b/linden/indra/newview/lltoolplacer.cpp @@ -224,8 +224,8 @@ BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics ) // Play creation sound if (gAudiop) { - F32 volume = gSavedSettings.getBOOL("MuteUI") ? 0.f : gSavedSettings.getF32("AudioLevelUI"); - gAudiop->triggerSound( LLUUID(gSavedSettings.getString("UISndObjectCreate")), gAgent.getID(), volume); + gAudiop->triggerSound( LLUUID(gSavedSettings.getString("UISndObjectCreate")), + gAgent.getID(), 1.0f, LLAudioEngine::AUDIO_TYPE_UI); } gMessageSystem->newMessageFast(_PREHASH_ObjectAdd); diff --git a/linden/indra/newview/lltoolselectrect.cpp b/linden/indra/newview/lltoolselectrect.cpp index 26d9756..b7067dc 100644 --- a/linden/indra/newview/lltoolselectrect.cpp +++ b/linden/indra/newview/lltoolselectrect.cpp @@ -175,7 +175,7 @@ void LLToolSelectRect::draw() { gGL.color4f(1.f, 1.f, 0.f, 1.f); } - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gl_rect_2d( llmin(mDragStartX, mDragEndX), llmax(mDragStartY, mDragEndY), diff --git a/linden/indra/newview/lltracker.cpp b/linden/indra/newview/lltracker.cpp index 8572283..82e6bf2 100644 --- a/linden/indra/newview/lltracker.cpp +++ b/linden/indra/newview/lltracker.cpp @@ -445,7 +445,7 @@ void draw_shockwave(F32 center_z, F32 t, S32 steps, LLColor4 color) F32 y = 0.f; LLColor4 ccol = LLColor4(1,1,1,(1.f-t)*0.25f); - gGL.begin(LLVertexBuffer::TRIANGLE_FAN); + gGL.begin(LLRender::TRIANGLE_FAN); gGL.color4fv(ccol.mV); gGL.vertex3f(0.f, 0.f, center_z); // make sure circle is complete @@ -494,7 +494,8 @@ void LLTracker::renderBeacon(LLVector3d pos_global, LLVector3 pos_agent = gAgent.getPosAgentFromGlobal(pos_global); - LLGLSTracker gls_tracker; // default - TEXTURE + CULL_FACE + LIGHTING + GL_BLEND + GL_ALPHA_TEST + LLGLSTracker gls_tracker; // default+ CULL_FACE + LIGHTING + GL_BLEND + GL_ALPHA_TEST + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDisable cull_face(GL_CULL_FACE); LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); @@ -535,7 +536,7 @@ void LLTracker::renderBeacon(LLVector3d pos_global, an *= 2.f; an += 1.0f+dr; - gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); + gGL.begin(LLRender::TRIANGLE_STRIP); gGL.color4fv(col_edge.mV); gGL.vertex3f(-x*a, -y*a, z); gGL.color4fv(col_edge_next.mV); diff --git a/linden/indra/newview/lluserauth.cpp b/linden/indra/newview/lluserauth.cpp index a9b00e1..bb6ee16 100644 --- a/linden/indra/newview/lluserauth.cpp +++ b/linden/indra/newview/lluserauth.cpp @@ -324,17 +324,29 @@ static void parseOptionInto( while(opt) { key.assign(XMLRPC_GetValueID(opt)); - //llinfos "option key: " << key << llendl; + //llinfos << "option key: " << key << llendl; type = XMLRPC_GetValueTypeEasy(opt); if(xmlrpc_type_string == type) { val.assign(XMLRPC_GetValueString(opt)); + //llinfos << "string val: " << val << llendl; } else if(xmlrpc_type_int == type) { val = llformat("%d", XMLRPC_GetValueInt(opt)); + //llinfos << "int val: " << val << llendl; } - //llinfos "option val: " << val << llendl; + else if(xmlrpc_type_double == type) + { + val = llformat("%g", XMLRPC_GetValueDouble(opt)); + //llinfos << "double val: " << val << llendl; + } + else + { // Can't understand the type + val = "???"; + //llinfos << "unknown value type: " << type << llendl; + } + responses.insert(LLUserAuth::response_t::value_type(key, val)); opt = XMLRPC_VectorNext(row); } diff --git a/linden/indra/newview/llvelocitybar.cpp b/linden/indra/newview/llvelocitybar.cpp index e8b9a74..3d5784f 100644 --- a/linden/indra/newview/llvelocitybar.cpp +++ b/linden/indra/newview/llvelocitybar.cpp @@ -63,7 +63,7 @@ void LLVelocityBar::draw() // Set bar color // - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // draw background box // gGL.color4f(0.f, 0.f, 0.f, 0.3f); diff --git a/linden/indra/newview/llvieweraudio.cpp b/linden/indra/newview/llvieweraudio.cpp index 122a0bc..23a685a 100644 --- a/linden/indra/newview/llvieweraudio.cpp +++ b/linden/indra/newview/llvieweraudio.cpp @@ -139,6 +139,14 @@ void audio_update_volume(bool force_update) { audio_update_wind(true); } + + // handle secondary gains + gAudiop->setSecondaryGain(LLAudioEngine::AUDIO_TYPE_SFX, + gSavedSettings.getBOOL("MuteSounds") ? 0.f : gSavedSettings.getF32("AudioLevelSFX")); + gAudiop->setSecondaryGain(LLAudioEngine::AUDIO_TYPE_UI, + gSavedSettings.getBOOL("MuteUI") ? 0.f : gSavedSettings.getF32("AudioLevelUI")); + gAudiop->setSecondaryGain(LLAudioEngine::AUDIO_TYPE_AMBIENT, + gSavedSettings.getBOOL("MuteAmbient") ? 0.f : gSavedSettings.getF32("AudioLevelAmbient")); } // Streaming Music diff --git a/linden/indra/newview/llviewerdisplay.cpp b/linden/indra/newview/llviewerdisplay.cpp index 627609b..4db26a0 100644 --- a/linden/indra/newview/llviewerdisplay.cpp +++ b/linden/indra/newview/llviewerdisplay.cpp @@ -248,8 +248,11 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gViewerWindow->checkSettings(); - LLAppViewer::instance()->pingMainloopTimeout("Display:Pick"); - gViewerWindow->performPick(); + { + LLFastTimer ftm(LLFastTimer::FTM_PICK); + LLAppViewer::instance()->pingMainloopTimeout("Display:Pick"); + gViewerWindow->performPick(); + } LLAppViewer::instance()->pingMainloopTimeout("Display:CheckStates"); @@ -373,6 +376,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gAgent.setTeleportMessage( LLAgent::sTeleportProgressMessages["arriving"]); gImageList.mForceResetTextureStats = TRUE; + gAgent.resetView(TRUE, TRUE); break; case LLAgent::TELEPORT_ARRIVING: @@ -690,7 +694,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) // glMatrixMode(GL_MODELVIEW); // glPushMatrix(); // { - // LLGLSNoTexture gls_no_texture; + // gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); // glLoadIdentity(); @@ -997,8 +1001,8 @@ void render_ui() void renderCoordinateAxes() { - LLGLSNoTexture gls_no_texture; - gGL.begin(LLVertexBuffer::LINES); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.begin(LLRender::LINES); gGL.color3f(1.0f, 0.0f, 0.0f); // i direction = X-Axis = red gGL.vertex3f(0.0f, 0.0f, 0.0f); gGL.vertex3f(2.0f, 0.0f, 0.0f); @@ -1048,10 +1052,10 @@ void renderCoordinateAxes() void draw_axes() { LLGLSUIDefault gls_ui; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // A vertical white line at origin LLVector3 v = gAgent.getPositionAgent(); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); gGL.color3f(1.0f, 1.0f, 1.0f); gGL.vertex3f(0.0f, 0.0f, 0.0f); gGL.vertex3f(0.0f, 0.0f, 40.0f); @@ -1194,7 +1198,7 @@ void render_disconnected_background() raw->expandToPowerOfTwo(); gDisconnectedImagep->createGLTexture(0, raw); gStartImageGL = gDisconnectedImagep; - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } // Make sure the progress view always fills the entire window. @@ -1213,10 +1217,10 @@ void render_disconnected_background() const LLVector2& display_scale = gViewerWindow->getDisplayScale(); glScalef(display_scale.mV[VX], display_scale.mV[VY], 1.f); - LLViewerImage::bindTexture(gDisconnectedImagep); + gGL.getTexUnit(0)->bind(gDisconnectedImagep); gGL.color4f(1.f, 1.f, 1.f, 1.f); gl_rect_2d_simple_tex(width, height); - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } glPopMatrix(); } diff --git a/linden/indra/newview/llviewerimage.cpp b/linden/indra/newview/llviewerimage.cpp index 0b70f51..6ad6ca2 100644 --- a/linden/indra/newview/llviewerimage.cpp +++ b/linden/indra/newview/llviewerimage.cpp @@ -149,23 +149,13 @@ F32 texmem_middle_bound_scale = 0.925f; //static void LLViewerImage::updateClass(const F32 velocity, const F32 angular_velocity) { - sBoundTextureMemory = LLImageGL::sBoundTextureMemory; - sTotalTextureMemory = LLImageGL::sGlobalTextureMemory; - sMaxBoundTextureMem = gImageList.getMaxResidentTexMem(); - - sMaxTotalTextureMem = sMaxBoundTextureMem * 2; - if (sMaxBoundTextureMem > 64000000) - { - sMaxTotalTextureMem -= sMaxBoundTextureMem/4; - } - - if ((U32)sMaxTotalTextureMem > gSysMemory.getPhysicalMemoryClamped() - (U32)min_non_tex_system_mem) - { - sMaxTotalTextureMem = (S32)gSysMemory.getPhysicalMemoryClamped() - min_non_tex_system_mem; - } - - if (sBoundTextureMemory >= sMaxBoundTextureMem || - sTotalTextureMemory >= sMaxTotalTextureMem) + sBoundTextureMemory = LLImageGL::sBoundTextureMemory;//in bytes + sTotalTextureMemory = LLImageGL::sGlobalTextureMemory;//in bytes + sMaxBoundTextureMem = gImageList.getMaxResidentTexMem();//in MB + sMaxTotalTextureMem = gImageList.getMaxTotalTextureMem() ;//in MB + + if ((sBoundTextureMemory >> 20) >= sMaxBoundTextureMem || + (sTotalTextureMemory >> 20) >= sMaxTotalTextureMem) { // If we are using more texture memory than we should, // scale up the desired discard level @@ -176,8 +166,8 @@ void LLViewerImage::updateClass(const F32 velocity, const F32 angular_velocity) } } else if (sDesiredDiscardBias > 0.0f && - sBoundTextureMemory < sMaxBoundTextureMem*texmem_lower_bound_scale && - sTotalTextureMemory < sMaxTotalTextureMem*texmem_lower_bound_scale) + (sBoundTextureMemory >> 20) < sMaxBoundTextureMem*texmem_lower_bound_scale && + (sTotalTextureMemory >> 20) < sMaxTotalTextureMem*texmem_lower_bound_scale) { // If we are using less texture memory than we should, // scale down the desired discard level @@ -1210,45 +1200,58 @@ void LLViewerImage::setKnownDrawSize(S32 width, S32 height) } // virtual -BOOL LLViewerImage::bind(S32 stage) const +bool LLViewerImage::bindError(S32 stage) const { - if (stage == -1) + if (stage < 0) return false; + + if (gNoRender) { - return TRUE; + return false; } + + bool res = true; - if (gNoRender) + // On failure to bind, what should we set the currently bound texture to? + if (mIsMissingAsset && !sMissingAssetImagep.isNull() && (this != (LLImageGL *)sMissingAssetImagep)) { - return true; + res = gGL.getTexUnit(stage)->bind(sMissingAssetImagep.get()); } - BOOL res = bindTextureInternal(stage); - if (res) + if (!res && !sDefaultImagep.isNull() && (this != (LLImageGL *)sDefaultImagep)) { - //llassert_always(mIsMissingAsset == FALSE); - + // use default if we've got it + res = gGL.getTexUnit(stage)->bind(sDefaultImagep.get()); } - else + if (!res && !sNullImagep.isNull() && (this != (LLImageGL *)sNullImagep)) { - // On failure to bind, what should we set the currently bound texture to? - if (mIsMissingAsset && !sMissingAssetImagep.isNull() && (this != (LLImageGL *)sMissingAssetImagep)) - { - res = sMissingAssetImagep->bind( stage ); - } - if (!res && !sDefaultImagep.isNull() && (this != (LLImageGL *)sDefaultImagep)) - { - // use default if we've got it - res = sDefaultImagep->bind(stage); - } - if (!res && !sNullImagep.isNull() && (this != (LLImageGL *)sNullImagep)) - { - res = sNullImagep->bind(stage); - } - if (!res) - { - llwarns << "LLViewerImage::bindTexture failed." << llendl; - } - stop_glerror(); + res = gGL.getTexUnit(stage)->bind(sNullImagep.get()); + } + if (!res) + { + llwarns << "LLViewerImage::bindError failed." << llendl; } + stop_glerror(); + return res; +} + +bool LLViewerImage::bindDefaultImage(S32 stage) const +{ + if (stage < 0) return false; + + bool res = true; + if (!sDefaultImagep.isNull() && (this != (LLImageGL *)sDefaultImagep)) + { + // use default if we've got it + res = gGL.getTexUnit(stage)->bind(sDefaultImagep.get()); + } + if (!res && !sNullImagep.isNull() && (this != (LLImageGL *)sNullImagep)) + { + res = gGL.getTexUnit(stage)->bind(sNullImagep.get()); + } + if (!res) + { + llwarns << "LLViewerImage::bindError failed." << llendl; + } + stop_glerror(); return res; } diff --git a/linden/indra/newview/llviewerimage.h b/linden/indra/newview/llviewerimage.h index 60d9fb8..523f66a 100644 --- a/linden/indra/newview/llviewerimage.h +++ b/linden/indra/newview/llviewerimage.h @@ -86,17 +86,6 @@ public: static LLViewerImage * getImage(const LLUUID &image_id); // lightweight wrapper for gImageList.getImage() - static BOOL bindTexture(LLImageGL* image, const U32 stage = 0) - { - if (image) - { - return image->bind(stage); - } - else - { - return sDefaultImagep->bind(stage); - } - } struct Compare { @@ -189,7 +178,8 @@ public: /*virtual*/ void dump(); // debug info to llinfos - /*virtual*/ BOOL bind(const S32 stage = 0) const; + /*virtual*/ bool bindError(const S32 stage = 0) const; + /*virtual*/ bool bindDefaultImage(const S32 stage = 0) const; void reinit(BOOL usemipmaps = TRUE); diff --git a/linden/indra/newview/llviewerimagelist.cpp b/linden/indra/newview/llviewerimagelist.cpp index a79a76a..1e58fce 100644 --- a/linden/indra/newview/llviewerimagelist.cpp +++ b/linden/indra/newview/llviewerimagelist.cpp @@ -89,7 +89,8 @@ LLStat LLViewerImageList::sFormattedMemStat(32, TRUE); LLViewerImageList::LLViewerImageList() : mForceResetTextureStats(FALSE), mUpdateStats(FALSE), - mMaxResidentTexMem(0) + mMaxResidentTexMem(0), + mMaxTotalTextureMem(0) { } @@ -97,6 +98,7 @@ void LLViewerImageList::init() { sNumImages = 0; mMaxResidentTexMem = 0; + mMaxTotalTextureMem = 0 ; if (gNoRender) { @@ -918,12 +920,14 @@ LLPointer LLViewerImageList::convertToUploadFile(LLPointer> 20); + //min texture mem sets to 128M if total physical mem is more than 1.5GB + return (system_ram > 1500) ? 128 : MIN_VIDEO_RAM; } //static @@ -956,8 +960,8 @@ S32 LLViewerImageList::getMaxVideoRamSetting(bool get_recommended) max_texmem = llmin(max_texmem, (S32)(system_ram/2)); else max_texmem = llmin(max_texmem, (S32)(system_ram)); - - max_texmem = llclamp(max_texmem, MIN_VIDEO_RAM, MAX_VIDEO_RAM); + + max_texmem = llclamp(max_texmem, getMinVideoRamSetting(), MAX_VIDEO_RAM); return max_texmem; } @@ -994,7 +998,18 @@ void LLViewerImageList::updateMaxResidentTexMem(S32 mem) S32 vb_mem = mem; S32 fb_mem = llmax(VIDEO_CARD_FRAMEBUFFER_MEM, vb_mem/4); - mMaxResidentTexMem = (vb_mem - fb_mem)<<20; + mMaxResidentTexMem = (vb_mem - fb_mem) ; //in MB + + mMaxTotalTextureMem = mMaxResidentTexMem * 2; + if (mMaxResidentTexMem > 640) + { + mMaxTotalTextureMem -= (mMaxResidentTexMem >> 2); + } + + if (mMaxTotalTextureMem > (S32)(gSysMemory.getPhysicalMemoryClamped() >> 20) - 128) + { + mMaxTotalTextureMem = (gSysMemory.getPhysicalMemoryClamped() >> 20) - 128 ; + } llinfos << "Total Video Memory set to: " << vb_mem << " MB" << llendl; llinfos << "Available Texture Memory set to: " << (vb_mem - fb_mem) << " MB" << llendl; diff --git a/linden/indra/newview/llviewerimagelist.h b/linden/indra/newview/llviewerimagelist.h index 8aa9913..1f1a122 100644 --- a/linden/indra/newview/llviewerimagelist.h +++ b/linden/indra/newview/llviewerimagelist.h @@ -129,6 +129,7 @@ public: void setUpdateStats(BOOL b) { mUpdateStats = b; } S32 getMaxResidentTexMem() const { return mMaxResidentTexMem; } + S32 getMaxTotalTextureMem() const { return mMaxTotalTextureMem;} S32 getNumImages() { return mImageList.size(); } void updateMaxResidentTexMem(S32 mem); @@ -170,6 +171,7 @@ private: BOOL mUpdateStats; S32 mMaxResidentTexMem; + S32 mMaxTotalTextureMem; LLFrameTimer mForceDecodeTimer; public: diff --git a/linden/indra/newview/llviewerinventory.cpp b/linden/indra/newview/llviewerinventory.cpp index 6d9d685..0323bb7 100644 --- a/linden/indra/newview/llviewerinventory.cpp +++ b/linden/indra/newview/llviewerinventory.cpp @@ -196,15 +196,34 @@ void LLViewerInventoryItem::fetchFromServer(void) const { if(!mIsComplete) { - LLMessageSystem* msg = gMessageSystem; - msg->newMessage("FetchInventory"); - msg->nextBlock("AgentData"); - msg->addUUID("AgentID", gAgent.getID()); - msg->addUUID("SessionID", gAgent.getSessionID()); - msg->nextBlock("InventoryData"); - msg->addUUID("OwnerID", mPermissions.getOwner()); - msg->addUUID("ItemID", mUUID); - gAgent.sendReliableMessage(); + std::string url; + + if( ALEXANDRIA_LINDEN_ID.getString() == mPermissions.getOwner().getString()) + url = gAgent.getRegion()->getCapability("FetchLib"); + else + url = gAgent.getRegion()->getCapability("FetchInventory"); + + if (!url.empty()) + { + LLSD body; + body["agent_id"] = gAgent.getID(); + body["items"][0]["owner_id"] = mPermissions.getOwner(); + body["items"][0]["item_id"] = mUUID; + + LLHTTPClient::post(url, body, new LLInventoryModel::fetchInventoryResponder(body)); + } + else + { + LLMessageSystem* msg = gMessageSystem; + msg->newMessage("FetchInventory"); + msg->nextBlock("AgentData"); + msg->addUUID("AgentID", gAgent.getID()); + msg->addUUID("SessionID", gAgent.getSessionID()); + msg->nextBlock("InventoryData"); + msg->addUUID("OwnerID", mPermissions.getOwner()); + msg->addUUID("ItemID", mUUID); + gAgent.sendReliableMessage(); + } } else { @@ -441,7 +460,7 @@ bool LLViewerInventoryCategory::fetchDescendents() // This comes from LLInventoryFilter from llfolderview.h U32 sort_order = gSavedSettings.getU32("InventorySortOrder") & 0x1; - std::string url = gAgent.getRegion()->getCapability("FetchInventoryDescendents"); + std::string url = gAgent.getRegion()->getCapability("WebFetchInventoryDescendents"); if (!url.empty()) //Capability found. Build up LLSD and use it. { @@ -449,7 +468,7 @@ bool LLViewerInventoryCategory::fetchDescendents() } else { //Deprecated, but if we don't have a capability, use the old system. - llinfos << "FetchInventoryDescendents capability not found. Using deprecated UDP message." << llendl; + llinfos << "WebFetchInventoryDescendents capability not found. Using deprecated UDP message." << llendl; LLMessageSystem* msg = gMessageSystem; msg->newMessage("FetchInventoryDescendents"); msg->nextBlock("AgentData"); diff --git a/linden/indra/newview/llviewerjoint.cpp b/linden/indra/newview/llviewerjoint.cpp index 914448e..d0359d6 100644 --- a/linden/indra/newview/llviewerjoint.cpp +++ b/linden/indra/newview/llviewerjoint.cpp @@ -149,7 +149,7 @@ void LLViewerJoint::setValid( BOOL valid, BOOL recursive ) // //---------------------------------------------------------------- // if (mComponents & SC_AXES) // { -// gGL.begin(LLVertexBuffer::LINES); +// gGL.begin(LLRender::LINES); // gGL.color3f( 1.0f, 0.0f, 0.0f ); // gGL.vertex3f( 0.0f, 0.0f, 0.0f ); // gGL.vertex3f( 0.1f, 0.0f, 0.0f ); @@ -171,7 +171,7 @@ void LLViewerJoint::setValid( BOOL valid, BOOL recursive ) // { // gGL.color3f( 1.0f, 1.0f, 0.0f ); -// gGL.begin(LLVertexBuffer::TRIANGLES); +// gGL.begin(LLRender::TRIANGLES); // // joint top half // glNormal3f(nc, nc, nc); @@ -362,7 +362,7 @@ U32 LLViewerJoint::render( F32 pixelArea, BOOL first_pass ) // // render the bone // gGL.color3f( 0.5f, 0.5f, 0.0f ); -// gGL.begin(LLVertexBuffer::TRIANGLES); +// gGL.begin(LLRender::TRIANGLES); // gGL.vertex3f( length, 0.0f, 0.0f); // gGL.vertex3f( 0.0f, boneSize, 0.0f); @@ -524,14 +524,69 @@ LLViewerJointCollisionVolume::LLViewerJointCollisionVolume(const std::string &na void LLViewerJointCollisionVolume::renderCollision() { updateWorldMatrix(); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); + + gGL.pushMatrix(); glMultMatrixf( &mXform.getWorldMatrix().mMatrix[0][0] ); - glColor3f( 0.f, 0.f, 1.f ); - gSphere.render(); + gGL.color3f( 0.f, 0.f, 1.f ); + + gGL.begin(LLRender::LINES); + + LLVector3 v[] = + { + LLVector3(1,0,0), + LLVector3(-1,0,0), + LLVector3(0,1,0), + LLVector3(0,-1,0), + + LLVector3(0,0,-1), + LLVector3(0,0,1), + }; + + //sides + gGL.vertex3fv(v[0].mV); + gGL.vertex3fv(v[2].mV); + + gGL.vertex3fv(v[0].mV); + gGL.vertex3fv(v[3].mV); + + gGL.vertex3fv(v[1].mV); + gGL.vertex3fv(v[2].mV); + + gGL.vertex3fv(v[1].mV); + gGL.vertex3fv(v[3].mV); + + + //top + gGL.vertex3fv(v[0].mV); + gGL.vertex3fv(v[4].mV); + + gGL.vertex3fv(v[1].mV); + gGL.vertex3fv(v[4].mV); + + gGL.vertex3fv(v[2].mV); + gGL.vertex3fv(v[4].mV); + + gGL.vertex3fv(v[3].mV); + gGL.vertex3fv(v[4].mV); + + + //bottom + gGL.vertex3fv(v[0].mV); + gGL.vertex3fv(v[5].mV); + + gGL.vertex3fv(v[1].mV); + gGL.vertex3fv(v[5].mV); + + gGL.vertex3fv(v[2].mV); + gGL.vertex3fv(v[5].mV); + + gGL.vertex3fv(v[3].mV); + gGL.vertex3fv(v[5].mV); + + gGL.end(); - glPopMatrix(); + gGL.popMatrix(); } LLVector3 LLViewerJointCollisionVolume::getVolumePos(LLVector3 &offset) diff --git a/linden/indra/newview/llviewerjointattachment.cpp b/linden/indra/newview/llviewerjointattachment.cpp index 4b58361..42b8d9a 100644 --- a/linden/indra/newview/llviewerjointattachment.cpp +++ b/linden/indra/newview/llviewerjointattachment.cpp @@ -91,7 +91,7 @@ U32 LLViewerJointAttachment::drawShape( F32 pixelArea, BOOL first_pass ) LLGLDisable cull_face(GL_CULL_FACE); gGL.color4f(1.f, 1.f, 1.f, 1.f); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); { gGL.vertex3f(-0.1f, 0.1f, 0.f); gGL.vertex3f(-0.1f, -0.1f, 0.f); diff --git a/linden/indra/newview/llviewerjointmesh.cpp b/linden/indra/newview/llviewerjointmesh.cpp index b590907..5c2002b 100644 --- a/linden/indra/newview/llviewerjointmesh.cpp +++ b/linden/indra/newview/llviewerjointmesh.cpp @@ -537,7 +537,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass) if (mTestImageName) { - LLImageGL::bindExternalTexture( mTestImageName, 0, GL_TEXTURE_2D ); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mTestImageName); if (mIsTransparent) { @@ -553,12 +553,12 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass) { if( mLayerSet->hasComposite() ) { - mLayerSet->getComposite()->bindTexture(); + gGL.getTexUnit(0)->bind(mLayerSet->getComposite()->getTexture()); } else { llwarns << "Layerset without composite" << llendl; - gImageList.getImage(IMG_DEFAULT)->bind(); + gGL.getTexUnit(0)->bind(gImageList.getImage(IMG_DEFAULT)); } } else @@ -566,13 +566,13 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass) { if (!mTexture->getClampS() || !mTexture->getClampT()) { - mTexture->bind(); + gGL.getTexUnit(0)->bind(mTexture.get()); mTexture->overrideClamp (TRUE, TRUE); } } else { - gImageList.getImage(IMG_DEFAULT_AVATAR)->bind(); + gGL.getTexUnit(0)->bind(gImageList.getImage(IMG_DEFAULT_AVATAR)); } if (gRenderForSelect) @@ -584,7 +584,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass) } else { - LLImageGL::unbindTexture(0); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } } @@ -605,14 +605,14 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass) } } - mFace->mVertexBuffer->drawRange(LLVertexBuffer::TRIANGLES, start, end, count, offset); + mFace->mVertexBuffer->drawRange(LLRender::TRIANGLES, start, end, count, offset); } else { glPushMatrix(); LLMatrix4 jointToWorld = getWorldMatrix(); glMultMatrixf((GLfloat*)jointToWorld.mMatrix); - mFace->mVertexBuffer->drawRange(LLVertexBuffer::TRIANGLES, start, end, count, offset); + mFace->mVertexBuffer->drawRange(LLRender::TRIANGLES, start, end, count, offset); glPopMatrix(); } gPipeline.addTrianglesDrawn(count/3); @@ -626,7 +626,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass) if (mTexture.notNull()) { - mTexture->bind(); + gGL.getTexUnit(0)->bind(mTexture.get()); mTexture->restoreClamp(); } diff --git a/linden/indra/newview/llviewermedia.cpp b/linden/indra/newview/llviewermedia.cpp index e99c838..00639cc 100644 --- a/linden/indra/newview/llviewermedia.cpp +++ b/linden/indra/newview/llviewermedia.cpp @@ -552,6 +552,7 @@ void LLViewerMedia::buildMediaManagerData( LLMediaManagerData* init_data ) // static void LLViewerMedia::cleanupClass() { + stop() ; LLMediaManager::cleanupClass(); } diff --git a/linden/indra/newview/llviewermenu.cpp b/linden/indra/newview/llviewermenu.cpp index c2a8055..9782d4b 100644 --- a/linden/indra/newview/llviewermenu.cpp +++ b/linden/indra/newview/llviewermenu.cpp @@ -85,6 +85,7 @@ #include "llfloateranimpreview.h" #include "llfloateravatarinfo.h" #include "llfloateravatartextures.h" +#include "llfloaterbeacons.h" #include "llfloaterbuildoptions.h" #include "llfloaterbump.h" #include "llfloaterbuy.h" @@ -323,13 +324,6 @@ void handle_talk_to(void *userdata); // Debug menu void show_permissions_control(void*); void toggle_build_options(void* user_data); -#if 0 // Unused -void handle_audio_status_1(void*); -void handle_audio_status_2(void*); -void handle_audio_status_3(void*); -void handle_audio_status_4(void*); -#endif -void manage_landmarks(void*); void reload_ui(void*); void handle_agent_stop_moving(void*); void print_packets_lost(void*); @@ -795,12 +789,6 @@ void init_client_menu(LLMenuGL* menu) &menu_check_control, (void*)"QuietSnapshotsToDisk")); - menu->append(new LLMenuItemCheckGL( "Compress Snapshots to Disk", - &menu_toggle_control, - NULL, - &menu_check_control, - (void*)"CompressSnapshotsToDisk")); - menu->append(new LLMenuItemCheckGL("Show Mouselook Crosshairs", &menu_toggle_control, NULL, @@ -948,6 +936,7 @@ void init_client_menu(LLMenuGL* menu) sub->append(new LLMenuItemCallGL("Force LLError And Crash", &force_error_llerror)); sub->append(new LLMenuItemCallGL("Force Bad Memory Access", &force_error_bad_memory_access)); sub->append(new LLMenuItemCallGL("Force Infinite Loop", &force_error_infinite_loop)); + sub->append(new LLMenuItemCallGL("Force Disconnect Viewer", &handle_disconnect_viewer)); // *NOTE:Mani this isn't handled yet... sub->append(new LLMenuItemCallGL("Force Software Exception", &force_error_unhandled_exception)); sub->createJumpKeys(); menu->appendMenu(sub); @@ -1162,10 +1151,6 @@ void init_debug_rendering_menu(LLMenuGL* menu) &LLPipeline::toggleRenderDebugFeature, NULL, &LLPipeline::toggleRenderDebugFeatureControl, (void*)LLPipeline::RENDER_DEBUG_FEATURE_FOG, KEY_F6, MASK_ALT|MASK_CONTROL)); - sub_menu->append(new LLMenuItemCheckGL("Palletized Textures", - &LLPipeline::toggleRenderDebugFeature, NULL, - &LLPipeline::toggleRenderDebugFeatureControl, - (void*)LLPipeline::RENDER_DEBUG_FEATURE_PALETTE, KEY_F7, MASK_ALT|MASK_CONTROL)); sub_menu->append(new LLMenuItemCheckGL("Test FRInfo", &LLPipeline::toggleRenderDebugFeature, NULL, &LLPipeline::toggleRenderDebugFeatureControl, @@ -1216,9 +1201,6 @@ void init_debug_rendering_menu(LLMenuGL* menu) sub_menu->append(new LLMenuItemCheckGL("Face Area (sqrt(A))",&LLPipeline::toggleRenderDebug, NULL, &LLPipeline::toggleRenderDebugControl, (void*)LLPipeline::RENDER_DEBUG_FACE_AREA)); - sub_menu->append(new LLMenuItemCheckGL("Pick Render", &LLPipeline::toggleRenderDebug, NULL, - &LLPipeline::toggleRenderDebugControl, - (void*)LLPipeline::RENDER_DEBUG_PICKING)); sub_menu->append(new LLMenuItemCheckGL("Lights", &LLPipeline::toggleRenderDebug, NULL, &LLPipeline::toggleRenderDebugControl, (void*)LLPipeline::RENDER_DEBUG_LIGHTS)); @@ -1237,9 +1219,7 @@ void init_debug_rendering_menu(LLMenuGL* menu) sub_menu->append(new LLMenuItemCheckGL("Sculpt", &LLPipeline::toggleRenderDebug, NULL, &LLPipeline::toggleRenderDebugControl, (void*)LLPipeline::RENDER_DEBUG_SCULPTED)); - - sub_menu->append(new LLMenuItemToggleGL("Show Select Buffer", &gDebugSelect)); - + sub_menu->append(new LLMenuItemCallGL("Vectorize Perf Test", &run_vectorize_perf_test)); sub_menu = new LLMenuGL("Render Tests"); @@ -1757,6 +1737,24 @@ class LLViewCheckJoystickFlycam : public view_listener_t } }; +class LLViewCommunicate : public view_listener_t +{ + bool handleEvent(LLPointer event, const LLSD& userdata) + { + if (LLFloaterChatterBox::getInstance()->getFloaterCount() == 0) + { + LLFloaterMyFriends::toggleInstance(); + } + else + { + LLFloaterChatterBox::toggleInstance(); + } + + return true; + } +}; + + void handle_toggle_flycam() { LLViewerJoystick::getInstance()->toggleFlycam(); @@ -2225,37 +2223,71 @@ class LLAvatarDebug : public view_listener_t } }; +struct MenuCallbackData +{ + bool ban_enabled; + LLUUID avatar_id; +}; + void callback_eject(S32 option, void* data) { - LLUUID* avatar_id = (LLUUID*) data; + MenuCallbackData *callback_data = (MenuCallbackData*)data; + if (!callback_data) + { + return; + } + if (2 == option) + { + // Cancle button. + return; + } + LLUUID avatar_id = callback_data->avatar_id; + bool ban_enabled = callback_data->ban_enabled; - if (0 == option || 1 == option) + if (0 == option) { + // Eject button LLMessageSystem* msg = gMessageSystem; - LLViewerObject* avatar = gObjectList.findObject(*avatar_id); + LLViewerObject* avatar = gObjectList.findObject(avatar_id); if (avatar) { U32 flags = 0x0; - if (1 == option) - { - // eject and add to ban list - flags |= 0x1; - } + msg->newMessage("EjectUser"); + msg->nextBlock("AgentData"); + msg->addUUID("AgentID", gAgent.getID() ); + msg->addUUID("SessionID", gAgent.getSessionID() ); + msg->nextBlock("Data"); + msg->addUUID("TargetID", avatar_id ); + msg->addU32("Flags", flags ); + msg->sendReliable( avatar->getRegion()->getHost() ); + } + } + else if (ban_enabled) + { + // This is tricky. It is similar to say if it is not an 'Eject' button, + // and it is also not an 'Cancle' button, and ban_enabled==ture, + // it should be the 'Eject and Ban' button. + LLMessageSystem* msg = gMessageSystem; + LLViewerObject* avatar = gObjectList.findObject(avatar_id); + if (avatar) + { + U32 flags = 0x1; msg->newMessage("EjectUser"); msg->nextBlock("AgentData"); msg->addUUID("AgentID", gAgent.getID() ); msg->addUUID("SessionID", gAgent.getSessionID() ); msg->nextBlock("Data"); - msg->addUUID("TargetID", *avatar_id ); + msg->addUUID("TargetID", avatar_id ); msg->addU32("Flags", flags ); msg->sendReliable( avatar->getRegion()->getHost() ); } } - delete avatar_id; - avatar_id = NULL; + + delete callback_data; + callback_data = NULL; } class LLAvatarEject : public view_listener_t @@ -2265,23 +2297,50 @@ class LLAvatarEject : public view_listener_t LLVOAvatar* avatar = find_avatar_from_object( LLSelectMgr::getInstance()->getSelection()->getPrimaryObject() ); if( avatar ) { - LLUUID* avatar_id = new LLUUID( avatar->getID() ); + MenuCallbackData *data = new MenuCallbackData; + (*data).avatar_id = avatar->getID(); std::string fullname = avatar->getFullname(); - if (!fullname.empty()) + const LLVector3d& pos = avatar->getPositionGlobal(); + LLParcel* parcel = LLViewerParcelMgr::getInstance()->selectParcelAt(pos)->getParcel(); + + if (LLViewerParcelMgr::getInstance()->isParcelOwnedByAgent(parcel,GP_LAND_MANAGE_BANNED)) { - LLStringUtil::format_map_t args; - args["[AVATAR_NAME]"] = fullname; - gViewerWindow->alertXml("EjectAvatarFullname", - args, - callback_eject, - (void*)avatar_id); + (*data).ban_enabled = true; + if (!fullname.empty()) + { + LLStringUtil::format_map_t args; + args["[AVATAR_NAME]"] = fullname; + gViewerWindow->alertXml("EjectAvatarFullname", + args, + callback_eject, + (void*)data); + } + else + { + gViewerWindow->alertXml("EjectAvatar", + callback_eject, + (void*)data); + } } else { - gViewerWindow->alertXml("EjectAvatar", - callback_eject, - (void*)avatar_id); + (*data).ban_enabled = false; + if (!fullname.empty()) + { + LLStringUtil::format_map_t args; + args["[AVATAR_NAME]"] = fullname; + gViewerWindow->alertXml("EjectAvatarFullnameNoBan", + args, + callback_eject, + (void*)data); + } + else + { + gViewerWindow->alertXml("EjectAvatarNoBan", + callback_eject, + (void*)data); + } } } return true; @@ -2298,12 +2357,18 @@ class LLAvatarEnableFreezeEject : public view_listener_t if (new_value) { const LLVector3& pos = avatar->getPositionRegion(); + const LLVector3d& pos_global = avatar->getPositionGlobal(); + LLParcel* parcel = LLViewerParcelMgr::getInstance()->selectParcelAt(pos_global)->getParcel(); LLViewerRegion* region = avatar->getRegion(); new_value = (region != NULL); - + if (new_value) { - new_value = (region->isOwnedSelf(pos) || region->isOwnedGroup(pos)); + new_value = region->isOwnedSelf(pos); + if (!new_value || region->isOwnedGroup(pos)) + { + new_value = LLViewerParcelMgr::getInstance()->isParcelOwnedByAgent(parcel,GP_LAND_ADMIN); + } } } @@ -2674,33 +2739,6 @@ void process_grant_godlike_powers(LLMessageSystem* msg, void**) } } -void load_url_local_file(const std::string& file_name) -{ - if( gAgent.cameraMouselook() ) - { - gAgent.changeCameraToDefault(); - } - -#if LL_DARWIN || LL_LINUX || LL_SOLARIS - // MBW -- If the Mac client is in fullscreen mode, it needs to go windowed so the browser will be visible. - if(gViewerWindow->mWindow->getFullscreen()) - { - gViewerWindow->toggleFullscreen(TRUE); - } -#endif - - // JC - system() blocks until IE has launched. - // spawn() runs asynchronously, but opens a command prompt. - // ShellExecute() just opens the damn file with the default - // web browser. - std::string full_path = "file:///"; - full_path.append(gDirUtilp->getAppRODataDir()); - full_path.append(gDirUtilp->getDirDelimiter()); - full_path.append(file_name); - - LLWeb::loadURL(full_path); -} - /* class LLHaveCallingcard : public LLInventoryCollectFunctor { @@ -2908,63 +2946,16 @@ void show_permissions_control(void*) floaterp->mPermissions->addPermissionsData("foo3", LLUUID::null, 0); } -#if 0 // Unused (these just modify AudioInfoPage which is not used anywhere in the code -void handle_audio_status_1(void*) -{ - S32 page = gSavedSettings.getS32("AudioInfoPage"); - if (1 == page) - { - page = 0; - } - else - { - page = 1; - } - gSavedSettings.setS32("AudioInfoPage", page); -} - -void handle_audio_status_2(void*) -{ - S32 page = gSavedSettings.getS32("AudioInfoPage"); - if (2 == page) - { - page = 0; - } - else - { - page = 2; - } - gSavedSettings.setS32("AudioInfoPage", page); -} - -void handle_audio_status_3(void*) -{ - S32 page = gSavedSettings.getS32("AudioInfoPage"); - if (3 == page) - { - page = 0; - } - else - { - page = 3; - } - gSavedSettings.setS32("AudioInfoPage", page); -} -void handle_audio_status_4(void*) +class LLCreateLandmarkCallback : public LLInventoryCallback { - S32 page = gSavedSettings.getS32("AudioInfoPage"); - if (4 == page) - { - page = 0; - } - else +public: + /*virtual*/ void fire(const LLUUID& inv_item) { - page = 4; + llinfos << "Created landmark with inventory id " << inv_item + << llendl; } - gSavedSettings.setS32("AudioInfoPage", page); -} -#endif +}; void reload_ui(void *) { @@ -3197,26 +3188,7 @@ void reset_view_final( BOOL proceed, void* ) return; } - gAgent.changeCameraToDefault(); - - if (LLViewerJoystick::getInstance()->getOverrideCamera()) - { - handle_toggle_flycam(); - } - - // reset avatar mode from eventual residual motion - if (LLToolMgr::getInstance()->inBuildMode()) - { - LLViewerJoystick::getInstance()->moveAvatar(true); - } - - gAgent.resetView(!gFloaterTools->getVisible()); - gFloaterTools->close(); - - gViewerWindow->showCursor(); - - // Switch back to basic toolset - LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); + gAgent.resetView(TRUE, TRUE); } class LLViewLookAtLastChatter : public view_listener_t @@ -4881,7 +4853,7 @@ class LLWorldCreateLandmark : public view_listener_t LLAssetType::AT_LANDMARK, LLInventoryType::IT_LANDMARK, NOT_WEARABLE, PERM_ALL, - NULL); + new LLCreateLandmarkCallback); return true; } }; @@ -5301,6 +5273,10 @@ class LLShowFloater : public view_listener_t { LLFloaterActiveSpeakers::toggleInstance(LLSD()); } + else if (floater_name == "beacons") + { + LLFloaterBeacons::toggleInstance(LLSD()); + } return true; } }; @@ -5348,6 +5324,10 @@ class LLFloaterVisible : public view_listener_t { new_value = LLFloaterActiveSpeakers::instanceVisible(LLSD()); } + else if (floater_name == "beacons") + { + new_value = LLFloaterBeacons::instanceVisible(LLSD()); + } gMenuHolder->findControl(control_name)->setValue(new_value); return true; } @@ -5384,37 +5364,6 @@ class LLPromptShowURL : public view_listener_t } }; -void callback_show_file(S32 option, void* data) -{ - std::string* filenamep = (std::string*)data; - if (0 == option) - { - load_url_local_file(*filenamep); - } - delete filenamep; -} - -class LLPromptShowFile : public view_listener_t -{ - bool handleEvent(LLPointer event, const LLSD& userdata) - { - std::string param = userdata.asString(); - std::string::size_type offset = param.find(","); - if (offset != param.npos) - { - std::string alert = param.substr(0, offset); - std::string file = param.substr(offset+1); - std::string* file_copy = new std::string(file); - gViewerWindow->alertXml(alert, callback_show_file, file_copy); - } - else - { - llinfos << "PromptShowFile invalid parameters! Expecting \"ALERT,FILE\"." << llendl; - } - return true; - } -}; - class LLShowAgentProfile : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) @@ -6038,10 +5987,10 @@ namespace void queue_actions(LLFloaterScriptQueue* q, const std::string& noscriptmsg, const std::string& nomodmsg) { - // Apply until an object fails QueueObjects func(q); - const bool firstonly = true; - bool fail = LLSelectMgr::getInstance()->getSelection()->applyToObjects(&func, firstonly); + LLSelectMgr *mgr = LLSelectMgr::getInstance(); + LLObjectSelectionHandle selectHandle = mgr->getSelection(); + bool fail = selectHandle->applyToObjects(&func); if(fail) { if ( !func.scripted ) @@ -6066,61 +6015,67 @@ void queue_actions(LLFloaterScriptQueue* q, const std::string& noscriptmsg, cons } } +void handle_compile_queue(std::string to_lang) +{ + LLFloaterCompileQueue* queue; + if (to_lang == "mono") + { + queue = LLFloaterCompileQueue::create(TRUE); + } + else + { + queue = LLFloaterCompileQueue::create(FALSE); + } + queue_actions(queue, "CannotRecompileSelectObjectsNoScripts", "CannotRecompileSelectObjectsNoPermission"); +} + +void handle_reset_selection(void) +{ + LLFloaterResetQueue* queue = LLFloaterResetQueue::create(); + queue_actions(queue, "CannotResetSelectObjectsNoScripts", "CannotResetSelectObjectsNoPermission"); +} + +void handle_set_run_selection(void) +{ + LLFloaterRunQueue* queue = LLFloaterRunQueue::create(); + queue_actions(queue, "CannotSetRunningSelectObjectsNoScripts", "CannotSerRunningSelectObjectsNoPermission"); +} + +void handle_set_not_run_selection(void) +{ + LLFloaterNotRunQueue* queue = LLFloaterNotRunQueue::create(); + queue_actions(queue, "CannotSetRunningNotSelectObjectsNoScripts", "CannotSerRunningNotSelectObjectsNoPermission"); +} + class LLToolsSelectedScriptAction : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) { std::string action = userdata.asString(); - LLFloaterScriptQueue* queue = NULL; if (action == "compile mono") { - queue = LLFloaterCompileQueue::create(TRUE); + handle_compile_queue("mono"); } if (action == "compile lsl") { - queue = LLFloaterCompileQueue::create(FALSE); + handle_compile_queue("lsl"); } else if (action == "reset") { - queue = LLFloaterResetQueue::create(); + handle_reset_selection(); } else if (action == "start") { - queue = LLFloaterRunQueue::create(); + handle_set_run_selection(); } else if (action == "stop") { - queue = LLFloaterNotRunQueue::create(); - } - if (!queue) - { - return true; + handle_set_not_run_selection(); } - - queue_actions(queue, "CannotRecompileSelectObjectsNoScripts", "CannotRecompileSelectObjectsNoPermission"); - return true; } }; -void handle_reset_selection(void*) -{ - LLFloaterResetQueue* queue = LLFloaterResetQueue::create(); - queue_actions(queue, "CannotResetSelectObjectsNoScripts", "CannotResetSelectObjectsNoPermission"); -} - -void handle_set_run_selection(void*) -{ - LLFloaterRunQueue* queue = LLFloaterRunQueue::create(); - queue_actions(queue, "CannotSetRunningSelectObjectsNoScripts", "CannotSerRunningSelectObjectsNoPermission"); -} - -void handle_set_not_run_selection(void*) -{ - LLFloaterNotRunQueue* queue = LLFloaterNotRunQueue::create(); - queue_actions(queue, "CannotSetRunningNotSelectObjectsNoScripts", "CannotSerRunningNotSelectObjectsNoPermission"); -} - void handle_selected_texture_info(void*) { for (LLObjectSelection::valid_iterator iter = LLSelectMgr::getInstance()->getSelection()->valid_begin(); @@ -7139,148 +7094,6 @@ class LLViewCheckHighlightTransparent : public view_listener_t } }; -class LLViewBeaconWidth : public view_listener_t -{ - bool handleEvent(LLPointer event, const LLSD& userdata) - { - std::string width = userdata.asString(); - if(width == "1") - { - gSavedSettings.setS32("DebugBeaconLineWidth", 1); - } - else if(width == "4") - { - gSavedSettings.setS32("DebugBeaconLineWidth", 4); - } - else if(width == "16") - { - gSavedSettings.setS32("DebugBeaconLineWidth", 16); - } - else if(width == "32") - { - gSavedSettings.setS32("DebugBeaconLineWidth", 32); - } - - return true; - } -}; - - -class LLViewToggleBeacon : public view_listener_t -{ - bool handleEvent(LLPointer event, const LLSD& userdata) - { - std::string beacon = userdata.asString(); - if (beacon == "scriptsbeacon") - { - LLPipeline::toggleRenderScriptedBeacons(NULL); - gSavedSettings.setBOOL( "scriptsbeacon", LLPipeline::getRenderScriptedBeacons(NULL) ); - // toggle the other one off if it's on - if (LLPipeline::getRenderScriptedBeacons(NULL) && LLPipeline::getRenderScriptedTouchBeacons(NULL)) - { - LLPipeline::toggleRenderScriptedTouchBeacons(NULL); - gSavedSettings.setBOOL( "scripttouchbeacon", LLPipeline::getRenderScriptedTouchBeacons(NULL) ); - } - } - else if (beacon == "physicalbeacon") - { - LLPipeline::toggleRenderPhysicalBeacons(NULL); - gSavedSettings.setBOOL( "physicalbeacon", LLPipeline::getRenderPhysicalBeacons(NULL) ); - } - else if (beacon == "soundsbeacon") - { - LLPipeline::toggleRenderSoundBeacons(NULL); - gSavedSettings.setBOOL( "soundsbeacon", LLPipeline::getRenderSoundBeacons(NULL) ); - } - else if (beacon == "particlesbeacon") - { - LLPipeline::toggleRenderParticleBeacons(NULL); - gSavedSettings.setBOOL( "particlesbeacon", LLPipeline::getRenderParticleBeacons(NULL) ); - } - else if (beacon == "scripttouchbeacon") - { - LLPipeline::toggleRenderScriptedTouchBeacons(NULL); - gSavedSettings.setBOOL( "scripttouchbeacon", LLPipeline::getRenderScriptedTouchBeacons(NULL) ); - // toggle the other one off if it's on - if (LLPipeline::getRenderScriptedBeacons(NULL) && LLPipeline::getRenderScriptedTouchBeacons(NULL)) - { - LLPipeline::toggleRenderScriptedBeacons(NULL); - gSavedSettings.setBOOL( "scriptsbeacon", LLPipeline::getRenderScriptedBeacons(NULL) ); - } - } - else if (beacon == "renderbeacons") - { - LLPipeline::toggleRenderBeacons(NULL); - gSavedSettings.setBOOL( "renderbeacons", LLPipeline::getRenderBeacons(NULL) ); - // toggle the other one on if it's not - if (!LLPipeline::getRenderBeacons(NULL) && !LLPipeline::getRenderHighlights(NULL)) - { - LLPipeline::toggleRenderHighlights(NULL); - gSavedSettings.setBOOL( "renderhighlights", LLPipeline::getRenderHighlights(NULL) ); - } - } - else if (beacon == "renderhighlights") - { - LLPipeline::toggleRenderHighlights(NULL); - gSavedSettings.setBOOL( "renderhighlights", LLPipeline::getRenderHighlights(NULL) ); - // toggle the other one on if it's not - if (!LLPipeline::getRenderBeacons(NULL) && !LLPipeline::getRenderHighlights(NULL)) - { - LLPipeline::toggleRenderBeacons(NULL); - gSavedSettings.setBOOL( "renderbeacons", LLPipeline::getRenderBeacons(NULL) ); - } - } - - return true; - } -}; - -class LLViewCheckBeaconEnabled : public view_listener_t -{ - bool handleEvent(LLPointer event, const LLSD& userdata) - { - std::string beacon = userdata["data"].asString(); - bool new_value = false; - if (beacon == "scriptsbeacon") - { - new_value = gSavedSettings.getBOOL( "scriptsbeacon"); - LLPipeline::setRenderScriptedBeacons(new_value); - } - else if (beacon == "physicalbeacon") - { - new_value = gSavedSettings.getBOOL( "physicalbeacon"); - LLPipeline::setRenderPhysicalBeacons(new_value); - } - else if (beacon == "soundsbeacon") - { - new_value = gSavedSettings.getBOOL( "soundsbeacon"); - LLPipeline::setRenderSoundBeacons(new_value); - } - else if (beacon == "particlesbeacon") - { - new_value = gSavedSettings.getBOOL( "particlesbeacon"); - LLPipeline::setRenderParticleBeacons(new_value); - } - else if (beacon == "scripttouchbeacon") - { - new_value = gSavedSettings.getBOOL( "scripttouchbeacon"); - LLPipeline::setRenderScriptedTouchBeacons(new_value); - } - else if (beacon == "renderbeacons") - { - new_value = gSavedSettings.getBOOL( "renderbeacons"); - LLPipeline::setRenderBeacons(new_value); - } - else if (beacon == "renderhighlights") - { - new_value = gSavedSettings.getBOOL( "renderhighlights"); - LLPipeline::setRenderHighlights(new_value); - } - gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); - return true; - } -}; - class LLViewToggleRenderType : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) @@ -7622,12 +7435,11 @@ void initialize_menus() addMenu(new LLViewMouselook(), "View.Mouselook"); addMenu(new LLViewBuildMode(), "View.BuildMode"); addMenu(new LLViewJoystickFlycam(), "View.JoystickFlycam"); + addMenu(new LLViewCommunicate(), "View.Communicate"); addMenu(new LLViewResetView(), "View.ResetView"); addMenu(new LLViewLookAtLastChatter(), "View.LookAtLastChatter"); addMenu(new LLViewShowHoverTips(), "View.ShowHoverTips"); addMenu(new LLViewHighlightTransparent(), "View.HighlightTransparent"); - addMenu(new LLViewToggleBeacon(), "View.ToggleBeacon"); - addMenu(new LLViewBeaconWidth(), "View.BeaconWidth"); addMenu(new LLViewToggleRenderType(), "View.ToggleRenderType"); addMenu(new LLViewShowHUDAttachments(), "View.ShowHUDAttachments"); addMenu(new LLViewZoomOut(), "View.ZoomOut"); @@ -7643,7 +7455,6 @@ void initialize_menus() addMenu(new LLViewCheckJoystickFlycam(), "View.CheckJoystickFlycam"); addMenu(new LLViewCheckShowHoverTips(), "View.CheckShowHoverTips"); addMenu(new LLViewCheckHighlightTransparent(), "View.CheckHighlightTransparent"); - addMenu(new LLViewCheckBeaconEnabled(), "View.CheckBeaconEnabled"); addMenu(new LLViewCheckRenderType(), "View.CheckRenderType"); addMenu(new LLViewCheckHUDAttachments(), "View.CheckHUDAttachments"); @@ -7777,7 +7588,6 @@ void initialize_menus() // Generic actions addMenu(new LLShowFloater(), "ShowFloater"); addMenu(new LLPromptShowURL(), "PromptShowURL"); - addMenu(new LLPromptShowFile(), "PromptShowFile"); addMenu(new LLShowAgentProfile(), "ShowAgentProfile"); addMenu(new LLShowAgentGroups(), "ShowAgentGroups"); addMenu(new LLToggleControl(), "ToggleControl"); diff --git a/linden/indra/newview/llviewermenu.h b/linden/indra/newview/llviewermenu.h index e003e90..495e826 100644 --- a/linden/indra/newview/llviewermenu.h +++ b/linden/indra/newview/llviewermenu.h @@ -50,7 +50,6 @@ void cleanup_menus(); void show_debug_menus(); // checks for if menus should be shown first. void show_context_menu( S32 x, S32 y, MASK mask ); void show_build_mode_context_menu(S32 x, S32 y, MASK mask); -void load_url_local_file(const std::string& file_name); BOOL enable_save_into_inventory(void*); void handle_reset_view(); void handle_cut(void*); diff --git a/linden/indra/newview/llviewermenufile.cpp b/linden/indra/newview/llviewermenufile.cpp index 5dd760e..d9d8636 100644 --- a/linden/indra/newview/llviewermenufile.cpp +++ b/linden/indra/newview/llviewermenufile.cpp @@ -503,7 +503,7 @@ void handle_compress_image(void*) } else { - llinfos << "Compression failed: " << LLImageBase::getLastError() << llendl; + llinfos << "Compression failed: " << LLImage::getLastError() << llendl; } infile = picker.getNextFile(); @@ -554,9 +554,9 @@ void upload_new_resource(const std::string& src_filename, std::string name, IMG_CODEC_BMP )) { error_message = llformat( "Problem with file %s:\n\n%s\n", - src_filename.c_str(), LLImageBase::getLastError().c_str()); + src_filename.c_str(), LLImage::getLastError().c_str()); args["[FILE]"] = src_filename; - args["[ERROR]"] = LLImageBase::getLastError(); + args["[ERROR]"] = LLImage::getLastError(); upload_error(error_message, "ProblemWithFile", filename, args); return; } @@ -569,9 +569,9 @@ void upload_new_resource(const std::string& src_filename, std::string name, IMG_CODEC_TGA )) { error_message = llformat("Problem with file %s:\n\n%s\n", - src_filename.c_str(), LLImageBase::getLastError().c_str()); + src_filename.c_str(), LLImage::getLastError().c_str()); args["[FILE]"] = src_filename; - args["[ERROR]"] = LLImageBase::getLastError(); + args["[ERROR]"] = LLImage::getLastError(); upload_error(error_message, "ProblemWithFile", filename, args); return; } @@ -584,9 +584,9 @@ void upload_new_resource(const std::string& src_filename, std::string name, IMG_CODEC_JPEG )) { error_message = llformat("Problem with file %s:\n\n%s\n", - src_filename.c_str(), LLImageBase::getLastError().c_str()); + src_filename.c_str(), LLImage::getLastError().c_str()); args["[FILE]"] = src_filename; - args["[ERROR]"] = LLImageBase::getLastError(); + args["[ERROR]"] = LLImage::getLastError(); upload_error(error_message, "ProblemWithFile", filename, args); return; } @@ -599,9 +599,9 @@ void upload_new_resource(const std::string& src_filename, std::string name, IMG_CODEC_PNG )) { error_message = llformat("Problem with file %s:\n\n%s\n", - src_filename.c_str(), LLImageBase::getLastError().c_str()); + src_filename.c_str(), LLImage::getLastError().c_str()); args["[FILE]"] = src_filename; - args["[ERROR]"] = LLImageBase::getLastError(); + args["[ERROR]"] = LLImage::getLastError(); upload_error(error_message, "ProblemWithFile", filename, args); return; } diff --git a/linden/indra/newview/llviewermessage.cpp b/linden/indra/newview/llviewermessage.cpp index 0e39026..30e5e26 100644 --- a/linden/indra/newview/llviewermessage.cpp +++ b/linden/indra/newview/llviewermessage.cpp @@ -356,7 +356,7 @@ void process_layer_data(LLMessageSystem *mesgsys, void **user_data) // size_t nread = fread(buffer, 1, length, fXML); // if (nread < (size_t) length) // { -// llwarns << "Short read" << llendl; +// LL_WARNS("Messaging") << "Short read" << LL_ENDL; // } // buffer[nread] = '\0'; // fclose(fXML); @@ -3308,8 +3308,7 @@ void process_sound_trigger(LLMessageSystem *msg, void **) return; } - F32 volume = gSavedSettings.getBOOL("MuteSounds") ? 0.f : (gain * gSavedSettings.getF32("AudioLevelSFX")); - gAudiop->triggerSound(sound_id, owner_id, volume, pos_global); + gAudiop->triggerSound(sound_id, owner_id, gain, LLAudioEngine::AUDIO_TYPE_SFX, pos_global); } void process_preload_sound(LLMessageSystem *msg, void **user_data) @@ -3506,6 +3505,15 @@ void process_sim_stats(LLMessageSystem *msg, void **user_data) case LL_SIM_STAT_SIMPHYSICSMEMORY: LLViewerStats::getInstance()->mPhysicsMemoryAllocated.addValue(stat_value); break; + case LL_SIM_STAT_SIMSPARETIME: + LLViewerStats::getInstance()->mSimSpareMsec.addValue(stat_value); + break; + case LL_SIM_STAT_SIMSLEEPTIME: + LLViewerStats::getInstance()->mSimSleepMsec.addValue(stat_value); + break; + case LL_SIM_STAT_IOPUMPTIME: + LLViewerStats::getInstance()->mSimPumpIOMsec.addValue(stat_value); + break; default: // Used to be a commented out warning. LL_DEBUGS("Messaging") << "Unknown stat id" << stat_id << LL_ENDL; @@ -4718,7 +4726,7 @@ void process_teleport_local(LLMessageSystem *msg,void**) gAgent.slamLookAt(look_at); // likewise make sure the camera is behind the avatar - gAgent.resetView(TRUE); + gAgent.resetView(TRUE, TRUE); // send camera update to new region gAgent.updateCamera(); diff --git a/linden/indra/newview/llviewernetwork.cpp b/linden/indra/newview/llviewernetwork.cpp index 13d432a..25bdcb7 100644 --- a/linden/indra/newview/llviewernetwork.cpp +++ b/linden/indra/newview/llviewernetwork.cpp @@ -58,10 +58,22 @@ static LLGridData gGridInfo[GRID_INFO_COUNT] = "util.aruna.lindenlab.com", "https://login.aruna.lindenlab.com/cgi-bin/login.cgi", "http://aruna-secondlife.webdev.lindenlab.com/helpers/" }, + { "Bharati", + "util.bharati.lindenlab.com", + "https://login.bharati.lindenlab.com/cgi-bin/login.cgi", + "http://bharati-secondlife.webdev.lindenlab.com/helpers/" }, + { "Chandra", + "util.chandra.lindenlab.com", + "https://login.chandra.lindenlab.com/cgi-bin/login.cgi", + "http://chandra-secondlife.webdev.lindenlab.com/helpers/" }, { "Damballah", "util.damballah.lindenlab.com", "https://login.damballah.lindenlab.com/cgi-bin/login.cgi", "http://damballah-secondlife.webdev.lindenlab.com/helpers/" }, + { "Danu", + "util.danu.lindenlab.com", + "https://login.danu.lindenlab.com/cgi-bin/login.cgi", + "http://danu-secondlife.webdev.lindenlab.com/helpers/" }, { "Durga", "util.durga.lindenlab.com", "https://login.durga.lindenlab.com/cgi-bin/login.cgi", @@ -82,6 +94,10 @@ static LLGridData gGridInfo[GRID_INFO_COUNT] = "util.nandi.lindenlab.com", "https://login.nandi.lindenlab.com/cgi-bin/login.cgi", "http://nandi-secondlife.webdev.lindenlab.com/helpers/" }, + { "Parvati", + "util.parvati.lindenlab.com", + "https://login.parvati.lindenlab.com/cgi-bin/login.cgi", + "http://parvati-secondlife.webdev.lindenlab.com/helpers/" }, { "Radha", "util.radha.lindenlab.com", "https://login.radha.lindenlab.com/cgi-bin/login.cgi", @@ -98,6 +114,10 @@ static LLGridData gGridInfo[GRID_INFO_COUNT] = "util.shakti.lindenlab.com", "https://login.shakti.lindenlab.com/cgi-bin/login.cgi", "http://shakti-secondlife.webdev.lindenlab.com/helpers/" }, + { "Skanda", + "util.skanda.lindenlab.com", + "https://login.skanda.lindenlab.com/cgi-bin/login.cgi", + "http://skanda-secondlife.webdev.lindenlab.com/helpers/" }, { "Soma", "util.soma.lindenlab.com", "https://login.soma.lindenlab.com/cgi-bin/login.cgi", diff --git a/linden/indra/newview/llviewernetwork.h b/linden/indra/newview/llviewernetwork.h index 53bb0ab..73c3a5d 100644 --- a/linden/indra/newview/llviewernetwork.h +++ b/linden/indra/newview/llviewernetwork.h @@ -41,16 +41,21 @@ enum EGridInfo GRID_INFO_ADITI, GRID_INFO_AGNI, GRID_INFO_ARUNA, + GRID_INFO_BHARATI, + GRID_INFO_CHANDRA, GRID_INFO_DAMBALLAH, + GRID_INFO_DANU, GRID_INFO_DURGA, GRID_INFO_GANGA, GRID_INFO_MITRA, GRID_INFO_MOHINI, GRID_INFO_NANDI, + GRID_INFO_PARVATI, GRID_INFO_RADHA, GRID_INFO_RAVI, GRID_INFO_SIVA, GRID_INFO_SHAKTI, + GRID_INFO_SKANDA, GRID_INFO_SOMA, GRID_INFO_UMA, GRID_INFO_VAAK, diff --git a/linden/indra/newview/llviewerobject.cpp b/linden/indra/newview/llviewerobject.cpp index c560ced..6dc9af1 100644 --- a/linden/indra/newview/llviewerobject.cpp +++ b/linden/indra/newview/llviewerobject.cpp @@ -150,6 +150,8 @@ LLViewerObject *LLViewerObject::createObject(const LLUUID &id, const LLPCode pco res = new LLVOGround(id, pcode, regionp); break; case LL_VO_PART_GROUP: res = new LLVOPartGroup(id, pcode, regionp); break; + case LL_VO_HUD_PART_GROUP: + res = new LLVOHUDPartGroup(id, pcode, regionp); break; case LL_VO_WL_SKY: res = new LLVOWLSky(id, pcode, regionp); break; default: @@ -159,7 +161,7 @@ LLViewerObject *LLViewerObject::createObject(const LLUUID &id, const LLPCode pco return res; } -LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) +LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp, BOOL is_global) : LLPrimitive(), mChildList(), mID(id), @@ -201,7 +203,10 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe mMedia(NULL), mClickAction(0) { - llassert(mRegionp); + if(!is_global) + { + llassert(mRegionp); + } LLPrimitive::init_primitive(pcode); @@ -209,7 +214,11 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe mLastInterpUpdateSecs = LLFrameTimer::getElapsedSeconds(); mPositionRegion = LLVector3(0.f, 0.f, 0.f); - mPositionAgent = mRegionp->getOriginAgent(); + + if(!is_global) + { + mPositionAgent = mRegionp->getOriginAgent(); + } LLViewerObject::sNumObjects++; } @@ -2763,12 +2772,6 @@ void LLViewerObject::setPixelAreaAndAngle(LLAgent &agent) BOOL LLViewerObject::updateLOD() { - // Update volume of looping sounds - if (mAudioSourcep && mAudioSourcep->isLoop()) - { - F32 volume = gSavedSettings.getBOOL("MuteSounds") ? 0.f : (mAudioGain * gSavedSettings.getF32("AudioLevelSFX")); - mAudioSourcep->setGain(volume); - } return FALSE; } @@ -3055,28 +3058,38 @@ LLNameValue *LLViewerObject::getNVPair(const std::string& name) const void LLViewerObject::updatePositionCaches() const { - if (!isRoot()) - { - mPositionRegion = ((LLViewerObject *)getParent())->getPositionRegion() + getPosition() * getParent()->getRotation(); - mPositionAgent = mRegionp->getPosAgentFromRegion(mPositionRegion); - } - else + if(mRegionp) { - mPositionRegion = getPosition(); - mPositionAgent = mRegionp->getPosAgentFromRegion(mPositionRegion); + if (!isRoot()) + { + mPositionRegion = ((LLViewerObject *)getParent())->getPositionRegion() + getPosition() * getParent()->getRotation(); + mPositionAgent = mRegionp->getPosAgentFromRegion(mPositionRegion); + } + else + { + mPositionRegion = getPosition(); + mPositionAgent = mRegionp->getPosAgentFromRegion(mPositionRegion); + } } } const LLVector3d LLViewerObject::getPositionGlobal() const -{ - LLVector3d position_global = mRegionp->getPosGlobalFromRegion(getPositionRegion()); - - if (isAttachment()) +{ + if(mRegionp) { - position_global = gAgent.getPosGlobalFromAgent(getRenderPosition()); - } + LLVector3d position_global = mRegionp->getPosGlobalFromRegion(getPositionRegion()); - return position_global; + if (isAttachment()) + { + position_global = gAgent.getPosGlobalFromAgent(getRenderPosition()); + } + return position_global; + } + else + { + LLVector3d position_global(getPosition()); + return position_global; + } } const LLVector3 &LLViewerObject::getPositionAgent() const @@ -3398,6 +3411,7 @@ LLViewerObject* LLViewerObject::getRootEdit() const BOOL LLViewerObject::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, + BOOL pick_transparent, S32* face_hit, LLVector3* intersection, LLVector2* tex_coord, @@ -3407,6 +3421,20 @@ BOOL LLViewerObject::lineSegmentIntersect(const LLVector3& start, const LLVector return false; } +BOOL LLViewerObject::lineSegmentBoundingBox(const LLVector3& start, const LLVector3& end) +{ + if (mDrawable.isNull() || mDrawable->isDead()) + { + return FALSE; + } + + const LLVector3* ext = mDrawable->getSpatialExtents(); + + LLVector3 center = (ext[1]+ext[0])*0.5f; + LLVector3 size = (ext[1]-ext[0])*0.5f; + + return LLLineSegmentBoxIntersect(start, end, center, size); +} U8 LLViewerObject::getMediaType() const { @@ -4331,8 +4359,7 @@ void LLViewerObject::setAttachedSound(const LLUUID &audio_uuid, const LLUUID& ow { BOOL queue = flags & LL_SOUND_FLAG_QUEUE; mAudioGain = gain; - F32 volume = gSavedSettings.getBOOL("MuteSounds") ? 0.f : gain * gSavedSettings.getF32("AudioLevelSFX"); - mAudioSourcep->setGain(volume); + mAudioSourcep->setGain(gain); mAudioSourcep->setLoop(flags & LL_SOUND_FLAG_LOOP); mAudioSourcep->setSyncMaster(flags & LL_SOUND_FLAG_SYNC_MASTER); mAudioSourcep->setSyncSlave(flags & LL_SOUND_FLAG_SYNC_SLAVE); @@ -4370,8 +4397,7 @@ void LLViewerObject::adjustAudioGain(const F32 gain) if (mAudioSourcep) { mAudioGain = gain; - F32 volume = gSavedSettings.getBOOL("MuteSounds") ? 0.f : mAudioGain * gSavedSettings.getF32("AudioLevelSFX"); - mAudioSourcep->setGain(volume); + mAudioSourcep->setGain(mAudioGain); } } diff --git a/linden/indra/newview/llviewerobject.h b/linden/indra/newview/llviewerobject.h index 06d385c..5827dc2 100644 --- a/linden/indra/newview/llviewerobject.h +++ b/linden/indra/newview/llviewerobject.h @@ -132,7 +132,7 @@ public: typedef std::list > child_list_t; typedef const child_list_t const_child_list_t; - LLViewerObject(const LLUUID &id, const LLPCode type, LLViewerRegion *regionp); + LLViewerObject(const LLUUID &id, const LLPCode type, LLViewerRegion *regionp, BOOL is_global = FALSE); MEM_TYPE_NEW(LLMemType::MTYPE_OBJECT); virtual void markDead(); // Mark this object as dead, and clean up its references @@ -248,6 +248,7 @@ public: //returns TRUE if intersection detected and returns information about intersection virtual BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face = -1, // which face to check, -1 = ALL_SIDES + BOOL pick_transparent = FALSE, S32* face_hit = NULL, // which face was hit LLVector3* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -255,6 +256,8 @@ public: LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point ); + virtual BOOL lineSegmentBoundingBox(const LLVector3& start, const LLVector3& end); + virtual const LLVector3d getPositionGlobal() const; virtual const LLVector3 &getPositionRegion() const; virtual const LLVector3 getPositionEdit() const; @@ -507,6 +510,7 @@ public: LL_VO_PART_GROUP = LL_PCODE_APP | 0x90, LL_VO_TRIANGLE_TORUS = LL_PCODE_APP | 0xa0, LL_VO_WL_SKY = LL_PCODE_APP | 0xb0, // should this be moved to 0x40? + LL_VO_HUD_PART_GROUP = LL_PCODE_APP | 0xc0, } EVOType; LLUUID mID; @@ -705,8 +709,8 @@ public: class LLStaticViewerObject : public LLViewerObject { public: - LLStaticViewerObject(const LLUUID& id, const LLPCode type, LLViewerRegion* regionp) - : LLViewerObject(id,type,regionp) + LLStaticViewerObject(const LLUUID& id, const LLPCode type, LLViewerRegion* regionp, BOOL is_global = FALSE) + : LLViewerObject(id,type,regionp, is_global) { } virtual void updateDrawable(BOOL force_damped); diff --git a/linden/indra/newview/llviewerobjectlist.cpp b/linden/indra/newview/llviewerobjectlist.cpp index 163b039..f3d7bd9 100644 --- a/linden/indra/newview/llviewerobjectlist.cpp +++ b/linden/indra/newview/llviewerobjectlist.cpp @@ -163,15 +163,20 @@ U64 LLViewerObjectList::getIndex(const U32 local_id, BOOL LLViewerObjectList::removeFromLocalIDTable(const LLViewerObject &object) { - U32 local_id = object.mLocalID; - LLHost region_host = object.getRegion()->getHost(); - U32 ip = region_host.getAddress(); - U32 port = region_host.getPort(); - U64 ipport = (((U64)ip) << 32) | (U64)port; - U32 index = sIPAndPortToIndex[ipport]; + if(object.getRegion()) + { + U32 local_id = object.mLocalID; + LLHost region_host = object.getRegion()->getHost(); + U32 ip = region_host.getAddress(); + U32 port = region_host.getPort(); + U64 ipport = (((U64)ip) << 32) | (U64)port; + U32 index = sIPAndPortToIndex[ipport]; + + U64 indexid = (((U64)index) << 32) | (U64)local_id; + return sIndexAndLocalIDToUUID.erase(indexid) > 0 ? TRUE : FALSE; + } - U64 indexid = (((U64)index) << 32) | (U64)local_id; - return sIndexAndLocalIDToUUID.erase(indexid) > 0 ? TRUE : FALSE; + return FALSE ; } void LLViewerObjectList::setUUIDAndLocal(const LLUUID &id, @@ -822,8 +827,15 @@ void LLViewerObjectList::removeDrawable(LLDrawable* drawablep) for (S32 i = 0; i < drawablep->getNumFaces(); i++) { - LLViewerObject* objectp = drawablep->getFace(i)->getViewerObject(); - mSelectPickList.erase(objectp); + LLFace* facep = drawablep->getFace(i) ; + if(facep) + { + LLViewerObject* objectp = facep->getViewerObject(); + if(objectp) + { + mSelectPickList.erase(objectp); + } + } } } @@ -898,7 +910,7 @@ void LLViewerObjectList::killAllObjects() if (!mMapObjects.empty()) { llwarns << "Some objects still on map object list!" << llendl; - mActiveObjects.clear(); + mMapObjects.clear(); } } diff --git a/linden/indra/newview/llviewerparcelmedia.cpp b/linden/indra/newview/llviewerparcelmedia.cpp index 956ed03..5f29ea6 100644 --- a/linden/indra/newview/llviewerparcelmedia.cpp +++ b/linden/indra/newview/llviewerparcelmedia.cpp @@ -344,7 +344,7 @@ void LLViewerParcelMedia::processParcelMediaUpdate( LLMessageSystem *msg, void * media_url = media_url_buffer; msg->getU8("DataBlock", "MediaAutoScale", media_auto_scale); - if (msg->getNumberOfBlocks("DataBlockExtended")) // do we have the extended data? + if (msg->has("DataBlockExtended")) // do we have the extended data? { char media_type_buffer[257]; msg->getString("DataBlockExtended", "MediaType", 255, media_type_buffer); diff --git a/linden/indra/newview/llviewerparceloverlay.cpp b/linden/indra/newview/llviewerparceloverlay.cpp index b50ddb6..392f8cd 100644 --- a/linden/indra/newview/llviewerparceloverlay.cpp +++ b/linden/indra/newview/llviewerparceloverlay.cpp @@ -72,7 +72,7 @@ LLViewerParcelOverlay::LLViewerParcelOverlay(LLViewerRegion* region, F32 region_ mImageRaw = new LLImageRaw(mParcelGridsPerEdge, mParcelGridsPerEdge, OVERLAY_IMG_COMPONENTS); mTexture->createGLTexture(0, mImageRaw); gGL.getTexUnit(0)->activate(); - mTexture->bind(0); + gGL.getTexUnit(0)->bind(mTexture); mTexture->setClamp(TRUE, TRUE); mTexture->setMipFilterNearest(TRUE); @@ -748,7 +748,7 @@ S32 LLViewerParcelOverlay::renderPropertyLines () LLSurface& land = mRegion->getLand(); LLGLSUIDefault gls_ui; // called from pipeline - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest mDepthTest(GL_TRUE); // Find camera height off the ground (not from zero) @@ -826,7 +826,7 @@ S32 LLViewerParcelOverlay::renderPropertyLines () continue; } - gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); + gGL.begin(LLRender::TRIANGLE_STRIP); for (j = 0; j < vertex_per_edge; j++) { @@ -848,7 +848,7 @@ S32 LLViewerParcelOverlay::renderPropertyLines () colorp = mColorArray + BYTES_PER_COLOR * i; vertexp = mVertexArray + FLOATS_PER_VERTEX * i; - gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); + gGL.begin(LLRender::TRIANGLE_STRIP); for (j = 0; j < vertex_per_edge; j++) { diff --git a/linden/indra/newview/llviewerpartsim.cpp b/linden/indra/newview/llviewerpartsim.cpp index d27e0df..95fb307 100644 --- a/linden/indra/newview/llviewerpartsim.cpp +++ b/linden/indra/newview/llviewerpartsim.cpp @@ -116,7 +116,8 @@ void LLViewerPart::init(LLPointer sourcep, LLViewerImage *im // -LLViewerPartGroup::LLViewerPartGroup(const LLVector3 ¢er_agent, const F32 box_side) +LLViewerPartGroup::LLViewerPartGroup(const LLVector3 ¢er_agent, const F32 box_side, bool hud) + : mHud(hud) { LLMemType mt(LLMemType::MTYPE_PARTICLES); mVOPartGroupp = NULL; @@ -133,7 +134,14 @@ LLViewerPartGroup::LLViewerPartGroup(const LLVector3 ¢er_agent, const F32 bo mCenterAgent = center_agent; mBoxRadius = F_SQRT3*box_side*0.5f; + if (mHud) + { + mVOPartGroupp = (LLVOPartGroup *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_HUD_PART_GROUP, getRegion()); + } + else + { mVOPartGroupp = (LLVOPartGroup *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_PART_GROUP, getRegion()); + } mVOPartGroupp->setViewerPartGroup(this); mVOPartGroupp->setPositionAgent(getCenterAgent()); F32 scale = box_side * 0.5f; @@ -223,6 +231,12 @@ BOOL LLViewerPartGroup::posInGroup(const LLVector3 &pos, const F32 desired_size) BOOL LLViewerPartGroup::addPart(LLViewerPart* part, F32 desired_size) { LLMemType mt(LLMemType::MTYPE_PARTICLES); + + if (part->mFlags & LLPartData::LL_PART_HUD && !mHud) + { + return FALSE; + } + BOOL uniform_part = part->mScale.mV[0] == part->mScale.mV[1] && !(part->mFlags & LLPartData::LL_PART_FOLLOW_VELOCITY_MASK); @@ -530,7 +544,7 @@ LLViewerPartGroup *LLViewerPartSim::put(LLViewerPart* part) if(!return_group) { llassert_always(part->mPosAgent.isFinite()); - LLViewerPartGroup *groupp = createViewerPartGroup(part->mPosAgent, desired_size); + LLViewerPartGroup *groupp = createViewerPartGroup(part->mPosAgent, desired_size, part->mFlags & LLPartData::LL_PART_HUD); groupp->mUniformParticles = (part->mScale.mV[0] == part->mScale.mV[1] && !(part->mFlags & LLPartData::LL_PART_FOLLOW_VELOCITY_MASK)); if (!groupp->addPart(part)) @@ -555,12 +569,12 @@ LLViewerPartGroup *LLViewerPartSim::put(LLViewerPart* part) return return_group ; } -LLViewerPartGroup *LLViewerPartSim::createViewerPartGroup(const LLVector3 &pos_agent, const F32 desired_size) +LLViewerPartGroup *LLViewerPartSim::createViewerPartGroup(const LLVector3 &pos_agent, const F32 desired_size, bool hud) { LLMemType mt(LLMemType::MTYPE_PARTICLES); //find a box that has a center position divisible by PART_SIM_BOX_SIDE that encompasses //pos_agent - LLViewerPartGroup *groupp = new LLViewerPartGroup(pos_agent, desired_size); + LLViewerPartGroup *groupp = new LLViewerPartGroup(pos_agent, desired_size, hud); mViewerPartGroups.push_back(groupp); return groupp; } diff --git a/linden/indra/newview/llviewerpartsim.h b/linden/indra/newview/llviewerpartsim.h index 0f51240..b6001ee 100644 --- a/linden/indra/newview/llviewerpartsim.h +++ b/linden/indra/newview/llviewerpartsim.h @@ -87,7 +87,8 @@ class LLViewerPartGroup { public: LLViewerPartGroup(const LLVector3 ¢er, - const F32 box_radius); + const F32 box_radius, + bool hud); virtual ~LLViewerPartGroup(); void cleanup(); @@ -115,6 +116,7 @@ public: U32 mID; F32 mSkippedTime; + bool mHud; protected: LLVector3 mCenterAgent; @@ -178,7 +180,7 @@ public: U32 mID; protected: - LLViewerPartGroup *createViewerPartGroup(const LLVector3 &pos_agent, const F32 desired_size); + LLViewerPartGroup *createViewerPartGroup(const LLVector3 &pos_agent, const F32 desired_size, bool hud); LLViewerPartGroup *put(LLViewerPart* part); group_list_t mViewerPartGroups; diff --git a/linden/indra/newview/llviewerpartsource.cpp b/linden/indra/newview/llviewerpartsource.cpp index dcef8c2..13da131 100644 --- a/linden/indra/newview/llviewerpartsource.cpp +++ b/linden/indra/newview/llviewerpartsource.cpp @@ -33,6 +33,7 @@ #include "llviewerpartsource.h" #include "llviewercontrol.h" +#include "llrender.h" #include "llagent.h" #include "lldrawable.h" @@ -69,7 +70,7 @@ void LLViewerPartSource::updatePart(LLViewerPart &part, const F32 dt) { } -void LLViewerPartSource::update(const F32 dt) +void LLViewerPartSource::update(const F32 dt) { llerrs << "Creating default part source!" << llendl; } @@ -99,7 +100,7 @@ LLViewerPartSourceScript::LLViewerPartSourceScript(LLViewerObject *source_objp) mSourceObjectp = source_objp; mPosAgent = mSourceObjectp->getPositionAgent(); mImagep = gImageList.getImageFromFile("pixiesmall.j2c"); - mImagep->bind(); + gGL.getTexUnit(0)->bind(mImagep.get()); mImagep->setClamp(TRUE, TRUE); } @@ -282,6 +283,10 @@ void LLViewerPartSourceScript::update(const F32 dt) part->init(this, mImagep, NULL); part->mFlags = mPartSysData.mPartData.mFlags; + if (!mSourceObjectp.isNull() && mSourceObjectp->isHUDAttachment()) + { + part->mFlags |= LLPartData::LL_PART_HUD; + } part->mMaxAge = mPartSysData.mPartData.mMaxAge; part->mStartColor = mPartSysData.mPartData.mStartColor; part->mEndColor = mPartSysData.mPartData.mEndColor; diff --git a/linden/indra/newview/llviewerregion.cpp b/linden/indra/newview/llviewerregion.cpp index 08dc979..507481a 100644 --- a/linden/indra/newview/llviewerregion.cpp +++ b/linden/indra/newview/llviewerregion.cpp @@ -215,6 +215,7 @@ LLViewerRegion::LLViewerRegion(const U64 &handle, mObjectPartition.push_back(new LLGrassPartition()); //PARTITION_GRASS mObjectPartition.push_back(new LLVolumePartition()); //PARTITION_VOLUME mObjectPartition.push_back(new LLBridgePartition()); //PARTITION_BRIDGE + mObjectPartition.push_back(new LLHUDParticlePartition());//PARTITION_HUD_PARTICLE mObjectPartition.push_back(NULL); //PARTITION_NONE } @@ -1028,12 +1029,18 @@ void LLViewerRegion::updateCoarseLocations(LLMessageSystem* msg) msg->getS16Fast(_PREHASH_Index, _PREHASH_You, agent_index); msg->getS16Fast(_PREHASH_Index, _PREHASH_Prey, target_index); + BOOL has_agent_data = msg->has(_PREHASH_AgentData); S32 count = msg->getNumberOfBlocksFast(_PREHASH_Location); for(S32 i = 0; i < count; i++) { msg->getU8Fast(_PREHASH_Location, _PREHASH_X, x_pos, i); msg->getU8Fast(_PREHASH_Location, _PREHASH_Y, y_pos, i); msg->getU8Fast(_PREHASH_Location, _PREHASH_Z, z_pos, i); + LLUUID agent_id = LLUUID::null; + if(has_agent_data) + { + msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id, i); + } //llinfos << " object X: " << (S32)x_pos << " Y: " << (S32)y_pos // << " Z: " << (S32)(z_pos * 4) @@ -1059,6 +1066,10 @@ void LLViewerRegion::updateCoarseLocations(LLMessageSystem* msg) pos <<= 8; pos |= z_pos; mMapAvatars.put(pos); + if(has_agent_data) + { + mMapAvatarIDs.put(agent_id); + } } } } @@ -1387,8 +1398,12 @@ void LLViewerRegion::setSeedCapability(const std::string& url) capabilityNames.append("DispatchRegionInfo"); capabilityNames.append("EstateChangeInfo"); capabilityNames.append("EventQueueGet"); - capabilityNames.append("FetchInventoryDescendents"); + capabilityNames.append("FetchInventory"); + capabilityNames.append("WebFetchInventoryDescendents"); + capabilityNames.append("FetchLib"); + capabilityNames.append("FetchLibDescendents"); capabilityNames.append("GroupProposalBallot"); + capabilityNames.append("HomeLocation"); capabilityNames.append("MapLayer"); capabilityNames.append("MapLayerGod"); capabilityNames.append("NewFileAgentInventory"); diff --git a/linden/indra/newview/llviewerregion.h b/linden/indra/newview/llviewerregion.h index d65ad23..097bfcc 100644 --- a/linden/indra/newview/llviewerregion.h +++ b/linden/indra/newview/llviewerregion.h @@ -81,6 +81,7 @@ public: PARTITION_GRASS, PARTITION_VOLUME, PARTITION_BRIDGE, + PARTITION_HUD_PARTICLE, PARTITION_NONE, NUM_PARTITIONS } eObjectPartitions; diff --git a/linden/indra/newview/llviewershadermgr.cpp b/linden/indra/newview/llviewershadermgr.cpp index a654120..44f6abe 100644 --- a/linden/indra/newview/llviewershadermgr.cpp +++ b/linden/indra/newview/llviewershadermgr.cpp @@ -108,7 +108,7 @@ GLint gAvatarMatrixParam; LLViewerShaderMgr::LLViewerShaderMgr() : mVertexShaderLevel(SHADER_COUNT, 0) { -/// Make sure WL Sky is the first program + /// Make sure WL Sky is the first program mShaderList.push_back(&gWLSkyProgram); mShaderList.push_back(&gWLCloudProgram); mShaderList.push_back(&gAvatarProgram); @@ -139,28 +139,28 @@ LLViewerShaderMgr * LLViewerShaderMgr::instance() if(NULL == sInstance) { sInstance = new LLViewerShaderMgr(); - } - - return static_cast(sInstance); } + return static_cast(sInstance); +} + void LLViewerShaderMgr::initAttribsAndUniforms(void) - { +{ if (mReservedAttribs.empty()) - { + { mReservedAttribs.push_back("materialColor"); mReservedAttribs.push_back("specularColor"); mReservedAttribs.push_back("binormal"); - + mAvatarAttribs.reserve(5); mAvatarAttribs.push_back("weight"); mAvatarAttribs.push_back("clothing"); mAvatarAttribs.push_back("gWindDir"); mAvatarAttribs.push_back("gSinWaveParams"); mAvatarAttribs.push_back("gGravity"); - + mAvatarUniforms.push_back("matrixPalette"); - + mReservedUniforms.reserve(24); mReservedUniforms.push_back("diffuseMap"); mReservedUniforms.push_back("specularMap"); @@ -186,16 +186,16 @@ void LLViewerShaderMgr::initAttribsAndUniforms(void) mReservedUniforms.push_back("cloud_scale"); mReservedUniforms.push_back("gamma"); mReservedUniforms.push_back("scene_light_strength"); - + mWLUniforms.push_back("camPosLocal"); - + mTerrainUniforms.reserve(5); mTerrainUniforms.push_back("detail_0"); mTerrainUniforms.push_back("detail_1"); mTerrainUniforms.push_back("detail_2"); mTerrainUniforms.push_back("detail_3"); mTerrainUniforms.push_back("alpha_ramp"); - + mGlowUniforms.push_back("glowDelta"); mGlowUniforms.push_back("glowStrength"); @@ -204,7 +204,7 @@ void LLViewerShaderMgr::initAttribsAndUniforms(void) mGlowExtractUniforms.push_back("lumWeights"); mGlowExtractUniforms.push_back("warmthWeights"); mGlowExtractUniforms.push_back("warmthAmount"); - + mShinyUniforms.push_back("origin"); mWaterUniforms.reserve(12); @@ -222,9 +222,9 @@ void LLViewerShaderMgr::initAttribsAndUniforms(void) mWaterUniforms.push_back("kd"); mWaterUniforms.push_back("refScale"); mWaterUniforms.push_back("waterHeight"); - } - } - + } +} + //============================================================================ // Set Levels @@ -1087,12 +1087,12 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() } std::string LLViewerShaderMgr::getShaderDirPrefix(void) - { +{ return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "shaders/class"); - } +} void LLViewerShaderMgr::updateShaderUniforms(LLGLSLShader * shader) - { +{ LLWLParamManager::instance()->updateShaderUniforms(shader); LLWaterParamManager::instance()->updateShaderUniforms(shader); } diff --git a/linden/indra/newview/llviewerstats.h b/linden/indra/newview/llviewerstats.h index f33ad02..5ae8cdc 100644 --- a/linden/indra/newview/llviewerstats.h +++ b/linden/indra/newview/llviewerstats.h @@ -77,6 +77,9 @@ public: LLStat mSimAgentMsec; LLStat mSimImagesMsec; LLStat mSimScriptMsec; + LLStat mSimSpareMsec; + LLStat mSimSleepMsec; + LLStat mSimPumpIOMsec; LLStat mSimMainAgents; LLStat mSimChildAgents; diff --git a/linden/indra/newview/llviewertexteditor.cpp b/linden/indra/newview/llviewertexteditor.cpp index 8a55b3f..1dda1ca 100644 --- a/linden/indra/newview/llviewertexteditor.cpp +++ b/linden/indra/newview/llviewertexteditor.cpp @@ -1402,8 +1402,7 @@ void LLViewerTextEditor::openEmbeddedSound( LLInventoryItem* item ) const F32 SOUND_GAIN = 1.0f; if(gAudiop) { - F32 volume = gSavedSettings.getBOOL("MuteSounds") ? 0.f : (SOUND_GAIN * gSavedSettings.getF32("AudioLevelSFX")); - gAudiop->triggerSound(item->getAssetUUID(), gAgentID, volume, lpos_global); + gAudiop->triggerSound(item->getAssetUUID(), gAgentID, SOUND_GAIN, LLAudioEngine::AUDIO_TYPE_UI, lpos_global); } showCopyToInvDialog( item ); } diff --git a/linden/indra/newview/llviewerwindow.cpp b/linden/indra/newview/llviewerwindow.cpp index 64c042a..106ad08 100644 --- a/linden/indra/newview/llviewerwindow.cpp +++ b/linden/indra/newview/llviewerwindow.cpp @@ -168,6 +168,7 @@ #include "llviewerobjectlist.h" #include "llviewerparcelmgr.h" #include "llviewerregion.h" +#include "llviewershadermgr.h" #include "llviewerstats.h" #include "llvoavatar.h" #include "llvovolume.h" @@ -182,7 +183,6 @@ #include "llviewernetwork.h" #if LL_WINDOWS -#include "llwindebug.h" #include // For Unicode conversion methods #endif @@ -218,6 +218,7 @@ LLVector3 gDebugRaycastIntersection; LLVector2 gDebugRaycastTexCoord; LLVector3 gDebugRaycastNormal; LLVector3 gDebugRaycastBinormal; +S32 gDebugRaycastFaceHit; // HUD display lines in lower right BOOL gDisplayWindInfo = FALSE; @@ -1102,6 +1103,7 @@ void LLViewerWindow::handleQuit(LLWindow *window) void LLViewerWindow::handleResize(LLWindow *window, S32 width, S32 height) { reshape(width, height); + mResDirty = true; } // The top-level window has gained focus (e.g. via ALT-TAB) @@ -1258,6 +1260,8 @@ BOOL LLViewerWindow::handleActivate(LLWindow *window, BOOL activated) BOOL LLViewerWindow::handleActivateApp(LLWindow *window, BOOL activating) { + //if (!activating) gAgent.changeCameraToDefault(); + LLViewerJoystick::getInstance()->setNeedsReset(true); return FALSE; } @@ -1410,7 +1414,11 @@ LLViewerWindow::LLViewerWindow( mHideCursorPermanent( FALSE ), mCursorHidden(FALSE), mIgnoreActivate( FALSE ), - mHoverPick() + mHoverPick(), + mResDirty(false), + mStatesDirty(false), + mIsFullscreenChecked(false), + mCurrResolutionIndex(0) { // Default to application directory. LLViewerWindow::sSnapshotBaseName = "Snapshot"; @@ -1426,12 +1434,12 @@ LLViewerWindow::LLViewerWindow( !gNoRender, ignore_pixel_depth, gSavedSettings.getU32("RenderFSAASamples")); -#if LL_WINDOWS - if (!LLWinDebug::checkExceptionHandler()) + + if (!LLAppViewer::instance()->restoreErrorTrap()) { - LL_WARNS("Window") << " Someone took over my exception handler (post createWindow)!" << LL_ENDL; + LL_WARNS("Window") << " Someone took over my signal/exception handler (post createWindow)!" << LL_ENDL; } -#endif + if (NULL == mWindow) { @@ -1545,7 +1553,7 @@ void LLViewerWindow::initGLDefaults() glPixelStorei(GL_PACK_ALIGNMENT,1); glPixelStorei(GL_UNPACK_ALIGNMENT,1); - glEnable(GL_TEXTURE_2D); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); // lights for objects glShadeModel( GL_SMOOTH ); @@ -3042,8 +3050,9 @@ BOOL LLViewerWindow::handlePerFrameHover() if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST)) { - gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, - NULL, + gDebugRaycastFaceHit = -1; + gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, + &gDebugRaycastFaceHit, &gDebugRaycastIntersection, &gDebugRaycastTexCoord, &gDebugRaycastNormal, @@ -3184,7 +3193,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, // Render light for editing if (LLSelectMgr::sRenderLightRadius && LLToolMgr::getInstance()->inEdit()) { - LLImageGL::unbindTexture(0); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLEnable gls_blend(GL_BLEND); LLGLEnable gls_cull(GL_CULL_FACE); LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); @@ -3398,7 +3407,7 @@ void LLViewerWindow::schedulePick(LLPickInfo& pick_info) llassert_always(pick_info.mScreenRegion.notNull()); mPicks.push_back(pick_info); - S32 scaled_x = llround((F32)pick_info.mMousePt.mX * mDisplayScale.mV[VX]); + /*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 @@ -3467,7 +3476,7 @@ void LLViewerWindow::schedulePick(LLPickInfo& pick_info) setup3DRender(); setup2DRender(); - setupViewport(); + setupViewport();*/ // delay further event processing until we receive results of pick mWindow->delayInputProcessing(); @@ -3529,6 +3538,7 @@ LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_trans LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 depth, LLViewerObject *this_object, S32 this_face, + BOOL pick_transparent, S32* face_hit, LLVector3 *intersection, LLVector2 *uv, @@ -3562,7 +3572,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de { if (this_object->isHUDAttachment()) // is a HUD object? { - if (this_object->lineSegmentIntersect(mouse_hud_start, mouse_hud_end, this_face, + if (this_object->lineSegmentIntersect(mouse_hud_start, mouse_hud_end, this_face, pick_transparent, face_hit, intersection, uv, normal, binormal)) { found = this_object; @@ -3571,7 +3581,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de else // is a world object { - if (this_object->lineSegmentIntersect(mouse_world_start, mouse_world_end, this_face, + if (this_object->lineSegmentIntersect(mouse_world_start, mouse_world_end, this_face, pick_transparent, face_hit, intersection, uv, normal, binormal)) { found = this_object; @@ -3581,13 +3591,13 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de else // check ALL objects { - found = gPipeline.lineSegmentIntersectInHUD(mouse_hud_start, mouse_hud_end, + found = gPipeline.lineSegmentIntersectInHUD(mouse_hud_start, mouse_hud_end, pick_transparent, face_hit, intersection, uv, normal, binormal); if (!found) // if not found in HUD, look in world: { - found = gPipeline.lineSegmentIntersectInWorld(mouse_world_start, mouse_world_end, + found = gPipeline.lineSegmentIntersectInWorld(mouse_world_start, mouse_world_end, pick_transparent, face_hit, intersection, uv, normal, binormal); } @@ -3811,13 +3821,8 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageFormatted *image) return FALSE; } - std::string extension("." + image->getExtension()); - if (extension.empty()) - { - extension = (gSavedSettings.getBOOL("CompressSnapshotsToDisk")) ? ".j2c" : ".bmp"; - } - LLFilePicker::ESaveFilter pick_type; + std::string extension("." + image->getExtension()); if (extension == ".j2c") pick_type = LLFilePicker::FFSAVE_J2C; else if (extension == ".bmp") @@ -3835,7 +3840,8 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageFormatted *image) if ( ! isSnapshotLocSet()) { std::string proposed_name( sSnapshotBaseName ); - proposed_name.append( extension ); + + // getSaveFile will append an appropriate extension to the proposed name, based on the ESaveFilter constant passed in. // pick a directory in which to save LLFilePicker& picker = LLFilePicker::instance(); @@ -4152,7 +4158,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei snapshot_width = image_width; snapshot_height = image_height; - target.allocate(snapshot_width, snapshot_height, GL_RGBA, TRUE, GL_TEXTURE_RECTANGLE_ARB, TRUE); + target.allocate(snapshot_width, snapshot_height, GL_RGBA, TRUE, LLTexUnit::TT_RECT_TEXTURE, TRUE); window_width = snapshot_width; window_height = snapshot_height; scale_factor = 1.f; @@ -4380,7 +4386,7 @@ void LLViewerWindow::drawMouselookInstructions() llround(font->getLineHeight() + 2 * INSTRUCTIONS_PAD)); { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f( 0.9f, 0.9f, 0.9f, 1.0f ); gl_rect_2d( instructions_rect ); } @@ -4586,12 +4592,10 @@ void LLViewerWindow::restoreGL(const std::string& progress_message) setProgressString(progress_message); } llinfos << "...Restoring GL done" << llendl; -#if LL_WINDOWS - if(!LLWinDebug::checkExceptionHandler()) + if(!LLAppViewer::instance()->restoreErrorTrap()) { - llwarns << " Someone took over my exception handler (post restoreGL)!" << llendl; + llwarns << " Someone took over my signal/exception handler (post restoreGL)!" << llendl; } -#endif } } @@ -4647,9 +4651,97 @@ void LLViewerWindow::getTargetWindow(BOOL& fullscreen, S32& width, S32& height) } } +bool LLViewerWindow::updateResolution() +{ + if (gSavedSettings.getBOOL("FullScreenAutoDetectAspectRatio")) + { + getWindow()->setNativeAspectRatio(0.f); + } + else + { + getWindow()->setNativeAspectRatio(gSavedSettings.getF32("FullScreenAspectRatio")); + } + + reshape(getWindowDisplayWidth(), getWindowDisplayHeight()); + + // Screen resolution + S32 num_resolutions; + LLWindow::LLWindowResolution* supported_resolutions = getWindow()->getSupportedResolutions(num_resolutions); + + // check if resolution has changed + BOOL targetFullscreen; + S32 targetWidth; + S32 targetHeight; + + getTargetWindow(targetFullscreen, targetWidth, targetHeight); + + if ((mIsFullscreenChecked != (bool) targetFullscreen) || + (mIsFullscreenChecked && + (supported_resolutions[mCurrResolutionIndex].mWidth != targetWidth || + supported_resolutions[mCurrResolutionIndex].mHeight != targetHeight) + )) + { + // change fullscreen resolution or switch in/out of windowed mode + BOOL result; + + BOOL logged_in = (LLStartUp::getStartupState() >= STATE_STARTED); + if (mIsFullscreenChecked) + { + result = changeDisplaySettings(TRUE, + LLCoordScreen( supported_resolutions[mCurrResolutionIndex].mWidth, + supported_resolutions[mCurrResolutionIndex].mHeight), + gSavedSettings.getBOOL("DisableVerticalSync"), + logged_in); + } + else + { + result = changeDisplaySettings(FALSE, + LLCoordScreen(gSavedSettings.getS32("WindowWidth"), gSavedSettings.getS32("WindowHeight")), + TRUE, + logged_in); + } + if (!result) + { + + // GL is non-existent at this point, so we can't continue. + llerrs << "LLPanelDisplay::apply() failed" << llendl; + } + } + + // force aspect ratio + if (mIsFullscreenChecked) + { + LLViewerCamera::getInstance()->setAspect( getDisplayAspectRatio() ); + } + return true; +} + +void LLViewerWindow::requestResolutionUpdate(bool fullscreen_checked, U32 resolution_index) +{ + mResDirty = true; + mIsFullscreenChecked = fullscreen_checked; + mCurrResolutionIndex = resolution_index; +} + BOOL LLViewerWindow::checkSettings() { + if (mStatesDirty) + { + gGL.refreshState(); + LLViewerShaderMgr::instance()->setShaders(); + mStatesDirty = false; + } + + // We want to update the resolution AFTER the states getting refreshed not before. + if (mResDirty) + { + updateResolution(); + mResDirty = false; + // This will force a state update the next frame. + mStatesDirty = true; + } + BOOL is_fullscreen = mWindow->getFullscreen(); if (is_fullscreen && !mWantFullscreen) { @@ -4658,6 +4750,7 @@ BOOL LLViewerWindow::checkSettings() gSavedSettings.getS32("WindowHeight")), TRUE, mShowFullscreenProgress); + mStatesDirty = true; return TRUE; } else if (!is_fullscreen && mWantFullscreen) @@ -4677,6 +4770,7 @@ BOOL LLViewerWindow::checkSettings() LLGLState::checkStates(); LLGLState::checkTextureChannels(); + mStatesDirty = true; return TRUE; } return FALSE; @@ -5103,25 +5197,34 @@ LLPickInfo::~LLPickInfo() void LLPickInfo::fetchResults() { + + S32 face_hit = -1; + LLVector3 intersection, normal, binormal; + LLVector2 uv; + + LLViewerObject* hit_object = gViewerWindow->cursorIntersect(-1, -1, 512.f, + NULL, -1, mPickTransparent, &face_hit, + &intersection, &uv, &normal, &binormal); + // read back colors and depth values from buffer - glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, mPickBuffer); - glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_DEPTH_COMPONENT, GL_FLOAT, mPickDepthBuffer ); + //glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, mPickBuffer); + //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); - 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]; + //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]; - S32 x_offset = mMousePt.mX - llround((F32)scaled_pick_point.mX / gViewerWindow->getDisplayScale().mV[VX]); - S32 y_offset = mMousePt.mY - llround((F32)scaled_pick_point.mY / gViewerWindow->getDisplayScale().mV[VY]); + //S32 x_offset = mMousePt.mX - llround((F32)scaled_pick_point.mX / gViewerWindow->getDisplayScale().mV[VX]); + //S32 y_offset = mMousePt.mY - llround((F32)scaled_pick_point.mY / gViewerWindow->getDisplayScale().mV[VY]); mPickPt = mMousePt; // we hit nothing, scan surrounding pixels for something useful - if (!pick_id) + /*if (!pick_id) { S32 closest_distance = 10000; //S32 closest_pick_name = 0; @@ -5142,25 +5245,21 @@ void LLPickInfo::fetchResults() } } } - } + }*/ - U32 te_offset = ((U32)pick_id >> 20); - pick_id &= 0x000fffff; - //unproject relative clicked coordinate from window coordinate using GL - GLint viewport[4]; - GLdouble modelview[16]; - GLdouble projection[16]; - GLfloat winX, winY; - GLdouble posX, posY, posZ; + U32 te_offset = face_hit > -1 ? face_hit : 0; + //pick_id &= 0x000fffff; - LLViewerObject* objectp = gObjectList.getSelectedObject(pick_id); + //unproject relative clicked coordinate from window coordinate using GL + + LLViewerObject* objectp = hit_object; - if (pick_id == (S32)GL_NAME_PARCEL_WALL) - { - mPickType = PICK_PARCEL_WALL; - } - else if (objectp) + //if (pick_id == (S32)GL_NAME_PARCEL_WALL) + //{ + // mPickType = PICK_PARCEL_WALL; + //} + if (objectp) { if( objectp->getPCode() == LLViewerObject::LL_VO_SURFACE_PATCH ) { @@ -5186,11 +5285,11 @@ void LLPickInfo::fetchResults() { mPickType = PICK_OBJECT; } - mObjectOffset = gAgent.calcFocusOffset(objectp, mPickPt.mX, mPickPt.mY); + mObjectOffset = gAgent.calcFocusOffset(objectp, intersection, mPickPt.mX, mPickPt.mY); mObjectID = objectp->mID; mObjectFace = (te_offset == NO_FACE) ? -1 : (S32)te_offset; - glh::matrix4f newModel((F32*)LLViewerCamera::getInstance()->getModelview().mMatrix); + /*glh::matrix4f newModel((F32*)LLViewerCamera::getInstance()->getModelview().mMatrix); for(U32 i = 0; i < 16; ++i) { @@ -5202,9 +5301,9 @@ void LLPickInfo::fetchResults() winX = ((F32)mPickPt.mX) * gViewerWindow->getDisplayScale().mV[VX]; winY = ((F32)mPickPt.mY) * gViewerWindow->getDisplayScale().mV[VY]; - gluUnProject( winX, winY, depth, modelview, projection, viewport, &posX, &posY, &posZ); + gluUnProject( winX, winY, depth, modelview, projection, viewport, &posX, &posY, &posZ);*/ - mPosGlobal = gAgent.getPosGlobalFromAgent(LLVector3(posX, posY, posZ)); + mPosGlobal = gAgent.getPosGlobalFromAgent(intersection); if (mWantSurfaceInfo) { @@ -5212,16 +5311,16 @@ void LLPickInfo::fetchResults() } } } - else - { + //else + //{ // was this name referring to a hud icon? - mHUDIcon = LLHUDIcon::handlePick(pick_id); - if (mHUDIcon) - { - mPickType = PICK_ICON; - mPosGlobal = mHUDIcon->getPositionGlobal(); - } - } + // mHUDIcon = LLHUDIcon::handlePick(pick_id); + // if (mHUDIcon) + // { + // mPickType = PICK_ICON; + // mPosGlobal = mHUDIcon->getPositionGlobal(); + // } + //} if (mPickCallback) { @@ -5236,16 +5335,19 @@ LLPointer LLPickInfo::getObject() const void LLPickInfo::updateXYCoords() { - const LLTextureEntry* tep = getObject()->getTE(mObjectFace); - LLPointer imagep = gImageList.getImage(tep->getID()); - if(mUVCoords.mV[VX] >= 0.f && mUVCoords.mV[VY] >= 0.f && imagep.notNull()) + if (mObjectFace > -1) { - LLCoordGL coords; - - coords.mX = llround(mUVCoords.mV[VX] * (F32)imagep->getWidth()); - coords.mY = llround(mUVCoords.mV[VY] * (F32)imagep->getHeight()); + const LLTextureEntry* tep = getObject()->getTE(mObjectFace); + LLPointer imagep = gImageList.getImage(tep->getID()); + if(mUVCoords.mV[VX] >= 0.f && mUVCoords.mV[VY] >= 0.f && imagep.notNull()) + { + LLCoordGL coords; + + coords.mX = llround(mUVCoords.mV[VX] * (F32)imagep->getWidth()); + coords.mY = llround(mUVCoords.mV[VY] * (F32)imagep->getHeight()); - gViewerWindow->getWindow()->convertCoords(coords, &mXYCoords); + gViewerWindow->getWindow()->convertCoords(coords, &mXYCoords); + } } } @@ -5256,7 +5358,7 @@ void LLPickInfo::drawPickBuffer() const gGL.pushMatrix(); LLGLDisable no_blend(GL_BLEND); LLGLDisable no_alpha_test(GL_ALPHA_TEST); - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); glPixelZoom(10.f, 10.f); LLVector2 display_scale = gViewerWindow->getDisplayScale(); glRasterPos2f(((F32)mMousePt.mX * display_scale.mV[VX] + 10.f), @@ -5308,7 +5410,7 @@ void LLPickInfo::getSurfaceInfo() if (objectp) { if (gViewerWindow->cursorIntersect(llround((F32)mMousePt.mX), llround((F32)mMousePt.mY), 1024.f, - objectp, -1, + objectp, -1, mPickTransparent, &mObjectFace, &mIntersection, &mSTCoords, @@ -5317,7 +5419,7 @@ void LLPickInfo::getSurfaceInfo() { // if we succeeded with the intersect above, compute the texture coordinates: - if (objectp->mDrawable.notNull()) + if (objectp->mDrawable.notNull() && mObjectFace > -1) { LLFace* facep = objectp->mDrawable->getFace(mObjectFace); diff --git a/linden/indra/newview/llviewerwindow.h b/linden/indra/newview/llviewerwindow.h index 21df0d5..28fcb3e 100644 --- a/linden/indra/newview/llviewerwindow.h +++ b/linden/indra/newview/llviewerwindow.h @@ -313,6 +313,7 @@ public: LLViewerObject* cursorIntersect(S32 mouse_x = -1, S32 mouse_y = -1, F32 depth = 512.f, LLViewerObject *this_object = NULL, S32 this_face = -1, + BOOL pick_transparent = FALSE, S32* face_hit = NULL, LLVector3 *intersection = NULL, LLVector2 *uv = NULL, @@ -340,6 +341,8 @@ public: void toggleFullscreen(BOOL show_progress); // handle shutting down GL and bringing it back up + bool updateResolution(void); + void requestResolutionUpdate(bool fullscreen_checked, U32 resolution_index); BOOL checkSettings(); void restartDisplay(BOOL show_progress_bar); BOOL changeDisplaySettings(BOOL fullscreen, LLCoordScreen size, BOOL disable_vsync, BOOL show_progress_bar); @@ -421,6 +424,11 @@ protected: std::string mInitAlert; // Window / GL initialization requires an alert class LLDebugText* mDebugText; // Internal class for debug text + + bool mResDirty; + bool mStatesDirty; + bool mIsFullscreenChecked; // Did the user check the fullscreen checkbox in the display settings + U32 mCurrResolutionIndex; protected: static std::string sSnapshotBaseName; @@ -473,6 +481,7 @@ extern LLVector3 gDebugRaycastIntersection; extern LLVector2 gDebugRaycastTexCoord; extern LLVector3 gDebugRaycastNormal; extern LLVector3 gDebugRaycastBinormal; +extern S32 gDebugRaycastFaceHit; extern S32 CHAT_BAR_HEIGHT; diff --git a/linden/indra/newview/llvoavatar.cpp b/linden/indra/newview/llvoavatar.cpp index e480eb3..c3ad4f9 100644 --- a/linden/indra/newview/llvoavatar.cpp +++ b/linden/indra/newview/llvoavatar.cpp @@ -244,6 +244,11 @@ static F32 calc_bouncy_animation(F32 x) return -(cosf(x * F_PI * 2.5f - F_PI_BY_TWO))*(0.4f + x * -0.1f) + x * 1.3f; } +BOOL LLLineSegmentCapsuleIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& p1, const LLVector3& p2, const F32& radius, LLVector3& result) +{ + return FALSE; +} + //----------------------------------------------------------------------------- // Static Data //----------------------------------------------------------------------------- @@ -753,7 +758,7 @@ LLVOAvatar::LLVOAvatar( mRippleTimeLast = 0.f; mShadowImagep = gImageList.getImageFromFile("foot_shadow.j2c"); - mShadowImagep->bind(); + gGL.getTexUnit(0)->bind(mShadowImagep.get()); mShadowImagep->setClamp(TRUE, TRUE); mInAir = FALSE; @@ -1131,7 +1136,7 @@ void LLVOAvatar::dumpBakedStatus() } - F64 dist_to_camera = (inst->getPositionGlobal() - camera_pos_global).magVec(); + F64 dist_to_camera = (inst->getPositionGlobal() - camera_pos_global).length(); llcont << " " << dist_to_camera << "m "; llcont << " " << inst->mPixelArea << " pixels"; @@ -1569,6 +1574,96 @@ void LLVOAvatar::getSpatialExtents(LLVector3& newMin, LLVector3& newMax) newMax += buffer; } +//----------------------------------------------------------------------------- +// renderCollisionVolumes() +//----------------------------------------------------------------------------- +void LLVOAvatar::renderCollisionVolumes() +{ + for (S32 i = 0; i < mNumCollisionVolumes; i++) + { + mCollisionVolumes[i].renderCollision(); + } + + if (mNameText.notNull()) + { + LLVector3 unused; + mNameText->lineSegmentIntersect(LLVector3(0,0,0), LLVector3(0,0,1), unused, TRUE); + } +} + +BOOL LLVOAvatar::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, + S32 face, + BOOL pick_transparent, + S32* face_hit, + LLVector3* intersection, + LLVector2* tex_coord, + LLVector3* normal, + LLVector3* bi_normal + ) +{ + + if (mIsSelf && !gAgent.needsRenderAvatar()) + { + return FALSE; + } + + if (lineSegmentBoundingBox(start, end)) + { + for (S32 i = 0; i < mNumCollisionVolumes; ++i) + { + mCollisionVolumes[i].updateWorldMatrix(); + + glh::matrix4f mat((F32*) mCollisionVolumes[i].getXform()->getWorldMatrix().mMatrix); + glh::matrix4f inverse = mat.inverse(); + glh::matrix4f norm_mat = inverse.transpose(); + + glh::vec3f p1(start.mV); + glh::vec3f p2(end.mV); + + inverse.mult_matrix_vec(p1); + inverse.mult_matrix_vec(p2); + + LLVector3 position; + LLVector3 norm; + + if (linesegment_sphere(LLVector3(p1.v), LLVector3(p2.v), LLVector3(0,0,0), 1.f, position, norm)) + { + glh::vec3f res_pos(position.mV); + mat.mult_matrix_vec(res_pos); + + norm.normalize(); + glh::vec3f res_norm(norm.mV); + norm_mat.mult_matrix_dir(res_norm); + + if (intersection) + { + *intersection = LLVector3(res_pos.v); + } + + if (normal) + { + *normal = LLVector3(res_norm.v); + } + + return TRUE; + } + } + } + + LLVector3 position; + if (mNameText.notNull() && mNameText->lineSegmentIntersect(start, end, position)) + { + if (intersection) + { + *intersection = position; + } + + return TRUE; + } + + return FALSE; +} + //----------------------------------------------------------------------------- // parseSkeletonFile() @@ -2737,8 +2832,8 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update) else { getSpatialExtents(ext[0], ext[1]); - if ((ext[1]-mImpostorExtents[1]).magVec() > 0.05f || - (ext[0]-mImpostorExtents[0]).magVec() > 0.05f) + if ((ext[1]-mImpostorExtents[1]).length() > 0.05f || + (ext[0]-mImpostorExtents[0]).length() > 0.05f) { mNeedsImpostorUpdate = TRUE; } @@ -2905,7 +3000,7 @@ void LLVOAvatar::idleUpdateWindEffect() F32 time_delta = mRippleTimer.getElapsedTimeF32() - mRippleTimeLast; mRippleTimeLast = mRippleTimer.getElapsedTimeF32(); LLVector3 velocity = getVelocity(); - F32 speed = velocity.magVec(); + F32 speed = velocity.length(); //RN: velocity varies too much frame to frame for this to work mRippleAccel.clearVec();//lerp(mRippleAccel, (velocity - mLastVel) * time_delta, LLCriticalDamp::getInterpolant(0.02f)); mLastVel = velocity; @@ -2924,7 +3019,7 @@ void LLVOAvatar::idleUpdateWindEffect() } wind.mV[VZ] += hover_strength; - wind.normVec(); + wind.normalize(); wind.mV[VW] = llmin(0.025f + (speed * 0.015f) + hover_strength, 0.5f); F32 interp; @@ -3047,10 +3142,10 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last) LLVector3 pixel_up_vec; LLViewerCamera::getInstance()->getPixelVectors(root_pos_last, pixel_up_vec, pixel_right_vec); LLVector3 camera_to_av = root_pos_last - LLViewerCamera::getInstance()->getOrigin(); - camera_to_av.normVec(); + camera_to_av.normalize(); LLVector3 local_camera_at = camera_to_av * ~root_rot; LLVector3 local_camera_up = camera_to_av % LLViewerCamera::getInstance()->getLeftAxis(); - local_camera_up.normVec(); + local_camera_up.normalize(); local_camera_up = local_camera_up * ~root_rot; local_camera_up.scaleVec(mBodySize * 0.5f); @@ -3509,7 +3604,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) LLVector3 xyVel = getVelocity(); xyVel.mV[VZ] = 0.0f; - speed = xyVel.magVec(); + speed = xyVel.length(); BOOL throttle = TRUE; @@ -3594,14 +3689,14 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) if (mIsSelf) { primDir = agent.getAtAxis() - projected_vec(agent.getAtAxis(), agent.getReferenceUpVector()); - primDir.normVec(); + primDir.normalize(); } else { primDir = getRotation().getMatrix3().getFwdRow(); } LLVector3 velDir = getVelocity(); - velDir.normVec(); + velDir.normalize(); if ( mSignaledAnimations.find(ANIM_AGENT_WALK) != mSignaledAnimations.end()) { F32 vpD = velDir * primDir; @@ -3623,13 +3718,13 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) LLVector3 at_axis = LLViewerCamera::getInstance()->getAtAxis(); LLVector3 up_vector = gAgent.getReferenceUpVector(); at_axis -= up_vector * (at_axis * up_vector); - at_axis.normVec(); + at_axis.normalize(); F32 dot = fwdDir * at_axis; if (dot < 0.f) { fwdDir -= 2.f * at_axis * dot; - fwdDir.normVec(); + fwdDir.normalize(); } } @@ -3697,7 +3792,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) // Now compute the full world space rotation for the whole body (wQv) LLVector3 leftDir = upDir % fwdDir; - leftDir.normVec(); + leftDir.normalize(); fwdDir = leftDir % upDir; LLQuaternion wQv( fwdDir, leftDir, upDir ); @@ -3828,10 +3923,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) // AUDIO_STEP_LO_SPEED, AUDIO_STEP_HI_SPEED, // AUDIO_STEP_LO_GAIN, AUDIO_STEP_HI_GAIN ); - F32 ambient_volume = gSavedSettings.getF32("AudioLevelAmbient"); - F32 gain = gSavedSettings.getBOOL("MuteAmbient") - ? 0.f - : (.50f * ambient_volume * ambient_volume); + const F32 STEP_VOLUME = 0.5f; LLUUID& step_sound_id = getStepSound(); LLVector3d foot_pos_global = gAgent.getPosGlobalFromAgent(foot_pos_agent); @@ -3839,7 +3931,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) if (LLViewerParcelMgr::getInstance()->canHearSound(foot_pos_global) && !LLMuteList::getInstance()->isMuted(getID(), LLMute::flagObjectSounds)) { - gAudiop->triggerSound(step_sound_id, getID(), gain, foot_pos_global); + gAudiop->triggerSound(step_sound_id, getID(), STEP_VOLUME, LLAudioEngine::AUDIO_TYPE_AMBIENT, foot_pos_global); } } } @@ -4141,7 +4233,7 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) LLVector3 collide_point = slaved_pos; collide_point.mV[VZ] -= foot_plane_normal.mV[VZ] * (dist_from_plane + COLLISION_TOLERANCE - FOOT_COLLIDE_FUDGE); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); { F32 SQUARE_SIZE = 0.2f; gGL.color4f(1.f, 0.f, 0.f, 1.f); @@ -4288,7 +4380,7 @@ U32 LLVOAvatar::renderFootShadows() LLGLDepthTest test(GL_TRUE, GL_FALSE); //render foot shadows LLGLEnable blend(GL_BLEND); - mShadowImagep->bind(); + gGL.getTexUnit(0)->bind(mShadowImagep.get()); glColor4fv(mShadow0Facep->getRenderColor().mV); mShadow0Facep->renderIndexed(foot_mask); glColor4fv(mShadow1Facep->getRenderColor().mV); @@ -4306,7 +4398,7 @@ U32 LLVOAvatar::renderImpostor(LLColor4U color) LLVector3 pos(getRenderPosition()+mImpostorOffset); LLVector3 at = (pos - LLViewerCamera::getInstance()->getOrigin()); - at.normVec(); + at.normalize(); LLVector3 left = LLViewerCamera::getInstance()->getUpAxis() % at; LLVector3 up = at%left; @@ -4334,8 +4426,8 @@ U32 LLVOAvatar::renderImpostor(LLColor4U color) color.mV[3] = (U8) (alpha*255); gGL.color4ubv(color.mV); - mImpostor.bindTexture(); - gGL.begin(LLVertexBuffer::QUADS); + gGL.getTexUnit(0)->bind(&mImpostor); + gGL.begin(LLRender::QUADS); gGL.texCoord2f(0,0); gGL.vertex3fv((pos+left-up).mV); gGL.texCoord2f(1,0); @@ -4350,17 +4442,6 @@ U32 LLVOAvatar::renderImpostor(LLColor4U color) return 6; } -//----------------------------------------------------------------------------- -// renderCollisionVolumes() -//----------------------------------------------------------------------------- -void LLVOAvatar::renderCollisionVolumes() -{ - for (S32 i = 0; i < mNumCollisionVolumes; i++) - { - mCollisionVolumes[i].renderCollision(); - } -} - //------------------------------------------------------------------------ // LLVOAvatar::updateTextures() //------------------------------------------------------------------------ @@ -4395,23 +4476,23 @@ void LLVOAvatar::updateTextures(LLAgent &agent) { if( head_baked && ! mHeadBakedLoaded ) { - getTEImage( TEX_HEAD_BAKED )->bind(); + gGL.getTexUnit(0)->bind(getTEImage( TEX_HEAD_BAKED )); } if( upper_baked && ! mUpperBakedLoaded ) { - getTEImage( TEX_UPPER_BAKED )->bind(); + gGL.getTexUnit(0)->bind(getTEImage( TEX_UPPER_BAKED )); } if( lower_baked && ! mLowerBakedLoaded ) { - getTEImage( TEX_LOWER_BAKED )->bind(); + gGL.getTexUnit(0)->bind(getTEImage( TEX_LOWER_BAKED )); } if( eyes_baked && ! mEyesBakedLoaded ) { - getTEImage( TEX_EYES_BAKED )->bind(); + gGL.getTexUnit(0)->bind(getTEImage( TEX_EYES_BAKED )); } if( skirt_baked && ! mSkirtBakedLoaded ) { - getTEImage( TEX_SKIRT_BAKED )->bind(); + gGL.getTexUnit(0)->bind(getTEImage( TEX_SKIRT_BAKED )); } } @@ -4813,14 +4894,12 @@ BOOL LLVOAvatar::processSingleAnimationStateChange( const LLUUID& anim_id, BOOL // to support both spatialized and non-spatialized instances of the same sound //if (mIsSelf) //{ - // F32 volume = gain * gSavedSettings.getF32("AudioLevelUI") - // gAudiop->triggerSound(LLUUID(gSavedSettings.getString("UISndTyping")), volume); + // gAudiop->triggerSound(LLUUID(gSavedSettings.getString("UISndTyping")), 1.0f, LLAudioEngine::AUDIO_TYPE_UI); //} //else { LLUUID sound_id = LLUUID(gSavedSettings.getString("UISndTyping")); - F32 volume = gSavedSettings.getBOOL("MuteSounds") ? 0.f : gSavedSettings.getF32("AudioLevelSFX"); - gAudiop->triggerSound(sound_id, getID(), volume, char_pos_global); + gAudiop->triggerSound(sound_id, getID(), 1.0f, LLAudioEngine::AUDIO_TYPE_SFX, char_pos_global); } } } @@ -5719,7 +5798,9 @@ BOOL LLVOAvatar::loadMeshNodes() // llinfos << "Parsing mesh data for " << type << "..." << llendl; - mesh->setColor( 0.8f, 0.8f, 0.8f, 1.0f ); + // If this isn't set to white (1.0), avatars will *ALWAYS* be darker than their surroundings. + // Do not touch!!! + mesh->setColor( 1.0f, 1.0f, 1.0f, 1.0f ); LLPolyMesh *poly_mesh = NULL; @@ -5837,7 +5918,7 @@ void LLVOAvatar::setPixelAreaAndAngle(LLAgent &agent) } else { - F32 radius = size.magVec(); + F32 radius = size.length(); mAppAngle = (F32) atan2( radius, range) * RAD_TO_DEG; } @@ -6009,7 +6090,7 @@ void LLVOAvatar::updateShadowFaces() sprite.setPosition(shadow_pos_agent); LLVector3 foot_to_knee = mKneeLeftp->getWorldPosition() - joint_world_pos; - //foot_to_knee.normVec(); + //foot_to_knee.normalize(); foot_to_knee -= projected_vec(foot_to_knee, sun_vec); sprite.setYaw(azimuth(sun_vec - foot_to_knee)); @@ -6042,7 +6123,7 @@ void LLVOAvatar::updateShadowFaces() sprite.setPosition(shadow_pos_agent); LLVector3 foot_to_knee = mKneeRightp->getWorldPosition() - joint_world_pos; - //foot_to_knee.normVec(); + //foot_to_knee.normalize(); foot_to_knee -= projected_vec(foot_to_knee, sun_vec); sprite.setYaw(azimuth(sun_vec - foot_to_knee)); @@ -6403,7 +6484,7 @@ void LLVOAvatar::getOffObject() LLVector3 at_axis = LLVector3::x_axis; at_axis = at_axis * av_rot; at_axis.mV[VZ] = 0.f; - at_axis.normVec(); + at_axis.normalize(); gAgent.resetAxes(at_axis); //reset orientation @@ -6957,7 +7038,7 @@ BOOL LLVOAvatar::bindScratchTexture( LLGLenum format ) GLuint gl_name = getScratchTexName( format, &texture_bytes ); if( gl_name ) { - LLImageGL::bindExternalTexture( gl_name, 0, GL_TEXTURE_2D ); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, gl_name); stop_glerror(); F32* last_bind_time = LLVOAvatar::sScratchTexLastBindTime.getIfThere( format ); @@ -7015,7 +7096,7 @@ LLGLuint LLVOAvatar::getScratchTexName( LLGLenum format, U32* texture_bytes ) glGenTextures(1, &name ); stop_glerror(); - LLImageGL::bindExternalTexture( name, 0, GL_TEXTURE_2D ); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, name); stop_glerror(); glTexImage2D( @@ -7030,7 +7111,7 @@ LLGLuint LLVOAvatar::getScratchTexName( LLGLenum format, U32* texture_bytes ) glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); stop_glerror(); - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); stop_glerror(); LLVOAvatar::sScratchTexNames.addData( format, new LLGLuint( name ) ); @@ -8639,7 +8720,7 @@ void LLVOAvatar::onBakedTextureMasksLoaded( BOOL success, LLViewerImage *src_vi, glGenTextures(1, (GLuint*) &gl_name ); stop_glerror(); - LLImageGL::bindExternalTexture( gl_name, 0, GL_TEXTURE_2D ); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, gl_name); stop_glerror(); glTexImage2D( @@ -9914,7 +9995,7 @@ void LLVOAvatar::getImpostorValues(LLVector3* extents, LLVector3& angle, F32& di extents[1] = ext[1]; LLVector3 at = LLViewerCamera::getInstance()->getOrigin()-(getRenderPosition()+mImpostorOffset); - distance = at.normVec(); + distance = at.normalize(); F32 da = 1.f - (at*LLViewerCamera::getInstance()->getAtAxis()); angle.mV[0] = LLViewerCamera::getInstance()->getYaw()*da; angle.mV[1] = LLViewerCamera::getInstance()->getPitch()*da; diff --git a/linden/indra/newview/llvoavatar.h b/linden/indra/newview/llvoavatar.h index d66ddfc..8265e8a 100644 --- a/linden/indra/newview/llvoavatar.h +++ b/linden/indra/newview/llvoavatar.h @@ -308,6 +308,16 @@ public: U32 renderTransparent(); void renderCollisionVolumes(); + /*virtual*/ BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, + S32 face = -1, // which face to check, -1 = ALL_SIDES + BOOL pick_transparent = FALSE, + S32* face_hit = NULL, // which face was hit + LLVector3* intersection = NULL, // return the intersection point + LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point + LLVector3* normal = NULL, // return the surface normal at the intersection point + LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point + ); + /*virtual*/ void updateTextures(LLAgent &agent); // If setting a baked texture, need to request it from a non-local sim. /*virtual*/ S32 setTETexture(const U8 te, const LLUUID& uuid); diff --git a/linden/indra/newview/llvograss.cpp b/linden/indra/newview/llvograss.cpp index a028a63..821cf3e 100644 --- a/linden/indra/newview/llvograss.cpp +++ b/linden/indra/newview/llvograss.cpp @@ -273,9 +273,9 @@ U32 LLVOGrass::processUpdateMessage(LLMessageSystem *mesgsys, updateSpecies(); - if ( (getVelocity().magVecSquared() > 0.f) - ||(getAcceleration().magVecSquared() > 0.f) - ||(getAngularVelocity().magVecSquared() > 0.f)) + if ( (getVelocity().lengthSquared() > 0.f) + ||(getAcceleration().lengthSquared() > 0.f) + ||(getAngularVelocity().lengthSquared() > 0.f)) { llinfos << "ACK! Moving grass!" << llendl; setVelocity(LLVector3::zero); @@ -322,7 +322,7 @@ void LLVOGrass::setPixelAreaAndAngle(LLAgent &agent) { // This should be the camera's center, as soon as we move to all region-local. LLVector3 relative_position = getPositionAgent() - agent.getCameraPositionAgent(); - F32 range = relative_position.magVec(); + F32 range = relative_position.length(); F32 max_scale = getMaxScale(); @@ -501,7 +501,7 @@ void LLVOGrass::getGeometry(S32 idx, LLVector3 normal1 = (v1-v2) % (v2-v3); normal1.mV[VZ] = 0.75f; - normal1.normVec(); + normal1.normalize(); LLVector3 normal2 = -normal1; normal2.mV[VZ] = -normal2.mV[VZ]; @@ -578,3 +578,146 @@ void LLVOGrass::updateDrawable(BOOL force_damped) } clearChanged(SHIFTED); } + +// virtual +BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, BOOL pick_transparent, S32 *face_hitp, + LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal) + +{ + BOOL ret = FALSE; + if (!mbCanSelect || + mDrawable->isDead() || + !gPipeline.hasRenderType(mDrawable->getRenderType())) + { + return FALSE; + } + + LLVector3 dir = end-start; + + mPatch = mRegionp->getLand().resolvePatchRegion(getPositionRegion()); + + LLVector3 position; + // Create random blades of grass with gaussian distribution + F32 x,y,xf,yf,dzx,dzy; + + LLColor4U color(255,255,255,255); + + F32 width = sSpeciesTable[mSpecies]->mBladeSizeX; + F32 height = sSpeciesTable[mSpecies]->mBladeSizeY; + + LLVector2 tc[4]; + LLVector3 v[4]; + // LLVector3 n[4]; // unused! + + F32 closest_t = 1.f; + + for (S32 i = 0; i < mNumBlades; i++) + { + x = exp_x[i] * mScale.mV[VX]; + y = exp_y[i] * mScale.mV[VY]; + xf = rot_x[i] * GRASS_BLADE_BASE * width * w_mod[i]; + yf = rot_y[i] * GRASS_BLADE_BASE * width * w_mod[i]; + dzx = dz_x [i]; + dzy = dz_y [i]; + + LLVector3 v1,v2,v3; + F32 blade_height= GRASS_BLADE_HEIGHT * height * w_mod[i]; + + tc[0] = LLVector2(0, 0); + tc[1] = LLVector2(0, 0.98f); + tc[2] = LLVector2(1, 0); + tc[3] = LLVector2(1, 0.98f); + + position.mV[0] = mPosition.mV[VX] + x + xf; + position.mV[1] = mPosition.mV[VY] + y + yf; + position.mV[2] = mRegionp->getLand().resolveHeightRegion(position); + v[0] = v1 = position + mRegionp->getOriginAgent(); + + + + position.mV[0] += dzx; + position.mV[1] += dzy; + position.mV[2] += blade_height; + v[1] = v2 = position + mRegionp->getOriginAgent(); + + position.mV[0] = mPosition.mV[VX] + x - xf; + position.mV[1] = mPosition.mV[VY] + y - xf; + position.mV[2] = mRegionp->getLand().resolveHeightRegion(position); + v[2] = v3 = position + mRegionp->getOriginAgent(); + + LLVector3 normal1 = (v1-v2) % (v2-v3); + normal1.normalize(); + + position.mV[0] += dzx; + position.mV[1] += dzy; + position.mV[2] += blade_height; + v[3] = v1 = position + mRegionp->getOriginAgent(); + + + F32 a,b,t; + + BOOL hit = FALSE; + + + U32 idx0 = 0,idx1 = 0,idx2 = 0; + + if (LLTriangleRayIntersect(v[0], v[1], v[2], start, dir, &a, &b, &t, FALSE)) + { + hit = TRUE; + idx0 = 0; idx1 = 1; idx2 = 2; + } + else if (LLTriangleRayIntersect(v[1], v[3], v[2], start, dir, &a, &b, &t, FALSE)) + { + hit = TRUE; + idx0 = 1; idx1 = 3; idx2 = 2; + } + else if (LLTriangleRayIntersect(v[2], v[1], v[0], start, dir, &a, &b, &t, FALSE)) + { + normal1 = -normal1; + hit = TRUE; + idx0 = 2; idx1 = 1; idx2 = 0; + } + else if (LLTriangleRayIntersect(v[2], v[3], v[1], start, dir, &a, &b, &t, FALSE)) + { + normal1 = -normal1; + hit = TRUE; + idx0 = 2; idx1 = 3; idx2 = 1; + } + + if (hit) + { + if (t >= 0.f && + t <= 1.f && + t < closest_t) + { + + LLVector2 hit_tc = ((1.f - a - b) * tc[idx0] + + a * tc[idx1] + + b * tc[idx2]); + if (pick_transparent || + getTEImage(0)->getMask(hit_tc)) + { + closest_t = t; + if (intersection != NULL) + { + *intersection = start+dir*closest_t; + } + + if (tex_coord != NULL) + { + *tex_coord = hit_tc; + } + + if (normal != NULL) + { + *normal = normal1; + } + ret = TRUE; + } + } + } + } + + return ret; +} + diff --git a/linden/indra/newview/llvograss.h b/linden/indra/newview/llvograss.h index 679f5dc..fa22ebb 100644 --- a/linden/indra/newview/llvograss.h +++ b/linden/indra/newview/llvograss.h @@ -80,6 +80,16 @@ public: /*virtual*/ BOOL isActive() const; // Whether this object needs to do an idleUpdate. BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time); + /*virtual*/ BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, + S32 face = -1, // which face to check, -1 = ALL_SIDES + BOOL pick_transparent = FALSE, + S32* face_hit = NULL, // which face was hit + LLVector3* intersection = NULL, // return the intersection point + LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point + LLVector3* normal = NULL, // return the surface normal at the intersection point + LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point + ); + static S32 sMaxGrassSpecies; struct GrassSpeciesData diff --git a/linden/indra/newview/llvoground.cpp b/linden/indra/newview/llvoground.cpp index 32622ec..166c879 100644 --- a/linden/indra/newview/llvoground.cpp +++ b/linden/indra/newview/llvoground.cpp @@ -45,7 +45,7 @@ #include "pipeline.h" LLVOGround::LLVOGround(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) -: LLStaticViewerObject(id, pcode, regionp) +: LLStaticViewerObject(id, pcode, regionp, TRUE) { mbCanSelect = FALSE; } diff --git a/linden/indra/newview/llvoicevisualizer.cpp b/linden/indra/newview/llvoicevisualizer.cpp index f00247b..ad00804 100644 --- a/linden/indra/newview/llvoicevisualizer.cpp +++ b/linden/indra/newview/llvoicevisualizer.cpp @@ -378,20 +378,20 @@ void LLVoiceVisualizer::render() //----------------------------- // bind texture 0 (the dot) //----------------------------- - mSoundSymbol.mTexture[0]->bind(); + gGL.getTexUnit(0)->bind(mSoundSymbol.mTexture[0]); //------------------------------------------------------------- // now render the dot //------------------------------------------------------------- gGL.color4fv( LLColor4( 1.0f, 1.0f, 1.0f, DOT_OPACITY ).mV ); - gGL.begin( LLVertexBuffer::TRIANGLE_STRIP ); + gGL.begin( LLRender::TRIANGLE_STRIP ); gGL.texCoord2i( 0, 0 ); gGL.vertex3fv( bottomLeft.mV ); gGL.texCoord2i( 1, 0 ); gGL.vertex3fv( bottomRight.mV ); gGL.texCoord2i( 0, 1 ); gGL.vertex3fv( topLeft.mV ); gGL.end(); - gGL.begin( LLVertexBuffer::TRIANGLE_STRIP ); + gGL.begin( LLRender::TRIANGLE_STRIP ); gGL.texCoord2i( 1, 0 ); gGL.vertex3fv( bottomRight.mV ); gGL.texCoord2i( 1, 1 ); gGL.vertex3fv( topRight.mV ); gGL.texCoord2i( 0, 1 ); gGL.vertex3fv( topLeft.mV ); @@ -503,18 +503,19 @@ void LLVoiceVisualizer::render() LLVector3 topRight = mSoundSymbol.mPosition - l + u; gGL.color4fv( LLColor4( red, green, blue, mSoundSymbol.mWaveOpacity[i] ).mV ); - mSoundSymbol.mTexture[i]->bind(); + gGL.getTexUnit(0)->bind(mSoundSymbol.mTexture[i]); + //--------------------------------------------------- // now, render the mofo //--------------------------------------------------- - gGL.begin( LLVertexBuffer::TRIANGLE_STRIP ); + gGL.begin( LLRender::TRIANGLE_STRIP ); gGL.texCoord2i( 0, 0 ); gGL.vertex3fv( bottomLeft.mV ); gGL.texCoord2i( 1, 0 ); gGL.vertex3fv( bottomRight.mV ); gGL.texCoord2i( 0, 1 ); gGL.vertex3fv( topLeft.mV ); gGL.end(); - gGL.begin( LLVertexBuffer::TRIANGLE_STRIP ); + gGL.begin( LLRender::TRIANGLE_STRIP ); gGL.texCoord2i( 1, 0 ); gGL.vertex3fv( bottomRight.mV ); gGL.texCoord2i( 1, 1 ); gGL.vertex3fv( topRight.mV ); gGL.texCoord2i( 0, 1 ); gGL.vertex3fv( topLeft.mV ); @@ -550,8 +551,8 @@ VoiceGesticulationLevel LLVoiceVisualizer::getCurrentGesticulationLevel() //----------------------------------------------------------------------------------------- F32 range = mMaxGesticulationAmplitude - mMinGesticulationAmplitude; - if ( mSpeakingAmplitude > mMinGesticulationAmplitude + range * 0.66666f ) { gesticulationLevel = VOICE_GESTICULATION_LEVEL_HIGH; } - else if ( mSpeakingAmplitude > mMinGesticulationAmplitude + range * 0.33333f ) { gesticulationLevel = VOICE_GESTICULATION_LEVEL_MEDIUM; } + if ( mSpeakingAmplitude > mMinGesticulationAmplitude + range * 0.5f ) { gesticulationLevel = VOICE_GESTICULATION_LEVEL_HIGH; } + else if ( mSpeakingAmplitude > mMinGesticulationAmplitude + range * 0.25f ) { gesticulationLevel = VOICE_GESTICULATION_LEVEL_MEDIUM; } else if ( mSpeakingAmplitude > mMinGesticulationAmplitude + range * 0.00000f ) { gesticulationLevel = VOICE_GESTICULATION_LEVEL_LOW; } return gesticulationLevel; diff --git a/linden/indra/newview/llvopartgroup.cpp b/linden/indra/newview/llvopartgroup.cpp index 11d7341..fb91cfa 100644 --- a/linden/indra/newview/llvopartgroup.cpp +++ b/linden/indra/newview/llvopartgroup.cpp @@ -95,7 +95,7 @@ void LLVOPartGroup::setPixelAreaAndAngle(LLAgent &agent) { // mPixelArea is calculated during render F32 mid_scale = getMidScale(); - F32 range = (getRenderPosition()-LLViewerCamera::getInstance()->getOrigin()).magVec(); + F32 range = (getRenderPosition()-LLViewerCamera::getInstance()->getOrigin()).length(); if (range < 0.001f || isHUDAttachment()) // range == zero { @@ -133,15 +133,16 @@ F32 LLVOPartGroup::getPartSize(S32 idx) return 0.f; } +LLVector3 LLVOPartGroup::getCameraPosition() const +{ + return gAgent.getCameraPositionAgent(); +} + BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable) { LLFastTimer ftm(LLFastTimer::FTM_UPDATE_PARTICLES); dirtySpatialGroup(); - - LLVector3 at; - LLVector3 position_agent; - LLVector3 camera_agent = LLViewerCamera::getInstance()->getOrigin(); S32 num_parts = mViewerPartGroupp->getCount(); LLFace *facep; @@ -187,9 +188,9 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable) const LLViewerPart *part = mViewerPartGroupp->mParticles[i]; LLVector3 part_pos_agent(part->mPosAgent); - at = part_pos_agent - camera_agent; + LLVector3 at(part_pos_agent - LLViewerCamera::getInstance()->getOrigin()); - F32 camera_dist_squared = at.magVecSquared(); + F32 camera_dist_squared = at.lengthSquared(); F32 inv_camera_dist_squared; if (camera_dist_squared > 1.f) inv_camera_dist_squared = 1.f / camera_dist_squared; @@ -278,36 +279,38 @@ void LLVOPartGroup::getGeometry(S32 idx, LLVector3 part_pos_agent(part.mPosAgent); - LLVector3 camera_agent = gAgent.getCameraPositionAgent(); + LLVector3 camera_agent = getCameraPosition(); LLVector3 at = part_pos_agent - camera_agent; - LLVector3 up, right; + LLVector3 up; + LLVector3 right; right = at % LLVector3(0.f, 0.f, 1.f); - right.normVec(); + right.normalize(); up = right % at; - up.normVec(); + up.normalize(); if (part.mFlags & LLPartData::LL_PART_FOLLOW_VELOCITY_MASK) { LLVector3 normvel = part.mVelocity; - normvel.normVec(); + normvel.normalize(); LLVector2 up_fracs; up_fracs.mV[0] = normvel*right; up_fracs.mV[1] = normvel*up; - up_fracs.normVec(); + up_fracs.normalize(); LLVector3 new_up; LLVector3 new_right; new_up = up_fracs.mV[0] * right + up_fracs.mV[1]*up; new_right = up_fracs.mV[1] * right - up_fracs.mV[0]*up; up = new_up; right = new_right; - up.normVec(); - right.normVec(); + up.normalize(); + right.normalize(); } right *= 0.5f*part.mScale.mV[0]; up *= 0.5f*part.mScale.mV[1]; + const LLVector3& normal = -LLViewerCamera::getInstance()->getXAxis(); *verticesp++ = part_pos_agent + up - right; @@ -355,6 +358,13 @@ LLParticlePartition::LLParticlePartition() mLODPeriod = 1; } +LLHUDParticlePartition::LLHUDParticlePartition() : + LLParticlePartition() +{ + mDrawableType = LLPipeline::RENDER_TYPE_HUD; + mPartitionType = LLViewerRegion::PARTITION_HUD_PARTICLE; +} + void LLParticlePartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_count, U32& index_count) { group->mBufferUsage = mBufferUsage; @@ -480,3 +490,24 @@ F32 LLParticlePartition::calcPixelArea(LLSpatialGroup* group, LLCamera& camera) return 1024.f; } +U32 LLVOHUDPartGroup::getPartitionType() const +{ + // Commenting out and returning PARTITION_NONE because DEV-16909 + // (SVC-2396: Particles not handled properly as hud) didn't work completely + // so this disables HUD particles until they can be fixed properly. -MG + //return LLViewerRegion::PARTITION_HUD_PARTICLE; + return LLViewerRegion::PARTITION_NONE; +} + +LLDrawable* LLVOHUDPartGroup::createDrawable(LLPipeline *pipeline) +{ + pipeline->allocDrawable(this); + mDrawable->setLit(FALSE); + mDrawable->setRenderType(LLPipeline::RENDER_TYPE_HUD); + return mDrawable; +} + +LLVector3 LLVOHUDPartGroup::getCameraPosition() const +{ + return LLVector3(-1,0,0); +} diff --git a/linden/indra/newview/llvopartgroup.h b/linden/indra/newview/llvopartgroup.h index 5fe6750..037aa63 100644 --- a/linden/indra/newview/llvopartgroup.h +++ b/linden/indra/newview/llvopartgroup.h @@ -80,6 +80,23 @@ protected: ~LLVOPartGroup(); LLViewerPartGroup *mViewerPartGroupp; + + virtual LLVector3 getCameraPosition() const; + +}; + + +class LLVOHUDPartGroup : public LLVOPartGroup +{ +public: + LLVOHUDPartGroup(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) : + LLVOPartGroup(id, pcode, regionp) + { + } +protected: + LLDrawable* createDrawable(LLPipeline *pipeline); + U32 getPartitionType() const; + virtual LLVector3 getCameraPosition() const; }; #endif // LL_LLVOPARTGROUP_H diff --git a/linden/indra/newview/llvosky.cpp b/linden/indra/newview/llvosky.cpp index 60f674e..8c3b718 100644 --- a/linden/indra/newview/llvosky.cpp +++ b/linden/indra/newview/llvosky.cpp @@ -294,7 +294,7 @@ void LLSkyTex::createGLImage(S32 which) void LLSkyTex::bindTexture(BOOL curr) { - mImageGL[getWhich(curr)]->bind(); + gGL.getTexUnit(0)->bind(mImageGL[getWhich(curr)]); } /*************************************** @@ -308,7 +308,7 @@ S32 LLVOSky::sTileResX = sResolution/NUM_TILES_X; S32 LLVOSky::sTileResY = sResolution/NUM_TILES_Y; LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) -: LLStaticViewerObject(id, pcode, regionp), +: LLStaticViewerObject(id, pcode, regionp, TRUE), mSun(SUN_DISK_RADIUS), mMoon(MOON_DISK_RADIUS), mBrightnessScale(1.f), mBrightnessScaleNew(0.f), @@ -528,7 +528,7 @@ void LLVOSky::initSkyTextureDirs(const S32 side, const S32 tile) coeff[x_coef] = F32((x<<1) + 1) * inv_res - 1.f; coeff[y_coef] = F32((y<<1) + 1) * inv_res - 1.f; LLVector3 dir(coeff[0], coeff[1], coeff[2]); - dir.normVec(); + dir.normalize(); mSkyTex[side].setDir(dir, x, y); mShinyTex[side].setDir(dir, x, y); } @@ -762,7 +762,7 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo Pn *= (-32000.f / Pn[1]); } - Plen = Pn.magVec(); + Plen = Pn.length(); Pn /= Plen; // Initialize temp variables @@ -1082,7 +1082,7 @@ BOOL LLVOSky::updateSky() const static F32 COLOR_CHANGE_THRESHOLD = 0.01f; LLVector3 direction = mSun.getDirection(); - direction.normVec(); + direction.normalize(); const F32 dot_lighting = direction * mLastLightingDirection; LLColor3 delta_color; @@ -1092,7 +1092,7 @@ BOOL LLVOSky::updateSky() if ( mForceUpdate || ((dot_lighting < LIGHT_DIRECTION_THRESHOLD) - || (delta_color.magVec() > COLOR_CHANGE_THRESHOLD) + || (delta_color.length() > COLOR_CHANGE_THRESHOLD) || !mInitialized) && !direction.isExactlyZero()) { @@ -1336,8 +1336,8 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable) const LLVector3 &look_at = LLViewerCamera::getInstance()->getAtAxis(); LLVector3 right = look_at % LLVector3::z_axis; LLVector3 up = right % look_at; - right.normVec(); - up.normVec(); + right.normalize(); + up.normalize(); const static F32 elevation_factor = 0.0f/sResolution; const F32 cos_max_angle = cosHorizon(elevation_factor); @@ -1417,8 +1417,8 @@ BOOL LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 f, cons LLVector3 hb_right = to_dir % LLVector3::z_axis; LLVector3 hb_up = hb_right % to_dir; - hb_right.normVec(); - hb_up.normVec(); + hb_right.normalize(); + hb_up.normalize(); //const static F32 cos_max_turn = sqrt(3.f) / 2; // 30 degrees //const F32 cos_turn_right = 1. / (llmax(cos_max_turn, hb_right * right)); @@ -1601,8 +1601,8 @@ void LLVOSky::updateSunHaloGeometry(LLDrawable *drawable ) const LLVector3 right = 2 * (v_corner[2] - v_corner[0]); LLVector3 up = 2 * (v_corner[2] - v_corner[3]); - up.normVec(); - F32 size = right.magVec(); + up.normalize(); + F32 size = right.length(); up = size * up; const LLVector3 draw_pos = 0.25 * (v_corner[0] + v_corner[1] + v_corner[2] + v_corner[3]); @@ -1654,7 +1654,7 @@ void LLVOSky::updateSunHaloGeometry(LLDrawable *drawable ) F32 dtReflection(const LLVector3& p, F32 cos_dir_from_top, F32 sin_dir_from_top, F32 diff_angl_dir) { LLVector3 P = p; - P.normVec(); + P.normalize(); const F32 cos_dir_angle = -P.mV[VZ]; const F32 sin_dir_angle = sqrt(1 - cos_dir_angle * cos_dir_angle); @@ -1679,9 +1679,9 @@ F32 dtClip(const LLVector3& v0, const LLVector3& v1, F32 far_clip2) { F32 dt_clip; const LLVector3 otrezok = v1 - v0; - const F32 A = otrezok.magVecSquared(); + const F32 A = otrezok.lengthSquared(); const F32 B = v0 * otrezok; - const F32 C = v0.magVecSquared() - far_clip2; + const F32 C = v0.lengthSquared() - far_clip2; const F32 det = sqrt(B*B - A*C); dt_clip = (-B - det) / A; if ((dt_clip < 0) || (dt_clip > 1)) @@ -1701,16 +1701,16 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, LLVector3 hb_pos = to_dir * (HORIZON_DIST - 10); LLVector3 to_dir_proj = to_dir; to_dir_proj.mV[VZ] = 0; - to_dir_proj.normVec(); + to_dir_proj.normalize(); LLVector3 Right = to_dir % LLVector3::z_axis; LLVector3 Up = Right % to_dir; - Right.normVec(); - Up.normVec(); + Right.normalize(); + Up.normalize(); // finding angle between look direction and sprite. LLVector3 look_at_right = look_at % LLVector3::z_axis; - look_at_right.normVec(); + look_at_right.normalize(); const static F32 cos_horizon_angle = cosHorizon(0.0f/sResolution); //const static F32 horizon_angle = acos(cos_horizon_angle); @@ -1745,7 +1745,7 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, else dt_hor = llmax(0.0f, llmin(1.0f, dt_hor)); - top_hb.normVec(); + top_hb.normalize(); const F32 cos_angle_of_view = fabs(top_hb.mV[VZ]); const F32 extension = llmin (5.0f, 1.0f / cos_angle_of_view); @@ -1762,11 +1762,11 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, F32 cos_dir_from_top[2]; LLVector3 dir = stretch_corner[0]; - dir.normVec(); + dir.normalize(); cos_dir_from_top[0] = dir.mV[VZ]; dir = stretch_corner[1]; - dir.normVec(); + dir.normalize(); cos_dir_from_top[1] = dir.mV[VZ]; const F32 sin_dir_from_top = sqrt(1 - cos_dir_from_top[0] * cos_dir_from_top[0]); @@ -1789,7 +1789,7 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, for (vtx = 0; vtx < 2; ++vtx) { LLVector3 light_proj = v_corner[vtx]; - light_proj.normVec(); + light_proj.normalize(); const F32 z = light_proj.mV[VZ]; const F32 sin_angle = sqrt(1 - z * z); @@ -1813,9 +1813,9 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, S32 side = 0; LLVector3 refl_corn_norm[2]; refl_corn_norm[0] = v_refl_corner[1]; - refl_corn_norm[0].normVec(); + refl_corn_norm[0].normalize(); refl_corn_norm[1] = v_refl_corner[3]; - refl_corn_norm[1].normVec(); + refl_corn_norm[1].normalize(); F32 cos_refl_look_at[2]; cos_refl_look_at[0] = refl_corn_norm[0] * look_at; @@ -1833,13 +1833,13 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, F32 dt_clip; F32 vtx_near2, vtx_far2; - if ((vtx_far2 = v_refl_corner[side].magVecSquared()) > far_clip2) + if ((vtx_far2 = v_refl_corner[side].lengthSquared()) > far_clip2) { // whole thing is sprite: reflection is beyond far clip plane. dt_clip = 1.1f; quads = 1; } - else if ((vtx_near2 = v_refl_corner[side+1].magVecSquared()) > far_clip2) + else if ((vtx_near2 = v_refl_corner[side+1].lengthSquared()) > far_clip2) { // part is reflection, the rest is sprite. dt_clip = dtClip(v_refl_corner[side + 1], v_refl_corner[side], far_clip2); @@ -1903,7 +1903,7 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, { for (S32 vtx = 0; vtx < 4; ++vtx) { - F32 ratio = far_clip / v_refl_corner[vtx].magVec(); + F32 ratio = far_clip / v_refl_corner[vtx].length(); *(verticesp++) = v_refl_corner[vtx] = ratio * v_refl_corner[vtx] + mCameraPosAgent; } const LLVector3 draw_pos = 0.25 * @@ -1912,10 +1912,10 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, } else { - F32 ratio = far_clip / v_refl_corner[1].magVec(); + F32 ratio = far_clip / v_refl_corner[1].length(); v_sprite_corner[1] = v_refl_corner[1] * ratio; - ratio = far_clip / v_refl_corner[3].magVec(); + ratio = far_clip / v_refl_corner[3].length(); v_sprite_corner[3] = v_refl_corner[3] * ratio; v_refl_corner[1] = (1 - dt_clip) * v_refl_corner[1] + dt_clip * v_refl_corner[0]; @@ -2039,20 +2039,20 @@ void LLVOSky::updateFog(const F32 distance) LLVector3 tosun = getToSunLast(); const F32 tosun_z = tosun.mV[VZ]; tosun.mV[VZ] = 0.f; - tosun.normVec(); + tosun.normalize(); LLVector3 perp_tosun; perp_tosun.mV[VX] = -tosun.mV[VY]; perp_tosun.mV[VY] = tosun.mV[VX]; LLVector3 tosun_45 = tosun + perp_tosun; - tosun_45.normVec(); + tosun_45.normalize(); F32 delta = 0.06f; tosun.mV[VZ] = delta; perp_tosun.mV[VZ] = delta; tosun_45.mV[VZ] = delta; - tosun.normVec(); - perp_tosun.normVec(); - tosun_45.normVec(); + tosun.normalize(); + perp_tosun.normalize(); + tosun_45.normalize(); // Sky colors, just slightly above the horizon in the direction of the sun, perpendicular to the sun, and at a 45 degree angle to the sun. initAtmospherics(); @@ -2202,8 +2202,8 @@ F32 azimuth(const LLVector3 &v) void LLVOSky::initSunDirection(const LLVector3 &sun_dir, const LLVector3 &sun_ang_velocity) { - LLVector3 sun_direction = (sun_dir.magVec() == 0) ? LLVector3::x_axis : sun_dir; - sun_direction.normVec(); + LLVector3 sun_direction = (sun_dir.length() == 0) ? LLVector3::x_axis : sun_dir; + sun_direction.normalize(); mSun.setDirection(sun_direction); mSun.renewDirection(); mSun.setAngularVelocity(sun_ang_velocity); @@ -2222,8 +2222,8 @@ void LLVOSky::initSunDirection(const LLVector3 &sun_dir, const LLVector3 &sun_an void LLVOSky::setSunDirection(const LLVector3 &sun_dir, const LLVector3 &sun_ang_velocity) { - LLVector3 sun_direction = (sun_dir.magVec() == 0) ? LLVector3::x_axis : sun_dir; - sun_direction.normVec(); + LLVector3 sun_direction = (sun_dir.length() == 0) ? LLVector3::x_axis : sun_dir; + sun_direction.normalize(); // Push the sun "South" as it approaches directly overhead so that we can always see bump mapping // on the upward facing faces of cubes. @@ -2239,7 +2239,7 @@ void LLVOSky::setSunDirection(const LLVector3 &sun_dir, const LLVector3 &sun_ang // Blend between normal sun dir and adjusted sun dir based on how close we are // to having the sun overhead. mBumpSunDir = adjustedDir * sunDot + newDir * (1.0f - sunDot); - mBumpSunDir.normVec(); + mBumpSunDir.normalize(); F32 dp = mLastLightingDirection * sun_direction; mSun.setDirection(sun_direction); diff --git a/linden/indra/newview/llvosurfacepatch.cpp b/linden/indra/newview/llvosurfacepatch.cpp index 310a745..7055b30 100644 --- a/linden/indra/newview/llvosurfacepatch.cpp +++ b/linden/indra/newview/llvosurfacepatch.cpp @@ -916,6 +916,87 @@ void LLVOSurfacePatch::getGeomSizesEast(const S32 stride, const S32 east_stride, } } +BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, BOOL pick_transparent, S32 *face_hitp, + LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal) + +{ + + if (!lineSegmentBoundingBox(start, end)) + { + return FALSE; + } + + LLVector3 delta = end-start; + + LLVector3 pdelta = delta; + pdelta.mV[2] = 0; + + F32 plength = pdelta.length(); + + F32 tdelta = 1.f/plength; + + LLVector3 origin = start - mRegionp->getOriginAgent(); + + if (mRegionp->getLandHeightRegion(origin) > origin.mV[2]) + { + //origin is under ground, treat as no intersection + return FALSE; + } + + //step one meter at a time until intersection point found + + F32 t = 0.f; + while ( t <= 1.f) + { + LLVector3 sample = origin + delta*t; + + F32 height = mRegionp->getLandHeightRegion(sample); + if (height > sample.mV[2]) + { //ray went below ground, positive intersection + //quick and dirty binary search to get impact point + tdelta = -tdelta*0.5f; + F32 err_dist = 0.001f; + F32 dist = fabsf(sample.mV[2] - height); + + while (dist > err_dist && tdelta*tdelta > 0.0f) + { + t += tdelta; + sample = origin+delta*t; + height = mRegionp->getLandHeightRegion(sample); + if ((tdelta < 0 && height < sample.mV[2]) || + (height > sample.mV[2] && tdelta > 0)) + { //jumped over intersection point, go back + tdelta = -tdelta; + } + tdelta *= 0.5f; + dist = fabsf(sample.mV[2] - height); + } + + if (intersection) + { + sample.mV[2] = mRegionp->getLandHeightRegion(sample); + *intersection = sample + mRegionp->getOriginAgent(); + } + + if (normal) + { + *normal = mRegionp->getLand().resolveNormalGlobal(mRegionp->getPosGlobalFromRegion(sample)); + } + + return TRUE; + } + + t += tdelta; + if (t > 1 && t < 1.f+tdelta*0.99f) + { //make sure end point is checked (saves vertical lines coming up negative) + t = 1.f; + } + } + + + return FALSE; +} + void LLVOSurfacePatch::updateSpatialExtents(LLVector3& newMin, LLVector3 &newMax) { LLVector3 posAgent = getPositionAgent(); diff --git a/linden/indra/newview/llvosurfacepatch.h b/linden/indra/newview/llvosurfacepatch.h index 52c11c9..f014ca6 100644 --- a/linden/indra/newview/llvosurfacepatch.h +++ b/linden/indra/newview/llvosurfacepatch.h @@ -85,6 +85,16 @@ public: void dirtyPatch(); void dirtyGeom(); + /*virtual*/ BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, + S32 face = -1, // which face to check, -1 = ALL_SIDES + BOOL pick_transparent = FALSE, + S32* face_hit = NULL, // which face was hit + LLVector3* intersection = NULL, // return the intersection point + LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point + LLVector3* normal = NULL, // return the surface normal at the intersection point + LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point + ); + BOOL mDirtiedPatch; protected: ~LLVOSurfacePatch(); diff --git a/linden/indra/newview/llvotextbubble.cpp b/linden/indra/newview/llvotextbubble.cpp index 5424cc8..69b57d9 100644 --- a/linden/indra/newview/llvotextbubble.cpp +++ b/linden/indra/newview/llvotextbubble.cpp @@ -126,7 +126,7 @@ void LLVOTextBubble::updateTextures(LLAgent &agent) LLVector3 position_local = getPositionAgent() - agent.getCameraPositionAgent(); F32 dot_product = position_local * agent.getFrameAgent().getAtAxis(); - F32 cos_angle = dot_product / position_local.magVec(); + F32 cos_angle = dot_product / position_local.length(); if (cos_angle > 1.f) { diff --git a/linden/indra/newview/llvotree.cpp b/linden/indra/newview/llvotree.cpp index c86803d..06ab222 100644 --- a/linden/indra/newview/llvotree.cpp +++ b/linden/indra/newview/llvotree.cpp @@ -273,9 +273,9 @@ U32 LLVOTree::processUpdateMessage(LLMessageSystem *mesgsys, // Do base class updates... U32 retval = LLViewerObject::processUpdateMessage(mesgsys, user_data, block_num, update_type, dp); - if ( (getVelocity().magVecSquared() > 0.f) - ||(getAcceleration().magVecSquared() > 0.f) - ||(getAngularVelocity().magVecSquared() > 0.f)) + if ( (getVelocity().lengthSquared() > 0.f) + ||(getAcceleration().lengthSquared() > 0.f) + ||(getAngularVelocity().lengthSquared() > 0.f)) { llinfos << "ACK! Moving tree!" << llendl; setVelocity(LLVector3::zero); @@ -312,7 +312,7 @@ U32 LLVOTree::processUpdateMessage(LLMessageSystem *mesgsys, mTreeImagep = gImageList.getImage(sSpeciesTable[mSpecies]->mTextureID); if (mTreeImagep) { - mTreeImagep->bindTexture(0); + gGL.getTexUnit(0)->bind(mTreeImagep.get()); } mBranchLength = sSpeciesTable[mSpecies]->mBranchLength; mTrunkLength = sSpeciesTable[mSpecies]->mTrunkLength; @@ -359,14 +359,14 @@ BOOL LLVOTree::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) mTrunkBend += mTrunkVel; mTrunkVel *= 0.99f; // Add damping - if (mTrunkBend.magVec() > 1.f) + if (mTrunkBend.length() > 1.f) { - mTrunkBend.normVec(); + mTrunkBend.normalize(); } - if (mTrunkVel.magVec() > 1.f) + if (mTrunkVel.length() > 1.f) { - mTrunkVel.normVec(); + mTrunkVel.normalize(); } return TRUE; @@ -391,7 +391,7 @@ void LLVOTree::setPixelAreaAndAngle(LLAgent &agent) // This should be the camera's center, as soon as we move to all region-local. LLVector3 relative_position = getPositionAgent() - agent.getCameraPositionAgent(); - F32 range = relative_position.magVec(); // ugh, square root + F32 range = relative_position.length(); // ugh, square root F32 max_scale = mBillboardScale * getMaxScale(); F32 area = max_scale * (max_scale*mBillboardRatio); @@ -713,9 +713,9 @@ BOOL LLVOTree::updateGeometry(LLDrawable *drawable) LLVector2 tc; // This isn't totally accurate. Should compute based on slope as well. start_radius = r0 * (1.f + 1.2f*fabs(z - 0.66f*height)/height); - nvec.setVec( cos(nangle * DEG_TO_RAD)*start_radius*nvec_scale, - sin(nangle * DEG_TO_RAD)*start_radius*nvec_scale, - z*nvec_scalez); + nvec.set( cos(nangle * DEG_TO_RAD)*start_radius*nvec_scale, + sin(nangle * DEG_TO_RAD)*start_radius*nvec_scale, + z*nvec_scalez); // First and last slice at 0 radius (to bring in top/bottom of structure) radius = start_radius + turbulence3((F32*)&nvec.mV, (F32)fractal_depth)*noise_scale; @@ -918,7 +918,7 @@ void LLVOTree::updateRadius() void LLVOTree::updateSpatialExtents(LLVector3& newMin, LLVector3& newMax) { - F32 radius = getScale().magVec()*0.05f; + F32 radius = getScale().length()*0.05f; LLVector3 center = getRenderPosition(); F32 sz = mBillboardScale*mBillboardRatio*radius*0.5f; @@ -926,11 +926,53 @@ void LLVOTree::updateSpatialExtents(LLVector3& newMin, LLVector3& newMax) center += LLVector3(0, 0, size.mV[2]) * getRotation(); - newMin.setVec(center-size); - newMax.setVec(center+size); + newMin.set(center-size); + newMax.set(center+size); mDrawable->setPositionGroup(center); } +BOOL LLVOTree::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, BOOL pick_transparent, S32 *face_hitp, + LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal) + +{ + + if (!lineSegmentBoundingBox(start, end)) + { + return FALSE; + } + + const LLVector3* ext = mDrawable->getSpatialExtents(); + + LLVector3 center = (ext[1]+ext[0])*0.5f; + LLVector3 size = (ext[1]-ext[0]); + + LLQuaternion quat = getRotation(); + + center -= LLVector3(0,0,size.magVec() * 0.25f)*quat; + + size.scaleVec(LLVector3(0.25f, 0.25f, 1.f)); + size.mV[0] = llmin(size.mV[0], 1.f); + size.mV[1] = llmin(size.mV[1], 1.f); + + LLVector3 pos, norm; + + if (linesegment_tetrahedron(start, end, center, size, quat, pos, norm)) + { + if (intersection) + { + *intersection = pos; + } + + if (normal) + { + *normal = norm; + } + return TRUE; + } + + return FALSE; +} + U32 LLVOTree::getPartitionType() const { return LLViewerRegion::PARTITION_TREE; diff --git a/linden/indra/newview/llvotree.h b/linden/indra/newview/llvotree.h index 180e5b0..d6152a5 100644 --- a/linden/indra/newview/llvotree.h +++ b/linden/indra/newview/llvotree.h @@ -80,6 +80,17 @@ public: U32 drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD, S32 stop_level, U16 depth, U16 trunk_depth, F32 scale, F32 twist, F32 droop, F32 branches, F32 alpha); + + /*virtual*/ BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, + S32 face = -1, // which face to check, -1 = ALL_SIDES + BOOL pick_transparent = FALSE, + S32* face_hit = NULL, // which face was hit + LLVector3* intersection = NULL, // return the intersection point + LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point + LLVector3* normal = NULL, // return the surface normal at the intersection point + LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point + ); + static S32 sMaxTreeSpecies; struct TreeSpeciesData diff --git a/linden/indra/newview/llvovolume.cpp b/linden/indra/newview/llvovolume.cpp index 9d8369f..47289ff 100644 --- a/linden/indra/newview/llvovolume.cpp +++ b/linden/indra/newview/llvovolume.cpp @@ -90,7 +90,7 @@ LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re mLOD = MIN_LOD; mSculptLevel = -2; mTextureAnimp = NULL; - mVObjRadius = LLVector3(1,1,0.5f).magVec(); + mVObjRadius = LLVector3(1,1,0.5f).length(); mNumFaces = 0; mLODChanged = FALSE; mSculptChanged = FALSE; @@ -577,7 +577,7 @@ F32 LLVOVolume::getTextureVirtualSize(LLFace* face) //get area of circle in texture space LLVector2 tdim = face->mTexExtents[1] - face->mTexExtents[0]; - F32 texel_area = (tdim * 0.5f).magVecSquared()*3.14159f; + F32 texel_area = (tdim * 0.5f).lengthSquared()*3.14159f; if (texel_area <= 0) { // Probably animated, use default @@ -605,7 +605,7 @@ BOOL LLVOVolume::setMaterial(const U8 material) void LLVOVolume::setTexture(const S32 face) { llassert(face < getNumTEs()); - LLViewerImage::bindTexture(getTEImage(face)); + gGL.getTexUnit(0)->bind(getTEImage(face)); } void LLVOVolume::setScale(const LLVector3 &scale, BOOL damped) @@ -828,7 +828,7 @@ BOOL LLVOVolume::calcLOD() S32 cur_detail = 0; - F32 radius = getVolume()->mLODScaleBias.scaledVec(getScale()).magVec(); + F32 radius = getVolume()->mLODScaleBias.scaledVec(getScale()).length(); F32 distance = mDrawable->mDistanceWRTCamera; distance *= sDistanceFactor; @@ -1687,7 +1687,7 @@ void LLVOVolume::generateSilhouette(LLSelectNode* nodep, const LLVector3& view_p //transform view vector into volume space view_vector -= getRenderPosition(); - mDrawable->mDistanceWRTCamera = view_vector.magVec(); + mDrawable->mDistanceWRTCamera = view_vector.length(); LLQuaternion worldRot = getRenderRotation(); view_vector = view_vector * ~worldRot; if (!isVolumeGlobal()) @@ -1728,7 +1728,7 @@ void LLVOVolume::updateRadius() return; } - mVObjRadius = getScale().magVec(); + mVObjRadius = getScale().length(); mDrawable->setRadius(mVObjRadius); } @@ -1841,7 +1841,7 @@ F32 LLVOVolume::getBinRadius() } else if (shrink_wrap) { - radius = (ext[1]-ext[0]).magVec()*0.5f; + radius = (ext[1]-ext[0]).length()*0.5f; } else if (mDrawable->isStatic()) { @@ -1934,10 +1934,18 @@ LLVector3 LLVOVolume::volumeDirectionToAgent(const LLVector3& dir) const } -BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, S32 *face_hitp, +BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, BOOL pick_transparent, S32 *face_hitp, LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal) { + if (!mbCanSelect || + (gHideSelectedObjects && isSelected()) || + mDrawable->isDead() || + !gPipeline.hasRenderType(mDrawable->getRenderType())) + { + return FALSE; + } + LLVolume* volume = getVolume(); if (volume) { @@ -1946,37 +1954,88 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& e v_start = agentPositionToVolume(start); v_end = agentPositionToVolume(end); - S32 face_hit = volume->lineSegmentIntersect(v_start, v_end, face, - intersection, tex_coord, normal, bi_normal); - if (face_hit >= 0) + LLVector3 p; + LLVector3 n; + LLVector2 tc; + LLVector3 bn; + + if (intersection != NULL) { - if (face_hitp != NULL) - { - *face_hitp = face_hit; - } + p = *intersection; + } + + if (tex_coord != NULL) + { + tc = *tex_coord; + } + + if (normal != NULL) + { + n = *normal; + } + + if (bi_normal != NULL) + { + bn = *bi_normal; + } + + S32 face_hit = -1; + + S32 start_face, end_face; + if (face == -1) + { + start_face = 0; + end_face = volume->getNumFaces(); + } + else + { + start_face = face; + end_face = face+1; + } + + for (S32 i = start_face; i < end_face; ++i) + { + face_hit = volume->lineSegmentIntersect(v_start, v_end, i, + &p, &tc, &n, &bn); - if (intersection != NULL) + if (face_hit >= 0) { - *intersection = volumePositionToAgent(*intersection); // must map back to agent space - } + LLFace* face = mDrawable->getFace(face_hit); + if (pick_transparent || !face->getTexture() || face->getTexture()->getMask(face->surfaceToTexture(tc, p, n))) + { + if (face_hitp != NULL) + { + *face_hitp = face_hit; + } + + if (intersection != NULL) + { + *intersection = volumePositionToAgent(p); // must map back to agent space + } - if (normal != NULL) - { - *normal = volumeDirectionToAgent(*normal); - (*normal).normVec(); - } + if (normal != NULL) + { + *normal = volumeDirectionToAgent(n); + (*normal).normVec(); + } - if (bi_normal != NULL) - { - *bi_normal = volumeDirectionToAgent(*bi_normal); - (*bi_normal).normVec(); - } + if (bi_normal != NULL) + { + *bi_normal = volumeDirectionToAgent(bn); + (*bi_normal).normVec(); + } - - return TRUE; + if (tex_coord != NULL) + { + *tex_coord = tc; + } + + return TRUE; + } + } } } - + return FALSE; } diff --git a/linden/indra/newview/llvovolume.h b/linden/indra/newview/llvovolume.h index d8828f0..9502bc3 100644 --- a/linden/indra/newview/llvovolume.h +++ b/linden/indra/newview/llvovolume.h @@ -114,6 +114,7 @@ public: /*virtual*/ BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face = -1, // which face to check, -1 = ALL_SIDES + BOOL pick_transparent = FALSE, S32* face_hit = NULL, // which face was hit LLVector3* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/linden/indra/newview/llvowlsky.cpp b/linden/indra/newview/llvowlsky.cpp index 159603e..7c8e874 100644 --- a/linden/indra/newview/llvowlsky.cpp +++ b/linden/indra/newview/llvowlsky.cpp @@ -87,7 +87,7 @@ inline U32 LLVOWLSky::getStarsNumIndices(void) } LLVOWLSky::LLVOWLSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) - : LLStaticViewerObject(id, pcode, regionp) + : LLStaticViewerObject(id, pcode, regionp, TRUE) { initStars(); } @@ -488,7 +488,7 @@ void LLVOWLSky::drawStars(void) if (mStarsVerts.notNull()) { mStarsVerts->setBuffer(LLDrawPoolWLSky::STAR_VERTEX_DATA_MASK); - mStarsVerts->draw(LLVertexBuffer::POINTS, getStarsNumIndices(), 0); + mStarsVerts->draw(LLRender::POINTS, getStarsNumIndices(), 0); } } @@ -513,7 +513,7 @@ void LLVOWLSky::drawDome(void) strips_segment->setBuffer(data_mask); strips_segment->drawRange( - LLVertexBuffer::TRIANGLE_STRIP, + LLRender::TRIANGLE_STRIP, 0, strips_segment->getRequestedVerts()-1, strips_segment->getRequestedIndices(), 0); gPipeline.addTrianglesDrawn(strips_segment->getRequestedIndices() - 2); diff --git a/linden/indra/newview/llwaterparammanager.cpp b/linden/indra/newview/llwaterparammanager.cpp index f4f1163..e61c5b6 100644 --- a/linden/indra/newview/llwaterparammanager.cpp +++ b/linden/indra/newview/llwaterparammanager.cpp @@ -89,48 +89,57 @@ LLWaterParamManager::~LLWaterParamManager() void LLWaterParamManager::loadAllPresets(const std::string& file_name) { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); - LL_INFOS2("AppInit", "Shaders") << "Loading water settings from " << path_name << LL_ENDL; - - //mParamList.clear(); - + LL_INFOS2("AppInit", "Shaders") << "Loading Default water settings from " << path_name << LL_ENDL; + bool found = true; while(found) { std::string name; found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false); - - LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; - - // if we have one - if(found) + if(found) { + + name=name.erase(name.length()-4); + // bugfix for SL-46920: preventing filenames that break stuff. char * curl_str = curl_unescape(name.c_str(), name.size()); std::string unescaped_name(curl_str); curl_free(curl_str); curl_str = NULL; - // not much error checking here since we're getting rid of this - std::string water_name = unescaped_name.substr(0, unescaped_name.size() - 4); - - std::string cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", name)); - LL_DEBUGS2("AppInit", "Shaders") << "Loading water from " << cur_path << LL_ENDL; + LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; + loadPreset(unescaped_name,FALSE); + } + } + + // And repeat for user presets, note the user presets will modify any system presets already loaded + + std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", "")); + LL_INFOS2("AppInit", "Shaders") << "Loading User water settings from " << path_name2 << LL_ENDL; - llifstream water_xml(cur_path); - if (water_xml) - { - LLSD water_data(LLSD::emptyMap()); - LLPointer parser = new LLSDXMLParser(); - parser->parse(water_xml, water_data, LLSDSerialize::SIZE_UNLIMITED); + found = true; + while(found) + { + std::string name; + found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name, false); + if(found) + { + name=name.erase(name.length()-4); - addParamSet(water_name, water_data); - water_xml.close(); - } + // bugfix for SL-46920: preventing filenames that break stuff. + char * curl_str = curl_unescape(name.c_str(), name.size()); + std::string unescaped_name(curl_str); + curl_free(curl_str); + curl_str = NULL; + + LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; + loadPreset(unescaped_name,FALSE); } } + } -void LLWaterParamManager::loadPreset(const std::string & name) +void LLWaterParamManager::loadPreset(const std::string & name,bool propagate) { // bugfix for SL-46920: preventing filenames that break stuff. char * curl_str = curl_escape(name.c_str(), name.size()); @@ -142,8 +151,17 @@ void LLWaterParamManager::loadPreset(const std::string & name) std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", escaped_filename)); llinfos << "Loading water settings from " << pathName << llendl; - - llifstream presetsXML(pathName); + + std::ifstream presetsXML; + presetsXML.open(pathName.c_str()); + + // That failed, try loading from the users area instead. + if(!presetsXML) + { + pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", escaped_filename); + llinfos << "Loading User water setting from " << pathName << llendl; + presetsXML.open(pathName.c_str()); + } if (presetsXML) { @@ -170,10 +188,12 @@ void LLWaterParamManager::loadPreset(const std::string & name) return; } - getParamSet(name, mCurParams); - - propagateParameters(); -} + if(propagate) + { + getParamSet(name, mCurParams); + propagateParameters(); + } +} void LLWaterParamManager::savePreset(const std::string & name) { @@ -187,7 +207,7 @@ void LLWaterParamManager::savePreset(const std::string & name) // make an empty llsd LLSD paramsData(LLSD::emptyMap()); - std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", escaped_filename)); + std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", escaped_filename)); // fill it with LLSD windlight params paramsData = mParamList[name].getAll(); @@ -390,7 +410,8 @@ bool LLWaterParamManager::removeParamSet(const std::string& name, bool delete_fr if(delete_from_disk) { - std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); + + std::string path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", "")); // use full curl escaped name char * curl_str = curl_escape(name.c_str(), name.size()); diff --git a/linden/indra/newview/llwaterparammanager.h b/linden/indra/newview/llwaterparammanager.h index 872725e..a351697 100644 --- a/linden/indra/newview/llwaterparammanager.h +++ b/linden/indra/newview/llwaterparammanager.h @@ -228,7 +228,8 @@ public: void loadAllPresets(const std::string & fileName); /// load an individual preset into the sky - void loadPreset(const std::string & name); + + void loadPreset(const std::string & name,bool propagate=true); /// save the parameter presets to file void savePreset(const std::string & name); diff --git a/linden/indra/newview/llwebbrowserctrl.cpp b/linden/indra/newview/llwebbrowserctrl.cpp index e9a7132..8c56e5c 100644 --- a/linden/indra/newview/llwebbrowserctrl.cpp +++ b/linden/indra/newview/llwebbrowserctrl.cpp @@ -596,14 +596,14 @@ void LLWebBrowserCtrl::draw() } // scale texture to fit the space using texture coords - mWebBrowserImage->bindTexture(); + gGL.getTexUnit(0)->bind(mWebBrowserImage->getTexture()); gGL.color4fv( LLColor4::white.mV ); F32 max_u = ( F32 )mWebBrowserImage->getBrowserWidth() / ( F32 )mWebBrowserImage->getWidth(); F32 max_v = ( F32 )mWebBrowserImage->getBrowserHeight() / ( F32 )mWebBrowserImage->getHeight(); // draw the browser gGL.setSceneBlendType(LLRender::BT_REPLACE); - gGL.begin( LLVertexBuffer::QUADS ); + gGL.begin( LLRender::QUADS ); { // render using web browser reported width and height, instead of trying to invert GL scale gGL.texCoord2f( max_u, max_v ); diff --git a/linden/indra/newview/llwindebug.cpp b/linden/indra/newview/llwindebug.cpp index d2f6748..04457eb 100644 --- a/linden/indra/newview/llwindebug.cpp +++ b/linden/indra/newview/llwindebug.cpp @@ -42,6 +42,7 @@ #pragma warning(disable: 4200) //nonstandard extension used : zero-sized array in struct/union #pragma warning(disable: 4100) //unreferenced formal parameter + /* LLSD Block for Windows Dump Information @@ -552,6 +553,58 @@ void LLMemoryReserve::release() static LLMemoryReserve gEmergencyMemoryReserve; +#ifndef _M_IX86 + #error "The following code only works for x86!" +#endif +LPTOP_LEVEL_EXCEPTION_FILTER WINAPI MyDummySetUnhandledExceptionFilter( + LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) +{ + if(lpTopLevelExceptionFilter == gFilterFunc) + return gFilterFunc; + + llinfos << "Someone tried to set the exception filter. Listing call stack modules" << llendl; + LLSD cs_info; + GetCallStackData(NULL, cs_info); + + if(cs_info.has("CallStack") && cs_info["CallStack"].isArray()) + { + LLSD cs = cs_info["CallStack"]; + for(LLSD::array_iterator i = cs.beginArray(); + i != cs.endArray(); + ++i) + { + llinfos << "Module: " << (*i)["ModuleName"] << llendl; + } + } + + return gFilterFunc; +} + +BOOL PreventSetUnhandledExceptionFilter() +{ + HMODULE hKernel32 = LoadLibrary(_T("kernel32.dll")); + if (hKernel32 == NULL) + return FALSE; + + void *pOrgEntry = GetProcAddress(hKernel32, "SetUnhandledExceptionFilter"); + if(pOrgEntry == NULL) + return FALSE; + + unsigned char newJump[ 100 ]; + DWORD dwOrgEntryAddr = (DWORD)pOrgEntry; + dwOrgEntryAddr += 5; // add 5 for 5 op-codes for jmp far + void *pNewFunc = &MyDummySetUnhandledExceptionFilter; + DWORD dwNewEntryAddr = (DWORD) pNewFunc; + DWORD dwRelativeAddr = dwNewEntryAddr - dwOrgEntryAddr; + + newJump[ 0 ] = 0xE9; // JMP absolute + memcpy(&newJump[ 1 ], &dwRelativeAddr, sizeof(pNewFunc)); + SIZE_T bytesWritten; + BOOL bRet = WriteProcessMemory(GetCurrentProcess(), + pOrgEntry, newJump, sizeof(pNewFunc) + 1, &bytesWritten); + return bRet; +} + // static void LLWinDebug::initExceptionHandler(LPTOP_LEVEL_EXCEPTION_FILTER filter_func) { @@ -602,6 +655,9 @@ void LLWinDebug::initExceptionHandler(LPTOP_LEVEL_EXCEPTION_FILTER filter_func) LPTOP_LEVEL_EXCEPTION_FILTER prev_filter; prev_filter = SetUnhandledExceptionFilter(filter_func); + // *REMOVE:Mani + //PreventSetUnhandledExceptionFilter(); + if(prev_filter != gFilterFunc) { LL_WARNS("AppInit") @@ -737,3 +793,10 @@ void LLWinDebug::generateCrashStacks(struct _EXCEPTION_POINTERS *exception_infop LLSDSerialize::toPrettyXML(info, out_file); out_file.close(); } + +void LLWinDebug::clearCrashStacks() +{ + LLSD info; + std::string dump_path = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "SecondLifeException.log"); + LLFile::remove(dump_path); +} diff --git a/linden/indra/newview/llwindebug.h b/linden/indra/newview/llwindebug.h index eef2340..e6e32b4 100644 --- a/linden/indra/newview/llwindebug.h +++ b/linden/indra/newview/llwindebug.h @@ -39,7 +39,6 @@ class LLWinDebug { public: - /** * @brief initialize the llwindebug exception filter callback * @@ -66,6 +65,8 @@ public: static bool checkExceptionHandler(); static void generateCrashStacks(struct _EXCEPTION_POINTERS *pExceptionInfo = NULL); + static void clearCrashStacks(); // Delete the crash stack file(s). + static void writeDumpToFile(MINIDUMP_TYPE type, MINIDUMP_EXCEPTION_INFORMATION *ExInfop, const std::string& filename); private: }; diff --git a/linden/indra/newview/llwlparammanager.cpp b/linden/indra/newview/llwlparammanager.cpp index 1707fe9..b522284 100644 --- a/linden/indra/newview/llwlparammanager.cpp +++ b/linden/indra/newview/llwlparammanager.cpp @@ -106,84 +106,65 @@ LLWLParamManager::~LLWLParamManager() void LLWLParamManager::loadPresets(const std::string& file_name) { - // if fileName exists, use legacy loading form the big file, otherwise, search the sky - // directory, and add the list - if(file_name != "") + std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); + LL_INFOS2("AppInit", "Shaders") << "Loading Default WindLight settings from " << path_name << LL_ENDL; + + bool found = true; + while(found) { - std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", file_name)); - LL_INFOS2("AppInit", "Shaders") << "Loading WindLight settings from " << path_name << LL_ENDL; - - llifstream presetsXML(path_name); - - if (presetsXML) + std::string name; + found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false); + if(found) { - LLSD paramsData(LLSD::emptyMap()); - LLPointer parser = new LLSDXMLParser(); + name=name.erase(name.length()-4); - parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED); + // bugfix for SL-46920: preventing filenames that break stuff. + char * curl_str = curl_unescape(name.c_str(), name.size()); + std::string unescaped_name(curl_str); + curl_free(curl_str); + curl_str = NULL; - LLSD::map_const_iterator endParams = paramsData.endMap(); - for(LLSD::map_const_iterator curParams = paramsData.beginMap(); - curParams != endParams; - ++curParams) - { - addParamSet(curParams->first, curParams->second); - } + LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; + loadPreset(unescaped_name,FALSE); } } - - // otherwise, search the sky directory and find things there - else + + // And repeat for user presets, note the user presets will modify any system presets already loaded + + std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", "")); + LL_INFOS2("AppInit", "Shaders") << "Loading User WindLight settings from " << path_name2 << LL_ENDL; + + found = true; + while(found) { - std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); - LL_INFOS2("AppInit", "Shaders") << "Loading WindLight settings from " << path_name << LL_ENDL; - - //mParamList.clear(); - - bool found = true; - while(found) + std::string name; + found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name, false); + if(found) { - std::string name; - found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false); + name=name.erase(name.length()-4); + + // bugfix for SL-46920: preventing filenames that break stuff. + char * curl_str = curl_unescape(name.c_str(), name.size()); + std::string unescaped_name(curl_str); + curl_free(curl_str); + curl_str = NULL; LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; - - // if we have one - if(found) - { - // bugfix for SL-46920: preventing filenames that break stuff. - char * curl_str = curl_unescape(name.c_str(), name.size()); - std::string unescaped_name(curl_str); - curl_free(curl_str); - curl_str = NULL; - - // not much error checking here since we're getting rid of this - std::string sky_name = unescaped_name.substr(0, unescaped_name.size() - 4); - - std::string cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", name)); - LL_DEBUGS2("AppInit", "Shaders") << "Loading sky from " << cur_path << LL_ENDL; - - llifstream sky_xml(cur_path); - if (sky_xml) - { - LLSD sky_data(LLSD::emptyMap()); - LLPointer parser = new LLSDXMLParser(); - parser->parse(sky_xml, sky_data, LLSDSerialize::SIZE_UNLIMITED); - - addParamSet(sky_name, sky_data); - sky_xml.close(); - } - } + loadPreset(unescaped_name,FALSE); } } + } void LLWLParamManager::savePresets(const std::string & fileName) { + //Nobody currently calls me, but if they did, then its reasonable to write the data out to the user's folder + //and not over the RO system wide version. + LLSD paramsData(LLSD::emptyMap()); - std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", fileName)); + std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight", fileName)); for(std::map::iterator mIt = mParamList.begin(); mIt != mParamList.end(); @@ -201,8 +182,9 @@ void LLWLParamManager::savePresets(const std::string & fileName) presetsXML.close(); } -void LLWLParamManager::loadPreset(const std::string & name) +void LLWLParamManager::loadPreset(const std::string & name,bool propagate) { + // bugfix for SL-46920: preventing filenames that break stuff. char * curl_str = curl_escape(name.c_str(), name.size()); std::string escaped_filename(curl_str); @@ -214,7 +196,16 @@ void LLWLParamManager::loadPreset(const std::string & name) std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename)); llinfos << "Loading WindLight sky setting from " << pathName << llendl; - llifstream presetsXML(pathName); + llifstream presetsXML; + presetsXML.open(pathName.c_str()); + + // That failed, try loading from the users area instead. + if(!presetsXML) + { + pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename); + llinfos << "Loading User WindLight sky setting from " << pathName << llendl; + presetsXML.open(pathName.c_str()); + } if (presetsXML) { @@ -241,10 +232,13 @@ void LLWLParamManager::loadPreset(const std::string & name) return; } - getParamSet(name, mCurParams); - - propagateParameters(); -} + + if(propagate) + { + getParamSet(name, mCurParams); + propagateParameters(); + } +} void LLWLParamManager::savePreset(const std::string & name) { @@ -258,7 +252,7 @@ void LLWLParamManager::savePreset(const std::string & name) // make an empty llsd LLSD paramsData(LLSD::emptyMap()); - std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename)); + std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename)); // fill it with LLSD windlight params paramsData = mParamList[name].getAll(); @@ -533,7 +527,7 @@ bool LLWLParamManager::removeParamSet(const std::string& name, bool delete_from_ if(delete_from_disk) { - std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); + std::string path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", "")); // use full curl escaped name char * curl_str = curl_escape(name.c_str(), name.size()); diff --git a/linden/indra/newview/llwlparammanager.h b/linden/indra/newview/llwlparammanager.h index 7094051..2e1edad 100644 --- a/linden/indra/newview/llwlparammanager.h +++ b/linden/indra/newview/llwlparammanager.h @@ -135,7 +135,7 @@ public: void savePresets(const std::string & fileName); /// load an individual preset into the sky - void loadPreset(const std::string & name); + void loadPreset(const std::string & name,bool propogate=true); /// save the parameter presets to file void savePreset(const std::string & name); @@ -195,7 +195,6 @@ public: // singleton pattern implementation static LLWLParamManager * instance(); - public: // helper variables diff --git a/linden/indra/newview/llworld.cpp b/linden/indra/newview/llworld.cpp index 66c4068..28df561 100644 --- a/linden/indra/newview/llworld.cpp +++ b/linden/indra/newview/llworld.cpp @@ -32,6 +32,7 @@ #include "llviewerprecompiledheaders.h" #include "llworld.h" +#include "llrender.h" #include "indra_constants.h" #include "llstl.h" @@ -108,7 +109,7 @@ LLWorld::LLWorld() : *(default_texture++) = MAX_WATER_COLOR.mV[3]; mDefaultWaterTexturep = new LLViewerImage(raw, FALSE); - mDefaultWaterTexturep->bind(); + gGL.getTexUnit(0)->bind(mDefaultWaterTexturep.get()); mDefaultWaterTexturep->setClamp(TRUE, TRUE); } diff --git a/linden/indra/newview/llworldmap.cpp b/linden/indra/newview/llworldmap.cpp index 1048fe9..e83f6a9 100644 --- a/linden/indra/newview/llworldmap.cpp +++ b/linden/indra/newview/llworldmap.cpp @@ -498,7 +498,8 @@ void LLWorldMap::processMapLayerReply(LLMessageSystem* msg, void**) new_layer.LayerDefined = TRUE; msg->getUUIDFast(_PREHASH_LayerData, _PREHASH_ImageID, new_layer.LayerImageID, block); new_layer.LayerImage = gImageList.getImage(new_layer.LayerImageID, MIPMAP_TRUE, FALSE); - new_layer.LayerImage->bindTexture(0); + + gGL.getTexUnit(0)->bind(new_layer.LayerImage.get()); new_layer.LayerImage->setClamp(TRUE, TRUE); U32 left, right, top, bottom; @@ -610,7 +611,7 @@ void LLWorldMap::processMapBlockReply(LLMessageSystem* msg, void**) siminfo->mWaterHeight = (F32) water_height; siminfo->mMapImageID[agent_flags] = image_id; siminfo->mCurrentImage = gImageList.getImage(siminfo->mMapImageID[LLWorldMap::getInstance()->mCurrentMap], MIPMAP_TRUE, FALSE); - siminfo->mCurrentImage->bindTexture(0); + gGL.getTexUnit(0)->bind(siminfo->mCurrentImage.get()); siminfo->mCurrentImage->setClamp(TRUE, TRUE); if (siminfo->mMapImageID[2].notNull()) diff --git a/linden/indra/newview/llworldmapview.cpp b/linden/indra/newview/llworldmapview.cpp index 92d9588..3fd1d11 100644 --- a/linden/indra/newview/llworldmapview.cpp +++ b/linden/indra/newview/llworldmapview.cpp @@ -301,7 +301,7 @@ void LLWorldMapView::draw() LLLocalClipRect clip(getLocalRect()); { - LLGLSNoTexture no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); glMatrixMode(GL_MODELVIEW); @@ -377,7 +377,7 @@ void LLWorldMapView::draw() // Draw using the texture. If we don't clamp we get artifact at // the edge. - LLViewerImage::bindTexture(current_image); + gGL.getTexUnit(0)->bind(current_image); // Draw map image into RGB //gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -385,7 +385,7 @@ void LLWorldMapView::draw() gGL.setColorMask(true, false); gGL.color4f(1.f, 1.f, 1.f, layer_alpha); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.0f, 1.0f); gGL.vertex3f(left, top, -1.0f); gGL.texCoord2f(0.0f, 0.0f); @@ -401,7 +401,7 @@ void LLWorldMapView::draw() gGL.setColorMask(false, true); gGL.color4f(1.f, 1.f, 1.f, 1.f); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.0f, 1.0f); gGL.vertex2f(left, top); gGL.texCoord2f(0.0f, 0.0f); @@ -434,7 +434,7 @@ void LLWorldMapView::draw() if (info->mOverlayImage.isNull() && info->mMapImageID[2].notNull()) { info->mOverlayImage = gImageList.getImage(info->mMapImageID[2], MIPMAP_TRUE, FALSE); - info->mOverlayImage->bind(0); + gGL.getTexUnit(0)->bind(info->mOverlayImage.get()); info->mOverlayImage->setClamp(TRUE, TRUE); } @@ -536,13 +536,13 @@ void LLWorldMapView::draw() // Draw using the texture. If we don't clamp we get artifact at // the edge. LLGLSUIDefault gls_ui; - LLViewerImage::bindTexture(simimage); + gGL.getTexUnit(0)->bind(simimage); gGL.setSceneBlendType(LLRender::BT_ALPHA); F32 alpha = sim_alpha * info->mAlpha; gGL.color4f(1.f, 1.0f, 1.0f, alpha); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex3f(left, top, 0.f); gGL.texCoord2f(0.f, 0.f); @@ -555,9 +555,9 @@ void LLWorldMapView::draw() if (gSavedSettings.getBOOL("MapShowLandForSale") && overlayimage && overlayimage->getHasGLTexture()) { - LLViewerImage::bindTexture(overlayimage); + gGL.getTexUnit(0)->bind(overlayimage); gGL.color4f(1.f, 1.f, 1.f, alpha); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex3f(left, top, -0.5f); gGL.texCoord2f(0.f, 0.f); @@ -577,8 +577,8 @@ void LLWorldMapView::draw() gGL.setColorMask(false, true); gGL.color4f(1.f, 1.f, 1.f, 1.f); - LLGLSNoTexture gls_no_texture; - gGL.begin(LLVertexBuffer::QUADS); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.begin(LLRender::QUADS); gGL.vertex2f(left, top); gGL.vertex2f(left, bottom); gGL.vertex2f(right, bottom); @@ -596,8 +596,8 @@ void LLWorldMapView::draw() gGL.blendFunc(LLRender::BF_DEST_ALPHA, LLRender::BF_SOURCE_ALPHA); gGL.color4f(0.2f, 0.0f, 0.0f, 0.4f); - LLGLSNoTexture gls_no_texture; - gGL.begin(LLVertexBuffer::QUADS); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.begin(LLRender::QUADS); gGL.vertex2f(left, top); gGL.vertex2f(left, bottom); gGL.vertex2f(right, bottom); @@ -612,9 +612,9 @@ void LLWorldMapView::draw() { gGL.blendFunc(LLRender::BF_DEST_ALPHA, LLRender::BF_ZERO); - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color3f(1.f, 0.f, 0.f); - gGL.begin(LLVertexBuffer::LINES); + gGL.begin(LLRender::LINES); gGL.vertex2f(left, top); gGL.vertex2f(right, bottom); gGL.vertex2f(left, bottom); @@ -683,7 +683,7 @@ void LLWorldMapView::draw() // Draw background rectangle LLGLSUIDefault gls_ui; { - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.setAlphaRejectSettings(LLRender::CF_GREATER_EQUAL, 0.f); gGL.blendFunc(LLRender::BF_ONE_MINUS_DEST_ALPHA, LLRender::BF_DEST_ALPHA); gGL.color4fv( mBackgroundColor.mV ); @@ -969,7 +969,7 @@ void LLWorldMapView::drawFrustum() F32 ctr_x = getRect().getWidth() * 0.5f + sPanX; F32 ctr_y = getRect().getHeight() * 0.5f + sPanY; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // Since we don't rotate the map, we have to rotate the frustum. gGL.pushMatrix(); @@ -978,7 +978,7 @@ void LLWorldMapView::drawFrustum() // Draw triangle with more alpha in far pixels to make it // fade out in distance. - gGL.begin( LLVertexBuffer::TRIANGLES ); + gGL.begin( LLRender::TRIANGLES ); gGL.color4f(1.f, 1.f, 1.f, 0.25f); gGL.vertex2f( 0, 0 ); @@ -1184,11 +1184,11 @@ static void drawDot(F32 x_pixels, F32 y_pixels, F32 top = y_pixels + dot_radius; F32 bottom = y_pixels - dot_radius; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4fv( color.mV ); LLUI::setLineWidth(1.5f); F32 h_bar = relative_z > HEIGHT_THRESHOLD ? top : bottom; // horizontal bar Y - gGL.begin( LLVertexBuffer::LINES ); + gGL.begin( LLRender::LINES ); gGL.vertex2f(center, top); gGL.vertex2f(left, h_bar); gGL.vertex2f(right, h_bar); diff --git a/linden/indra/newview/lsl_guide.html b/linden/indra/newview/lsl_guide.html deleted file mode 100644 index aa660b8..0000000 --- a/linden/indra/newview/lsl_guide.html +++ /dev/null @@ -1,22078 +0,0 @@ - -Linden Scripting Language Guide

Linden Scripting Language Guide

Aaron Brashears

Andrew Meadows

Cory Ondrejka

Doug Soo

Donald Kjer

Copyright © 2007 Linden Lab

Linden Lab® and - Second Life® are registered - trademarks of Linden Research, Inc.


Table of Contents
1. Introduction
2. Getting Started
2.1. Hello Avatar
2.1.1. Creating the Script
2.1.2. Default State
2.1.3. Functions
2.1.4. Touch Event
2.1.5. Try it Out
2.2. Using The Built-In Editor
2.3. Using Alternative Editors
3. Basics
3.1. Comments
3.2. Arithmetic Operations
3.2.1. Assignment
3.2.2. Hexadecimal Entry
3.2.3. Binary Arithmetic Operators
3.2.4. Boolean Operators
3.2.5. Bitwise Operators
3.3. Types
3.3.1. Type Conversion
3.4. Global Functions
3.5. Global Variables
3.6. Local Variables
4. Flow Control
4.1. Conditional Statements
4.2. Loop Constructs
4.2.1. for loop
4.2.2. do-while loop
4.2.3. while loop
4.3. Jumps
4.4. State Change
5. States
5.1. state_entry()
5.2. state_exit()
5.3. States vs. Global variables
6. Math
6.1. Tables of Functions
7. Strings
7.1. Tables of Functions
8. Lists
8.1. Tables of Functions
9. Communication
9.1. Tables of Functions
10. Inventory
10.1. Tables of Functions
11. Vehicles
11.1. Overview
11.2. Warnings
11.3. Definitions
11.4. Setting the Vehicle Type
11.5. Linear and Angular Deflection
11.6. Moving and Steering the Vehicle
11.7. The Linear Motor
11.8. The Angular Motor
11.9. Using the Camera to Steer
11.10. The Vertical Attractor
11.11. Banking
11.12. Friction Timescales
11.13. Buoyancy
11.14. Hover
11.15. Reference Frame
A. Linden Library Functions
A.1. llAbs
A.2. llAcos
A.3. llAddToLandPassList
A.4. llAdjustSoundVolume
A.5. llAllowInventoryDrop
A.6. llAngleBetween
A.7. llApplyImpulse
A.8. llApplyRotationalImpulse
A.9. llAsin
A.10. llAtan2
A.11. llAttachToAvatar
A.12. llAvatarOnSitTarget
A.13. llAxes2Rot
A.14. llAxisAngle2Rot
A.15. llBase64ToString
A.16. llBreakAllLinks
A.17. llBreakLink
A.18. llCSV2List
A.19. llCeil
A.20. llCloseRemoteDataChannel
A.21. llCloud
A.22. llCollisionFilter
A.23. llCollisionSound
A.24. llCollisionSprite
A.25. llCos
A.26. llCreateLink
A.27. llDeleteSubList
A.28. llDeleteSubString
A.29. llDetachFromAvatar
A.30. llDetectedGrab
A.31. llDetectedGroup
A.32. llDetectedKey
A.33. llDetectedLinkNumber
A.34. llDetectedName
A.35. llDetectedOwner
A.36. llDetectedPos
A.37. llDetectedRot
A.38. llDetectedType
A.39. llDetectedVel
A.40. llDialog
A.41. llDie
A.42. llDumpList2String
A.43. llEscapeURL
A.44. llEdgeOfWorld
A.45. llEjectFromLand
A.46. llEmail
A.47. llEuler2Rot
A.48. llFabs
A.49. llFloor
A.50. llFrand
A.51. llGetAccel
A.52. llGetAttached
A.53. llGetAgentInfo
A.54. llGetAgentSize
A.55. llGetAlpha
A.56. llGetAndResetTime
A.57. llGetAnimation
A.58. llGetAnimationList
A.59. llGetBoundingBox
A.60. llGetCenterOfMass
A.61. llGetColor
A.62. llGetCreator
A.63. llGetDate
A.64. llGetEnergy
A.65. llGetForce
A.66. llGetFreeMemory
A.67. llGetGeometricCenter
A.68. llGetGMTclock
A.69. llGetInventoryCreator
A.70. llGetInventoryKey
A.71. llGetInventoryName
A.72. llGetInventoryNumber
A.73. llGetInventoryPermMask
A.74. llGetInventoryType
A.75. llGetKey
A.76. llGetLandOwnerAt
A.77. llGetLinkKey
A.78. llGetLinkName
A.79. llGetLinkNumber
A.80. llGetListEntryType
A.81. llGetListLength
A.82. llGetLocalPos
A.83. llGetLocalRot
A.84. llGetMass
A.85. llGetObjectMass
A.86. llGetNextEmail
A.87. llGetNotecardLine
A.88. llGetNumberOfNotecardLines
A.89. llGetNumberOfPrims
A.90. llGetNumberOfSides
A.91. llGetObjectDesc
A.92. llGetObjectName
A.93. llGetObjectPermMask
A.94. llGetOmega
A.95. llGetOwner
A.96. llGetOwnerKey
A.97. llGetPermissions
A.98. llGetPermissionsKey
A.99. llGetPos
A.100. llGetPrimitiveParams
A.101. llGetRegionCorner
A.102. llGetRegionFPS
A.103. llGetRegionName
A.104. llGetRegionTimeDilation
A.105. llGetRootPosition
A.106. llGetRootRotation
A.107. llGetRot
A.108. llGetScale
A.109. llGetScriptName
A.110. llGetStartParameter
A.111. llGetScriptState
A.112. llGetStatus
A.113. llGetSubString
A.114. llGetSunDirection
A.115. llGetTexture
A.116. llGetTextureOffset
A.117. llGetTextureRot
A.118. llGetTextureScale
A.119. llGetTime
A.120. llGetTimeOfDay
A.121. llGetTimestamp
A.122. llGetTorque
A.123. llGetVel
A.124. llGetWallclock
A.125. llGiveInventory
A.126. llGiveInventoryList
A.127. llGiveMoney
A.128. llGround
A.129. llGroundContour
A.130. llGroundNormal
A.131. llGroundRepel
A.132. llGroundSlope
A.133. llInsertString
A.134. llInstantMessage
A.135. llKey2Name
A.136. llList2CSV
A.137. llList2Float
A.138. llList2Integer
A.139. llList2Key
A.140. llList2List
A.141. llList2ListStrided
A.142. llList2Rot
A.143. llList2String
A.144. llList2Vector
A.145. llListFindList
A.146. llListInsertList
A.147. llListRandomize
A.148. llListReplaceList
A.149. llListSort
A.150. llListen
A.151. llListenControl
A.152. llListenRemove
A.153. llLoadURL
A.154. llLog
A.155. llLog10
A.156. llLookAt
A.157. llLoopSound
A.158. llLoopSoundMaster
A.159. llLoopSoundSlave
A.160. llMakeExplosion
A.161. llMakeFire
A.162. llMakeFountain
A.163. llMakeSmoke
A.164. llMD5String
A.165. llMessageLinked
A.166. llMinEventDelay
A.167. llModifyLand
A.168. llModPow
A.169. llMoveToTarget
A.170. llOffsetTexture
A.171. llOpenRemoteDataChannel
A.172. llOverMyLand
A.173. llParcelMediaCommandList
A.174. llParcelMediaQuery
A.175. llParseString2List
A.176. llParseStringKeepNulls
A.177. llParticleSystem
A.178. llPassCollisions
A.179. llPassTouches
A.180. llPlaySound
A.181. llPlaySoundSlave
A.182. llPointAt
A.183. llPow
A.184. llPreloadSound
A.185. llPushObject
A.186. llReleaseControls
A.187. llRemoteDataReply
A.188. llRemoteDataSetRegion
A.189. llRemoteLoadScript
A.190. llRemoteLoadScriptPin
A.191. llRemoveInventory
A.192. llRemoveVehicleFlags
A.193. llRequestAgentData
A.194. llRequestInventoryData
A.195. llRequestPermissions
A.196. llRequestSimulatorData
A.197. llResetScript
A.198. llResetOtherScript
A.199. llResetTime
A.200. llRezAtRoot
A.201. llRezObject
A.202. llRot2Angle
A.203. llRot2Axis
A.204. llRot2Euler
A.205. llRot2Fwd
A.206. llRot2Left
A.207. llRot2Up
A.208. llRotBetween
A.209. llRotLookAt
A.210. llRotTarget
A.211. llRotTargetRemove
A.212. llRotateTexture
A.213. llRound
A.214. llSameGroup
A.215. llSay
A.216. llScaleTexture
A.217. llScriptDanger
A.218. llSendRemoteData
A.219. llSensor
A.220. llSensorRemove
A.221. llSensorRepeat
A.222. llSetAlpha
A.223. llSetBuoyancy
A.224. llSetCameraAtOffset
A.225. llSetClickAction
A.226. llForceMouselook
A.227. llSetCameraEyeOffset
A.228. llSetColor
A.229. llSetDamage
A.230. llSetForce
A.231. llSetForceAndTorque
A.232. llSetHoverHeight
A.233. llSetLinkAlpha
A.234. llSetLinkColor
A.235. llSetLinkPrimitiveParams
A.236. llSetLinkTexture
A.237. llSetLocalRot
A.238. llSetObjectDesc
A.239. llSetObjectName
A.240. llSetParcelMusicURL
A.241. llSetPayPrice
A.242. llSetPos
A.243. llSetPrimitiveParams
A.244. llSetRemoteScriptAccessPin
A.245. llSetRot
A.246. llSetScale
A.247. llSetScriptState
A.248. llSetSitText
A.249. llSetSoundQueueing
A.250. llSetStatus
A.251. llSetText
A.252. llSetTexture
A.253. llSetTextureAnim
A.254. llSetTimerEvent
A.255. llSetTorque
A.256. llSetTouchText
A.257. llSetVehicleFlags
A.258. llSetVehicleFloatParam
A.259. llSetVehicleType
A.260. llSetVehicleRotationParam
A.261. llSetVehicleVectorParam
A.262. llShout
A.263. llSin
A.264. llSitTarget
A.265. llSleep
A.266. llSqrt
A.267. llStartAnimation
A.268. llStopAnimation
A.269. llStopHover
A.270. llStopLookAt
A.271. llStopMoveToTarget
A.272. llStopPointAt
A.273. llStopSound
A.274. llStringLength
A.275. llSubStringIndex
A.276. llStringToBase64
A.277. llTakeControls
A.278. llTan
A.279. llTarget
A.280. llTargetOmega
A.281. llTargetRemove
A.282. llTeleportAgentHome
A.283. llToLower
A.284. llToUpper
A.285. llTriggerSound
A.286. llTriggerSoundLimited
A.287. llUnescapeURL
A.288. llUnSit
A.289. llVecDist
A.290. llVecMag
A.291. llVecNorm
A.292. llVolumeDetect
A.293. llWater
A.294. llWhisper
A.295. llWind
A.296. llXorBase64Strings
B. Events
B.1. at_rot_target
B.2. at_target
B.3. attach
B.4. changed
B.5. collision
B.6. collision_end
B.7. collision_start
B.8. control
B.9. dataserver
B.10. email
B.11. land_collision
B.12. land_collision_end
B.13. land_collision_start
B.14. link_message
B.15. listen
B.16. money
B.17. moving_end
B.18. moving_start
B.19. no_sensor
B.20. not_at_rot_target
B.21. not_at_target
B.22. object_rez
B.23. on_rez
B.24. run_time_permissions
B.25. sensor
B.26. state_entry
B.27. state_exit
B.28. timer
B.29. touch
B.30. touch_end
B.31. touch_start
B.32. remote_data
C. Constants
C.1. Boolean Constants
C.2. Status Constants
C.3. Object Type Constants
C.4. Permission Constants
C.5. Inventory Constants
C.6. Pay Price Constants
C.7. Attachment Constants
C.8. Land Constants
C.9. Link Constants
C.10. Control Constants
C.11. Change Constants
C.12. Type Constants
C.13. Agent Info Constants
C.14. Texture Animation - Constants
C.15. Particle System Constants
C.16. Agent Data Constants
C.17. Float Constants
C.18. Key Constant
C.19. Miscellaneous Integer Constants
C.20. Miscellaneous String - Constants
C.21. Vector Constant
C.22. Rotation Constant
C.23. Simulator Data Constants
C.24. Vehicle Parameters
C.25. Vehicle Flags
C.26. Vehicle Types
C.27. Primitive Constants
C.28. XML-RPC Constants
C.29. Permission Mask Constants
C.30. Parcel Media Constants
C.31. Click Action Constants

Chapter 1. Introduction

The Linden Scripting Language (LSL) is a simple, powerful - language used to attach behaviors to the objects found in Second - Life. It follows the familiar syntax of a c/Java style language, - with an implicit state machine for every script.

Multiple scripts may also be attached to the same object, - allowing a style of small, single-function scripts to evolve. This - leads to scripts that perform specific functions ("hover", "follow", - etc.) and allows them to be combined to form new behaviors.

The text of the script is compiled into an executable byte - code, much like Java. This byte code is then run within a virtual - machine on the simulator. Each script receives a time slice of the - total simulator time allocated to scripts, so a simulator with many - scripts would allow each individual script less time rather than - degrading its own performance. In addition, each script executes - within its own chunk of memory, preventing scripts from writing into - protected simulator memory or into other scripts, making it much - harder for scripts to crash the simulator.

This tutorial introduces the reader to the basic features of - LSL, how to edit and apply your scripts, and a complete reference - for standard linden constants, events, and library functions.


Chapter 2. Getting Started

You're probably wondering what you can do with LSL, and how - quickly you can do it. We'll start with some simple examples, dissect - them, and introduce you the script development process while - we're at it.


2.1. Hello Avatar

Continuing a long tradition of getting started by looking at - a script that says "Hello", we'll do just that. Though obviously - not a particularly useful example on it's own, this example will - introduce us to:

  • Creating a basic script

  • Script states

  • Calling functions

  • Script events

  • Applying a script to an object


2.1.1. Creating the Script

Start by opening your inventory and selecting 'Create|New - Script' from the inventory pull down menu. This will create an - empty script called 'New Script' in your 'Scripts' - folder. Double click on the text or icon of the script to open - the script in the built in editor. When you open the script, the - viewer will automatically insert a basic skeleton for lsl. It - should look like:


default
-{
-    state_entry()
-    {
-        llSay(0, "Hello, Avatar!");
-    }
-
-    touch_start(integer total_number)
-    {
-        llSay(0, "Touched.");
-    }
-}
-      

A casual inspection of this script reveals that this script - probably says 'Hello, Avatar!' when it enters some state, and it - says 'Touched.' when it is touched. But since this is also - probably the first time you have seen a script we'll dissect this - short listing, explaining each segment individually.


2.1.2. Default State


default
-{
-...
-}
-      

All LSL scripts have a simple implicit state machine with - one or more states. All scripts must have a default state, so - if there is only one state, it will be the 'default' - state. When a script is first started or reset, it will start - out in the default state.

The default state is declared by placing the default at - the root level of the document, and marking the beginning with - an open brace '{' and ending with a close brace '}'. Because of - it's privileged status, you do not declare that it is fact a - state like you normally would with other states.

Every time you enter a state, the script engine will - automatically call the state_entry() event and execute the code - found there. On state exit, the script engine will automatically - call the state_exit() event before calling the next state's - state_entry handler. In our example, we call the - llSay() - function in state_entry() and do not bother to define a - state_exit() handler. the state entry and exit handlers are a - convenient place to initialize state data and clean up state - specific data such as listen event callback.

You can read more about the default state, and how to - create and utilize other states in the states chapter.


2.1.3. Functions

The language comes with well over 200 built in functions which allow scripts and - objects to interact with their environment. All of the built in - functions start with 'll'.

The example calls the llSay() - function twice, which is used to emit text on the specified channel. -

llSay( - integer channel - string text - );

Say text on channel. Channel 0 is the public chat channel - that all avatars see as chat text. Channels 1 to 2,147,483,648 - are private channels that aren't sent to avatars but other - scripts can listen for.

You can define your own functions as long as the name does - not conflict with a reserved word, built in constant, or built - in function.


2.1.4. Touch Event


touch_start(integer total_number)
-{
-    llSay(0, "Touched.");
-}
-      

There are many events that can - be detected in your scripts by declaring a handler. The - touch_start() - event is raised when a - user touches the object through the user interface.


2.1.5. Try it Out

Now that we have seen the default script, and examined it - in some detail, it is time to see the script in action. Save - the script by clicking on Save. During - the save process, the editor will save the text of the script - and compile the script into bytecode and then save that. When - you see message 'Compile successful!' in the preview window, you - know the compile and save is done.

To test the script you will have to apply it to an object - in the world. Create a new object in the world by - context clicking in the main world - view and selecting Create. When the wand - appears, you can create a simple primitive by - clicking in the world. Once the - object appears, you can drag your newly created script onto the - object to start the script.

Soon after dragging the script onto the object, you will - see the message Object: Hello - Avatar!

Make sure the touch event is working by - clicking on the object. You should - see the message Touched printed into the chat - history.


2.2. Using The Built-In Editor

The built in editor comes with most of the typical features - you would expect from a basic text editor. Highlight text with the - mouse, or by holding down the shift key while using the arrow - keys. You can cut, copy, paste, and delete your selection using - the 'Edit' pull down menu or by pressing the usual shortcut - key.


2.3. Using Alternative Editors

Since the built-in editor supports pasting text from the - clipboard, you can employ a different editor to edit your scripts, - copying them into Second Life when you're ready to save them.


Chapter 3. Basics

Now that we have seen a very simple script in action, we need - to look at the our toolchest for writing scripts. The next set of - tools we will consider are the basic building blocks for programming - a script, and will be used in every non-trivial script you write.


3.1. Comments

Commenting your scripts is a good idea, and will help when - you update and modify the script, or when you adapt parts of it - into other scripts. Unless the meaning is obvious, you should add - comments:

  • at the start of the script to explain the - purpose of the script

  • before every global variable to describe what - it holds

  • before every global function to describe what - it does

  • sprinkled through your script wherever the code - solves a problem that took you more than a few minutes to - figure out.

LSL uses Java/C++ style single line comments.


// This script toggles a the rotation of an object
-
-// g_is_rotating stores the current state of the rotation. TRUE is
-// rotating, FALSE otherwise.
-integer g_is_rotating = FALSE;
-default
-{
-    // toggle state during the touch handler
-    touch(integer num)
-    {
-        if(g_is_rotating)
-        {
-            // turn off rotation
-            llTargetOmega(<0,0,1>, 0, 0);
-            g_is_rotating = FALSE;
-        }
-        else
-        {
-            // rotate around the positive z axis - up.
-            llTargetOmega(<0,0,1>, 4, 1);
-            g_is_rotating = TRUE;
-        }
-    }
-}
-    


3.2. Arithmetic Operations

Most of the common arithmetic operations are supported in - lsl, and follow the C/Java syntax.


3.2.1. Assignment

The most common arithmetic operation is assignment, - denoted with the '=' sign. Loosely translated, it means, take - what you find on the right hand side of the equal sign and - assign it to the left hand side. Any expression that evaluates - to a basic type can be used as the right hand side of an - assignment, but the left hand side must be a normal - variable.

All basic types support assignment '=', equality '==' and - inequality '!=' operators.


// variables to hold a information about the target
-key g_target;
-vector g_target_postion;
-float g_target_distance;
-
-// function that demonstrates assignment
-set_globals(key target, vector pos)
-{
-    g_target = target;
-    g_target_position = pos;
-
-    // assignment from the return value of a function
-    vector my_pos = llGetPos(); 
-    g_target_distance = llVecDist(g_target_position, my_pos);
-}
-      


3.2.2. Hexadecimal Entry

Integers may be entered in hex form (e.g. 0xffff). For example:


integer Mask = 0xff;  // Equivalent to integer Mask = 255;
-integer Bit  = 0x0100 // Equivalent to integer Mask = 256;
-	


3.2.3. Binary Arithmetic Operators

Binary arithmetic operators behave like a function call - that accepts two parameters of the same type, and then return - that type; however, the syntax is slightly different.

Table 3-1. Binary Arithmetic Operators

OperatorMeaning
+Addition
-Subtraction
*Multiplication
/Division
%Modulo (remainder)
^Exclusive OR
<<Shift Left
>>Shift Right

Where noted, each type may have a special interpretation - of a binary arithmetic operator. See the lsl types section for more - details.


      


3.2.4. Boolean Operators

Table 3-2. Boolean Operators

OperatorMeaning
<Operator returns TRUE if the left hand side is less - than the right hand side.
>Operator returns TRUE if the left hand side is greater - than the right hand side.
<=Operator returns TRUE if the left hand side is less - than or equal to the right hand side.
>=Operator returns TRUE if the left hand side is greater - than or equal to the right hand side.
&&Operator returns TRUE if the left hand side and right - hand side are both true.
||Operator returns TRUE if either the left hand or right - hand side are true.
!Unary operator returns the logical negation of the - expression to the right.

3.2.5. Bitwise Operators

Table 3-3. Bitwise Operators

OperatorMeaning
&Returns the bitwise and of the left and right hand - side.
|Returns the bitwise or of the left and right hand - side.
~Unary operator returns the bitwise complement of the - expression to the right.

3.3. Types

Variables, return values, and parameters have type - information. LSL provides a small set of basic types that are used - throughout the language.

LSL Types

integer

A signed, 32-bit integer value with valid range from - -2147483648 to 2147483647.

float

An IEEE 32-bit floating point value with - values ranging from 1.175494351E-38 to - 3.402823466E+38.

key

A unique identifier that can be used to - reference objects and agents in Second Life.

vector

3 floats that are used together as a single - item. A vector can be used to represent a 3 dimensional - position, direction, velocity, force, impulse, or a - color. Each component can be accessed via '.x', '.y', and - '.z'.

Table 3-4. Vector Arithmetic Operators

OperatorMeaning
+Add two vectors together
-Subtract one vector from another
*Vector dot product
%Vector cross product
rotation

4 floats that are used together as a single - item to represent a rotation. This data is interpreted as a - quaternion. Each component can be accessed via '.x', '.y', - '.z', and '.s'.

Table 3-5. Rotation Arithmetic Operators

OperatorMeaning
+Add two rotations together
-Subtract one rotation from another
*Rotate the first rotation by the second
/Rotate the first rotation by the inverse of the second
list

A heterogeneous list of the other data types. Lists are - created via comma separated values of the other data types - enclosed by '[' and ']'.


string StringVar = "Hello, Carbon Unit";
-list MyList = [ 1234, ZERO_ROTATION, StringVar ];
-        

- Yields the list: [ 1234, <0,0,0,1>, "Hello, - Carbon Unit" ] -

Lists can be combined with other lists. For example: -


MyList = 3.14159 + MyList;
-        

- Yields the list: [ 3.14159, 1234, <0,0,0,1>, - "Hello, Carbon Unit" ] - And similarly, -


MyList = MyList + MyList;
-        

- Yields: [ 3.14159, 1234, <0,0,0,1>, "Hello, - Carbon Unit", 3.14159, 1234, <0,0,0,1>, "Hello, Carbon Unit" - ] -

Library functions exist used to copy data from lists, - sort lists, copy/remove sublists.


3.3.1. Type Conversion

Type conversion can either occur implicitly or explicitly. - Explicit type casts are accomplished using C syntax: -


float foo_float = 1.0;
-integer  foo_int = (integer)foo_float;
-      

-


3.3.1.1. Implicit Casting

LSL only supports two implicit type casts: integer to - float and string to key. Thus, any place you see a float - specified you can supply an integer, and any place you see a - key specified, you can supply a string.


3.3.1.2. Explicit Casting

LSL supports the following explicit casts: -

  • Integer to String

  • Float to Integer

  • Float to String

  • Vector to String

  • Rotation to String

  • Integer to List

  • Float to List

  • Key to List

  • String to List

  • Vector to List

  • Rotation to List

  • String to Integer

  • String to Float

  • String to Vector

  • String to Rotation

-


3.4. Global Functions

Global functions are also declared much like Java/C, with - the exception that no 'void' return value exists. Instead, if no - return value is needed, just don't specify one: - -


make_physical_and_spin(vector torque)
-{
-    // double the torque
-    vector double_torque = 2.0*torque;
-    llSetStatus(STATUS_PHYSICS, TRUE);
-    llApplyTorque(double_torque);
-}    
-    


3.5. Global Variables

Global variables and functions are accessible from anywhere - in the file. Global variables are declared much like Java or C, - although only one declaration may be made per line: -


vector gStartPosition;
-    

Global variables may also be initialized if desired, - although uninitialized global and local variables are initialized - to legal zero values: -


vector gStartPosition = <10.0,10.0,10.0>
-    


3.6. Local Variables

Local variables are scoped below their declaration within - the block of code they are declared in and may be declared within - any block of code. Thus the following code is legal and will work - like C: -


integer test_function()
-{
-    // Test vector that we can use anywhere in the function
-    vector test = <1,2,3>;
-    integer j;
-    for (j = 0; j < 10; j++)
-    {
-        // This vector is a different variable than the one declared above
-        // This IS NOT good coding practice
-        vector test = <j, j, j>;
-    }
-    // this test fails
-    if (test == <9,9,9>)
-    {
-        // never reached
-    }
-}
-    


Chapter 4. Flow Control

LSL comes with a complete complement of constructs meant to - deal with conditional processing, looping, as well as simply jumping - to a different point in the script.


4.1. Conditional Statements

The 'if' statement operates and has the - same syntax as the Java/C version.


check_message(string message)
-{
-    if(message == "open")
-    {
-        open();
-    }
-    else if(message == "close")
-    {
-        close();
-    }
-    else
-    {
-        llSay(0, "Unknown command: " + message);
-    }
-}
-    

The statements between the open and close curly brace are - performed if the conditional inside the parentheses evaluates to a - non-zero integer. Once a conditional is determined to be true - (non-zero), no further processing of 'else' conditionals will be - considered. The NULL_KEY constant - is counted as FALSE by conditional expressions.

There can be zero or more 'else if' statements, and an - optional final 'else' to handle the case when none of the if - statements evaluate to a non-zero integer.

The usual set of integer arithmetic and comparison operators - are available.


// a function that accepts some information about its environment and
-// determines the 'best' next step. This kind of code might be
-// part of a simple box meant to move close to an agent and attach to
-// them once near. This code sample relies on the standard linden
-// library functions as well as two other methods not defined here.
-assess_next_step(integer perm, integer attached, integer balance, float dist)
-{
-    string msg;
-    if(!attached)
-    {
-        if((perm & PERMISSION_ATTACH) && (dist < 10.0))
-        {
-             attach();
-        }
-        else if((dist > 10.0) || ((dist > 20.0) && (balance > 1000)))
-        {
-            move_closer();
-        }
-        else
-        {
-            llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
-        }
-    }
-}
-    


4.2. Loop Constructs

Loops are a basic building block of most useful programming - languages, and LSL offers the same loop constructs as found in - Java or C.


4.2.1. for loop

A for loop is most useful for when you know how many times - you need to iterate over an operation. Just like a Java or C for - loop, the parentheses have three parts, the initializer, the - continuation condition, and the increment. The loop continues - while the middle term evaluates to true, and the increment step - is performed at the end of every loop.


// move a non-physical block smoothly upward (positive z) the total
-// distance specified divided into steps discrete moves.
-move_up(float distance, integer steps)
-{
-    float step_distance = distance / (float)steps;
-    vector offset = <0.0, 0.0, step_distance>;
-    vector base_pos = llGetPos();
-    integer i;
-    for(i = 0; i <= steps; ++i)
-    {
-        llSetPos(base_pos + i * offset);
-        llSleep(0.1);
-    }
-}
-      


4.2.2. do-while loop

The do-while loop construct is most useful when you are - sure that you want to perform an operation at least once, but - you are not sure how many times you want to loop. The syntax is - the same as you would find in a Java or C program. A simple - English translation would be 'do the code inside the curly braces - and continue doing it if the statement after the while is - true.


// output the name of all inventory items attached to this object
-talk_about_inventory(integer type)
-{
-    string name;
-    integer i = 0;
-    integer continue = TRUE;
-    do
-    {
-        name = llGetInventoryName(type, i);
-        if(llStringLength(name) > 0)
-        {
-            llSay(0, "Inventory " + (string)i + ": " + name);
-        }
-        else
-        {
-            llSay(0, "No more inventory items");
-            continue = FALSE;
-        }
-        i++;
-    } while(continue);
-}
-      


4.2.3. while loop

The while loop behaves similarly to the do-while loop, - except it allows you to exit the loop without doing a single - iteration inside.


mention_inventory_type(integer type)
-{
-    integer i = llGetInventoryNumber(type);
-    while(i--)
-    {
-        llSay(0, "item: " + llGetInventory(i));
-    }
-}
-      


4.3. Jumps

A jump is used to move the running script to a new point - inside of a function or event handler. You cannot jump into other - functions or event handlers. Usually, you will want to use a jump - for in situations where the if..else statements would become too - cumbersome. For example, you may want to check several - preconditions, and exit if any of them are not met.


attach_if_ready(vector target_pos)
-{
-    // make sure we have permission
-    integer perm = llGetPerm();
-    if(!(perm & PERMISSION_ATTACH))
-    {
-        jump early_exit;
-    }
-
-    // make sure we're 10 or less meters away
-    vector pos = llGetPos()
-    float dist = llVecDist(pos, target_pos);
-    if(dist > 10.0)
-    {
-        jump early_exit;
-    }
-
-    // make sure we're roughly pointed toward the target.
-    // the calculation of max_cos_theta could be precomputed 
-    // as a constant, but is manually computed here to 
-    // illustrate the math.
-    float max_cos_theta = llCos(PI / 4.0);
-    vector toward_target = llVecNorm(target_pos - pos);
-    rotation rot = llGetRot();
-    vector fwd = llRot2Fwd(rot);
-    float cos_theta = toward_target * fwd;
-    if(cos_theta > max_cos_theta)
-    {
-        jump early_exit;
-    }
-
-    // at this point, we've done all the checks.
-    attach();
-
-    @early_exit;
-}
-    


4.4. State Change

State change allow you to move through the lsl virtual - machine's flexible state machine by transitioning your script to - and from user defined states and the default state. You can define - your own script state by placing the keyword 'state' before its - name and enclosing the event handlers with open and close curly - braces ('{' and '}'.) You can invoke the transition to a new state - by calling it with the syntax: 'state <statename>'.


default
-{
-    state_entry()
-    {
-        llSay(0, "I am in the default state");
-        llSetTimer(1.0);
-    }
-
-    timer()
-    {
-        state SpinState;
-    }
-}
-
-state SpinState
-{
-    state_entry()
-    {
-        llSay(0, "I am in SpinState!");
-        llTargetOmega(<0,0,1>, 4, 1.0);
-        llSetTimer(2.0);
-    }
-
-    timer()
-    {
-        state default;
-    }
-
-    state_exit()
-    {
-        llTargetOmega(<0,0,1>, 0, 0.0);
-    }
-}
-    


Chapter 5. States

All scripts must have a 'default' state, which is the first - state entered when the script starts. States contain event handlers - that are triggered by the LSL virtual machine. All states must - supply at least one event handler - it's not really a state without - one.

When state changes, all callback settings are retained and all - pending events are cleared.


5.1. state_entry()

The state_entry - event occurs whenever a new state is - entered, including program start, and is always the first event - handled. No data is passed to this event handler.

You will usually want to set callbacks for things such as - timers and sensor in the state_entry() callback of the state to - put your object into a useful condition for that state.

Warning: It is a common mistake to assume that the state_entry() - callback is called when you rez an object out of your - inventory. When you derez an object into your inventory the - current state of the script is saved, so there will not be a - call to state_entry() during the rez. If you need to provide - startup code every time an object is created, you should create - a global function and call it from both state_entry() and the - on_rez() callbacks.


// global initialization function.
-init()
-{
-    // Set up a listen callback for whoever owns this object.
-    key owner = llGetOwner();
-    llListen(0, "", owner, "");
-}
-
-default
-{
-    state_entry()
-    {
-        init();
-    }
-
-    on_rez(integer start_param)
-    {
-        init();
-    }
-
-    listen(integer channel, string name, key id, string message)
-    {
-        llSay(0, "Hi " + name + "! You own me.");
-    }
-}
-      


5.2. state_exit()

You will want to provide a state_exit() if you need to clean - up any events that you have requested in the current state, but do - not expect in the next state.


default
-{
-    state_entry()
-    {
-        state TimerState;
-    }
-}
-
-state TimerState
-{
-    state_entry()
-    {
-        // set a timer event for 5 seconds in the future.
-        llSetTimerEvent(5.0);
-    }
-
-    timer()
-    {
-        llSay(0, "timer");
-        state ListenState;
-    }
-
-    state_exit()
-    {
-        // turn off future timer events.
-        llSetTimerEvent(0.0);
-    }
-}
-
-integer g_listen_control;
-
-state ListenState
-{
-    state_entry()
-    {
-        // listen for anything on the public channel
-        g_listen_control = llListen(0, "", NULL_KEY, "");
-    }
-
-    listen(integer channel, string name, key id, string message)
-    {
-        llSay(0, "listen");
-        state TimerState;
-    }
-
-    state_exit()
-    {
-        // turn off the listener
-        llListenRemove(g_listen_control);
-    }
-}
-    

The state_exit() - handler is not called when an object is - being deleted - all callbacks, handlers, sounds, etc, will be - cleaned up automatically for you.


5.3. States vs. Global variables

A state and a set of global variables can serve the same - purpose, and each can be expressed in terms of the other. In - general, you should prefer the use of states over global variables - since states allow you to immediately assume script state without - making comparisons. The less comparisons a script makes, the more - regular code statements it can run.


Chapter 9. Communication


Chapter 11. Vehicles

Custom Vehicles can be constructed and controlled using the LSL. - This chapter will cover the basics of how vehicles work, the - terms used when describing vehicles, and a more thorough examination - of the api available.

There are several ways to make scripted objects move - themselves around. One way is to turn the object into a - "vehicle". This feature is versatile enough to make things - that slide, hover, fly, and float. Some of the behaviors that can be - enabled are:


11.1. Overview

Each scripted object can have one vehicle behavior that is - configurable through the llSetVehicleType, llSetVehicleFloatParam, - llSetVehicleVectorParam, - llSetVehicleRotationParam, - llSetVehicleFlags, - and llRemoveVehicleFlags - library calls.

These script calls are described in more detail below, but - the important thing to notice here is that the vehicle behavior - has several parameters that can be adjusted to change how the - vehicle handles. Depending on the values chosen the vehicle can - veer like a boat in water, or ride like a sled on rails.

Setting the vehicle flags allow you to make exceptions to - some default behaviors. Some of these flags only have an effect - when certain behaviors are enabled. For example, the - VEHICLE_FLAG_HOVER_WATER_ONLY will make the vehicle ignore the - height of the terrain, however it only makes a difference if the - vehicle is hovering.


11.2. Warnings

Vehicles are a work in progress and will - likely experience changes in future versions of Second Life. - Some of the details of vehicle behavior may be changed - as necessary to ensure stability - and user safety. In particular, many of the limits and defaults - described in the appendices will probably change and should not be - relied upon in the long term.

It is not recommended that you mix vehicle behavior with - some of the other script calls that provide impulse and forces to - the object, especially llSetBuoyancy, llSetForce, llSetTorque, and llSetHoverHeight.

While the following methods probably don't cause any - instabilities, their behavior may conflict with vehicles and cause - undesired and/or inconsistent results, so use llLookAt, llRotLookAt, llMoveToTarget, and llTargetOmega at your own - risk.

If you think you have found a bug relating to how vehicle's - work, one way to submit the problem is to give a copy of the - vehicle and script to Andrew Linden with comments or a notecard - describing the problem. Please name all submissions "Bugged - Vehicle XX" where XX are your Second Life initials. The - vehicle and script will be examined at the earliest - convenience.


11.3. Definitions

The terms "roll", "pitch", and - "yaw" are often used to describe the modes of rotations - that can happen to a airplane or boat. They correspond to - rotations about the local x-, y-, and z-axis respectively.


        z-axis  .
-      yaw-axis /|\
-                |     __. y-axis
-   ._        ___|      /| pitch-axis
-  _||\       \\ |\.   /
-  \|| \_______\_|__\_/_______
-   | _ _   o o o o o o o    |\_  ______\ x-axis
-   // ./_______,----,__________)       / roll-axis
-  /_,/        //  ./
-             /__,/ 
-	

The right-hand-rule, often introduced in beginning physics - courses, is used to define the direction of positive rotation - about any axis. As an example of how to use the right hand rule, - consider a positive rotation about the roll axis. To help - visualize how such a rotation would move the airplane, place your - right thumb parallel to the plane's roll-axis such that the thumb - points in the positive x-direction, then curl the four fingers - into a fist. Your fingers will be pointing in the direction that - the plane will spin.


    .-.--.--.--.              __
-   / /  /  /  _ \            /  \
-  (-(- (- (- (   | _________|______\ axis of
-   \.\._\._\._)  |          |      / rotation
-    |           \:__,---.  \|/
-    |                    |  + positive
-     \           .,_.___.'    rotation
-      \_ ^ `.__,/ 
-      |      / 
-      |      | 
-	

Many of the parameters that control a vehicle's behavior are - of the form: VEHICLE_BEHAVIOR_TIMESCALE. A behavior's - "timescale" can usually be understood as the time for - the behavior to push, twist, or otherwise affect the vehicle such - that the difference between what it is doing, and what it is - supposed to be doing, has been reduced to 1/e of what it was, - where "e" is the natural exponent (approximately - 2.718281828). In other words, it is the timescale for exponential - decay toward full compliance to the desired behavior. When you - want the vehicle to be very responsive use a short timescale of - one second or less, and if you want to disable a behavior then set - the timescale to a very large number like 300 (5 minutes) or - more. Note, for stability reasons, there is usually a limit to how - small a timescale is allowed to be, and is usually on the order of - a tenth of a second. Setting a timescale to zero is safe and is - always equivalent to setting it to its minimum. Any feature with a - timescale can be effectively disabled by setting the timescale so - large that it would take them all day to have any - effect.


11.4. Setting the Vehicle Type

Before any vehicle parameters can be set the vehicle - behavior must first be enabled. It is enabled by calling llSetVehicleType with any - VEHICLE_TYPE_*, except VEHICLE_TYPE_NONE which will disable the - vehicle. See the vehicle type - constants section for currently available types. More types - will be available soon.

Setting the vehicle type is necessary for enabling the - vehicle behavior and sets all of the parameters to its default - values. For each vehicle type listed we provide the corresponding - equivalent code in long format. Is is - important to realize that the defaults are - not the optimal settings for any of these - vehicle types and that they will definitely be changed in the - future. Do not rely on these values to be constant until - specified.

Should you want to make a unique or experimental vehicle you - will still have to enable the vehicle behavior with one of the - default types first, after which you will be able to change any of - the parameters or flags within the allowed ranges.

Setting the vehicle type does not automatically take - controls or otherwise move the object. However should you enable - the vehicle behavior while the object is free to move and parked - on a hill then it may start to slide away.

We're looking for new and better default vehicle types. If - you think you've found a set of parameters that make a better car, - boat, or any other default type of vehicle then you may submit - your proposed list of settings to Andrew Linden via a script or - notecard.


11.5. Linear and Angular Deflection

A common feature of real vehicles is their tendency to move - along "preferred axes of motion". That is, due to - their wheels, wings, shape, or method of propulsion they tend to - push or redirect themselves along axes that are static in the - vehicle's local frame. This general feature defines a - class of vehicles and included in this category a common - dart is a "vehicle": it - has fins in the back such that if it were to tumble in the air it - would eventually align itself to move point-forward -- we'll call - this alignment effect angular - deflection.

A wheeled craft exhibits a - different effect: when a - skateboard is pushed in some direction it will tend to redirect - the resultant motion along that which it is free to roll -- we'll - call this effect linear deflection.

So a typical Second Life vehicle is an object that - exhibits linear and/or angular deflection along the - "preferential axes of motion". The default - preferential axes of motion are the local x- (at), y- (left), and - z- (up) axes of the local frame of the - vehicle's root primitive. The deflection behaviors relate to the - x-axis (at): linear deflection will tend to rotate its velocity - until it points along it's positive local x-axis while the - angular deflection will tend to reorient the vehicle such that - it's x-axis points in the direction that it is moving. The other - axes are relevant to vehicle behaviors that are described later, - such as the - vertical attractor - which tries to keep a vehicle's - local z-axis pointed toward the world z-axis (up). The vehicle - axes can be rotated relative to the object's actual local axes by - using the - VEHICLE_REFERENCE_FRAME - parameter, however that is an - advanced feature and is covered in detail in a later section of - these documents.

Depending on the vehicle it might be desirable to have lots - of linear and/or angular deflection or not. The speed of the - deflections are controlled by setting the relevant parameters - using the llSetVehicleFloatParam - script call. Each variety of deflection has a - "timescale" parameter that determines how quickly a - full deflection happens. Basically the timescale it the time - coefficient for exponential decay toward full deflection. So, a - vehicle that deflects quickly should have a small timescale. For - instance, a typical dart might have a angular deflection - timescale of a couple of seconds but a linear deflection of - several seconds; it will tend to reorient itself before it - changes direction. To set the deflection timescales of a dart - you might use the lines below:


llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 2.0);
-llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 6.0);
-	

Each variety of deflection has an "efficiency" - parameter that is a slider between 0.0 and 1.0. Unlike the other - efficiency parameters of other vehicle behaviors, the deflection - efficiencies do not slide between "bouncy" and - "damped", but instead slide from "no deflection - whatsoever" (0.0) to "maximum deflection" (1.0). - That is, they behave much like the deflection timescales, however - they are normalized to the range between 0.0 and 1.0.


11.6. Moving and Steering the Vehicle

Once enabled, a vehicle can be pushed and rotated by - external forces and/or from script calls such as - llApplyImpulse, - however linear and angular motors have been built in - to make motion smoother and easier to control. - Their directions can be set using the - llSetVehicleVectorParam - call. For example, to make the vehicle try to move at 5 - meters/second along its local x-axis (the default look-at - direction) you would put the following line in your script:


llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <5, 0, 0>);
-	

The motor strength is not the full story, since you can also - control how fast the motor engages (VEHICLE_LINEAR_MOTOR_TIMESCALE) - and there is a parameter that causes the motor's effectiveness to - decay over time (VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE).

Steering the vehicle involves setting the - VEHICLE_ANGULAR_MOTOR_DIRECTION and related parameters. - It is also possible to set some flags that allow the angular - motor slave to your camera view when in mouselook.

For more details about the vehicle motors - read the sections on the linear - and angular - motors below.


11.7. The Linear Motor

The parameters that control the linear motor are:

  • VEHICLE_LINEAR_MOTOR_DIRECTION

    A vector. - It is the velocity (meters/sec) that the vehicle will - try to attain. It points in the vehicle's local frame, and has a - maximum length of 40.

  • VEHICLE_LINEAR_MOTOR_OFFSET

    A vector. - It is the offset point from the vehicle's center of mass at which - the linear motor's impulse is applied. This allows the linear motor - to also cause rotational torque. It is in the vehicle's local - frame and its maximum length is 100 meters! No need to worry - about stability -- if the vehicle starts to spin too fast - (greater than about 4*PI radians per second) then angular - velocity damping will kick in. The reason the offset is allowed - to be so large is so that it can compete with the other vehicle - behaviors such as angular deflection - and the vertical - attractor. Some of the other vehicle behaviors may - drastically reduce the effective torque from the linear motor - offset, in which case a longer leverage arm may help.

  • VEHICLE_LINEAR_MOTOR_TIMESCALE

    A float. Determines how long it takes for the motor to - push the vehicle to full speed. Its minimum value is approximately - 0.06 seconds.

  • VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE

    A float. The effectiveness of the motor will exponentially - decay over this timescale, but the effectiveness will be reset - whenever the motor's value is explicitly set. The maximum value - of this decay timescale is 120 seconds, - and this timescale is always in effect.

The flags that affect the linear motor are:

  • VEHICLE_FLAG_LIMIT_MOTOR_UP

    Useful for "ground vehicles". - Setting this flag will clamp the z-component of the linear - motor (in world frame) to prevent it from defeating gravity.

Setting the motor speed is not enough to enable all - interesting vehicles. For example, some will want a car that - immediately gets up to the speed they want, while others will want - a boat that slowly climbs up to its maximum velocity. To control - this effect the VEHICLE_LINEAR_MOTOR_TIMESCALE parameter can be - used. Basically the "timescale" of a motor is the - time constant for the vehicle to exponentially accelerate toward - its full speed.

What would happen if you were to accidentally set the - vehicle's linear velocity to maximum possible speed and then let - go? It would run away and never stop, right? Not necessarily: an - automatic "motor decay" has been built in such that all - motors will gradually decrease their effectiveness after being - set.

Each time the linear motor's vector is set its - "grip" - immediately starts to decay exponentially with a timescale - determined by the VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, such - that after enough time the motor ceases to have any effect. - This decay timescale serves two purposes. First, since it - cannot be set longer than 120 seconds, - and is always enabled it - guarantees that a vehicle will not push itself about forever - in the absence - of active control (from keyboard commands or some logic loop in - the script). Second, it can be used to push some vehicles around - using a simple impulse model. That is, rather than setting the - motor "on" or "off" depending on whether - a particular key is pressed "down" or "up" - the decay timescale can be set short and the motor can be set - "on" whenever the key transitions from "up" - to "down" and allowed to automatically decay.

Since the motor's effectiveness is reset whenever the - motor's vector is set, then setting it to a vector of length zero - is different from allowing it to decay completely. The first case - will cause the vehicle to try to reach zero velocity, while the - second will leave the motor impotent.

The two motor timescales have very similar names, but have - different effects, so try not to get them confused. - VEHICLE_LINEAR_MOTOR_TIMESCALE is the time for motor to - "win", and VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE is the - time for the motor's "effectiveness" to decay toward - zero. If you set one when you think you are changing the other - you will have frustrating results. Also, if the motor's decay - timescale is shorter than the regular timescale, then the - effective magnitude of the motor vector will be - diminished.


11.8. The Angular Motor

The parameters that control the angular motor are:

  • VEHICLE_ANGULAR_MOTOR_DIRECTION

    A vector. It is the angular velocity (radians/sec) - that the vehicle will try to rotate. It points in the vehicle's - local frame, and has a maximum value of 4*PI (two revolutions - per second).

  • VEHICLE_ANGULAR_MOTOR_TIMESCALE

    A float. Determines how long it takes for the motor to - spin the vehicle to full speed. Its minimum value is approximately - 0.06 seconds.

  • VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE

    A float. The effectiveness of the motor will exponentially - decay over this timescale, but the effectiveness will be reset - whenever the motor's value is explicitly set. The maximum value - of this decay timescale is 120 seconds, - and this timescale is always in effect.

Like the linear motor the angular motor can be set explicitly, - and has magnitude/direction, a timescale, and a decay timescale.

When it comes to actually steering a vehicle there are - several ways to do it. One way would be for the script to grab - keyboard input and to explicitly turn the motor on/off based on - which keys are pressed. When steering this way you probably - don't want it to turn very far or for very long. One way to do - it using the angular motor would be to leave the decay timescale - long, enable a significant amount of angular friction (to - quickly slow the vehicle down when the motor is turned off) then - set the angular motor to a large vector on a key press, and set - it to zero when the key is released. That has the effect of - making the vehicle unresponsive to external collisions, due to - the angular friction.

Another way to do it is to set the - VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE to a short value and push - the vehicle about with a more impulsive method that sets the - motor fast on a key press down (and optionally setting the motor - to zero on a key up) relying on the automatic exponential decay - of the motor's effectiveness rather than a constant angular - friction.

Finally, it may be possible to discard the angular motor - entirely and use the VEHICLE_LINEAR_MOTOR_OFFSET. Whenever the - offset has a component that is perpendicular to the direction - of the linear motor the vehicle will rotate as it travels. - Note, with the incorrect values for offset and strength the - linear motor effect can easily cause the vehicle to tumble - and spin uncontrollably, so experiement with small offsets - first!.

Setting the angular motor to zero magnitude is different - from allowing it to decay. When the motor completely decays - it no longer affects the motion of the vehicle, however setting - it to zero will reset the "grip" of the vehicle and - will make the vehicle try to achieve zero angular velocity. -

Many real vehicles bank (roll about their - forward axis) to effect a turn, such as motorcycles and airplanes. - To make it easier to build banking vehicles there is - banking behavior - available which can be controlled by setting other parameters and is - described in more detail here.

It is also possible to make a - vehicle turn in response - to changing the camera view - (right now this only works in mouselook).


11.9. Using the Camera to Steer

The vehicle can be instructed to rotate its forward axis - to point in the same direction as the camera view. This - is achieved by setting some flags that change how the - VEHICLE_ANGULAR_MOTOR_DIRECTION is interpreted. When used properly - this feature has the advantage of being able to provide simple - and stable steering that is resilient to bad render frame rates - on the client.

The flags that affect the angular motor are:

  • VEHICLE_FLAG_MOUSELOOK_STEER

    Steer the vehicle using the mouse. Use this flag to make - the angular motor try to make the vehicle - turn such that its local x-axis points in the same direction as - the client-side camera.

  • VEHICLE_FLAG_MOUSELOOK_BANK

    Same as above, but relies on banking. It remaps left-right - motions of the client camera (also known as "yaw") to rotations about - the vehicle's local x-axis (also known as "roll").

  • VEHICLE_FLAG_CAMERA_DECOUPLED

    Makes mouselook camera rotate independently of the vehicle. - By default the client mouselook camera will rotate about - with the vehicle, however when this flag is set the camera - direction is independent of the vehicle's rotation.

When using the VEHICLE_FLAG_MOUSELOOK_STEER (or - VEHICLE_FLAG_MOUSELOOK_BANK) the meaning of the - VEHICLE_ANGULAR_MOTOR_DIRECTION parameter subtly changes. Instead - of representing the "angular velocity" of the motor - the components of the parameter scale the "measured angular - velocity" (as determined by the rotation between - the client's camera view direction and the forward-axis of the vehicle) - to compute the "final angular velocity". That is, - suppose you set the angular motor to <0, 0, 5>, then moved the - camera view to be PI/4 radians to the left of the vehicle's forward axis, - and down PI/8 toward the ground. - The measured angular velocity would be <0, -PI/8, PI/4> - radians/second, but the final velocity would be <0, 0, 5*PI/4>... - the vehicle will turn left, but will not dip its nose down. - Thus, by setting a component of the VEHICLE_ANGULAR_MOTOR_DIRECTION - to zero, one can negate the pitch or yaw response of the motor, - or even scale one to be much more responsive than the other. -

The VEHICLE_ANGULAR_MOTOR_TIMESCALE still has an effect when - using mouselook control, and scales the global responsiveness of the - angular motor. The VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, on the other - hand, is ignored when using mouselook controls.


11.10. The Vertical Attractor

Some vehicles, like boats, should always keep their up-side - up. This can be done by enabling the "vertical - attractor" behavior that springs the vehicle's local z-axis - to the world z-axis (a.k.a. "up"). To take advantage of - this feature you would set the VEHICLE_VERTICAL_ATTRACTION_TIMESCALE - to control the period of the spring frequency, and then set the - VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY to control the damping. An - efficiency of 0.0 will cause the spring to wobble around its - equilibrium, while an efficiency of 1.0 will cause the spring to - reach it's equilibrium with exponential decay.


llSetVehicleVectorParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 4.0);
-llSetVehicleVectorParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.5);
-	

The vertical attractor is disabled by setting its timescale - to anything larger than 300 seconds.

Note that by default the vertical attractor will prevent the - vehicle from diving and climbing. So, if you wanted to make a - airplane you would probably want to unlock the attractor around the - pitch axis by setting the VEHICLE_FLAG_LIMIT_ROLL_ONLY bit:


llSetVehicleFlags(VEHICLE_FLAG_LIMIT_ROLL_ONLY);
-	


11.11. Banking

The vertical attractor feature must be enabled in order for - the banking behavior to function. The way banking works is this: a - rotation around the vehicle's roll-axis will produce a angular - velocity around the yaw-axis, causing the vehicle to turn. The - magnitude of the yaw effect will be proportional to the - VEHICLE_BANKING_EFFICIENCY, the angle of the roll rotation, and - sometimes the vehicle's velocity along it's preferred axis of - motion.

The VEHICLE_BANKING_EFFICIENCY can vary between -1 and +1. When - it's positive then any positive rotation (by the right-hand rule) - about the roll-axis will effect a (negative) torque around the - yaw-axis, making it turn to the right -- that is the vehicle will - lean into the turn, which is how real airplanes and motorcycle's - work. Negating the banking coefficient will make it so that the - vehicle leans to the outside of the turn (not very - "physical" but might allow interesting vehicles so why - not?).

The VEHICLE_BANKING_MIX is a fake (i.e. non-physical) - parameter that is useful for making banking vehicles do what you - want rather than what the laws of physics allow. For example, - consider a real motorcycle... it must be moving forward in order - for it to turn while banking, however video-game motorcycles are - often configured to turn in place when at a dead stop -- because - they're often easier to control that way using the limited - interface of the keyboard or game controller. The - VEHICLE_BANKING_MIX enables combinations of both realistic and - non-realistic banking by functioning as a slider between a banking - that is correspondingly totally static (0.0) and totally dynamic - (1.0). By "static" we mean that the banking effect - depends only on the vehicle's rotation about it's roll-axis - compared to "dynamic" where the banking is also - proportional to it's velocity along it's roll-axis. Finding the - best value of the "mixture" will probably require trial - and error.

The time it takes for the - banking behavior to defeat a - pre-existing angular velocity about the world z-axis is determined - by the VEHICLE_BANKING_TIMESCALE. So if you want the vehicle to - bank quickly then give it a banking timescale of about a second or - less, otherwise you can make a sluggish vehicle by giving it a - timescale of several seconds.


11.12. Friction Timescales

VEHICLE_LINEAR_FRICTION_TIMESCALE is a vector parameter that - defines the timescales for the vehicle to come to a complete stop - along the three local axes of the - vehicle's reference frame. - The timescale along each axis is independent of the others. - For example, a sliding ground car would probably have very little - friction along its x- and z-axes (so it can easily slide forward - and fall down) while there would usually significant friction - along its y-axis:


llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1000, 1000, 3>);
-	

Remember that a longer timescale corresponds to a weaker - friction, hence to effectively disable all linear friction you - would set all of the timescales to large values.

Setting the linear friction as a scalar is allowed, and has - the effect of setting all of the timescales to the same - value. Both code snippets below are equivalent, and both make friction - negligible:


// set all linear friction timescales to 1000
-llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1000, 1000, 1000>);
-	


// same as above, but fewer characters
-llSetVehicleFloatParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, 1000);
-	

VEHICLE_ANGULAR_FRICTION_TIMESCALE is also a vector - parameter that defines the timescales for the vehicle to stop - rotating about the x-, y-, and z-axes, and are set and disabled in - the same way as the linear friction.


11.13. Buoyancy

The vehicle has a built-in buoyancy feature that is - independent of the llSetBuoyancy call. It - is recommended that the two buoyancies do not mix! To make - a vehicle buoyant, set the VEHICLE_BUOYANCY parameter to something - between -1.0 (extra gravity) to 1.0 (full anti-gravity). -

The buoyancy behavior is independent of hover, however - in order for hover to work without a large offset of the - VEHICLE_HOVER_HEIGHT, the VEHICLE_BUOYANCY should be set to 1.0. -

It is not recommended that you mix vehicle buoyancy with - the llSetBuoyancy script call. - It would probably cause the object to fly up into space.


11.14. Hover

The hover behavior is enabled by setting the - VEHICLE_HOVER_TIMESCALE to a value less than 300 seconds; larger - timescales totally disable it. Most vehicles will work - best with short hover timescales of a few seconds or less. - The shorter the timescale, the faster the vehicle will - slave to is target height. Note, that if the values of - VEHICLE_LINEAR_FRICTION_TIMESCALE may affect the speed of - the hover.

Hover is independent of buoyancy, however the - VEHICLE_BUOYANCY should be set to 1.0, otherwise the vehicle - will not lift itself off of the ground until the - VEHICLE_HOVER_HEIGHT is made large enough to counter the - acceleration of gravity, and the vehicle will never float - all the way to its target height.

The VEHICLE_HOVER_EFFICIENCY can be thought of as a slider - between bouncy (0.0) and smoothed (1.0). When in the - bouncy range the vehicle will tend to hover a little lower than - its target height and the VEHICLE_HOVER_TIMESCALE will be - approximately the oscillation period of the bounce (the real - period will tend to be a little longer than the timescale).

For performance reasons, until improvements are made to the - Second Life physics engine the vehicles can only hover over the - terrain and water, so they will not be able to hover above - objects made out of primitives, such as bridges and houses. By - default the hover behavior will float over terrain and water, - however this can be changed by setting some flags:

If you wanted to make a boat you should set the - VEHICLE_HOVER_WATER_ONLY flag, or if you wanted to drive a hover - tank under water you would use the - VEHICLE_HOVER_TERRAIN_ONLY flag instead. - Finally, if you wanted to make a submarine or a balloon you would use the - VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT. Note that - the flags are independent of each other and that setting two - contradictory flags will have undefined behavior. The flags are - set using the script call llSetVehicleFlags().

The VEHICLE_HOVER_HEIGHT determines - how high the vehicle - will hover over the terrain and/or water, or the global height, - and has a maximum value of 100 meters. Note that for hovering - purposes the "center" of the vehicle is its "center of mass" - which is not always obvious to the untrained eye, and it - changes when avatar's sit on the vehicle.


11.15. Reference Frame

The vehicle relies on the x- (at), y- (left), and z- (up) - axes in order to figure out which way it prefers to move and - which end is up. By default these axes are identical to the - local axes of the root primitive of the object, however this - means that the vehicle's root primitive must, by default, be - oriented to agree with the designed at, left, and up axes of the - vehicle. But, what if the vehicle object was already pre-built - with the root primitive in some non-trivial orientation - relative to where the vehicle as a whole should move? This is - where the VEHICLE_REFERENCE_FRAME parameter becomes useful; the - vehicle's axes can be arbitrarily reoriented by setting this - parameter.

As an example, suppose you had built a rocket out of a big - cylinder, a cone for the nose, and some stretched cut boxes for - the fins, then linked them all together with the cylinder as the - root primitive. Ideally the rocket would move nose-first, - however the cylinder's axis of symmetry is its local z-axis while - the default "at-axis" of the vehicle, the axis it will - want to deflect to forward under angular deflection, is the local - x-axis and points out from the curved surface of the cylinder. - The script code below will rotate the vehicle's axes such that - the local z-axis becomes the "at-axis" and the local - negative x-axis becomes the "up-axis":


// rotate the vehicle frame -PI/2 about the local y-axis (left-axis)
-rotation rot = llEuler2Rot(0, PI/2, 0);
-llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, rot);
-

Another example of how the reference frame parameter could - be used is to consider flying craft that uses the vertical - attractor for stability during flying but wants to use VTOL - (vertical takeoff and landing). During flight the craft's dorsal - axis should point up, but during landing its nose-axis should be - up. To land the vehicle: while the - vertical attractor - is in effect, rotate the existing VEHICLE_REFERENCE_FRAME by +PI/2 - about the left-axis, then the vehicle will pitch up such that - it's nose points toward the sky. The vehicle could be allowed to - fall to the landing pad under friction, or a decreasing hover - effect.


Appendix A. Linden Library Functions

Complete listing of the Linden Library function calls - available in lsl.


A.1. llAbs

integer llAbs(integer val);

Returns the absolute value of - val.


A.2. llAcos

float llAcos(float val);

Returns the arccosine in radians of - val.


A.3. llAddToLandPassList

llAddToLandPassList(key avatar, float hours);

Add avatar to the land pass list for - hours.


A.4. llAdjustSoundVolume

llAdjustSoundVolume(float volume);

Adjusts the volume of the currently playing attached sound - started with llPlaySound or - llLoopSound. This function - Has no effect on sounds started with llTriggerSound.


A.5. llAllowInventoryDrop

llAllowInventoryDrop(integer add);

If add == TRUE, users that do no have - object modify permissions can still drop inventory items onto - object.


A.6. llAngleBetween

float llAngleBetween(rotation a, rotation b);

Returns the angle in radians between rotations - a and b.


A.7. llApplyImpulse

llApplyImpulse(vector force, integer local);

Applies the impulse in local - coordinates if local == TRUE. Otherwise the - impulse is applied in global coordinates. This function only works - on physical objects.


A.8. llApplyRotationalImpulse

llApplyRotationalImpulse(vector force, integer local);

Applies a rotational impulse force in - local coordinates if local == - TRUE. Otherwise the impulse is applied in global coordinates. This - function only works on physical objects.


A.9. llAsin

float llAsin(float val);

Returns the arcsine in radians of - val.


A.10. llAtan2

float llAtan2(float y, float x);

returns the arctangent2 of y, - x


A.11. llAttachToAvatar

llAttachToAvatar(key avatar, integer attachment);

Attach to avatar at point attachment. - Requires the PERMISSION_ATTACH runtime - permission.


A.12. llAvatarOnSitTarget

key llAvatarOnSitTarget(void);

If an avatar is sitting on the sit target, return - the avatar's key, NULL_KEY otherwise. - This only will detect avatars sitting on sit targets defined with llSitTarget.


A.13. llAxes2Rot

rotation llAxes2Rot(vector fwd, vector left, vector up);

Returns the rotation represented by coordinate axes - fwd, left, and - up.


A.14. llAxisAngle2Rot

rotation llAxisAngle2Rot(vector axis, float angle);

Returns the rotation generated angle - about axis.


A.15. llBase64ToString

string llBase64ToString(string str);

Converts a Base 64 string to a conventional string. If the - conversion creates any unprintable characters, they are converted to - spaces.


A.16. llBreakAllLinks

llBreakAllLinks(void);

Delinks all objects in the link set. Requires the permission - PERMISSION_CHANGE_LINKS - be set.


A.17. llBreakLink

llBreakLink(integer linknum);

Delinks the object with the given - link number. Requires permission PERMISSION_CHANGE_LINKS - be set.


A.18. llCSV2List

list llCSV2List(string src);

Create a list from a string of comma separated values - specified in src.


A.19. llCeil

integer llCeil(float val);

Returns largest integer value >= - val.


A.20. llCloseRemoteDataChannel

llCloseRemoteDataChannel(key channel);

Closes XML-RPC channel.


A.21. llCloud

float llCloud(vector offset);

Returns the cloud density at the object position + - offset.


A.22. llCollisionFilter

llCollisionFilter(string name, key id, integer accept);

If accept == TRUE, only accept - collisions with objects name and - id, otherwise with objects not - name or id. Specify - an empty string or NULL_KEY to - not filter on the corresponding parameter.


A.23. llCollisionSound

llCollisionSound(string impact_sound, float impact_volume);

Suppress default collision sounds, replace default impact - sounds with impact_sound found in the - object inventory. Supply an empty string to suppress collision - sounds.


A.24. llCollisionSprite

llCollisionSprite(string impact_sprite);

Suppress default collision sprites, replace default impact - sprite with impact_sprite found in the - object inventory. Supply an empty string to just suppress.


A.25. llCos

float llCos(float theta);

Returns the cosine of theta - radians.


A.26. llCreateLink

llCreateLink(key target, integer parent);

Attempt to link object script is attached to and - target. Requires permission PERMISSION_CHANGE_LINKS - be set. If parent == TRUE, object script is - attached to is the root.


A.27. llDeleteSubList

list llDeleteSubList(list src, integer start, integer end);

Remove the slice from the list and return the remainder. - The start and end - are inclusive, so 0, length - 1 would delete the entire list and - 0,0 would delete the first list entry. Using negative numbers for - start and/or end - causes the index to count backwards from the length of the list, - so 0,-1 would delete the entire list. If - start is larger than - end the list deleted is the exclusion of the - entries, so 6,4 would delete the entire list except for the - 5th list entry.


A.28. llDeleteSubString

string llDeleteSubString(string src, integer start, integer end);

Removes the indicated substring and returns the result. The - start and end are - inclusive, so 0,length-1 would delete the entire string and 0,0 - would delete the first character. Using negative numbers for - start and/or end - causes the index to count backwards from the length of the string, - so 0,-1 would delete the entire string. If - start is larger than end the sub string is - the exclusion of the entries, so 6,4 would delete the entire - string except for the 5th - character.


A.29. llDetachFromAvatar

llDetachFromAvatar(key avatar);

Drop off of avatar.


A.30. llDetectedGrab

vector llDetectedGrab(integer number);

Returns the grab offset of detected object - number. Returns <0,0,0> if number is - not valid sensed object.


A.31. llDetectedGroup

integer llDetectedGroup(integer number);

Returns TRUE if detected object - number is part of same group as - owner.


A.32. llDetectedKey

key llDetectedKey(integer number);

Returns the key of detected object - number. Returns NULL_KEY if number is not valid sensed - object.


A.33. llDetectedLinkNumber

integer llDetectedLinkNumber(integer number);

Returns the link position of the triggered event for - touches. 0 for a non-linked object, 1 for the root of a linked - object, 2 for the first child, etc.


A.34. llDetectedName

string llDetectedName(integer number);

Returns the name of detected object - number. Returns empty string if - number is not valid sensed object.


A.35. llDetectedOwner

key llDetectedOwner(integer number);

Returns the key of detected number - object's owner. Returns invalid key if - number is not valid sensed object.


A.36. llDetectedPos

vector llDetectedPos(integer number);

Returns the position of detected object - number. Returns <0,0,0> if - number is not valid sensed object.


A.37. llDetectedRot

rotation llDetectedRot(integer number);

Returns the rotation of detected object - number. Returns <0,0,0,1> if - number is not valid sensed object).


A.38. llDetectedType

integer llDetectedType(integer number);

Returns the type (AGENT, ACTIVE, PASSIVE, SCRIPTED) of - detected object number. Returns 0 if - number is not valid sensed object. Note - that number is a bitfield, so comparisons - need to be a bitwise and check. eg: -


integer type = llDetectedType(0);
-if (type & AGENT)
-{
-  // ...do stuff with the agent
-}
-

-


A.39. llDetectedVel

vector llDetectedVel(integer number);

Returns the velocity of detected object - number. Returns <0,0,0> if - number is not valid sensed object.


A.40. llDialog

llDialog(key avatar, string message, list buttons, integer channel);

Opens a "notify box" in the top-right corner of the given avatar's screen displaying the message. Up to twelve buttons can be specified in a list of strings. When the player clicks a button, the name of the button is chatted on the specified channel. Channels work just like llSay(), so channel 0 can be heard by everyone. The chat originates at the object's position, not the avatar's position. e.g. -


LLDialog(who, "Are you a boy or a girl?", [ "Boy", "Girl" ], 4913);
-LLDialog(who, "This shows only an OK button.", [], 192);
-llDialog(who, "This chats so you can hear it.", ["Hooray"], 0);
-

-


A.41. llDie

llDie(void);

Delete the object which holds the script.


A.42. llDumpList2String

string llDumpList2String(list src, string separator);

Write the list out in a single string using separator between values.


A.43. llEscapeURL

string llEscapeURL(string url);

Returns the string that is the URL escaped version of url, - replacing spaces with %20 etc.


A.44. llEdgeOfWorld

integer llEdgeOfWorld(vector pos, vector dir);

Returns TRUE if the line along dir - from pos hits the edge of the world in the - current simulator and returns FALSE if that edge crosses into - another simulator.


A.45. llEjectFromLand

llEjectFromLand(key pest);

Ejects pest from land that you - own.


A.46. llEmail

llEmail(string address, string subject, string message);

Sends email to address with - subject and - message.


A.47. llEuler2Rot

rotation llEuler2Rot(vector vec);

Returns the rotation represented by Euler Angle - vec.


A.48. llFabs

float llFabs(float val);

Returns the absolute value of - val.


A.49. llFloor

integer llFloor(float val);

Returns largest integer value <= - val.


A.50. llFrand

float llFrand(float mag);

Returns a pseudo-random number between [0, - mag).


A.51. llGetAccel

vector llGetAccel(void);

Gets the acceleration.


A.52. llGetAttached

integer llGetAttached(void);

Returns the object attachment point or 0 if not attached.


A.53. llGetAgentInfo

integer llGetAgentInfo(key id);

Returns information about the given agent - id. Returns a bitfield of agent info constants.


A.54. llGetAgentSize

vector llGetAgentSize(key id);

If the agent id is in the same sim as - the object, returns the size of the avatar.


A.55. llGetAlpha

float llGetAlpha(integer face);

Returns the alpha of the given - face. If face is - ALL_SIDES the value returned is - the mean average of all faces.


A.56. llGetAndResetTime

float llGetAndResetTime(void);

Returns the seconds of elapsed time from an internal timer - associated with the script. The timer is reset to zero during the - call. The timer is also reset on rez, simulator restart, script - reset, and in calls to llResetTime. Use llSetTimerEvent if you want a - reliable timing mechanism.


A.57. llGetAnimation

string llGetAnimation(key id);

Returns the currently playing animation for avatar - id.


A.58. llGetAnimationList

list llGetAnimationList(key id);

Returns a list of currently playing animations for avatar - id.


A.59. llGetBoundingBox

list llGetBoundingBox(key object);

Returns the bounding box around object (including any linked prims) - relative to the root prim. Returned value is a list of the form: - [ (vector) min_corner, (vector) max_corner ]


A.60. llGetCenterOfMass

vector llGetCenterOfMass(void);

Returns the center of mass of the root object.


A.61. llGetColor

vector llGetColor(integer face);

Returns the color of face as a vector - of red, green, and blue values between 0 and 1. If - face is ALL_SIDES the color returned is the - mean average of each channel.


A.62. llGetCreator

key llGetCreator(void);

Returns the creator of the object which has the script.


A.63. llGetDate

string llGetDate(void);

Returns the current UTC date as YYYY-MM-DD.


A.64. llGetEnergy

float llGetEnergy(void);

Returns how much energy is in the object as a percentage of - maximum.


A.65. llGetForce

vector llGetForce(void);

Returns the current force if the script is physical.


A.66. llGetFreeMemory

integer llGetFreeMemory(void);

Returns the available heap space for the current script.


A.67. llGetGeometricCenter

vector llGetGeometricCenter(void);

Returns the geometric center of the linked set the script is attached to.


A.68. llGetGMTclock

float llGetGMTclock(void);

Returns the time in seconds since GMT midnight.


A.69. llGetInventoryCreator

key llGetInventoryCreator(string name);

Returns the key for the creator of the inventory - name.


A.70. llGetInventoryKey

key llGetInventoryKey(string name);

Returns the key of the inventory - name.


A.71. llGetInventoryName

string llGetInventoryName(integer type, integer number);

Get the name of the inventory item - number of type. Use - the inventory constants to - specify the type.


A.72. llGetInventoryNumber

integer llGetInventoryNumber(integer type);

Get the number of items of type in - the object inventory. Use the inventory constants to specify - the type.


A.73. llGetInventoryPermMask

integer llGetInventoryPermMask(string item, integer mask);

Returns the requested permission mask for the - specified inventory item. See Permission Mask Constants - for more information. Example usage: -


integer JeansPerms = llGetInventoryPermMask("Black Jeans", MASK_NEXT);
-if (JeansPerms & PERM_COPY)
-{
-	llSay(0, "The next owner may copy the 'Black Jeans'");
-}
-


A.74. llGetInventoryType

integer llGetInventoryType(string name);

Returns the type of the inventory - name. INVENTORY_NONE is returned if no - inventory matching name is found. Use the inventory constants to compare - against the return value.


A.75. llGetKey

key llGetKey(void);

Get the key for the object which has this script.


A.76. llGetLandOwnerAt

key llGetLandOwnerAt(vector pos);

Returns the key of the land owner at - pos or NULL_KEY if public.


A.77. llGetLinkKey

key llGetLinkKey(integer linknum);

Returns the key of linknum in the link - set.


A.78. llGetLinkName

string llGetLinkName(integer linknum);

Returns the name of linknum in the - link set.


A.79. llGetLinkNumber

integer llGetLinkNumber(void);

Returns what link number in a link set the for the object - which has this script. 0 means no link, 1 the root, 2 for first - child, etc.


A.80. llGetListEntryType

integer llGetListEntryType(list src, integer index);

Returns the type of the - variable at index in - src.


A.81. llGetListLength

integer llGetListLength(list src);

Returns the number of elements in - src.


A.82. llGetLocalPos

vector llGetLocalPos(void);

Returns the local position of a child object relative to the - root.


A.83. llGetLocalRot

rotation llGetLocalRot(void);

Returns the local rotation of a child object relative to the - root.


A.84. llGetMass

float llGetMass(void);

Returns the mass of the object in Kilograms. Most materials - in Second Life are less dense than their first life counterparts, - so the returned mass may be less than you might expect.


A.85. llGetObjectMass

float llGetObjectMass(key id);

Returns the mass of the object specified by id in Kilograms. Most materials - in Second Life are less dense than their first life counterparts, - so the returned mass may be less than you might expect.


A.86. llGetNextEmail

llGetNextEmail(string address, string subject);

Get the next waiting email with appropriate - address and/or - subject. If the parameters are blank, they - are not used for filtering.


A.87. llGetNotecardLine

key llGetNotecardLine(string name, integer line);

This function fetches line number - line of notecard - name and returns the data through the dataserver event. The line count - starts at zero. If the requested line is past the end of the - notecard the dataserver - event will return the constant EOF string. The key returned by - this function is a unique identifier which will be supplied to the - dataserver event in the - requested parameter.


A.88. llGetNumberOfNotecardLines

key llGetNumberOfNotecardLines(string name);

This function reads the number of lines in notecard name - and returns this information through the dataserver event. - The key returned by this function is a unique identifier which will be supplied to the - dataserver event in the requested - parameter. You will need to cast the returned string to an integer.


A.89. llGetNumberOfPrims

integer llGetNumberOfPrims(void);

Returns the number of prims in the linked set the script is attached to.


A.90. llGetNumberOfSides

key llGetNumberOfSides(void);

Returns the number of sides of the current which has the - script.


A.91. llGetObjectDesc

string llGetObjectDesc(void);

Returns the description of the object which has the script.


A.92. llGetObjectName

string llGetObjectName(void);

Returns the name of the object which has the script.


A.93. llGetObjectPermMask

integer llGetObjectPermMask(integer mask);

Returns the requested permission mask for the root object the - task is attached to. See Permission Mask Constants - for more information. Example usage: -


integer ObjectPerms = llGetObjectPermMask(MASK_NEXT);
-if (ObjectPerms & PERM_COPY)
-{
-	llSay(0, "The next owner may copy this item");
-}
-


A.94. llGetOmega

vector llGetOmega(void);

Returns the omega.


A.95. llGetOwner

key llGetOwner(void);

Returns the owner of the object.


A.96. llGetOwnerKey

key llGetOwnerKey(key id);

Returns the owner of object - id.


A.97. llGetPermissions

integer llGetPermissions(void);

Returns what permissions have been enabled. eg: -


integer perm = llGetPermissions();
-if((perm & PERMISSION_DEBIT) == PERMISSION_DEBIT)
-{
-    // code goes here
-}
-


A.98. llGetPermissionsKey

key llGetPermissionsKey(void);

Returns avatar that has enabled permissions. Returns NULL_KEY if not enabled.


A.99. llGetPos

vector llGetPos(void);

Returns the position.


A.100. llGetPrimitiveParams

list llGetPrimitiveParams(list parameters);

Get primitive parameters specified in parameters. The - parameters are identical to the rules of llSetPrimitiveParams, and the returned list is ordered as such. Most requested parameters do not require a value to be associated, except for texture-related requests (PRIM_TEXTURE, PRIM_COLOR, and PRIM_BUMP_SHINY) which require a side number to be specified as well. - - Valid parameters can be found in the Primitive Constants. - Here is a simple example: -


llGetPrimitiveParams([PRIM_TYPE, PRIM_MATERIAL, PRIM_COLOR, ALL_SIDES, PRIM_POSITION]);
-

- This would return a list similar to this: -


    [PRIM_TYPE_BOX, PRIM_HOLE_DEFAULT, <0, 1, 0>, 0.0, <0, 0, 0>, <1, 1, 0>, <0, 0, 0>, // PRIM_TYPE
-     PRIM_MATERIAL_WOOD, 	// PRIM_MATERIAL
-     0, <1, 1, 1>, 1.0, 	// PRIM_COLOR (ALL_SIDES specified, so all 6 sides returned)
-     1, <1, 0, 0>, 0.5,
-     2, <0, 0, 1>, 1.0,
-     3, <0, 1, 0>, 1.0,
-     4, <0, 0, 0>, 0.5,
-     5, <1, 1, 1>, 1.0,
-     <37.341, 195.283, 31.239>]	// PRIM_POSITION
-


A.101. llGetRegionCorner

llGetRegionCorner(void);

Returns a vector with the south west corner position of the - current region.


A.102. llGetRegionFPS

llGetRegionFPS(void);

Returns the mean region frames per second.


A.103. llGetRegionName

string llGetRegionName(void);

Returns the current region name.


A.104. llGetRegionTimeDilation

float llGetRegionTimeDilation(void);

Returns the current time dilation as a float between 0 and 1.


A.105. llGetRootPosition

vector llGetRootPosition(void);

Returns the global position of the root object of the object the script is attached to.


A.106. llGetRootRotation

rotation llGetRootRotation(void);

Returns the global rotation of the root object of the object the script is attached to.


A.107. llGetRot

rotation llGetRot(void);

Returns the rotation.


A.108. llGetScale

vector llGetScale(void);

Returns the scale.


A.109. llGetScriptName

string llGetScriptName(void);

Returns the name of this script.


A.110. llGetStartParameter

integer llGetStartParameter(void);

Returns the start parameter passed to llRezObject or llRezAtRoot. If the object was - created from agent inventory, this function returns 0.


A.111. llGetScriptState

integer llGetScriptState(string name);

Resets TRUE if script name is running


A.112. llGetStatus

integer llGetStatus(integer status);

Returns the value of status. The - value will be one of the status - constants.


A.113. llGetSubString

string llGetSubString(string src, integer start, integer end);

Returns the indicated substring from - src. The start and - end are inclusive, so 0,length-1 would - capture the entire string and 0,0 would capture the first - character. Using negative numbers for start - and/or end causes the index to count - backwards from the length of the string, so 0,-1 would capture the - entire string. If start is larger than end the sub string is the - exclusion of the entries, so 6,4 would give the entire string - except for the 5th character.


A.114. llGetSunDirection

vector llGetSunDirection(void);

Returns the sun direction on the simulator.


A.115. llGetTexture

string llGetTexture(integer face);

Returns the texture of face if it is - found in object inventory.


A.116. llGetTextureOffset

vector llGetTextureOffset(integer side);

Returns the texture offset of side in - the x and y components of a vector.


A.117. llGetTextureRot

float llGetTextureRot(integer side);

Returns the texture rotation of - side.


A.118. llGetTextureScale

vector llGetTextureScale(integer side);

Returns the texture scale of side in - the x and y components of a vector.


A.119. llGetTime

float llGetTime(void);

Returns the seconds of elapsed time from an internal timer - associated with the script. The timer is reset on rez, simulator - restart, script reset, and in calls to llGetAndResetTime or llResetTime. Use llSetTimerEvent if you want a - reliable timing mechanism.


A.120. llGetTimeOfDay

float llGetTimeOfDay(void);

Gets the time in seconds since midnight in Second Life.


A.121. llGetTimestamp

string llGetTimestamp(void);

Returns a timestamp in the format: YYYY-MM-DDThh:mm:ss.ff..fZ.


A.122. llGetTorque

vector llGetTorque(void);

Returns the torque if the script is physical.


A.123. llGetVel

vector llGetVel();

Returns the velocity.


A.124. llGetWallclock

float llGetWallclock(void);

Returns the time in seconds since simulator timezone - midnight. Currently this is PST.


A.125. llGiveInventory

llGiveInventory(key destination, string inventory);

Give the named inventory item to the keyed avatar or object - in the same simulator as the giver. If the recipient is an avatar, - the avatar then follows the normal procedure of accepting or - denying the offer. If the recipient is an object, the same - permissions apply as if you were dragging inventory onto the - object by hand, ie if llAllowInventoryDrop has - been called with TRUE, any other object can pass objects to its - inventory.


A.126. llGiveInventoryList

llGiveInventoryList(key destination, string category, list inventory);

Give the list of named inventory items to the keyed avatar - or object in the same simulator as the giver. If the recipient is - an avatar, the avatar then follows the normal procedure of - accepting or denying the offer. The offered inventory is then - placed in a folder named category in the - recipients inventory. If the recipient is an object, the same - permissions apply as if you were dragging inventory onto the - object by hand, ie if llAllowInventoryDrop has - been called with TRUE, any other object can pass objects to its - inventory.If the recipient is an object, the - category parameter is ignored.


A.127. llGiveMoney

llGiveMoney(key destination, integer amount);

Transfer amount from the script owner - to destination. This call will fail if - PERMISSION_DEBIT has not - been set.


A.128. llGround

float llGround(vector offset);

Returns the ground height at the object position + - offset.


A.129. llGroundContour

vector llGroundContour(vector offset);

Returns the ground contour at the object position + - offset.


A.130. llGroundNormal

vector llGroundNormal(vector offset);

Returns the ground contour at the object position + - offset.


A.131. llGroundRepel

llGroundRepel(float height, integer water, float tau);

Critically damps to height if within - height * 0.5 of - level. The height - is above ground level if water is FALSE or - above the higher of land and water if water - is TRUE.


A.132. llGroundSlope

vector llGroundSlope(vector offset);

Returns the ground slope at the object position + - offset.


A.133. llInsertString

string llInsertString(string dst, integer position, string src);

Inserts src into - dst at position and - returns the result.


A.134. llInstantMessage

llInstantMessage(key user, string message);

Send message to the - user as an instant message.


A.135. llKey2Name

string llKey2Name(key id);

If object id is in the same - simulator, return the name of the object.


A.136. llList2CSV

string llList2CSV(list src);

Create a string of comma separated values from - list.


A.137. llList2Float

float llList2Float(list src, integer index);

Returns the float at index in the - list src.


A.138. llList2Integer

integer llList2Integer(list src, integer index);

Returns the integer at index in the list - src.


A.139. llList2Key

key llList2Key(list src, integer index);

Returns the key at index in the list - src.


A.140. llList2List

list llList2List(list src, integer start, integer end);

Returns the slice of the list from - start to end from - the list src as a new list. The - start and end - parameters are inclusive, so 0,length-1 would copy the entire list - and 0,0 would capture the first list entry. Using negative numbers - for start and/or end - causes the index to count backwards from the length of the list, - so 0,-1 would capture the entire list. If - start is larger than - end the list returned is the exclusion of - the entries, so 6,4 would give the entire list except for the - 5th entry.


A.141. llList2ListStrided

list llList2ListStrided(list src, integer start, integer end, integer stride);

Copy the strided slice of src from - start to end.


A.142. llList2Rot

rotation llList2Rot(list src, integer index);

Returns the rotation at index in - src.


A.143. llList2String

string llList2String(list src, integer index);

Returns the string at index in - src.


A.144. llList2Vector

llList2Vector(list src, integer index);

Returns the string at index in - src.


A.145. llListFindList

integer llListFindList(list src, list test);

Returns the position of the first instance of - test in src. Returns - -1 if test is not in - src.


A.146. llListInsertList

list llListInsertList(list dest, list src, integer pos);

Returns the list created by inserting - src into dest at - pos.


A.147. llListRandomize

list llListRandomize(list src, integer stride);

Returns src randomized into blocks of - size stride. If the length of - src divided by - stride is non-zero, this function does - not randomize the list.


A.148. llListReplaceList

list llListReplaceList(list dest, list src, integer start, integer end);

Returns the list created by replacing the segment of dest from - start to end with src.


A.149. llListSort

list llListSort(list src, integer stride, integer ascending);

Returns src sorted into blocks of - stride in ascending order if - ascending is TRUE. Note that sort only works in - the head of each sort block is the same type.


A.150. llListen

integer llListen(integer channel, string name, key id, string msg);

Sets a listen event callback for msg - on channel from name - and returns an identifier that can be used to deactivate or remove - the listen. The name, - id and/or msg - parameters can be blank to indicate not to filter on that - argument. Channel 0 is the public chat channel that all avatars - see as chat text. Channels 1 to 2,147,483,648 are hidden channels - that are not sent to avatars.


A.151. llListenControl

llListenControl(integer number, integer active);

Make a listen event callback active or inactive. Pass in the - value returned from llListen - to the number parameter to specify which - event you are controlling. Use boolean values to specify - active.


A.152. llListenRemove

llListenRemove(integer number);

Removes a listen event callback. Pass in the value returned - from llListen to the - number parameter to specify which event you - are removing.


A.153. llLoadURL

llLoadURL(key avatar_id, string message, string url);

Displays a dialog to user avatar_id - with message offering to - go to the web page at url. If the user clicks the - "Go to page" button, their default web browser is launched and - directed to url.

The url must begin with "http:" or - "https:", other protocols are not currently supported. - The dialog box shows the name of the object's - owner so that abuse (e.g. spamming) can be easily reported. - This function has a 10 second implicit sleep.


A.154. llLog

float llLog(float val);

Returns the natural logarithm (base e) of - val if val > 0, - otherwise returns 0.


A.155. llLog10

float llLog10(float val);

Returns the base 10 log of val if - val > 0, otherwise returns 0.


A.156. llLookAt

llLookAt(vector target, float strength, float damping);

Cause object to point the forward axis toward - target. Good - strength values are around half the mass of - the object and good damping values are less - than 1/10th of the - strength. Asymmetrical shapes require - smaller damping. A - strength of 0.0 cancels the look at.


A.157. llLoopSound

llLoopSound(string sound, float volume);

Similar to llPlaySound, this function plays - a sound attached to an object, but will continuously loop that - sound until llStopSound or - llPlaySound is called. Only - one sound may be attached to an object at a time. A second call to - llLoopSound with the same key will not restart the sound, but the - new volume will be used. This allows control over the volume of - already playing sounds. Setting the volume - to 0 is not the same as calling llStopSound; a sound with 0 - volume will continue to loop. To restart the sound from the - beginning, call llStopSound - before calling llLoopSound again.


A.158. llLoopSoundMaster

llLoopSoundMaster(string sound, float volume);

Behaviour is identical to llLoopSound, with the addition of - marking the source as a "Sync Master", causing "Slave" sounds to - sync to it. If there are multiple masters within a viewer's - interest area, the most audible one (a function of both distance - and volume) will win out as the master. The use of multiple - masters within a small area is unlikely to produce the desired - effect.


A.159. llLoopSoundSlave

llLoopSoundSlave(string sound, float volume);

Behaviour is identical to llLoopSound, unless there is a - "Sync Master" present. If a Sync Master is already playing the - Slave sound will begin playing from the same point the master is - in its loop synchronizing the loop points of both sounds. If a - Sync Master is started when the Slave is already playing, the - Slave will skip to the correct position to sync with the - Master.


A.160. llMakeExplosion

llMakeExplosion(integer particles, float scale, float velocity, float lifetime, float arc, string texture, vector offset);

Make a round explosion of particles using - texture from the object's inventory.


A.161. llMakeFire

llMakeFire(integer particles, float scale, float velocity, float lifetime, float arc, string texture, vector offset);

Make fire particles using texture - from the object's inventory.


A.162. llMakeFountain

llMakeFountain(integer particles, float scale, float velocity, float lifetime, float arc, string texture, vector offset);

Make a fountain of particles using - texture from the object's inventory.


A.163. llMakeSmoke

llMakeSmoke(integer particles, float scale, float velocity, float lifetime, float arc, string texture, vector offset);

Make smoky particles using texture - from the object's inventory.


A.164. llMD5String

string llMD5String(string str, integer nonce);

Performs a RSA Data Security, Inc. MD5 Message-Digest - Algorithm on str with - nonce. The function returns the digest as a - 32 character hex string. The digest is computed on the string in - the following format: -


str + ":" + (string)nonce
-

-


A.165. llMessageLinked

llMessageLinked(integer linknum, integer num, string str, key id);

Sends num, - str, and id to - members of the link set. The linknum - parameter is either the linked number available through llGetLinkNumber or a link constant.


A.166. llMinEventDelay

llMinEventDelay(float delay);

Set the minimum time between events being handled.


A.167. llModifyLand

llModifyLand(integer action, integer size);

Modify land with action on - size area. The parameters can be chosen - from the land constants.


A.168. llModPow

integer llModPow(integer a, integer b, integer c);

Raise a to the b power, modulo c. - b is capped at 0xFFFF (16 bits).


A.169. llMoveToTarget

llMoveToTarget(vector target, float tau);

Critically damp to position target in - tau seconds if the script is physical. Good - tau values are greater than 0.2. A - tau of 0.0 stops the critical - damping.


A.170. llOffsetTexture

llOffsetTexture(float offset_s, float offset_t, integer face);

Sets the texture s and t offsets of - face. If face is - ALL_SIDES this - function sets the texture offsets for all faces.


A.171. llOpenRemoteDataChannel

llOpenRemoteDataChannel(void);

Creates a channel to listen for XML-RPC calls. - Will trigger a remote_data event with type = REMOTE_DATA_CHANNEL and a channel id once it is available.


A.172. llOverMyLand

integer llOverMyLand(key id);

Returns TRUE if - id is over land owned by the object owner, - FALSE otherwise.


A.173. llParcelMediaCommandList

llParcelMediaCommandList(list command_list);

Controls the playback of movies and other multimedia resources on a land parcel. - command can be one of - PARCEL_MEDIA_COMMAND_STOP, - PARCEL_MEDIA_COMMAND_PAUSE, - PARCEL_MEDIA_COMMAND_PLAY, - PARCEL_MEDIA_COMMAND_LOOP, - PARCEL_MEDIA_COMMAND_TEXTURE, - PARCEL_MEDIA_COMMAND_URL, - PARCEL_MEDIA_COMMAND_TYPE, - PARCEL_MEDIA_COMMAND_DESC, - PARCEL_MEDIA_COMMAND_SIZE, - PARCEL_MEDIA_COMMAND_TIME, - PARCEL_MEDIA_COMMAND_AGENT, - PARCEL_MEDIA_COMMAND_UNLOAD, or - PARCEL_MEDIA_COMMAND_AUTO_ALIGN. -

You are allowed one movie (or "media" resource) per land parcel. - The movie will be played by replacing a texture on an object with the - movie. Users will only see the movie when they are standing on your - land parcel. Otherwise they will see the static texture.

Most of the QuickTime media formats are supported including: -

  • QuickTime movies (.mov)

  • Streamable stored QuickTime movies (.mov)

  • Real time QuickTime streams (rtsp://)

  • MPEG4 movies (.mp4, .mpeg4) (simple profile only)

  • QuickTime VR scenes and objects (.mov)

  • Flash movies (.swf) (only non-interative, version 5 and earlier

  • and many others from http://www.apple.com/quicktime/products/qt/specifications.html

- A good rule of thumb is if it plays in the QuickTime Media Player, it will play in Second Life. -

You can set up a movie for playback as follows: -

  • First, select a texture from your inventory to be the static texture. It should not be a common texture -- a test pattern would be better than the default plywood.

  • Apply that texture to an object.

  • Right click on your land and select "About Land..."

  • Under "Options" use the GUI to select the static texture.

  • Enter the URL of your movie or media stream.

  • Create objects you want to click on for PLAY, STOP, PAUSE and LOOP (play forever)

  • Attach the following script (or similar) to each.

-


default
-{
-    touch_start ( integer total_number )
-    {
-		// This will play the current movie for all agents in the parcel.
-        llParcelMediaCommandList( [PARCEL_MEDIA_COMMAND_LOOP] );
-    }
-}
-

-Or a more advanced example: -


float START_TIME = 30.0;
-float RUN_LENGTH = 10.0;
-
-default
-{
-	state_entry()
-	{
-		llParcelMediaCommandList( [
-			PARCEL_MEDIA_COMMAND_URL, "http://enter_your.url/here",
-			PARCEL_MEDIA_COMMAND_TEXTURE, (key) llGetTexture(0) ] );
-	}
-
-	touch_start(integer num_detected)
-	{
-		llParcelMediaCommandList( [
-			PARCEL_MEDIA_COMMAND_AGENT, llDetectedKey(0),
-			PARCEL_MEDIA_COMMAND_TIME, START_TIME,
-			PARCEL_MEDIA_COMMAND_PLAY ] );
-		list Info = llParcelMediaQuery([PARCEL_MEDIA_COMMAND_URL, PARCEL_MEDIA_COMMAND_TEXTURE]);
-		llSay(0, "Playing '" + llList2String(Info, 0) + "' on texture '" + (string)llList2Key(Info, 1) + "' for agent " + llDetectedName(0));
-		llSetTimerEvent(RUN_LENGTH);
-	}
-
-	timer()
-	{
-		llParcelMediaCommandList( [ PARCEL_MEDIA_COMMAND_STOP ] );
-		llSetTimerEvent(0.0);
-	}
-}
-

- - -


A.174. llParcelMediaQuery

list llParcelMediaQuery(list query_list);

Controls the playback of movies and other multimedia resources on a land parcel. - command can be one of - PARCEL_MEDIA_COMMAND_TEXTURE or - PARCEL_MEDIA_COMMAND_URL. -

This allows you to query the texture or url for media on the parcel. - See llParcelMediaCommandList for an example - of usage.


A.175. llParseString2List

list llParseString2List(string src, list separators, list spacers);

Breaks src into a list, discarding - anything in separators, keeping any entry - in spacers. The - separators and - spacers must be lists of strings with a - maximum of 8 entries each. So, if you had made the call: -


llParseString2List("Parsethisnow!  I dare:you to.", ["this", "!", " "], [":"]);
-

- You would get the list: -


["Parse", "now", "I", "dare", ":", "you", "to"]
-


A.176. llParseStringKeepNulls

list llParseStringKeepNulls(string src, list separators, list spacers);

Breaks src into a list, discarding - anything in separators, keeping any entry - in spacers. Any resulting null values - are kept. The separators and - spacers must be lists of strings with a - maximum of 8 entries each. So, if you had made the call: -


llParseString2List("!Parsethisthisnow I dare::you to.", ["this", "!", " "], [":"]);
-

- You would get the list: -


[NULL, "Parse", NULL, "now", "I", "dare", ":", NULL, ":", "you", "to"]
-


A.177. llParticleSystem

llParticleSystem(list parameters);

Makes a particle system based on the parameter list. The - parameters are specified as an ordered list - of parameter and value. Valid parameters and their expected values - can be found in the particle system - constants. Here is a simple example: -


llParticleSystem([PSYS_PART_FLAGS, PSYS_PART_WIND_MASK,
-                  PSYS_PART_START_COLOR, <1,0,0>,
-                  PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE]);
-


A.178. llPassCollisions

llPassCollisions(integer pass);

If pass is TRUE, land and object collisions - are passed from children on to parents.


A.179. llPassTouches

llPassTouches(integer pass);

If pass is TRUE, touches are passed from - children on to parents.


A.180. llPlaySound

llPlaySound(string sound, float volume);

Plays a sound once. The sound will be attached to an object - and follow object movement. Only one sound may be attached to an - object at a time, and attaching a new sound or calling llStopSound will stop the - previously attached sound. A second call to llPlaySound with the - same sound will not restart the sound, but - the new volume will be used, which allows control over the volume - of already playing sounds. To restart the sound from the - beginning, call llStopSound - before calling llPlaySound again.


A.181. llPlaySoundSlave

llPlaySoundSlave(string sound, float volume);

Behaviour is identical to llPlaySound, unless there is a - "Sync Master" present. If a Sync Master is already - playing the Slave sound will not be played until the Master hits - its loop point and returns to the beginning. llPlaySoundSlave will - play the sound exactly once; if it is desired to have the sound - play every time the Master loops, either use llLoopSoundSlave with extra - silence padded on the end of the sound or ensure that - llPlaySoundSlave is called at least once per loop of the - Master.


A.182. llPointAt

llPointAt(vector pos);

Make avatar that owns object point at - pos.


A.183. llPow

llPow(float base, float exp);

Returns base raised to the - exp.


A.184. llPreloadSound

llPreloadSound(string sound);

Preloads sound from object inventory - on nearby viewers.


A.185. llPushObject

llPushObject(key id, vector impulse, vector angular_impulse, integer local);

Applies impulse and - angular_impulse to object - id.


A.186. llReleaseControls

llReleaseControls(key avatar);

Stop taking inputs from avatar.


A.187. llRemoteDataReply

llRemoteDataReply(key channel, key message_id, string sdata);

Send an XML-RPC reply to message_id on channel with payload of string sdata.


A.188. llRemoteDataSetRegion

llRemoteDataSetRegion(void);

If an object using remote data channels changes regions, you - must call this function to reregister the remote data - channels. You do not need to make this call if your object does - not change regions or use remote data channels.


A.189. llRemoteLoadScript

llRemoteLoadScript(void);

Deprecated. Please use llRemoteLoadScriptPin instead.


A.190. llRemoteLoadScriptPin

llRemoteLoadScriptPin(key target, string name, integer pin, integer running, integer param);

If the owner of the object this script is attached can modify target, it has the correct pin and the objects are in the same region, copy script name onto target, if running == TRUE, start the script with param. If name already exists on target, it is replaced.


A.191. llRemoveInventory

llRemoveInventory(string inventory);

Remove the name inventory item from - the object inventory.


A.192. llRemoveVehicleFlags

llRemoveVehicleFlags(integer flags);

Sets the vehicle flags to - FALSE. Valid parameters can be found in the vehicle flags constants - section.


A.193. llRequestAgentData

key llRequestAgentData(key id, integer data);

This function requests data about agent - id. If and when the information is - collected, the dataserver - event is called with the returned key returned from this function - passed in the requested parameter. See the - agent data constants for - details about valid values of data and what - each will return in the dataserver event.


A.194. llRequestInventoryData

key llRequestInventoryData(string name);

Requests data from object inventory item - name. When data is available the dataserver event will be raised - with the key returned from this function in the - requested parameter. The only request - currently implemented is to request data from landmarks, where the - data returned is in the form "<float, float, - float>" which can be cast to a vector. This position is in - region local coordinates of the region the script call is made - (possible even resulting in negative values). So, to - convert this value into a global position, just add the result of - llGetRegionCorner.


A.195. llRequestPermissions

integer llRequestPermissions(key avatar, integer perm);

Ask avatar to allow the script to do - perm. The perm - parameter should be a permission - constant. Multiple permissions can be requested - simultaneously by or'ing the constants together. Many of the - permissions requests can only go to object owner. This call will - not stop script execution - if the specified avatar grants the - requested permissions, the run_time_permissions - event will be called.


A.196. llRequestSimulatorData

key llRequestSimulatorData(string sim_name, integer data);

This function requests data about simulator - sim_name. When the information is - collected, the dataserver - event is called with the returned key returned from this function - passed in the requested parameter. See the - simulator data constants for - details about valid values of data and what - each will return in the dataserver event.


A.197. llResetScript

llResetScript(void);

Resets this script.


A.198. llResetOtherScript

llResetOtherScript(string name);

Resets the script name.


A.199. llResetTime

llResetTime(void);

Sets the internal script timer to zero.


A.200. llRezAtRoot

llRezAtRoot(string inventory, vector pos, vector vel, rotation rot, integer param);

Creates object's inventory object at - position pos with velocity - vel and rotation - rot. The last selected root object's location - in a multi-object selection will be placed at pos. - All other objects in a selection will be created relative to the last - selected root's position, taking rot into account. - The param value - will be available to the newly created object in the on_rez event or through the llGetStartParameter - library function. The vel parameter is - ignored if the rezzed object is not physical.


A.201. llRezObject

llRezObject(string inventory, vector pos, vector vel, rotation rot, integer param);

Creates object's inventory object at - position pos with velocity - vel and rotation - rot. The param value - will be available to the newly created object in the on_rez event or through the llGetStartParameter - library function. The vel parameter is - ignored if the rezzed object is not physical.


A.202. llRot2Angle

float llRot2Angle(rotation rot);

Returns the rotation angle represented by - rot.


A.203. llRot2Axis

vector llRot2Axis(rotation rot);

Returns the rotation axis represented by - rot.


A.204. llRot2Euler

vector llRot2Euler(rotation rot);

Returns the Euler Angle representation of - rot.


A.205. llRot2Fwd

vector llRot2Fwd(rotation rot);

Returns the forward axis represented by - rot.


A.206. llRot2Left

llRot2Left(rotation rot);

Returns the left axis represented by - rot.


A.207. llRot2Up

llRot2Up(rotation rot);

Returns the up axis represented by - rot.


A.208. llRotBetween

rotation llRotBetween(vector a, vector b);

Returns the rotation needed to rotate - a to b.


A.209. llRotLookAt

llRotLookAt(rotation rot, float strength, float damping);

Cause object to rotate to rot. Good - strength values are around half the mass of - the object and good damping values are less - than 1/10th of the - strength. Asymmetrical shapes require - smaller damping. A - strength of 0.0 cancels the look at.


A.210. llRotTarget

integer llRotTarget(rotation rot, float error);

Set object rotation within error of - rotation as a rotational target and return - an integer number for the target. The number can be used in llRotTargetRemove.


A.211. llRotTargetRemove

llRotTargetRemove(integer number);

Remove rotational target - number.


A.212. llRotateTexture

llRotateTexture(float radians, integer face);

Sets the texture rotation of face to - radians. If face - ALL_SIDES, rotate the - texture of all faces.


A.213. llRound

integer llRound(float val);

returns val rounded to the nearest - integer.


A.214. llSameGroup

integer llSameGroup(key id);

Returns TRUE if the - object or agent id is in the same simulator - and has the same active group as this object. Otherwise, returns - FALSE.


A.215. llSay

llSay(integer channel, string text);

Say text on - channel. Channel 0 is the public chat - channel that all avatars see as chat text. Channels 1 to - 2,147,483,648 are private channels that are not sent to avatars - but other scripts can listen for through the llListen api.


A.216. llScaleTexture

llScaleTexture(integer scale_s, integer scale_t, integer face);

Sets the texture s and t scales of - face to scale_s and - scale_t respectively. If face is ALL_SIDES, scale the texture - to all faces.


A.217. llScriptDanger

integer llScriptDanger(vector pos);

Returns true if pos is over public land, land that doesn't allow everyone to edit and build, or land that doesn't allow outside scripts.


A.218. llSendRemoteData

key llSendRemoteData(string dest, integer idata, string sdata);

Send an XML-RPC request to dest through channel with payload - of channel (in a string), integer idata and string sdata. An - XML-RPC reply will trigger a remote_data event with type = - REMOTE_DATA_REPLY. The call returns a message_id that can be used - to identify XML-RPC replies.


A.219. llSensor

llSensor(string name, key id, integer type, float range, float arc);

Performs a single scan for name and - id with type within - range meters and arc - radians of forward vector. Specifying a blank name or NULL_KEY id will not filter results for - any particular name or id. A range of 0.0 does not perform a - scan. Range is limited to 96.0. The type parameter should be an object type constant value. If anything is found - during the scan, a sensor event is triggered. A maximum - of 16 items are passed to this event. If nothing is found during the scan, a - no sensor event is triggered instead.


A.220. llSensorRemove

llSensorRemove(void);

Removes the sensor.


A.221. llSensorRepeat

llSensorRepeat(string name, key id, integer type, float range, float arc, float rate);

Performs a single scan for name and - id with type within - range meters and arc - radians of forward vector and repeats every - rate seconds. Specifying a blank name or - NULL_KEY id will not filter - results for any particular name or id. A range of 0.0 cancels the - scan. Range is limited to 96.0. The type parameter should be an object type constant - value. If anything is found during the scan, a sensor - event is triggered. A maximum of 16 items are passed to this event. If nothing is found - during the scan, a no sensor event is triggered instead.


A.222. llSetAlpha

llSetAlpha(float alpha, integer face);

Sets the alpha value for face. If - face is ALL_SIDES, set - the alpha to all faces. The alpha value is - interpreted as an opacity percentage - 1.0 is fully opaque, and - 0.2 is mostly transparent. This api will clamp - alpha values less 0.1 to .1 and greater - than 1.0 to 1.


A.223. llSetBuoyancy

llSetBuoyancy(float buoyancy);

Set the object buoyancy. A value of 0 is none, less than 1.0 sinks, - 1.0 floats, and greater than 1.0 rises.


A.224. llSetCameraAtOffset

llSetCameraAtOffset(vector offset);

Sets the camera at offset used in this object if an avatar - sits on it.


A.225. llSetClickAction

llSetClickAction(integer action);

Sets which action is invoked when a resident clicks a prim.


A.226. llForceMouselook

llForceMouselook(integer mouselook);

Puts the camera into mouselook mode if an avatar - sits on this object.


A.227. llSetCameraEyeOffset

llSetCameraEyeOffset(vector offset);

Sets the camera eye offset used in this object if an avatar - sits on it.


A.228. llSetColor

llSetColor(vector color, integer face);

Sets the color of - face. If face is ALL_SIDES, set the alpha to - all faces.


A.229. llSetDamage

llSetDamage(float damage);

Sets the amount of damage that will be done to an object - that this object hits. This object will be destroyed on damaging - another object.


A.230. llSetForce

llSetForce(vector force, integer local);

If the object is physical, this function sets the - force. The vector is in local coordinates if - local is TRUE, global if - FALSE.


A.231. llSetForceAndTorque

llSetForceAndTorque(vector force, vector torque, integer local);

If the object is physical, this function sets the - force and - torque. The vectors are in local coordinates - if local is TRUE, global if - FALSE.


A.232. llSetHoverHeight

llSetHoverHeight(float height, float water, float tau);

Critically damps to a height. The height is above ground and - water if water is TRUE.


A.233. llSetLinkAlpha

llSetLinkAlpha(integer linknumber, float alpha, integer face);

Sets the alpha of a prim in the link set. - The linknum - parameter is either the linked number available through llGetLinkNumber or a link constant. - If face is - ALL_SIDES, set the alpha - of all faces.


A.234. llSetLinkColor

llSetLinkColor(integer linknumber, vector color, integer face);

Sets the color of a prim in the link set. - The linknum - parameter is either the linked number available through llGetLinkNumber or a link constant. - If face is - ALL_SIDES, set the color - of all faces.


A.235. llSetLinkPrimitiveParams

llSetLinkPrimitiveParams(integer linknumber, list rules);

Sets the primitive parameters of a prim in the link set. - The linknum - parameter is either the linked number available through llGetLinkNumber or a link constant. - The rules - list is identical to that of - llSetPrimitiveParams.


A.236. llSetLinkTexture

llSetLinkTexture(integer linknumber, string texture, integer face);

Sets the texture of a prim in the link set. - The linknum - parameter is either the linked number available through llGetLinkNumber or a link constant. - If face is - ALL_SIDES, set the texture - of all faces.


A.237. llSetLocalRot

llSetLocalRot(rotation rot);

If the object is not physical, this function sets the - rotation of a child prim relative to the root prim, and the - linked set is adjusted.


A.238. llSetObjectDesc

llSetObjectDesc(string description);

Sets the object description to description.


A.239. llSetObjectName

llSetObjectName(string name);

Sets the object name to name.


A.240. llSetParcelMusicURL

llSetParcelMusicURL(string url);

Sets the streaming audio URL for the parcel where the object - is currently located. The url must be an - http streaming source of mp3 or ogg data.


A.241. llSetPayPrice

llSetPayPrice(integer default_price, list quick_pay_buttons);

Sets the default pay price and optionally the quick pay buttons - for the 'Pay' window when someone pays this object. - See also Pay Button Constants.


A.242. llSetPos

llSetPos(vector pos);

If the object is not physical, this function sets the - position in region coordinates. If the object is a child, the - position is treated as root relative and the linked set is - adjusted.


A.243. llSetPrimitiveParams

llSetPrimitiveParams(list rules);

Set primitive parameters based on rules. The - rules are specified as an ordered list - of parameter and value(s). Valid parameters and their expected values - can be found in the Primitive Constants. - Here is a simple example: -


llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_DEFAULT, <0,1,0>,
-                  0.5, <-0.2, 0.2, 0>, <0.5,0.5,0>,<-0.5,0.5,0>]);
-


A.244. llSetRemoteScriptAccessPin

llSetRemoteScriptAccessPin(integer pin);

If pin is set to a non-zero number, the task will accept remote script - loads via llRemoteLoadScriptPin if it passes in the correct pin. - Otherwise, llRemoteLoadScriptPin is ignored.


A.245. llSetRot

llSetRot(rotation rot);

If the object is not physical, this function sets the - rotation. If the object is a child, the position is treated as - root relative and the linked set is adjusted.


A.246. llSetScale

llSetScale(vector scale);

Sets the object scale.


A.247. llSetScriptState

llSetScriptState(string name, integer run);

Control the state of a script on the object.


A.248. llSetSitText

llSetSitText(string text);

Displays text rather than 'sit' in - viewer pie menu.


A.249. llSetSoundQueueing

llSetSoundQueueing(integer queue);

Sets whether successive calls to llPlaySound, llLoopSound, etc., (attached - sounds) interrupt the playing sound. The default for objects is - FALSE. Setting this value to - TRUE will make the sound wait - until the current playing sound reaches its end. The queue is one - level deep.


A.250. llSetStatus

llSetStatus(integer status, integer value);

Sets the status to - value. Use status constants for the values of - status.


A.251. llSetText

llSetText(string text, vector color, float alpha);

Sets text that floats above object to - text, using the specified - color and - alpha.


A.252. llSetTexture

llSetTexture(string texture, integer face);

Sets the texture from object - inventory of face. If face is ALL_SIDES, set the texture to - all faces.


A.253. llSetTextureAnim

llSetTextureAnim(integer mode, integer face, integer sizex, integer sizey, float start, float length, float rate);

Animates a texture by setting the texture scale and - offset. The mode is a mask of texture animation - constants. You can only have one texture animation on an - object, calling llSetTextureAnim more than once on an object will - reset it.

You can only do one traditional animation, ROTATE or SCALE at a time, you - cannot combine masks. In the case of ROTATE or SCALE, - sizex and sizey are - ignored, and start and - length are used as the start and length - values of the animation. For rotation, - start and length are - in radians.

The face specified which face to - animate. If face is ALL_SIDES, all textures on the - object are animated.

The sizex and - sizey describe the layout of the frames - within the texture. sizex specifies how - many horizontal frames and sizey is how - many vertical frames.

start is the frame number to begin - the animation on. Frames are numbered from left to right, top to - bottom, starting at 0.

length is the number of frames to - animate. 0 means to animate all frames after the start - frame.

rate is the frame rate to animate - at. 1.0 means 1 frame per second, 10.0 means 10 - frames per second, etc.


A.254. llSetTimerEvent

llSetTimerEvent(float sec);

Sets the timer event to - be triggered every sec seconds. Passing in - 0.0 stops further timer - events.


A.255. llSetTorque

llSetTorque(vector torque, integer local);

If the object is physical, this function sets the - torque. The vector is in local coordinates - if local is TRUE, global if - FALSE.


A.256. llSetTouchText

llSetTouchText(string text);

Displays text in viewer pie menu that - acts as a touch.


A.257. llSetVehicleFlags

llSetVehicleFlags(integer flags);

Sets the vehicle flags to TRUE. Valid - parameters can be found in the vehicle flags constants - section.


A.258. llSetVehicleFloatParam

llSetVehicleFloatParam(integer param_name, float param_value);

Sets the vehicle floating point parameter - param_name to - param_value. Valid parameters and their - expected values can be found in the vehicle parameter - constants section.


A.259. llSetVehicleType

llSetVehicleType(integer type);

Activates the vehicle action and choose vehicle - type. Valid types and an explanation of - their characteristics can be found in the vehicle type constants - section.


A.260. llSetVehicleRotationParam

llSetVehicleRotationParam(integer param_name, rotation param_value);

Sets the vehicle rotation parameter - param_name to - param_value. Valid parameters can be found - in the vehicle parameter - constants section.


A.261. llSetVehicleVectorParam

llSetVehicleVectorParam(integer param_name, vector param_value);

Sets the vehicle vector parameter - param_name to - param_value. Valid parameters can be found - in the vehicle parameter - constants section.


A.262. llShout

llShout(integer channel, string text);

Shout text on - channel. Channel 0 is the public chat - channel that all avatars see as chat text. Channels 1 to - 2,147,483,648 are private channels that are not sent to avatars - but other scripts can listen for through the llListen api.


A.263. llSin

float llSin(float theta);

Returns the sine of theta in - radians.


A.264. llSitTarget

llSitTarget(vector offset, rotation rot);

Set the sit location for this object. If - offset == ZERO_VECTOR - clear the sit target.


A.265. llSleep

llSleep(float sec);

Puts the script to sleep for sec - seconds.


A.266. llSqrt

float llSqrt(float val);

Returns the square root of val. If - val is less than 0.0, this function returns - 0.0 and raises a math runtime error.


A.267. llStartAnimation

llStartAnimation(string anim);

This function starts animation anim - for the avatar that owns the object.

Valid strings for anim

hold_R_bazooka, hold_R_handgun, hold_R_rifle

Holds the appropriately shaped weapon in the - right hand. Automatically switches to the aims (below) when - user enters mouse look

aim_R_bazooka, aim_R_handgun, aim_R_rifle

Aims the appropriately shaped weapon along the - direction the avatar is looking.

away

Flops over in "away from keyboard" - state.

backflip

Performs a backflip.

bow

Bows at waist.

brush

Brushes dirt from shirt.

clap

Applauds.

courtbow

Bows with a courtly flourish.

crouch

Crouches in place.

crouchwalk

Walks in place while crouching.

dance1, dance2, dance3, dance4, dance5, dance6, dance7, dance8

Various dance maneuvers.

falldown

Freefall falling animation.

female_walk

Walks with hip sway.

fly

Flies forward.

flyslow

Flies forward at a less aggressive - angle.

hello

Waves.

hold_throw_R

Hold object in right hand, prepared to throw - it.

hover

Hovers in place.

hover_down

Pretends to hover straight - down.

hover_up

Pretends to hover straight - up.

jump

Midair jump position.

kick_roundhouse_R

Roundhouse kick with right - leg.

land

Lands after flying.

prejump

Prepares to jump.

punch_L

Punch with left hand.

punch_R

Punch with right hand.

punch_onetwo

Punch with one hand then the - other.

run

Runs in place.

salute

Salutes with right hand.

sit

Sits on object at knee - height.

sit_ground

Sits down on ground.

slowwalk

Walks in place slowly.

smoke_idle

Leans on imaginary prop while holding - cigarette.

smoke_inhale

Leans on imaginary prop and smokes a - cigarette.

smoke_throw_down

Leans on imaginary prop, throws down a - cigarette, and stamps it out.

snapshot

Pantomimes taking a picture.

soft_land

Stumbles a bit as if - landing.

stand

Stands in place.

standup

Falls on face and stands up.

stride

Legs extended as if stepping off of a - ledge.

sword_strike_R

Strike with sword in right - hand.

talk

Head moves as if talking.

throw_R

Throws object in right hand.

tryon_shirt

Turns around and models a new - shirt.

turnleft

Pretends to turn left.

turnright

Pretends to turn right.

type

Makes typing motion.

uphillwalk

Walks uphill in place.

walk

Walks in place.

whisper

Whispers behind hand.

whistle

Whistles with hands in - mouth.

yell

Shouts between cupped hands.


A.268. llStopAnimation

llStopAnimation(string anim);

Stop animation anim for avatar that - owns object.


A.269. llStopHover

llStopHover(void);

Stop hover to a height.


A.270. llStopLookAt

llStopLookAt(void);

Stop causing object to look at target.


A.271. llStopMoveToTarget

llStopMoveToTarget(void);

Stops critically damped motion.


A.272. llStopPointAt

llStopPointAt(void);

Stop avatar that owns object pointing.


A.273. llStopSound

llStopSound(void);

Stops a currently playing attached sound started with llPlaySound or llLoopSound. Has no effect on - sounds started with llTriggerSound.


A.274. llStringLength

integer llStringLength(string src);

Returns the number of characters in - src.


A.275. llSubStringIndex

integer llSubStringIndex(string source, string pattern);

Finds index in source where pattern first appears. Returns - -1 if no match is found.


A.276. llStringToBase64

string llStringToBase64(string str);

Converts a string to the Base 64 representation of the string.


A.277. llTakeControls

llTakeControls(integer controls, integer accept, integer pass_on);

If (accept == - (controls & input)), send input to - object. If the boolean pass_on is TRUE, also send input to - avatar.


A.278. llTan

float llTan(float theta);

Returns the tangent of theta - radians.


A.279. llTarget

integer llTarget(vector position, float range);

Set object position within range of - position as a target and returns an integer - ID for the target.


A.280. llTargetOmega

llTargetOmega(vector axis, float spinrate, float gain);

Attempt to spin at spinrate with - strength gain on - axis. A spinrate of - 0.0 cancels the spin. This function works in object local - coordinates for child objects and works in world coordinates for - root objects.


A.281. llTargetRemove

llTargetRemove(integer tnumber);

Remove target number tnumber.


A.282. llTeleportAgentHome

llTeleportAgentHome(key id);

Teleport agent on the owner's land to agent's home - location.


A.283. llToLower

llToLower();


A.284. llToUpper

string llToUpper(string src);

Returns src in all lower case.


A.285. llTriggerSound

llTriggerSound(string sound, float volume);

Plays a transient sound NOT attached to an object. The sound - plays from a stationary position located at the center of the - object at the time of the trigger. There is no limit to the number - of triggered sounds which can be generated by an object, and - calling llTriggerSound - does not affect the attached sounds created by llPlaySound and llLoopSound. This is very useful - for things like collision noises, explosions, etc. There is no - way to stop or alter the volume of a sound triggered by - this function.


A.286. llTriggerSoundLimited

llTriggerSoundLimited(string sound, float volume, vector tne, vector bsw);

Plays a transient sound NOT attached to an object with its - audible range limited by the axis aligned bounding box define by - tne (top-north-eash) and - bsw (bottom-south-west). The sound plays - from a stationary position located at the center of the object at - the time of the trigger. There is no limit to the number of - triggered sounds which can be generated by an object, and calling - llTriggerSound does not - affect the attached sounds created by llPlaySound and llLoopSound. This is very useful - for things like collision noises, explosions, etc. There is no way - to stop or alter the volume of a sound triggered by this - function.


A.287. llUnescapeURL

string llUnescapeURL(string url);

Returns the string that is the URL unescaped version of url, - replacing %20 with spaces etc.


A.288. llUnSit

llUnSit(key id);

If agent identified by id is sitting - on the object the script is attached to or is over land owned by - the objects owner, the agent is forced to stand up.


A.289. llVecDist

float llVecDist(vector a, vector b);

Returns the distance from a to - b


A.290. llVecMag

float llVecMag(vector vec);

Returns the magnitude of vec.


A.291. llVecNorm

vector llVecNorm(vector vec);

Returns normalized vec.


A.292. llVolumeDetect

llVolumeDetect(integer detect);

When detect = TRUE, this makes the entire link set the script is attached to phantom but if another object interpenetrates it, it will get a collision_start event. When an object stops interpenetrating, a collision_end event is generated. While the other is interpenetrating, collision events are NOT generated. The script must be applied to the root object of the link set to get the collision events. Collision filters work normally.


A.293. llWater

float llWater(vector offset);

Returns the water height at the object position + - offset.


A.294. llWhisper

llWhisper(integer channel, string text);

Whisper text on - channel. Channel 0 is the public chat - channel that all avatars see as chat text. Channels 1 to - 2,147,483,648 are private channels that are not sent to avatars - but other scripts can listen for through the llListen api.


A.295. llWind

vector llWind(vector offset);

Returns the wind velocity below the object position + - offset.


A.296. llXorBase64Strings

string llXorBase64Strings(string s1, string s2);

Performs an exclusive or on two Base 64 strings and returns - a Base 64 string. The s2 parameter repeats if - it is shorter than s1.


Appendix B. Events

Every state must have at least one handler. You can choose to - handle an event by defining one of the reserved event - handlers named here.


B.1. at_rot_target

at_rot_target(integer number, rotation target_rotation, rotation our_rotation);

This event is triggered when a script comes within a defined - angle of a target rotation. The range is set by a call to llRotTarget.


B.2. at_target

not_at_target(integer number, vector target_position, vector our_position);

This event is triggered when a script comes within a defined - range from a target position. The range and position are set by a - call to llTarget.


B.3. attach

attach(key attached);

This event is triggered whenever a object with this script - is attached or detached from an avatar. If it is attached, - attached is the key of the avatar it is attached to, otherwise - attached is NULL_KEY.


B.4. changed

changed(integer changed);

Triggered when various events change the object. The - changed will be a bitfield of change constants.


B.5. collision

collision(integer total_number);

This event is raised while another object is colliding with - the object the script is attached to. The number of detected - objects is passed to the script. Information on those objects may - be gathered via the llDetected* library - functions. (Collisions are also generated if a user walks into an - object.)


B.6. collision_end

collision_end(integer total_number);

This event is raised when another object stops colliding - with the object the script is attached to. The number of detected - objects is passed to the script. Information on those objects may - be gathered via the llDetected* library - functions. (Collisions are also generated if a user walks into an - object.)


B.7. collision_start

collision_start(integer total_number);

This event is raised when another object begins to collide - with the object the script is attached to. The number of detected - objects is passed to the script. Information on those objects may - be gathered via the llDetected* library - functions. (Collisions are also generated if a user walks into an - object.)


B.8. control

control(key name, integer levels, integer edges);

Once a script has the ability to grab control inputs from - the avatar, this event will be used to pass the commands into the - script. The levels and - edges are bitfields of control constants.


B.9. dataserver

dataserver(key requested, string data);

This event is triggered when the requested data is returned - to the script. Data may be requested by the llRequestAgentData, the llRequestSimulatorData, the - llRequestInventoryData, - and the llGetNotecardLine function - calls.


B.10. email

email(string time, string address, string subject, string body, integer remaining);

This event is triggered when an email sent to this script - arrives. The remaining tells how many more - emails are known as still pending.


B.11. land_collision

land_collision(vector position);

This event is raised when the object the script is attached - to is colliding with the ground.


B.12. land_collision_end

land_collision_end(vector position);

This event is raised when the object the script is attached - to stops colliding with the ground.


B.13. land_collision_start

land_collision_start(vector position);

This event is raised when the object the script is attached - to begins to collide with the ground.


B.14. link_message

link_message(integer sender_number, integer number, string message, key id);

Triggered when object receives a link message via llMessageLinked library - function call.


B.15. listen

listen(integer channel, string name, key id, string message);

This event is raised whenever a chat message matching the - constraints passed in the llListen - command is heard. The name and - id of the speaker as well as the - message are passed in as parameters. - Channel 0 is the public chat channel that all avatars see as chat - text. Channels 1 through 2,147,483,648 are private channels that - are not sent to avatars but other scripts can listen on those - channels.


B.16. money

money(key giver, integer amount);

This event is triggered when user - giver has given an - amount of Linden dollars to the - object.


B.17. moving_end

moving_end(void);

Triggered whenever a object with this script stops - moving.


B.18. moving_start

moving_start(void);

Triggered whenever a object with this script starts - moving.


B.19. no_sensor

no_sensor(void);

This event is raised when sensors are active (via the llSensor library call) but are not - sensing anything.


B.20. not_at_rot_target

not_at_rot_target(void);

When a target is set via the llRotTarget library call, but the - script is outside the specified angle this event is raised.


B.21. not_at_target

not_at_target(void);

When a target is set via the llTarget library call, but the - script is outside the specified range this event is raised.


B.22. object_rez

object_rez(key id);

Triggered when object rezzes another object from its - inventory via the llRezObject api. The - id is the globally unique key for the - object.


B.23. on_rez

on_rez(integer start_param);

Triggered whenever a object is rezzed from inventory or by - another object. The start_param is the - parameter passed in from the call to llRezObject or llRezAtRoot.


B.24. run_time_permissions

run_time_permissions(integer permissions);

Scripts need permission from either the owner or the avatar - they wish to act on before they perform certain functions, such as - debiting money from their owner's account, triggering an animation - on an avatar, or capturing control inputs. The llRequestPermissions - library function is used to request these permissions and the - various permissions integer - constants can be supplied. The integer returned to this - event handler contains the current set of permissions flags, so if - permissions equal 0 then no permissions are - set.


B.25. sensor

sensor(integer total_number);

This event is raised whenever objects matching the - constraints of the llSensor - command are detected. The number of detected objects is passed to - the script in the total_number - parameter. A maximum of 16 objects are passed to this event. - Information on those objects may be gathered via the - llDetected* library - functions.


B.26. state_entry

state_entry(void);

The state_entry event occurs whenever a new state is - entered, including program start, and is always the first event - handled.


B.27. state_exit

state_exit(void);

The state_exit event occurs whenever the state command is - used to transition to another state. It is handled before the new - state's state_entry event.


B.28. timer

timer(void);

This event is raised at regular intervals set by the llSetTimerEvent library - function.


B.29. touch

touch(integer total_number);

This event is raised while a user is touching the object the - script is attached to. The number of touching objects is passed to - the script in the total_number - parameter. Information on those objects may be gathered via the - llDetected* library - functions.


B.30. touch_end

touch_end(integer total_number);

This event is raised when a user stops touching the object - the script is attached to. The number of touching objects is - passed to the script in the total_number - parameter. Information on those objects may be gathered via the - llDetected* library - functions.


B.31. touch_start

touch_start(integer total_number);

This event is raised when a user first touches the object - the script is attached to. The number of touching objects is - passed to the script in the total_number - parameter. Information on those objects may be gathered via the - llDetected* library - functions.


B.32. remote_data

remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval);

This event is raised when a user creates an XML-RPC - channel via llOpenRemoteDataChannel, - a remote XML-RPC server replies to a llSendRemoteData, - or a remote XML-RPC client sends in an XML-RPC request. In the open case, - type = REMOTE_DATA_CHANNEL, channel = NULL_KEY, - message_id = NULL_KEY, sender is an empty string, - ival = 0, and sval is an empty string. In the reply case, - type = REMOTE_DATA_REPLY, channel is set to the channel that the request was sent on, - message_id is set to the id of the message, sender is an empty string, - ival = 0, and sval is a string. In the remote request case, - type = REMOTE_DATA_REQUEST, channel is set to the channel that sent the message, - message_id is set to the id of the message, sender is set by the sender, - ival is an integer, and sval is a string. - parameter.


Appendix C. Constants

To ease scripting, many useful constants are defined by - LSL.


C.1. Boolean Constants

The boolean constants represent the values for TRUE and - FALSE. LSL represents booleans as integer values 1 and 0 - respectively. Since there is no boolean type these constants act - as a scripting aid usually employed for testing variables which - conceptually represent boolean values.

  • TRUE

  • FALSE


C.2. Status Constants

The status constants are used in the llSetStatus and llGetStatus library calls. These - constants can be bitwise or'ed together when calling the library - functions to set the same value to more than one status - flag

Status Constants

STATUS_PHYSICS

Controls whether the object moves - physically. This controls the same flag that the ui checkbox - for 'Physical' controls. The default is FALSE.

STATUS_PHANTOM

Controls whether the object collides or - not. Setting the value to TRUE makes the object non-colliding - with all objects. It is a good idea to use this for most - objects that move or rotate, but are non-physical. It is also - useful for simulating volumetric lighting. The default is - FALSE.

STATUS_ROTATE_X, STATUS_ROTATE_Y, STATUS_ROTATE_Z

Controls whether the object can physically rotate - around the specific axis or not. This flag has no meaning - for non-physical objects. Set the value to FALSE - to disable rotation around that axis. The default is TRUE - for a physical object.

A useful example to think about when visualizing the - effect is a 'sit-and-spin' device. They spin around the Z - axis (up) but not around the X or Y axis.

STATUS_BLOCK_GRAB

Controls whether the object can be grabbed. A - grab is the default action when in third person, and is - available as the 'hand' tool in build mode. This is useful for - physical objects that you don't want other people to be able - to trivially disturb. The default if FALSE

STATUS_SANDBOX

Controls whether the object can cross region - boundaries and move more than 20 meters from its creation - point. The default if FALSE.

STATUS_DIE_AT_EDGE

Controls whether the object is returned to the - owner's inventory if it wanders off the edge of the world. It - is useful to set this status TRUE for things like bullets or - rockets. The default is TRUE


C.3. Object Type Constants

These constants can be combined using the binary '|' - operator and are used in the llSensor and related calls.

Object Type Constants

AGENT

Objects in world that are agents.

ACTIVE

Objects in world that are running a script or - currently physically moving.

PASSIVE

Static in-world objects.

SCRIPTED

Scripted in-world objects.


C.4. Permission Constants

The permission constants are used for passing values to - llRequestPermissions, - determining the value of llGetPermissions, and - explicitly passed to the run_time_permissions - event. For many of the basic library functions to work, a - specific permission must be enabled. The permission constants can - be or'ed together to be used in conjunction.

Permission Constants

PERMISSION_DEBIT

If this permission is enabled, the object can - successfully call llGiveMoney to debit the - owner's account.

PERMISSION_TAKE_CONTROLS

If this permission enabled, the object can - successfully call the llTakeControls library - call.

PERMISSION_REMAP_CONTROLS

(not yet implemented)

PERMISSION_TRIGGER_ANIMATION

If this permission is enabled, the object can - successfully call llStartAnimation for the - avatar that owns this object.

PERMISSION_ATTACH

If this permission is enabled, the object can - successfully call llAttachToAvatar to attach - to the given avatar.

PERMISSION_RELEASE_OWNERSHIP

(not yet implemented)

PERMISSION_CHANGE_LINKS

If this permission is enabled, the object can - successfully call llCreateLink, llBreakLink, and llBreakAllLinks to change - links to other objects.

PERMISSION_CHANGE_JOINTS

(not yet implemented)

PERMISSION_CHANGE_PERMISSIONS

(not yet implemented)


C.5. Inventory Constants

These constants can be used to refer to a specific inventory - type in calls to llGetInventoryNumber and - llGetInventoryName. They - are also returned by llGetInventoryType. -

Inventory Constants

INVENTORY_TEXTURE, INVENTORY_SOUND, INVENTORY_OBJECT, INVENTORY_SCRIPT, INVENTORY_LANDMARK, INVENTORY_CLOTHING, INVENTORY_NOTECARD, INVENTORY_BODYPART, INVENTORY_ANIMATION, INVENTORY_GESTURE, INVENTORY_ALL, INVENTORY_NONE

Each constant refers to the named type of - inventory.


C.6. Pay Price Constants

These constants can be used in llSetPayPrice

Pay Price Constants

PAY_HIDE

Do not show this quick pay button.

PAY_DEFAULT

Use the default value for this quick pay button.


C.7. Attachment Constants

These constants are used to refer to attachment points in - calls to llAttachToAvatar.

Attachment Constants

ATTACH_CHEST

Attach to the avatar chest.

ATTACH_HEAD

Attach to the avatar head.

ATTACH_LSHOULDER

Attach to the avatar left shoulder.

ATTACH_RSHOULDER

Attach to the avatar right shoulder.

ATTACH_LHAND

Attach to the avatar left hand.

ATTACH_RHAND

Attach to the avatar right hand.

ATTACH_LFOOT

Attach to the avatar left foot.

ATTACH_RFOOT

Attach to the avatar right foot.

ATTACH_BACK

Attach to the avatar back.

ATTACH_PELVIS

Attach to the avatar pelvis.

ATTACH_MOUTH

Attach to the avatar mouth.

ATTACH_CHIN

Attach to the avatar chin.

ATTACH_LEAR

Attach to the avatar left ear.

ATTACH_REAR

Attach to the avatar right ear.

ATTACH_LEYE

Attach to the avatar left eye.

ATTACH_REYE

Attach to the avatar right eye.

ATTACH_NOSE

Attach to the avatar nose.

ATTACH_RUARM

Attach to the avatar right upper arm.

ATTACH_RLARM

Attach to the avatar right lower arm.

ATTACH_LUARM

Attach to the avatar left upper arm.

ATTACH_LLARM

Attach to the avatar left lower arm.

ATTACH_RHIP

Attach to the avatar right hip.

ATTACH_RULEG

Attach to the avatar right upper leg.

ATTACH_RLLEG

Attach to the avatar right lower leg.

ATTACH_LHIP

Attach to the avatar left hip.

ATTACH_LULEG

Attach to the avatar lower upper leg.

ATTACH_LLLEG

Attach to the avatar lower left leg.

ATTACH_BELLY

Attach to the avatar belly.

ATTACH_RPEC

Attach to the avatar right pectoral.

ATTACH_LPEC

Attach to the avatar left pectoral.


C.8. Land Constants

These constants are only used in calls to llModifyLand. The constants - are equivalent to the similarly labelled user interface elements - for editing land in the viewer.

Land Constants

LAND_LEVEL

Action to make the land flat and level.

LAND_RAISE

Action to raise the land.

LAND_LOWER

Action to lower the land.

LAND_SMOOTH

Action to smooth the land.

LAND_NOISE

Action to push the land toward a pseudo-random - heightfield.

LAND_REVERT

Action to push the land toward the original - shape from when it was first terraformed.

LAND_SMALL_BRUSH

Use a small brush size.

LAND_MEDIUM_BRUSH

Use a medium brush size.

LAND_LARGE_BRUSH

Use a large brush size.


C.9. Link Constants

These constants are used in calls to llSetLinkColor and llMessageLinked.

Link Constants

LINK_SET

This targets every object in the linked - set.

LINK_ROOT

This targets the root of the linked - set.

LINK_ALL_OTHERS

This targets every object in the linked set - except the object with the script.

LINK_ALL_CHILDREN

This targets every object except the root in - the linked set.

LINK_THIS

This targets the object making the call only. -


C.10. Control Constants

These constants are used in llTakeControls as well as the - control event handler.

Control Constants

CONTROL_FWD

Test for the avatar move forward - control.

CONTROL_BACK

Test for the avatar move back - control.

CONTROL_LEFT

Test for the avatar move left - control.

CONTROL_RIGHT

Test for the avatar move right - control.

CONTROL_ROT_LEFT

Test for the avatar rotate left - control.

CONTROL_ROT_RIGHT

Test for the avatar rotate right - control.

CONTROL_UP

Test for the avatar move up - control.

CONTROL_DOWN

Test for the avatar move down - control.

CONTROL_LBUTTON

Test for the avatar left button - control.

CONTROL_ML_BUTTON

Test for the avatar left button control while - in mouse look.


C.11. Change Constants

These constants are used in the changed event handler.

Change Constants

CHANGED_INVENTORY

The object inventory has changed.

CHANGED_ALLOWED_DROP

The object inventory has changed because an item - was added through the llAllowInventoryDrop - interface.

CHANGED_COLOR

The object color has changed.

CHANGED_SHAPE

The object shape has changed, eg, a box to a - cylinder

CHANGED_SCALE

The object scale has changed.

CHANGED_TEXTURE

The texture offset, scale rotation, or simply - the object texture has changed.

CHANGED_LINK

The object has linked or its links were - broken.

CHANGED_REGION

The object has changed regions.

CHANGED_TELEPORT

The object has been teleported.


C.12. Type Constants

These constants are used to determine the variable type - stored in a heterogeneous list. The value returned from llGetListEntryType can be - used for comparison against these constants.

Type Constants

TYPE_INTEGER

The list entry is an integer.

TYPE_FLOAT

The list entry is a float.

TYPE_STRING

The list entry is a string.

TYPE_KEY

The list entry is a key.

TYPE_VECTOR

The list entry is a vector.

TYPE_ROTATION

The list entry is a rotation.

TYPE_INVALID

The list entry is invalid.


C.13. Agent Info Constants

Each of these constants represents a bit in the integer - returned from the llGetAgentInfo function and can - be used in an expression to determine the specified information - about an agent.

Agent Info Constants

AGENT_FLYING

The agent is flying.

AGENT_ATTACHMENTS

The agent has attachments.

AGENT_SCRIPTED

The agent has scripted attachments.

AGENT_SITTING

The agent is sitting.

AGENT_ON_OBJECT

The agent is sitting on an object.

AGENT_WALKING

The agent is walking.

AGENT_IN_AIR

The agent is in the air.

AGENT_MOUSELOOK

The agent is in mouselook.

AGENT_AWAY

The agent is away (AFK).

AGENT_TYPING

The agent is typing.

AGENT_CROUCHING

The agent is crouching.


C.14. Texture Animation - Constants

These constants are used in the llSetTextureAnim api to - control the animation mode.

Texture Animation Constants

ANIM_ON

Texture animation is on.

LOOP

Loop the texture animation.

REVERSE

Play animation in reverse direction.

PING_PONG

play animation going forwards, then - backwards.

SMOOTH

slide in the X direction, instead of playing - separate frames.

ROTATE

Animate texture rotation.

SCALE

Animate the texture scale.


C.15. Particle System Constants

These constants are used in calls to the llParticleSystem api to - specify parameters.

Particle System Parameters

PSYS_PART_FLAGS

Each particle that is emitted by the particle system - is simulated based on the following flags. To use multiple - flags, bitwise or (|) them together.

PSYS_PART_FLAGS Values

PSYS_PART_INTERP_COLOR_MASK

Interpolate both the color and alpha - from the start value to the end - value.

PSYS_PART_INTERP_SCALE_MASK

Interpolate the particle scale from - the start value to the end value.

PSYS_PART_WIND_MASK

Particles have their velocity damped - towards the wind velocity.

PSYS_PART_BOUNCE_MASK

Particles bounce off of a plane at the - object's Z height.

PSYS_PART_FOLLOW_SRC_MASK

The particle position is relative to - the source object's position.

PSYS_PART_FOLLOW_VELOCITY_MASK

The particle orientation is rotated so - the vertical axis faces towards the particle - velocity.

PSYS_PART_TARGET_POS_MASK

The particle heads towards the - location of the target object as defined by - PSYS_SRC_TARGET_KEY.

PSYS_PART_EMISSIVE_MASK

The particle glows.

PSYS_PART_RANDOM_ACCEL_MASK

(not implemented)

PSYS_PART_RANDOM_VEL_MASK

(not implemented)

PSYS_PART_TRAIL_MASK

(not implemented)

PSYS_SRC_PATTERN

The pattern which is used to generate particles. Use - one of the following values:

PSYS_SRC_PATTERN Values

PSYS_SRC_PATTERN_DROP

Drop particles at the source - position.

PSYS_SRC_PATTERN_EXPLODE

Shoot particles out in all directions, - using the burst parameters.

PSYS_SRC_PATTERN_ANGLE

Shoot particles across a 2 dimensional - area defined by the arc created from - PSYS_SRC_OUTERANGLE. There will be an open area - defined by PSYS_SRC_INNERANGLE within the larger - arc.

PSYS_SRC_PATTERN_ANGLE_CONE

Shoot particles out in a 3 dimensional - cone with an outer arc of PSYS_SRC_OUTERANGLE and an - inner open area defined by - PSYS_SRC_INNERANGLE.

PSYS_PART_START_COLOR

a vector <r,g,b> which determines the starting - color of the object.

PSYS_PART_START_ALPHA

a float which determines the starting alpha of - the object.

PSYS_PART_END_COLOR

a vector <r, g, b> which determines the ending - color of the object.

PSYS_PART_END_ALPHA

a float which determines the ending alpha of - the object.

PSYS_PART_START_SCALE

a vector <sx, sy, z>, which is the starting - size of the particle billboard in meters (z is - ignored).

PSYS_PART_END_SCALE

a vector <sx, sy, z>, which is the ending size - of the particle billboard in meters (z is - ignored).

PSYS_PART_MAX_AGE

age in seconds of a particle at which it - dies.

PSYS_SRC_ACCEL

a vector <x, y, z> which is the acceleration - to apply on particles.

PSYS_SRC_TEXTURE

an asset name for the texture to use for the - particles.

PSYS_SRC_BURST_RATE

how often to release a particle burst (float - seconds).

PSYS_SRC_INNERANGLE

specifies the inner angle of the arc created - by the PSYS_SRC_PATTERN_ANGLE or - PSYS_SRC_PATTERN_ANGLE_CONE source pattern. The area - specified will not have particles in it..

PSYS_SRC_OUTERANGLE

specifies the outer angle of the arc created - by the PSYS_SRC_PATTERN_ANGLE or - PSYS_SRC_PATTERN_ANGLE_CONE source pattern. The area - between the outer and inner angle will be filled with - particles..

PSYS_SRC_BURST_PART_COUNT

how many particles to release in a - burst.

PSYS_SRC_BURST_RADIUS

what distance from the center of the object to - create the particles.

PSYS_SRC_BURST_SPEED_MIN

minimum speed that a particle should be - moving.

PSYS_SRC_BURST_SPEED_MAX

maximum speed that a particle should be - moving.

PSYS_SRC_MAX_AGE

how long this particle system should last, 0.0 - means forever.

PSYS_SRC_TARGET_KEY

the key of a target object to move towards if - PSYS_PART_TARGET_POS_MASK is enabled.

PSYS_SRC_OMEGA

Sets the angular velocity to rotate the axis - that SRC_PATTERN_ANGLE and SRC_PATTERN_ANGLE_CONE - use..


C.16. Agent Data Constants

These constants are used in calls to the llRequestAgentData api to - collect information about an agent which will be provided in the - dataserver event.

Agent Data Constants

DATA_ONLINE

"1" for online "0" for - offline.

DATA_NAME

The name of the agent.

DATA_BORN

The date the agent was born returned in ISO - 8601 format of YYYY-MM-DD.

DATA_RATING

Returns the agent ratings as a comma separated - string of six integers. They are: -

  1. Positive rated behavior

  2. Negative rated behavior

  3. Positive rated appearance

  4. Negative rated appearance

  5. Positive rated building

  6. Negative rated building

-


C.17. Float Constants

LSL provides a small collection of floating point constants - for use in float arithmetic. These constants are usually employed - while performing trigonometric calculations, but are sometimes - useful for other applications such as specifying arc radians to - sensor or particle system functions.

Float Constants

PI

3.14159265 - The radians of a - hemicircle.

TWO_PI

6.28318530 - The radians of a - circle.

PI_BY_TWO

1.57079633 - The radians of a quarter - circle.

DEG_TO_RAD

0.01745329 - Number of radians per degree. - You can use this to convert degrees to radians by multiplying - the degrees by this number.

RAD_TO_DEG

57.2957795 - Number of degrees per radian. You - can use this number to convert radians to degrees by - multiplying the radians by this number.

SQRT2

1.41421356 - The square root of 2.


C.18. Key Constant

There is only one key constant which acts as an invalid - key: NULL_KEY.


C.19. Miscellaneous Integer Constants

There is one uncategorized integer constant which is used in - some of the texturing and coloring api: ALL_SIDES


C.20. Miscellaneous String - Constants

There is one uncategorized string constant - which is used in the dataserver event: - EOF


C.21. Vector Constant

There is only one vector constant which acts as a zero - vector: ZERO_VECTOR = <0,0,0>.


C.22. Rotation Constant

There is only one rotation constant which acts as a zero - rotation: ZERO_ROTATION = <0,0,0,1>.


C.23. Simulator Data Constants

These constants are used in calls to the llRequestSimulatorData api to - collect information about a simulator which will be provided in the - dataserver event.

Simulator Data Constants

DATA_SIM_POS

The global position of the simulator. Cast the - value to a vector.

DATA_SIM_STATUS

The status of the simulator. Currently, this may be one of the following: -

  • up

  • down

  • stopping

  • starting

  • crashed

-


C.24. Vehicle Parameters

Parameters

VEHICLE_LINEAR_FRICTION_TIMESCALE

A vector of timescales for exponential decay of the - vehicle's linear velocity along its preferred axes of motion (at, left, - up). Range = [0.07, inf) seconds for each element of the vector. -

VEHICLE_ANGULAR_FRICTION_TIMESCALE

A vector of timescales for exponential decay of the - vehicle's angular velocity about its preferred axes of motion (at, - left, up). Range = [0.07, inf) seconds for each element of the vector. -

VEHICLE_LINEAR_MOTOR_DIRECTION

The direction and magnitude (in preferred frame) of the - vehicle's linear motor. The vehicle will accelerate (or decelerate if - necessary) to match its velocity to its motor. Range of magnitude = - [0, 30] meters/second. -

VEHICLE_LINEAR_MOTOR_OFFSET

The offset point from the vehicle's center of mass at which - the linear motor's impulse is applied. This allows the linear motor - to also cause rotational torque. Range of magnitude = [0, 100] - meters.

VEHICLE_LINEAR_MOTOR_TIMESCALE

The timescale for exponential approach to full - linear motor velocity.

VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE

The timescale for exponential decay of the linear - motor's magnitude.

VEHICLE_ANGULAR_MOTOR_DIRECTION

The direction and magnitude (in preferred frame) - of the vehicle's angular motor.The vehicle will accelerate (or - decelerate if necessary) to match its velocity to its - motor.

VEHICLE_ANGULAR_MOTOR_TIMESCALE

The timescale for exponential approach to full - angular motor velocity.

VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE

The timescale for exponential decay of the angular - motor's magnitude.

VEHICLE_HOVER_HEIGHT

The height (above the terrain or water, or global) - at which the vehicle will try to hover.

VEHICLE_HOVER_EFFICIENCY

A slider between minimum (0.0 = bouncy) and - maximum (1.0 = fast as possible) damped motion of the hover - behavior.

VEHICLE_HOVER_TIMESCALE

The period of bounce (or timescale of exponential - approach, depending on the hover efficiency) for the vehicle to - hover to the proper height.

VEHICLE_BUOYANCY

A slider between minimum (0.0) and maximum - anti-gravity (1.0).

VEHICLE_LINEAR_DEFLECTION_EFFICIENCY

A slider between minimum (0.0) and maximum (1.0) - deflection of linear velocity. That is, it's a simple scalar for - modulating the strength of linear deflection.

VEHICLE_LINEAR_DEFLECTION_TIMESCALE

The timescale for exponential success of linear - deflection. It is another way to specify how much time - it takes for the vehicle's linear velocity to be redirected to - it's preferred axis of motion.

VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY

A slider between minimum (0.0) and maximum (1.0) - deflection of angular orientation. That is, it's a simple scalar - for modulating the strength of angular deflection such that the - vehicle's preferred axis of motion points toward it's real - velocity.

VEHICLE_ANGULAR_DEFLECTION_TIMESCALE

The timescale for exponential success of angular - deflection. It's another way to specify the strength - of the vehicle's tendency to reorient itself so that it's - preferred axis of motion agrees with it's true - velocity.

VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY

A slider between minimum (0.0 = wobbly) and - maximum (1.0 = firm as possible) stability of the vehicle to keep - itself upright.

VEHICLE_VERTICAL_ATTRACTION_TIMESCALE

The period of wobble, or timescale for exponential - approach, of the vehicle to rotate such that it's preferred - "up" axis is oriented along the world's "up" - axis.

VEHICLE_BANKING_EFFICIENCY

A slider between anti (-1.0), none (0.0), and - maximum (1.0) banking strength.

VEHICLE_BANKING_MIX

A slider between static (0.0) and dynamic (1.0) - banking. "Static" means the banking scales only with the - angle of roll, whereas "dynamic" is a term that also - scales with the vehicle's linear speed.

VEHICLE_BANKING_TIMESCALE

The timescale for banking to exponentially - approach it's maximum effect. This is another way to scale the - strength of the banking effect, however it affects the term that - is proportional to the difference between what the banking - behavior is trying to do, and what the vehicle is actually - doing.

VEHICLE_REFERENCE_FRAME

A rotation of the vehicle's preferred axes of - motion and orientation (at, left, up) with respect to the - vehicle's local frame (x, y, z).


C.25. Vehicle Flags

Flags

VEHICLE_FLAG_NO_DEFLECTION_UP

This flag prevents - linear deflection - parallel to world z-axis. This is useful for preventing ground - vehicles with large linear deflection, like bumper cars, from climbing - their linear deflection into the sky.

VEHICLE_FLAG_LIMIT_ROLL_ONLY

For vehicles with - vertical attractor - that want to be able to climb/dive, for instance, airplanes that want - to use the banking - feature.

VEHICLE_FLAG_HOVER_WATER_ONLY

Ignore terrain height when - hovering.

VEHICLE_FLAG_HOVER_TERRAIN_ONLY

Ignore water height when - hovering.

VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT

Hover at - global height instead of height above ground or water.

VEHICLE_FLAG_HOVER_UP_ONLY

Hover doesn't - push down. Use this flag for hovering - vehicles that should be able to jump above their - hover height. -

VEHICLE_FLAG_LIMIT_MOTOR_UP

Prevents ground vehicles from motoring into the - sky. This flag has a subtle effect when used with conjunction - with banking: the strength - of the banking will decay when the vehicle no longer experiences - collisions. The decay timescale is the same as - VEHICLE_BANKING_TIMESCALE - . This is to help prevent ground vehicles from steering - when they are in mid jump. -

VEHICLE_FLAG_MOUSELOOK_STEER

Steer the vehicle using the mouse. Use this - flag to make the angular motor try to make the vehicle - turn such that its local - x-axis points in the same direction as - the client-side camera.

VEHICLE_FLAG_MOUSELOOK_BANK

Same as above, but relies on - banking. It remaps - left-right motions of the client camera (also known as "yaw") to - rotations about the vehicle's local x-axis. -

VEHICLE_FLAG_CAMERA_DECOUPLED

Makes mouselook camera rotate independently of - the vehicle. By default the client mouselook camera will rotate - about with the vehicle, however when this flag is set the camera - direction is independent of the vehicle's rotation. -


C.26. Vehicle Types

Types

VEHICLE_TYPE_SLED

Simple vehicle that bumps along the ground, and likes to move along - it's local x-axis.


// most friction for left-right, least for up-down
-llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <30, 1, 1000> );
-
-// no angular friction
-llSetVehicleVectorParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, <1000, 1000, 1000> );
-
-// no linear motor
-llSetVehicleVectorParam( VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0> );
-llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_TIMESCALE, 1000 );
-llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 120 );
-
-// no angular motor
-llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 0> );
-llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 1000 );
-llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 120 );
-
-// no hover (but with timescale of 10 sec if enabled)
-llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, 0 );
-llSetVehicleFloatParam( VEHICLE_HOVER_EFFICIENCY, 10 );
-llSetVehicleFloatParam( VEHICLE_HOVER_TIMESCALE, 10 );
-llSetVehicleFloatParam( VEHICLE_BUOYANCY, 0 );
-
-// maximum linear deflection with timescale of 1 second
-llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 1 );
-llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 1 );
-
-// no angular deflection 
-llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0 );
-llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 10 );
-
-// no vertical attractor (doesn't mind flipping over)
-llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 1 );
-llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 1000 );
-
-// no banking
-llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, 0 );
-llSetVehicleFloatParam( VEHICLE_BANKING_MIX, 1 );
-llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, 10 );
-
-// default rotation of local frame
-llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> );
-
-// remove these flags 
-llRemoveVehicleFlags( VEHICLE_FLAG_HOVER_WATER_ONLY 
-                      | VEHICLE_FLAG_HOVER_TERRAIN_ONLY 
-                      | VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT 
-                      | VEHICLE_FLAG_HOVER_UP_ONLY );
-
-// set these flags (the limit_roll flag will have no effect
-// until banking is enabled, if ever)
-llSetVehicleFlags( VEHICLE_FLAG_NO_DEFLECTION_UP 
-                   | VEHICLE_FLAG_LIMIT_ROLL_ONLY
-                   | VEHICLE_FLAG_LIMIT_MOTOR_UP );
-        

VEHICLE_TYPE_CAR

Another vehicle that bounces along the ground but - needs the motors to be driven from external controls or timer events.


// most friction for left-right, least for up-down
-llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <100, 2, 1000> );
-        
-// no angular friction
-llSetVehicleVectorParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, <1000, 1000, 1000> );
-
-// linear motor wins after about a second, decays after about a minute
-llSetVehicleVectorParam( VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0> );
-llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_TIMESCALE, 1 );
-llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 60 );
-
-// angular motor wins after a second, decays in less time than that
-llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 0> );
-llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 1 );
-llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.8 );
-
-// no hover 
-llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, 0 );
-llSetVehicleFloatParam( VEHICLE_HOVER_EFFICIENCY, 0 );
-llSetVehicleFloatParam( VEHICLE_HOVER_TIMESCALE, 1000 );
-llSetVehicleFloatParam( VEHICLE_BUOYANCY, 0 );
-
-// maximum linear deflection with timescale of 2 seconds
-llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 1 );
-llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 2 );
-
-// no angular deflection 
-llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0 );
-llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 10 );
-        
-// critically damped vertical attractor
-llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 1 );
-llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 10 );
-
-// weak negative critically damped banking
-llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, -0.2 );
-llSetVehicleFloatParam( VEHICLE_BANKING_MIX, 1 );
-llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, 1 );
-
-// default rotation of local frame
-llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> );
-
-// remove these flags 
-llRemoveVehicleFlags( VEHICLE_FLAG_HOVER_WATER_ONLY 
-                      | VEHICLE_FLAG_HOVER_TERRAIN_ONLY 
-                      | VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT);
-
-// set these flags 
-llSetVehicleFlags( VEHICLE_FLAG_NO_DEFLECTION_UP 
-                   | VEHICLE_FLAG_LIMIT_ROLL_ONLY 
-                   | VEHICLE_FLAG_HOVER_UP_ONLY
-                   | VEHICLE_FLAG_LIMIT_MOTOR_UP );
-        

VEHICLE_TYPE_BOAT

Hovers over water with lots of friction and some angular deflection.


// least for forward-back, most friction for up-down
-llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <10, 3, 2> );
-        
-// uniform angular friction (setting it as a scalar rather than a vector)
-llSetVehicleFloatParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, 10 );
-
-// linear motor wins after about five seconds, decays after about a minute
-llSetVehicleVectorParam( VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0> );
-llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_TIMESCALE, 5 );
-llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 60 );
-
-// angular motor wins after four seconds, decays in same amount of time
-llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 0> );
-llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 4 );
-llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 4 );
-
-// hover 
-llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, 0 );
-llSetVehicleFloatParam( VEHICLE_HOVER_EFFICIENCY, 0.5 );
-llSetVehicleFloatParam( VEHICLE_HOVER_TIMESCALE, 2.0 );
-llSetVehicleFloatParam( VEHICLE_BUOYANCY, 1 );
-
-// halfway linear deflection with timescale of 3 seconds
-llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.5 );
-llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 3 );
-
-// angular deflection 
-llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.5 );
-llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 5 );
-        
-// somewhat bouncy vertical attractor 
-llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.5 );
-llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 5 );
-
-// weak negative damped banking
-llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, -0.3 );
-llSetVehicleFloatParam( VEHICLE_BANKING_MIX, 0.8 );
-llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, 1 );
-
-// default rotation of local frame
-llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> );
-
-// remove these flags 
-llRemoveVehicleFlags( VEHICLE_FLAG_HOVER_TERRAIN_ONLY 
-                      | VEHICLE_FLAG_LIMIT_ROLL_ONLY 
-                      | VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT);
-
-// set these flags 
-llSetVehicleFlags( VEHICLE_FLAG_NO_DEFLECTION_UP 
-                   | VEHICLE_FLAG_HOVER_WATER_ONLY 
-                   | VEHICLE_FLAG_HOVER_UP_ONLY 
-                   | VEHICLE_FLAG_LIMIT_MOTOR_UP );
-        

VEHICLE_TYPE_AIRPLANE

Uses linear deflection for lift, no hover, and banking to turn.


// very little friction along forward-back axis
-llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <200, 10, 5> );
-        
-// uniform angular friction
-llSetVehicleFloatParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, 20 );
-
-// linear motor
-llSetVehicleVectorParam( VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0> );
-llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_TIMESCALE, 2 );
-llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 60 );
-
-// angular motor
-llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 0> );
-llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 4 );
-llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 8 );
-
-// no hover 
-llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, 0 );
-llSetVehicleFloatParam( VEHICLE_HOVER_EFFICIENCY, 0.5 );
-llSetVehicleFloatParam( VEHICLE_HOVER_TIMESCALE, 1000 );
-llSetVehicleFloatParam( VEHICLE_BUOYANCY, 0 );
-
-// linear deflection 
-llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.5 );
-llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.5 );
-
-// angular deflection 
-llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 1.0 );
-llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 2.0 );
-        
-// vertical attractor
-llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.9 );
-llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 2 );
-
-// banking
-llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, 1 );
-llSetVehicleFloatParam( VEHICLE_BANKING_MIX, 0.7 );
-llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, 2 );
-
-// default rotation of local frame
-llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> );
-
-// remove these flags 
-llRemoveVehicleFlags( VEHICLE_FLAG_NO_DEFLECTION_UP 
-                      | VEHICLE_FLAG_HOVER_WATER_ONLY 
-                      | VEHICLE_FLAG_HOVER_TERRAIN_ONLY 
-                      | VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT 
-                      | VEHICLE_FLAG_HOVER_UP_ONLY
-                      | VEHICLE_FLAG_LIMIT_MOTOR_UP );
-
-// set these flags 
-llSetVehicleFlags( VEHICLE_FLAG_LIMIT_ROLL_ONLY );
-        

VEHICLE_TYPE_BALLOON

Hover, and friction, but no deflection.


// uniform linear friction
-llSetVehicleFloatParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, 5 );
-        
-// uniform angular friction
-llSetVehicleFloatParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, 10 );
-
-// linear motor
-llSetVehicleVectorParam( VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0> );
-llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_TIMESCALE, 5 );
-llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 60 );
-
-// angular motor
-llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 0> );
-llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 6 );
-llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 10 );
-
-// hover 
-llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, 5 );
-llSetVehicleFloatParam( VEHICLE_HOVER_EFFICIENCY, 0.8 );
-llSetVehicleFloatParam( VEHICLE_HOVER_TIMESCALE, 10 );
-llSetVehicleFloatParam( VEHICLE_BUOYANCY, 1 );
-
-// no linear deflection 
-llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0 );
-llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 5 );
-
-// no angular deflection 
-llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0 );
-llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 5 );
-        
-// no vertical attractor 
-llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 1 );
-llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 1000 );
-
-// no banking
-llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, 0 );
-llSetVehicleFloatParam( VEHICLE_BANKING_MIX, 0.7 );
-llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, 5 );
-
-// default rotation of local frame
-llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> );
-
-// remove all flags 
-llRemoveVehicleFlags( VEHICLE_FLAG_NO_DEFLECTION_UP 
-                      | VEHICLE_FLAG_HOVER_WATER_ONLY 
-                      | VEHICLE_FLAG_LIMIT_ROLL_ONLY 
-                      | VEHICLE_FLAG_HOVER_TERRAIN_ONLY 
-                      | VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT 
-                      | VEHICLE_FLAG_HOVER_UP_ONLY 
-                      | VEHICLE_FLAG_LIMIT_MOTOR_UP );
-        


C.27. Primitive Constants

These constants are used in calls to the llSetPrimitiveParams and llGetPrimitiveParams api to - specify parameters.

Primitive Parameters

PRIM_TYPE

This allows the various primitive shape parameters to be controlled. PRIM_TYPE must be followed by - appropriate arguments based on which type is selected.

PRIM_TYPE Values

PRIM_TYPE_BOX

Sets the primitive to a box, followed by integer hole shape, vector cut, float hollow, vector twist, vector top size, and vector top shear.

PRIM_TYPE_CYLINDER

Sets the primitive to a cylinder, followed by integer hole shape, vector cut, float hollow, vector twist, vector top size, and vector top shear.

PRIM_TYPE_PRISM

Sets the primitive to a prism, followed by integer hole shape, vector cut, float hollow, vector twist, vector top size, and vector top shear.

PRIM_TYPE_SPHERE

Sets the primitive to a sphere, followed by integer hole shape, vector cut, float hollow, vector twist, and vector dimple.

PRIM_TYPE_TORUS

Sets the primitive to a torus, followed by integer hole shape, vector cut, float hollow, vector twist, vector hole size, vector top shear, vector advanced cut, vector taper, float revolutions, float radius offset, and float skew.

PRIM_TYPE_TUBE

Sets the primitive to a tube, followed by integer hole shape, vector cut, float hollow, vector twist, vector hole size, vector top shear, vector advanced cut, vector taper, float revolutions, float radius offset, and float skew.

PRIM_TYPE_RING

Sets the primitive to a ring, followed by integer hole shape, vector cut, float hollow, vector twist, vector hole size, vector top shear, vector advanced cut, vector taper, float revolutions, float radius offset, and float skew.

Choose hole shape from one of PRIM_HOLE_DEFAULT, PRIM_HOLE_CIRCLE, PRIM_HOLE_SQUARE, or PRIM_HOLE_TRIANGLE.

PRIM_MATERIAL

Choose material from one of PRIM_MATERIAL_STONE, PRIM_MATERIAL_METAL, PRIM_MATERIAL_GLASS, - PRIM_MATERIAL_WOOD, PRIM_MATERIAL_FLESH, PRIM_MATERIAL_PLASTIC, PRIM_MATERIAL_RUBBER, or PRIM_MATERIAL_LIGHT.

PRIM_PHYSICS

Set physics to TRUE or FALSE.

PRIM_TEMP_ON_REZ

Set temporary on rez to TRUE or FALSE.

PRIM_PHANTOM

Set phantom to TRUE or FALSE.

PRIM_POSITION

Sets the position with a vector.

PRIM_SIZE

Sets the size with a vector.

PRIM_ROTATION

Sets the rotation with a rotation.

PRIM_TEXTURE

Followed by an integer face, key id, vector repeats, vector offsets, and float rotation in radians.

PRIM_COLOR

Followed by an integer face, vector color, and float alpha.

PRIM_BUMP_SHINY

Followed by an integer face, one of PRIM_SHINY_NONE, PRIM_SHINY_LOW, PRIM_SHINY_MEDIUM, or PRIM_SHINY_HIGH, - and one of PRIM_BUMP_NONE, PRIM_BUMP_BRIGHT, PRIM_BUMP_DARK, PRIM_BUMP_WOOD, PRIM_BUMP_BARK, - PRIM_BUMP_BRICKS, PRIM_BUMP_CHECKER, PRIM_BUMP_CONCRETE, PRIM_BUMP_TILE, PRIM_BUMP_STONE, PRIM_BUMP_DISKS, - PRIM_BUMP_GRAVEL, PRIM_BUMP_BLOBS, PRIM_BUMP_SIDING, PRIM_BUMP_LARGETILE, PRIM_BUMP_STUCCO, PRIM_BUMP_SUCTION, - or PRIM_BUMP_WEAVE.

PRIM_GLOW

Followed by an integer face and a float glow value (in range 0.0 to 1.0).


C.28. XML-RPC Constants

These constants are passed to the remote_data event: REMOTE_DATA_CHANNEL, REMOTE_DATA_REQUEST, and REMOTE_DATA_REPLY.


C.29. Permission Mask Constants

These MASK_* constants are used as arguments to llGetObjectPermMask and llGetInventoryPermMask. These functions return combinations of PERM_* constants.

Mask and Permission Constants

MASK_BASE

Specifies base permissions. These permissions are identical to owner permissions except in the case that the object is locked. When an object is locked, owner permissions are stripped of move/modify rights (thus, the 'locking'). On unlock, owner permissions revert back to base permissions.

MASK_OWNER

Specifies owner permissions. These are never more permissive than base permissions.

MASK_GROUP

Specifies group permissions. These are never more permissive than owner permissions.

MASK_EVERYONE

Specifies everyone permissions. These are never more permissive than owner permissions.

MASK_NEXT

Specifies next owner permissions. These are never more permissive than base permissions.

PERM_MOVE

Set if movement is allowed.

PERM_MODIFY

Set if modification is allowed.

PERM_COPY

Set if copying is allowed.

PERM_TRANSFER

Set if transfers are allowed.

PERM_ALL

This is returned if all other PERM_* are set.


C.30. Parcel Media Constants

These constants are passed to the llParcelMediaCommand to control playback of movies and other multimedia within a land parcel.

Parcel Media Constants

PARCEL_MEDIA_COMMAND_STOP

Stop the media stream and go back to the first frame.

PARCEL_MEDIA_COMMAND_PAUSE

Pause the media stream (stop playing but stay on current frame).

PARCEL_MEDIA_COMMAND_PLAY

Start the media stream playing from the current frame and stop when the end is reached.

PARCEL_MEDIA_COMMAND_LOOP_SET

Used to get or set the parcel's media looping variable. -

PARCEL_MEDIA_COMMAND_TEXTURE

Use this to get or set the parcel's media texture. -

PARCEL_MEDIA_COMMAND_URL

Used to get or set the parcel's media url. -

PARCEL_MEDIA_COMMAND_TYPE

Used to get or set the parcel's media mimetype. -

PARCEL_MEDIA_COMMAND_DESC

Used to get or set the parcel's media description. -

PARCEL_MEDIA_COMMAND_SIZE

Used to get or set the parcel's media pixel size. -

PARCEL_MEDIA_COMMAND_TIME

Move a media stream to a specific time. -

PARCEL_MEDIA_COMMAND_AGENT

Applies the media command to the specified agent only. -

PARCEL_MEDIA_COMMAND_UNLOAD

Completely unloads the movie and restores the original texture. -

PARCEL_MEDIA_COMMAND_AUTO_ALIGN

Sets the parcel option 'Auto scale content'. -

PARCEL_MEDIA_COMMAND_LOOP

This command has been depricated in favor of the PARCEL_MEDIA_COMMAND_LOOP_SET above. -


C.31. Click Action Constants

These constants are passed to llSetClickAction to define default behavior when a resident clicks upon a prim.

Click Action Constants

CLICK_ACTION_NONE

Disables the click action for this prim.

CLICK_ACTION_TOUCH

Sets the click-action behavior of this prim to touch.

CLICK_ACTION_SIT

Sets the click-action behavior of this prim to sit.

CLICK_ACTION_BUY

Sets the click-action behavior of this prim to buy.

CLICK_ACTION_PAY

Sets the click-action behavior of this prim to pay.

CLICK_ACTION_OPEN

Sets the click-action behavior of this prim to open.

CLICK_ACTION_PLAY

Sets the click-action behavior of this prim to play.

CLICK_ACTION_OPEN_MEDIA

Sets the click-action behavior of this prim to open-media.

CLICK_ACTION_SIT

Sets the click-action behavior of this prim to sit.

CLICK_ACTION_SIT

Sets the click-action behavior of this prim to sit.

\ No newline at end of file diff --git a/linden/indra/newview/pipeline.cpp b/linden/indra/newview/pipeline.cpp index f232fdf..81f1a90 100644 --- a/linden/indra/newview/pipeline.cpp +++ b/linden/indra/newview/pipeline.cpp @@ -330,8 +330,15 @@ void LLPipeline::init() mRenderDebugFeatureMask = 0xffffffff; // All debugging features on mRenderDebugMask = 0; // All debug starts off + // Don't turn on ground when this is set + // Mac Books with intel 950s need this + if(!gSavedSettings.getBOOL("RenderGround")) + { + toggleRenderType(RENDER_TYPE_GROUND); + } + mOldRenderDebugMask = mRenderDebugMask; - + mBackfaceCull = TRUE; stop_glerror(); @@ -454,7 +461,7 @@ void LLPipeline::resizeScreenTexture() } mScreen.release(); - mScreen.allocate(resX, resY, GL_RGBA, TRUE, GL_TEXTURE_RECTANGLE_ARB); + mScreen.allocate(resX, resY, GL_RGBA, TRUE, LLTexUnit::TT_RECT_TEXTURE); llinfos << "RESIZED SCREEN TEXTURE: " << resX << "x" << resY << llendl; } @@ -556,7 +563,7 @@ void LLPipeline::createGLBuffers() for (U32 j = 0; j < 3; j++) { - glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mBlurCubeTexture[j]); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_CUBE_MAP, mBlurCubeTexture[j]); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -583,10 +590,11 @@ void LLPipeline::createGLBuffers() mGlow[i].allocate(512,glow_res,GL_RGBA,FALSE); } + GLuint resX = gViewerWindow->getWindowDisplayWidth(); GLuint resY = gViewerWindow->getWindowDisplayHeight(); - - mScreen.allocate(resX, resY, GL_RGBA, TRUE, GL_TEXTURE_RECTANGLE_ARB); + + mScreen.allocate(resX, resY, GL_RGBA, TRUE, LLTexUnit::TT_RECT_TEXTURE); } } @@ -1212,7 +1220,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl LLVertexBuffer::unbind(); LLGLDisable blend(GL_BLEND); LLGLDisable test(GL_ALPHA_TEST); - LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.setColorMask(false, false); LLGLDepthTest depth(GL_TRUE, GL_FALSE); @@ -1357,7 +1365,7 @@ void LLPipeline::doOcclusion(LLCamera& camera) } LLGLDisable blend(GL_BLEND); LLGLDisable test(GL_ALPHA_TEST); - LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest depth(GL_TRUE, GL_FALSE); if (LLPipeline::sUseOcclusion > 1) @@ -2368,7 +2376,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) sUnderWaterRender = FALSE; } - LLViewerImage::sDefaultImagep->bind(0); + gGL.getTexUnit(0)->bind(LLViewerImage::sDefaultImagep); LLViewerImage::sDefaultImagep->setClamp(FALSE, FALSE); ////////////////////////////////////////////// @@ -2604,11 +2612,11 @@ void LLPipeline::renderDebug() // Debug composition layers F32 x, y; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); if (gAgent.getRegion()) { - gGL.begin(LLVertexBuffer::POINTS); + gGL.begin(LLRender::POINTS); // Draw the composition layer for the region that I'm in. for (x = 0; x <= 260; x++) { @@ -2654,6 +2662,7 @@ void LLPipeline::renderForSelect(std::set& objects, BOOL render LLGLSDefault gls_default; LLGLSObjectSelect gls_object_select; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest gls_depth(GL_TRUE,GL_TRUE); disableLights(); @@ -2665,6 +2674,18 @@ void LLPipeline::renderForSelect(std::set& objects, BOOL render 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; @@ -3089,7 +3110,7 @@ void LLPipeline::setupAvatarLights(BOOL for_edit) camera_rot.invert(); LLVector4 light_pos = light_pos_cam * camera_rot; - light_pos.normVec(); + light_pos.normalize(); mHWLightColors[1] = diffuse; glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse.mV); @@ -3107,7 +3128,7 @@ void LLPipeline::setupAvatarLights(BOOL for_edit) LLVector3 opposite_pos = -1.f * mSunDir; LLVector3 orthog_light_pos = mSunDir % LLVector3::z_axis; LLVector4 backlight_pos = LLVector4(lerp(opposite_pos, orthog_light_pos, 0.3f), 0.0f); - backlight_pos.normVec(); + backlight_pos.normalize(); LLColor4 light_diffuse = mSunDiffuse; LLColor4 backlight_diffuse(1.f - light_diffuse.mV[VRED], 1.f - light_diffuse.mV[VGREEN], 1.f - light_diffuse.mV[VBLUE], 1.f); @@ -3446,7 +3467,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) atten = x / (light_radius); // % of brightness at radius quad = 0.0f; } - //mHWLightColors[cur_light] = light_color; + mHWLightColors[2] = light_color; S32 gllight = GL_LIGHT2; glLightfv(gllight, GL_POSITION, light_pos_gl.mV); glLightfv(gllight, GL_DIFFUSE, light_color.mV); @@ -3987,6 +4008,7 @@ BOOL LLPipeline::getRenderHighlights(void*) } LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start, const LLVector3& end, + BOOL pick_transparent, S32* face_hit, LLVector3* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -3996,6 +4018,10 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start, { LLDrawable* drawable = NULL; + LLVector3 local_end = end; + + LLVector3 position; + for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { @@ -4003,24 +4029,49 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start, for (U32 j = 0; j < LLViewerRegion::NUM_PARTITIONS; j++) { - if ((j == LLViewerRegion::PARTITION_VOLUME) || (j == LLViewerRegion::PARTITION_BRIDGE)) // only check these partitions for now + if ((j == LLViewerRegion::PARTITION_VOLUME) || + (j == LLViewerRegion::PARTITION_BRIDGE) || + (j == LLViewerRegion::PARTITION_TERRAIN) || + (j == LLViewerRegion::PARTITION_TREE) || + (j == LLViewerRegion::PARTITION_GRASS)) // only check these partitions for now { LLSpatialPartition* part = region->getSpatialPartition(j); - if (part) + if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, end, face_hit, intersection, tex_coord, normal, bi_normal); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, face_hit, &position, tex_coord, normal, bi_normal); if (hit) { drawable = hit; + local_end = position; } } } } } + + //check all avatar nametags (silly, isn't it?) + for (std::vector< LLCharacter* >::iterator iter = LLCharacter::sInstances.begin(); + iter != LLCharacter::sInstances.end(); + ++iter) + { + LLVOAvatar* av = (LLVOAvatar*) *iter; + if (av->mNameText.notNull() && av->mNameText->lineSegmentIntersect(start, local_end, position)) + { + drawable = av->mDrawable; + local_end = position; + } + } + + if (intersection) + { + *intersection = position; + } + return drawable ? drawable->getVObj().get() : NULL; } LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector3& start, const LLVector3& end, + BOOL pick_transparent, S32* face_hit, LLVector3* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -4035,15 +4086,27 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector3& start, co { LLViewerRegion* region = *iter; + BOOL toggle = FALSE; + if (!hasRenderType(LLPipeline::RENDER_TYPE_HUD)) + { + toggleRenderType(LLPipeline::RENDER_TYPE_HUD); + toggle = TRUE; + } + LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_HUD); if (part) { - LLDrawable* hit = part->lineSegmentIntersect(start, end, face_hit, intersection, tex_coord, normal, bi_normal); + LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, face_hit, intersection, tex_coord, normal, bi_normal); if (hit) { drawable = hit; } } + + if (toggle) + { + toggleRenderType(LLPipeline::RENDER_TYPE_HUD); + } } return drawable ? drawable->getVObj().get() : NULL; } @@ -4197,7 +4260,8 @@ void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam) LLPipeline::sReflectionRender = TRUE; - cube_map->bind(); + gGL.getTexUnit(cube_map->getStage())->bind(cube_map); + gGL.getTexUnit(0)->activate(); GLint width; glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_TEXTURE_WIDTH, &width); if (width != res) @@ -4209,8 +4273,10 @@ void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam) glTexImage2D(gl_cube_face[i], 0, GL_RGBA, res, res, 0, GL_RGBA, GL_FLOAT, NULL); } } - glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0); - cube_map->disable(); + gGL.getTexUnit(cube_map->getStage())->unbind(LLTexUnit::TT_CUBE_MAP); + gGL.getTexUnit(cube_map->getStage())->disable(); + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); BOOL toggle_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI); if (toggle_ui) @@ -4254,7 +4320,7 @@ void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam) gPipeline.calcNearbyLights(cube_cam); stop_glerror(); - LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mCubeFrameBuffer); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mCubeDepth); @@ -4410,7 +4476,8 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out) glPushMatrix(); cube_out->enableTexture(0); - cube_out->bind(); + gGL.getTexUnit(cube_out->getStage())->bind(cube_out); + gGL.getTexUnit(0)->activate(); GLint width; glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_TEXTURE_WIDTH, &width); if (width != res) @@ -4422,8 +4489,8 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out) glTexImage2D(gl_cube_face[i], 0, GL_RGBA, res, res, 0, GL_RGBA, GL_FLOAT, NULL); } } - glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0); - + gGL.getTexUnit(cube_out->getStage())->unbind(LLTexUnit::TT_CUBE_MAP); + gGL.getTexUnit(0)->activate(); glViewport(0, 0, res, res); LLGLEnable blend(GL_BLEND); @@ -4451,16 +4518,17 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out) if (j == 0) { - cube_in->bind(); + gGL.getTexUnit(cube_in->getStage())->bind(cube_in); } else { - glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mBlurCubeTexture[j-1]); + gGL.getTexUnit(cube_in->getStage())->bindManual(LLTexUnit::TT_CUBE_MAP, mBlurCubeTexture[j-1]); } + gGL.getTexUnit(0)->activate(); stop_glerror(); - LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mBlurCubeBuffer[j]); stop_glerror(); @@ -4489,7 +4557,7 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out) stop_glerror(); - glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0); + gGL.getTexUnit(cube_in->getStage())->unbind(LLTexUnit::TT_CUBE_MAP); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); gGL.setColorMask(true, false); @@ -4498,7 +4566,8 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out) glMatrixMode(GL_MODELVIEW); glPopMatrix(); - cube_in->disableTexture(); + gGL.getTexUnit(cube_in->getStage())->disable(); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); gViewerWindow->setupViewport(); gGL.setSceneBlendType(LLRender::BT_ALPHA); @@ -4566,7 +4635,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot) if (for_snapshot) { - mGlow[1].bindTexture(); + gGL.getTexUnit(0)->bind(&mGlow[1]); { //LLGLEnable stencil(GL_STENCIL_TEST); //glStencilFunc(GL_NOTEQUAL, 255, 0xFFFFFFFF); @@ -4575,7 +4644,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot) LLGLEnable blend(GL_BLEND); gGL.setSceneBlendType(LLRender::BT_ADD); tc2.setVec(1,1); - gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); + gGL.begin(LLRender::TRIANGLE_STRIP); gGL.color4f(1,1,1,1); gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); gGL.vertex2f(-1,-1); @@ -4625,15 +4694,15 @@ void LLPipeline::renderBloom(BOOL for_snapshot) LLGLEnable test(GL_ALPHA_TEST); gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); - LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); - glDisable(GL_TEXTURE_2D); - glEnable(GL_TEXTURE_RECTANGLE_ARB); - mScreen.bindTexture(); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->disable(); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); + gGL.getTexUnit(0)->bind(&mScreen); gGL.color4f(1,1,1,1); gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); - gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); + gGL.begin(LLRender::TRIANGLE_STRIP); gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); gGL.vertex2f(-1,-1); @@ -4647,8 +4716,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot) gGL.vertex2f(1,1); gGL.end(); - glEnable(GL_TEXTURE_2D); - glDisable(GL_TEXTURE_RECTANGLE_ARB); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); mGlow[2].flush(); } @@ -4678,7 +4746,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot) for (S32 i = 0; i < kernel; i++) { - LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); { LLFastTimer ftm(LLFastTimer::FTM_RENDER_BLOOM_FBO); mGlow[i%2].bindTarget(); @@ -4687,11 +4755,11 @@ void LLPipeline::renderBloom(BOOL for_snapshot) if (i == 0) { - mGlow[2].bindTexture(); + gGL.getTexUnit(0)->bind(&mGlow[2]); } else { - mGlow[(i-1)%2].bindTexture(); + gGL.getTexUnit(0)->bind(&mGlow[(i-1)%2]); } if (i%2 == 0) @@ -4703,7 +4771,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot) gGlowProgram.uniform2f("glowDelta", 0, delta); } - gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); + gGL.begin(LLRender::TRIANGLE_STRIP); gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); gGL.vertex2f(-1,-1); @@ -4768,8 +4836,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot) LLGLEnable blend(GL_BLEND); gGL.blendFunc(GL_ONE, GL_ONE); - glDisable(GL_TEXTURE_2D); - glEnable(GL_TEXTURE_RECTANGLE_ARB); + gGL.getTexUnit(0)->disable(); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); mScreen.bindTexture(); gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); @@ -4789,8 +4857,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot) gGL.flush(); - glEnable(GL_TEXTURE_2D); - glDisable(GL_TEXTURE_RECTANGLE_ARB); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); }*/ @@ -4835,12 +4902,12 @@ void LLPipeline::renderBloom(BOOL for_snapshot) //tex unit 0 gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_COLOR); - - mGlow[1].bindTexture(); + + gGL.getTexUnit(0)->bind(&mGlow[1]); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, 0, uv0); gGL.getTexUnit(1)->activate(); - glEnable(GL_TEXTURE_RECTANGLE_ARB); + 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); @@ -4851,14 +4918,16 @@ void LLPipeline::renderBloom(BOOL for_snapshot) glVertexPointer(2, GL_FLOAT, 0, v); - mScreen.bindTexture(); + gGL.getTexUnit(1)->bind(&mScreen); + gGL.getTexUnit(1)->activate(); LLGLEnable multisample(GL_MULTISAMPLE_ARB); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glDisable(GL_TEXTURE_RECTANGLE_ARB); + gGL.getTexUnit(1)->disable(); glDisableClientState(GL_TEXTURE_COORD_ARRAY); gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT); + glClientActiveTextureARB(GL_TEXTURE0_ARB); gGL.getTexUnit(0)->activate(); glDisableClientState(GL_TEXTURE_COORD_ARRAY); @@ -4936,7 +5005,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) if (!LLViewerCamera::getInstance()->cameraUnderWater()) { //generate planar reflection map - LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); glClearColor(0,0,0,0); gGL.setColorMask(true, true); mWaterRef.bindTarget(); @@ -5041,7 +5110,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) } LLViewerCamera::updateFrustumPlanes(camera); - LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLColor4& col = LLDrawPoolWater::sWaterFogColor; glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); gGL.setColorMask(true, true); @@ -5173,11 +5242,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) LLVector3 left = camera.getLeftAxis(); left *= left; - left.normVec(); + left.normalize(); LLVector3 up = camera.getUpAxis(); up *= up; - up.normVec(); + up.normalize(); tdim.mV[0] = fabsf(half_height * left); tdim.mV[1] = fabsf(half_height * up); @@ -5218,10 +5287,10 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) resY != avatar->mImpostor.getHeight()) { avatar->mImpostor.allocate(resX,resY,GL_RGBA,TRUE); - avatar->mImpostor.bindTexture(); + gGL.getTexUnit(0)->bind(&avatar->mImpostor); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } { @@ -5258,13 +5327,13 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) } gGL.setSceneBlendType(LLRender::BT_ADD); - LLImageGL::unbindTexture(0, GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest depth(GL_FALSE, GL_FALSE); gGL.color4f(1,1,1,1); gGL.color4ub(64,64,64,255); - gGL.begin(LLVertexBuffer::QUADS); + gGL.begin(LLRender::QUADS); gGL.vertex3fv((pos+left-up).mV); gGL.vertex3fv((pos-left-up).mV); gGL.vertex3fv((pos-left+up).mV); diff --git a/linden/indra/newview/pipeline.h b/linden/indra/newview/pipeline.h index 5f94e37..c795283 100644 --- a/linden/indra/newview/pipeline.h +++ b/linden/indra/newview/pipeline.h @@ -131,6 +131,7 @@ public: //get the object between start and end that's closest to start. LLViewerObject* lineSegmentIntersectInWorld(const LLVector3& start, const LLVector3& end, + BOOL pick_transparent, S32* face_hit, // return the face hit LLVector3* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -138,6 +139,7 @@ public: LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point ); LLViewerObject* lineSegmentIntersectInHUD(const LLVector3& start, const LLVector3& end, + BOOL pick_transparent, S32* face_hit, // return the face hit LLVector3* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -317,7 +319,6 @@ public: // RENDER_DEBUG_FEATURE_HW_LIGHTING = 0x0010, RENDER_DEBUG_FEATURE_FLEXIBLE = 0x0010, RENDER_DEBUG_FEATURE_FOG = 0x0020, - RENDER_DEBUG_FEATURE_PALETTE = 0x0040, RENDER_DEBUG_FEATURE_FR_INFO = 0x0080, RENDER_DEBUG_FEATURE_FOOT_SHADOWS = 0x0100, }; diff --git a/linden/indra/newview/res/viewerRes.rc b/linden/indra/newview/res/viewerRes.rc index a39bb9f..8df0c57 100644 --- a/linden/indra/newview/res/viewerRes.rc +++ b/linden/indra/newview/res/viewerRes.rc @@ -231,8 +231,8 @@ TOOLMEDIAOPEN CURSOR "toolmediaopen.cur" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,20,9,87416 - PRODUCTVERSION 1,20,9,87416 + FILEVERSION 1,20,15,97417 + PRODUCTVERSION 1,20,15,97417 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -249,12 +249,12 @@ BEGIN BEGIN VALUE "CompanyName", "Linden Lab" VALUE "FileDescription", "Second Life" - VALUE "FileVersion", "1.20.9.87416" + VALUE "FileVersion", "1.20.15.97417" VALUE "InternalName", "Second Life" VALUE "LegalCopyright", "Copyright © 2001-2008, Linden Research, Inc." VALUE "OriginalFilename", "SecondLife.exe" VALUE "ProductName", "Second Life" - VALUE "ProductVersion", "1.20.9.87416" + VALUE "ProductVersion", "1.20.15.97417" END END BLOCK "VarFileInfo" diff --git a/linden/indra/newview/secondlife setup build dazzle.bat b/linden/indra/newview/secondlife setup build dazzle.bat deleted file mode 100644 index f09f657..0000000 --- a/linden/indra/newview/secondlife setup build dazzle.bat +++ /dev/null @@ -1,4 +0,0 @@ -@rem Invoke the script which preps then runs the installer. -@rem This batch file is customized per grid. - -@"secondlife setup build.bat" --channel="Second Life First Look Dazzle" diff --git a/linden/indra/newview/skins/default/xui/de/alerts.xml b/linden/indra/newview/skins/default/xui/de/alerts.xml index ab72b30..57a5a4b 100644 --- a/linden/indra/newview/skins/default/xui/de/alerts.xml +++ b/linden/indra/newview/skins/default/xui/de/alerts.xml @@ -735,13 +735,8 @@ Sie benötigen ein Benutzerkonto, um [SECOND_LIFE] betreten zu können. Möchten - Anzeigen erscheinen für eine Woche unter 'Anzeigen' -im Suchverzeichnis. -Füllen Sie Ihre Anzeige aus und klicken Sie auf 'Veröffentlichen...', um sie zum -Verzeichnis hinzuzufügen. -Sie werden gebeten, einen Preis zu bezahlen, wenn Sie auf 'Veröffentlichen' klicken. -Wenn Sie mehr bezahlen oder ein Benutzer nach Ihren Suchbegriffen sucht, -erscheint Ihre Anzeige weiter oben in der Liste. + Anzeigen erscheinen für eine Woche unter 'Anzeigen' im Suchverzeichnis. Füllen Sie Ihre Anzeige aus und klicken Sie auf 'Veröffentlichen...', um sie zum Verzeichnis hinzuzufügen. +Sie werden gebeten, einen Preis zu bezahlen, wenn Sie auf 'Veröffentlichen' klicken. Wenn Sie mehr bezahlen oder ein Benutzer nach Ihren Suchbegriffen sucht, erscheint Ihre Anzeige weiter oben in der Liste. - Zur [SECOND_LIFE]-Webseite, um Auktionen anzuzeigen oder -ein Gebot abzugeben? + Zur [SECOND_LIFE]-Webseite, um Auktionen anzuzeigen oder ein Gebot abzugeben?