원본 셰이핑을 보존하면서 글리프의 가로·세로 오프셋에 떨림을 더한다.
33{
34 if (Amplitude < KINDA_SMALL_NUMBER || Speed < KINDA_SMALL_NUMBER)
35 {
36 return Sequence;
37 }
38
39
40 TArray<FShapedGlyphEntry> Glyphs = Sequence->GetGlyphsToRender();
41 const int64 Step = FMath::FloorToInt64(Time * Speed);
42
43 for (FShapedGlyphEntry& Glyph : Glyphs)
44 {
45
46 FRandomStream Random(HashCombine(GetTypeHash(Step), GetTypeHash(Glyph.SourceIndex - RunBeginIndex)));
47 const int32 X = FMath::RoundToInt(Random.FRandRange(-Amplitude, Amplitude) * Scale);
48 const int32 Y = FMath::RoundToInt(Random.FRandRange(-Amplitude, Amplitude) * Scale);
49
50 Glyph.XOffset = static_cast<int16>(FMath::Clamp<int32>(Glyph.XOffset + X, MIN_int16, MAX_int16));
51 Glyph.YOffset = static_cast<int16>(FMath::Clamp<int32>(Glyph.YOffset + Y, MIN_int16, MAX_int16));
52 }
53
54
55 return MakeShared<FShapedGlyphSequence>
56 (
57 MoveTemp(Glyphs),
58 Sequence->GetTextBaseline(),
59 Sequence->GetMaxTextHeight(),
60 Sequence->GetFontMaterial(),
61 Sequence->IsMaterialStencil(),
62 Sequence->GetFontOutlineSettings(),
63 FShapedGlyphSequence::FSourceTextRange(BlockRange.BeginIndex, BlockRange.Len())
64 );
65}