37
37
#include " lldrawable.h"
38
38
#include " llviewerobjectlist.h"
39
39
#include " llviewercontrol.h"
40
+ #include " llvoavatarself.h"
40
41
#include " llrendersphere.h"
41
42
#include " llselectmgr.h"
42
43
#include " llglheaders.h"
@@ -390,7 +391,7 @@ void LLHUDEffectLookAt::setTargetPosGlobal(const LLVector3d &target_pos_global)
390
391
// setLookAt()
391
392
// called by agent logic to set look at behavior locally, and propagate to sim
392
393
// -----------------------------------------------------------------------------
393
- bool LLHUDEffectLookAt::setLookAt (ELookAtType target_type, LLViewerObject * object, LLVector3 position)
394
+ bool LLHUDEffectLookAt::setLookAt (ELookAtType target_type, LLViewerObject* object, LLVector3 position)
394
395
{
395
396
static LLCachedControl<bool > enable_lookat_hints (gSavedSettings , " EnableLookAtHints" , true );
396
397
if (!enable_lookat_hints)
@@ -415,6 +416,29 @@ bool LLHUDEffectLookAt::setLookAt(ELookAtType target_type, LLViewerObject *objec
415
416
return false ;
416
417
}
417
418
419
+ static LLCachedControl<bool > limit_lookat_hints (gSavedSettings , " LimitLookAtHints" , true );
420
+ // Don't affect the look at if object is gAgentAvatarp (cursor head follow)
421
+ if (limit_lookat_hints && object != gAgentAvatarp )
422
+ {
423
+ // If it is a object
424
+ if (object)
425
+ {
426
+ position += object->getRenderPosition ();
427
+ object = NULL ;
428
+ }
429
+
430
+ LLVector3 agentHeadPosition = gAgentAvatarp ->mHeadp ->getWorldPosition ();
431
+ float dist = (float )dist_vec (agentHeadPosition, position);
432
+
433
+ static LLCachedControl<F32> limit_lookat_hints_distance (gSavedSettings , " LimitLookAtHintsDistance" , 2 .0f );
434
+ if (dist > limit_lookat_hints_distance)
435
+ {
436
+ LLVector3 headOffset = position - agentHeadPosition;
437
+ headOffset *= limit_lookat_hints_distance / dist;
438
+ position.setVec (agentHeadPosition + headOffset);
439
+ }
440
+ }
441
+
418
442
F32 current_time = mTimer .getElapsedTimeF32 ();
419
443
420
444
// type of lookat behavior or target object has changed
0 commit comments