llagent.h 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248
  1. /**
  2. * @file llagent.h
  3. * @brief LLAgent class header file
  4. *
  5. * $LicenseInfo:firstyear=2000&license=viewergpl$
  6. *
  7. * Copyright (c) 2000-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLAGENT_H
  33. #define LL_LLAGENT_H
  34. #include <set>
  35. #include <vector>
  36. #include "boost/signals2.hpp"
  37. #include "indra_constants.h"
  38. #include "llavatarappearancedefines.h"
  39. #include "llcharacter.h"
  40. #include "llcontrol.h"
  41. #include "llcoordframe.h"
  42. #include "llcorehttprequest.h"
  43. #include "llcorehttputil.h"
  44. #include "lldbstrings.h"
  45. #include "llevent.h"
  46. #include "llinventory.h"
  47. #include "llmath.h"
  48. #include "llpermissionsflags.h"
  49. #include "llpointer.h"
  50. #include "llquaternion.h"
  51. #include "llrefcount.h"
  52. #include "llstring.h"
  53. #include "lltimer.h"
  54. #include "lluuid.h"
  55. #include "llmatrix3.h"
  56. #include "llmatrix4.h"
  57. #include "llvector3d.h"
  58. #include "llcolor4.h"
  59. #include "llvector4.h"
  60. #include "llfollowcam.h"
  61. #include "llhudeffectlookat.h"
  62. #include "llhudeffectpointat.h"
  63. #include "llviewerinventory.h"
  64. #include "llviewerwearable.h"
  65. // Typing indication
  66. constexpr U8 AGENT_STATE_TYPING = 0x04;
  67. // Set when agent has objects selected
  68. constexpr U8 AGENT_STATE_EDITING = 0x10;
  69. ///////////////////////////////////////////////////////////////////////////////
  70. // These constants used to be defined in a separate llagentconstants.h file
  71. // that was only included by llagent.h, so it is best kept in the latter. HB
  72. ///////////////////////////////////////////////////////////////////////////////
  73. constexpr U32 CONTROL_AT_POS_INDEX = 0;
  74. constexpr U32 CONTROL_AT_NEG_INDEX = 1;
  75. constexpr U32 CONTROL_LEFT_POS_INDEX = 2;
  76. constexpr U32 CONTROL_LEFT_NEG_INDEX = 3;
  77. constexpr U32 CONTROL_UP_POS_INDEX = 4;
  78. constexpr U32 CONTROL_UP_NEG_INDEX = 5;
  79. constexpr U32 CONTROL_PITCH_POS_INDEX = 6;
  80. constexpr U32 CONTROL_PITCH_NEG_INDEX = 7;
  81. constexpr U32 CONTROL_YAW_POS_INDEX = 8;
  82. constexpr U32 CONTROL_YAW_NEG_INDEX = 9;
  83. constexpr U32 CONTROL_FAST_AT_INDEX = 10;
  84. constexpr U32 CONTROL_FAST_LEFT_INDEX = 11;
  85. constexpr U32 CONTROL_FAST_UP_INDEX = 12;
  86. constexpr U32 CONTROL_FLY_INDEX = 13;
  87. constexpr U32 CONTROL_STOP_INDEX = 14;
  88. constexpr U32 CONTROL_FINISH_ANIM_INDEX = 15;
  89. constexpr U32 CONTROL_STAND_UP_INDEX = 16;
  90. constexpr U32 CONTROL_SIT_ON_GROUND_INDEX = 17;
  91. constexpr U32 CONTROL_MOUSELOOK_INDEX = 18;
  92. constexpr U32 CONTROL_NUDGE_AT_POS_INDEX = 19;
  93. constexpr U32 CONTROL_NUDGE_AT_NEG_INDEX = 20;
  94. constexpr U32 CONTROL_NUDGE_LEFT_POS_INDEX = 21;
  95. constexpr U32 CONTROL_NUDGE_LEFT_NEG_INDEX = 22;
  96. constexpr U32 CONTROL_NUDGE_UP_POS_INDEX = 23;
  97. constexpr U32 CONTROL_NUDGE_UP_NEG_INDEX = 24;
  98. constexpr U32 CONTROL_TURN_LEFT_INDEX = 25;
  99. constexpr U32 CONTROL_TURN_RIGHT_INDEX = 26;
  100. constexpr U32 CONTROL_AWAY_INDEX = 27;
  101. constexpr U32 CONTROL_LBUTTON_DOWN_INDEX = 28;
  102. constexpr U32 CONTROL_LBUTTON_UP_INDEX = 29;
  103. constexpr U32 CONTROL_ML_LBUTTON_DOWN_INDEX = 30;
  104. constexpr U32 CONTROL_ML_LBUTTON_UP_INDEX = 31;
  105. constexpr U32 TOTAL_CONTROLS = 32;
  106. constexpr U32 AGENT_CONTROL_AT_POS = 0x1 << CONTROL_AT_POS_INDEX; // 0x00000001
  107. constexpr U32 AGENT_CONTROL_AT_NEG = 0x1 << CONTROL_AT_NEG_INDEX; // 0x00000002
  108. constexpr U32 AGENT_CONTROL_LEFT_POS = 0x1 << CONTROL_LEFT_POS_INDEX; // 0x00000004
  109. constexpr U32 AGENT_CONTROL_LEFT_NEG = 0x1 << CONTROL_LEFT_NEG_INDEX; // 0x00000008
  110. constexpr U32 AGENT_CONTROL_UP_POS = 0x1 << CONTROL_UP_POS_INDEX; // 0x00000010
  111. constexpr U32 AGENT_CONTROL_UP_NEG = 0x1 << CONTROL_UP_NEG_INDEX; // 0x00000020
  112. constexpr U32 AGENT_CONTROL_PITCH_POS = 0x1 << CONTROL_PITCH_POS_INDEX; // 0x00000040
  113. constexpr U32 AGENT_CONTROL_PITCH_NEG = 0x1 << CONTROL_PITCH_NEG_INDEX; // 0x00000080
  114. constexpr U32 AGENT_CONTROL_YAW_POS = 0x1 << CONTROL_YAW_POS_INDEX; // 0x00000100
  115. constexpr U32 AGENT_CONTROL_YAW_NEG = 0x1 << CONTROL_YAW_NEG_INDEX; // 0x00000200
  116. constexpr U32 AGENT_CONTROL_FAST_AT = 0x1 << CONTROL_FAST_AT_INDEX; // 0x00000400
  117. constexpr U32 AGENT_CONTROL_FAST_LEFT = 0x1 << CONTROL_FAST_LEFT_INDEX; // 0x00000800
  118. constexpr U32 AGENT_CONTROL_FAST_UP = 0x1 << CONTROL_FAST_UP_INDEX; // 0x00001000
  119. constexpr U32 AGENT_CONTROL_FLY = 0x1 << CONTROL_FLY_INDEX; // 0x00002000
  120. constexpr U32 AGENT_CONTROL_STOP = 0x1 << CONTROL_STOP_INDEX; // 0x00004000
  121. constexpr U32 AGENT_CONTROL_FINISH_ANIM = 0x1 << CONTROL_FINISH_ANIM_INDEX; // 0x00008000
  122. constexpr U32 AGENT_CONTROL_STAND_UP = 0x1 << CONTROL_STAND_UP_INDEX; // 0x00010000
  123. constexpr U32 AGENT_CONTROL_SIT_ON_GROUND = 0x1 << CONTROL_SIT_ON_GROUND_INDEX; // 0x00020000
  124. constexpr U32 AGENT_CONTROL_MOUSELOOK = 0x1 << CONTROL_MOUSELOOK_INDEX; // 0x00040000
  125. constexpr U32 AGENT_CONTROL_NUDGE_AT_POS = 0x1 << CONTROL_NUDGE_AT_POS_INDEX; // 0x00080000
  126. constexpr U32 AGENT_CONTROL_NUDGE_AT_NEG = 0x1 << CONTROL_NUDGE_AT_NEG_INDEX; // 0x00100000
  127. constexpr U32 AGENT_CONTROL_NUDGE_LEFT_POS = 0x1 << CONTROL_NUDGE_LEFT_POS_INDEX; // 0x00200000
  128. constexpr U32 AGENT_CONTROL_NUDGE_LEFT_NEG = 0x1 << CONTROL_NUDGE_LEFT_NEG_INDEX; // 0x00400000
  129. constexpr U32 AGENT_CONTROL_NUDGE_UP_POS = 0x1 << CONTROL_NUDGE_UP_POS_INDEX; // 0x00800000
  130. constexpr U32 AGENT_CONTROL_NUDGE_UP_NEG = 0x1 << CONTROL_NUDGE_UP_NEG_INDEX; // 0x01000000
  131. constexpr U32 AGENT_CONTROL_TURN_LEFT = 0x1 << CONTROL_TURN_LEFT_INDEX; // 0x02000000
  132. constexpr U32 AGENT_CONTROL_TURN_RIGHT = 0x1 << CONTROL_TURN_RIGHT_INDEX; // 0x04000000
  133. constexpr U32 AGENT_CONTROL_AWAY = 0x1 << CONTROL_AWAY_INDEX; // 0x08000000
  134. constexpr U32 AGENT_CONTROL_LBUTTON_DOWN = 0x1 << CONTROL_LBUTTON_DOWN_INDEX; // 0x10000000
  135. constexpr U32 AGENT_CONTROL_LBUTTON_UP = 0x1 << CONTROL_LBUTTON_UP_INDEX; // 0x20000000
  136. constexpr U32 AGENT_CONTROL_ML_LBUTTON_DOWN = 0x1 << CONTROL_ML_LBUTTON_DOWN_INDEX; // 0x40000000
  137. constexpr U32 AGENT_CONTROL_ML_LBUTTON_UP = ((U32)0x1) << CONTROL_ML_LBUTTON_UP_INDEX; // 0x80000000
  138. constexpr U32 AGENT_CONTROL_AT = AGENT_CONTROL_AT_POS
  139. | AGENT_CONTROL_AT_NEG
  140. | AGENT_CONTROL_NUDGE_AT_POS
  141. | AGENT_CONTROL_NUDGE_AT_NEG;
  142. constexpr U32 AGENT_CONTROL_LEFT = AGENT_CONTROL_LEFT_POS
  143. | AGENT_CONTROL_LEFT_NEG
  144. | AGENT_CONTROL_NUDGE_LEFT_POS
  145. | AGENT_CONTROL_NUDGE_LEFT_NEG;
  146. constexpr U32 AGENT_CONTROL_UP = AGENT_CONTROL_UP_POS
  147. | AGENT_CONTROL_UP_NEG
  148. | AGENT_CONTROL_NUDGE_UP_POS
  149. | AGENT_CONTROL_NUDGE_UP_NEG;
  150. constexpr U32 AGENT_CONTROL_HORIZONTAL = AGENT_CONTROL_AT
  151. | AGENT_CONTROL_LEFT;
  152. constexpr U32 AGENT_CONTROL_NOT_USED_BY_LSL = AGENT_CONTROL_FLY
  153. | AGENT_CONTROL_STOP
  154. | AGENT_CONTROL_FINISH_ANIM
  155. | AGENT_CONTROL_STAND_UP
  156. | AGENT_CONTROL_SIT_ON_GROUND
  157. | AGENT_CONTROL_MOUSELOOK
  158. | AGENT_CONTROL_AWAY;
  159. constexpr U32 AGENT_CONTROL_MOVEMENT = AGENT_CONTROL_AT
  160. | AGENT_CONTROL_LEFT
  161. | AGENT_CONTROL_UP;
  162. constexpr U32 AGENT_CONTROL_ROTATION = AGENT_CONTROL_PITCH_POS
  163. | AGENT_CONTROL_PITCH_NEG
  164. | AGENT_CONTROL_YAW_POS
  165. | AGENT_CONTROL_YAW_NEG;
  166. constexpr U32 AGENT_CONTROL_NUDGE = AGENT_CONTROL_NUDGE_AT_POS
  167. | AGENT_CONTROL_NUDGE_AT_NEG
  168. | AGENT_CONTROL_NUDGE_LEFT_POS
  169. | AGENT_CONTROL_NUDGE_LEFT_NEG;
  170. // Move these up so that we can hide them in "State" for object updates
  171. // (for now)
  172. constexpr U32 AGENT_ATTACH_OFFSET = 4;
  173. constexpr U32 AGENT_ATTACH_MASK = 0xf << AGENT_ATTACH_OFFSET;
  174. // RN: this method swaps the upper and lower nibbles to maintain backward
  175. // compatibility with old objects that only used the upper nibble
  176. #define ATTACHMENT_ID_FROM_STATE(state) \
  177. ((S32)((((U8)state & AGENT_ATTACH_MASK) >> 4) | \
  178. (((U8)state & ~AGENT_ATTACH_MASK) << 4)))
  179. constexpr F32 MAX_ATTACHMENT_DIST = 3.5f; // In meters
  180. ///////////////////////////////////////////////////////////////////////////////
  181. typedef enum e_camera_modes
  182. {
  183. CAMERA_MODE_THIRD_PERSON,
  184. CAMERA_MODE_MOUSELOOK,
  185. CAMERA_MODE_CUSTOMIZE_AVATAR,
  186. CAMERA_MODE_FOLLOW
  187. } ECameraMode;
  188. typedef enum e_camera_position
  189. {
  190. CAMERA_POSITION_SELF, // Camera positioned at our position
  191. CAMERA_POSITION_OBJECT // Camera positioned at observed object's position
  192. } ECameraPosition;
  193. typedef enum e_anim_request
  194. {
  195. ANIM_REQUEST_START,
  196. ANIM_REQUEST_STOP
  197. } EAnimRequest;
  198. class LLChat;
  199. class LLFriendObserver;
  200. class LLHost;
  201. class LLMessageSystem;
  202. class LLMotion;
  203. class LLPermissions;
  204. class LLPickInfo;
  205. class LLToolset;
  206. class LLViewerRegion;
  207. class LLVOAvatarSelf;
  208. struct LLGroupData
  209. {
  210. LLGroupData() = default;
  211. LLGroupData(const LLUUID& group_id, const std::string& name, U64 powers,
  212. S32 contribution = 0, bool accept_notices = true,
  213. bool list_in_profile = true)
  214. : mID(group_id),
  215. mName(name),
  216. mPowers(powers),
  217. mContribution(contribution),
  218. mAcceptNotices(accept_notices),
  219. mListInProfile(list_in_profile)
  220. {
  221. }
  222. LLUUID mID;
  223. LLUUID mInsigniaID;
  224. std::string mName;
  225. U64 mPowers;
  226. S32 mContribution;
  227. bool mAcceptNotices;
  228. bool mListInProfile;
  229. };
  230. LL_INLINE bool operator==(const LLGroupData& a, const LLGroupData& b)
  231. {
  232. return (a.mID == b.mID);
  233. }
  234. class LLAgent : public LLOldEvents::LLObservable
  235. {
  236. protected:
  237. LOG_CLASS(LLAgent);
  238. public:
  239. // When the agent has not typed anything for this duration, it leaves the
  240. // typing state (for both chat and IM).
  241. static constexpr F32 TYPING_TIMEOUT_SECS = 5.f;
  242. //MK
  243. static bool canWear(LLWearableType::EType type);
  244. static bool canUnwear(LLWearableType::EType type);
  245. //mk
  246. LLAgent();
  247. ~LLAgent();
  248. void init();
  249. void cleanup();
  250. // MANIPULATORS
  251. // Called whenever the agent moves. Puts camera back in default position,
  252. // deselects items, etc.
  253. void resetView(bool reset_camera = true, bool change_camera = false);
  254. // Called on camera movement, to allow the camera to be unlocked from the
  255. // default position behind the avatar.
  256. void unlockView();
  257. void onAppFocusGained();
  258. void sendMessage(); // Send message to this agent's region.
  259. void sendReliableMessage(U32 retries_factor = 1);
  260. // Calculate the camera position target
  261. LLVector3d calcCameraPositionTargetGlobal(bool* hit_limit = NULL);
  262. LLVector3d calcFocusPositionTargetGlobal();
  263. LLVector3d calcThirdPersonFocusOffset();
  264. LLVector3d getCameraPositionGlobal() const;
  265. const LLVector3& getCameraPositionAgent() const;
  266. LL_INLINE void resetHUDZoom()
  267. {
  268. if (mHUDTargetZoom != 1.f)
  269. {
  270. mHUDTargetZoom = mHUDCurZoom = 1.f;
  271. }
  272. }
  273. LL_INLINE void getHUDZoom(F32& target_zoom, F32& current_zoom) const
  274. {
  275. target_zoom = mHUDTargetZoom;
  276. current_zoom = mHUDCurZoom;
  277. }
  278. LL_INLINE void setHUDZoom(F32 target_zoom, F32 current_zoom)
  279. {
  280. mHUDTargetZoom = target_zoom;
  281. mHUDCurZoom = current_zoom;
  282. }
  283. F32 getHUDTargetZoom() const;
  284. F32 calcCameraFOVZoomFactor();
  285. // Minimum height off ground for this mode, meters
  286. F32 getCameraMinOffGround();
  287. void endAnimationUpdateUI();
  288. // Sets key to +1 for +direction, -1 for -direction
  289. void setKey(S32 direction, S32& key);
  290. void handleScrollWheel(S32 clicks); // mousewheel driven zoom
  291. void setAvatarObject(LLVOAvatarSelf* avatar);
  292. // Rendering state bitmask helpers
  293. void startTyping();
  294. void stopTyping();
  295. void setRenderState(U8 newstate);
  296. void clearRenderState(U8 clearstate);
  297. U8 getRenderState();
  298. // Set the region data
  299. typedef boost::signals2::signal<void()> region_change_cb_t;
  300. boost::signals2::connection addRegionChangedCB(const region_change_cb_t::slot_type& cb);
  301. void setRegion(LLViewerRegion* regionp);
  302. LL_INLINE LLViewerRegion* getRegion() const { return mRegionp; }
  303. U64 getRegionHandle() const;
  304. const LLHost& getRegionHost() const;
  305. std::string getSLURL() const;
  306. bool regionCapabilitiesReceived() const;
  307. const std::string& getRegionCapability(const char* cap);
  308. bool hasRegionCapability(const char* cap) const;
  309. // For OpenSim export permission support. This is on a per-region basis and
  310. // here we only test the agent region. HB
  311. bool regionHasExportPermSupport() const;
  312. S32 getRegionMaxTextureSize() const;
  313. // This replaces LLEnvironment::isExtendedEnvironmentEnabled(). HB
  314. LL_INLINE bool hasExtendedEnvironment() const { return mHasExtEnvironment; }
  315. // This replaces LLEnvironment::isInventoryEnabled(). HB
  316. LL_INLINE bool hasInventorySettings() const { return mInventorySettings; }
  317. // This replaces LLMaterialEditor::capabilitiesAvailable(). HB
  318. LL_INLINE bool hasInventoryMaterial() const { return mInventoryMaterial; }
  319. // Call once per frame to update position, angles radians
  320. void updateAgentPosition(F32 dt, F32 yaw, S32 mouse_x, S32 mouse_y);
  321. void updateLookAt(S32 mouse_x, S32 mouse_y);
  322. // Call once per frame to update camera location/orientation
  323. void updateCamera();
  324. void resetCamera(); // Slam camera into its default position
  325. void setupSitCamera();
  326. void setupCameraView(bool reset = false);
  327. LL_INLINE void setCameraCollidePlane(const LLVector4& plane)
  328. {
  329. mCameraCollidePlane = plane;
  330. }
  331. bool changeCameraToDefault(bool animate = true);
  332. bool changeCameraToMouselook(bool animate = true);
  333. bool changeCameraToThirdPerson(bool animate = true);
  334. bool changeCameraToFollow(bool animate = true);
  335. void changeCameraToCustomizeAvatar();
  336. void setFocusGlobal(const LLPickInfo& pick);
  337. void setFocusGlobal(const LLVector3d& focus,
  338. const LLUUID& object_id = LLUUID::null);
  339. void setFocusOnAvatar(bool focus = true, bool animate = true);
  340. void setCameraPosAndFocusGlobal(const LLVector3d& pos,
  341. const LLVector3d& focus,
  342. const LLUUID& object_id);
  343. void setSitCamera(const LLUUID& object_id,
  344. const LLVector3& camera_pos = LLVector3::zero,
  345. const LLVector3& camera_focus = LLVector3::zero);
  346. void clearFocusObject();
  347. void setFocusObject(LLViewerObject* object);
  348. LL_INLINE void setObjectTracking(bool track) { mTrackFocusObject = track; }
  349. void heardChat(const LLUUID& id);
  350. void lookAtLastChat();
  351. void lookAtObject(LLUUID avatar_id, ECameraPosition camera_pos);
  352. LL_INLINE F32 getTypingTime() { return mTypingTimer.getElapsedTimeF32(); }
  353. void setAFK();
  354. void clearAFK();
  355. LL_INLINE bool getAFK() const { return (mControlFlags & AGENT_CONTROL_AWAY) != 0; }
  356. void setBusy();
  357. void clearBusy();
  358. LL_INLINE bool getBusy() const { return mIsBusy; }
  359. void setAutoReply();
  360. void clearAutoReply();
  361. LL_INLINE bool getAutoReply() const { return mIsAutoReplying; }
  362. LL_INLINE void setAlwaysRun() { mAlwaysRun = true; }
  363. LL_INLINE void clearAlwaysRun() { mAlwaysRun = false; }
  364. LL_INLINE void setRunning() { mRunning = true; }
  365. LL_INLINE void clearRunning() { mRunning = false; }
  366. LL_INLINE void setFirstLogin(bool b) { mFirstLogin = b; }
  367. LL_INLINE void setGenderChosen(bool b) { mGenderChosen = b; }
  368. // update internal datastructures and update the server with the new
  369. // contribution level. Returns true if the group id was found and
  370. // contribution could be set.
  371. bool setGroupContribution(const LLUUID& group_id, S32 contribution);
  372. bool setUserGroupFlags(const LLUUID& group_id, bool accept_notices,
  373. bool list_in_profile);
  374. LL_INLINE void setHideGroupTitle(bool hide) { mHideGroupTitle = hide; }
  375. void updateLanguage();
  376. // Note: NEVER send this value in the clear or over any weakly encrypted
  377. // channel (such as simple XOR masking).
  378. LL_INLINE const LLUUID& getSecureSessionID() const { return mSecureSessionID; }
  379. //--------------------------------------------------------------------
  380. // God
  381. //--------------------------------------------------------------------
  382. LL_INLINE bool isGodlike() const { return mAdminOverride || mGodLevel > GOD_NOT; }
  383. LL_INLINE bool isGodlikeWithoutAdminMenuFakery() const { return mGodLevel > GOD_NOT; }
  384. LL_INLINE U8 getGodLevel() const { return mAdminOverride ? GOD_FULL : mGodLevel; }
  385. LL_INLINE void setAdminOverride(bool b) { mAdminOverride = b; }
  386. void setGodLevel(U8 god_level);
  387. void requestEnterGodMode();
  388. void requestLeaveGodMode();
  389. typedef boost::function<void (U8)> god_level_change_callback_t;
  390. typedef boost::signals2::signal<void (U8)> god_level_change_signal_t;
  391. typedef boost::signals2::connection god_level_change_slot_t;
  392. god_level_change_slot_t registerGodLevelChanageListener(god_level_change_callback_t callback);
  393. bool wantsPGOnly() const;
  394. bool canAccessMature() const;
  395. bool canAccessAdult() const;
  396. bool canAccessMaturityInRegion(U64 region_handle) const;
  397. bool canAccessMaturityAtGlobal(LLVector3d pos_global) const;
  398. bool prefersPG() const;
  399. bool prefersMature() const;
  400. bool prefersAdult() const;
  401. LL_INLINE bool isTeen() const { return mAccess < SIM_ACCESS_MATURE; }
  402. LL_INLINE bool isMature() const { return mAccess >= SIM_ACCESS_MATURE; }
  403. LL_INLINE bool isAdult() const { return mAccess >= SIM_ACCESS_ADULT; }
  404. void setTeen(bool teen);
  405. void setMaturity(char text);
  406. static U8 convertTextToMaturity(char text);
  407. bool sendMaturityPreferenceToServer(U8 preferredMaturity);
  408. // Maturity callbacks for PreferredMaturity control variable:
  409. void handleMaturity(const LLSD& newvalue);
  410. bool validateMaturity(const LLSD& newvalue);
  411. LL_INLINE bool isGroupTitleHidden() const { return mHideGroupTitle; }
  412. // This is only used for building titles:
  413. LL_INLINE bool isGroupMember() const { return mGroupID.notNull(); }
  414. LL_INLINE const LLUUID& getGroupID() const { return mGroupID; }
  415. LL_INLINE ECameraMode getCameraMode() const { return mCameraMode; }
  416. LL_INLINE bool getFocusOnAvatar() const { return mFocusOnAvatar; }
  417. LL_INLINE LLPointer<LLViewerObject>& getFocusObject() { return mFocusObject; }
  418. LL_INLINE F32 getFocusObjectDist() const { return mFocusObjectDist; }
  419. bool inPrelude();
  420. bool canManageEstate() const;
  421. LL_INLINE bool getAdminOverride() const { return mAdminOverride; }
  422. LL_INLINE LLUUID getLastChatter() const { return mLastChatterID; }
  423. LL_INLINE bool getAlwaysRun() const { return mAlwaysRun; }
  424. LL_INLINE bool getRunning() const { return mRunning; }
  425. void buildFullname(std::string& name) const;
  426. void buildFullnameAndTitle(std::string& name) const;
  427. // Checks against all groups in the entire agent group list.
  428. bool isInGroup(const LLUUID& group_id, bool ignore_god_mode = false) const;
  429. // Sets to the group (or "none" if group_id is LLUUID::null) if possible
  430. // and not already in that group. Returns true when the group was changed
  431. // or already set, false when changing to that group was not possible.
  432. bool setGroup(const LLUUID& group_id);
  433. bool hasPowerInGroup(const LLUUID& group_id, U64 power) const;
  434. // Check for power in just the active group.
  435. bool hasPowerInActiveGroup(U64 power) const;
  436. U64 getPowerInGroup(const LLUUID& group_id) const;
  437. // Get group information by group_id. if not in group, data is left
  438. // unchanged and method returns false. otherwise, values are copied and
  439. // returns true.
  440. bool getGroupData(const LLUUID& group_id, LLGroupData& data) const;
  441. // Get just the agent's contribution to the given group.
  442. S32 getGroupContribution(const LLUUID& group_id) const;
  443. // Returns true if the database reported this login as the first
  444. // for this particular user.
  445. LL_INLINE bool isFirstLogin() const { return mFirstLogin; }
  446. // On the very first login, gender isn't chosen until the user clicks
  447. // in a dialog. We don't render the avatar until they choose.
  448. LL_INLINE bool isGenderChosen() const { return mGenderChosen; }
  449. // utility to build a location string
  450. void buildLocationString(std::string& str);
  451. LLQuaternion getHeadRotation();
  452. // true when camera mode is such that your own avatar should draw.
  453. // Not const because timers can't be accessed in const-fashion.
  454. bool needsRenderAvatar();
  455. // true if we need to render your own avatar's head.
  456. bool needsRenderHead();
  457. LL_INLINE bool cameraThirdPerson() const { return mCameraMode == CAMERA_MODE_THIRD_PERSON && mLastCameraMode == CAMERA_MODE_THIRD_PERSON; }
  458. LL_INLINE bool cameraMouselook() const { return mCameraMode == CAMERA_MODE_MOUSELOOK && mLastCameraMode == CAMERA_MODE_MOUSELOOK; }
  459. LL_INLINE bool cameraCustomizeAvatar() const { return mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR /*&& !mCameraAnimating*/; }
  460. LL_INLINE bool cameraFollow() const { return mCameraMode == CAMERA_MODE_FOLLOW && mLastCameraMode == CAMERA_MODE_FOLLOW; }
  461. typedef boost::signals2::signal<void(const LLVector3& pos_local,
  462. const LLVector3d& pos_global)> pos_change_signal_t;
  463. boost::signals2::connection setPosChangeCallback(const pos_change_signal_t::slot_type& cb);
  464. LLVector3 getPosAgentFromGlobal(const LLVector3d& pos_global) const;
  465. LLVector3d getPosGlobalFromAgent(const LLVector3& pos_agent) const;
  466. // Get the data members
  467. // These return the direction the avatar is looking, not the camera's:
  468. LL_INLINE const LLVector3& getAtAxis() const { return mFrameAgent.getAtAxis(); }
  469. LL_INLINE const LLVector3& getUpAxis() const { return mFrameAgent.getUpAxis(); }
  470. LL_INLINE const LLVector3& getLeftAxis() const { return mFrameAgent.getLeftAxis(); }
  471. LL_INLINE LLCoordFrame getFrameAgent() const { return mFrameAgent; }
  472. LLVector3 getVelocity() const;
  473. LL_INLINE F32 getVelocityZ() const { return getVelocity().mV[VZ]; }
  474. const LLVector3d& getPositionGlobal() const;
  475. const LLVector3& getPositionAgent();
  476. S32 getRegionsVisited() const;
  477. LL_INLINE F64 getDistanceTraveled() const { return mDistanceTraveled; }
  478. LL_INLINE const LLVector3d& getFocusGlobal() const { return mFocusGlobal; }
  479. LL_INLINE const LLVector3d& getFocusTargetGlobal() const
  480. {
  481. return mFocusTargetGlobal;
  482. }
  483. // Returns the quat that represents the rotation of the agent in the
  484. // absolute frame:
  485. LL_INLINE LLQuaternion getQuat() const { return mFrameAgent.getQuaternion(); }
  486. void getName(std::string& name);
  487. LL_INLINE const LLColor4& getEffectColor() { return mEffectColor; }
  488. LL_INLINE void setEffectColor(const LLColor4& color) { mEffectColor = color; }
  489. //
  490. // UTILITIES
  491. //
  492. // Set the physics data
  493. void slamLookAt(const LLVector3& look_at);
  494. void setPositionAgent(const LLVector3& center);
  495. void resetAxes();
  496. void resetAxes(const LLVector3& look_at); // makes reasonable left and up
  497. // Move the avatar's frame
  498. void rotate(F32 angle, const LLVector3& axis);
  499. void rotate(F32 angle, F32 x, F32 y, F32 z);
  500. void rotate(const LLMatrix3& matrix);
  501. void rotate(const LLQuaternion& quaternion);
  502. void pitch(F32 angle);
  503. void roll(F32 angle);
  504. void yaw(F32 angle);
  505. LLVector3 getReferenceUpVector();
  506. F32 clampPitchToLimits(F32 angle);
  507. LL_INLINE void setThirdPersonHeadOffset(LLVector3 dlt) { mThirdPersonHeadOffset = dlt; }
  508. // Flight management
  509. LL_INLINE bool getFlying() const { return (mControlFlags & AGENT_CONTROL_FLY) != 0; }
  510. void setFlying(bool fly, bool play_failed_sound = true);
  511. void toggleFlying();
  512. // Does this parcel allow you to fly ?
  513. bool canFly();
  514. LL_INLINE bool sittingOnGround() { return mSittingOnGround; }
  515. LL_INLINE void notOnSatGround() { mSittingOnGround = false; }
  516. // Animation functions
  517. void stopCurrentAnimations();
  518. void requestStopMotion(LLMotion* motion);
  519. void onAnimStop(const LLUUID& id);
  520. void sendAnimationRequests(std::vector<LLUUID>& anim_ids,
  521. EAnimRequest request);
  522. void sendAnimationRequest(const LLUUID& anim_id, EAnimRequest request);
  523. void sendAnimationStateReset();
  524. void sendRevokePermissions(const LLUUID& target_id, U32 permissions);
  525. bool noCameraConstraints();
  526. LLVector3 calcFocusOffset(LLViewerObject* object, LLVector3 pos_agent,
  527. S32 x, S32 y);
  528. bool calcCameraMinDistance(F32& obj_min_distance);
  529. void startCameraAnimation();
  530. LL_INLINE void stopCameraAnimation() { mCameraAnimating = false; }
  531. // Zooms in by fraction of current distance
  532. void cameraZoomIn(F32 factor);
  533. // Rotates camera CCW radians about build focus point
  534. void cameraOrbitAround(F32 radians);
  535. // Rotates camera forward radians over build focus point
  536. void cameraOrbitOver(F32 radians);
  537. // Moves camera in toward build focus point
  538. void cameraOrbitIn(F32 meters);
  539. // Gets camera zoom as fraction of minimum and maximum zoom
  540. F32 getCameraZoomFraction();
  541. // Sets camera zoom as fraction of minimum and maximum zoom
  542. void setCameraZoomFraction(F32 fraction);
  543. void cameraPanIn(F32 meters);
  544. void cameraPanLeft(F32 meters);
  545. void cameraPanUp(F32 meters);
  546. void updateFocusOffset();
  547. void validateFocusObject();
  548. F32 calcCustomizeAvatarUIOffset(const LLVector3d& camera_pos_global);
  549. // Marks current location as start, sends information to servers
  550. void setStartPosition(U32 location_id);
  551. // Movement from user input. All set the appropriate animation flags.
  552. // All turn off autopilot and make sure the camera is behind the avatar.
  553. // direction is either positive, zero, or negative
  554. void moveAt(S32 direction, bool reset_view = true);
  555. void moveAtNudge(S32 direction);
  556. void moveLeft(S32 direction);
  557. void moveLeftNudge(S32 direction);
  558. void moveUp(S32 direction);
  559. void moveYaw(F32 mag, bool reset_view = true);
  560. void movePitch(S32 direction);
  561. LL_INLINE void setOrbitLeftKey(F32 mag) { mOrbitLeftKey = mag; }
  562. LL_INLINE void setOrbitRightKey(F32 mag) { mOrbitRightKey = mag; }
  563. LL_INLINE void setOrbitUpKey(F32 mag) { mOrbitUpKey = mag; }
  564. LL_INLINE void setOrbitDownKey(F32 mag) { mOrbitDownKey = mag; }
  565. LL_INLINE void setOrbitInKey(F32 mag) { mOrbitInKey = mag; }
  566. LL_INLINE void setOrbitOutKey(F32 mag) { mOrbitOutKey = mag; }
  567. LL_INLINE void setPanLeftKey(F32 mag) { mPanLeftKey = mag; }
  568. LL_INLINE void setPanRightKey(F32 mag) { mPanRightKey = mag; }
  569. LL_INLINE void setPanUpKey(F32 mag) { mPanUpKey = mag; }
  570. LL_INLINE void setPanDownKey(F32 mag) { mPanDownKey = mag; }
  571. LL_INLINE void setPanInKey(F32 mag) { mPanInKey = mag; }
  572. LL_INLINE void setPanOutKey(F32 mag) { mPanOutKey = mag; }
  573. LL_INLINE U32 getControlFlags() { return mControlFlags; }
  574. // Performs bitwise mControlFlags |= mask
  575. void setControlFlags(U32 mask);
  576. // Performs bitwise mControlFlags &= ~mask
  577. void clearControlFlags(U32 mask);
  578. LL_INLINE bool controlFlagsDirty() const { return mFlagsDirty; }
  579. LL_INLINE void enableControlFlagReset() { mFlagsNeedReset = true; }
  580. void resetControlFlags();
  581. // *FIXME: should roll into updateAgentPosition
  582. void propagate(F32 dt);
  583. //
  584. // Teportation methods
  585. //
  586. // Fire any queued, waiting teleport, if possible. HB
  587. void fireQueuedTeleport();
  588. // Teleport to a landmark
  589. void teleportViaLandmark(const LLUUID& landmark_id);
  590. // Go home
  591. LL_INLINE void teleportHome() { teleportViaLandmark(LLUUID::null); }
  592. // Teleport to an invited location
  593. void teleportViaLure(const LLUUID& lure_id, bool godlike);
  594. // Teleport to a global location
  595. void teleportViaLocation(const LLVector3d& pos_global);
  596. // Teleport to a global location, preserving camera rotation
  597. void teleportViaLocationLookAt(const LLVector3d& pos_global);
  598. // Cancel the teleport, may or may not be allowed by server
  599. void teleportCancel();
  600. LL_INLINE const std::string getTeleportSourceSLURL() const
  601. {
  602. return mTeleportSourceSLURL;
  603. }
  604. void setTargetVelocity(const LLVector3& vel);
  605. const LLVector3& getTargetVelocity() const;
  606. void handleServerFeaturesTransition();
  607. static void processAgentDataUpdate(LLMessageSystem* msg, void**);
  608. static void processAgentGroupDataUpdate(LLMessageSystem* msg, void**);
  609. static void processAgentDropGroup(LLMessageSystem* msg, void**);
  610. static void processScriptControlChange(LLMessageSystem* msg, void**);
  611. static void processAgentCachedTextureResponse(LLMessageSystem* mesgsys,
  612. void** user_data);
  613. // This method checks to see if this agent can modify an object based on
  614. // the permissions and the agent's proxy status.
  615. bool isGrantedProxy(const LLPermissions& perm);
  616. bool allowOperation(PermissionBit op, const LLPermissions& perm,
  617. U64 group_proxy_power = 0,
  618. U8 god_minimum = GOD_MAINTENANCE);
  619. friend std::ostream& operator<<(std::ostream& s, const LLAgent& sphere);
  620. // Only to be used in ONE place ! - djs 08/07/02
  621. LL_INLINE void initOriginGlobal(const LLVector3d& pos) { mAgentOriginGlobal = pos; }
  622. LL_INLINE bool leftButtonGrabbed() const
  623. {
  624. if (cameraMouselook())
  625. {
  626. return mControlsTakenCount[CONTROL_ML_LBUTTON_DOWN_INDEX] > 0 ||
  627. mControlsTakenPassedOnCount[CONTROL_ML_LBUTTON_DOWN_INDEX] > 0;
  628. }
  629. else
  630. {
  631. return mControlsTakenCount[CONTROL_LBUTTON_DOWN_INDEX] > 0 ||
  632. mControlsTakenPassedOnCount[CONTROL_LBUTTON_DOWN_INDEX] > 0;
  633. }
  634. }
  635. LL_INLINE bool rotateGrabbed() const
  636. {
  637. return mControlsTakenCount[CONTROL_YAW_POS_INDEX] > 0 ||
  638. mControlsTakenCount[CONTROL_YAW_NEG_INDEX] > 0;
  639. }
  640. LL_INLINE bool forwardGrabbed() const { return mControlsTakenCount[CONTROL_AT_POS_INDEX] > 0; }
  641. LL_INLINE bool backwardGrabbed() const { return mControlsTakenCount[CONTROL_AT_NEG_INDEX] > 0; }
  642. LL_INLINE bool upGrabbed() const { return mControlsTakenCount[CONTROL_UP_POS_INDEX] > 0; }
  643. LL_INLINE bool downGrabbed() const { return mControlsTakenCount[CONTROL_UP_NEG_INDEX] > 0; }
  644. // True if a script has taken over a control.
  645. bool anyControlGrabbed() const;
  646. LL_INLINE bool isControlGrabbed(S32 ctrl_index) const { return mControlsTakenCount[ctrl_index] > 0; }
  647. // Send message to simulator to force grabbed controls to be
  648. // released, in case of a poorly written script.
  649. void forceReleaseControls();
  650. LL_INLINE bool sitCameraEnabled() { return mSitCameraEnabled; }
  651. LL_INLINE F32 getCurrentCameraBuildOffset() { return (F32)mCameraFocusOffset.length(); }
  652. LL_INLINE ELookAtType getLookAtType()
  653. {
  654. return mLookAt ? mLookAt->getLookAtType() : LOOKAT_TARGET_NONE;
  655. }
  656. LL_INLINE EPointAtType getPointAtType()
  657. {
  658. return mPointAt ? mPointAt->getPointAtType() : POINTAT_TARGET_NONE;
  659. }
  660. // look at behavior.
  661. bool setLookAt(ELookAtType target_type, LLViewerObject* object = NULL,
  662. LLVector3 position = LLVector3::zero);
  663. bool setPointAt(EPointAtType target_type, LLViewerObject* object = NULL,
  664. LLVector3 position = LLVector3::zero);
  665. void setHomePosRegion(const U64& region_handle,
  666. const LLVector3& pos_region);
  667. bool getHomePosGlobal(LLVector3d* pos_global);
  668. LL_INLINE void setCameraAnimating(bool b) { mCameraAnimating = b; }
  669. LL_INLINE bool getCameraAnimating() { return mCameraAnimating; }
  670. LL_INLINE void setAnimationDuration(F32 seconds) { mAnimationDuration = seconds; }
  671. LL_INLINE F32 getNearChatRadius() { return mNearChatRadius; }
  672. void setNearChatRadius(F32 radius);
  673. enum EDoubleTapRunMode
  674. {
  675. DOUBLETAP_NONE,
  676. DOUBLETAP_FORWARD,
  677. DOUBLETAP_BACKWARD,
  678. DOUBLETAP_SLIDELEFT,
  679. DOUBLETAP_SLIDERIGHT
  680. };
  681. enum ETeleportState
  682. {
  683. TELEPORT_NONE = 0, // No teleport in progress
  684. // Transition to REQUESTED. Viewer has sent a TeleportRequest to the source
  685. // simulator.
  686. TELEPORT_START = 1,
  687. // Waiting for source simulator to respond with TeleportFinish.
  688. TELEPORT_REQUESTED = 2,
  689. // Viewer has received destination location from source simulator
  690. TELEPORT_MOVING = 3,
  691. // Transition to ARRIVING. Viewer has received avatar update, etc, from
  692. // destination simulator
  693. TELEPORT_START_ARRIVAL = 4,
  694. // Make the user wait while content "pre-caches"
  695. TELEPORT_ARRIVING = 5,
  696. // Teleporting in-sim without showing the progress screen
  697. TELEPORT_LOCAL = 6,
  698. // Viewer not yet ready to receive reliably the TeleportFinish message:
  699. // TP has been queued. HB
  700. TELEPORT_QUEUED = 10,
  701. };
  702. LL_INLINE ETeleportState getTeleportState() const { return mTeleportState; }
  703. void setTeleportState(ETeleportState state,
  704. const std::string& reason = LLStringUtil::null);
  705. LL_INLINE bool notTPingFar()
  706. {
  707. return mTeleportState == TELEPORT_NONE ||
  708. mTeleportState == TELEPORT_LOCAL;
  709. }
  710. LL_INLINE bool teleportInProgress()
  711. {
  712. return mTeleportState != TELEPORT_NONE;
  713. }
  714. LL_INLINE const std::string& getTeleportMessage() const { return mTeleportMessage; }
  715. LL_INLINE void setTeleportMessage(const std::string& m) { mTeleportMessage = m; }
  716. LL_INLINE bool wasTeleportedFar() { return mArrivalHandle != mDepartureHandle; }
  717. // Whether look-at reset after teleport
  718. LL_INLINE bool getTeleportKeepsLookAt() { return mTeleportKeepsLookAt; }
  719. LL_INLINE U64 getTeleportedSimHandle() { return mTeleportedSimHandle; }
  720. LL_INLINE const LLVector3d& getTeleportedPosGlobal() { return mTeleportedPosGlobal; }
  721. static void parseTeleportMessages(const std::string& xml_filename);
  722. // Triggers random fidget animations
  723. void fidget();
  724. // Returns true when a rebake has been scheduled as a result of a change
  725. // in the number of uploaded bakes (which may now only happen in OpenSim).
  726. bool setUploadedBakesLimit();
  727. void sendAgentSetAppearance();
  728. void sendAgentDataUpdateRequest();
  729. void sendAgentUpdateUserInfo(bool im_via_email,
  730. const std::string& dir_visibility);
  731. void sendAgentUserInfoRequest();
  732. void sendWalkRun(bool running);
  733. void observeFriends();
  734. void friendsChanged();
  735. static void stopFidget();
  736. static void clearVisualParams(void*); // debug method
  737. typedef LLCoreHttpUtil::HttpCoroutineAdapter::completionCallback_t httpCallback_t;
  738. bool requestPostCapability(const char* cap_name, LLSD& data,
  739. httpCallback_t cbsucc = NULL,
  740. httpCallback_t cbfail = NULL);
  741. bool requestGetCapability(const char* cap_name,
  742. httpCallback_t cbsucc = NULL,
  743. httpCallback_t cbfail = NULL);
  744. LL_INLINE LLCore::HttpRequest::policy_t getAgentPolicy() const
  745. {
  746. return mHttpPolicy;
  747. }
  748. protected:
  749. // Helper function to prematurely age chat when agent is moving
  750. void ageChat();
  751. private:
  752. bool canSetMaturity(U8 maturity);
  753. static void setStartPositionSuccess(const LLSD& result);
  754. static void processMaturityPreferenceFromServer(const LLSD& result,
  755. std::string reqmatstr);
  756. static void handlePreferredMaturityError(U8 requested_maturity);
  757. static void userInfoRequestCallback(const LLSD& result, bool success);
  758. void sendAgentUserInfoRequestMessage();
  759. static void userInfoUpdateCallback(const LLSD& result, bool success,
  760. bool im_via_email, std::string dir_vis);
  761. void sendAgentUserInfoRequestMessage(bool im_via_email,
  762. const std::string& dir_vis);
  763. void checkPositionChanged();
  764. void setTeleportedSimHandle(const LLVector3d& pos_global);
  765. void resetTeleportedSimHandle();
  766. // Stuff to do for any sort of teleport. Returns true if the teleport can
  767. // proceed.
  768. bool teleportCore(const LLVector3d& pos_global = LLVector3d::zero);
  769. // Keeps camera look-at axis when look_at vector is zero
  770. void teleportRequest(U64 region_handle, const LLVector3d& pos_global,
  771. const LLVector3& pos_local,
  772. const LLVector3& look_at = LLVector3::zero);
  773. void onSimFeaturesReceived(const LLUUID& region_id);
  774. public:
  775. // Secure token for this login session
  776. LLUUID mSecureSessionID;
  777. LLUUID mGroupID;
  778. std::string mGroupName;
  779. std::string mGroupTitle;
  780. U64 mGroupPowers;
  781. std::vector<LLGroupData> mGroups;
  782. // Message of the day
  783. std::string mMOTD;
  784. LLUUID mMapID;
  785. S32 mMapWidth; // Width of map in meters
  786. S32 mMapHeight; // Height of map in meters
  787. // Global x coord of mMapID's bottom left corner.
  788. F64 mMapOriginX;
  789. // Global y coord of mMapID's bottom left corner.
  790. F64 mMapOriginY;
  791. LLPointer<LLHUDEffectLookAt> mLookAt;
  792. LLPointer<LLHUDEffectPointAt> mPointAt;
  793. F32 mDrawDistance;
  794. // Current animated zoom level for HUD objects
  795. F32 mHUDCurZoom;
  796. LLFollowCam mFollowCam;
  797. LLFrameTimer mDoubleTapRunTimer;
  798. EDoubleTapRunMode mDoubleTapRunMode;
  799. U8 mUploadedBakes;
  800. bool mRebakeNeeded;
  801. bool mInitialized;
  802. bool mForceMouselook;
  803. bool mHideGroupTitle;
  804. // We should really define ERROR and PROGRESS enums here but I do not
  805. // really feel like doing that, so I am just going to expose the
  806. // mappings... yup
  807. typedef std::map<std::string, std::string> tp_msg_map_t;
  808. static tp_msg_map_t sTeleportErrorMessages;
  809. static tp_msg_map_t sTeleportProgressMessages;
  810. private:
  811. boost::signals2::connection mSimFeaturesReceivedSlot;
  812. std::string mTeleportMessage;
  813. ETeleportState mTeleportState;
  814. U64 mDepartureHandle; // Set when TP starts
  815. U64 mArrivalHandle; // Set on TP arrival
  816. U64 mTeleportedSimHandle;
  817. // SLURL where last TP began.
  818. std::string mTeleportSourceSLURL;
  819. LLVector3d mTeleportedPosGlobal;
  820. // Target zoom level for HUD objects (used when editing)
  821. F32 mHUDTargetZoom;
  822. S32 mControlsTakenCount[TOTAL_CONTROLS];
  823. S32 mControlsTakenPassedOnCount[TOTAL_CONTROLS];
  824. god_level_change_signal_t mGodLevelChangeSignal;
  825. LLCore::HttpRequest::policy_t mHttpPolicy;
  826. LLViewerRegion* mRegionp;
  827. pos_change_signal_t mPosChangeSignal;
  828. // Origin of agent coords from global coords
  829. LLVector3d mAgentOriginGlobal;
  830. mutable LLVector3d mPositionGlobal;
  831. // Used to calculate travel distance
  832. LLVector3d mLastPositionGlobal;
  833. // Used to detect position changes
  834. LLVector3d mLastPosGlobalTest;
  835. // Position at TP departure point
  836. LLVector3d mPosGlobalTPdeparture;
  837. // How far has the avatar moved
  838. F64 mDistanceTraveled;
  839. // Last time the position change was signaled
  840. F32 mLastPosGlobalSignaled;
  841. // Statistsics: what distinct regions has the avatar been to ?
  842. std::set<U64> mRegionsVisited;
  843. LLFrameTimer mTypingTimer;
  844. // Current behavior state of agent
  845. U8 mRenderState;
  846. // Target mode after transition animation is done
  847. ECameraMode mCameraMode;
  848. ECameraMode mLastCameraMode;
  849. LLAnimPauseRequest mPauseRequest;
  850. U32 mAppearanceSerialNum;
  851. // Camera start position, global coords
  852. LLVector3d mAnimationCameraStartGlobal;
  853. // Camera focus point, global coords
  854. LLVector3d mAnimationFocusStartGlobal;
  855. // Seconds that transition animation has been active
  856. LLFrameTimer mAnimationTimer;
  857. F32 mAnimationDuration; // Seconds
  858. // Amount of fov zoom applied to camera when zeroing in on an object
  859. F32 mCameraFOVZoomFactor;
  860. // Interpolated fov zoom
  861. F32 mCameraCurrentFOVZoomFactor;
  862. // Offset from focus point in build mode
  863. LLVector3d mCameraFocusOffset;
  864. // Target towards which we are lerping the camera's focus offset
  865. LLVector3d mCameraFocusOffsetTarget;
  866. // Default focus point offset relative to avatar
  867. LLVector3 mCameraFocusOffsetDefault;
  868. // Default third-person camera offset
  869. LLVector3 mCameraOffsetDefault;
  870. // Colliding plane for camera
  871. LLVector4 mCameraCollidePlane;
  872. // Current camera offset from avatar
  873. F32 mCurrentCameraDistance;
  874. // Target camera offset from avatar
  875. F32 mTargetCameraDistance;
  876. // Mouse wheel driven fraction of zoom
  877. F32 mCameraZoomFraction;
  878. // Third person camera lag
  879. LLVector3 mCameraLag;
  880. // Head offset for third person camera position
  881. LLVector3 mThirdPersonHeadOffset;
  882. // Camera position in agent coordinates
  883. LLVector3 mCameraPositionAgent;
  884. // Camera virtual position (target) before performing FOV zoom
  885. LLVector3 mCameraVirtualPositionAgent;
  886. // Root relative camera pos when sitting
  887. LLVector3 mSitCameraPos;
  888. // Root relative camera target when sitting
  889. LLVector3 mSitCameraFocus;
  890. LLVector3d mCameraSmoothingLastPositionGlobal;
  891. LLVector3d mCameraSmoothingLastPositionAgent;
  892. // Camera's up direction in world coordinates (determines the 'roll' of the
  893. // view):
  894. LLVector3 mCameraUpVector;
  895. // Object to which camera is related when sitting
  896. LLPointer<LLViewerObject> mSitCameraReferenceObject;
  897. LLPointer<LLViewerObject> mFocusObject;
  898. LLVector3d mFocusGlobal;
  899. LLVector3d mFocusTargetGlobal;
  900. LLVector3 mFocusObjectOffset;
  901. F32 mFocusObjectDist;
  902. F32 mUIOffset;
  903. // Agent position and view, agent-region coordinates
  904. LLCoordFrame mFrameAgent;
  905. // Either 1, 0, or -1... Indicates that movement-key is pressed
  906. S32 mAtKey;
  907. // Like AtKey, but causes less forward thrust
  908. S32 mWalkKey;
  909. S32 mLeftKey;
  910. S32 mUpKey;
  911. F32 mYawKey;
  912. S32 mPitchKey;
  913. F32 mOrbitLeftKey;
  914. F32 mOrbitRightKey;
  915. F32 mOrbitUpKey;
  916. F32 mOrbitDownKey;
  917. F32 mOrbitInKey;
  918. F32 mOrbitOutKey;
  919. F32 mPanUpKey;
  920. F32 mPanDownKey;
  921. F32 mPanLeftKey;
  922. F32 mPanRightKey;
  923. F32 mPanInKey;
  924. F32 mPanOutKey;
  925. U32 mControlFlags;
  926. LLFriendObserver* mFriendObserver;
  927. std::set<LLUUID> mProxyForAgents;
  928. LLColor4 mEffectColor;
  929. LLVector3 mHomePosRegion;
  930. U64 mHomeRegionHandle;
  931. LLFrameTimer mChatTimer;
  932. LLUUID mLastChatterID;
  933. F32 mNearChatRadius;
  934. LLFrameTimer mFidgetTimer;
  935. LLFrameTimer mFocusObjectFadeTimer;
  936. F32 mNextFidgetTime;
  937. S32 mCurrentFidget;
  938. // Emitted when agent region changes.
  939. region_change_cb_t mRegionChangeSignal;
  940. // Used to be part of the (useless and now removed) LLAgentAccess class...
  941. U8 mAccess; // SIM_ACCESS_MATURE etc
  942. U8 mGodLevel;
  943. bool mAdminOverride;
  944. // Keep track of whether or not we have pushed views.
  945. bool mViewsPushed;
  946. // Try to keep look-at after teleport is complete
  947. bool mTeleportKeepsLookAt;
  948. // The avatar runs by default rather than walking
  949. bool mAlwaysRun;
  950. // Is the avatar trying to run right now ?
  951. bool mRunning;
  952. bool mSittingOnGround;
  953. // Current animation is ANIM_AGENT_CUSTOMIZE ?
  954. bool mCustomAnim;
  955. // Should we render the avatar?
  956. bool mShowAvatar;
  957. // Camera is transitioning from one mode to another
  958. bool mCameraAnimating;
  959. // Use provided camera information when sitting?
  960. bool mSitCameraEnabled;
  961. bool mCameraSmoothingStop;
  962. bool mFlagsDirty;
  963. // HACK for preventing incorrect flags sent when crossing region boundaries
  964. bool mFlagsNeedReset;
  965. bool mFocusOnAvatar;
  966. bool mTrackFocusObject;
  967. bool mIsBusy;
  968. bool mIsAutoReplying;
  969. // Capability flags caches
  970. bool mHasExtEnvironment;
  971. // Inventory items support in the agent region.
  972. bool mInventorySettings;
  973. bool mInventoryMaterial;
  974. bool mHaveHomePosition;
  975. bool mFirstLogin;
  976. bool mGenderChosen;
  977. };
  978. class LLAgentQueryManager
  979. {
  980. friend class LLAgent;
  981. friend class LLAgentWearables;
  982. public:
  983. LLAgentQueryManager();
  984. LL_INLINE bool hasNoPendingQueries() const { return getNumPendingQueries() == 0; }
  985. LL_INLINE S32 getNumPendingQueries() const { return mNumPendingQueries; }
  986. LL_INLINE void resetPendingQueries() { mNumPendingQueries = 0; }
  987. private:
  988. S32 mNumPendingQueries;
  989. S32 mWearablesCacheQueryID;
  990. U32 mUpdateSerialNum;
  991. S32 mActiveCacheQueries[LLAvatarAppearanceDefines::BAKED_NUM_INDICES];
  992. };
  993. extern LLAgent gAgent;
  994. extern LLUUID gAgentID;
  995. extern LLUUID gAgentSessionID;
  996. extern LLAgentQueryManager gAgentQueryManager;
  997. void update_group_floaters(const LLUUID& group_id);
  998. #endif