Cogs.Core
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Cogs::Core::BasicOceanSystem Class Reference
Inheritance diagram for Cogs::Core::BasicOceanSystem:
Cogs::Core::ComponentSystemWithDataPool< BasicOceanComponent, BasicOceanData > Cogs::Core::ComponentSystemWithDataPools< ComponentType, DataTypes > Cogs::Core::ComponentSystem< ComponentType > Cogs::Core::ComponentSystemBase

Public Member Functions

 BasicOceanSystem (Memory::Allocator *allocator, SizeType capacity)
 
void initialize (Context *context) override
 Initialize the system.
 
void cleanup (Context *context) override
 Provided for custom cleanup logic in derived systems.
 
void update (Context *context) override
 Provided for custom update logic in derived systems.
 
void postUpdate (Context *context) override
 Provided for custom post update logic in derived systems.
 
TextureHandle getRealTex () const
 
TextureHandle getImagTex () const
 
TextureHandle getTangentTex () const
 
float getTileScale () const
 
float getSignificantWaveHeight () const
 
- Public Member Functions inherited from Cogs::Core::ComponentSystemWithDataPool< BasicOceanComponent, BasicOceanData >
 ComponentSystemWithDataPool (Memory::Allocator *allocator, SizeType size=1024)
 
BasicOceanDatagetData (const BasicOceanComponent *component)
 
const BasicOceanDatagetData (const BasicOceanComponent *component) const
 
- Public Member Functions inherited from Cogs::Core::ComponentSystemWithDataPools< ComponentType, DataTypes >
 ComponentSystemWithDataPools (Memory::Allocator *allocator, SizeType size=1024, MemBlockType componentMemType=MemBlockType::Component, MemBlockType dataMemType=MemBlockType::ComponentData)
 
ComponentHandle createComponent () override
 
void destroyComponent (ComponentHandle component) override
 
template<typename T >
T & getData (const ComponentType *component)
 Get the data stored for the given component from the data pool storing objects of the specified template type.
 
template<typename T >
const T & getData (const ComponentType *component) const
 Get the const data stored for the given component from the data pool storing objects of the specified template type.
 
- Public Member Functions inherited from Cogs::Core::ComponentSystem< ComponentType >
 ComponentSystem (Memory::Allocator *allocator, SizeType size=16384, MemBlockType componentMemType=MemBlockType::Component)
 
void instrumentedPreUpdate () override
 Provided for tagged engine instrumentation.
 
void instrumentedUpdate () override
 Provided for tagged engine instrumentation.
 
void instrumentedPostUpdate () override
 Provided for tagged engine instrumentation.
 
ComponentHandle createComponent () override
 Create a new component instance.
 
void destroyComponent (ComponentHandle component) override
 Destroy the component held by the given handle.
 
SizeType getComponentIndex (const Component *component) const
 Get the index of the given component in the component pool.
 
size_t size ()
 Returns the number of active components.
 
void clearCarryFlags ()
 Clear carry flags of all active components.
 
void resetFlags ()
 Reset the flags of all active components.
 
void prepareUpdate (Context *) override
 
void postUpdate (Context *) override
 
ComponentHandle getHandle (const ComponentType *component)
 Get a handle to the given Component instance.
 
virtual void addEntitiesWithComponent (std::vector< EntityId > &entities, Reflection::TypeId componentTypeId) override
 Return all entities with a given.
 
- Public Member Functions inherited from Cogs::Core::ComponentSystemBase
virtual ~ComponentSystemBase ()
 Provided for destruction via pointer to base.
 
 ComponentSystemBase (Reflection::TypeId componentType)
 Constructs a ComponentSystemBase to manage components of the given componentType.
 
virtual void initialize (Context *context)
 Initialize the system.
 
void preUpdate ()
 Run the pre-update method of the system.
 
void update ()
 Updates the system state to that of the current frame.
 
void postUpdate ()
 Perform post update logic in the system.
 
virtual void preUpdate (Context *)
 Provided for custom pre update logic in derived systems.
 
