Unravel Engine C++ Reference
Loading...
Searching...
No Matches
particle_system.h File Reference
#include <bx/allocator.h>
#include <bx/bounds.h>
#include <bx/easing.h>
#include <bx/rng.h>
#include <bgfx/bgfx.h>
#include <math/gradient.h>
#include <math/math.h>
#include <math/bbox.h>
#include <core/base/basetypes.hpp>

Go to the source code of this file.

Classes

struct  EmitterHandle
 
struct  EmitterShape
 
struct  EmitterDirection
 
struct  SimulationSpace
 
struct  EmitterUniforms
 

Functions

template<typename Ty >
bool isValid (Ty _handle)
 
void psInit (uint16_t _maxEmitters=64, bx::AllocatorI *_allocator=nullptr)
 
void psShutdown ()
 
EmitterHandle psCreateEmitter (EmitterShape::Enum _shape, EmitterDirection::Enum _direction, uint32_t _maxParticles)
 
void psUpdateEmitter (EmitterHandle _handle, float _dt, EmitterUniforms *_uniforms=nullptr)
 
bool psHasUpdated (EmitterHandle _handle)
 
void psResetEmitter (EmitterHandle _handle)
 
void psGetAabb (EmitterHandle _handle, math::bbox &_outAabb)
 
uint32_t psGetNumParticles (EmitterHandle _handle)
 
void psDestroyEmitter (EmitterHandle _handle)
 
void psRenderEmitter (EmitterHandle _handle, uint8_t _view, bgfx::ProgramHandle _program, const float *_mtxView, const math::vec3 &_eye, bgfx::TextureHandle _texture)
 
uint32_t psRenderEmitterBatch (const EmitterHandle *_handles, uint32_t _count, uint8_t _view, bgfx::ProgramHandle _program, const float *_mtxView, const math::vec3 &_eye, bgfx::TextureHandle _texture)
 

Function Documentation

◆ isValid()

template<typename Ty >
bool isValid ( Ty _handle)
inline

Definition at line 22 of file particle_system.h.

◆ psCreateEmitter()

EmitterHandle psCreateEmitter ( EmitterShape::Enum _shape,
EmitterDirection::Enum _direction,
uint32_t _maxParticles )

Definition at line 1053 of file particle_system.cpp.

◆ psDestroyEmitter()

void psDestroyEmitter ( EmitterHandle _handle)

Definition at line 1085 of file particle_system.cpp.

◆ psGetAabb()

void psGetAabb ( EmitterHandle _handle,
math::bbox & _outAabb )

Definition at line 1070 of file particle_system.cpp.

◆ psGetNumParticles()

uint32_t psGetNumParticles ( EmitterHandle _handle)

Definition at line 1075 of file particle_system.cpp.

◆ psHasUpdated()

bool psHasUpdated ( EmitterHandle _handle)

Definition at line 1080 of file particle_system.cpp.

◆ psInit()

void psInit ( uint16_t _maxEmitters = 64,
bx::AllocatorI * _allocator = nullptr )

Definition at line 1041 of file particle_system.cpp.

◆ psRenderEmitter()

void psRenderEmitter ( EmitterHandle _handle,
uint8_t _view,
bgfx::ProgramHandle _program,
const float * _mtxView,
const math::vec3 & _eye,
bgfx::TextureHandle _texture )

Definition at line 1090 of file particle_system.cpp.

◆ psRenderEmitterBatch()

uint32_t psRenderEmitterBatch ( const EmitterHandle * _handles,
uint32_t _count,
uint8_t _view,
bgfx::ProgramHandle _program,
const float * _mtxView,
const math::vec3 & _eye,
bgfx::TextureHandle _texture )

Render multiple emitters in a single batched draw call (all must use the same texture) This is much more efficient than calling psRenderEmitter multiple times as it:

  • Combines all particles into a single instance buffer
  • Sorts all particles globally for proper alpha blending
  • Uses only one draw call instead of multiple

Example usage: EmitterHandle handles[] = {fire_emitter, smoke_emitter, spark_emitter}; psRenderEmitterBatch(handles, 3, view, program, viewMatrix, cameraPos, fireTexture);

Definition at line 1100 of file particle_system.cpp.

◆ psResetEmitter()

void psResetEmitter ( EmitterHandle _handle)

Definition at line 1063 of file particle_system.cpp.

◆ psShutdown()

void psShutdown ( )

Definition at line 1046 of file particle_system.cpp.

◆ psUpdateEmitter()

void psUpdateEmitter ( EmitterHandle _handle,
float _dt,
EmitterUniforms * _uniforms = nullptr )

Definition at line 1058 of file particle_system.cpp.