27 #include "generic/property.h"
28 #include "generic/managed.h"
29 #include "renderers/renderer.h"
31 #include "interfaces.h"
32 #include "nodes/stage_node.h"
40 WRITE_OPERATION_UPDATE,
41 WRITE_OPERATION_REMOVE,
46 WriteOperation operation;
47 StageNodeType stage_node_type;
51 #define MAX_STAGED_WRITES 256
64 void add_geom(
GeomID geom_id);
65 void remove_geom(
GeomID geom_id);
67 void add_actor(
ActorID actor_id);
68 void update_actor(
ActorID actor_id,
const AABB& bounds);
69 void remove_actor(
ActorID actor_id);
71 void add_light(
LightID light_id);
72 void update_light(
LightID light_id,
const AABB& bounds);
73 void remove_light(
LightID light_id);
81 virtual void lights_and_geometry_visible_from(
83 std::vector<LightID>& lights_out,
84 std::vector<StageNode*>& geom_out
89 Stage* get_stage()
const {
return stage_; }
91 virtual void apply_staged_write(
const UniqueIDKey& key,
const StagedWrite& write) = 0;
94 void stage_write(
const ID&
id,
const StagedWrite& op) {
95 auto key = make_unique_id_key(
id);
96 auto& value = staged_writes_[key];
97 value.slot[op.operation] = op;
99 if(!(value.bits & (1 << WRITE_OPERATION_ADD)) && op.operation == WRITE_OPERATION_REMOVE) {
102 value.bits |= (1 << WRITE_OPERATION_MAX);
105 value.bits |= (1 << op.operation);
108 if(staged_writes_.size() >= MAX_STAGED_WRITES) {
123 std::map<UniqueIDKey, WriteSlots> staged_writes_;
126 Property<decltype(&Partitioner::stage_)> stage = {
this, &Partitioner::stage_ };
133 DEFINE_ENUM_HASH(smlt::WriteOperation);
136 #endif // PARTITIONER_H