UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SlateVectorArtInstanceData.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
7#include "Math/Vector2D.h"
8#include "Math/Vector4.h"
10
12{
13public:
14 const FVector4& GetData() const { return Data; }
15 FVector4& GetData() { return Data; }
16
19
21 UMG_API void SetScale(float Scale);
22 UMG_API void SetBaseAddress(float Address);
23
24 template<int32 Component, int32 ByteIndex>
26 {
27 PackByteIntoByte<Component, ByteIndex>(static_cast<uint8>(FMath::RoundToInt(InValue * 0xFFu)));
28 }
29
30 template<int32 Component, int32 ByteIndex>
32 {
33 // Each float has 24 usable bits of mantissa, but we cannot access the bits directly.
34 // We will not respect the IEEE "normalized mantissa" rules, so let
35 // the compiler/FPU do conversions from byte to float and vice versa for us.
36
37 //Produces a value like 0xFFFF00FF; where the 00s are shifted by `Position` bytes.
38 static const uint32 Mask = ~(0xFF << ByteIndex * 8);
39
40 // Clear out a byte to OR with while maintaining the rest of the data intact.
41 uint32 CurrentData = static_cast<uint32>(Data[Component]) & Mask;
42 // OR in the value
43 Data[Component] = CurrentData | (InValue << ByteIndex * 8);
44 }
45
46 template<int32 Component, int32 ByteIndex>
48 {
49 checkf(false, TEXT("PackByteIntoByte() being used with a float value. This is almost definitely an error. Use PackFloatIntoByte()."));
50 }
51
52protected:
53 // LWC_TODO: should this and GetData() use FVector4f?
55};
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define TEXT(x)
Definition Platform.h:1272
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition SlateVectorArtInstanceData.h:12
FVector4 Data
Definition SlateVectorArtInstanceData.h:54
UMG_API void SetPosition(FVector2D Position)
Definition SlateVectorArtInstanceData.cpp:30
void PackByteIntoByte(float InValue)
Definition SlateVectorArtInstanceData.h:47
UMG_API void SetScaleFixedPoint16(float Scale)
Definition SlateVectorArtInstanceData.cpp:22
FVector4 & GetData()
Definition SlateVectorArtInstanceData.h:15
UMG_API void SetPositionFixedPoint16(FVector2D Position)
Definition SlateVectorArtInstanceData.cpp:5
UMG_API void SetScale(float Scale)
Definition SlateVectorArtInstanceData.cpp:36
void PackByteIntoByte(uint8 InValue)
Definition SlateVectorArtInstanceData.h:31
void PackFloatIntoByte(float InValue)
Definition SlateVectorArtInstanceData.h:25
UMG_API void SetBaseAddress(float Address)
Definition SlateVectorArtInstanceData.cpp:41
const FVector4 & GetData() const
Definition SlateVectorArtInstanceData.h:14