Skip to content

Commit

Permalink
Merge pull request #15 from z3y/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
z3y authored May 2, 2023
2 parents c124acd + a877cbb commit c8ad26a
Show file tree
Hide file tree
Showing 3 changed files with 330 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Runtime/Scripts/MarkerSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public override void OnDeserialization()
if (markerTrail.enabled)
{
markerTrail.StopWriting();
markerTrail.AddEndCap();
//markerTrail.AddEndCap();
}
markerTrail.StartWriting();
break;
case 1: // stop writing without sync
markerTrail.StopWriting();
markerTrail.AddEndCap();
//markerTrail.AddEndCap();
markerTrail.UpdateUsedVertices();
markerTrail.RecalculateMeshBounds();
break;
Expand Down
14 changes: 9 additions & 5 deletions Runtime/Scripts/MarkerTrail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,20 @@ public void SetGradient(MaterialPropertyBlock pb)

private void Update()
{
_time += Time.deltaTime;
if (!enabled) // can end up running for a frame breaking things
{
return;
}

_time += Time.deltaTime;

_smoothingPosition = Vector3.Lerp(trailPosition.position, _previousSmoothingPosition, _smoothingCached);
_previousSmoothingPosition = _smoothingPosition;

UpdateLastPosition(_smoothingPosition, _previousPosition);
UpdateMeshData();

if (_time <= updateRate || Vector3.Distance(_smoothingPosition, _previousPosition) < minDistance || !enabled)
if (_time <= updateRate || Vector3.Distance(_smoothingPosition, _previousPosition) < minDistance)
{
return;
}
Expand Down Expand Up @@ -164,18 +168,18 @@ public void StopWriting()

if (isLocal && GetSyncLines().Length > 1)
{
AddEndCap();
//AddEndCap();
StoreLastLinesTransform(_smoothingPosition);
RecalculateMeshBounds();
}
}

public void AddEndCap()
/* public void AddEndCap()
{
CreateTrailLine(_previousPosition, _smoothingPosition);
//CreateTrailLine(_smoothingPosition, _previousPosition); // mot needed anymore
UpdateMeshData();
}
}*/



Expand Down
Loading

0 comments on commit c8ad26a

Please sign in to comment.