virtual void prepareUpdate (Context *)
 Provided for custom update preparation logic in derived systems.
 
virtual void update (Context *)
 Provided for custom update logic in derived systems.
 
virtual void postUpdate (Context *)
 Provided for custom post update logic in derived systems.
 
virtual void instrumentedPreUpdate ()
 Provided for tagged engine instrumentation.
 
virtual void instrumentedUpdate ()
 Provided for tagged engine instrumentation.
 
virtual void instrumentedPostUpdate ()
 Provided for tagged engine instrumentation.
 
virtual void addEntitiesWithComponent (std::vector< EntityId > &, Reflection::TypeId)
 Return all entities with a given.
 
virtual void cleanup (Context *)
 Provided for custom cleanup logic in derived systems.
 
virtual ComponentHandle createComponent ()
 Create a new component instance.
 
virtual void destroyComponent (ComponentHandle)
 Destroy the component held by the given handle.
 
Reflection::TypeId getComponentType () const
 Get the reflected type of the components managed by this system.
 

Private Member Functions

void setupMaterial ()
 
void updateTextureResolution (BasicOceanComponent *oceanComp)
 
void setupWaveSpectrum ()
 
void updateTextures (const float magnitudeIn0, const float magnitudeIn1)
 
void updateTileMaterialInstances (const BasicOceanData &oceanData, class AdaptivePlanarGridComponent *gridComp, struct AdaptivePlanarGridData &gridData, const glm::mat4 &viewToWorld, const glm::vec2 &viewPortSize)
 

Private Attributes

float fftTileExtent = 10.f
 Size of FFT-tile in meters, set up setupWaveSpectrum.
 
int fftTileResolutionLog2 = 7
 
float significantWaveHeight = 4.f
 
float dominantWavePeriod = 25.f
 
float windSpeed = 10.f
 
float windDirection = 0.f
 
unsigned int phaseShiftNoiseFrequency = 3
 Frequency of phase shift noise wrt FFT tile size.
 
unsigned int tilePeriod = 30
 Number of FFT-tiles before ocean repeats itself.
 
BasicOceanWaves waves = BasicOceanWaves::Default
 
struct {
   float   channel0 = std::numeric_limits<float>::quiet_NaN()
 
   float   channel1 = std::numeric_limits<float>::quiet_NaN()
 
magnitudes
 
struct {
   float   channel0 = std::numeric_limits<float>::quiet_NaN()
 
