Cogs.Core
Source
Systems
Appearance
MaterialSystem.h
1
#pragma once
2
3
#include "Systems/ComponentSystem.h"
4
5
#include <unordered_map>
6
7
#include "Components/Appearance/MaterialComponent.h"
8
9
namespace
Cogs
10
{
11
namespace
Core
12
{
13
class
Context;
14
15
struct
MaterialData
16
{
18
MaterialInstanceHandle
instance
=
MaterialInstanceHandle::NoHandle
;
19
21
bool
sharedInstance
=
false
;
22
24
bool
lockInstance
=
false
;
25
};
26
35
class
MaterialSystem
:
public
ComponentSystemWithDataPool
<MaterialComponent, MaterialData>
36
{
37
public
:
38
MaterialSystem
(
Memory::Allocator
* allocator,
SizeType
capacity) :
ComponentSystemWithDataPool
(allocator, capacity) {}
39
41
void
update
(
Context
*
context
)
override
;
42
44
void
cleanup
(
Context
*
context
)
override
;
45
47
void
removeUnusedSharedInstances
();
48
50
std::unordered_map<size_t, MaterialInstanceHandle>
instances
;
51
};
52
}
53
}
Cogs::Core::ComponentSystemBase::context
Context * context
Pointer to the Context instance the system lives in.
Definition:
ComponentSystem.h:136
Cogs::Core::ComponentSystemBase::update
void update()
Updates the system state to that of the current frame.
Definition:
ComponentSystem.h:65
Cogs::Core::ComponentSystemWithDataPool
Component system with parallel data per component stored in a pool similar to how the components them...
Definition:
ComponentSystem.h:365
Cogs::Core::Context
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition:
Context.h:83
Cogs::Core::MaterialSystem
Updates material components.
Definition:
MaterialSystem.h:36
Cogs::Core::MaterialSystem::removeUnusedSharedInstances
void removeUnusedSharedInstances()
Removes any shared material instances no longer in use.
Definition:
MaterialSystem.cpp:290
Cogs::Core::MaterialSystem::instances
std::unordered_map< size_t, MaterialInstanceHandle > instances
Holds shared material instances used by one or more MaterialComponent instances.
Definition:
MaterialSystem.h:50
Cogs::Core::MaterialSystem::cleanup
void cleanup(Context *context) override
Cleanup the material system, releasing any shared material instances held.
Definition:
MaterialSystem.cpp:308
Cogs::Memory::Allocator
Base allocator implementation.
Definition:
Allocator.h:30
Cogs
Contains all Cogs related functionality.
Definition:
FieldSetter.h:23
Cogs::SizeType
ComponentIndex SizeType
Type used to track the size of pools.
Definition:
Component.h:19
Cogs::Core::MaterialData
Definition:
MaterialSystem.h:16
Cogs::Core::MaterialData::lockInstance
bool lockInstance
If the material component should be locked to its current instance.
Definition:
MaterialSystem.h:24
Cogs::Core::MaterialData::sharedInstance
bool sharedInstance
If the material instance currently held is shared.
Definition:
MaterialSystem.h:21
Cogs::Core::MaterialData::instance
MaterialInstanceHandle instance
Currently active material instance.
Definition:
MaterialSystem.h:18
Cogs::Core::ResourceHandle_t< MaterialInstance >
Cogs::Core::ResourceHandle_t< MaterialInstance >::NoHandle
static const ResourceHandle_t NoHandle
Handle representing a default (or none if default not present) resource.
Definition:
ResourceHandle.h:193
Generated by
1.9.6