From 2bafe0dc8a2eb1d99516a4af96acc93c3541a1cd Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 28 Jan 2011 20:18:10 -0500 Subject: Extend LLEventAPI to directly call other functions & methods. Until now, LLEventAPI has only been able to register functions specifically accepting(const LLSD&). Typically you add a wrapper method to your LLEventAPI subclass, register that, have it extract desired params from the incoming LLSD and then call the actual function of interest. With help from Alain, added new LLEventAPI::add() methods capable of registering functions/methods with arbitrary parameter signatures. The code uses boost::fusion magic to implicitly match incoming LLSD arguments to the function's formal parameter list, bypassing the need for an explicit helper method. New add() methods caused an ambiguity with a previous convenience overload. Removed that overload and fixed the one existing usage. Replaced LLEventDispatcher::get() with try_call() -- it's no longer easy to return a Callable for caller to call directly. But the one known use of that feature simply used it to avoid fatal LL_ERRS on unknown function-name string, hence the try_call() approach actually addresses that case more directly. Added indra/common/lleventdispatcher_test.cpp to exercise new functionality. --- indra/newview/lllogininstance.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index 33e051bfab..abcd8588dc 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -480,10 +480,12 @@ LLLoginInstance::LLLoginInstance() : { mLoginModule->getEventPump().listen("lllogininstance", boost::bind(&LLLoginInstance::handleLoginEvent, this, _1)); - mDispatcher.add("fail.login", boost::bind(&LLLoginInstance::handleLoginFailure, this, _1)); - mDispatcher.add("connect", boost::bind(&LLLoginInstance::handleLoginSuccess, this, _1)); - mDispatcher.add("disconnect", boost::bind(&LLLoginInstance::handleDisconnect, this, _1)); - mDispatcher.add("indeterminate", boost::bind(&LLLoginInstance::handleIndeterminate, this, _1)); + // This internal use of LLEventDispatcher doesn't really need + // per-function descriptions. + mDispatcher.add("fail.login", "", boost::bind(&LLLoginInstance::handleLoginFailure, this, _1)); + mDispatcher.add("connect", "", boost::bind(&LLLoginInstance::handleLoginSuccess, this, _1)); + mDispatcher.add("disconnect", "", boost::bind(&LLLoginInstance::handleDisconnect, this, _1)); + mDispatcher.add("indeterminate", "", boost::bind(&LLLoginInstance::handleIndeterminate, this, _1)); } LLLoginInstance::~LLLoginInstance() @@ -625,11 +627,7 @@ bool LLLoginInstance::handleLoginEvent(const LLSD& event) // Call the method registered in constructor, if any, for more specific // handling - LLEventDispatcher::Callable method(mDispatcher.get(event["change"])); - if (! method.empty()) - { - method(event); - } + mDispatcher.try_call(event); return false; } -- cgit v1.2.3 From 5946d84eef30caeae6dee63767fabdcf81613984 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 16 Feb 2011 12:49:35 -0500 Subject: SWAT-484, SWAT-485: add LLSideTrayListener, a new LLEventAPI. Expand XUI-visible LLUICtrl::CommitCallbackRegistry operations to include "SideTray.Toggle" and "SideTray.Collapse". Give LLSideTrayListener friend access to LLSideTray so it can query the attached and detached tabs. Introduce tab_cast template to deal with the unavailability of the LLSideTrayTab class outside of llsidetray.cpp. --- indra/newview/CMakeLists.txt | 2 + indra/newview/llsidetray.cpp | 11 +++ indra/newview/llsidetray.h | 10 +++ indra/newview/llsidetraylistener.cpp | 167 +++++++++++++++++++++++++++++++++++ indra/newview/llsidetraylistener.h | 36 ++++++++ 5 files changed, 226 insertions(+) create mode 100644 indra/newview/llsidetraylistener.cpp create mode 100644 indra/newview/llsidetraylistener.h (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index af6beacdfa..11bebf04ef 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -412,6 +412,7 @@ set(viewer_SOURCE_FILES llsidepaneliteminfo.cpp llsidepaneltaskinfo.cpp llsidetray.cpp + llsidetraylistener.cpp llsidetraypanelcontainer.cpp llsky.cpp llslurl.cpp @@ -947,6 +948,7 @@ set(viewer_HEADER_FILES llsidepaneliteminfo.h llsidepaneltaskinfo.h llsidetray.h + llsidetraylistener.h llsidetraypanelcontainer.h llsky.h llslurl.h diff --git a/indra/newview/llsidetray.cpp b/indra/newview/llsidetray.cpp index eb537c7d7b..85efebabfe 100644 --- a/indra/newview/llsidetray.cpp +++ b/indra/newview/llsidetray.cpp @@ -53,6 +53,8 @@ #include "llsidepanelappearance.h" +#include "llsidetraylistener.h" + //#include "llscrollcontainer.h" using namespace std; @@ -71,6 +73,8 @@ static const std::string TAB_PANEL_CAPTION_TITLE_BOX = "sidetray_tab_title"; LLSideTray* LLSideTray::sInstance = 0; +static LLSideTrayListener sSideTrayListener(LLSideTray::getInstance); + // static LLSideTray* LLSideTray::getInstance() { @@ -417,6 +421,11 @@ LLSideTrayTab* LLSideTrayTab::createInstance () return tab; } +// Now that we know the definition of LLSideTrayTab, we can implement +// tab_cast. +template <> +LLPanel* tab_cast(LLSideTrayTab* tab) { return tab; } + ////////////////////////////////////////////////////////////////////////////// // LLSideTrayButton // Side Tray tab button with "tear off" handling. @@ -530,6 +539,8 @@ LLSideTray::LLSideTray(const Params& params) // register handler function to process data from the xml. // panel_name should be specified via "parameter" attribute. commit.add("SideTray.ShowPanel", boost::bind(&LLSideTray::showPanel, this, _2, LLUUID::null)); + commit.add("SideTray.Toggle", boost::bind(&LLSideTray::onToggleCollapse, this)); + commit.add("SideTray.Collapse", boost::bind(&LLSideTray::collapseSideBar, this)); LLTransientFloaterMgr::getInstance()->addControlView(this); LLView* side_bar_tabs = gViewerWindow->getRootView()->getChildView("side_bar_tabs"); if (side_bar_tabs != NULL) diff --git a/indra/newview/llsidetray.h b/indra/newview/llsidetray.h index 184d78845f..c4d3c2626c 100644 --- a/indra/newview/llsidetray.h +++ b/indra/newview/llsidetray.h @@ -33,6 +33,13 @@ class LLAccordionCtrl; class LLSideTrayTab; +// Deal with LLSideTrayTab being opaque. Generic do-nothing cast... +template +T tab_cast(LLSideTrayTab* tab) { return tab; } +// specialized for implementation in presence of LLSideTrayTab definition +template <> +LLPanel* tab_cast(LLSideTrayTab* tab); + // added inheritance from LLDestroyClass to enable Side Tray perform necessary actions // while disconnecting viewer in LLAppViewer::disconnectViewer(). // LLDestroyClassList::instance().fireCallbacks() calls destroyClass method. See EXT-245. @@ -217,6 +224,9 @@ private: } private: + // Since we provide no public way to query mTabs and mDetachedTabs, give + // LLSideTrayListener friend access. + friend class LLSideTrayListener; LLPanel* mButtonsPanel; typedef std::map button_map_t; button_map_t mTabButtons; diff --git a/indra/newview/llsidetraylistener.cpp b/indra/newview/llsidetraylistener.cpp new file mode 100644 index 0000000000..185bf1d6a7 --- /dev/null +++ b/indra/newview/llsidetraylistener.cpp @@ -0,0 +1,167 @@ +/** + * @file llsidetraylistener.cpp + * @author Nat Goodspeed + * @date 2011-02-15 + * @brief Implementation for llsidetraylistener. + * + * $LicenseInfo:firstyear=2011&license=lgpl$ + * Copyright (c) 2011, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Precompiled header +#include "llviewerprecompiledheaders.h" +// associated header +#include "llsidetraylistener.h" +// STL headers +// std headers +// external library headers +// other Linden headers +#include "llsidetray.h" +#include "llsdutil.h" + +LLSideTrayListener::LLSideTrayListener(const Getter& getter): + LLEventAPI("LLSideTray", + "Operations on side tray (e.g. query state, query tabs)"), + mGetter(getter) +{ + add("getCollapsed", "Send on [\"reply\"] an [\"open\"] Boolean", + &LLSideTrayListener::getCollapsed, LLSDMap("reply", LLSD())); + add("getTabs", + "Send on [\"reply\"] a map of tab names and info about them", + &LLSideTrayListener::getTabs, LLSDMap("reply", LLSD())); + add("getPanels", + "Send on [\"reply\"] data about panels available with SideTray.ShowPanel", + &LLSideTrayListener::getPanels, LLSDMap("reply", LLSD())); +} + +void LLSideTrayListener::getCollapsed(const LLSD& event) const +{ + LLReqID reqID(event); + LLSD reply(reqID.makeResponse()); + reply["open"] = ! mGetter()->getCollapsed(); + LLEventPumps::instance().obtain(event["reply"]).post(reply); +} + +void LLSideTrayListener::getTabs(const LLSD& event) const +{ + LLReqID reqID(event); + LLSD reply(reqID.makeResponse()); + + LLSideTray* tray = mGetter(); + LLSD::Integer ord(0); + for (LLSideTray::child_list_const_iter_t chi(tray->beginChild()), chend(tray->endChild()); + chi != chend; ++chi, ++ord) + { + LLView* child = *chi; + // How much info is important? Toss in as much as seems reasonable for + // each tab. But to me, at least for the moment, the most important + // item is the tab name. + LLSD info; + // I like the idea of returning a map keyed by tab name. But as + // compared to an array of maps, that loses sequence information. + // Address that by indicating the original order in each map entry. + info["ord"] = ord; + info["visible"] = bool(child->getVisible()); + info["enabled"] = bool(child->getEnabled()); + info["available"] = child->isAvailable(); + reply[child->getName()] = info; + } + + LLEventPumps::instance().obtain(event["reply"]).post(reply); +} + +static LLSD getTabInfo(LLPanel* tab) +{ + LLSD panels; + for (LLPanel::tree_iterator_t ti(tab->beginTreeDFS()), tend(tab->endTreeDFS()); + ti != tend; ++ti) + { + // *ti is actually an LLView*, which had better not be NULL + LLView* view(*ti); + if (! view) + { + LL_ERRS("LLSideTrayListener") << "LLSideTrayTab '" << tab->getName() + << "' has a NULL child LLView*" << LL_ENDL; + } + + // The logic we use to decide what "panel" names to return is heavily + // based on LLSideTray::showPanel(): the function that actually + // implements the "SideTray.ShowPanel" operation. showPanel(), in + // turn, depends on LLSideTray::openChildPanel(): when + // openChildPanel() returns non-NULL, showPanel() stops searching + // attached and detached LLSideTrayTab tabs. + + // For each LLSideTrayTab, openChildPanel() first calls + // findChildView(panel_name, true). In other words, panel_name need + // not be a direct LLSideTrayTab child, it's sought recursively. + // That's why we use (begin|end)TreeDFS() in this loop. + + // But this tree_iterator_t loop will actually traverse every widget + // in every panel. Returning all those names will not help our caller: + // passing most such names to openChildPanel() would not do what we + // want. Even though the code suggests that passing ANY valid + // side-panel widget name to openChildPanel() will open the tab + // containing that widget, results could get confusing since followup + // (onOpen()) logic wouldn't be invoked, and showPanel() wouldn't stop + // searching because openChildPanel() would return NULL. + + // We must filter these LLView items, using logic that (sigh!) mirrors + // openChildPanel()'s own. + + // openChildPanel() returns a non-NULL LLPanel* when either: + // - the LLView is a direct child of an LLSideTrayPanelContainer + // - the LLView is itself an LLPanel. + // But as LLSideTrayPanelContainer can directly contain LLView items + // that are NOT themselves LLPanels (e.g. "sidebar_me" contains an + // LLButton called "Jump Right Arrow"), we'd better focus only on + // LLSideTrayPanelContainer children that are themselves LLPanel + // items. Which means that the second test completely subsumes the + // first. + LLPanel* panel(dynamic_cast(view)); + if (panel) + { + // Maybe it's overkill to construct an LLSD::Map for each panel, but + // the possibility remains that we might want to deliver more info + // about each panel than just its name. + panels.append(LLSDMap("name", panel->getName())); + } + } + + return LLSDMap("panels", panels); +} + +void LLSideTrayListener::getPanels(const LLSD& event) const +{ + LLReqID reqID(event); + LLSD reply(reqID.makeResponse()); + + LLSideTray* tray = mGetter(); + // Iterate through the attached tabs. + LLSD::Integer ord(0); + for (LLSideTray::child_vector_t::const_iterator + ati(tray->mTabs.begin()), atend(tray->mTabs.end()); + ati != atend; ++ati) + { + // We don't have access to LLSideTrayTab: the class definition is + // hidden in llsidetray.cpp. But as LLSideTrayTab isa LLPanel, use the + // LLPanel API. Unfortunately, without the LLSideTrayTab definition, + // the compiler doesn't even know this LLSideTrayTab* is an LLPanel*. + // Persuade it. + LLPanel* tab(tab_cast(*ati)); + reply[tab->getName()] = getTabInfo(tab).with("attached", true).with("ord", ord); + } + + // Now iterate over the detached tabs. These can also be opened via + // SideTray.ShowPanel. + ord = 0; + for (LLSideTray::child_vector_t::const_iterator + dti(tray->mDetachedTabs.begin()), dtend(tray->mDetachedTabs.end()); + dti != dtend; ++dti) + { + LLPanel* tab(tab_cast(*dti)); + reply[tab->getName()] = getTabInfo(tab).with("attached", false).with("ord", ord); + } + + LLEventPumps::instance().obtain(event["reply"]).post(reply); +} diff --git a/indra/newview/llsidetraylistener.h b/indra/newview/llsidetraylistener.h new file mode 100644 index 0000000000..0dd2067433 --- /dev/null +++ b/indra/newview/llsidetraylistener.h @@ -0,0 +1,36 @@ +/** + * @file llsidetraylistener.h + * @author Nat Goodspeed + * @date 2011-02-15 + * @brief + * + * $LicenseInfo:firstyear=2011&license=lgpl$ + * Copyright (c) 2011, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#if ! defined(LL_LLSIDETRAYLISTENER_H) +#define LL_LLSIDETRAYLISTENER_H + +#include "lleventapi.h" +#include + +class LLSideTray; +class LLSD; + +class LLSideTrayListener: public LLEventAPI +{ + typedef boost::function Getter; + +public: + LLSideTrayListener(const Getter& getter); + +private: + void getCollapsed(const LLSD& event) const; + void getTabs(const LLSD& event) const; + void getPanels(const LLSD& event) const; + + Getter mGetter; +}; + +#endif /* ! defined(LL_LLSIDETRAYLISTENER_H) */ -- cgit v1.2.3 From 4ef02bc1b6cf5e044d2cf57725eac1a4ccd7580d Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 18 Feb 2011 10:56:26 -0500 Subject: Introduce and use new sendReply() function for LLEventAPI methods. Each LLEventAPI method that generates a reply needs to extract the name of the reply LLEventPump from the request, typically from a ["reply"] key, copy the ["reqid"] value from request to reply, locate the reply LLEventPump and send the enriched reply object. Encapsulate in sendReply() function before we proliferate doing all that by hand too many more times. --- indra/newview/llsidetraylistener.cpp | 15 +++++---------- indra/newview/llviewerwindowlistener.cpp | 5 +---- 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llsidetraylistener.cpp b/indra/newview/llsidetraylistener.cpp index 185bf1d6a7..6db13e517d 100644 --- a/indra/newview/llsidetraylistener.cpp +++ b/indra/newview/llsidetraylistener.cpp @@ -37,16 +37,12 @@ LLSideTrayListener::LLSideTrayListener(const Getter& getter): void LLSideTrayListener::getCollapsed(const LLSD& event) const { - LLReqID reqID(event); - LLSD reply(reqID.makeResponse()); - reply["open"] = ! mGetter()->getCollapsed(); - LLEventPumps::instance().obtain(event["reply"]).post(reply); + sendReply(LLSDMap("open", ! mGetter()->getCollapsed()), event); } void LLSideTrayListener::getTabs(const LLSD& event) const { - LLReqID reqID(event); - LLSD reply(reqID.makeResponse()); + LLSD reply; LLSideTray* tray = mGetter(); LLSD::Integer ord(0); @@ -68,7 +64,7 @@ void LLSideTrayListener::getTabs(const LLSD& event) const reply[child->getName()] = info; } - LLEventPumps::instance().obtain(event["reply"]).post(reply); + sendReply(reply, event); } static LLSD getTabInfo(LLPanel* tab) @@ -133,8 +129,7 @@ static LLSD getTabInfo(LLPanel* tab) void LLSideTrayListener::getPanels(const LLSD& event) const { - LLReqID reqID(event); - LLSD reply(reqID.makeResponse()); + LLSD reply; LLSideTray* tray = mGetter(); // Iterate through the attached tabs. @@ -163,5 +158,5 @@ void LLSideTrayListener::getPanels(const LLSD& event) const reply[tab->getName()] = getTabInfo(tab).with("attached", false).with("ord", ord); } - LLEventPumps::instance().obtain(event["reply"]).post(reply); + sendReply(reply, event); } diff --git a/indra/newview/llviewerwindowlistener.cpp b/indra/newview/llviewerwindowlistener.cpp index 0b52948680..1fe5fc9800 100644 --- a/indra/newview/llviewerwindowlistener.cpp +++ b/indra/newview/llviewerwindowlistener.cpp @@ -65,7 +65,6 @@ LLViewerWindowListener::LLViewerWindowListener(LLViewerWindow* llviewerwindow): void LLViewerWindowListener::saveSnapshot(const LLSD& event) const { - LLReqID reqid(event); typedef std::map TypeMap; TypeMap types; #define tp(name) types[#name] = LLViewerWindow::SNAPSHOT_TYPE_##name @@ -98,9 +97,7 @@ void LLViewerWindowListener::saveSnapshot(const LLSD& event) const type = found->second; } bool ok = mViewerWindow->saveSnapshot(event["filename"], width, height, showui, rebuild, type); - LLSD response(reqid.makeResponse()); - response["ok"] = ok; - LLEventPumps::instance().obtain(event["reply"]).post(response); + sendReply(LLSDMap("ok", ok), event); } void LLViewerWindowListener::requestReshape(LLSD const & event_data) const -- cgit v1.2.3 From 0e39a7881e29fe58761403424941b78f82042ac1 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Fri, 18 Feb 2011 11:31:18 -0800 Subject: Initial stub for getValue() and path walker --- indra/newview/lluilistener.cpp | 31 +++++++++++++++++++++++++++++++ indra/newview/lluilistener.h | 1 + 2 files changed, 32 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/lluilistener.cpp b/indra/newview/lluilistener.cpp index 4d6eac4958..dafca0abf2 100644 --- a/indra/newview/lluilistener.cpp +++ b/indra/newview/lluilistener.cpp @@ -47,6 +47,12 @@ LLUIListener::LLUIListener(): "as if from a user gesture on a menu -- or a button click.", &LLUIListener::call, LLSD().with("function", LLSD())); + + add("getValue", + "For the UI control identified by the path in [\"path\"], return the control's\n" + "current value as [\"value\"] reply.", + &LLUIListener::getValue, + LLSD().with("path", LLSD())); } void LLUIListener::call(const LLSD& event) const @@ -71,3 +77,28 @@ void LLUIListener::call(const LLSD& event) const (*func)(NULL, event["parameter"]); } } + +const LLUICtrl* resolve_path(const LLUICtrl* base, const std::string path) +{ + // *TODO: walk the path + return NULL; +} + +void LLUIListener::getValue(const LLSD&event) const +{ + LLSD reply; + + const LLUICtrl* root = NULL; // *TODO: look this up + const LLUICtrl* ctrl = resolve_path(root, event["path"].asString()); + + if (ctrl) + { + reply["value"] = ctrl->getValue(); + } + else + { + // *TODO: ??? return something indicating failure to resolve + } + + sendReply(reply, event, "reply"); +} diff --git a/indra/newview/lluilistener.h b/indra/newview/lluilistener.h index e7847f01e8..08724024dc 100644 --- a/indra/newview/lluilistener.h +++ b/indra/newview/lluilistener.h @@ -41,6 +41,7 @@ public: private: void call(const LLSD& event) const; + void getValue(const LLSD&event) const; }; #endif /* ! defined(LL_LLUILISTENER_H) */ -- cgit v1.2.3 From f6970e6ad1f0576ec194fdc8d369030f1e31aeab Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Fri, 18 Feb 2011 13:04:41 -0800 Subject: Implemented path resolution. Should be able to test this now. --- indra/newview/lluilistener.cpp | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lluilistener.cpp b/indra/newview/lluilistener.cpp index dafca0abf2..22d3b8b219 100644 --- a/indra/newview/lluilistener.cpp +++ b/indra/newview/lluilistener.cpp @@ -34,9 +34,11 @@ // std headers // external library headers // other Linden headers +#include "llviewerwindow.h" // to get root view #include "lluictrl.h" #include "llerror.h" + LLUIListener::LLUIListener(): LLEventAPI("UI", "LLUICtrl::CommitCallbackRegistry listener.\n" @@ -78,9 +80,38 @@ void LLUIListener::call(const LLSD& event) const } } -const LLUICtrl* resolve_path(const LLUICtrl* base, const std::string path) +const LLView* resolve_path(const LLView* context, const std::string path) { - // *TODO: walk the path + std::vector parts; + const std::string delims("/"); + LLStringUtilBase::getTokens(path, parts, delims); + + bool recurse = false; + for (std::vector::iterator it = parts.begin(); + it != parts.end() && context; it++) + { + std::string part = *it; + + if (part.length() == 0) + { + // Allow "foo//bar" meaning "descendant named bar" + recurse = true; + } + else + { + const LLView* found = context->findChildView(part, recurse); + if (!found) + { + return NULL; + } + else + { + context = found; + } + recurse = false; + } + } + return NULL; } @@ -88,9 +119,10 @@ void LLUIListener::getValue(const LLSD&event) const { LLSD reply; - const LLUICtrl* root = NULL; // *TODO: look this up - const LLUICtrl* ctrl = resolve_path(root, event["path"].asString()); - + const LLView* root = (LLView*)(gViewerWindow->getRootView()); + const LLView* view = resolve_path(root, event["path"].asString()); + const LLUICtrl* ctrl(dynamic_cast(view)); + if (ctrl) { reply["value"] = ctrl->getValue(); -- cgit v1.2.3 From 18bf5f09b22a2c36ccf543104b1115a7b0b9db71 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 18 Feb 2011 17:49:01 -0500 Subject: Add LLAgent operations to set/query avatar orientation. --- indra/newview/llagentlistener.cpp | 36 ++++++++++++++++++++++++++++++++++++ indra/newview/llagentlistener.h | 2 ++ 2 files changed, 38 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/llagentlistener.cpp b/indra/newview/llagentlistener.cpp index d520debc31..c453fe91f4 100644 --- a/indra/newview/llagentlistener.cpp +++ b/indra/newview/llagentlistener.cpp @@ -37,6 +37,8 @@ #include "llviewerobject.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" +#include "llsdutil.h" +#include "llsdutil_math.h" LLAgentListener::LLAgentListener(LLAgent &agent) : LLEventAPI("LLAgent", @@ -53,6 +55,15 @@ LLAgentListener::LLAgentListener(LLAgent &agent) add("requestStand", "Ask to stand up", &LLAgentListener::requestStand); + add("resetAxes", + "Set the agent to a fixed orientation (optionally specify [\"lookat\"] = array of [x, y, z])", + &LLAgentListener::resetAxes); + add("getAxes", + "Send information about the agent's orientation on [\"reply\"]:\n" + "[\"euler\"]: map of {roll, pitch, yaw}\n" + "[\"quat\"]: array of [x, y, z, w] quaternion values", + &LLAgentListener::getAxes, + LLSDMap("reply", LLSD())); } void LLAgentListener::requestTeleport(LLSD const & event_data) const @@ -104,3 +115,28 @@ void LLAgentListener::requestStand(LLSD const & event_data) const mAgent.setControlFlags(AGENT_CONTROL_STAND_UP); } +void LLAgentListener::resetAxes(const LLSD& event) const +{ + if (event.has("lookat")) + { + mAgent.resetAxes(ll_vector3_from_sd(event["lookat"])); + } + else + { + // no "lookat", default call + mAgent.resetAxes(); + } +} + +void LLAgentListener::getAxes(const LLSD& event) const +{ + LLQuaternion quat(mAgent.getQuat()); + F32 roll, pitch, yaw; + quat.getEulerAngles(&roll, &pitch, &yaw); + // The official query API for LLQuaternion's [x, y, z, w] values is its + // public member mQ... + sendReply(LLSDMap + ("quat", llsd_copy_array(boost::begin(quat.mQ), boost::end(quat.mQ))) + ("euler", LLSDMap("roll", roll)("pitch", pitch)("yaw", yaw)), + event); +} diff --git a/indra/newview/llagentlistener.h b/indra/newview/llagentlistener.h index 9b585152f4..0aa58d0b16 100644 --- a/indra/newview/llagentlistener.h +++ b/indra/newview/llagentlistener.h @@ -44,6 +44,8 @@ private: void requestTeleport(LLSD const & event_data) const; void requestSit(LLSD const & event_data) const; void requestStand(LLSD const & event_data) const; + void resetAxes(const LLSD& event) const; + void getAxes(const LLSD& event) const; private: LLAgent & mAgent; -- cgit v1.2.3 From 774405e92bec6bdfa9e2be28e04b4b47fd71615e Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Fri, 18 Feb 2011 23:16:38 +0000 Subject: Cleanup of headless client (was: DisableRendering mode) * Now called 'HeadlessClient' instead of 'DisableRendering' * Removed most cases where we skipped certain behaviors in the client when in this mode. This gets us closer to a 'true' client, for testing purposes. --- indra/newview/app_settings/settings.xml | 4 +- indra/newview/llagent.cpp | 11 --- indra/newview/llagentcamera.cpp | 29 ++++--- indra/newview/llappviewer.cpp | 118 +++++++++++++--------------- indra/newview/llfloaterbump.cpp | 2 - indra/newview/llhudeffectlookat.cpp | 5 -- indra/newview/llhudmanager.cpp | 7 -- indra/newview/llimview.cpp | 9 --- indra/newview/llselectmgr.cpp | 18 ++--- indra/newview/llstartup.cpp | 132 +++++++++++++------------------- indra/newview/llsurface.cpp | 5 -- indra/newview/lltexturestats.cpp | 2 +- indra/newview/llviewerdisplay.cpp | 6 +- indra/newview/llviewermessage.cpp | 30 +++----- indra/newview/llviewerobject.cpp | 11 --- indra/newview/llviewerobjectlist.cpp | 26 +++---- indra/newview/llviewerparcelmgr.cpp | 5 -- indra/newview/llviewerregion.cpp | 35 +++------ indra/newview/llviewerstats.cpp | 2 +- indra/newview/llviewertexture.cpp | 100 ++++++++++++------------ indra/newview/llviewertexturelist.cpp | 15 +--- indra/newview/llviewerwindow.cpp | 56 +++++--------- indra/newview/llvoavatar.cpp | 55 +------------ indra/newview/llvoavatarself.cpp | 4 - indra/newview/llworld.cpp | 10 +-- indra/newview/pipeline.cpp | 4 - 26 files changed, 236 insertions(+), 465 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index ced46c7294..603fddbccd 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -2612,10 +2612,10 @@ Value 0 - DisableRendering + HeadlessClient Comment - Disable GL rendering and GUI (load testing) + Run in headless mode by disabling GL rendering, keyboard, etc Persist 1 Type diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 7d908df5ce..7d491a7774 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -1119,12 +1119,6 @@ void LLAgent::resetControlFlags() //----------------------------------------------------------------------------- void LLAgent::setAFK() { - // Drones can't go AFK - if (gNoRender) - { - return; - } - if (!gAgent.getRegion()) { // Don't set AFK if we're not talking to a region yet. @@ -1684,11 +1678,6 @@ void LLAgent::clearRenderState(U8 clearstate) //----------------------------------------------------------------------------- U8 LLAgent::getRenderState() { - if (gNoRender || gKeyboard == NULL) - { - return 0; - } - // *FIX: don't do stuff in a getter! This is infinite loop city! if ((mTypingTimer.getElapsedTimeF32() > TYPING_TIMEOUT_SECS) && (mRenderState & AGENT_STATE_TYPING)) diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index f01d5ff1f5..6c5c3bcdab 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -282,25 +282,22 @@ void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera) gAgent.stopAutoPilot(TRUE); } - if (!gNoRender) - { - LLSelectMgr::getInstance()->unhighlightAll(); + LLSelectMgr::getInstance()->unhighlightAll(); - // By popular request, keep land selection while walking around. JC - // LLViewerParcelMgr::getInstance()->deselectLand(); + // By popular request, keep land selection while walking around. JC + // LLViewerParcelMgr::getInstance()->deselectLand(); - // force deselect when walking and attachment is selected - // this is so people don't wig out when their avatar moves without animating - if (LLSelectMgr::getInstance()->getSelection()->isAttachment()) - { - LLSelectMgr::getInstance()->deselectAll(); - } + // force deselect when walking and attachment is selected + // this is so people don't wig out when their avatar moves without animating + if (LLSelectMgr::getInstance()->getSelection()->isAttachment()) + { + LLSelectMgr::getInstance()->deselectAll(); + } - if (gMenuHolder != NULL) - { - // Hide all popup menus - gMenuHolder->hideMenus(); - } + if (gMenuHolder != NULL) + { + // Hide all popup menus + gMenuHolder->hideMenus(); } if (change_camera && !gSavedSettings.getBOOL("FreezeTime")) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 6a9dfaf21b..25bdaed0c9 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -881,7 +881,7 @@ bool LLAppViewer::init() } // If we don't have the right GL requirements, exit. - if (!gGLManager.mHasRequirements && !gNoRender) + if (!gGLManager.mHasRequirements) { // can't use an alert here since we're exiting and // all hell breaks lose. @@ -1171,7 +1171,8 @@ bool LLAppViewer::mainLoop() } // Render scene. - if (!LLApp::isExiting()) + // *TODO: Should we run display() even during gHeadlessClient? DK 2011-02-18 + if (!LLApp::isExiting() && !gHeadlessClient) { pingMainloopTimeout("Main:Display"); gGLActive = TRUE; @@ -1199,8 +1200,7 @@ bool LLAppViewer::mainLoop() } // yield cooperatively when not running as foreground window - if ( gNoRender - || (gViewerWindow && !gViewerWindow->mWindow->getVisible()) + if ( (gViewerWindow && !gViewerWindow->mWindow->getVisible()) || !gFocusMgr.getAppHasFocus()) { // Sleep if we're not rendering, or the window is minimized. @@ -2640,7 +2640,8 @@ bool LLAppViewer::initWindow() LL_INFOS("AppInit") << "Initializing window..." << LL_ENDL; // store setting in a global for easy access and modification - gNoRender = gSavedSettings.getBOOL("DisableRendering"); + gHeadlessClient = gSavedSettings.getBOOL("DisableRendering") + || gSavedSettings.getBOOL("HeadlessClient"); // always start windowed BOOL ignorePixelDepth = gSavedSettings.getBOOL("IgnorePixelDepth"); @@ -2676,28 +2677,25 @@ bool LLAppViewer::initWindow() gViewerWindow->mWindow->maximize(); } - if (!gNoRender) + // + // Initialize GL stuff + // + + if (mForceGraphicsDetail) { - // - // Initialize GL stuff - // + LLFeatureManager::getInstance()->setGraphicsLevel(gSavedSettings.getU32("RenderQualityPerformance"), false); + } + + // Set this flag in case we crash while initializing GL + gSavedSettings.setBOOL("RenderInitError", TRUE); + gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE ); - if (mForceGraphicsDetail) - { - LLFeatureManager::getInstance()->setGraphicsLevel(gSavedSettings.getU32("RenderQualityPerformance"), false); - } - - // Set this flag in case we crash while initializing GL - gSavedSettings.setBOOL("RenderInitError", TRUE); - gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE ); - - gPipeline.init(); - stop_glerror(); - gViewerWindow->initGLDefaults(); + gPipeline.init(); + stop_glerror(); + gViewerWindow->initGLDefaults(); - gSavedSettings.setBOOL("RenderInitError", FALSE); - gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE ); - } + gSavedSettings.setBOOL("RenderInitError", FALSE); + gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE ); //If we have a startup crash, it's usually near GL initialization, so simulate that. if(gCrashOnStartup) @@ -2739,12 +2737,9 @@ void LLAppViewer::cleanupSavedSettings() gSavedSettings.setBOOL("ShowObjectUpdates", gShowObjectUpdates); - if (!gNoRender) + if (gDebugView) { - if (gDebugView) - { - gSavedSettings.setBOOL("ShowDebugConsole", gDebugView->mDebugConsolep->getVisible()); - } + gSavedSettings.setBOOL("ShowDebugConsole", gDebugView->mDebugConsolep->getVisible()); } // save window position if not maximized @@ -3711,7 +3706,7 @@ void LLAppViewer::badNetworkHandler() // is destroyed. void LLAppViewer::saveFinalSnapshot() { - if (!mSavedFinalSnapshot && !gNoRender) + if (!mSavedFinalSnapshot) { gSavedSettings.setVector3d("FocusPosOnLogout", gAgentCamera.calcFocusPositionTargetGlobal()); gSavedSettings.setVector3d("CameraPosOnLogout", gAgentCamera.calcCameraPositionTargetGlobal()); @@ -4115,34 +4110,31 @@ void LLAppViewer::idle() // // Update weather effects // - if (!gNoRender) - { - LLWorld::getInstance()->updateClouds(gFrameDTClamped); - gSky.propagateHeavenlyBodies(gFrameDTClamped); // moves sun, moon, and planets + LLWorld::getInstance()->updateClouds(gFrameDTClamped); + gSky.propagateHeavenlyBodies(gFrameDTClamped); // moves sun, moon, and planets - // Update wind vector - LLVector3 wind_position_region; - static LLVector3 average_wind; + // Update wind vector + LLVector3 wind_position_region; + static LLVector3 average_wind; - LLViewerRegion *regionp; - regionp = LLWorld::getInstance()->resolveRegionGlobal(wind_position_region, gAgent.getPositionGlobal()); // puts agent's local coords into wind_position - if (regionp) - { - gWindVec = regionp->mWind.getVelocity(wind_position_region); + LLViewerRegion *regionp; + regionp = LLWorld::getInstance()->resolveRegionGlobal(wind_position_region, gAgent.getPositionGlobal()); // puts agent's local coords into wind_position + if (regionp) + { + gWindVec = regionp->mWind.getVelocity(wind_position_region); - // Compute average wind and use to drive motion of water - - average_wind = regionp->mWind.getAverage(); - F32 cloud_density = regionp->mCloudLayer.getDensityRegion(wind_position_region); - - gSky.setCloudDensityAtAgent(cloud_density); - gSky.setWind(average_wind); - //LLVOWater::setWind(average_wind); - } - else - { - gWindVec.setVec(0.0f, 0.0f, 0.0f); - } + // Compute average wind and use to drive motion of water + + average_wind = regionp->mWind.getAverage(); + F32 cloud_density = regionp->mCloudLayer.getDensityRegion(wind_position_region); + + gSky.setCloudDensityAtAgent(cloud_density); + gSky.setWind(average_wind); + //LLVOWater::setWind(average_wind); + } + else + { + gWindVec.setVec(0.0f, 0.0f, 0.0f); } ////////////////////////////////////// @@ -4151,13 +4143,10 @@ void LLAppViewer::idle() // Here, particles are updated and drawables are moved. // - if (!gNoRender) - { - LLFastTimer t(FTM_WORLD_UPDATE); - gPipeline.updateMove(); + LLFastTimer t(FTM_WORLD_UPDATE); + gPipeline.updateMove(); - LLWorld::getInstance()->updateParticles(); - } + LLWorld::getInstance()->updateParticles(); if (LLViewerJoystick::getInstance()->getOverrideCamera()) { @@ -4523,12 +4512,9 @@ void LLAppViewer::disconnectViewer() gSavedSettings.setBOOL("FlyingAtExit", gAgent.getFlying() ); // Un-minimize all windows so they don't get saved minimized - if (!gNoRender) + if (gFloaterView) { - if (gFloaterView) - { - gFloaterView->restoreAll(); - } + gFloaterView->restoreAll(); } if (LLSelectMgr::getInstance()) diff --git a/indra/newview/llfloaterbump.cpp b/indra/newview/llfloaterbump.cpp index 61cf4dad93..eeb81085bb 100644 --- a/indra/newview/llfloaterbump.cpp +++ b/indra/newview/llfloaterbump.cpp @@ -38,13 +38,11 @@ ///---------------------------------------------------------------------------- /// Class LLFloaterBump ///---------------------------------------------------------------------------- -extern BOOL gNoRender; // Default constructor LLFloaterBump::LLFloaterBump(const LLSD& key) : LLFloater(key) { - if(gNoRender) return; } diff --git a/indra/newview/llhudeffectlookat.cpp b/indra/newview/llhudeffectlookat.cpp index 8cf7d23f88..72f64752d6 100644 --- a/indra/newview/llhudeffectlookat.cpp +++ b/indra/newview/llhudeffectlookat.cpp @@ -587,11 +587,6 @@ void LLHUDEffectLookAt::update() */ bool LLHUDEffectLookAt::calcTargetPosition() { - if (gNoRender) - { - return false; - } - LLViewerObject *target_obj = (LLViewerObject *)mTargetObject; LLVector3 local_offset; diff --git a/indra/newview/llhudmanager.cpp b/indra/newview/llhudmanager.cpp index 5f3178b955..8f14b53db0 100644 --- a/indra/newview/llhudmanager.cpp +++ b/indra/newview/llhudmanager.cpp @@ -38,8 +38,6 @@ #include "llviewercontrol.h" #include "llviewerobjectlist.h" -extern BOOL gNoRender; - // These are loaded from saved settings. LLColor4 LLHUDManager::sParentColor; LLColor4 LLHUDManager::sChildColor; @@ -150,11 +148,6 @@ LLHUDEffect *LLHUDManager::createViewerEffect(const U8 type, BOOL send_to_sim, B //static void LLHUDManager::processViewerEffect(LLMessageSystem *mesgsys, void **user_data) { - if (gNoRender) - { - return; - } - LLHUDEffect *effectp = NULL; LLUUID effect_id; U8 effect_type = 0; diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 9623554200..060ad17c02 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -3174,10 +3174,6 @@ public: //just like a normal IM //this is just replicated code from process_improved_im //and should really go in it's own function -jwolk - if (gNoRender) - { - return; - } LLChat chat; std::string message = message_params["message"].asString(); @@ -3254,11 +3250,6 @@ public: } //end if invitation has instant message else if ( input["body"].has("voice") ) { - if (gNoRender) - { - return; - } - if(!LLVoiceClient::getInstance()->voiceEnabled() || !LLVoiceClient::getInstance()->isVoiceWorking()) { // Don't display voice invites unless the user has voice enabled. diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index da891d1c51..81f4dd802a 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -516,17 +516,15 @@ BOOL LLSelectMgr::removeObjectFromSelections(const LLUUID &id) { BOOL object_found = FALSE; LLTool *tool = NULL; - if (!gNoRender) - { - tool = LLToolMgr::getInstance()->getCurrentTool(); - // It's possible that the tool is editing an object that is not selected - LLViewerObject* tool_editing_object = tool->getEditingObject(); - if( tool_editing_object && tool_editing_object->mID == id) - { - tool->stopEditing(); - object_found = TRUE; - } + tool = LLToolMgr::getInstance()->getCurrentTool(); + + // It's possible that the tool is editing an object that is not selected + LLViewerObject* tool_editing_object = tool->getEditingObject(); + if( tool_editing_object && tool_editing_object->mID == id) + { + tool->stopEditing(); + object_found = TRUE; } // Iterate through selected objects list and kill the object diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 0eac7d5e2a..34a79bcde3 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -354,11 +354,8 @@ bool idle_startup() LLStringUtil::setLocale (LLTrans::getString(system)); - if (!gNoRender) - { - //note: Removing this line will cause incorrect button size in the login screen. -- bao. - gTextureList.updateImages(0.01f) ; - } + //note: Removing this line will cause incorrect button size in the login screen. -- bao. + gTextureList.updateImages(0.01f) ; if ( STATE_FIRST == LLStartUp::getStartupState() ) { @@ -673,6 +670,7 @@ bool idle_startup() { gUserCredential = gLoginHandler.initializeLoginInfo(); } + // Previous initialĂzeLoginInfo may have generated user credentials. Re-check them. if (gUserCredential.isNull()) { show_connect_box = TRUE; @@ -731,9 +729,9 @@ bool idle_startup() { gUserCredential = gLoginHandler.initializeLoginInfo(); } - if (gNoRender) + if (gHeadlessClient) { - LL_ERRS("AppInit") << "Need to autologin or use command line with norender!" << LL_ENDL; + LL_WARNS("AppInit") << "Waiting at connection box in headless client. Did you mean to add autologin params?" << LL_ENDL; } // Make sure the process dialog doesn't hide things gViewerWindow->setShowProgress(FALSE); @@ -941,10 +939,7 @@ bool idle_startup() gViewerWindow->getWindow()->setCursor(UI_CURSOR_WAIT); - if (!gNoRender) - { - init_start_screen(agent_location_id); - } + init_start_screen(agent_location_id); // Display the startup progress bar. gViewerWindow->setShowProgress(TRUE); @@ -975,11 +970,6 @@ bool idle_startup() // Setting initial values... LLLoginInstance* login = LLLoginInstance::getInstance(); login->setNotificationsInterface(LLNotifications::getInstance()); - if(gNoRender) - { - // HACK, skip optional updates if you're running drones - login->setSkipOptionalUpdate(true); - } login->setSerialNumber(LLAppViewer::instance()->getSerialNumber()); login->setLastExecEvent(gLastExecEvent); @@ -1265,14 +1255,11 @@ bool idle_startup() gLoginMenuBarView->setVisible( FALSE ); gLoginMenuBarView->setEnabled( FALSE ); - if (!gNoRender) - { - // direct logging to the debug console's line buffer - LLError::logToFixedBuffer(gDebugView->mDebugConsolep); - - // set initial visibility of debug console - gDebugView->mDebugConsolep->setVisible(gSavedSettings.getBOOL("ShowDebugConsole")); - } + // direct logging to the debug console's line buffer + LLError::logToFixedBuffer(gDebugView->mDebugConsolep); + + // set initial visibility of debug console + gDebugView->mDebugConsolep->setVisible(gSavedSettings.getBOOL("ShowDebugConsole")); // // Set message handlers @@ -1300,7 +1287,7 @@ bool idle_startup() //gCacheName is required for nearby chat history loading //so I just moved nearby history loading a few states further - if (!gNoRender && gSavedPerAccountSettings.getBOOL("LogShowHistory")) + if (gSavedPerAccountSettings.getBOOL("LogShowHistory")) { LLNearbyChat* nearby_chat = LLNearbyChat::getInstance(); if (nearby_chat) nearby_chat->loadHistory(); @@ -1352,18 +1339,15 @@ bool idle_startup() gAgentCamera.resetCamera(); // Initialize global class data needed for surfaces (i.e. textures) - if (!gNoRender) - { - LL_DEBUGS("AppInit") << "Initializing sky..." << LL_ENDL; - // Initialize all of the viewer object classes for the first time (doing things like texture fetches. - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); + LL_DEBUGS("AppInit") << "Initializing sky..." << LL_ENDL; + // Initialize all of the viewer object classes for the first time (doing things like texture fetches. + LLGLState::checkStates(); + LLGLState::checkTextureChannels(); - gSky.init(initial_sun_direction); + gSky.init(initial_sun_direction); - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - } + LLGLState::checkStates(); + LLGLState::checkTextureChannels(); LL_DEBUGS("AppInit") << "Decoding images..." << LL_ENDL; // For all images pre-loaded into viewer cache, decode them. @@ -1726,46 +1710,43 @@ bool idle_startup() LLUIColorTable::instance().saveUserSettings(); }; - if (!gNoRender) - { - // JC: Initializing audio requests many sounds for download. - init_audio(); - - // JC: Initialize "active" gestures. This may also trigger - // many gesture downloads, if this is the user's first - // time on this machine or -purge has been run. - LLSD gesture_options - = LLLoginInstance::getInstance()->getResponse("gestures"); - if (gesture_options.isDefined()) + // JC: Initializing audio requests many sounds for download. + init_audio(); + + // JC: Initialize "active" gestures. This may also trigger + // many gesture downloads, if this is the user's first + // time on this machine or -purge has been run. + LLSD gesture_options + = LLLoginInstance::getInstance()->getResponse("gestures"); + if (gesture_options.isDefined()) + { + LL_DEBUGS("AppInit") << "Gesture Manager loading " << gesture_options.size() + << LL_ENDL; + uuid_vec_t item_ids; + for(LLSD::array_const_iterator resp_it = gesture_options.beginArray(), + end = gesture_options.endArray(); resp_it != end; ++resp_it) { - LL_DEBUGS("AppInit") << "Gesture Manager loading " << gesture_options.size() - << LL_ENDL; - uuid_vec_t item_ids; - for(LLSD::array_const_iterator resp_it = gesture_options.beginArray(), - end = gesture_options.endArray(); resp_it != end; ++resp_it) - { - // If the id is not specifed in the LLSD, - // the LLSD operator[]() will return a null LLUUID. - LLUUID item_id = (*resp_it)["item_id"]; - LLUUID asset_id = (*resp_it)["asset_id"]; + // If the id is not specifed in the LLSD, + // the LLSD operator[]() will return a null LLUUID. + LLUUID item_id = (*resp_it)["item_id"]; + LLUUID asset_id = (*resp_it)["asset_id"]; - if (item_id.notNull() && asset_id.notNull()) - { - // Could schedule and delay these for later. - const BOOL no_inform_server = FALSE; - const BOOL no_deactivate_similar = FALSE; - LLGestureMgr::instance().activateGestureWithAsset(item_id, asset_id, - no_inform_server, - no_deactivate_similar); - // We need to fetch the inventory items for these gestures - // so we have the names to populate the UI. - item_ids.push_back(item_id); - } + if (item_id.notNull() && asset_id.notNull()) + { + // Could schedule and delay these for later. + const BOOL no_inform_server = FALSE; + const BOOL no_deactivate_similar = FALSE; + LLGestureMgr::instance().activateGestureWithAsset(item_id, asset_id, + no_inform_server, + no_deactivate_similar); + // We need to fetch the inventory items for these gestures + // so we have the names to populate the UI. + item_ids.push_back(item_id); } - // no need to add gesture to inventory observer, it's already made in constructor - LLGestureMgr::instance().setFetchIDs(item_ids); - LLGestureMgr::instance().startFetch(); } + // no need to add gesture to inventory observer, it's already made in constructor + LLGestureMgr::instance().setFetchIDs(item_ids); + LLGestureMgr::instance().startFetch(); } gDisplaySwapBuffers = TRUE; @@ -1786,13 +1767,6 @@ bool idle_startup() // JC - 7/20/2002 gViewerWindow->sendShapeToSim(); - - // Ignore stipend information for now. Money history is on the web site. - // if needed, show the L$ history window - //if (stipend_since_login && !gNoRender) - //{ - //} - // The reason we show the alert is because we want to // reduce confusion for when you log in and your provided // location is not your expected location. So, if this is @@ -3218,7 +3192,7 @@ bool process_login_success_response() void transition_back_to_login_panel(const std::string& emsg) { - if (gNoRender) + if (gHeadlessClient && gSavedSettings.getBOOL("AutoLogin")) { LL_WARNS("AppInit") << "Failed to login!" << LL_ENDL; LL_WARNS("AppInit") << emsg << LL_ENDL; diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp index 6fc8153b77..bccabe21a8 100644 --- a/indra/newview/llsurface.cpp +++ b/indra/newview/llsurface.cpp @@ -340,11 +340,6 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction) S32 i; LLSurfacePatch *patchp, *neighbor_patchp; - if (gNoRender) - { - return; - } - mNeighbors[direction] = neighborp; neighborp->mNeighbors[gDirOpposite[direction]] = this; diff --git a/indra/newview/lltexturestats.cpp b/indra/newview/lltexturestats.cpp index dd35d5cf83..f820ae65df 100644 --- a/indra/newview/lltexturestats.cpp +++ b/indra/newview/lltexturestats.cpp @@ -37,7 +37,7 @@ void send_texture_stats_to_sim(const LLSD &texture_stats) { LLSD texture_stats_report; // Only send stats if the agent is connected to a region. - if (!gAgent.getRegion() || gNoRender) + if (!gAgent.getRegion()) { return; } diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index ddb11829df..3e13537113 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -115,8 +115,7 @@ void display_startup() { if ( !gViewerWindow->getActive() || !gViewerWindow->mWindow->getVisible() - || gViewerWindow->mWindow->getMinimized() - || gNoRender ) + || gViewerWindow->mWindow->getMinimized() ) { return; } @@ -294,7 +293,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) // Logic for forcing window updates if we're in drone mode. // - if (gNoRender) + // *TODO: Investigate running display() during gHeadlessClient. See if this early exit is needed DK 2011-02-18 + if (gHeadlessClient) { #if LL_WINDOWS static F32 last_update_time = 0.f; diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 6fc85a3944..7e8fbf7345 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -343,12 +343,6 @@ void process_layer_data(LLMessageSystem *mesgsys, void **user_data) { LLViewerRegion *regionp = LLWorld::getInstance()->getRegion(mesgsys->getSender()); - if (!regionp || gNoRender) - { - return; - } - - S32 size; S8 type; @@ -2163,10 +2157,6 @@ void god_message_name_cb(const LLAvatarName& av_name, LLChat chat, std::string m void process_improved_im(LLMessageSystem *msg, void **user_data) { - if (gNoRender) - { - return; - } LLUUID from_id; BOOL from_group; LLUUID to_id; @@ -3936,7 +3926,14 @@ void send_agent_update(BOOL force_send, BOOL send_reliable) // LBUTTON and ML_LBUTTON so that using the camera (alt-key) doesn't // trigger a control event. U32 control_flags = gAgent.getControlFlags(); - MASK key_mask = gKeyboard->currentMask(TRUE); + + MASK key_mask = MASK_NONE; + // *TODO: Create a headless gKeyboard DK 2011-02-18 + if (gKeyboard) + { + key_mask = gKeyboard->currentMask(TRUE); + } + if (key_mask & MASK_ALT || key_mask & MASK_CONTROL) { control_flags &= ~( AGENT_CONTROL_LBUTTON_DOWN | @@ -4255,7 +4252,7 @@ void process_time_synch(LLMessageSystem *mesgsys, void **user_data) gSky.setSunPhase(phase); gSky.setSunTargetDirection(sun_direction, sun_ang_velocity); - if (!gNoRender && !(gSavedSettings.getBOOL("SkyOverrideSimSunPosition") || gSky.getOverrideSun())) + if ( !(gSavedSettings.getBOOL("SkyOverrideSimSunPosition") || gSky.getOverrideSun()) ) { gSky.setSunDirection(sun_direction, sun_ang_velocity); } @@ -5517,21 +5514,12 @@ time_t gLastDisplayedTime = 0; void handle_show_mean_events(void *) { - if (gNoRender) - { - return; - } LLFloaterReg::showInstance("bumps"); //LLFloaterBump::showInstance(); } void mean_name_callback(const LLUUID &id, const std::string& full_name, bool is_group) { - if (gNoRender) - { - return; - } - static const U32 max_collision_list_size = 20; if (gMeanCollisionList.size() > max_collision_list_size) { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 090d3cadd4..c60bdf31c9 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -469,11 +469,6 @@ void LLViewerObject::initVOClasses() // Initialized shared class stuff first. LLVOAvatar::initClass(); LLVOTree::initClass(); - if (gNoRender) - { - // Don't init anything else in drone mode - return; - } llinfos << "Viewer Object size: " << sizeof(LLViewerObject) << llendl; LLVOGrass::initClass(); LLVOWater::initClass(); @@ -2151,12 +2146,6 @@ BOOL LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) } } - if (gNoRender) - { - // Skip drawable stuff if not rendering. - return TRUE; - } - updateDrawable(FALSE); return TRUE; diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 970cc2e2a7..d112b3490e 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -636,19 +636,16 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent) } - if (!gNoRender) + // Slam priorities for textures that we care about (hovered, selected, and focused) + // Hovered + // Assumes only one level deep of parenting + LLSelectNode* nodep = LLSelectMgr::instance().getHoverNode(); + if (nodep) { - // Slam priorities for textures that we care about (hovered, selected, and focused) - // Hovered - // Assumes only one level deep of parenting - LLSelectNode* nodep = LLSelectMgr::instance().getHoverNode(); - if (nodep) + objectp = nodep->getObject(); + if (objectp) { - objectp = nodep->getObject(); - if (objectp) - { - objectp->boostTexturePriority(); - } + objectp->boostTexturePriority(); } } @@ -1099,7 +1096,7 @@ void LLViewerObjectList::shiftObjects(const LLVector3 &offset) // We need to update many object caches, I'll document this more as I dig through the code // cleaning things out... - if (gNoRender || 0 == offset.magVecSquared()) + if (0 == offset.magVecSquared()) { return; } @@ -1505,11 +1502,6 @@ void LLViewerObjectList::orphanize(LLViewerObject *childp, U32 parent_id, U32 ip void LLViewerObjectList::findOrphans(LLViewerObject* objectp, U32 ip, U32 port) { - if (gNoRender) - { - return; - } - if (objectp->isDead()) { llwarns << "Trying to find orphans for dead obj " << objectp->mID diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index fccd1156d3..e84e4a859a 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -1383,11 +1383,6 @@ void LLViewerParcelMgr::setHoverParcel(const LLVector3d& pos) // static void LLViewerParcelMgr::processParcelOverlay(LLMessageSystem *msg, void **user) { - if (gNoRender) - { - return; - } - // Extract the packed overlay information S32 packed_overlay_size = msg->getSizeFast(_PREHASH_ParcelData, _PREHASH_Data); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 23b7b921b8..8e0373c79e 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -72,8 +72,6 @@ #pragma warning(disable:4355) #endif -extern BOOL gNoRender; - const F32 WATER_TEXTURE_SCALE = 8.f; // Number of times to repeat the water texture across a region const S16 MAX_MAP_DIST = 10; @@ -234,28 +232,19 @@ LLViewerRegion::LLViewerRegion(const U64 &handle, updateRenderMatrix(); mLandp = new LLSurface('l', NULL); - if (!gNoRender) - { - // Create the composition layer for the surface - mCompositionp = new LLVLComposition(mLandp, grids_per_region_edge, region_width_meters/grids_per_region_edge); - mCompositionp->setSurface(mLandp); - - // Create the surfaces - mLandp->setRegion(this); - mLandp->create(grids_per_region_edge, - grids_per_patch_edge, - mOriginGlobal, - mWidth); - } - if (!gNoRender) - { - mParcelOverlay = new LLViewerParcelOverlay(this, region_width_meters); - } - else - { - mParcelOverlay = NULL; - } + // Create the composition layer for the surface + mCompositionp = new LLVLComposition(mLandp, grids_per_region_edge, region_width_meters/grids_per_region_edge); + mCompositionp->setSurface(mLandp); + + // Create the surfaces + mLandp->setRegion(this); + mLandp->create(grids_per_region_edge, + grids_per_patch_edge, + mOriginGlobal, + mWidth); + + mParcelOverlay = new LLViewerParcelOverlay(this, region_width_meters); setOriginGlobal(from_region_handle(handle)); calculateCenterGlobal(); diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 546ee9a334..e29370dfa4 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -711,7 +711,7 @@ void send_stats() // but that day is not today. // Only send stats if the agent is connected to a region. - if (!gAgent.getRegion() || gNoRender) + if (!gAgent.getRegion()) { return; } diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index cd16b15e3e..16e73da79b 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -1415,61 +1415,59 @@ BOOL LLViewerFetchedTexture::createTexture(S32 usename/*= 0*/) // mRawImage->getWidth(), mRawImage->getHeight(),mRawImage->getDataSize()) // << mID.getString() << llendl; BOOL res = TRUE; - if (!gNoRender) - { - // store original size only for locally-sourced images - if (mUrl.compare(0, 7, "file://") == 0) - { - mOrigWidth = mRawImage->getWidth(); - mOrigHeight = mRawImage->getHeight(); - // leave black border, do not scale image content - mRawImage->expandToPowerOfTwo(MAX_IMAGE_SIZE, FALSE); - - mFullWidth = mRawImage->getWidth(); - mFullHeight = mRawImage->getHeight(); - setTexelsPerImage(); - } - else - { - mOrigWidth = mFullWidth; - mOrigHeight = mFullHeight; - } + // store original size only for locally-sourced images + if (mUrl.compare(0, 7, "file://") == 0) + { + mOrigWidth = mRawImage->getWidth(); + mOrigHeight = mRawImage->getHeight(); - bool size_okay = true; + // leave black border, do not scale image content + mRawImage->expandToPowerOfTwo(MAX_IMAGE_SIZE, FALSE); - U32 raw_width = mRawImage->getWidth() << mRawDiscardLevel; - U32 raw_height = mRawImage->getHeight() << mRawDiscardLevel; - if( raw_width > MAX_IMAGE_SIZE || raw_height > MAX_IMAGE_SIZE ) - { - llinfos << "Width or height is greater than " << MAX_IMAGE_SIZE << ": (" << raw_width << "," << raw_height << ")" << llendl; - size_okay = false; - } - - if (!LLImageGL::checkSize(mRawImage->getWidth(), mRawImage->getHeight())) - { - // A non power-of-two image was uploaded (through a non standard client) - llinfos << "Non power of two width or height: (" << mRawImage->getWidth() << "," << mRawImage->getHeight() << ")" << llendl; - size_okay = false; - } - - if( !size_okay ) - { - // An inappropriately-sized image was uploaded (through a non standard client) - // We treat these images as missing assets which causes them to - // be renderd as 'missing image' and to stop requesting data - setIsMissingAsset(); - destroyRawImage(); - return FALSE; - } - - if(!(res = insertToAtlas())) - { - res = mGLTexturep->createGLTexture(mRawDiscardLevel, mRawImage, usename, TRUE, mBoostLevel); - resetFaceAtlas() ; - } - setActive() ; + mFullWidth = mRawImage->getWidth(); + mFullHeight = mRawImage->getHeight(); + setTexelsPerImage(); + } + else + { + mOrigWidth = mFullWidth; + mOrigHeight = mFullHeight; + } + + bool size_okay = true; + + U32 raw_width = mRawImage->getWidth() << mRawDiscardLevel; + U32 raw_height = mRawImage->getHeight() << mRawDiscardLevel; + if( raw_width > MAX_IMAGE_SIZE || raw_height > MAX_IMAGE_SIZE ) + { + llinfos << "Width or height is greater than " << MAX_IMAGE_SIZE << ": (" << raw_width << "," << raw_height << ")" << llendl; + size_okay = false; + } + + if (!LLImageGL::checkSize(mRawImage->getWidth(), mRawImage->getHeight())) + { + // A non power-of-two image was uploaded (through a non standard client) + llinfos << "Non power of two width or height: (" << mRawImage->getWidth() << "," << mRawImage->getHeight() << ")" << llendl; + size_okay = false; + } + + if( !size_okay ) + { + // An inappropriately-sized image was uploaded (through a non standard client) + // We treat these images as missing assets which causes them to + // be renderd as 'missing image' and to stop requesting data + setIsMissingAsset(); + destroyRawImage(); + return FALSE; + } + + if(!(res = insertToAtlas())) + { + res = mGLTexturep->createGLTexture(mRawDiscardLevel, mRawImage, usename, TRUE, mBoostLevel); + resetFaceAtlas() ; } + setActive() ; if (!mForceToSaveRawImage) { diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 10126219f8..06f6ff23c2 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -91,11 +91,6 @@ void LLViewerTextureList::init() sNumImages = 0; mMaxResidentTexMemInMegaBytes = 0; mMaxTotalTextureMemInMegaBytes = 0 ; - if (gNoRender) - { - // Don't initialize GL stuff if we're not rendering. - return; - } mUpdateStats = TRUE; @@ -345,13 +340,6 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromUrl(const std::string& LLGLenum primary_format, const LLUUID& force_id) { - if (gNoRender) - { - // Never mind that this ignores image_set_id; - // getImage() will handle that later. - return LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, TRUE, LLViewerTexture::BOOST_UI); - } - // generate UUID based on hash of filename LLUUID new_id; if (force_id.notNull()) @@ -741,7 +729,7 @@ static LLFastTimer::DeclareTimer FTM_IMAGE_CREATE("Create Images"); F32 LLViewerTextureList::updateImagesCreateTextures(F32 max_time) { - if (gNoRender || gGLManager.mIsDisabled) return 0.0f; + if (gGLManager.mIsDisabled) return 0.0f; // // Create GL textures for all textures that need them (images which have been @@ -876,7 +864,6 @@ void LLViewerTextureList::updateImagesUpdateStats() void LLViewerTextureList::decodeAllImages(F32 max_time) { LLTimer timer; - if(gNoRender) return; // Update texture stats and priorities std::vector > image_list; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 166b110412..435da72622 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1225,8 +1225,9 @@ void LLViewerWindow::handleMenuSelect(LLWindow *window, S32 menu_item) BOOL LLViewerWindow::handlePaint(LLWindow *window, S32 x, S32 y, S32 width, S32 height) { + // *TODO: Enable similar information output for other platforms? DK 2011-02-18 #if LL_WINDOWS - if (gNoRender) + if (gHeadlessClient) { HWND window_handle = (HWND)window->getPlatformWindow(); PAINTSTRUCT ps; @@ -1256,7 +1257,7 @@ BOOL LLViewerWindow::handlePaint(LLWindow *window, S32 x, S32 y, S32 width, S len = temp_str.length(); TextOutA(hdc, 0, 25, temp_str.c_str(), len); - TextOutA(hdc, 0, 50, "Set \"DisableRendering FALSE\" in settings.ini file to reenable", 61); + TextOutA(hdc, 0, 50, "Set \"HeadlessClient FALSE\" in settings.ini file to reenable", 61); EndPaint(window_handle, &ps); return TRUE; } @@ -1404,9 +1405,9 @@ LLViewerWindow::LLViewerWindow( mWindow = LLWindowManager::createWindow(this, title, name, x, y, width, height, 0, fullscreen, - gNoRender, + gHeadlessClient, gSavedSettings.getBOOL("DisableVerticalSync"), - !gNoRender, + !gHeadlessClient, ignore_pixel_depth, gSavedSettings.getBOOL("RenderUseFBO") ? 0 : gSavedSettings.getU32("RenderFSAASamples")); //don't use window level anti-aliasing if FBOs are enabled @@ -1862,11 +1863,8 @@ void LLViewerWindow::shutdownGL() LLVertexBuffer::cleanupClass(); llinfos << "Stopping GL during shutdown" << llendl; - if (!gNoRender) - { - stopGL(FALSE); - stop_glerror(); - } + stopGL(FALSE); + stop_glerror(); gGL.shutdown(); } @@ -1930,11 +1928,6 @@ void LLViewerWindow::reshape(S32 width, S32 height) // may have been destructed. if (!LLApp::isExiting()) { - if (gNoRender) - { - return; - } - gWindowResized = TRUE; // update our window rectangle @@ -2575,11 +2568,12 @@ void LLViewerWindow::updateUI() S32 x = mCurrentMousePoint.mX; S32 y = mCurrentMousePoint.mY; - MASK mask = gKeyboard->currentMask(TRUE); - if (gNoRender) + MASK mask = MASK_NONE; + // *TODO: Create a headless gKeyboard DK 2011-02-18 + if (gKeyboard) { - return; + mask = gKeyboard->currentMask(TRUE); } if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST)) @@ -3410,11 +3404,6 @@ BOOL LLViewerWindow::clickPointOnSurfaceGlobal(const S32 x, const S32 y, LLViewe void LLViewerWindow::pickAsync(S32 x, S32 y_from_bot, MASK mask, void (*callback)(const LLPickInfo& info), BOOL pick_transparent) { - if (gNoRender) - { - return; - } - BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); if (in_build_mode || LLDrawPoolAlpha::sShowDebugAlpha) { @@ -3450,11 +3439,6 @@ void LLViewerWindow::schedulePick(LLPickInfo& pick_info) void LLViewerWindow::performPick() { - if (gNoRender) - { - return; - } - if (!mPicks.empty()) { std::vector::iterator pick_it; @@ -3486,11 +3470,6 @@ void LLViewerWindow::returnEmptyPicks() // Performs the GL object/land pick. LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_transparent) { - if (gNoRender) - { - return LLPickInfo(); - } - BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); if (in_build_mode || LLDrawPoolAlpha::sShowDebugAlpha) { @@ -3500,7 +3479,13 @@ LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_trans } // shortcut queueing in mPicks and just update mLastPick in place - mLastPick = LLPickInfo(LLCoordGL(x, y_from_bot), gKeyboard->currentMask(TRUE), pick_transparent, TRUE, NULL); + MASK key_mask = MASK_NONE; + // *TODO: Create a headless gKeyboard DK 2011-02-18 + if (gKeyboard) + { + key_mask = gKeyboard->currentMask(TRUE); + } + mLastPick = LLPickInfo(LLCoordGL(x, y_from_bot), key_mask, pick_transparent, TRUE, NULL); mLastPick.fetchResults(); return mLastPick; @@ -4774,12 +4759,9 @@ bool LLViewerWindow::onAlert(const LLSD& notify) { LLNotificationPtr notification = LLNotifications::instance().find(notify["id"].asUUID()); - if (gNoRender) + if (gHeadlessClient) { llinfos << "Alert: " << notification->getName() << llendl; - notification->respond(LLSD::emptyMap()); - LLNotifications::instance().cancel(notification); - return false; } // If we're in mouselook, the mouse is hidden and so the user can't click diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index fd89044995..26b595c923 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -1295,18 +1295,8 @@ void LLVOAvatar::initInstance(void) } - if (gNoRender) - { - return; - } - buildCharacter(); - if (gNoRender) - { - return; - } - // preload specific motions here createMotion( ANIM_AGENT_CUSTOMIZE); createMotion( ANIM_AGENT_CUSTOMIZE_DONE); @@ -1747,12 +1737,6 @@ void LLVOAvatar::buildCharacter() BOOL status = loadAvatar(); stop_glerror(); - if (gNoRender) - { - // Still want to load the avatar skeleton so visual parameters work. - return; - } - // gPrintMessagesThisFrame = TRUE; lldebugs << "Avatar load took " << timer.getElapsedTimeF32() << " seconds." << llendl; @@ -2223,7 +2207,7 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) setPixelAreaAndAngle(gAgent); // force asynchronous drawable update - if(mDrawable.notNull() && !gNoRender) + if(mDrawable.notNull()) { LLFastTimer t(FTM_JOINT_UPDATE); @@ -2280,11 +2264,6 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) LLVector3 root_pos_last = mRoot.getWorldPosition(); BOOL detailed_update = updateCharacter(agent); - if (gNoRender) - { - return TRUE; - } - static LLUICachedControl visualizers_in_calls("ShowVoiceVisualizersInCalls", false); bool voice_enabled = (visualizers_in_calls || LLVoiceClient::getInstance()->inProximalChannel()) && LLVoiceClient::getInstance()->getVoiceEnabled(mID); @@ -3257,17 +3236,6 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) } } - if (gNoRender) - { - // Hack if we're running drones... - if (isSelf()) - { - gAgent.setPositionAgent(getPositionAgent()); - } - return FALSE; - } - - LLVector3d root_pos_global; if (!mIsBuilt) @@ -4194,7 +4162,7 @@ void LLVOAvatar::updateTextures() { BOOL render_avatar = TRUE; - if (mIsDummy || gNoRender) + if (mIsDummy) { return; } @@ -4468,11 +4436,6 @@ void LLVOAvatar::processAnimationStateChanges() { LLMemType mt(LLMemType::MTYPE_AVATAR); - if (gNoRender) - { - return; - } - if ( isAnyAnimationSignaled(AGENT_WALK_ANIMS, NUM_AGENT_WALK_ANIMS) ) { startMotion(ANIM_AGENT_WALK_ADJUST); @@ -4867,7 +4830,7 @@ void LLVOAvatar::getGround(const LLVector3 &in_pos_agent, LLVector3 &out_pos_age LLVector3d z_vec(0.0f, 0.0f, 1.0f); LLVector3d p0_global, p1_global; - if (gNoRender || mIsDummy) + if (mIsDummy) { outNorm.setVec(z_vec); out_pos_agent = in_pos_agent; @@ -5439,11 +5402,6 @@ BOOL LLVOAvatar::loadLayersets() //----------------------------------------------------------------------------- void LLVOAvatar::updateVisualParams() { - if (gNoRender) - { - return; - } - setSex( (getVisualParamWeight( "male" ) > 0.5f) ? SEX_MALE : SEX_FEMALE ); LLCharacter::updateVisualParams(); @@ -6174,8 +6132,6 @@ LLMotion* LLVOAvatar::findMotion(const LLUUID& id) const void LLVOAvatar::updateMeshTextures() { // llinfos << "updateMeshTextures" << llendl; - if (gNoRender) return; - // if user has never specified a texture, assign the default for (U32 i=0; i < getNumTEs(); i++) { @@ -6831,11 +6787,6 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) } } - if (gNoRender) - { - return; - } - ESex old_sex = getSex(); // llinfos << "LLVOAvatar::processAvatarAppearance()" << llendl; diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 5f9e343907..c74b60f7e7 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -2506,10 +2506,6 @@ bool LLVOAvatarSelf::sendAppearanceMessage(LLMessageSystem *mesgsys) const //------------------------------------------------------------------------ BOOL LLVOAvatarSelf::needsRenderBeam() { - if (gNoRender) - { - return FALSE; - } LLTool *tool = LLToolMgr::getInstance()->getCurrentTool(); BOOL is_touching_or_grabbing = (tool == LLToolGrab::getInstance() && LLToolGrab::getInstance()->isEditing()); diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 399442e5c4..7f3a8deb47 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -98,11 +98,6 @@ LLWorld::LLWorld() : mEdgeWaterObjects[i] = NULL; } - if (gNoRender) - { - return; - } - LLPointer raw = new LLImageRaw(1,1,4); U8 *default_texture = raw->getData(); *(default_texture++) = MAX_WATER_COLOR.mV[0]; @@ -622,10 +617,7 @@ void LLWorld::updateVisibilities() if (LLViewerCamera::getInstance()->sphereInFrustum(regionp->getCenterAgent(), radius)) { regionp->calculateCameraDistance(); - if (!gNoRender) - { - regionp->getLand().updatePatchVisibilities(gAgent); - } + regionp->getLand().updatePatchVisibilities(gAgent); } else { diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 59b526059b..b4ea455318 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1227,10 +1227,6 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable) U32 LLPipeline::addObject(LLViewerObject *vobj) { LLMemType mt_ao(LLMemType::MTYPE_PIPELINE_ADD_OBJECT); - if (gNoRender) - { - return 0; - } if (gSavedSettings.getBOOL("RenderDelayCreation")) { -- cgit v1.2.3 From 3f5760b5ee4e422e11f3416133b7a4c3a73b1d8c Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Fri, 18 Feb 2011 23:53:38 +0000 Subject: More cleanup from self-reviewing headless client changes --- indra/newview/llappviewer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 25bdaed0c9..0595d6f3c7 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2640,8 +2640,7 @@ bool LLAppViewer::initWindow() LL_INFOS("AppInit") << "Initializing window..." << LL_ENDL; // store setting in a global for easy access and modification - gHeadlessClient = gSavedSettings.getBOOL("DisableRendering") - || gSavedSettings.getBOOL("HeadlessClient"); + gHeadlessClient = gSavedSettings.getBOOL("HeadlessClient"); // always start windowed BOOL ignorePixelDepth = gSavedSettings.getBOOL("IgnorePixelDepth"); -- cgit v1.2.3 From 96cac7c82fcb189a61d514a244b62970e943e4ad Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Fri, 18 Feb 2011 17:01:48 -0800 Subject: Fix up path resolution. --- indra/newview/lluilistener.cpp | 80 +++++++++++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 17 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lluilistener.cpp b/indra/newview/lluilistener.cpp index 22d3b8b219..d02d126cb5 100644 --- a/indra/newview/lluilistener.cpp +++ b/indra/newview/lluilistener.cpp @@ -32,6 +32,7 @@ #include "lluilistener.h" // STL headers // std headers +#include // external library headers // other Linden headers #include "llviewerwindow.h" // to get root view @@ -80,45 +81,90 @@ void LLUIListener::call(const LLSD& event) const } } +// Split string given a single character delimiter. +// Note that this returns empty strings for leading, trailing, and adjacent +// delimiters, such as "/foo/bar//baz/" -> ["", "foo", "bar", "", "baz", "" ] +std::vector split(const std::string& s, char delim) +{ + std::stringstream ss(s); + std::string item; + std::vector items; + while (std::getline(ss, item, delim)) + { + items.push_back(item); + } + return items; +} + +// Walk the LLView tree to resolve a path +// Paths can be discovered using Develop > XUI > Show XUI Paths +// +// A leading "/" indicates the root of the tree is the starting +// position of the search, (otherwise the context node is used) +// +// Adjacent "//" mean that the next level of the search is done +// recursively ("descendant" rather than "child"). +// +// Return values: If no match is found, NULL is returned, +// otherwise the matching LLView* is returned. +// +// Examples: +// +// "/" -> return the root view +// "/foo" -> find "foo" as a direct child of the root +// "foo" -> find "foo" as a direct child of the context node +// "//foo" -> find the first "foo" child anywhere in the tree +// "/foo/bar" -> find "foo" as direct child of the root, and +// "bar" as a direct child of "foo" +// "//foo//bar/baz" -> find the first "foo" anywhere in the +// tree, the first "bar" anywhere under it, and "baz" +// as a direct child of that +// const LLView* resolve_path(const LLView* context, const std::string path) { - std::vector parts; - const std::string delims("/"); - LLStringUtilBase::getTokens(path, parts, delims); + std::vector parts = split(path, '/'); + + if (parts.size() == 0) + { + return context; + } + + std::vector::iterator it = parts.begin(); + + // leading / means "start at root" + if ((*it).length() == 0) + { + context = (LLView*)(gViewerWindow->getRootView()); + it++; + } bool recurse = false; - for (std::vector::iterator it = parts.begin(); - it != parts.end() && context; it++) + for (; it != parts.end() && context; it++) { std::string part = *it; - + if (part.length() == 0) { - // Allow "foo//bar" meaning "descendant named bar" recurse = true; } else { const LLView* found = context->findChildView(part, recurse); if (!found) - { return NULL; - } - else - { - context = found; - } + + context = found; recurse = false; } } - return NULL; + return context; } void LLUIListener::getValue(const LLSD&event) const { - LLSD reply; - + LLSD reply = LLSD::emptyMap(); + const LLView* root = (LLView*)(gViewerWindow->getRootView()); const LLView* view = resolve_path(root, event["path"].asString()); const LLUICtrl* ctrl(dynamic_cast(view)); @@ -132,5 +178,5 @@ void LLUIListener::getValue(const LLSD&event) const // *TODO: ??? return something indicating failure to resolve } - sendReply(reply, event, "reply"); + sendReply(reply, event); } -- cgit v1.2.3 From b5e843abb59ac32cb8cd85dc4b1a43f2bb5c22ee Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Sat, 19 Feb 2011 02:21:51 +0000 Subject: Fix for more instances of dereferencing gKeyboard in headless client. --- indra/newview/llviewerwindow.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 336915ac8c..2d6fabf611 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2973,7 +2973,13 @@ void LLViewerWindow::updateLayout() } // Update the location of the blue box tool popup LLCoordGL select_center_screen; - gFloaterTools->updatePopup( select_center_screen, gKeyboard->currentMask(TRUE) ); + MASK mask = MASK_NONE; + // *TODO: Create a headless gKeyboard DK 2011-02-18 + if (gKeyboard) + { + mask = gKeyboard->currentMask(TRUE); + } + gFloaterTools->updatePopup( select_center_screen, mask ); } else { @@ -3099,7 +3105,13 @@ void LLViewerWindow::updateKeyboardFocus() // sync all floaters with their focus state gFloaterView->highlightFocusedFloater(); gSnapshotFloaterView->highlightFocusedFloater(); - if ((gKeyboard->currentMask(TRUE) & MASK_CONTROL) == 0) + MASK mask = MASK_NONE; + // *TODO: Create a headless gKeyboard DK 2011-02-18 + if (gKeyboard) + { + mask = gKeyboard->currentMask(TRUE); + } + if ((mask & MASK_CONTROL) == 0) { // control key no longer held down, finish cycle mode gFloaterView->setCycleMode(FALSE); -- cgit v1.2.3 From 1362a3e117dadbc5b1de18487314d4af57ce850f Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 22 Feb 2011 20:13:07 -0500 Subject: Move Josh's resolvePath() function to LLUI. Use boost::split_iterator to split LLView pathname on slashes. --- indra/newview/lluilistener.cpp | 89 ++---------------------------------------- 1 file changed, 4 insertions(+), 85 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lluilistener.cpp b/indra/newview/lluilistener.cpp index d02d126cb5..6b2cd71d40 100644 --- a/indra/newview/lluilistener.cpp +++ b/indra/newview/lluilistener.cpp @@ -32,10 +32,9 @@ #include "lluilistener.h" // STL headers // std headers -#include // external library headers // other Linden headers -#include "llviewerwindow.h" // to get root view +#include "llui.h" // getRootView(), resolvePath() #include "lluictrl.h" #include "llerror.h" @@ -55,7 +54,7 @@ LLUIListener::LLUIListener(): "For the UI control identified by the path in [\"path\"], return the control's\n" "current value as [\"value\"] reply.", &LLUIListener::getValue, - LLSD().with("path", LLSD())); + LLSDMap("path", LLSD())("reply", LLSD())); } void LLUIListener::call(const LLSD& event) const @@ -81,92 +80,12 @@ void LLUIListener::call(const LLSD& event) const } } -// Split string given a single character delimiter. -// Note that this returns empty strings for leading, trailing, and adjacent -// delimiters, such as "/foo/bar//baz/" -> ["", "foo", "bar", "", "baz", "" ] -std::vector split(const std::string& s, char delim) -{ - std::stringstream ss(s); - std::string item; - std::vector items; - while (std::getline(ss, item, delim)) - { - items.push_back(item); - } - return items; -} - -// Walk the LLView tree to resolve a path -// Paths can be discovered using Develop > XUI > Show XUI Paths -// -// A leading "/" indicates the root of the tree is the starting -// position of the search, (otherwise the context node is used) -// -// Adjacent "//" mean that the next level of the search is done -// recursively ("descendant" rather than "child"). -// -// Return values: If no match is found, NULL is returned, -// otherwise the matching LLView* is returned. -// -// Examples: -// -// "/" -> return the root view -// "/foo" -> find "foo" as a direct child of the root -// "foo" -> find "foo" as a direct child of the context node -// "//foo" -> find the first "foo" child anywhere in the tree -// "/foo/bar" -> find "foo" as direct child of the root, and -// "bar" as a direct child of "foo" -// "//foo//bar/baz" -> find the first "foo" anywhere in the -// tree, the first "bar" anywhere under it, and "baz" -// as a direct child of that -// -const LLView* resolve_path(const LLView* context, const std::string path) -{ - std::vector parts = split(path, '/'); - - if (parts.size() == 0) - { - return context; - } - - std::vector::iterator it = parts.begin(); - - // leading / means "start at root" - if ((*it).length() == 0) - { - context = (LLView*)(gViewerWindow->getRootView()); - it++; - } - - bool recurse = false; - for (; it != parts.end() && context; it++) - { - std::string part = *it; - - if (part.length() == 0) - { - recurse = true; - } - else - { - const LLView* found = context->findChildView(part, recurse); - if (!found) - return NULL; - - context = found; - recurse = false; - } - } - - return context; -} - void LLUIListener::getValue(const LLSD&event) const { LLSD reply = LLSD::emptyMap(); - const LLView* root = (LLView*)(gViewerWindow->getRootView()); - const LLView* view = resolve_path(root, event["path"].asString()); + const LLView* root = LLUI::getRootView(); + const LLView* view = LLUI::resolvePath(root, event["path"].asString()); const LLUICtrl* ctrl(dynamic_cast(view)); if (ctrl) -- cgit v1.2.3 From 28ef58285e95e3234d0faa5f230456ae47ecde13 Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Wed, 23 Feb 2011 02:10:54 +0000 Subject: Comment fix from code review with brad --- indra/newview/llstartup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 34a79bcde3..49d4983294 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -670,7 +670,7 @@ bool idle_startup() { gUserCredential = gLoginHandler.initializeLoginInfo(); } - // Previous initialĂzeLoginInfo may have generated user credentials. Re-check them. + // Previous initializeLoginInfo may have generated user credentials. Re-check them. if (gUserCredential.isNull()) { show_connect_box = TRUE; -- cgit v1.2.3 From 0929315ab103433275a71f26a4900ee0615932e9 Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Wed, 23 Feb 2011 05:40:08 +0000 Subject: Added headless client keyboard --- indra/newview/llviewermessage.cpp | 7 +------ indra/newview/llviewerwindow.cpp | 28 ++++------------------------ 2 files changed, 5 insertions(+), 30 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 852911ceb7..3097e98509 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -3935,12 +3935,7 @@ void send_agent_update(BOOL force_send, BOOL send_reliable) // trigger a control event. U32 control_flags = gAgent.getControlFlags(); - MASK key_mask = MASK_NONE; - // *TODO: Create a headless gKeyboard DK 2011-02-18 - if (gKeyboard) - { - key_mask = gKeyboard->currentMask(TRUE); - } + MASK key_mask = gKeyboard->currentMask(TRUE); if (key_mask & MASK_ALT || key_mask & MASK_CONTROL) { diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 21e3626bf8..a5218786d8 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2577,12 +2577,7 @@ void LLViewerWindow::updateUI() S32 x = mCurrentMousePoint.mX; S32 y = mCurrentMousePoint.mY; - MASK mask = MASK_NONE; - // *TODO: Create a headless gKeyboard DK 2011-02-18 - if (gKeyboard) - { - mask = gKeyboard->currentMask(TRUE); - } + MASK mask = gKeyboard->currentMask(TRUE); if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST)) { @@ -2973,12 +2968,7 @@ void LLViewerWindow::updateLayout() } // Update the location of the blue box tool popup LLCoordGL select_center_screen; - MASK mask = MASK_NONE; - // *TODO: Create a headless gKeyboard DK 2011-02-18 - if (gKeyboard) - { - mask = gKeyboard->currentMask(TRUE); - } + MASK mask = gKeyboard->currentMask(TRUE); gFloaterTools->updatePopup( select_center_screen, mask ); } else @@ -3105,12 +3095,7 @@ void LLViewerWindow::updateKeyboardFocus() // sync all floaters with their focus state gFloaterView->highlightFocusedFloater(); gSnapshotFloaterView->highlightFocusedFloater(); - MASK mask = MASK_NONE; - // *TODO: Create a headless gKeyboard DK 2011-02-18 - if (gKeyboard) - { - mask = gKeyboard->currentMask(TRUE); - } + MASK mask = gKeyboard->currentMask(TRUE); if ((mask & MASK_CONTROL) == 0) { // control key no longer held down, finish cycle mode @@ -3499,12 +3484,7 @@ LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_trans } // shortcut queueing in mPicks and just update mLastPick in place - MASK key_mask = MASK_NONE; - // *TODO: Create a headless gKeyboard DK 2011-02-18 - if (gKeyboard) - { - key_mask = gKeyboard->currentMask(TRUE); - } + MASK key_mask = gKeyboard->currentMask(TRUE); mLastPick = LLPickInfo(LLCoordGL(x, y_from_bot), key_mask, pick_transparent, TRUE, NULL); mLastPick.fetchResults(); -- cgit v1.2.3 From 64e8bd3a99adcc6a0381705a9da44fc5299903f2 Mon Sep 17 00:00:00 2001 From: LanceCorrimal Date: Thu, 24 Mar 2011 10:20:35 +0100 Subject: Fixed VWR-25269 --- indra/newview/llviewermenu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index ec72df79d1..625107cf55 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -6402,12 +6402,12 @@ class LLToolsSelectedScriptAction : public view_listener_t else if (action == "start") { name = "start_queue"; - msg = "Running"; + msg = "SetRunning"; } else if (action == "stop") { name = "stop_queue"; - msg = "RunningNot"; + msg = "SetRunningNot"; } LLUUID id; id.generate(); -- cgit v1.2.3 From 567035a2f758fc99ab09b8c9e802dfc881fc301b Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Fri, 25 Mar 2011 17:58:20 -0400 Subject: STORM-1094 Chat preferences > font size should increase size of input text in IM window --- indra/newview/llimfloater.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp index f74ae92a7b..a15d134f87 100644 --- a/indra/newview/llimfloater.cpp +++ b/indra/newview/llimfloater.cpp @@ -56,6 +56,7 @@ #include "llrootview.h" #include "llspeakers.h" #include "llsidetray.h" +#include "llviewerchat.h" static const S32 RECT_PADDING_NOT_INIT = -1; @@ -891,6 +892,7 @@ void LLIMFloater::updateChatHistoryStyle() void LLIMFloater::processChatHistoryStyleUpdate(const LLSD& newvalue) { + LLFontGL* font = LLViewerChat::getChatFont(); LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("impanel"); for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin(); iter != inst_list.end(); ++iter) @@ -899,6 +901,7 @@ void LLIMFloater::processChatHistoryStyleUpdate(const LLSD& newvalue) if (floater) { floater->updateChatHistoryStyle(); + floater->mInputEditor->setFont(font); } } -- cgit v1.2.3 From 85c97c19347c1409f8f7231940b0b8f3a57fc0a5 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Wed, 30 Mar 2011 09:23:48 -0400 Subject: STORM-1094 Added 2 lines so new IM windows pick up the font setting --- indra/newview/llimfloater.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp index a15d134f87..50a9c56518 100644 --- a/indra/newview/llimfloater.cpp +++ b/indra/newview/llimfloater.cpp @@ -267,7 +267,9 @@ BOOL LLIMFloater::postBuild() mInputEditor->setMaxTextLength(1023); // enable line history support for instant message bar mInputEditor->setEnableLineHistory(TRUE); - + + LLFontGL* font = LLViewerChat::getChatFont(); + mInputEditor->setFont(font); mInputEditor->setFocusReceivedCallback( boost::bind(onInputEditorFocusReceived, _1, this) ); mInputEditor->setFocusLostCallback( boost::bind(onInputEditorFocusLost, _1, this) ); -- cgit v1.2.3 From a1a5a793a70f62c977e97b7433840fcb70f47c03 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Wed, 6 Apr 2011 08:13:44 -0400 Subject: fix line endings (one missing, two files of DOS) --- indra/newview/llphysicsmotion.cpp | 1402 ++++++++++++++++++------------------- indra/newview/llphysicsmotion.h | 248 +++---- 2 files changed, 825 insertions(+), 825 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llphysicsmotion.cpp b/indra/newview/llphysicsmotion.cpp index acf8973f03..cb7a55320a 100644 --- a/indra/newview/llphysicsmotion.cpp +++ b/indra/newview/llphysicsmotion.cpp @@ -1,701 +1,701 @@ -/** - * @file llphysicsmotion.cpp - * @brief Implementation of LLPhysicsMotion class. - * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * - * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 - * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception - * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. - * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. - * $/LicenseInfo$ - */ - -//----------------------------------------------------------------------------- -// Header Files -//----------------------------------------------------------------------------- -#include "llviewerprecompiledheaders.h" -#include "linden_common.h" - -#include "m3math.h" -#include "v3dmath.h" - -#include "llphysicsmotion.h" -#include "llcharacter.h" -#include "llviewercontrol.h" -#include "llviewervisualparam.h" -#include "llvoavatarself.h" - -typedef std::map controller_map_t; -typedef std::map default_controller_map_t; - -#define MIN_REQUIRED_PIXEL_AREA_BREAST_MOTION 0.f; - -inline F64 llsgn(const F64 a) -{ - if (a >= 0) - return 1; - return -1; -} - -/* - At a high level, this works by setting temporary parameters that are not stored - in the avatar's list of params, and are not conveyed to other users. We accomplish - this by creating some new temporary driven params inside avatar_lad that are then driven - by the actual params that the user sees and sets. For example, in the old system, - the user sets a param called breast bouyancy, which controls the Z value of the breasts. - In our new system, the user still sets the breast bouyancy, but that param is redefined - as a driver param so that affects a new temporary driven param that the bounce is applied - to. -*/ - -class LLPhysicsMotion -{ -public: - /* - param_driver_name: The param that controls the params that are being affected by the physics. - joint_name: The joint that the body part is attached to. The joint is - used to determine the orientation (rotation) of the body part. - - character: The avatar that this physics affects. - - motion_direction_vec: The direction (in world coordinates) that determines the - motion. For example, (0,0,1) is up-down, and means that up-down motion is what - determines how this joint moves. - - controllers: The various settings (e.g. spring force, mass) that determine how - the body part behaves. - */ - LLPhysicsMotion(const std::string ¶m_driver_name, - const std::string &joint_name, - LLCharacter *character, - const LLVector3 &motion_direction_vec, - const controller_map_t &controllers) : - mParamDriverName(param_driver_name), - mJointName(joint_name), - mMotionDirectionVec(motion_direction_vec), - mParamDriver(NULL), - mParamControllers(controllers), - mCharacter(character), - mLastTime(0), - mPosition_local(0), - mVelocityJoint_local(0), - mPositionLastUpdate_local(0) - { - mJointState = new LLJointState; - } - - BOOL initialize(); - - ~LLPhysicsMotion() {} - - BOOL onUpdate(F32 time); - - LLPointer getJointState() - { - return mJointState; - } -protected: - F32 getParamValue(const std::string& controller_key) - { - const controller_map_t::const_iterator& entry = mParamControllers.find(controller_key); - if (entry == mParamControllers.end()) - { - return sDefaultController[controller_key]; - } - const std::string& param_name = (*entry).second.c_str(); - return mCharacter->getVisualParamWeight(param_name.c_str()); - } - void setParamValue(LLViewerVisualParam *param, - const F32 new_value_local); - - F32 toLocal(const LLVector3 &world); - F32 calculateVelocity_local(const F32 time_delta); - F32 calculateAcceleration_local(F32 velocity_local, - const F32 time_delta); -private: - const std::string mParamDriverName; - const std::string mParamControllerName; - const LLVector3 mMotionDirectionVec; - const std::string mJointName; - - F32 mPosition_local; - F32 mVelocityJoint_local; // How fast the joint is moving - F32 mAccelerationJoint_local; // Acceleration on the joint - - F32 mVelocity_local; // How fast the param is moving - F32 mPositionLastUpdate_local; - LLVector3 mPosition_world; - - LLViewerVisualParam *mParamDriver; - const controller_map_t mParamControllers; - - LLPointer mJointState; - LLCharacter *mCharacter; - - F32 mLastTime; - - static default_controller_map_t sDefaultController; -}; - -default_controller_map_t initDefaultController() -{ - default_controller_map_t controller; - controller["Mass"] = 0.2f; - controller["Gravity"] = 0.0f; - controller["Damping"] = .05f; - controller["Drag"] = 0.15f; - controller["MaxEffect"] = 0.1f; - controller["Spring"] = 0.1f; - controller["Gain"] = 10.0f; - return controller; -} - -default_controller_map_t LLPhysicsMotion::sDefaultController = initDefaultController(); - -BOOL LLPhysicsMotion::initialize() -{ - if (!mJointState->setJoint(mCharacter->getJoint(mJointName.c_str()))) - return FALSE; - mJointState->setUsage(LLJointState::ROT); - - mParamDriver = (LLViewerVisualParam*)mCharacter->getVisualParam(mParamDriverName.c_str()); - if (mParamDriver == NULL) - { - llinfos << "Failure reading in [ " << mParamDriverName << " ]" << llendl; - return FALSE; - } - - return TRUE; -} - -LLPhysicsMotionController::LLPhysicsMotionController(const LLUUID &id) : - LLMotion(id), - mCharacter(NULL) -{ - mName = "breast_motion"; -} - -LLPhysicsMotionController::~LLPhysicsMotionController() -{ - for (motion_vec_t::iterator iter = mMotions.begin(); - iter != mMotions.end(); - ++iter) - { - delete (*iter); - } -} - -BOOL LLPhysicsMotionController::onActivate() -{ - return TRUE; -} - -void LLPhysicsMotionController::onDeactivate() -{ -} - -LLMotion::LLMotionInitStatus LLPhysicsMotionController::onInitialize(LLCharacter *character) -{ - mCharacter = character; - - mMotions.clear(); - - // Breast Cleavage - { - controller_map_t controller; - controller["Mass"] = "Breast_Physics_Mass"; - controller["Gravity"] = "Breast_Physics_Gravity"; - controller["Drag"] = "Breast_Physics_Drag"; - controller["Damping"] = "Breast_Physics_InOut_Damping"; - controller["MaxEffect"] = "Breast_Physics_InOut_Max_Effect"; - controller["Spring"] = "Breast_Physics_InOut_Spring"; - controller["Gain"] = "Breast_Physics_InOut_Gain"; - LLPhysicsMotion *motion = new LLPhysicsMotion("Breast_Physics_InOut_Controller", - "mChest", - character, - LLVector3(-1,0,0), - controller); - if (!motion->initialize()) - { - llassert_always(FALSE); - return STATUS_FAILURE; - } - addMotion(motion); - } - - // Breast Bounce - { - controller_map_t controller; - controller["Mass"] = "Breast_Physics_Mass"; - controller["Gravity"] = "Breast_Physics_Gravity"; - controller["Drag"] = "Breast_Physics_Drag"; - controller["Damping"] = "Breast_Physics_UpDown_Damping"; - controller["MaxEffect"] = "Breast_Physics_UpDown_Max_Effect"; - controller["Spring"] = "Breast_Physics_UpDown_Spring"; - controller["Gain"] = "Breast_Physics_UpDown_Gain"; - LLPhysicsMotion *motion = new LLPhysicsMotion("Breast_Physics_UpDown_Controller", - "mChest", - character, - LLVector3(0,0,1), - controller); - if (!motion->initialize()) - { - llassert_always(FALSE); - return STATUS_FAILURE; - } - addMotion(motion); - } - - // Breast Sway - { - controller_map_t controller; - controller["Mass"] = "Breast_Physics_Mass"; - controller["Gravity"] = "Breast_Physics_Gravity"; - controller["Drag"] = "Breast_Physics_Drag"; - controller["Damping"] = "Breast_Physics_LeftRight_Damping"; - controller["MaxEffect"] = "Breast_Physics_LeftRight_Max_Effect"; - controller["Spring"] = "Breast_Physics_LeftRight_Spring"; - controller["Gain"] = "Breast_Physics_LeftRight_Gain"; - LLPhysicsMotion *motion = new LLPhysicsMotion("Breast_Physics_LeftRight_Controller", - "mChest", - character, - LLVector3(0,-1,0), - controller); - if (!motion->initialize()) - { - llassert_always(FALSE); - return STATUS_FAILURE; - } - addMotion(motion); - } - // Butt Bounce - { - controller_map_t controller; - controller["Mass"] = "Butt_Physics_Mass"; - controller["Gravity"] = "Butt_Physics_Gravity"; - controller["Drag"] = "Butt_Physics_Drag"; - controller["Damping"] = "Butt_Physics_UpDown_Damping"; - controller["MaxEffect"] = "Butt_Physics_UpDown_Max_Effect"; - controller["Spring"] = "Butt_Physics_UpDown_Spring"; - controller["Gain"] = "Butt_Physics_UpDown_Gain"; - LLPhysicsMotion *motion = new LLPhysicsMotion("Butt_Physics_UpDown_Controller", - "mPelvis", - character, - LLVector3(0,0,-1), - controller); - if (!motion->initialize()) - { - llassert_always(FALSE); - return STATUS_FAILURE; - } - addMotion(motion); - } - - // Butt LeftRight - { - controller_map_t controller; - controller["Mass"] = "Butt_Physics_Mass"; - controller["Gravity"] = "Butt_Physics_Gravity"; - controller["Drag"] = "Butt_Physics_Drag"; - controller["Damping"] = "Butt_Physics_LeftRight_Damping"; - controller["MaxEffect"] = "Butt_Physics_LeftRight_Max_Effect"; - controller["Spring"] = "Butt_Physics_LeftRight_Spring"; - controller["Gain"] = "Butt_Physics_LeftRight_Gain"; - LLPhysicsMotion *motion = new LLPhysicsMotion("Butt_Physics_LeftRight_Controller", - "mPelvis", - character, - LLVector3(0,-1,0), - controller); - if (!motion->initialize()) - { - llassert_always(FALSE); - return STATUS_FAILURE; - } - addMotion(motion); - } - - // Belly Bounce - { - controller_map_t controller; - controller["Mass"] = "Belly_Physics_Mass"; - controller["Gravity"] = "Belly_Physics_Gravity"; - controller["Drag"] = "Belly_Physics_Drag"; - controller["Damping"] = "Belly_Physics_UpDown_Damping"; - controller["MaxEffect"] = "Belly_Physics_UpDown_Max_Effect"; - controller["Spring"] = "Belly_Physics_UpDown_Spring"; - controller["Gain"] = "Belly_Physics_UpDown_Gain"; - LLPhysicsMotion *motion = new LLPhysicsMotion("Belly_Physics_UpDown_Controller", - "mPelvis", - character, - LLVector3(0,0,-1), - controller); - if (!motion->initialize()) - { - llassert_always(FALSE); - return STATUS_FAILURE; - } - addMotion(motion); - } - - return STATUS_SUCCESS; -} - -void LLPhysicsMotionController::addMotion(LLPhysicsMotion *motion) -{ - addJointState(motion->getJointState()); - mMotions.push_back(motion); -} - -F32 LLPhysicsMotionController::getMinPixelArea() -{ - return MIN_REQUIRED_PIXEL_AREA_BREAST_MOTION; -} - -// Local space means "parameter space". -F32 LLPhysicsMotion::toLocal(const LLVector3 &world) -{ - LLJoint *joint = mJointState->getJoint(); - const LLQuaternion rotation_world = joint->getWorldRotation(); - - LLVector3 dir_world = mMotionDirectionVec * rotation_world; - dir_world.normalize(); - return world * dir_world; -} - -F32 LLPhysicsMotion::calculateVelocity_local(const F32 time_delta) -{ - LLJoint *joint = mJointState->getJoint(); - const LLVector3 position_world = joint->getWorldPosition(); - const LLQuaternion rotation_world = joint->getWorldRotation(); - const LLVector3 last_position_world = mPosition_world; - const LLVector3 velocity_world = (position_world-last_position_world) / time_delta; - const F32 velocity_local = toLocal(velocity_world); - return velocity_local; -} - -F32 LLPhysicsMotion::calculateAcceleration_local(const F32 velocity_local, - const F32 time_delta) -{ -// const F32 smoothing = getParamValue("Smoothing"); - static const F32 smoothing = 3.0f; // Removed smoothing param since it's probably not necessary - const F32 acceleration_local = velocity_local - mVelocityJoint_local; - - const F32 smoothed_acceleration_local = - acceleration_local * 1.0/smoothing + - mAccelerationJoint_local * (smoothing-1.0)/smoothing; - - return smoothed_acceleration_local; -} - -BOOL LLPhysicsMotionController::onUpdate(F32 time, U8* joint_mask) -{ - // Skip if disabled globally. - if (!gSavedSettings.getBOOL("AvatarPhysics")) - { - return TRUE; - } - - BOOL update_visuals = FALSE; - for (motion_vec_t::iterator iter = mMotions.begin(); - iter != mMotions.end(); - ++iter) - { - LLPhysicsMotion *motion = (*iter); - update_visuals |= motion->onUpdate(time); - } - - if (update_visuals) - mCharacter->updateVisualParams(); - - return TRUE; -} - - -// Return TRUE if character has to update visual params. -BOOL LLPhysicsMotion::onUpdate(F32 time) -{ - // static FILE *mFileWrite = fopen("c:\\temp\\avatar_data.txt","w"); - - if (!mParamDriver) - return FALSE; - - if (!mLastTime) - { - mLastTime = time; - return FALSE; - } - - //////////////////////////////////////////////////////////////////////////////// - // Get all parameters and settings - // - - const F32 time_delta = time - mLastTime; - if (time_delta > 3.0 || time_delta <= 0.01) - { - mLastTime = time; - return FALSE; - } - - // Higher LOD is better. This controls the granularity - // and frequency of updates for the motions. - const F32 lod_factor = LLVOAvatar::sPhysicsLODFactor; - if (lod_factor == 0) - { - return TRUE; - } - - LLJoint *joint = mJointState->getJoint(); - - const F32 behavior_mass = getParamValue("Mass"); - const F32 behavior_gravity = getParamValue("Gravity"); - const F32 behavior_spring = getParamValue("Spring"); - const F32 behavior_gain = getParamValue("Gain"); - const F32 behavior_damping = getParamValue("Damping"); - const F32 behavior_drag = getParamValue("Drag"); - const BOOL physics_test = gSavedSettings.getBOOL("AvatarPhysicsTest"); - - F32 behavior_maxeffect = getParamValue("MaxEffect"); - if (physics_test) - behavior_maxeffect = 1.0f; - // Maximum effect is [0,1] range. - const F32 min_val = 0.5f-behavior_maxeffect/2.0; - const F32 max_val = 0.5f+behavior_maxeffect/2.0; - - // mPositon_local should be in normalized 0,1 range already. Just making sure... - F32 position_current_local = llclamp(mPosition_local, - 0.0f, - 1.0f); - - // Normalize the param position to be from [0,1]. - // We have to use normalized values because there may be more than one driven param, - // and each of these driven params may have its own range. - // This means we'll do all our calculations in normalized [0,1] local coordinates. - F32 position_user_local = mParamDriver->getWeight(); - position_user_local = (position_user_local - mParamDriver->getMinWeight()) / (mParamDriver->getMaxWeight() - mParamDriver->getMinWeight()); - - // If the effect is turned off then don't process unless we need one more update - // to set the position to the default (i.e. user) position. - if ((behavior_maxeffect == 0) && (position_current_local == position_user_local)) - { - return FALSE; - } - - // - // End parameters and settings - //////////////////////////////////////////////////////////////////////////////// - - - //////////////////////////////////////////////////////////////////////////////// - // Calculate velocity and acceleration in parameter space. - // - - const F32 velocity_joint_local = calculateVelocity_local(time_delta); - const F32 acceleration_joint_local = calculateAcceleration_local(velocity_joint_local, time_delta); - - // - // End velocity and acceleration - //////////////////////////////////////////////////////////////////////////////// - - - //////////////////////////////////////////////////////////////////////////////// - // Calculate the total force - // - - // Spring force is a restoring force towards the original user-set breast position. - // F = kx - const F32 spring_length = position_current_local - position_user_local; - const F32 force_spring = -spring_length * behavior_spring; - - // Acceleration is the force that comes from the change in velocity of the torso. - // F = ma - const F32 force_accel = behavior_gain * (acceleration_joint_local * behavior_mass); - - // Gravity always points downward in world space. - // F = mg - const LLVector3 gravity_world(0,0,1); - const F32 force_gravity = behavior_gain * (toLocal(gravity_world) * behavior_gravity * behavior_mass); - - // Damping is a restoring force that opposes the current velocity. - // F = -kv - const F32 force_damping = -behavior_damping * mVelocity_local; - - // Drag is a force imparted by velocity (intuitively it is similar to wind resistance) - // F = .5kv^2 - const F32 force_drag = .5*behavior_drag*velocity_joint_local*velocity_joint_local*llsgn(velocity_joint_local); - - const F32 force_net = (force_accel + - force_gravity + - force_spring + - force_damping + - force_drag); - - // - // End total force - //////////////////////////////////////////////////////////////////////////////// - - - //////////////////////////////////////////////////////////////////////////////// - // Calculate new params - // - - // Calculate the new acceleration based on the net force. - // a = F/m - const F32 acceleration_new_local = force_net / behavior_mass; - static const F32 max_acceleration = 10.0f; // magic number, used to be customizable. - F32 velocity_new_local = mVelocity_local + acceleration_new_local; - velocity_new_local = llclamp(velocity_new_local, - -max_acceleration, max_acceleration); - - // Temporary debugging setting to cause all avatars to move, for profiling purposes. - if (physics_test) - { - velocity_new_local = sin(time*4.0); - } - // Calculate the new parameters, or remain unchanged if max speed is 0. - F32 position_new_local = position_current_local + velocity_new_local*time_delta; - if (behavior_maxeffect == 0) - position_new_local = position_user_local; - - // Zero out the velocity if the param is being pushed beyond its limits. - if ((position_new_local < min_val && velocity_new_local < 0) || - (position_new_local > max_val && velocity_new_local > 0)) - { - velocity_new_local = 0; - } - - const F32 position_new_local_clamped = llclamp(position_new_local, - min_val, - max_val); - - LLDriverParam *driver_param = dynamic_cast(mParamDriver); - llassert_always(driver_param); - if (driver_param) - { - // If this is one of our "hidden" driver params, then make sure it's - // the default value. - if ((driver_param->getGroup() != VISUAL_PARAM_GROUP_TWEAKABLE) && - (driver_param->getGroup() != VISUAL_PARAM_GROUP_TWEAKABLE_NO_TRANSMIT)) - { - mCharacter->setVisualParamWeight(driver_param, - 0, - FALSE); - } - for (LLDriverParam::entry_list_t::iterator iter = driver_param->mDriven.begin(); - iter != driver_param->mDriven.end(); - ++iter) - { - LLDrivenEntry &entry = (*iter); - LLViewerVisualParam *driven_param = entry.mParam; - setParamValue(driven_param,position_new_local_clamped); - } - } - - // - // End calculate new params - //////////////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////////////// - // Conditionally update the visual params - // - - // Updating the visual params (i.e. what the user sees) is fairly expensive. - // So only update if the params have changed enough, and also take into account - // the graphics LOD settings. - - BOOL update_visuals = FALSE; - - // For non-self, if the avatar is small enough visually, then don't update. - const F32 area_for_max_settings = 0.0; - const F32 area_for_min_settings = 1400.0; - const F32 area_for_this_setting = area_for_max_settings + (area_for_min_settings-area_for_max_settings)*(1.0-lod_factor); - const F32 pixel_area = fsqrtf(mCharacter->getPixelArea()); - - const BOOL is_self = (dynamic_cast(mCharacter) != NULL); - if ((pixel_area > area_for_this_setting) || is_self) - { - const F32 position_diff_local = llabs(mPositionLastUpdate_local-position_new_local_clamped); - const F32 min_delta = (1.01f-lod_factor)*0.4f; - if (llabs(position_diff_local) > min_delta) - { - update_visuals = TRUE; - mPositionLastUpdate_local = position_new_local; - } - } - - // - // End update visual params - //////////////////////////////////////////////////////////////////////////////// - - mVelocityJoint_local = velocity_joint_local; - - mVelocity_local = velocity_new_local; - mAccelerationJoint_local = acceleration_joint_local; - mPosition_local = position_new_local; - - mPosition_world = joint->getWorldPosition(); - mLastTime = time; - - /* - // Write out debugging info into a spreadsheet. - if (mFileWrite != NULL && is_self) - { - fprintf(mFileWrite,"%f\t%f\t%f \t\t%f \t\t%f\t%f\t%f\t \t\t%f\t%f\t%f\t%f\t%f \t\t%f\t%f\t%f\n", - position_new_local, - velocity_new_local, - acceleration_new_local, - - time_delta, - - mPosition_world[0], - mPosition_world[1], - mPosition_world[2], - - force_net, - force_spring, - force_accel, - force_damping, - force_drag, - - spring_length, - velocity_joint_local, - acceleration_joint_local - ); - } - */ - - return update_visuals; -} - -// Range of new_value_local is assumed to be [0 , 1] normalized. -void LLPhysicsMotion::setParamValue(LLViewerVisualParam *param, - F32 new_value_normalized) -{ - const F32 value_min_local = param->getMinWeight(); - const F32 value_max_local = param->getMaxWeight(); - - const F32 new_value_local = value_min_local + (value_max_local-value_min_local) * new_value_normalized; - - mCharacter->setVisualParamWeight(param, - new_value_local, - FALSE); -} +/** + * @file llphysicsmotion.cpp + * @brief Implementation of LLPhysicsMotion class. + * + * $LicenseInfo:firstyear=2001&license=viewergpl$ + * + * Copyright (c) 2001-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +//----------------------------------------------------------------------------- +// Header Files +//----------------------------------------------------------------------------- +#include "llviewerprecompiledheaders.h" +#include "linden_common.h" + +#include "m3math.h" +#include "v3dmath.h" + +#include "llphysicsmotion.h" +#include "llcharacter.h" +#include "llviewercontrol.h" +#include "llviewervisualparam.h" +#include "llvoavatarself.h" + +typedef std::map controller_map_t; +typedef std::map default_controller_map_t; + +#define MIN_REQUIRED_PIXEL_AREA_BREAST_MOTION 0.f; + +inline F64 llsgn(const F64 a) +{ + if (a >= 0) + return 1; + return -1; +} + +/* + At a high level, this works by setting temporary parameters that are not stored + in the avatar's list of params, and are not conveyed to other users. We accomplish + this by creating some new temporary driven params inside avatar_lad that are then driven + by the actual params that the user sees and sets. For example, in the old system, + the user sets a param called breast bouyancy, which controls the Z value of the breasts. + In our new system, the user still sets the breast bouyancy, but that param is redefined + as a driver param so that affects a new temporary driven param that the bounce is applied + to. +*/ + +class LLPhysicsMotion +{ +public: + /* + param_driver_name: The param that controls the params that are being affected by the physics. + joint_name: The joint that the body part is attached to. The joint is + used to determine the orientation (rotation) of the body part. + + character: The avatar that this physics affects. + + motion_direction_vec: The direction (in world coordinates) that determines the + motion. For example, (0,0,1) is up-down, and means that up-down motion is what + determines how this joint moves. + + controllers: The various settings (e.g. spring force, mass) that determine how + the body part behaves. + */ + LLPhysicsMotion(const std::string ¶m_driver_name, + const std::string &joint_name, + LLCharacter *character, + const LLVector3 &motion_direction_vec, + const controller_map_t &controllers) : + mParamDriverName(param_driver_name), + mJointName(joint_name), + mMotionDirectionVec(motion_direction_vec), + mParamDriver(NULL), + mParamControllers(controllers), + mCharacter(character), + mLastTime(0), + mPosition_local(0), + mVelocityJoint_local(0), + mPositionLastUpdate_local(0) + { + mJointState = new LLJointState; + } + + BOOL initialize(); + + ~LLPhysicsMotion() {} + + BOOL onUpdate(F32 time); + + LLPointer getJointState() + { + return mJointState; + } +protected: + F32 getParamValue(const std::string& controller_key) + { + const controller_map_t::const_iterator& entry = mParamControllers.find(controller_key); + if (entry == mParamControllers.end()) + { + return sDefaultController[controller_key]; + } + const std::string& param_name = (*entry).second.c_str(); + return mCharacter->getVisualParamWeight(param_name.c_str()); + } + void setParamValue(LLViewerVisualParam *param, + const F32 new_value_local); + + F32 toLocal(const LLVector3 &world); + F32 calculateVelocity_local(const F32 time_delta); + F32 calculateAcceleration_local(F32 velocity_local, + const F32 time_delta); +private: + const std::string mParamDriverName; + const std::string mParamControllerName; + const LLVector3 mMotionDirectionVec; + const std::string mJointName; + + F32 mPosition_local; + F32 mVelocityJoint_local; // How fast the joint is moving + F32 mAccelerationJoint_local; // Acceleration on the joint + + F32 mVelocity_local; // How fast the param is moving + F32 mPositionLastUpdate_local; + LLVector3 mPosition_world; + + LLViewerVisualParam *mParamDriver; + const controller_map_t mParamControllers; + + LLPointer mJointState; + LLCharacter *mCharacter; + + F32 mLastTime; + + static default_controller_map_t sDefaultController; +}; + +default_controller_map_t initDefaultController() +{ + default_controller_map_t controller; + controller["Mass"] = 0.2f; + controller["Gravity"] = 0.0f; + controller["Damping"] = .05f; + controller["Drag"] = 0.15f; + controller["MaxEffect"] = 0.1f; + controller["Spring"] = 0.1f; + controller["Gain"] = 10.0f; + return controller; +} + +default_controller_map_t LLPhysicsMotion::sDefaultController = initDefaultController(); + +BOOL LLPhysicsMotion::initialize() +{ + if (!mJointState->setJoint(mCharacter->getJoint(mJointName.c_str()))) + return FALSE; + mJointState->setUsage(LLJointState::ROT); + + mParamDriver = (LLViewerVisualParam*)mCharacter->getVisualParam(mParamDriverName.c_str()); + if (mParamDriver == NULL) + { + llinfos << "Failure reading in [ " << mParamDriverName << " ]" << llendl; + return FALSE; + } + + return TRUE; +} + +LLPhysicsMotionController::LLPhysicsMotionController(const LLUUID &id) : + LLMotion(id), + mCharacter(NULL) +{ + mName = "breast_motion"; +} + +LLPhysicsMotionController::~LLPhysicsMotionController() +{ + for (motion_vec_t::iterator iter = mMotions.begin(); + iter != mMotions.end(); + ++iter) + { + delete (*iter); + } +} + +BOOL LLPhysicsMotionController::onActivate() +{ + return TRUE; +} + +void LLPhysicsMotionController::onDeactivate() +{ +} + +LLMotion::LLMotionInitStatus LLPhysicsMotionController::onInitialize(LLCharacter *character) +{ + mCharacter = character; + + mMotions.clear(); + + // Breast Cleavage + { + controller_map_t controller; + controller["Mass"] = "Breast_Physics_Mass"; + controller["Gravity"] = "Breast_Physics_Gravity"; + controller["Drag"] = "Breast_Physics_Drag"; + controller["Damping"] = "Breast_Physics_InOut_Damping"; + controller["MaxEffect"] = "Breast_Physics_InOut_Max_Effect"; + controller["Spring"] = "Breast_Physics_InOut_Spring"; + controller["Gain"] = "Breast_Physics_InOut_Gain"; + LLPhysicsMotion *motion = new LLPhysicsMotion("Breast_Physics_InOut_Controller", + "mChest", + character, + LLVector3(-1,0,0), + controller); + if (!motion->initialize()) + { + llassert_always(FALSE); + return STATUS_FAILURE; + } + addMotion(motion); + } + + // Breast Bounce + { + controller_map_t controller; + controller["Mass"] = "Breast_Physics_Mass"; + controller["Gravity"] = "Breast_Physics_Gravity"; + controller["Drag"] = "Breast_Physics_Drag"; + controller["Damping"] = "Breast_Physics_UpDown_Damping"; + controller["MaxEffect"] = "Breast_Physics_UpDown_Max_Effect"; + controller["Spring"] = "Breast_Physics_UpDown_Spring"; + controller["Gain"] = "Breast_Physics_UpDown_Gain"; + LLPhysicsMotion *motion = new LLPhysicsMotion("Breast_Physics_UpDown_Controller", + "mChest", + character, + LLVector3(0,0,1), + controller); + if (!motion->initialize()) + { + llassert_always(FALSE); + return STATUS_FAILURE; + } + addMotion(motion); + } + + // Breast Sway + { + controller_map_t controller; + controller["Mass"] = "Breast_Physics_Mass"; + controller["Gravity"] = "Breast_Physics_Gravity"; + controller["Drag"] = "Breast_Physics_Drag"; + controller["Damping"] = "Breast_Physics_LeftRight_Damping"; + controller["MaxEffect"] = "Breast_Physics_LeftRight_Max_Effect"; + controller["Spring"] = "Breast_Physics_LeftRight_Spring"; + controller["Gain"] = "Breast_Physics_LeftRight_Gain"; + LLPhysicsMotion *motion = new LLPhysicsMotion("Breast_Physics_LeftRight_Controller", + "mChest", + character, + LLVector3(0,-1,0), + controller); + if (!motion->initialize()) + { + llassert_always(FALSE); + return STATUS_FAILURE; + } + addMotion(motion); + } + // Butt Bounce + { + controller_map_t controller; + controller["Mass"] = "Butt_Physics_Mass"; + controller["Gravity"] = "Butt_Physics_Gravity"; + controller["Drag"] = "Butt_Physics_Drag"; + controller["Damping"] = "Butt_Physics_UpDown_Damping"; + controller["MaxEffect"] = "Butt_Physics_UpDown_Max_Effect"; + controller["Spring"] = "Butt_Physics_UpDown_Spring"; + controller["Gain"] = "Butt_Physics_UpDown_Gain"; + LLPhysicsMotion *motion = new LLPhysicsMotion("Butt_Physics_UpDown_Controller", + "mPelvis", + character, + LLVector3(0,0,-1), + controller); + if (!motion->initialize()) + { + llassert_always(FALSE); + return STATUS_FAILURE; + } + addMotion(motion); + } + + // Butt LeftRight + { + controller_map_t controller; + controller["Mass"] = "Butt_Physics_Mass"; + controller["Gravity"] = "Butt_Physics_Gravity"; + controller["Drag"] = "Butt_Physics_Drag"; + controller["Damping"] = "Butt_Physics_LeftRight_Damping"; + controller["MaxEffect"] = "Butt_Physics_LeftRight_Max_Effect"; + controller["Spring"] = "Butt_Physics_LeftRight_Spring"; + controller["Gain"] = "Butt_Physics_LeftRight_Gain"; + LLPhysicsMotion *motion = new LLPhysicsMotion("Butt_Physics_LeftRight_Controller", + "mPelvis", + character, + LLVector3(0,-1,0), + controller); + if (!motion->initialize()) + { + llassert_always(FALSE); + return STATUS_FAILURE; + } + addMotion(motion); + } + + // Belly Bounce + { + controller_map_t controller; + controller["Mass"] = "Belly_Physics_Mass"; + controller["Gravity"] = "Belly_Physics_Gravity"; + controller["Drag"] = "Belly_Physics_Drag"; + controller["Damping"] = "Belly_Physics_UpDown_Damping"; + controller["MaxEffect"] = "Belly_Physics_UpDown_Max_Effect"; + controller["Spring"] = "Belly_Physics_UpDown_Spring"; + controller["Gain"] = "Belly_Physics_UpDown_Gain"; + LLPhysicsMotion *motion = new LLPhysicsMotion("Belly_Physics_UpDown_Controller", + "mPelvis", + character, + LLVector3(0,0,-1), + controller); + if (!motion->initialize()) + { + llassert_always(FALSE); + return STATUS_FAILURE; + } + addMotion(motion); + } + + return STATUS_SUCCESS; +} + +void LLPhysicsMotionController::addMotion(LLPhysicsMotion *motion) +{ + addJointState(motion->getJointState()); + mMotions.push_back(motion); +} + +F32 LLPhysicsMotionController::getMinPixelArea() +{ + return MIN_REQUIRED_PIXEL_AREA_BREAST_MOTION; +} + +// Local space means "parameter space". +F32 LLPhysicsMotion::toLocal(const LLVector3 &world) +{ + LLJoint *joint = mJointState->getJoint(); + const LLQuaternion rotation_world = joint->getWorldRotation(); + + LLVector3 dir_world = mMotionDirectionVec * rotation_world; + dir_world.normalize(); + return world * dir_world; +} + +F32 LLPhysicsMotion::calculateVelocity_local(const F32 time_delta) +{ + LLJoint *joint = mJointState->getJoint(); + const LLVector3 position_world = joint->getWorldPosition(); + const LLQuaternion rotation_world = joint->getWorldRotation(); + const LLVector3 last_position_world = mPosition_world; + const LLVector3 velocity_world = (position_world-last_position_world) / time_delta; + const F32 velocity_local = toLocal(velocity_world); + return velocity_local; +} + +F32 LLPhysicsMotion::calculateAcceleration_local(const F32 velocity_local, + const F32 time_delta) +{ +// const F32 smoothing = getParamValue("Smoothing"); + static const F32 smoothing = 3.0f; // Removed smoothing param since it's probably not necessary + const F32 acceleration_local = velocity_local - mVelocityJoint_local; + + const F32 smoothed_acceleration_local = + acceleration_local * 1.0/smoothing + + mAccelerationJoint_local * (smoothing-1.0)/smoothing; + + return smoothed_acceleration_local; +} + +BOOL LLPhysicsMotionController::onUpdate(F32 time, U8* joint_mask) +{ + // Skip if disabled globally. + if (!gSavedSettings.getBOOL("AvatarPhysics")) + { + return TRUE; + } + + BOOL update_visuals = FALSE; + for (motion_vec_t::iterator iter = mMotions.begin(); + iter != mMotions.end(); + ++iter) + { + LLPhysicsMotion *motion = (*iter); + update_visuals |= motion->onUpdate(time); + } + + if (update_visuals) + mCharacter->updateVisualParams(); + + return TRUE; +} + + +// Return TRUE if character has to update visual params. +BOOL LLPhysicsMotion::onUpdate(F32 time) +{ + // static FILE *mFileWrite = fopen("c:\\temp\\avatar_data.txt","w"); + + if (!mParamDriver) + return FALSE; + + if (!mLastTime) + { + mLastTime = time; + return FALSE; + } + + //////////////////////////////////////////////////////////////////////////////// + // Get all parameters and settings + // + + const F32 time_delta = time - mLastTime; + if (time_delta > 3.0 || time_delta <= 0.01) + { + mLastTime = time; + return FALSE; + } + + // Higher LOD is better. This controls the granularity + // and frequency of updates for the motions. + const F32 lod_factor = LLVOAvatar::sPhysicsLODFactor; + if (lod_factor == 0) + { + return TRUE; + } + + LLJoint *joint = mJointState->getJoint(); + + const F32 behavior_mass = getParamValue("Mass"); + const F32 behavior_gravity = getParamValue("Gravity"); + const F32 behavior_spring = getParamValue("Spring"); + const F32 behavior_gain = getParamValue("Gain"); + const F32 behavior_damping = getParamValue("Damping"); + const F32 behavior_drag = getParamValue("Drag"); + const BOOL physics_test = gSavedSettings.getBOOL("AvatarPhysicsTest"); + + F32 behavior_maxeffect = getParamValue("MaxEffect"); + if (physics_test) + behavior_maxeffect = 1.0f; + // Maximum effect is [0,1] range. + const F32 min_val = 0.5f-behavior_maxeffect/2.0; + const F32 max_val = 0.5f+behavior_maxeffect/2.0; + + // mPositon_local should be in normalized 0,1 range already. Just making sure... + F32 position_current_local = llclamp(mPosition_local, + 0.0f, + 1.0f); + + // Normalize the param position to be from [0,1]. + // We have to use normalized values because there may be more than one driven param, + // and each of these driven params may have its own range. + // This means we'll do all our calculations in normalized [0,1] local coordinates. + F32 position_user_local = mParamDriver->getWeight(); + position_user_local = (position_user_local - mParamDriver->getMinWeight()) / (mParamDriver->getMaxWeight() - mParamDriver->getMinWeight()); + + // If the effect is turned off then don't process unless we need one more update + // to set the position to the default (i.e. user) position. + if ((behavior_maxeffect == 0) && (position_current_local == position_user_local)) + { + return FALSE; + } + + // + // End parameters and settings + //////////////////////////////////////////////////////////////////////////////// + + + //////////////////////////////////////////////////////////////////////////////// + // Calculate velocity and acceleration in parameter space. + // + + const F32 velocity_joint_local = calculateVelocity_local(time_delta); + const F32 acceleration_joint_local = calculateAcceleration_local(velocity_joint_local, time_delta); + + // + // End velocity and acceleration + //////////////////////////////////////////////////////////////////////////////// + + + //////////////////////////////////////////////////////////////////////////////// + // Calculate the total force + // + + // Spring force is a restoring force towards the original user-set breast position. + // F = kx + const F32 spring_length = position_current_local - position_user_local; + const F32 force_spring = -spring_length * behavior_spring; + + // Acceleration is the force that comes from the change in velocity of the torso. + // F = ma + const F32 force_accel = behavior_gain * (acceleration_joint_local * behavior_mass); + + // Gravity always points downward in world space. + // F = mg + const LLVector3 gravity_world(0,0,1); + const F32 force_gravity = behavior_gain * (toLocal(gravity_world) * behavior_gravity * behavior_mass); + + // Damping is a restoring force that opposes the current velocity. + // F = -kv + const F32 force_damping = -behavior_damping * mVelocity_local; + + // Drag is a force imparted by velocity (intuitively it is similar to wind resistance) + // F = .5kv^2 + const F32 force_drag = .5*behavior_drag*velocity_joint_local*velocity_joint_local*llsgn(velocity_joint_local); + + const F32 force_net = (force_accel + + force_gravity + + force_spring + + force_damping + + force_drag); + + // + // End total force + //////////////////////////////////////////////////////////////////////////////// + + + //////////////////////////////////////////////////////////////////////////////// + // Calculate new params + // + + // Calculate the new acceleration based on the net force. + // a = F/m + const F32 acceleration_new_local = force_net / behavior_mass; + static const F32 max_acceleration = 10.0f; // magic number, used to be customizable. + F32 velocity_new_local = mVelocity_local + acceleration_new_local; + velocity_new_local = llclamp(velocity_new_local, + -max_acceleration, max_acceleration); + + // Temporary debugging setting to cause all avatars to move, for profiling purposes. + if (physics_test) + { + velocity_new_local = sin(time*4.0); + } + // Calculate the new parameters, or remain unchanged if max speed is 0. + F32 position_new_local = position_current_local + velocity_new_local*time_delta; + if (behavior_maxeffect == 0) + position_new_local = position_user_local; + + // Zero out the velocity if the param is being pushed beyond its limits. + if ((position_new_local < min_val && velocity_new_local < 0) || + (position_new_local > max_val && velocity_new_local > 0)) + { + velocity_new_local = 0; + } + + const F32 position_new_local_clamped = llclamp(position_new_local, + min_val, + max_val); + + LLDriverParam *driver_param = dynamic_cast(mParamDriver); + llassert_always(driver_param); + if (driver_param) + { + // If this is one of our "hidden" driver params, then make sure it's + // the default value. + if ((driver_param->getGroup() != VISUAL_PARAM_GROUP_TWEAKABLE) && + (driver_param->getGroup() != VISUAL_PARAM_GROUP_TWEAKABLE_NO_TRANSMIT)) + { + mCharacter->setVisualParamWeight(driver_param, + 0, + FALSE); + } + for (LLDriverParam::entry_list_t::iterator iter = driver_param->mDriven.begin(); + iter != driver_param->mDriven.end(); + ++iter) + { + LLDrivenEntry &entry = (*iter); + LLViewerVisualParam *driven_param = entry.mParam; + setParamValue(driven_param,position_new_local_clamped); + } + } + + // + // End calculate new params + //////////////////////////////////////////////////////////////////////////////// + + //////////////////////////////////////////////////////////////////////////////// + // Conditionally update the visual params + // + + // Updating the visual params (i.e. what the user sees) is fairly expensive. + // So only update if the params have changed enough, and also take into account + // the graphics LOD settings. + + BOOL update_visuals = FALSE; + + // For non-self, if the avatar is small enough visually, then don't update. + const F32 area_for_max_settings = 0.0; + const F32 area_for_min_settings = 1400.0; + const F32 area_for_this_setting = area_for_max_settings + (area_for_min_settings-area_for_max_settings)*(1.0-lod_factor); + const F32 pixel_area = fsqrtf(mCharacter->getPixelArea()); + + const BOOL is_self = (dynamic_cast(mCharacter) != NULL); + if ((pixel_area > area_for_this_setting) || is_self) + { + const F32 position_diff_local = llabs(mPositionLastUpdate_local-position_new_local_clamped); + const F32 min_delta = (1.01f-lod_factor)*0.4f; + if (llabs(position_diff_local) > min_delta) + { + update_visuals = TRUE; + mPositionLastUpdate_local = position_new_local; + } + } + + // + // End update visual params + //////////////////////////////////////////////////////////////////////////////// + + mVelocityJoint_local = velocity_joint_local; + + mVelocity_local = velocity_new_local; + mAccelerationJoint_local = acceleration_joint_local; + mPosition_local = position_new_local; + + mPosition_world = joint->getWorldPosition(); + mLastTime = time; + + /* + // Write out debugging info into a spreadsheet. + if (mFileWrite != NULL && is_self) + { + fprintf(mFileWrite,"%f\t%f\t%f \t\t%f \t\t%f\t%f\t%f\t \t\t%f\t%f\t%f\t%f\t%f \t\t%f\t%f\t%f\n", + position_new_local, + velocity_new_local, + acceleration_new_local, + + time_delta, + + mPosition_world[0], + mPosition_world[1], + mPosition_world[2], + + force_net, + force_spring, + force_accel, + force_damping, + force_drag, + + spring_length, + velocity_joint_local, + acceleration_joint_local + ); + } + */ + + return update_visuals; +} + +// Range of new_value_local is assumed to be [0 , 1] normalized. +void LLPhysicsMotion::setParamValue(LLViewerVisualParam *param, + F32 new_value_normalized) +{ + const F32 value_min_local = param->getMinWeight(); + const F32 value_max_local = param->getMaxWeight(); + + const F32 new_value_local = value_min_local + (value_max_local-value_min_local) * new_value_normalized; + + mCharacter->setVisualParamWeight(param, + new_value_local, + FALSE); +} diff --git a/indra/newview/llphysicsmotion.h b/indra/newview/llphysicsmotion.h index 0c0087d269..657698e4f2 100644 --- a/indra/newview/llphysicsmotion.h +++ b/indra/newview/llphysicsmotion.h @@ -1,124 +1,124 @@ -/** - * @file llphysicsmotion.h - * @brief Implementation of LLPhysicsMotion class. - * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * - * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 - * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception - * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. - * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. - * $/LicenseInfo$ - */ - -#ifndef LL_LLPHYSICSMOTIONCONTROLLER_H -#define LL_LLPHYSICSMOTIONCONTROLLER_H - -//----------------------------------------------------------------------------- -// Header files -//----------------------------------------------------------------------------- -#include "llmotion.h" -#include "llframetimer.h" - -#define PHYSICS_MOTION_FADEIN_TIME 1.0f -#define PHYSICS_MOTION_FADEOUT_TIME 1.0f - -class LLPhysicsMotion; - -//----------------------------------------------------------------------------- -// class LLPhysicsMotion -//----------------------------------------------------------------------------- -class LLPhysicsMotionController : - public LLMotion -{ -public: - // Constructor - LLPhysicsMotionController(const LLUUID &id); - - // Destructor - virtual ~LLPhysicsMotionController(); - -public: - //------------------------------------------------------------------------- - // functions to support MotionController and MotionRegistry - //------------------------------------------------------------------------- - - // static constructor - // all subclasses must implement such a function and register it - static LLMotion *create(const LLUUID &id) { return new LLPhysicsMotionController(id); } - -public: - //------------------------------------------------------------------------- - // animation callbacks to be implemented by subclasses - //------------------------------------------------------------------------- - - // motions must specify whether or not they loop - virtual BOOL getLoop() { return TRUE; } - - // motions must report their total duration - virtual F32 getDuration() { return 0.0; } - - // motions must report their "ease in" duration - virtual F32 getEaseInDuration() { return PHYSICS_MOTION_FADEIN_TIME; } - - // motions must report their "ease out" duration. - virtual F32 getEaseOutDuration() { return PHYSICS_MOTION_FADEOUT_TIME; } - - // called to determine when a motion should be activated/deactivated based on avatar pixel coverage - virtual F32 getMinPixelArea(); - - // motions must report their priority - virtual LLJoint::JointPriority getPriority() { return LLJoint::MEDIUM_PRIORITY; } - - virtual LLMotionBlendType getBlendType() { return ADDITIVE_BLEND; } - - // run-time (post constructor) initialization, - // called after parameters have been set - // must return true to indicate success and be available for activation - virtual LLMotionInitStatus onInitialize(LLCharacter *character); - - // called when a motion is activated - // must return TRUE to indicate success, or else - // it will be deactivated - virtual BOOL onActivate(); - - // called per time step - // must return TRUE while it is active, and - // must return FALSE when the motion is completed. - virtual BOOL onUpdate(F32 time, U8* joint_mask); - - // called when a motion is deactivated - virtual void onDeactivate(); - - LLCharacter* getCharacter() { return mCharacter; } - -protected: - void addMotion(LLPhysicsMotion *motion); -private: - LLCharacter* mCharacter; - - typedef std::vector motion_vec_t; - motion_vec_t mMotions; -}; - -#endif // LL_LLPHYSICSMOTION_H - +/** + * @file llphysicsmotion.h + * @brief Implementation of LLPhysicsMotion class. + * + * $LicenseInfo:firstyear=2001&license=viewergpl$ + * + * Copyright (c) 2001-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_LLPHYSICSMOTIONCONTROLLER_H +#define LL_LLPHYSICSMOTIONCONTROLLER_H + +//----------------------------------------------------------------------------- +// Header files +//----------------------------------------------------------------------------- +#include "llmotion.h" +#include "llframetimer.h" + +#define PHYSICS_MOTION_FADEIN_TIME 1.0f +#define PHYSICS_MOTION_FADEOUT_TIME 1.0f + +class LLPhysicsMotion; + +//----------------------------------------------------------------------------- +// class LLPhysicsMotion +//----------------------------------------------------------------------------- +class LLPhysicsMotionController : + public LLMotion +{ +public: + // Constructor + LLPhysicsMotionController(const LLUUID &id); + + // Destructor + virtual ~LLPhysicsMotionController(); + +public: + //------------------------------------------------------------------------- + // functions to support MotionController and MotionRegistry + //------------------------------------------------------------------------- + + // static constructor + // all subclasses must implement such a function and register it + static LLMotion *create(const LLUUID &id) { return new LLPhysicsMotionController(id); } + +public: + //------------------------------------------------------------------------- + // animation callbacks to be implemented by subclasses + //------------------------------------------------------------------------- + + // motions must specify whether or not they loop + virtual BOOL getLoop() { return TRUE; } + + // motions must report their total duration + virtual F32 getDuration() { return 0.0; } + + // motions must report their "ease in" duration + virtual F32 getEaseInDuration() { return PHYSICS_MOTION_FADEIN_TIME; } + + // motions must report their "ease out" duration. + virtual F32 getEaseOutDuration() { return PHYSICS_MOTION_FADEOUT_TIME; } + + // called to determine when a motion should be activated/deactivated based on avatar pixel coverage + virtual F32 getMinPixelArea(); + + // motions must report their priority + virtual LLJoint::JointPriority getPriority() { return LLJoint::MEDIUM_PRIORITY; } + + virtual LLMotionBlendType getBlendType() { return ADDITIVE_BLEND; } + + // run-time (post constructor) initialization, + // called after parameters have been set + // must return true to indicate success and be available for activation + virtual LLMotionInitStatus onInitialize(LLCharacter *character); + + // called when a motion is activated + // must return TRUE to indicate success, or else + // it will be deactivated + virtual BOOL onActivate(); + + // called per time step + // must return TRUE while it is active, and + // must return FALSE when the motion is completed. + virtual BOOL onUpdate(F32 time, U8* joint_mask); + + // called when a motion is deactivated + virtual void onDeactivate(); + + LLCharacter* getCharacter() { return mCharacter; } + +protected: + void addMotion(LLPhysicsMotion *motion); +private: + LLCharacter* mCharacter; + + typedef std::vector motion_vec_t; + motion_vec_t mMotions; +}; + +#endif // LL_LLPHYSICSMOTION_H + -- cgit v1.2.3