Skip to content

Commit

Permalink
[Misc] Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
riperiperi committed Feb 9, 2020
1 parent ade1b56 commit 0577148
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
25 changes: 15 additions & 10 deletions TSOClient/tso.simantics/Entities/VMAvatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -663,18 +663,23 @@ private void UpdateHeadSeek()
case 1:
if (targ == null) goto case 4;
//keep seeking to target
var hseekdiff = VM.UseWorld ? (targ.WorldUI.GetLookTarget() - new Vector3(VisualPosition.X, VisualPosition.Z, VisualPosition.Y)) * 3f : Vector3.Zero;
hseekdiff.Y -= 1f;

Avatar.HeadSeekTarget = Animator.CalculateHeadSeek(Avatar, hseekdiff, RadianDirection);
if (Avatar.HeadSeekWeight == 0)
{
Avatar.HeadSeek = Avatar.HeadSeekTarget;
} else
if (UseWorld)
{
Avatar.SlideHeadToTarget(1 - Avatar.LastSeekFraction);
Avatar.LastSeekFraction = 0;
var hseekdiff = (targ.WorldUI.GetLookTarget() - new Vector3(VisualPosition.X, VisualPosition.Z, VisualPosition.Y)) * 3f;
hseekdiff.Y -= 1f;

Avatar.HeadSeekTarget = Animator.CalculateHeadSeek(Avatar, hseekdiff, RadianDirection);
if (Avatar.HeadSeekWeight == 0)
{
Avatar.HeadSeek = Avatar.HeadSeekTarget;
}
else
{
Avatar.SlideHeadToTarget(1 - Avatar.LastSeekFraction);
Avatar.LastSeekFraction = 0;
}
}

Avatar.HeadSeekWeight = Math.Min(SimAvatar.HEAD_SEEK_LENGTH, Avatar.HeadSeekWeight + 1);

if (PersonData[(int)VMPersonDataVariable.HeadSeekTimeout] > 0)
Expand Down
3 changes: 0 additions & 3 deletions TSOClient/tso.vitaboy.engine/Animator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,11 @@ public static Quaternion CalculateHeadSeek(Avatar avatar, Vector3 target, float
var dirh = (float)Math.Atan2(-diff.Y, diff.Z);
var dist = Math.Sqrt(diff.Z * diff.Z + diff.Y * diff.Y);
var dirv = (float)Math.Atan(diff.X / dist);
//diff.Y = 0;

var rand = new Random();
dirv = Math.Min((float)Math.PI / 4, Math.Max((float)Math.PI / -4, dirv));
var hlimit = (float)Math.PI * (65f / 180f);
dirh = Math.Min(hlimit, Math.Max(-hlimit, dirh));


var mat = Matrix.CreateRotationY(dirv) * Matrix.CreateRotationX(dirh);
var quat = Quaternion.CreateFromRotationMatrix(mat);
return quat;
Expand Down

0 comments on commit 0577148

Please sign in to comment.