   float   channel1 = std::numeric_limits<float>::quiet_NaN()
 
magnitudes_tmp
 
bool animate = true
 
bool specsChanged = true
 
bool eightBit = false
 Use eight bit texture format for wave displacement.
 
bool extraStep = false
 
TaskId oceanTaskGroup = NoTask
 
std::vector< float > P
 
ComplexArray frqH0
 
ComplexArray frqDz
 
ComplexArray frqDx
 
ComplexArray frqDy
 
ComplexArray frqdDzdu
 
ComplexArray frqdDzdv
 
ComplexArray spcDz
 
ComplexArray spcDx
 
ComplexArray spcDy
 
ComplexArray spcdDzdu
 
ComplexArray spcdDzdv
 
std::vector< uint8_t > fftScratch1
 
std::vector< uint8_t > fftScratch2
 
std::vector< uint8_t > fftScratch3
 
std::vector< uint8_t > fftScratch4
 
std::vector< uint8_t > fftScratch5
 
std::vector< uint8_t > fftScratch
 
TextureHandle DisplacementTexH = TextureHandle::NoHandle
 
TextureHandle NormalTexH = TextureHandle::NoHandle
 
TextureHandle TangentsTexH = TextureHandle::NoHandle
 
TextureHandle ReflectionTextureH = TextureHandle::NoHandle
 
MaterialHandle oceanMaterial = MaterialHandle::NoHandle
 
MaterialHandle oceanMaterial2 = MaterialHandle::NoHandle
 
VariableKey DisplacementKey = NoProperty
 
VariableKey NormalKey = NoProperty
 
VariableKey TangentsKey = NoProperty
 
VariableKey SkyDomeKey = NoProperty
 
VariableKey PlanarReflectionKey = NoProperty
 
VariableKey cameraYAxisKey = NoProperty
 
VariableKey waterColorKey = NoProperty
 
VariableKey waveDirectionKey = NoProperty
 
VariableKey significantWaveHeightKey = NoProperty
 
VariableKey fftTileScaleKey = NoProperty
 
VariableKey camPlaneDirKey = NoProperty
 
VariableKey camAzimuthKey = NoProperty
 
VariableKey seaLevelKey = NoProperty
 
VariableKey phaseShiftNoiseFrequencyKey = NoProperty
 
VariableKey phaseShiftNoisePeriodKey = NoProperty
 
VariableKey reflectionBrightnessKey = NoProperty
 

Additional Inherited Members

- Public Types inherited from Cogs::Core::ComponentSystem< ComponentType >
typedef ComponentType component_type
 
- Static Public Member Functions inherited from Cogs::Core::ComponentSystem< ComponentType >
static Reflection::TypeId getTypeId ()
 Get the type id of the component type used by the system.
 
- Public Attributes inherited from Cogs::Core::ComponentSystem< ComponentType >
ComponentPool< ComponentType > pool
 Pool of components managed by the system.
 
- Public Attributes inherited from Cogs::Core::ComponentSystemBase
Reflection::TypeId componentType
 The type of components managed by this instance.
 
Contextcontext = nullptr
 Pointer to the Context instance the system lives in.
 

Detailed Description

Definition at line 110 of file BasicOceanSystem.h.

Constructor & Destructor Documentation

◆ BasicOceanSystem()

Cogs::Core::BasicOceanSystem::BasicOceanSystem ( Memory::Allocator allocator,
SizeType  capacity 
)
inline

Definition at line 113 of file BasicOceanSystem.h.

Member Function Documentation

◆ cleanup()

void Cogs::Core::BasicOceanSystem::cleanup ( Context )
overridevirtual

Provided for custom cleanup logic in derived systems.

Cleanup is performed during shutdown of the system, and all entities and related data should have been deleted.

All system services are available during the execution of cleanup().

Reimplemented from Cogs::Core::ComponentSystemBase.

Definition at line 940 of file BasicOceanSystem.cpp.

References Cogs::Core::Context::taskManager.

◆ getImagTex()

TextureHandle Cogs::Core::BasicOceanSystem::getImagTex ( ) const
inline

Definition at line 121 of file BasicOceanSystem.h.

◆ getRealTex()

TextureHandle Cogs::Core::BasicOceanSystem::getRealTex ( ) const
inline

Definition at line 120 of file BasicOceanSystem.h.

◆ getSignificantWaveHeight()

float Cogs::Core::BasicOceanSystem::getSignificantWaveHeight ( ) const
inline

Definition at line 125 of file BasicOceanSystem.h.

◆ getTangentTex()

TextureHandle Cogs::Core::BasicOceanSystem::getTangentTex ( ) const
inline

Definition at line 122 of file BasicOceanSystem.h.

◆ getTileScale()

float Cogs::Core::BasicOceanSystem::getTileScale ( ) const
inline

Definition at line 124 of file BasicOceanSystem.h.

◆ initialize()

void Cogs::Core::BasicOceanSystem::initialize ( Context context)
overridevirtual

Initialize the system.

Initialization is performed after all systems are created and a renderer initialized, but before the first time anything is rendered.

Parameters
contextPointer to the context the system lives in.

Reimplemented from Cogs::Core::ComponentSystemBase.

Definition at line 913 of file BasicOceanSystem.cpp.

References Cogs::Core::ComponentSystemBase::context, Cogs::Core::TaskManager::GlobalQueue, Cogs::Core::ComponentSystemBase::initialize(), Cogs::Core::ResourceBase::setName(), Cogs::Core::Context::taskManager, and Cogs::Core::Context::variables.

◆ postUpdate()

void Cogs::Core::BasicOceanSystem::postUpdate ( Context )
overridevirtual

Provided for custom post update logic in derived systems.

Reimplemented from Cogs::Core::ComponentSystemBase.

Definition at line 1465 of file BasicOceanSystem.cpp.

References Cogs::ComponentModel::Component::getComponent(), Cogs::Core::ComponentSystemBase::postUpdate(), and Cogs::Core::Context::taskManager.

◆ setupMaterial()

void Cogs::Core::BasicOceanSystem::setupMaterial ( )
private

Definition at line 954 of file BasicOceanSystem.cpp.

◆ setupWaveSpectrum()

void Cogs::Core::BasicOceanSystem::setupWaveSpectrum ( )
private

Definition at line 1018 of file BasicOceanSystem.cpp.

◆ update()

void Cogs::Core::BasicOceanSystem::update ( Context )
overridevirtual

◆ updateTextureResolution()

void Cogs::Core::BasicOceanSystem::updateTextureResolution ( BasicOceanComponent oceanComp)
private

Definition at line 997 of file BasicOceanSystem.cpp.

◆ updateTextures()

void Cogs::Core::BasicOceanSystem::updateTextures ( const float  magnitudeIn0,
const float  magnitudeIn1 
)
private

Definition at line 1050 of file BasicOceanSystem.cpp.

◆ updateTileMaterialInstances()

void Cogs::Core::BasicOceanSystem::updateTileMaterialInstances ( const BasicOceanData oceanData,
class AdaptivePlanarGridComponent gridComp,
struct AdaptivePlanarGridData gridData,
const glm::mat4 &  viewToWorld,
const glm::vec2 &  viewPortSize 
)
private

Definition at line 1175 of file BasicOceanSystem.cpp.

Member Data Documentation

◆ animate

bool Cogs::Core::BasicOceanSystem::animate = true
private

Definition at line 144 of file BasicOceanSystem.h.

◆ camAzimuthKey

VariableKey Cogs::Core::BasicOceanSystem::camAzimuthKey = NoProperty
private

Definition at line 193 of file BasicOceanSystem.h.

◆ cameraYAxisKey

VariableKey Cogs::Core::BasicOceanSystem::cameraYAxisKey = NoProperty
private

Definition at line 187 of file BasicOceanSystem.h.

◆ camPlaneDirKey

VariableKey Cogs::Core::BasicOceanSystem::camPlaneDirKey = NoProperty
private

Definition at line 192 of file BasicOceanSystem.h.

◆ channel0

float Cogs::Core::BasicOceanSystem::channel0 = std::numeric_limits<float>::quiet_NaN()

Definition at line 139 of file BasicOceanSystem.h.

◆ channel1

float Cogs::Core::BasicOceanSystem::channel1 = std::numeric_limits<float>::quiet_NaN()

Definition at line 140 of file BasicOceanSystem.h.

◆ DisplacementKey

VariableKey Cogs::Core::BasicOceanSystem::DisplacementKey = NoProperty
private

Definition at line 182 of file BasicOceanSystem.h.

◆ DisplacementTexH

TextureHandle Cogs::Core::BasicOceanSystem::DisplacementTexH = TextureHandle::NoHandle
private

Definition at line 175 of file BasicOceanSystem.h.

◆ dominantWavePeriod

float Cogs::Core::BasicOceanSystem::dominantWavePeriod = 25.f
private

Definition at line 131 of file BasicOceanSystem.h.

◆ eightBit

bool Cogs::Core::BasicOceanSystem::eightBit = false
private

Use eight bit texture format for wave displacement.

Definition at line 147 of file BasicOceanSystem.h.

◆ extraStep

bool Cogs::Core::BasicOceanSystem::extraStep = false
private

Definition at line 148 of file BasicOceanSystem.h.

◆ fftScratch

std::vector<uint8_t> Cogs::Core::BasicOceanSystem::fftScratch
private

Definition at line 173 of file BasicOceanSystem.h.

◆ fftScratch1

std::vector<uint8_t> Cogs::Core::BasicOceanSystem::fftScratch1
private

Definition at line 167 of file BasicOceanSystem.h.

◆ fftScratch2

std::vector<uint8_t> Cogs::Core::BasicOceanSystem::fftScratch2
private

Definition at line 168 of file BasicOceanSystem.h.

◆ fftScratch3

std::vector<uint8_t> Cogs::Core::BasicOceanSystem::fftScratch3
private

Definition at line 169 of file BasicOceanSystem.h.

◆ fftScratch4

std::vector<uint8_t> Cogs::Core::BasicOceanSystem::fftScratch4
private

Definition at line 170 of file BasicOceanSystem.h.

◆ fftScratch5

std::vector<uint8_t> Cogs::Core::BasicOceanSystem::fftScratch5
private

Definition at line 171 of file BasicOceanSystem.h.

◆ fftTileExtent

float Cogs::Core::BasicOceanSystem::fftTileExtent = 10.f
private

Size of FFT-tile in meters, set up setupWaveSpectrum.

Definition at line 128 of file BasicOceanSystem.h.

◆ fftTileResolutionLog2

int Cogs::Core::BasicOceanSystem::fftTileResolutionLog2 = 7
private

Definition at line 129 of file BasicOceanSystem.h.

◆ fftTileScaleKey

VariableKey Cogs::Core::BasicOceanSystem::fftTileScaleKey = NoProperty
private

Definition at line 191 of file BasicOceanSystem.h.

◆ frqdDzdu

ComplexArray Cogs::Core::BasicOceanSystem::frqdDzdu
private

Definition at line 158 of file BasicOceanSystem.h.

◆ frqdDzdv

ComplexArray Cogs::Core::BasicOceanSystem::frqdDzdv
private

Definition at line 159 of file BasicOceanSystem.h.

◆ frqDx

ComplexArray Cogs::Core::BasicOceanSystem::frqDx
private

Definition at line 156 of file BasicOceanSystem.h.

◆ frqDy

ComplexArray Cogs::Core::BasicOceanSystem::frqDy
private

Definition at line 157 of file BasicOceanSystem.h.

◆ frqDz

ComplexArray Cogs::Core::BasicOceanSystem::frqDz
private

Definition at line 155 of file BasicOceanSystem.h.

◆ frqH0

ComplexArray Cogs::Core::BasicOceanSystem::frqH0
private

Definition at line 154 of file BasicOceanSystem.h.

◆ NormalKey

VariableKey Cogs::Core::BasicOceanSystem::NormalKey = NoProperty
private

Definition at line 183 of file BasicOceanSystem.h.

◆ NormalTexH

TextureHandle Cogs::Core::BasicOceanSystem::NormalTexH = TextureHandle::NoHandle
private

Definition at line 176 of file BasicOceanSystem.h.

◆ oceanMaterial

MaterialHandle Cogs::Core::BasicOceanSystem::oceanMaterial = MaterialHandle::NoHandle
private

Definition at line 180 of file BasicOceanSystem.h.

◆ oceanMaterial2

MaterialHandle Cogs::Core::BasicOceanSystem::oceanMaterial2 = MaterialHandle::NoHandle
private

Definition at line 181 of file BasicOceanSystem.h.

◆ oceanTaskGroup

TaskId Cogs::Core::BasicOceanSystem::oceanTaskGroup = NoTask
private

Definition at line 150 of file BasicOceanSystem.h.

◆ P

std::vector<float> Cogs::Core::BasicOceanSystem::P
private

Definition at line 152 of file BasicOceanSystem.h.

◆ phaseShiftNoiseFrequency

unsigned int Cogs::Core::BasicOceanSystem::phaseShiftNoiseFrequency = 3
private

Frequency of phase shift noise wrt FFT tile size.

Definition at line 134 of file BasicOceanSystem.h.

◆ phaseShiftNoiseFrequencyKey

VariableKey Cogs::Core::BasicOceanSystem::phaseShiftNoiseFrequencyKey = NoProperty
private

Definition at line 195 of file BasicOceanSystem.h.

◆ phaseShiftNoisePeriodKey

VariableKey Cogs::Core::BasicOceanSystem::phaseShiftNoisePeriodKey = NoProperty
private

Definition at line 196 of file BasicOceanSystem.h.

◆ PlanarReflectionKey

VariableKey Cogs::Core::BasicOceanSystem::PlanarReflectionKey = NoProperty
private

Definition at line 186 of file BasicOceanSystem.h.

◆ reflectionBrightnessKey

VariableKey Cogs::Core::BasicOceanSystem::reflectionBrightnessKey = NoProperty
private

Definition at line 197 of file BasicOceanSystem.h.

◆ ReflectionTextureH

TextureHandle Cogs::Core::BasicOceanSystem::ReflectionTextureH = TextureHandle::NoHandle
private

Definition at line 178 of file BasicOceanSystem.h.

◆ seaLevelKey

VariableKey Cogs::Core::BasicOceanSystem::seaLevelKey = NoProperty
private

Definition at line 194 of file BasicOceanSystem.h.

◆ significantWaveHeight

float Cogs::Core::BasicOceanSystem::significantWaveHeight = 4.f
private

Definition at line 130 of file BasicOceanSystem.h.

◆ significantWaveHeightKey

VariableKey Cogs::Core::BasicOceanSystem::significantWaveHeightKey = NoProperty
private

Definition at line 190 of file BasicOceanSystem.h.

◆ SkyDomeKey

VariableKey Cogs::Core::BasicOceanSystem::SkyDomeKey = NoProperty
private

Definition at line 185 of file BasicOceanSystem.h.

◆ spcdDzdu

ComplexArray Cogs::Core::BasicOceanSystem::spcdDzdu
private

Definition at line 164 of file BasicOceanSystem.h.

◆ spcdDzdv

ComplexArray Cogs::Core::BasicOceanSystem::spcdDzdv
private

Definition at line 165 of file BasicOceanSystem.h.

◆ spcDx

ComplexArray Cogs::Core::BasicOceanSystem::spcDx
private

Definition at line 162 of file BasicOceanSystem.h.

◆ spcDy

ComplexArray Cogs::Core::BasicOceanSystem::spcDy
private

Definition at line 163 of file BasicOceanSystem.h.

◆ spcDz

ComplexArray Cogs::Core::BasicOceanSystem::spcDz
private

Definition at line 161 of file BasicOceanSystem.h.

◆ specsChanged

bool Cogs::Core::BasicOceanSystem::specsChanged = true
private

Definition at line 145 of file BasicOceanSystem.h.

◆ TangentsKey

VariableKey Cogs::Core::BasicOceanSystem::TangentsKey = NoProperty
private

Definition at line 184 of file BasicOceanSystem.h.

◆ TangentsTexH

TextureHandle Cogs::Core::BasicOceanSystem::TangentsTexH = TextureHandle::NoHandle
private

Definition at line 177 of file BasicOceanSystem.h.

◆ tilePeriod

unsigned int Cogs::Core::BasicOceanSystem::tilePeriod = 30
private

Number of FFT-tiles before ocean repeats itself.

Definition at line 135 of file BasicOceanSystem.h.

◆ waterColorKey

VariableKey Cogs::Core::BasicOceanSystem::waterColorKey = NoProperty
private

Definition at line 188 of file BasicOceanSystem.h.

◆ waveDirectionKey

VariableKey Cogs::Core::BasicOceanSystem::waveDirectionKey = NoProperty
private

Definition at line 189 of file BasicOceanSystem.h.

◆ waves

BasicOceanWaves Cogs::Core::BasicOceanSystem::waves = BasicOceanWaves::Default
private

Definition at line 136 of file BasicOceanSystem.h.

◆ windDirection

float Cogs::Core::BasicOceanSystem::windDirection = 0.f
private

Definition at line 133 of file BasicOceanSystem.h.

◆ windSpeed

float Cogs::Core::BasicOceanSystem::windSpeed = 10.f
private

Definition at line 132 of file BasicOceanSystem.h.


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