|
IVSmoke 1.0
|
#include <IVSmokeVoxelVolume.h>


Public Member Functions | |
| virtual void | Tick (float DeltaTime) override |
| virtual bool | ShouldTickIfViewportsOnly () const override |
| virtual void | OnConstruction (const FTransform &Transform) override |
| TObjectPtr< UIVSmokeHoleGeneratorComponent > | GetHoleGeneratorComponent () |
| TObjectPtr< UIVSmokeCollisionComponent > | GetCollisionComponent () |
| void | Initialize () |
| void | StartSimulation () |
| void | StopSimulation (bool bImmediate=false) |
| void | ResetSimulation () |
| FORCEINLINE EIVSmokeVoxelVolumeState | GetCurrentState () const |
| bool | ShouldRender () const |
| FORCEINLINE const TArray< float > & | GetVoxelBirthTimes () const |
| FORCEINLINE const TArray< float > & | GetVoxelDeathTimes () const |
| FORCEINLINE FIntVector | GetGridResolution () const |
| FORCEINLINE FIntVector | GetCenterOffset () const |
| FORCEINLINE float | GetVoxelSize () const |
| FORCEINLINE EIVSmokeDirtyLevel | GetDirtyLevel () const |
| FORCEINLINE bool | IsVoxelDataDirty () const |
| FORCEINLINE void | ClearVoxelDataDirty () |
| FORCEINLINE int32 | GetVoxelBufferSize () const |
| FORCEINLINE int32 | GetActiveVoxelNum () const |
| FORCEINLINE const UIVSmokeSmokePreset * | GetSmokePresetOverride () const |
| FORCEINLINE FVector | GetVoxelWorldAABBMin () const |
| FORCEINLINE FVector | GetVoxelWorldAABBMax () const |
| FORCEINLINE bool | IsVoxelActive (int32 Index) const |
| FORCEINLINE bool | IsVoxelActive (FIntVector GridPos) const |
| FTextureRHIRef | GetHoleTexture () const |
| float | GetSyncWorldTimeSeconds () const |
| void | StartPreviewSimulation () |
| void | StopPreviewSimulation () |
Public Attributes | |
| TObjectPtr< UBillboardComponent > | BillboardComponent |
| FIntVector | VolumeExtent = FIntVector(16, 16, 16) |
| FVector | Radii = FVector(1.0f, 1.0f, 1.0f) |
| float | VoxelSize = 50.0f |
| int32 | MaxVoxelNum = 1000 |
| bool | bAutoStart = false |
| bool | bDestroyOnFinish = false |
| bool | bIsInfinite = false |
| TObjectPtr< UIVSmokeSmokePreset > | SmokePresetOverride |
| float | ExpansionDuration = 3.0f |
| float | SustainDuration = 5.0f |
| float | DissipationDuration = 2.0f |
| float | FadeInDuration = 2.0f |
| float | FadeOutDuration = 2.0f |
| float | ExpansionNoise = 100.0f |
| float | DissipationNoise = 100.0f |
| TObjectPtr< UCurveFloat > | ExpansionCurve |
| TObjectPtr< UCurveFloat > | DissipationCurve |
| bool | bEnableSimulationCollision = true |
| TEnumAsByte< ECollisionChannel > | VoxelCollisionChannel = ECC_WorldStatic |
| FIVSmokeDebugSettings | DebugSettings |
| TObjectPtr< UStaticMesh > | DebugVoxelMesh |
| TObjectPtr< UMaterialInterface > | DebugVoxelMaterial |
Protected Member Functions | |
| virtual void | BeginPlay () override |
| virtual void | EndPlay (const EEndPlayReason::Type EndPlayReason) override |
| virtual void | GetLifetimeReplicatedProps (TArray< FLifetimeProperty > &OutLifetimeProps) const override |
The core volumetric actor that simulates dynamic smoke expansion using a deterministic voxel-based flood-fill algorithm.
This actor generates a 3D grid of voxels that expand outward from the center, navigating around obstacles defined by the collision settings. The simulation is deterministic, ensuring the same shape and timing across both Server and Clients without replicating individual voxel data.
The simulation state machine progresses based on the sum of duration and fade settings:
ExpansionDuration + FadeInDuration.SustainDuration.DissipationDuration + FadeOutDuration.The simulation logic executes deterministically on both the Server and Client.
Definition at line 167 of file IVSmokeVoxelVolume.h.
| AIVSmokeVoxelVolume::AIVSmokeVoxelVolume | ( | ) |
Definition at line 140 of file IVSmokeVoxelVolume.cpp.
|
overrideprotectedvirtual |
Definition at line 171 of file IVSmokeVoxelVolume.cpp.
|
inline |
Marks the voxel data as clean after a successful GPU upload.
IVSmokeRenderer. Definition at line 680 of file IVSmokeVoxelVolume.h.
|
overrideprotectedvirtual |
Definition at line 203 of file IVSmokeVoxelVolume.cpp.
|
inline |
Returns the number of active (non-zero density) voxels.
Definition at line 686 of file IVSmokeVoxelVolume.h.
|
inline |
Returns the center offset for grid-to-local coordinate conversion.
Definition at line 665 of file IVSmokeVoxelVolume.h.
| TObjectPtr< UIVSmokeCollisionComponent > AIVSmokeVoxelVolume::GetCollisionComponent | ( | ) |
Returns the component responsible for handling physical interactions and collision queries. Caches the result to avoid repeated lookups. Returns nullptr if the component is missing.
Definition at line 1229 of file IVSmokeVoxelVolume.cpp.
|
inline |
Returns the current phase of the simulation state machine.
Definition at line 640 of file IVSmokeVoxelVolume.h.
|
inline |
Returns the current dirty level for GPU buffer synchronization.
Definition at line 671 of file IVSmokeVoxelVolume.h.
|
inline |
Returns the grid resolution (dimensions of the voxel grid).
Definition at line 655 of file IVSmokeVoxelVolume.h.
| TObjectPtr< UIVSmokeHoleGeneratorComponent > AIVSmokeVoxelVolume::GetHoleGeneratorComponent | ( | ) |
Returns the component responsible for generating holes (negative space) in the smoke. Caches the result to avoid repeated lookups. Returns nullptr if the component is missing.
Definition at line 1219 of file IVSmokeVoxelVolume.cpp.
| FTextureRHIRef AIVSmokeVoxelVolume::GetHoleTexture | ( | ) | const |
Returns the RHI texture resource from the HoleGeneratorComponent, if available.
Definition at line 1239 of file IVSmokeVoxelVolume.cpp.
|
overrideprotectedvirtual |
Definition at line 211 of file IVSmokeVoxelVolume.cpp.
|
inline |
Returns the smoke preset override for this volume, or nullptr to use default.
Definition at line 689 of file IVSmokeVoxelVolume.h.
| float AIVSmokeVoxelVolume::GetSyncWorldTimeSeconds | ( | ) | const |
Returns the synchronized world time in seconds. Handles network time offsets to ensure clients see the simulation at the same progress as the server.
Definition at line 1248 of file IVSmokeVoxelVolume.cpp.
|
inline |
Returns the raw array of timestamps indicating when each voxel was created (Server Time).
Definition at line 649 of file IVSmokeVoxelVolume.h.
|
inline |
Returns the current buffer size (for detecting resize).
Definition at line 683 of file IVSmokeVoxelVolume.h.
|
inline |
Returns the raw array of timestamps indicating when each voxel was removed (Server Time).
Definition at line 652 of file IVSmokeVoxelVolume.h.
|
inline |
Returns the world-space size of each voxel.
Definition at line 668 of file IVSmokeVoxelVolume.h.
|
inline |
Returns the AABBMax of voxels.
Definition at line 695 of file IVSmokeVoxelVolume.h.
|
inline |
Returns the AABBMin of voxels.
Definition at line 692 of file IVSmokeVoxelVolume.h.
| void AIVSmokeVoxelVolume::Initialize | ( | ) |
Allocates memory for the voxel grid based on VolumeExtent. Automatically called on BeginPlay. Can be called manually to resize the grid at runtime,
Definition at line 386 of file IVSmokeVoxelVolume.cpp.
|
inline |
Checks if a voxel at the given grid coordinate is currently active.
| GridPos | 3D grid coordinate of the voxel. |
Definition at line 715 of file IVSmokeVoxelVolume.h.
|
inline |
Checks if a voxel at the given linear index is currently active.
| Index | Linear index of the voxel. |
Definition at line 703 of file IVSmokeVoxelVolume.h.
|
inline |
Returns true if voxel data has been modified since last GPU upload.
Definition at line 674 of file IVSmokeVoxelVolume.h.
|
overridevirtual |
Definition at line 278 of file IVSmokeVoxelVolume.cpp.
| void AIVSmokeVoxelVolume::ResetSimulation | ( | ) |
Resets the simulation state to Idle and clears all voxel data. (Server Only) Increments the Generation counter to force all clients to reset and resync.
| bool AIVSmokeVoxelVolume::ShouldRender | ( | ) | const |
Returns true if this volume should be rendered. Used by SceneViewExtension to filter active volumes without explicit registration.
Definition at line 1173 of file IVSmokeVoxelVolume.cpp.
|
overridevirtual |
Definition at line 269 of file IVSmokeVoxelVolume.cpp.
| void AIVSmokeVoxelVolume::StartPreviewSimulation | ( | ) |
Runs a preview of the simulation directly in the Editor viewport without starting a Play In Editor (PIE) session. Use this to quickly iterate on parameters like ExpansionDuration, Noise, and Curves.
Definition at line 1273 of file IVSmokeVoxelVolume.cpp.
| void AIVSmokeVoxelVolume::StartSimulation | ( | ) |
Begins the simulation. (Server Only) Sets the state to Expansion and synchronizes the start time and random seed to clients. Has no effect if the simulation is already running.
| void AIVSmokeVoxelVolume::StopPreviewSimulation | ( | ) |
Stops the current editor preview simulation and clears all generated voxel data. Returns the actor to an Idle state.
Definition at line 1287 of file IVSmokeVoxelVolume.cpp.
| void AIVSmokeVoxelVolume::StopSimulation | ( | bool | bImmediate = false | ) |
Stops the simulation and triggers the dissipation phase. (Server Only)
| bImmediate | If true, skips the dissipation phase and instantly transitions to Finished, clearing all voxels. |
|
overridevirtual |
Definition at line 218 of file IVSmokeVoxelVolume.cpp.
| bool AIVSmokeVoxelVolume::bAutoStart = false |
If true, the simulation starts automatically on BeginPlay.
Definition at line 283 of file IVSmokeVoxelVolume.h.
| bool AIVSmokeVoxelVolume::bDestroyOnFinish = false |
If true, the actor is automatically destroyed when the simulation reaches the Finished state.
Definition at line 287 of file IVSmokeVoxelVolume.h.
| bool AIVSmokeVoxelVolume::bEnableSimulationCollision = true |
If true, voxels perform collision checks against the world before spawning. Disable this to allow smoke to pass through walls, significantly reducing CPU cost.
Definition at line 407 of file IVSmokeVoxelVolume.h.
| TObjectPtr<UBillboardComponent> AIVSmokeVoxelVolume::BillboardComponent |
Editor visualization sprite. Used as the RootComponent.
Definition at line 216 of file IVSmokeVoxelVolume.h.
| bool AIVSmokeVoxelVolume::bIsInfinite = false |
If true, the smoke stays in the Sustain phase indefinitely.
Definition at line 291 of file IVSmokeVoxelVolume.h.
| FIVSmokeDebugSettings AIVSmokeVoxelVolume::DebugSettings |
Configuration settings for visual debugging tools.
Definition at line 758 of file IVSmokeVoxelVolume.h.
| TObjectPtr<UMaterialInterface> AIVSmokeVoxelVolume::DebugVoxelMaterial |
Optional material to apply to the debug voxel mesh.
Definition at line 766 of file IVSmokeVoxelVolume.h.
| TObjectPtr<UStaticMesh> AIVSmokeVoxelVolume::DebugVoxelMesh |
Optional static mesh to use for voxel visualization when bShowVoxelMesh is enabled in settings.
Definition at line 762 of file IVSmokeVoxelVolume.h.
| TObjectPtr<UCurveFloat> AIVSmokeVoxelVolume::DissipationCurve |
Defines the normalized rate of voxel survival over DissipationDuration.
Definition at line 400 of file IVSmokeVoxelVolume.h.
| float AIVSmokeVoxelVolume::DissipationDuration = 2.0f |
The duration (in seconds) of the voxel removal phase. The actual Dissipation state lasts for DissipationDuration + FadeOutDuration.
Definition at line 356 of file IVSmokeVoxelVolume.h.
| float AIVSmokeVoxelVolume::DissipationNoise = 100.0f |
Randomness added to the voxel removal order. Higher values cause the smoke to break apart more randomly during dissipation.
Definition at line 382 of file IVSmokeVoxelVolume.h.
| TObjectPtr<UCurveFloat> AIVSmokeVoxelVolume::ExpansionCurve |
Defines the normalized rate of voxel spawning over ExpansionDuration.
MaxVoxelNum to spawn) Definition at line 391 of file IVSmokeVoxelVolume.h.
| float AIVSmokeVoxelVolume::ExpansionDuration = 3.0f |
The duration (in seconds) of the active expansion phase where voxels are spawned. The actual Expansion state lasts for ExpansionDuration + FadeInDuration.
Definition at line 342 of file IVSmokeVoxelVolume.h.
| float AIVSmokeVoxelVolume::ExpansionNoise = 100.0f |
Randomness added to the flood-fill pathfinding cost. Higher values create more irregular, jagged shapes instead of a perfect sphere.
Definition at line 375 of file IVSmokeVoxelVolume.h.
| float AIVSmokeVoxelVolume::FadeInDuration = 2.0f |
Additional time added to the Expansion phase to allow for opacity fade-in.
Definition at line 362 of file IVSmokeVoxelVolume.h.
| float AIVSmokeVoxelVolume::FadeOutDuration = 2.0f |
Additional time added to the Dissipation phase to allow for opacity fade-out.
Definition at line 368 of file IVSmokeVoxelVolume.h.
| int32 AIVSmokeVoxelVolume::MaxVoxelNum = 1000 |
The hard limit on the number of active voxels. Simulation will stop spawning new voxels once this limit is reached. Use this to guarantee a fixed performance budget for this actor.
Definition at line 279 of file IVSmokeVoxelVolume.h.
| FVector AIVSmokeVoxelVolume::Radii = FVector(1.0f, 1.0f, 1.0f) |
Defines the relative aspect ratio of the smoke's expansion shape per axis. These values act as ratios, not absolute units.
Definition at line 263 of file IVSmokeVoxelVolume.h.
| TObjectPtr<UIVSmokeSmokePreset> AIVSmokeVoxelVolume::SmokePresetOverride |
Optional Data Asset to override visual properties such as Smoke Color, Absorption, and Density. If set, the visual settings in this preset take precedence over the actor's local settings.
Definition at line 299 of file IVSmokeVoxelVolume.h.
| float AIVSmokeVoxelVolume::SustainDuration = 5.0f |
The duration (in seconds) the smoke maintains its shape after expansion. Ignored if bIsInfinite is true.
Definition at line 349 of file IVSmokeVoxelVolume.h.
| FIntVector AIVSmokeVoxelVolume::VolumeExtent = FIntVector(16, 16, 16) |
Half-size of the voxel grid in index units. The actual grid resolution will be (Extent * 2) - 1 per axis.
Definition at line 254 of file IVSmokeVoxelVolume.h.
| TEnumAsByte<ECollisionChannel> AIVSmokeVoxelVolume::VoxelCollisionChannel = ECC_WorldStatic |
The collision channel used for obstacle detection during expansion.
Definition at line 411 of file IVSmokeVoxelVolume.h.
| float AIVSmokeVoxelVolume::VoxelSize = 50.0f |
World space size of a single voxel in centimeters.
VolumeExtent or MaxVoxelNum) to cover the same area. Definition at line 271 of file IVSmokeVoxelVolume.h.