IVSmoke 1.0
Loading...
Searching...
No Matches
IVSmokeHoleData.cpp
1// Copyright (c) 2026, Team SDB. All rights reserved.
2
3#include "IVSmokeHoleData.h"
4#include "IVSmokeHolePreset.h"
5#include "IVSmokeHoleGeneratorComponent.h"
6
8{
9 if (InArray.OwnerComponent)
10 {
11 InArray.OwnerComponent->MarkHoleTextureDirty();
12 }
13}
14
16{
17 if (InArray.OwnerComponent)
18 {
19 InArray.OwnerComponent->MarkHoleTextureDirty();
20 }
21}
22
24{
25 if (InArray.OwnerComponent)
26 {
27 InArray.OwnerComponent->MarkHoleTextureDirty();
28 }
29}
30
32{
33 Items.Empty();
34 MarkArrayDirty();
35}
36
37TArray<FIVSmokeHoleGPU> FIVSmokeHoleArray::GetHoleGPUData(const float CurrentServerTime) const
38{
39 TArray<FIVSmokeHoleGPU> GPUBuffer;
40 TArray<FIVSmokeHoleGPU> BulletBuffer;
41 TArray<FIVSmokeHoleGPU> GrenadeBuffer;
42 TArray<FIVSmokeHoleGPU> DynamicObjectBuffer;
43
44 BulletBuffer.Reserve(FMath::Max(Num(), 1));
45 GrenadeBuffer.Reserve(FMath::Max(Num(), 1));
46 DynamicObjectBuffer.Reserve(FMath::Max(Num(), 1));
47 GPUBuffer.Reserve(FMath::Max(Num(), 1));
48
49 for (const FIVSmokeHoleData& Hole : Items)
50 {
51 TObjectPtr<UIVSmokeHolePreset> Preset = UIVSmokeHolePreset::FindByID(Hole.PresetID);
52 if (!Preset)
53 {
54 continue;
55 }
56
57 FIVSmokeHoleGPU GPUHole = FIVSmokeHoleGPU(Hole, *Preset.Get(), CurrentServerTime);
58
59 if (Preset->HoleType == EIVSmokeHoleType::Penetration)
60 {
61 BulletBuffer.Add(GPUHole);
62 }
63 else if (Preset->HoleType == EIVSmokeHoleType::Explosion)
64 {
65 GrenadeBuffer.Add(GPUHole);
66 }
67 else if (Preset->HoleType == EIVSmokeHoleType::Dynamic)
68 {
69 DynamicObjectBuffer.Add(GPUHole);
70 }
71 }
72
73 GPUBuffer.Append(GrenadeBuffer);
74 GPUBuffer.Append(BulletBuffer);
75 GPUBuffer.Append(DynamicObjectBuffer);
76
77 if (GPUBuffer.Num() == 0)
78 {
79 GPUBuffer.AddDefaulted(1);
80 }
81
82 return GPUBuffer;
83}
84
85FIVSmokeHoleGPU::FIVSmokeHoleGPU(const FIVSmokeHoleData& DynamicHoleData, const UIVSmokeHolePreset& Preset, const float CurrentServerTime)
86{
87 Position = FVector3f(DynamicHoleData.Position);
88 EndPosition = FVector3f(DynamicHoleData.EndPosition);
89
90 HoleType = static_cast<int32>(Preset.HoleType);
91 Radius = Preset.Radius;
92 Duration = Preset.Duration;
93 if (Duration == 0)
94 {
95 return;
96 }
97 Softness = Preset.Softness;
99
100 //SetTime
101 float RemainingTime = DynamicHoleData.ExpirationServerTime - CurrentServerTime;
102 CurLifeTime = Duration - RemainingTime;
103 float NormalizedTime = FMath::Clamp(CurLifeTime / Duration, 0.0f, 1.0f);
104
105 switch (Preset.HoleType)
106 {
107 case EIVSmokeHoleType::Explosion:
108 {
109 float ExpansionNormalizedTime = FMath::Clamp(CurLifeTime / Preset.ExpansionDuration, 0.0f, 1.0f);
110 float ShrinkNormalizedTime = FMath::Clamp((CurLifeTime - Preset.ExpansionDuration) / (Preset.Duration - Preset.ExpansionDuration), 0.0f, 1.0f);
111
113 CurShrinkFadeRangeOverTime = Preset.ShrinkFadeRangeCurveOverTime ? UIVSmokeHolePreset::GetFloatValue(Preset.ShrinkFadeRangeCurveOverTime, ShrinkNormalizedTime) : 1 - ShrinkNormalizedTime;
116 break;
117 }
118 case EIVSmokeHoleType::Penetration:
119 EndRadius = Preset.EndRadius;
120 break;
121 case EIVSmokeHoleType::Dynamic:
122 Extent = Preset.Extent;
123 break;
124 }
125}
static float GetFloatValue(const TObjectPtr< UCurveFloat > Curve, const float X)
static TObjectPtr< UIVSmokeHolePreset > FindByID(const uint8 InPresetID)
TObjectPtr< UCurveFloat > ShrinkFadeRangeCurveOverTime
EIVSmokeHoleType HoleType
TObjectPtr< UCurveFloat > ExpansionFadeRangeCurveOverTime
Fast TArray container for delta replication of hole data.
TArray< FIVSmokeHoleGPU > GetHoleGPUData(const float CurrentServerTime) const
TObjectPtr< UIVSmokeHoleGeneratorComponent > OwnerComponent
FORCEINLINE int32 Num() const
Network-optimized hole data structure.
void PostReplicatedAdd(const FIVSmokeHoleArray &InArray)
void PostReplicatedChange(const FIVSmokeHoleArray &InArray)
void PreReplicatedRemove(const FIVSmokeHoleArray &InArray)
Built from FIVSmokeHoleData + UIVSmokeHolePreset at render time.
float CurExpansionFadeRangeOverTime