Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubpa committed May 24, 2020
1 parent cb45fda commit f954f5d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ struct Position { float val; };
struct Velocity { float val; };

struct MoverSystem {
static void OnUpdate(Ubpa::Schedule& schedule) {
schedule.Request(
[](const Velocity* v, Position* p) {
p->val += v->val;
}, "Mover");
}
static void OnUpdate(Ubpa::Schedule& schedule) {
schedule.Request(
[](const Velocity* v, Position* p) {
p->val += v->val;
}, "Mover");
}
};

int main() {
Ubpa::World w;
w.systemMngr.Register<MoverSystem>();
w.entityMngr.CreateEntity<Position, Velocity>();
w.Update();
Ubpa::World w;
w.systemMngr.Register<MoverSystem>();
w.entityMngr.CreateEntity<Position, Velocity>();
w.Update();
}
```
Expand Down
17 changes: 16 additions & 1 deletion doc/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,19 @@ manage entities
- `void Update()`: schedule -> gen job graph -> run job graph in worker threads -> run commands in main thread
- `std::string DumpUpdateJobGraph() const`: after `Update()`, you can use graphviz to vistualize the graph
- `std::string DumpUpdateJobGraph() const`: after `Update()`, you can use graphviz to vistualize the graph
## `RTDCmptViewer`
use `RTDCmptViewer::Iterator` to read CmptPtr
no read/write control
### Methods
- `RTDCmptViewer(EntityLocator* locator, void** cmpts)`
- `Iterator begin() const`
- `Iterator end() const`
- `const std::set<CmptType>& CmptTypes() const`
- `void* const* Components()`
5 changes: 2 additions & 3 deletions doc/comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,13 @@ use `CmptTag::LastFrame<Cmpt> (like const <Cmpt>*)`, `CmptTag::Write<Cmpt> == <C
- `[const] Entity`
- `size_t entityInQueryIndex`
- (not-support) `size_t nativeThreadIndex`
- `const EntityLocator* locator`
- `void** cmpts`
- `RTDCmptViewer`

**System kind**

- components (optional: + `Entity`, `size_t entityInQueryIndex`) : system for each entity
- empty : job
- `const EntityLocator* locator` + `void** cmpts`: run-time dynamic system function
- `RTDCmptViewer`: run-time dynamic system function

### 3.2 System update order

Expand Down
10 changes: 7 additions & 3 deletions include/UECS/RTDCmptViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

namespace Ubpa {
class EntityLocator;

// use RTDCmptViewer::Iterator to read CmptPtr
// no read/write control
class RTDCmptViewer {
public:
// forward
class Iterator /*: public std::iterator<std::forward_iterator_tag, CmptPtr>*/ {
public:
using iterator_category = std::forward_iterator_tag;
Expand All @@ -17,7 +21,7 @@ namespace Ubpa {
using pointer = CmptPtr*;
using reference = CmptPtr&;

Iterator(std::set<CmptType>::iterator typeIter = std::set<CmptType>::iterator{}, void** ptr_cmpt = nullptr)
Iterator(std::set<CmptType>::iterator typeIter = std::set<CmptType>::iterator{}, void* const* ptr_cmpt = nullptr)
: typeIter(typeIter), ptr_cmpt{ ptr_cmpt } {}
bool operator==(const Iterator& rhs) const noexcept {
return ptr_cmpt == rhs.ptr_cmpt;
Expand All @@ -37,7 +41,7 @@ namespace Ubpa {
}
private:
std::set<CmptType>::iterator typeIter;
void** ptr_cmpt;
void* const* ptr_cmpt;
mutable CmptPtr cmptptr{ CmptType::Invalid(), nullptr };
};

Expand All @@ -52,6 +56,6 @@ namespace Ubpa {

private:
EntityLocator* locator;
void** cmpts;
void* const* cmpts;
};
}

0 comments on commit f954f5d

Please sign in to comment.