aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llagent.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-30 13:04:20 -0500
committerJacek Antonelli2009-04-30 13:07:16 -0500
commitca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch)
tree8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/newview/llagent.cpp
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz
Second Life viewer sources 1.23.0-RC
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llagent.cpp608
1 files changed, 395 insertions, 213 deletions
diff --git a/linden/indra/newview/llagent.cpp b/linden/indra/newview/llagent.cpp
index 301f00b..b0bb2a9 100644
--- a/linden/indra/newview/llagent.cpp
+++ b/linden/indra/newview/llagent.cpp
@@ -17,7 +17,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 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 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 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -36,6 +37,7 @@
36 37
37#include "llagent.h" 38#include "llagent.h"
38 39
40#include "llcamera.h"
39#include "llcoordframe.h" 41#include "llcoordframe.h"
40#include "indra_constants.h" 42#include "indra_constants.h"
41#include "llmath.h" 43#include "llmath.h"
@@ -99,6 +101,7 @@
99#include "llstartup.h" 101#include "llstartup.h"
100#include "llimview.h" 102#include "llimview.h"
101#include "lltool.h" 103#include "lltool.h"
104#include "lltoolcomp.h"
102#include "lltoolfocus.h" 105#include "lltoolfocus.h"
103#include "lltoolgrab.h" 106#include "lltoolgrab.h"
104#include "lltoolmgr.h" 107#include "lltoolmgr.h"
@@ -131,6 +134,8 @@
131#include "llviewerjoystick.h" 134#include "llviewerjoystick.h"
132#include "llfollowcam.h" 135#include "llfollowcam.h"
133 136
137using namespace LLVOAvatarDefines;
138
134extern LLMenuBarGL* gMenuBarView; 139extern LLMenuBarGL* gMenuBarView;
135 140
136//drone wandering constants 141//drone wandering constants
@@ -205,33 +210,12 @@ const F32 MIN_RADIUS_ALPHA_SIZZLE = 0.5f;
205 210
206const F64 CHAT_AGE_FAST_RATE = 3.0; 211const F64 CHAT_AGE_FAST_RATE = 3.0;
207 212
208const S32 MAX_WEARABLES_PER_LAYERSET = 7;
209
210const EWearableType WEARABLE_BAKE_TEXTURE_MAP[BAKED_TEXTURE_COUNT][MAX_WEARABLES_PER_LAYERSET] =
211{
212 { WT_SHAPE, WT_SKIN, WT_HAIR, WT_INVALID, WT_INVALID, WT_INVALID, WT_INVALID }, // TEX_HEAD_BAKED
213 { WT_SHAPE, WT_SKIN, WT_SHIRT, WT_JACKET, WT_GLOVES, WT_UNDERSHIRT, WT_INVALID }, // TEX_UPPER_BAKED
214 { WT_SHAPE, WT_SKIN, WT_PANTS, WT_SHOES, WT_SOCKS, WT_JACKET, WT_UNDERPANTS }, // TEX_LOWER_BAKED
215 { WT_EYES, WT_INVALID, WT_INVALID, WT_INVALID, WT_INVALID, WT_INVALID, WT_INVALID }, // TEX_EYES_BAKED
216 { WT_SKIRT, WT_INVALID, WT_INVALID, WT_INVALID, WT_INVALID, WT_INVALID, WT_INVALID } // TEX_SKIRT_BAKED
217};
218
219const LLUUID BAKED_TEXTURE_HASH[BAKED_TEXTURE_COUNT] =
220{
221 LLUUID("18ded8d6-bcfc-e415-8539-944c0f5ea7a6"),
222 LLUUID("338c29e3-3024-4dbb-998d-7c04cf4fa88f"),
223 LLUUID("91b4a2c7-1b1a-ba16-9a16-1f8f8dcc1c3f"),
224 LLUUID("b2cf28af-b840-1071-3c6a-78085d8128b5"),
225 LLUUID("ea800387-ea1a-14e0-56cb-24f2022f969a")
226};
227
228// The agent instance. 213// The agent instance.
229LLAgent gAgent; 214LLAgent gAgent;
230 215
231// 216//
232// Statics 217// Statics
233// 218//
234BOOL LLAgent::sDebugDisplayTarget = FALSE;
235 219
236const F32 LLAgent::TYPING_TIMEOUT_SECS = 5.f; 220const F32 LLAgent::TYPING_TIMEOUT_SECS = 5.f;
237 221
@@ -270,35 +254,42 @@ void LLAgentFriendObserver::changed(U32 mask)
270//----------------------------------------------------------------------------- 254//-----------------------------------------------------------------------------
271// LLAgent() 255// LLAgent()
272//----------------------------------------------------------------------------- 256//-----------------------------------------------------------------------------
273LLAgent::LLAgent() 257LLAgent::LLAgent() :
274: mDrawDistance( DEFAULT_FAR_PLANE ), 258 mDrawDistance( DEFAULT_FAR_PLANE ),
275
276 mDoubleTapRunTimer(),
277 mDoubleTapRunMode(DOUBLETAP_NONE),
278
279 mbAlwaysRun(false),
280 mbRunning(false),
281 259
282 mAccess(SIM_ACCESS_PG),
283 mGroupPowers(0), 260 mGroupPowers(0),
261 mHideGroupTitle(FALSE),
284 mGroupID(), 262 mGroupID(),
285 //mGroupInsigniaID(), 263
286 mMapOriginX(0), 264 mMapOriginX(0.F),
287 mMapOriginY(0), 265 mMapOriginY(0.F),
288 mMapWidth(0), 266 mMapWidth(0),
289 mMapHeight(0), 267 mMapHeight(0),
268
290 mLookAt(NULL), 269 mLookAt(NULL),
291 mPointAt(NULL), 270 mPointAt(NULL),
271
272 mHUDTargetZoom(1.f),
273 mHUDCurZoom(1.f),
292 mInitialized(FALSE), 274 mInitialized(FALSE),
293 mNumPendingQueries(0), 275 mNumPendingQueries(0),
276 mActiveCacheQueries(NULL),
294 mForceMouselook(FALSE), 277 mForceMouselook(FALSE),
278
279 mDoubleTapRunTimer(),
280 mDoubleTapRunMode(DOUBLETAP_NONE),
281
282 mbAlwaysRun(false),
283 mbRunning(false),
284
285 mAgentAccess(gSavedSettings),
295 mTeleportState( TELEPORT_NONE ), 286 mTeleportState( TELEPORT_NONE ),
296 mRegionp(NULL), 287 mRegionp(NULL),
297 288
298 mAgentOriginGlobal(), 289 mAgentOriginGlobal(),
299 mPositionGlobal(), 290 mPositionGlobal(),
300 291
301 mDistanceTraveled(0), 292 mDistanceTraveled(0.F),
302 mLastPositionGlobal(LLVector3d::zero), 293 mLastPositionGlobal(LLVector3d::zero),
303 294
304 mAvatarObject(NULL), 295 mAvatarObject(NULL),
@@ -310,43 +301,67 @@ LLAgent::LLAgent()
310 mLastCameraMode( CAMERA_MODE_THIRD_PERSON ), 301 mLastCameraMode( CAMERA_MODE_THIRD_PERSON ),
311 mViewsPushed(FALSE), 302 mViewsPushed(FALSE),
312 303
304 mCustomAnim(FALSE),
313 mShowAvatar(TRUE), 305 mShowAvatar(TRUE),
314
315 mCameraAnimating( FALSE ), 306 mCameraAnimating( FALSE ),
316 mAnimationCameraStartGlobal(), 307 mAnimationCameraStartGlobal(),
317 mAnimationFocusStartGlobal(), 308 mAnimationFocusStartGlobal(),
318 mAnimationTimer(), 309 mAnimationTimer(),
319 mAnimationDuration(0.33f), 310 mAnimationDuration(0.33f),
311
320 mCameraFOVZoomFactor(0.f), 312 mCameraFOVZoomFactor(0.f),
321 mCameraCurrentFOVZoomFactor(0.f), 313 mCameraCurrentFOVZoomFactor(0.f),
322 mCameraFocusOffset(), 314 mCameraFocusOffset(),
315 mCameraFOVDefault(DEFAULT_FIELD_OF_VIEW),
316
323 mCameraOffsetDefault(), 317 mCameraOffsetDefault(),
324// mCameraOffsetNorm(),
325 mCameraCollidePlane(), 318 mCameraCollidePlane(),
319
326 mCurrentCameraDistance(2.f), // meters, set in init() 320 mCurrentCameraDistance(2.f), // meters, set in init()
327 mTargetCameraDistance(2.f), 321 mTargetCameraDistance(2.f),
328 mCameraZoomFraction(1.f), // deprecated 322 mCameraZoomFraction(1.f), // deprecated
329 mThirdPersonHeadOffset(0.f, 0.f, 1.f), 323 mThirdPersonHeadOffset(0.f, 0.f, 1.f),
330 mSitCameraEnabled(FALSE), 324 mSitCameraEnabled(FALSE),
331 mHUDTargetZoom(1.f), 325 mCameraSmoothingLastPositionGlobal(),
332 mHUDCurZoom(1.f), 326 mCameraSmoothingLastPositionAgent(),
327 mCameraSmoothingStop(FALSE),
328
329 mCameraUpVector(LLVector3::z_axis), // default is straight up
330
333 mFocusOnAvatar(TRUE), 331 mFocusOnAvatar(TRUE),
334 mFocusGlobal(), 332 mFocusGlobal(),
335 mFocusTargetGlobal(), 333 mFocusTargetGlobal(),
336 mFocusObject(NULL), 334 mFocusObject(NULL),
335 mFocusObjectDist(0.f),
337 mFocusObjectOffset(), 336 mFocusObjectOffset(),
338 mFocusDotRadius( 0.1f ), // meters 337 mFocusDotRadius( 0.1f ), // meters
339 mTrackFocusObject(TRUE), 338 mTrackFocusObject(TRUE),
340 mCameraSmoothingLastPositionGlobal(), 339 mUIOffset(0.f),
341 mCameraSmoothingLastPositionAgent(),
342 mCameraSmoothingStop(FALSE),
343 340
344 mFrameAgent(), 341 mFrameAgent(),
345 342
346 mCrouching(FALSE),
347 mIsBusy(FALSE), 343 mIsBusy(FALSE),
348 344
349 // movement keys below 345 mAtKey(0), // Either 1, 0, or -1... indicates that movement-key is pressed
346 mWalkKey(0), // like AtKey, but causes less forward thrust
347 mLeftKey(0),
348 mUpKey(0),
349 mYawKey(0.f),
350 mPitchKey(0),
351
352 mOrbitLeftKey(0.f),
353 mOrbitRightKey(0.f),
354 mOrbitUpKey(0.f),
355 mOrbitDownKey(0.f),
356 mOrbitInKey(0.f),
357 mOrbitOutKey(0.f),
358
359 mPanUpKey(0.f),
360 mPanDownKey(0.f),
361 mPanLeftKey(0.f),
362 mPanRightKey(0.f),
363 mPanInKey(0.f),
364 mPanOutKey(0.f),
350 365
351 mControlFlags(0x00000000), 366 mControlFlags(0x00000000),
352 mbFlagsDirty(FALSE), 367 mbFlagsDirty(FALSE),
@@ -361,27 +376,27 @@ LLAgent::LLAgent()
361 mAutoPilotUseRotation(FALSE), 376 mAutoPilotUseRotation(FALSE),
362 mAutoPilotTargetFacing(LLVector3::zero), 377 mAutoPilotTargetFacing(LLVector3::zero),
363 mAutoPilotTargetDist(0.f), 378 mAutoPilotTargetDist(0.f),
379 mAutoPilotNoProgressFrameCount(0),
380 mAutoPilotRotationThreshold(0.f),
364 mAutoPilotFinishedCallback(NULL), 381 mAutoPilotFinishedCallback(NULL),
365 mAutoPilotCallbackData(NULL), 382 mAutoPilotCallbackData(NULL),
366 383
367
368 mEffectColor(0.f, 1.f, 1.f, 1.f), 384 mEffectColor(0.f, 1.f, 1.f, 1.f),
385
369 mHaveHomePosition(FALSE), 386 mHaveHomePosition(FALSE),
370 mHomeRegionHandle( 0 ), 387 mHomeRegionHandle( 0 ),
371 mNearChatRadius(CHAT_NORMAL_RADIUS / 2.f), 388 mNearChatRadius(CHAT_NORMAL_RADIUS / 2.f),
372 mGodLevel( GOD_NOT ),
373
374 389
375 mNextFidgetTime(0.f), 390 mNextFidgetTime(0.f),
376 mCurrentFidget(0), 391 mCurrentFidget(0),
377 mFirstLogin(FALSE), 392 mFirstLogin(FALSE),
378 mGenderChosen(FALSE), 393 mGenderChosen(FALSE),
394
379 mAgentWearablesUpdateSerialNum(0), 395 mAgentWearablesUpdateSerialNum(0),
380 mWearablesLoaded(FALSE), 396 mWearablesLoaded(FALSE),
381 mTextureCacheQueryID(0), 397 mTextureCacheQueryID(0),
382 mAppearanceSerialNum(0) 398 mAppearanceSerialNum(0)
383{ 399{
384
385 U32 i; 400 U32 i;
386 for (i = 0; i < TOTAL_CONTROLS; i++) 401 for (i = 0; i < TOTAL_CONTROLS; i++)
387 { 402 {
@@ -389,40 +404,13 @@ LLAgent::LLAgent()
389 mControlsTakenPassedOnCount[i] = 0; 404 mControlsTakenPassedOnCount[i] = 0;
390 } 405 }
391 406
392 // Initialize movement keys 407 mActiveCacheQueries = new S32[BAKED_NUM_INDICES];
393 mAtKey = 0; // Either 1, 0, or -1... indicates that movement-key is pressed 408 for (i = 0; i < (U32)BAKED_NUM_INDICES; i++)
394 mWalkKey = 0; // like AtKey, but causes less forward thrust
395 mLeftKey = 0;
396 mUpKey = 0;
397 mYawKey = 0.f;
398 mPitchKey = 0;
399
400 mOrbitLeftKey = 0.f;
401 mOrbitRightKey = 0.f;
402 mOrbitUpKey = 0.f;
403 mOrbitDownKey = 0.f;
404 mOrbitInKey = 0.f;
405 mOrbitOutKey = 0.f;
406
407 mPanUpKey = 0.f;
408 mPanDownKey = 0.f;
409 mPanLeftKey = 0.f;
410 mPanRightKey = 0.f;
411 mPanInKey = 0.f;
412 mPanOutKey = 0.f;
413
414 mActiveCacheQueries = new S32[BAKED_TEXTURE_COUNT];
415 for (i = 0; i < (U32)BAKED_TEXTURE_COUNT; i++)
416 { 409 {
417 mActiveCacheQueries[i] = 0; 410 mActiveCacheQueries[i] = 0;
418 } 411 }
419 412
420 //Ventrella
421 mCameraUpVector = LLVector3::z_axis;// default is straight up
422 mFollowCam.setMaxCameraDistantFromSubject( MAX_CAMERA_DISTANCE_FROM_AGENT ); 413 mFollowCam.setMaxCameraDistantFromSubject( MAX_CAMERA_DISTANCE_FROM_AGENT );
423 //end ventrella
424
425 mCustomAnim = FALSE ;
426} 414}
427 415
428// Requires gSavedSettings to be initialized. 416// Requires gSavedSettings to be initialized.
@@ -446,10 +434,8 @@ void LLAgent::init()
446 434
447 mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild")); 435 mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild"));
448 mCameraOffsetDefault = gSavedSettings.getVector3("CameraOffsetDefault"); 436 mCameraOffsetDefault = gSavedSettings.getVector3("CameraOffsetDefault");
449// mCameraOffsetNorm = mCameraOffsetDefault;
450// mCameraOffsetNorm.normalize();
451 mCameraCollidePlane.clearVec(); 437 mCameraCollidePlane.clearVec();
452 mCurrentCameraDistance = mCameraOffsetDefault.magVec(); 438 mCurrentCameraDistance = mCameraOffsetDefault.magVec() * gSavedSettings.getF32("CameraOffsetScale");
453 mTargetCameraDistance = mCurrentCameraDistance; 439 mTargetCameraDistance = mCurrentCameraDistance;
454 mCameraZoomFraction = 1.f; 440 mCameraZoomFraction = 1.f;
455 mTrackFocusObject = gSavedSettings.getBOOL("TrackFocusObject"); 441 mTrackFocusObject = gSavedSettings.getBOOL("TrackFocusObject");
@@ -468,8 +454,16 @@ void LLAgent::cleanup()
468{ 454{
469 setSitCamera(LLUUID::null); 455 setSitCamera(LLUUID::null);
470 mAvatarObject = NULL; 456 mAvatarObject = NULL;
471 mLookAt = NULL; 457 if(mLookAt)
472 mPointAt = NULL; 458 {
459 mLookAt->markDead() ;
460 mLookAt = NULL;
461 }
462 if(mPointAt)
463 {
464 mPointAt->markDead() ;
465 mPointAt = NULL;
466 }
473 mRegionp = NULL; 467 mRegionp = NULL;
474 setFocusObject(NULL); 468 setFocusObject(NULL);
475} 469}
@@ -575,7 +569,7 @@ void LLAgent::onAppFocusGained()
575 569
576void LLAgent::ageChat() 570void LLAgent::ageChat()
577{ 571{
578 if (mAvatarObject) 572 if (mAvatarObject.notNull())
579 { 573 {
580 // get amount of time since I last chatted 574 // get amount of time since I last chatted
581 F64 elapsed_time = (F64)mAvatarObject->mChatTimer.getElapsedTimeF32(); 575 F64 elapsed_time = (F64)mAvatarObject->mChatTimer.getElapsedTimeF32();
@@ -592,7 +586,7 @@ void LLAgent::unlockView()
592{ 586{
593 if (getFocusOnAvatar()) 587 if (getFocusOnAvatar())
594 { 588 {
595 if (mAvatarObject) 589 if (mAvatarObject.notNull())
596 { 590 {
597 setFocusGlobal( LLVector3d::zero, mAvatarObject->mID ); 591 setFocusGlobal( LLVector3d::zero, mAvatarObject->mID );
598 } 592 }
@@ -1009,7 +1003,7 @@ void LLAgent::sendReliableMessage()
1009//----------------------------------------------------------------------------- 1003//-----------------------------------------------------------------------------
1010LLVector3 LLAgent::getVelocity() const 1004LLVector3 LLAgent::getVelocity() const
1011{ 1005{
1012 if (mAvatarObject) 1006 if (mAvatarObject.notNull())
1013 { 1007 {
1014 return mAvatarObject->getVelocity(); 1008 return mAvatarObject->getVelocity();
1015 } 1009 }
@@ -1030,7 +1024,7 @@ void LLAgent::setPositionAgent(const LLVector3 &pos_agent)
1030 llerrs << "setPositionAgent is not a number" << llendl; 1024 llerrs << "setPositionAgent is not a number" << llendl;
1031 } 1025 }
1032 1026
1033 if (!mAvatarObject.isNull() && mAvatarObject->getParent()) 1027 if (mAvatarObject.notNull() && mAvatarObject->getParent())
1034 { 1028 {
1035 LLVector3 pos_agent_sitting; 1029 LLVector3 pos_agent_sitting;
1036 LLVector3d pos_agent_d; 1030 LLVector3d pos_agent_d;
@@ -1068,7 +1062,7 @@ void LLAgent::slamLookAt(const LLVector3 &look_at)
1068//----------------------------------------------------------------------------- 1062//-----------------------------------------------------------------------------
1069const LLVector3d &LLAgent::getPositionGlobal() const 1063const LLVector3d &LLAgent::getPositionGlobal() const
1070{ 1064{
1071 if (!mAvatarObject.isNull() && !mAvatarObject->mDrawable.isNull()) 1065 if (mAvatarObject.notNull() && !mAvatarObject->mDrawable.isNull())
1072 { 1066 {
1073 mPositionGlobal = getPosGlobalFromAgent(mAvatarObject->getRenderPosition()); 1067 mPositionGlobal = getPosGlobalFromAgent(mAvatarObject->getRenderPosition());
1074 } 1068 }
@@ -1085,7 +1079,7 @@ const LLVector3d &LLAgent::getPositionGlobal() const
1085//----------------------------------------------------------------------------- 1079//-----------------------------------------------------------------------------
1086const LLVector3 &LLAgent::getPositionAgent() 1080const LLVector3 &LLAgent::getPositionAgent()
1087{ 1081{
1088 if(!mAvatarObject.isNull() && !mAvatarObject->mDrawable.isNull()) 1082 if(mAvatarObject.notNull() && !mAvatarObject->mDrawable.isNull())
1089 { 1083 {
1090 mFrameAgent.setOrigin(mAvatarObject->getRenderPosition()); 1084 mFrameAgent.setOrigin(mAvatarObject->getRenderPosition());
1091 } 1085 }
@@ -1889,7 +1883,7 @@ void LLAgent::cameraOrbitIn(const F32 meters)
1889{ 1883{
1890 if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON) 1884 if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON)
1891 { 1885 {
1892 F32 camera_offset_dist = llmax(0.001f, mCameraOffsetDefault.magVec()); 1886 F32 camera_offset_dist = llmax(0.001f, mCameraOffsetDefault.magVec() * gSavedSettings.getF32("CameraOffsetScale"));
1893 1887
1894 mCameraZoomFraction = (mTargetCameraDistance - meters) / camera_offset_dist; 1888 mCameraZoomFraction = (mTargetCameraDistance - meters) / camera_offset_dist;
1895 1889
@@ -2337,11 +2331,11 @@ void LLAgent::stopAutoPilot(BOOL user_cancel)
2337 if (user_cancel && !mAutoPilotBehaviorName.empty()) 2331 if (user_cancel && !mAutoPilotBehaviorName.empty())
2338 { 2332 {
2339 if (mAutoPilotBehaviorName == "Sit") 2333 if (mAutoPilotBehaviorName == "Sit")
2340 LLNotifyBox::showXml("CancelledSit"); 2334 LLNotifications::instance().add("CancelledSit");
2341 else if (mAutoPilotBehaviorName == "Attach") 2335 else if (mAutoPilotBehaviorName == "Attach")
2342 LLNotifyBox::showXml("CancelledAttach"); 2336 LLNotifications::instance().add("CancelledAttach");
2343 else 2337 else
2344 LLNotifyBox::showXml("Cancelled"); 2338 LLNotifications::instance().add("Cancelled");
2345 } 2339 }
2346 } 2340 }
2347} 2341}
@@ -2366,7 +2360,7 @@ void LLAgent::autoPilot(F32 *delta_yaw)
2366 mAutoPilotTargetGlobal = object->getPositionGlobal(); 2360 mAutoPilotTargetGlobal = object->getPositionGlobal();
2367 } 2361 }
2368 2362
2369 if (!mAvatarObject) 2363 if (mAvatarObject.isNull())
2370 { 2364 {
2371 return; 2365 return;
2372 } 2366 }
@@ -2447,7 +2441,7 @@ void LLAgent::autoPilot(F32 *delta_yaw)
2447 // If we're flying, handle autopilot points above or below you. 2441 // If we're flying, handle autopilot points above or below you.
2448 if (getFlying() && xy_distance < AUTOPILOT_HEIGHT_ADJUST_DISTANCE) 2442 if (getFlying() && xy_distance < AUTOPILOT_HEIGHT_ADJUST_DISTANCE)
2449 { 2443 {
2450 if (mAvatarObject) 2444 if (mAvatarObject.notNull())
2451 { 2445 {
2452 F64 current_height = mAvatarObject->getPositionGlobal().mdV[VZ]; 2446 F64 current_height = mAvatarObject->getPositionGlobal().mdV[VZ];
2453 F32 delta_z = (F32)(mAutoPilotTargetGlobal.mdV[VZ] - current_height); 2447 F32 delta_z = (F32)(mAutoPilotTargetGlobal.mdV[VZ] - current_height);
@@ -2532,7 +2526,7 @@ void LLAgent::propagate(const F32 dt)
2532 pitch(PITCH_RATE * (F32) mPitchKey * dt); 2526 pitch(PITCH_RATE * (F32) mPitchKey * dt);
2533 2527
2534 // handle auto-land behavior 2528 // handle auto-land behavior
2535 if (mAvatarObject) 2529 if (mAvatarObject.notNull())
2536 { 2530 {
2537 BOOL in_air = mAvatarObject->mInAir; 2531 BOOL in_air = mAvatarObject->mInAir;
2538 LLVector3 land_vel = getVelocity(); 2532 LLVector3 land_vel = getVelocity();
@@ -2583,7 +2577,7 @@ void LLAgent::updateLookAt(const S32 mouse_x, const S32 mouse_y)
2583 static LLVector3 last_at_axis; 2577 static LLVector3 last_at_axis;
2584 2578
2585 2579
2586 if ( mAvatarObject.isNull() ) 2580 if (mAvatarObject.isNull())
2587 { 2581 {
2588 return; 2582 return;
2589 } 2583 }
@@ -2717,7 +2711,7 @@ BOOL LLAgent::needsRenderAvatar()
2717// TRUE if we need to render your own avatar's head. 2711// TRUE if we need to render your own avatar's head.
2718BOOL LLAgent::needsRenderHead() 2712BOOL LLAgent::needsRenderHead()
2719{ 2713{
2720 return mShowAvatar && !cameraMouselook(); 2714 return (LLVOAvatar::sVisibleInFirstPerson && LLPipeline::sReflectionRender) || (mShowAvatar && !cameraMouselook());
2721} 2715}
2722 2716
2723//----------------------------------------------------------------------------- 2717//-----------------------------------------------------------------------------
@@ -2816,7 +2810,7 @@ U8 LLAgent::getRenderState()
2816static const LLFloaterView::skip_list_t& get_skip_list() 2810static const LLFloaterView::skip_list_t& get_skip_list()
2817{ 2811{
2818 static LLFloaterView::skip_list_t skip_list; 2812 static LLFloaterView::skip_list_t skip_list;
2819 skip_list.insert(gFloaterMap); 2813 skip_list.insert(LLFloaterMap::getInstance());
2820 return skip_list; 2814 return skip_list;
2821} 2815}
2822 2816
@@ -2856,7 +2850,7 @@ void LLAgent::endAnimationUpdateUI()
2856 } 2850 }
2857 2851
2858 // Disable mouselook-specific animations 2852 // Disable mouselook-specific animations
2859 if (mAvatarObject) 2853 if (mAvatarObject.notNull())
2860 { 2854 {
2861 if( mAvatarObject->isAnyAnimationSignaled(AGENT_GUN_AIM_ANIMS, NUM_AGENT_GUN_AIM_ANIMS) ) 2855 if( mAvatarObject->isAnyAnimationSignaled(AGENT_GUN_AIM_ANIMS, NUM_AGENT_GUN_AIM_ANIMS) )
2862 { 2856 {
@@ -2894,7 +2888,7 @@ void LLAgent::endAnimationUpdateUI()
2894 // let the mini-map go visible again. JC 2888 // let the mini-map go visible again. JC
2895 if (!LLAppViewer::instance()->quitRequested()) 2889 if (!LLAppViewer::instance()->quitRequested())
2896 { 2890 {
2897 gFloaterMap->popVisible(); 2891 LLFloaterMap::getInstance()->popVisible();
2898 } 2892 }
2899 2893
2900 if( gMorphView ) 2894 if( gMorphView )
@@ -2902,7 +2896,7 @@ void LLAgent::endAnimationUpdateUI()
2902 gMorphView->setVisible( FALSE ); 2896 gMorphView->setVisible( FALSE );
2903 } 2897 }
2904 2898
2905 if (mAvatarObject) 2899 if (mAvatarObject.notNull())
2906 { 2900 {
2907 if(mCustomAnim) 2901 if(mCustomAnim)
2908 { 2902 {
@@ -2945,7 +2939,7 @@ void LLAgent::endAnimationUpdateUI()
2945 gIMMgr->setFloaterOpen( FALSE ); 2939 gIMMgr->setFloaterOpen( FALSE );
2946 gConsole->setVisible( TRUE ); 2940 gConsole->setVisible( TRUE );
2947 2941
2948 if (mAvatarObject) 2942 if (mAvatarObject.notNull())
2949 { 2943 {
2950 // Trigger mouselook-specific animations 2944 // Trigger mouselook-specific animations
2951 if( mAvatarObject->isAnyAnimationSignaled(AGENT_GUN_HOLD_ANIMS, NUM_AGENT_GUN_HOLD_ANIMS) ) 2945 if( mAvatarObject->isAnyAnimationSignaled(AGENT_GUN_HOLD_ANIMS, NUM_AGENT_GUN_HOLD_ANIMS) )
@@ -2991,7 +2985,7 @@ void LLAgent::endAnimationUpdateUI()
2991 { 2985 {
2992 LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset); 2986 LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset);
2993 2987
2994 gFloaterMap->pushVisible(FALSE); 2988 LLFloaterMap::getInstance()->pushVisible(FALSE);
2995 /* 2989 /*
2996 LLView *view; 2990 LLView *view;
2997 for (view = gFloaterView->getFirstChild(); view; view = gFloaterView->getNextChild()) 2991 for (view = gFloaterView->getFirstChild(); view; view = gFloaterView->getNextChild())
@@ -3006,7 +3000,7 @@ void LLAgent::endAnimationUpdateUI()
3006 } 3000 }
3007 3001
3008 // freeze avatar 3002 // freeze avatar
3009 if (mAvatarObject) 3003 if (mAvatarObject.notNull())
3010 { 3004 {
3011 mPauseRequest = mAvatarObject->requestPause(); 3005 mPauseRequest = mAvatarObject->requestPause();
3012 } 3006 }
@@ -3040,7 +3034,7 @@ void LLAgent::updateCamera()
3040 3034
3041 validateFocusObject(); 3035 validateFocusObject();
3042 3036
3043 if (!mAvatarObject.isNull() && 3037 if (mAvatarObject.notNull() &&
3044 mAvatarObject->mIsSitting && 3038 mAvatarObject->mIsSitting &&
3045 camera_mode == CAMERA_MODE_MOUSELOOK) 3039 camera_mode == CAMERA_MODE_MOUSELOOK)
3046 { 3040 {
@@ -3154,7 +3148,7 @@ void LLAgent::updateCamera()
3154 //Ventrella 3148 //Ventrella
3155 if ( mCameraMode == CAMERA_MODE_FOLLOW ) 3149 if ( mCameraMode == CAMERA_MODE_FOLLOW )
3156 { 3150 {
3157 if ( !mAvatarObject.isNull() ) 3151 if ( mAvatarObject.notNull() )
3158 { 3152 {
3159 //-------------------------------------------------------------------------------- 3153 //--------------------------------------------------------------------------------
3160 // this is where the avatar's position and rotation are given to followCam, and 3154 // this is where the avatar's position and rotation are given to followCam, and
@@ -3255,12 +3249,15 @@ void LLAgent::updateCamera()
3255 } 3249 }
3256 3250
3257 // smoothing 3251 // smoothing
3258 if (TRUE) 3252 if (TRUE)
3259 { 3253 {
3260 LLVector3d agent_pos = getPositionGlobal(); 3254 LLVector3d agent_pos = getPositionGlobal();
3261 LLVector3d camera_pos_agent = camera_pos_global - agent_pos; 3255 LLVector3d camera_pos_agent = camera_pos_global - agent_pos;
3256 // Sitting on what you're manipulating can cause camera jitter with smoothing.
3257 // This turns off smoothing while editing. -MG
3258 mCameraSmoothingStop |= (BOOL)LLToolMgr::getInstance()->inBuildMode();
3262 3259
3263 if (cameraThirdPerson() && !mCameraSmoothingStop) // only smooth in third person mode 3260 if (cameraThirdPerson() && !mCameraSmoothingStop)
3264 { 3261 {
3265 const F32 SMOOTHING_HALF_LIFE = 0.02f; 3262 const F32 SMOOTHING_HALF_LIFE = 0.02f;
3266 3263
@@ -3464,7 +3461,7 @@ LLVector3d LLAgent::calcFocusPositionTargetGlobal()
3464 { 3461 {
3465 LLVector3d at_axis(1.0, 0.0, 0.0); 3462 LLVector3d at_axis(1.0, 0.0, 0.0);
3466 LLQuaternion agent_rot = mFrameAgent.getQuaternion(); 3463 LLQuaternion agent_rot = mFrameAgent.getQuaternion();
3467 if (!mAvatarObject.isNull() && mAvatarObject->getParent()) 3464 if (mAvatarObject.notNull() && mAvatarObject->getParent())
3468 { 3465 {
3469 LLViewerObject* root_object = (LLViewerObject*)mAvatarObject->getRoot(); 3466 LLViewerObject* root_object = (LLViewerObject*)mAvatarObject->getRoot();
3470 if (!root_object->flagCameraDecoupled()) 3467 if (!root_object->flagCameraDecoupled())
@@ -3686,7 +3683,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit)
3686 } 3683 }
3687 else 3684 else
3688 { 3685 {
3689 local_camera_offset = mCameraZoomFraction * mCameraOffsetDefault; 3686 local_camera_offset = mCameraZoomFraction * mCameraOffsetDefault * gSavedSettings.getF32("CameraOffsetScale");
3690 3687
3691 // are we sitting down? 3688 // are we sitting down?
3692 if (mAvatarObject.notNull() && mAvatarObject->getParent()) 3689 if (mAvatarObject.notNull() && mAvatarObject->getParent())
@@ -3762,7 +3759,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit)
3762 camera_offset.setVec( local_camera_offset ); 3759 camera_offset.setVec( local_camera_offset );
3763 camera_position_global = frame_center_global + head_offset + camera_offset; 3760 camera_position_global = frame_center_global + head_offset + camera_offset;
3764 3761
3765 if (!mAvatarObject.isNull()) 3762 if (mAvatarObject.notNull())
3766 { 3763 {
3767 LLVector3d camera_lag_d; 3764 LLVector3d camera_lag_d;
3768 F32 lag_interp = LLCriticalDamp::getInterpolant(CAMERA_LAG_HALF_LIFE); 3765 F32 lag_interp = LLCriticalDamp::getInterpolant(CAMERA_LAG_HALF_LIFE);
@@ -3837,7 +3834,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit)
3837 if(constrain) 3834 if(constrain)
3838 { 3835 {
3839 F32 max_dist = ( CAMERA_MODE_CUSTOMIZE_AVATAR == mCameraMode ) ? 3836 F32 max_dist = ( CAMERA_MODE_CUSTOMIZE_AVATAR == mCameraMode ) ?
3840 APPEARANCE_MAX_ZOOM : MAX_CAMERA_DISTANCE_FROM_AGENT; 3837 APPEARANCE_MAX_ZOOM : mDrawDistance;
3841 3838
3842 LLVector3d camera_offset = camera_position_global 3839 LLVector3d camera_offset = camera_position_global
3843 - gAgent.getPositionGlobal(); 3840 - gAgent.getPositionGlobal();
@@ -3917,10 +3914,10 @@ void LLAgent::handleScrollWheel(S32 clicks)
3917 } 3914 }
3918 else if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON) 3915 else if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON)
3919 { 3916 {
3920 F32 current_zoom_fraction = mTargetCameraDistance / mCameraOffsetDefault.magVec(); 3917 F32 current_zoom_fraction = mTargetCameraDistance / (mCameraOffsetDefault.magVec() * gSavedSettings.getF32("CameraOffsetScale"));
3921 current_zoom_fraction *= 1.f - pow(ROOT_ROOT_TWO, clicks); 3918 current_zoom_fraction *= 1.f - pow(ROOT_ROOT_TWO, clicks);
3922 3919
3923 cameraOrbitIn(current_zoom_fraction * mCameraOffsetDefault.magVec()); 3920 cameraOrbitIn(current_zoom_fraction * mCameraOffsetDefault.magVec() * gSavedSettings.getF32("CameraOffsetScale"));
3924 } 3921 }
3925 else 3922 else
3926 { 3923 {
@@ -3993,7 +3990,7 @@ void LLAgent::changeCameraToMouselook(BOOL animate)
3993 gSavedSettings.setBOOL("ThirdPersonBtnState", FALSE); 3990 gSavedSettings.setBOOL("ThirdPersonBtnState", FALSE);
3994 gSavedSettings.setBOOL("BuildBtnState", FALSE); 3991 gSavedSettings.setBOOL("BuildBtnState", FALSE);
3995 3992
3996 if (mAvatarObject) 3993 if (mAvatarObject.notNull())
3997 { 3994 {
3998 mAvatarObject->stopMotion( ANIM_AGENT_BODY_NOISE ); 3995 mAvatarObject->stopMotion( ANIM_AGENT_BODY_NOISE );
3999 mAvatarObject->stopMotion( ANIM_AGENT_BREATHE_ROT ); 3996 mAvatarObject->stopMotion( ANIM_AGENT_BREATHE_ROT );
@@ -4081,7 +4078,7 @@ void LLAgent::changeCameraToFollow(BOOL animate)
4081 LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); 4078 LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
4082 } 4079 }
4083 4080
4084 if (mAvatarObject) 4081 if (mAvatarObject.notNull())
4085 { 4082 {
4086 mAvatarObject->mPelvisp->setPosition(LLVector3::zero); 4083 mAvatarObject->mPelvisp->setPosition(LLVector3::zero);
4087 mAvatarObject->startMotion( ANIM_AGENT_BODY_NOISE ); 4084 mAvatarObject->startMotion( ANIM_AGENT_BODY_NOISE );
@@ -4129,7 +4126,7 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate)
4129 4126
4130 mCameraZoomFraction = INITIAL_ZOOM_FRACTION; 4127 mCameraZoomFraction = INITIAL_ZOOM_FRACTION;
4131 4128
4132 if (mAvatarObject) 4129 if (mAvatarObject.notNull())
4133 { 4130 {
4134 if (!mAvatarObject->mIsSitting) 4131 if (!mAvatarObject->mIsSitting)
4135 { 4132 {
@@ -4175,7 +4172,7 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate)
4175 } 4172 }
4176 4173
4177 // Remove any pitch from the avatar 4174 // Remove any pitch from the avatar
4178 if (!mAvatarObject.isNull() && mAvatarObject->getParent()) 4175 if (mAvatarObject.notNull() && mAvatarObject->getParent())
4179 { 4176 {
4180 LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); 4177 LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation();
4181 at_axis = LLViewerCamera::getInstance()->getAtAxis(); 4178 at_axis = LLViewerCamera::getInstance()->getAtAxis();
@@ -4254,7 +4251,7 @@ void LLAgent::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL camera_ani
4254 LLVOAvatar::onCustomizeStart(); 4251 LLVOAvatar::onCustomizeStart();
4255 } 4252 }
4256 4253
4257 if (!mAvatarObject.isNull()) 4254 if (mAvatarObject.notNull())
4258 { 4255 {
4259 if(avatar_animate) 4256 if(avatar_animate)
4260 { 4257 {
@@ -4339,7 +4336,19 @@ void LLAgent::setFocusObject(LLViewerObject* object)
4339//----------------------------------------------------------------------------- 4336//-----------------------------------------------------------------------------
4340void LLAgent::setFocusGlobal(const LLPickInfo& pick) 4337void LLAgent::setFocusGlobal(const LLPickInfo& pick)
4341{ 4338{
4342 setFocusGlobal(pick.mPosGlobal, pick.mObjectID); 4339 LLViewerObject* objectp = gObjectList.findObject(pick.mObjectID);
4340
4341 if (objectp)
4342 {
4343 // focus on object plus designated offset
4344 // which may or may not be same as pick.mPosGlobal
4345 setFocusGlobal(objectp->getPositionGlobal() + LLVector3d(pick.mObjectOffset), pick.mObjectID);
4346 }
4347 else
4348 {
4349 // focus directly on point where user clicked
4350 setFocusGlobal(pick.mPosGlobal, pick.mObjectID);
4351 }
4343} 4352}
4344 4353
4345 4354
@@ -4354,7 +4363,7 @@ void LLAgent::setFocusGlobal(const LLVector3d& focus, const LLUUID &object_id)
4354 { 4363 {
4355 if (focus.isExactlyZero()) 4364 if (focus.isExactlyZero())
4356 { 4365 {
4357 if (!mAvatarObject.isNull()) 4366 if (mAvatarObject.notNull())
4358 { 4367 {
4359 mFocusTargetGlobal = getPosGlobalFromAgent(mAvatarObject->mHeadp->getWorldPosition()); 4368 mFocusTargetGlobal = getPosGlobalFromAgent(mAvatarObject->mHeadp->getWorldPosition());
4360 } 4369 }
@@ -4399,7 +4408,7 @@ void LLAgent::setFocusGlobal(const LLVector3d& focus, const LLUUID &object_id)
4399 { 4408 {
4400 if (focus.isExactlyZero()) 4409 if (focus.isExactlyZero())
4401 { 4410 {
4402 if (!mAvatarObject.isNull()) 4411 if (mAvatarObject.notNull())
4403 { 4412 {
4404 mFocusTargetGlobal = getPosGlobalFromAgent(mAvatarObject->mHeadp->getWorldPosition()); 4413 mFocusTargetGlobal = getPosGlobalFromAgent(mAvatarObject->mHeadp->getWorldPosition());
4405 } 4414 }
@@ -4417,7 +4426,8 @@ void LLAgent::setFocusGlobal(const LLVector3d& focus, const LLUUID &object_id)
4417 // for attachments, make offset relative to avatar, not the attachment 4426 // for attachments, make offset relative to avatar, not the attachment
4418 if (mFocusObject->isAttachment()) 4427 if (mFocusObject->isAttachment())
4419 { 4428 {
4420 while (!mFocusObject->isAvatar()) 4429 while (mFocusObject.notNull() // DEV-29123 - can crash with a messed-up attachment
4430 && !mFocusObject->isAvatar())
4421 { 4431 {
4422 mFocusObject = (LLViewerObject*) mFocusObject->getParent(); 4432 mFocusObject = (LLViewerObject*) mFocusObject->getParent();
4423 } 4433 }
@@ -4536,7 +4546,7 @@ void LLAgent::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate)
4536 if (mCameraMode == CAMERA_MODE_THIRD_PERSON) 4546 if (mCameraMode == CAMERA_MODE_THIRD_PERSON)
4537 { 4547 {
4538 LLVector3 at_axis; 4548 LLVector3 at_axis;
4539 if (!mAvatarObject.isNull() && mAvatarObject->getParent()) 4549 if (mAvatarObject.notNull() && mAvatarObject->getParent())
4540 { 4550 {
4541 LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); 4551 LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation();
4542 at_axis = LLViewerCamera::getInstance()->getAtAxis(); 4552 at_axis = LLViewerCamera::getInstance()->getAtAxis();
@@ -4603,7 +4613,7 @@ void LLAgent::lookAtLastChat()
4603 if (chatter->isAvatar()) 4613 if (chatter->isAvatar())
4604 { 4614 {
4605 LLVOAvatar *chatter_av = (LLVOAvatar*)chatter; 4615 LLVOAvatar *chatter_av = (LLVOAvatar*)chatter;
4606 if (!mAvatarObject.isNull() && chatter_av->mHeadp) 4616 if (mAvatarObject.notNull() && chatter_av->mHeadp)
4607 { 4617 {
4608 delta_pos = chatter_av->mHeadp->getWorldPosition() - mAvatarObject->mHeadp->getWorldPosition(); 4618 delta_pos = chatter_av->mHeadp->getWorldPosition() - mAvatarObject->mHeadp->getWorldPosition();
4609 } 4619 }
@@ -4684,7 +4694,7 @@ void LLAgent::setStartPosition( U32 location_id )
4684 LLVector3 agent_pos = getPositionAgent(); 4694 LLVector3 agent_pos = getPositionAgent();
4685 LLVector3 agent_look_at = mFrameAgent.getAtAxis(); 4695 LLVector3 agent_look_at = mFrameAgent.getAtAxis();
4686 4696
4687 if (mAvatarObject) 4697 if (mAvatarObject.notNull())
4688 { 4698 {
4689 // the z height is at the agent's feet 4699 // the z height is at the agent's feet
4690 agent_pos.mV[VZ] -= 0.5f * mAvatarObject->mBodySize.mV[VZ]; 4700 agent_pos.mV[VZ] -= 0.5f * mAvatarObject->mBodySize.mV[VZ];
@@ -4808,44 +4818,165 @@ void LLAgent::onAnimStop(const LLUUID& id)
4808 4818
4809BOOL LLAgent::isGodlike() const 4819BOOL LLAgent::isGodlike() const
4810{ 4820{
4811#ifdef HACKED_GODLIKE_VIEWER 4821 return mAgentAccess.isGodlike();
4812 return TRUE;
4813#else
4814 if(mAdminOverride) return TRUE;
4815 return mGodLevel > GOD_NOT;
4816#endif
4817} 4822}
4818 4823
4819U8 LLAgent::getGodLevel() const 4824U8 LLAgent::getGodLevel() const
4820{ 4825{
4821#ifdef HACKED_GODLIKE_VIEWER 4826 return mAgentAccess.getGodLevel();
4822 return GOD_MAINTENANCE;
4823#else
4824 if(mAdminOverride) return GOD_FULL;
4825 return mGodLevel;
4826#endif
4827} 4827}
4828 4828
4829bool LLAgent::isTeen() const 4829bool LLAgent::wantsPGOnly() const
4830{ 4830{
4831 return mAccess < SIM_ACCESS_MATURE; 4831 return mAgentAccess.wantsPGOnly();
4832} 4832}
4833 4833
4834void LLAgent::setTeen(bool teen) 4834bool LLAgent::canAccessMature() const
4835{
4836 return mAgentAccess.canAccessMature();
4837}
4838
4839bool LLAgent::canAccessAdult() const
4840{
4841 return mAgentAccess.canAccessAdult();
4842}
4843
4844bool LLAgent::canAccessMaturityInRegion( U64 region_handle ) const
4835{ 4845{
4836 if (teen) 4846 LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle( region_handle );
4847 if( regionp )
4837 { 4848 {
4838 mAccess = SIM_ACCESS_PG; 4849 switch( regionp->getSimAccess() )
4850 {
4851 case SIM_ACCESS_MATURE:
4852 if( !canAccessMature() )
4853 return false;
4854 break;
4855 case SIM_ACCESS_ADULT:
4856 if( !canAccessAdult() )
4857 return false;
4858 break;
4859 default:
4860 // Oh, go on and hear the silly noises.
4861 break;
4862 }
4839 } 4863 }
4840 else 4864
4865 return true;
4866}
4867
4868bool LLAgent::canAccessMaturityAtGlobal( LLVector3d pos_global ) const
4869{
4870 U64 region_handle = to_region_handle_global( pos_global.mdV[0], pos_global.mdV[1] );
4871 return canAccessMaturityInRegion( region_handle );
4872}
4873
4874bool LLAgent::prefersPG() const
4875{
4876 return mAgentAccess.prefersPG();
4877}
4878
4879bool LLAgent::prefersMature() const
4880{
4881 return mAgentAccess.prefersMature();
4882}
4883
4884bool LLAgent::prefersAdult() const
4885{
4886 return mAgentAccess.prefersAdult();
4887}
4888
4889bool LLAgent::isTeen() const
4890{
4891 return mAgentAccess.isTeen();
4892}
4893
4894bool LLAgent::isMature() const
4895{
4896 return mAgentAccess.isMature();
4897}
4898
4899bool LLAgent::isAdult() const
4900{
4901 return mAgentAccess.isAdult();
4902}
4903
4904void LLAgent::setTeen(bool teen)
4905{
4906 mAgentAccess.setTeen(teen);
4907}
4908
4909//static
4910int LLAgent::convertTextToMaturity(char text)
4911{
4912 return LLAgentAccess::convertTextToMaturity(text);
4913}
4914
4915bool LLAgent::sendMaturityPreferenceToServer(int preferredMaturity)
4916{
4917 // Update agent access preference on the server
4918 std::string url = getRegion()->getCapability("UpdateAgentInformation");
4919 if (!url.empty())
4841 { 4920 {
4842 mAccess = SIM_ACCESS_MATURE; 4921 // Set new access preference
4922 LLSD access_prefs = LLSD::emptyMap();
4923 if (preferredMaturity == SIM_ACCESS_PG)
4924 {
4925 access_prefs["max"] = "PG";
4926 }
4927 else if (preferredMaturity == SIM_ACCESS_MATURE)
4928 {
4929 access_prefs["max"] = "M";
4930 }
4931 if (preferredMaturity == SIM_ACCESS_ADULT)
4932 {
4933 access_prefs["max"] = "A";
4934 }
4935
4936 LLSD body = LLSD::emptyMap();
4937 body["access_prefs"] = access_prefs;
4938 llinfos << "Sending access prefs update to " << (access_prefs["max"].asString()) << " via capability to: "
4939 << url << llendl;
4940 LLHTTPClient::post(url, body, new LLHTTPClient::Responder()); // Ignore response
4941 return true;
4843 } 4942 }
4943 return false;
4944}
4945
4946BOOL LLAgent::getAdminOverride() const
4947{
4948 return mAgentAccess.getAdminOverride();
4949}
4950
4951void LLAgent::setMaturity(char text)
4952{
4953 mAgentAccess.setMaturity(text);
4954}
4955
4956void LLAgent::setAdminOverride(BOOL b)
4957{
4958 mAgentAccess.setAdminOverride(b);
4959}
4960
4961void LLAgent::setGodLevel(U8 god_level)
4962{
4963 mAgentAccess.setGodLevel(god_level);
4964}
4965
4966void LLAgent::setAOTransition()
4967{
4968 mAgentAccess.setTransition();
4844} 4969}
4845 4970
4971const LLAgentAccess& LLAgent::getAgentAccess()
4972{
4973 return mAgentAccess;
4974}
4975
4976
4846void LLAgent::buildFullname(std::string& name) const 4977void LLAgent::buildFullname(std::string& name) const
4847{ 4978{
4848 if (mAvatarObject) 4979 if (mAvatarObject.notNull())
4849 { 4980 {
4850 name = mAvatarObject->getFullname(); 4981 name = mAvatarObject->getFullname();
4851 } 4982 }
@@ -4863,7 +4994,7 @@ void LLAgent::buildFullnameAndTitle(std::string& name) const
4863 name.erase(0, name.length()); 4994 name.erase(0, name.length());
4864 } 4995 }
4865 4996
4866 if (mAvatarObject) 4997 if (mAvatarObject.notNull())
4867 { 4998 {
4868 name += mAvatarObject->getFullname(); 4999 name += mAvatarObject->getFullname();
4869 } 5000 }
@@ -5218,7 +5349,7 @@ void LLAgent::getName(std::string& name)
5218{ 5349{
5219 name.clear(); 5350 name.clear();
5220 5351
5221 if (mAvatarObject) 5352 if (mAvatarObject.notNull())
5222 { 5353 {
5223 LLNameValue *first_nv = mAvatarObject->getNVPair("FirstName"); 5354 LLNameValue *first_nv = mAvatarObject->getNVPair("FirstName");
5224 LLNameValue *last_nv = mAvatarObject->getNVPair("LastName"); 5355 LLNameValue *last_nv = mAvatarObject->getNVPair("LastName");
@@ -5728,11 +5859,11 @@ void LLAgent::processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void *
5728 mesgsys->getU8Fast(_PREHASH_WearableData, _PREHASH_TextureIndex, texture_index, texture_block); 5859 mesgsys->getU8Fast(_PREHASH_WearableData, _PREHASH_TextureIndex, texture_index, texture_block);
5729 5860
5730 if (texture_id.notNull() 5861 if (texture_id.notNull()
5731 && (S32)texture_index < BAKED_TEXTURE_COUNT 5862 && (S32)texture_index < BAKED_NUM_INDICES
5732 && gAgent.mActiveCacheQueries[ texture_index ] == query_id) 5863 && gAgent.mActiveCacheQueries[ texture_index ] == query_id)
5733 { 5864 {
5734 //llinfos << "Received cached texture " << (U32)texture_index << ": " << texture_id << llendl; 5865 //llinfos << "Received cached texture " << (U32)texture_index << ": " << texture_id << llendl;
5735 avatarp->setCachedBakedTexture((LLVOAvatar::ETextureIndex)LLVOAvatar::sBakedTextureIndices[texture_index], texture_id); 5866 avatarp->setCachedBakedTexture(getTextureIndex((EBakedTextureIndex)texture_index), texture_id);
5736 //avatarp->setTETexture( LLVOAvatar::sBakedTextureIndices[texture_index], texture_id ); 5867 //avatarp->setTETexture( LLVOAvatar::sBakedTextureIndices[texture_index], texture_id );
5737 gAgent.mActiveCacheQueries[ texture_index ] = 0; 5868 gAgent.mActiveCacheQueries[ texture_index ] = 0;
5738 num_results++; 5869 num_results++;
@@ -5822,18 +5953,24 @@ bool LLAgent::teleportCore(bool is_local)
5822 return false; 5953 return false;
5823 } 5954 }
5824 5955
5956#if 0
5957 // This should not exist. It has been added, removed, added, and now removed again.
5958 // This change needs to come from the simulator. Otherwise, the agent ends up out of
5959 // sync with other viewers. Discuss in DEV-14145/VWR-6744 before reenabling.
5960
5825 // Stop all animation before actual teleporting 5961 // Stop all animation before actual teleporting
5826 LLVOAvatar* avatarp = gAgent.getAvatarObject(); 5962 LLVOAvatar* avatarp = gAgent.getAvatarObject();
5827 if (avatarp) 5963 if (avatarp)
5828 { 5964 {
5829 for ( LLVOAvatar::AnimIterator anim_it= avatarp->mPlayingAnimations.begin() 5965 for ( LLVOAvatar::AnimIterator anim_it= avatarp->mPlayingAnimations.begin();
5830 ; anim_it != avatarp->mPlayingAnimations.end() 5966 anim_it != avatarp->mPlayingAnimations.end();
5831 ; anim_it++) 5967 ++anim_it)
5832 { 5968 {
5833 avatarp->stopMotion(anim_it->first); 5969 avatarp->stopMotion(anim_it->first);
5834 } 5970 }
5835 avatarp->processAnimationStateChanges(); 5971 avatarp->processAnimationStateChanges();
5836 } 5972 }
5973#endif
5837 5974
5838 // Don't call LLFirstUse::useTeleport because we don't know 5975 // Don't call LLFirstUse::useTeleport because we don't know
5839 // yet if the teleport will succeed. Look in 5976 // yet if the teleport will succeed. Look in
@@ -6012,6 +6149,42 @@ void LLAgent::setTeleportState(ETeleportState state)
6012 } 6149 }
6013} 6150}
6014 6151
6152void LLAgent::stopCurrentAnimations()
6153{
6154 // This function stops all current overriding animations on this
6155 // avatar, propagating this change back to the server.
6156
6157 LLVOAvatar* avatarp = gAgent.getAvatarObject();
6158 if (avatarp)
6159 {
6160 for ( LLVOAvatar::AnimIterator anim_it =
6161 avatarp->mPlayingAnimations.begin();
6162 anim_it != avatarp->mPlayingAnimations.end();
6163 anim_it++)
6164 {
6165 if (anim_it->first ==
6166 ANIM_AGENT_SIT_GROUND_CONSTRAINED)
6167 {
6168 // don't cancel a ground-sit anim, as viewers
6169 // use this animation's status in
6170 // determining whether we're sitting. ick.
6171 }
6172 else
6173 {
6174 // stop this animation locally
6175 avatarp->stopMotion(anim_it->first, TRUE);
6176 // ...and tell the server to tell everyone.
6177 sendAnimationRequest(anim_it->first, ANIM_REQUEST_STOP);
6178 }
6179 }
6180
6181 // re-assert at least the default standing animation, because
6182 // viewers get confused by avs with no associated anims.
6183 sendAnimationRequest(ANIM_AGENT_STAND,
6184 ANIM_REQUEST_START);
6185 }
6186}
6187
6015void LLAgent::fidget() 6188void LLAgent::fidget()
6016{ 6189{
6017 if (!getAFK()) 6190 if (!getAFK())
@@ -6284,6 +6457,8 @@ void LLAgent::saveWearable( EWearableType type, BOOL send_update )
6284 addWearableToAgentInventory(cb, new_wearable); 6457 addWearableToAgentInventory(cb, new_wearable);
6285 return; 6458 return;
6286 } 6459 }
6460
6461 getAvatarObject()->wearableUpdated( type );
6287 6462
6288 if( send_update ) 6463 if( send_update )
6289 { 6464 {
@@ -6682,7 +6857,7 @@ void LLAgent::onInitialWearableAssetArrived( LLWearable* wearable, void* userdat
6682void LLAgent::recoverMissingWearable( EWearableType type ) 6857void LLAgent::recoverMissingWearable( EWearableType type )
6683{ 6858{
6684 // Try to recover by replacing missing wearable with a new one. 6859 // Try to recover by replacing missing wearable with a new one.
6685 LLNotifyBox::showXml("ReplacedMissingWearable"); 6860 LLNotifications::instance().add("ReplacedMissingWearable");
6686 lldebugs << "Wearable " << LLWearable::typeToTypeLabel( type ) << " could not be downloaded. Replaced inventory item with default wearable." << llendl; 6861 lldebugs << "Wearable " << LLWearable::typeToTypeLabel( type ) << " could not be downloaded. Replaced inventory item with default wearable." << llendl;
6687 LLWearable* new_wearable = gWearableList.createNewWearable(type); 6862 LLWearable* new_wearable = gWearableList.createNewWearable(type);
6688 6863
@@ -6983,11 +7158,8 @@ void LLAgent::sendAgentSetAppearance()
6983 return; 7158 return;
6984 } 7159 }
6985 7160
6986 llinfos << "TAT: Sent AgentSetAppearance: " << 7161
6987 (( mAvatarObject->getTEImage( LLVOAvatar::TEX_HEAD_BAKED )->getID() != IMG_DEFAULT_AVATAR ) ? "HEAD " : "head " ) << 7162 llinfos << "TAT: Sent AgentSetAppearance: " << mAvatarObject->getBakedStatusForPrintout() << llendl;
6988 (( mAvatarObject->getTEImage( LLVOAvatar::TEX_UPPER_BAKED )->getID() != IMG_DEFAULT_AVATAR ) ? "UPPER " : "upper " ) <<
6989 (( mAvatarObject->getTEImage( LLVOAvatar::TEX_LOWER_BAKED )->getID() != IMG_DEFAULT_AVATAR ) ? "LOWER " : "lower " ) <<
6990 (( mAvatarObject->getTEImage( LLVOAvatar::TEX_EYES_BAKED )->getID() != IMG_DEFAULT_AVATAR ) ? "EYES" : "eyes" ) << llendl;
6991 //dumpAvatarTEs( "sendAgentSetAppearance()" ); 7163 //dumpAvatarTEs( "sendAgentSetAppearance()" );
6992 7164
6993 LLMessageSystem* msg = gMessageSystem; 7165 LLMessageSystem* msg = gMessageSystem;
@@ -7001,7 +7173,7 @@ void LLAgent::sendAgentSetAppearance()
7001 // NOTE -- when we start correcting all of the other Havok geometry 7173 // NOTE -- when we start correcting all of the other Havok geometry
7002 // to compensate for the COLLISION_TOLERANCE ugliness we will have 7174 // to compensate for the COLLISION_TOLERANCE ugliness we will have
7003 // to tweak this number again 7175 // to tweak this number again
7004 LLVector3 body_size = mAvatarObject->mBodySize; 7176 const LLVector3 body_size = mAvatarObject->mBodySize;
7005 msg->addVector3Fast(_PREHASH_Size, body_size); 7177 msg->addVector3Fast(_PREHASH_Size, body_size);
7006 7178
7007 // To guard against out of order packets 7179 // To guard against out of order packets
@@ -7013,19 +7185,18 @@ void LLAgent::sendAgentSetAppearance()
7013 // KLW - TAT this will probably need to check the local queue. 7185 // KLW - TAT this will probably need to check the local queue.
7014 BOOL textures_current = !mAvatarObject->hasPendingBakedUploads() && mWearablesLoaded; 7186 BOOL textures_current = !mAvatarObject->hasPendingBakedUploads() && mWearablesLoaded;
7015 7187
7016 S32 baked_texture_index; 7188 for(U8 baked_index = 0; baked_index < BAKED_NUM_INDICES; baked_index++ )
7017 for( baked_texture_index = 0; baked_texture_index < BAKED_TEXTURE_COUNT; baked_texture_index++ )
7018 { 7189 {
7019 S32 tex_index = LLVOAvatar::sBakedTextureIndices[baked_texture_index]; 7190 const ETextureIndex texture_index = getTextureIndex((EBakedTextureIndex)baked_index);
7020 7191
7021 // if we're not wearing a skirt, we don't need the texture to be baked 7192 // if we're not wearing a skirt, we don't need the texture to be baked
7022 if (tex_index == LLVOAvatar::TEX_SKIRT_BAKED && !mAvatarObject->isWearingWearableType(WT_SKIRT)) 7193 if (texture_index == TEX_SKIRT_BAKED && !mAvatarObject->isWearingWearableType(WT_SKIRT))
7023 { 7194 {
7024 continue; 7195 continue;
7025 } 7196 }
7026 7197
7027 // IMG_DEFAULT_AVATAR means not baked 7198 // IMG_DEFAULT_AVATAR means not baked
7028 if (mAvatarObject->getTEImage( tex_index)->getID() == IMG_DEFAULT_AVATAR) 7199 if (!mAvatarObject->isTextureDefined(texture_index))
7029 { 7200 {
7030 textures_current = FALSE; 7201 textures_current = FALSE;
7031 break; 7202 break;
@@ -7036,50 +7207,56 @@ void LLAgent::sendAgentSetAppearance()
7036 if (textures_current) 7207 if (textures_current)
7037 { 7208 {
7038 llinfos << "TAT: Sending cached texture data" << llendl; 7209 llinfos << "TAT: Sending cached texture data" << llendl;
7039 for (baked_texture_index = 0; baked_texture_index < BAKED_TEXTURE_COUNT; baked_texture_index++) 7210 for (U8 baked_index = 0; baked_index < BAKED_NUM_INDICES; baked_index++)
7040 { 7211 {
7212 const LLVOAvatarDictionary::WearableDictionaryEntry *wearable_dict = LLVOAvatarDictionary::getInstance()->getWearable((EBakedTextureIndex)baked_index);
7041 LLUUID hash; 7213 LLUUID hash;
7042 7214 for (U8 i=0; i < wearable_dict->mWearablesVec.size(); i++)
7043 for( S32 wearable_num = 0; wearable_num < MAX_WEARABLES_PER_LAYERSET; wearable_num++ )
7044 { 7215 {
7045 EWearableType wearable_type = WEARABLE_BAKE_TEXTURE_MAP[baked_texture_index][wearable_num]; 7216 // EWearableType wearable_type = gBakedWearableMap[baked_index][wearable_num];
7046 7217 const EWearableType wearable_type = wearable_dict->mWearablesVec[i];
7047 LLWearable* wearable = getWearable( wearable_type ); 7218 const LLWearable* wearable = getWearable(wearable_type);
7048 if (wearable) 7219 if (wearable)
7049 { 7220 {
7050 hash ^= wearable->getID(); 7221 hash ^= wearable->getID();
7051 } 7222 }
7052 } 7223 }
7053
7054 if (hash.notNull()) 7224 if (hash.notNull())
7055 { 7225 {
7056 hash ^= BAKED_TEXTURE_HASH[baked_texture_index]; 7226 hash ^= wearable_dict->mHashID;
7057 } 7227 }
7058 7228
7059 S32 tex_index = LLVOAvatar::sBakedTextureIndices[baked_texture_index]; 7229 const ETextureIndex texture_index = getTextureIndex((EBakedTextureIndex)baked_index);
7060 7230
7061 msg->nextBlockFast(_PREHASH_WearableData); 7231 msg->nextBlockFast(_PREHASH_WearableData);
7062 msg->addUUIDFast(_PREHASH_CacheID, hash); 7232 msg->addUUIDFast(_PREHASH_CacheID, hash);
7063 msg->addU8Fast(_PREHASH_TextureIndex, (U8)tex_index); 7233 msg->addU8Fast(_PREHASH_TextureIndex, (U8)texture_index);
7064 } 7234 }
7235 msg->nextBlockFast(_PREHASH_ObjectData);
7236 mAvatarObject->packTEMessage( gMessageSystem );
7237 }
7238 else
7239 {
7240 // If the textures aren't baked, send NULL for texture IDs
7241 // This means the baked texture IDs on the server will be untouched.
7242 // Once all textures are baked, another AvatarAppearance message will be sent to update the TEs
7243 msg->nextBlockFast(_PREHASH_ObjectData);
7244 gMessageSystem->addBinaryDataFast(_PREHASH_TextureEntry, NULL, 0);
7065 } 7245 }
7066 7246
7067 msg->nextBlockFast(_PREHASH_ObjectData);
7068 mAvatarObject->packTEMessage( gMessageSystem );
7069 7247
7070 S32 transmitted_params = 0; 7248 S32 transmitted_params = 0;
7071 for (LLViewerVisualParam* param = (LLViewerVisualParam*)mAvatarObject->getFirstVisualParam(); 7249 for (LLViewerVisualParam* param = (LLViewerVisualParam*)mAvatarObject->getFirstVisualParam();
7072 param; 7250 param;
7073 param = (LLViewerVisualParam*)mAvatarObject->getNextVisualParam()) 7251 param = (LLViewerVisualParam*)mAvatarObject->getNextVisualParam())
7074 { 7252 {
7075 F32 param_value = param->getWeight();
7076
7077 if (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE) 7253 if (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE)
7078 { 7254 {
7079 msg->nextBlockFast(_PREHASH_VisualParam ); 7255 msg->nextBlockFast(_PREHASH_VisualParam );
7080 7256
7081 // We don't send the param ids. Instead, we assume that the receiver has the same params in the same sequence. 7257 // We don't send the param ids. Instead, we assume that the receiver has the same params in the same sequence.
7082 U8 new_weight = F32_to_U8(param_value, param->getMinWeight(), param->getMaxWeight()); 7258 const F32 param_value = param->getWeight();
7259 const U8 new_weight = F32_to_U8(param_value, param->getMinWeight(), param->getMaxWeight());
7083 msg->addU8Fast(_PREHASH_ParamValue, new_weight ); 7260 msg->addU8Fast(_PREHASH_ParamValue, new_weight );
7084 transmitted_params++; 7261 transmitted_params++;
7085 } 7262 }
@@ -7113,8 +7290,10 @@ void LLAgent::removeWearable( EWearableType type )
7113 { 7290 {
7114 if( old_wearable->isDirty() ) 7291 if( old_wearable->isDirty() )
7115 { 7292 {
7293 LLSD payload;
7294 payload["wearable_type"] = (S32)type;
7116 // Bring up view-modal dialog: Save changes? Yes, No, Cancel 7295 // Bring up view-modal dialog: Save changes? Yes, No, Cancel
7117 gViewerWindow->alertXml("WearableSave", LLAgent::onRemoveWearableDialog, (void*)type ); 7296 LLNotifications::instance().add("WearableSave", LLSD(), payload, &LLAgent::onRemoveWearableDialog);
7118 return; 7297 return;
7119 } 7298 }
7120 else 7299 else
@@ -7125,9 +7304,10 @@ void LLAgent::removeWearable( EWearableType type )
7125} 7304}
7126 7305
7127// static 7306// static
7128void LLAgent::onRemoveWearableDialog( S32 option, void* userdata ) 7307bool LLAgent::onRemoveWearableDialog(const LLSD& notification, const LLSD& response )
7129{ 7308{
7130 EWearableType type = (EWearableType)(intptr_t)userdata; 7309 S32 option = LLNotification::getSelectedOption(notification, response);
7310 EWearableType type = (EWearableType)notification["payload"]["wearable_type"].asInteger();
7131 switch( option ) 7311 switch( option )
7132 { 7312 {
7133 case 0: // "Save" 7313 case 0: // "Save"
@@ -7146,6 +7326,7 @@ void LLAgent::onRemoveWearableDialog( S32 option, void* userdata )
7146 llassert(0); 7326 llassert(0);
7147 break; 7327 break;
7148 } 7328 }
7329 return false;
7149} 7330}
7150 7331
7151// Called by removeWearable() and onRemoveWearableDialog() to actually do the removal. 7332// Called by removeWearable() and onRemoveWearableDialog() to actually do the removal.
@@ -7314,8 +7495,6 @@ void LLAgent::setWearableOutfit(
7314 wearables[i]->writeToAvatar( TRUE ); 7495 wearables[i]->writeToAvatar( TRUE );
7315 } 7496 }
7316 7497
7317 LLFloaterCustomize::setCurrentWearableType( WT_SHAPE );
7318
7319 // Start rendering & update the server 7498 // Start rendering & update the server
7320 mWearablesLoaded = TRUE; 7499 mWearablesLoaded = TRUE;
7321 sendAgentWearablesUpdate(); 7500 sendAgentWearablesUpdate();
@@ -7344,8 +7523,9 @@ void LLAgent::setWearable( LLInventoryItem* new_item, LLWearable* new_wearable )
7344 if( old_wearable->isDirty() ) 7523 if( old_wearable->isDirty() )
7345 { 7524 {
7346 // Bring up modal dialog: Save changes? Yes, No, Cancel 7525 // Bring up modal dialog: Save changes? Yes, No, Cancel
7347 gViewerWindow->alertXml( "WearableSave", LLAgent::onSetWearableDialog, 7526 LLSD payload;
7348 new LLSetWearableData( new_item->getUUID(), new_wearable )); 7527 payload["item_id"] = new_item->getUUID();
7528 LLNotifications::instance().add( "WearableSave", LLSD(), payload, boost::bind(LLAgent::onSetWearableDialog, _1, _2, new_wearable));
7349 return; 7529 return;
7350 } 7530 }
7351 } 7531 }
@@ -7354,25 +7534,25 @@ void LLAgent::setWearable( LLInventoryItem* new_item, LLWearable* new_wearable )
7354} 7534}
7355 7535
7356// static 7536// static
7357void LLAgent::onSetWearableDialog( S32 option, void* userdata ) 7537bool LLAgent::onSetWearableDialog( const LLSD& notification, const LLSD& response, LLWearable* wearable )
7358{ 7538{
7359 LLSetWearableData* data = (LLSetWearableData*)userdata; 7539 S32 option = LLNotification::getSelectedOption(notification, response);
7360 LLInventoryItem* new_item = gInventory.getItem( data->mNewItemID ); 7540 LLInventoryItem* new_item = gInventory.getItem( notification["payload"]["item_id"].asUUID());
7361 if( !new_item ) 7541 if( !new_item )
7362 { 7542 {
7363 delete data; 7543 delete wearable;
7364 return; 7544 return false;
7365 } 7545 }
7366 7546
7367 switch( option ) 7547 switch( option )
7368 { 7548 {
7369 case 0: // "Save" 7549 case 0: // "Save"
7370 gAgent.saveWearable( data->mNewWearable->getType() ); 7550 gAgent.saveWearable( wearable->getType() );
7371 gAgent.setWearableFinal( new_item, data->mNewWearable ); 7551 gAgent.setWearableFinal( new_item, wearable );
7372 break; 7552 break;
7373 7553
7374 case 1: // "Don't Save" 7554 case 1: // "Don't Save"
7375 gAgent.setWearableFinal( new_item, data->mNewWearable ); 7555 gAgent.setWearableFinal( new_item, wearable );
7376 break; 7556 break;
7377 7557
7378 case 2: // "Cancel" 7558 case 2: // "Cancel"
@@ -7383,7 +7563,8 @@ void LLAgent::onSetWearableDialog( S32 option, void* userdata )
7383 break; 7563 break;
7384 } 7564 }
7385 7565
7386 delete data; 7566 delete wearable;
7567 return false;
7387} 7568}
7388 7569
7389// Called from setWearable() and onSetWearableDialog() to actually set the wearable. 7570// Called from setWearable() and onSetWearableDialog() to actually set the wearable.
@@ -7435,14 +7616,15 @@ void LLAgent::queryWearableCache()
7435 gMessageSystem->addS32Fast(_PREHASH_SerialNum, mTextureCacheQueryID); 7616 gMessageSystem->addS32Fast(_PREHASH_SerialNum, mTextureCacheQueryID);
7436 7617
7437 S32 num_queries = 0; 7618 S32 num_queries = 0;
7438 for (S32 baked_texture_index = 0; baked_texture_index < BAKED_TEXTURE_COUNT; baked_texture_index++) 7619 for (U8 baked_index = 0; baked_index < BAKED_NUM_INDICES; baked_index++ )
7439 { 7620 {
7621 const LLVOAvatarDictionary::WearableDictionaryEntry *wearable_dict = LLVOAvatarDictionary::getInstance()->getWearable((EBakedTextureIndex)baked_index);
7440 LLUUID hash; 7622 LLUUID hash;
7441 for (S32 wearable_num = 0; wearable_num < MAX_WEARABLES_PER_LAYERSET; wearable_num++) 7623 for (U8 i=0; i < wearable_dict->mWearablesVec.size(); i++)
7442 { 7624 {
7443 EWearableType wearable_type = WEARABLE_BAKE_TEXTURE_MAP[baked_texture_index][wearable_num]; 7625 // EWearableType wearable_type = gBakedWearableMap[baked_index][wearable_num];
7444 7626 const EWearableType wearable_type = wearable_dict->mWearablesVec[i];
7445 LLWearable* wearable = getWearable( wearable_type ); 7627 const LLWearable* wearable = getWearable(wearable_type);
7446 if (wearable) 7628 if (wearable)
7447 { 7629 {
7448 hash ^= wearable->getID(); 7630 hash ^= wearable->getID();
@@ -7450,17 +7632,17 @@ void LLAgent::queryWearableCache()
7450 } 7632 }
7451 if (hash.notNull()) 7633 if (hash.notNull())
7452 { 7634 {
7453 hash ^= BAKED_TEXTURE_HASH[baked_texture_index]; 7635 hash ^= wearable_dict->mHashID;
7454 num_queries++; 7636 num_queries++;
7455 // *NOTE: make sure at least one request gets packed 7637 // *NOTE: make sure at least one request gets packed
7456 7638
7457 //llinfos << "Requesting texture for hash " << hash << " in baked texture slot " << baked_texture_index << llendl; 7639 //llinfos << "Requesting texture for hash " << hash << " in baked texture slot " << baked_index << llendl;
7458 gMessageSystem->nextBlockFast(_PREHASH_WearableData); 7640 gMessageSystem->nextBlockFast(_PREHASH_WearableData);
7459 gMessageSystem->addUUIDFast(_PREHASH_ID, hash); 7641 gMessageSystem->addUUIDFast(_PREHASH_ID, hash);
7460 gMessageSystem->addU8Fast(_PREHASH_TextureIndex, (U8)baked_texture_index); 7642 gMessageSystem->addU8Fast(_PREHASH_TextureIndex, (U8)baked_index);
7461 } 7643 }
7462 7644
7463 mActiveCacheQueries[ baked_texture_index ] = mTextureCacheQueryID; 7645 mActiveCacheQueries[ baked_index ] = mTextureCacheQueryID;
7464 } 7646 }
7465 7647
7466 llinfos << "Requesting texture cache entry for " << num_queries << " baked textures" << llendl; 7648 llinfos << "Requesting texture cache entry for " << num_queries << " baked textures" << llendl;
@@ -7487,7 +7669,7 @@ void LLAgent::userRemoveAllClothes( void* userdata )
7487 // We have to do this up front to avoid having to deal with the case of multiple wearables being dirty. 7669 // We have to do this up front to avoid having to deal with the case of multiple wearables being dirty.
7488 if( gFloaterCustomize ) 7670 if( gFloaterCustomize )
7489 { 7671 {
7490 gFloaterCustomize->askToSaveAllIfDirty( LLAgent::userRemoveAllClothesStep2, NULL ); 7672 gFloaterCustomize->askToSaveIfDirty( LLAgent::userRemoveAllClothesStep2, NULL );
7491 } 7673 }
7492 else 7674 else
7493 { 7675 {