IVSmoke 1.0
Loading...
Searching...
No Matches
UIVSmokeCollisionComponent Class Reference

#include <IVSmokeCollisionComponent.h>

Inheritance diagram for UIVSmokeCollisionComponent:
Inheritance graph
Collaboration diagram for UIVSmokeCollisionComponent:
Collaboration graph

Public Member Functions

virtual UBodySetup * GetBodySetup () override
 
void TryUpdateCollision (const TArray< uint64 > &VoxelBitArray, const FIntVector &GridResolution, float VoxelSize, int32 ActiveVoxelNum, float SyncTime, bool bForce=false)
 
void ResetCollision ()
 
void DrawDebugVisualization () const
 

Public Attributes

bool bCollisionEnabled = true
 
int32 MinCollisionUpdateVoxelNum = 50
 
float MinCollisionUpdateInterval = 0.25f
 
bool bDebugEnabled = false
 

Protected Member Functions

virtual void OnCreatePhysicsState () override
 

Detailed Description

A primitive component that dynamically generates collision geometry based on the voxel grid data.

Overview

Unlike standard static meshes, this component constructs a set of box colliders (AggGeom) representing the active voxels. It uses a binary greedy meshing algorithm to merge adjacent voxels into larger boxes to minimize the physics cost.

Usage

This component uses the standard Collision category in the Details panel. By default, it is configured for Query-Only interactions:

  • Visibility: Blocked (Blocks AI Line of Sight).
  • Others: Ignored (Players can walk through).

You can customize these responses in the Collision Presets (set to 'Custom').

Note
Frequent updates to collision geometry are expensive. Use MinCollisionUpdateInterval and MinCollisionUpdateVoxelNum to throttle updates.

Definition at line 30 of file IVSmokeCollisionComponent.h.

Constructor & Destructor Documentation

◆ UIVSmokeCollisionComponent()

UIVSmokeCollisionComponent::UIVSmokeCollisionComponent ( )

Definition at line 21 of file IVSmokeCollisionComponent.cpp.

Member Function Documentation

◆ DrawDebugVisualization()

void UIVSmokeCollisionComponent::DrawDebugVisualization ( ) const

Renders wireframe boxes for each generated collision element (FKBoxElem). Useful for visualizing how the greedy meshing algorithm has optimized the voxels.

Definition at line 245 of file IVSmokeCollisionComponent.cpp.

◆ GetBodySetup()

UBodySetup * UIVSmokeCollisionComponent::GetBodySetup ( )
overridevirtual

Definition at line 40 of file IVSmokeCollisionComponent.cpp.

◆ OnCreatePhysicsState()

void UIVSmokeCollisionComponent::OnCreatePhysicsState ( )
overrideprotectedvirtual

Definition at line 63 of file IVSmokeCollisionComponent.cpp.

◆ ResetCollision()

void UIVSmokeCollisionComponent::ResetCollision ( )

Clears all generated physics geometry and resets the collision state. Called when the simulation is stopped or reset to ensure no "ghost" collision remains.

Definition at line 220 of file IVSmokeCollisionComponent.cpp.

◆ TryUpdateCollision()

void UIVSmokeCollisionComponent::TryUpdateCollision ( const TArray< uint64 > &  VoxelBitArray,
const FIntVector &  GridResolution,
float  VoxelSize,
int32  ActiveVoxelNum,
float  SyncTime,
bool  bForce = false 
)

Attempts to update the collision geometry based on the current voxel data.

It checks MinCollisionUpdateInterval and MinCollisionUpdateVoxelNum to throttle updates and prevent performance spikes from frequent physics rebuilding.

Parameters
VoxelBitArrayA bitmask buffer where each uint64 element represents a row of voxels along the X-axis.
Warning
The Grid X-resolution must not exceed 64.
Parameters
GridResolutionThe resolution of the voxel grid (Width, Depth, Height).
VoxelSizeWorld space size of a single voxel.
ActiveVoxelNumCurrent count of active voxels (used for threshold checks).
SyncTimeCurrent synchronized world time (used for interval checks).
bForceIf true, bypasses optimization checks and forces an immediate rebuild.

Definition at line 70 of file IVSmokeCollisionComponent.cpp.

Member Data Documentation

◆ bCollisionEnabled

bool UIVSmokeCollisionComponent::bCollisionEnabled = true

Master switch for voxel collision. If false, no physics geometry will be generated, and all update requests will be ignored.

Definition at line 74 of file IVSmokeCollisionComponent.h.

◆ bDebugEnabled

bool UIVSmokeCollisionComponent::bDebugEnabled = false

If true, draws debug visualization for the collision geometry in the editor.

Note
Only works if IVSmokeDebugSettings::bDebugEnabled is also true on the main actor.

Definition at line 122 of file IVSmokeCollisionComponent.h.

◆ MinCollisionUpdateInterval

float UIVSmokeCollisionComponent::MinCollisionUpdateInterval = 0.25f

The minimum time (in seconds) that must pass between two consecutive physics geometry rebuilds.

Definition at line 82 of file IVSmokeCollisionComponent.h.

◆ MinCollisionUpdateVoxelNum

int32 UIVSmokeCollisionComponent::MinCollisionUpdateVoxelNum = 50

The minimum number of voxel changes (spawned or destroyed) required to trigger a physics geometry rebuild.

Definition at line 78 of file IVSmokeCollisionComponent.h.


The documentation for this class was generated from the following files: