Skip to content

Commit

Permalink
docs: updated docs accordingly to new radius system
Browse files Browse the repository at this point in the history
  • Loading branch information
inlife committed May 8, 2021
1 parent 0f2296d commit 4a71d0b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 48 deletions.
48 changes: 1 addition & 47 deletions docs/defs/entity.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ Owner, is an artificial concept that represents a relation of the entity to some
Making an entity owned allows to do multiple things:
* Fetching entities owned by specific user via [librg_world_fetch_owner](defs/query.md#librg_world_fetch_owner)
* Querying nearby entities based of current [radius](librg_entity_radius_set) via [librg_world_query](defs/query.md#librg_world_query)
* Querying nearby entities based of current via [librg_world_query](defs/query.md#librg_world_query)
* Setting up global and relational visibility via [librg_entity_visibility_owner_set](#librg_entity_visibility_owner_set) that will be used by query methods
* Writing and reading world (serialization and replication) via [librg_world_write](defs/query.md#librg_world_write) methods
Expand Down Expand Up @@ -362,52 +362,6 @@ int64_t librg_entity_owner_get(
------------------------------
## librg_entity_radius_set
Sets current entity visibility radius.
Visibility radius influences only entities that are owned.
It represents a linear/circular/spherical (depending on world configuration) radius of entity visibility in terms of nearby chunks,
and used whilist general visibility calculations in the [librg_world_query](defs/query.md#librg_world_query) method.
If property set for an entity that is not owned, but the owner is later on changed, it will be still applied, since the value is stored in the internal storage.
##### Signature
```c
int8_t librg_entity_radius_set(
librg_world *world,
int64_t entity_id,
int8_t observed_chunk_radius
)
```
##### Returns
* In case of success: `LIBRG_OK`
* In case of invalid world: `LIBRG_WORLD_INVALID`
* In case of unknown entity: `LIBRG_ENTITY_UNTRACKED`
------------------------------
## librg_entity_radius_get
Returns current entity visibility radius.
##### Signature
```c
int8_t librg_entity_radius_get(
librg_world *world,
int64_t entity_id
)
```
##### Returns
* In case of success: number representing current radius
* In case of invalid world: `LIBRG_WORLD_INVALID`
* In case of unknown entity: `LIBRG_ENTITY_UNTRACKED`
------------------------------
## librg_entity_visibility_global_set
Set entity global visibility value.
Expand Down
3 changes: 3 additions & 0 deletions docs/defs/packing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ However, instead of returning set of results directly to you, it rather builds a
and compares it with a previous snapshot (from previous call to this method).
This way method is able to keep track which entities are considered to be new, existing or forgotten for each owner within his view radius (based on entities that he owns).

Visibility (Chunk) radius represents a linear/circular/spherical (depending on world configuration) radius of visibility in terms of nearby chunks.

Additionally, an event is fired for each entity within owner's view radius, allowing you to write any additional information specific for this owner or this entity.
For more details on events, please refer to the [events](defs/events.md) page.
In case you wish to write any additional information, you would need to return length of the data you copied to the buffer. More details in the [example](#example) below.
Expand All @@ -29,6 +31,7 @@ If the provided space will not be enough, you need to redefine the macro to incr
int32_t librg_world_write(
librg_world *world,
int64_t owner_id,
uint8_t chunk_radius,
char *buffer, /* out */
size_t *size, /* in-out */
void *userdata
Expand Down
3 changes: 2 additions & 1 deletion docs/defs/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ int32_t librg_world_fetch_ownerarray(
Method is used for spatial entity filtering.
It returns all entities that are "visible" to a provided `owner_id`.

The visibility is calculated based on visibility "radius" of each entity that is owned by that owner, and returned as a single array of unique entries.
Visibility (Chunk) radius represents a linear/circular/spherical (depending on world configuration) radius of visibility in terms of nearby chunks.
If entity was not properly placed onto a **valid chunk**, it will be filtered out from the query.
Additionally any visibility overrides are applied on per-entity basis, filtering out those entities that should be (in)visible for the given owner.

Expand All @@ -157,6 +157,7 @@ Additionally any visibility overrides are applied on per-entity basis, filtering
int32_t librg_world_query(
librg_world *world,
int64_t owner_id,
uint8_t chunk_radius,
int64_t *entity_ids, /* out */
size_t *entity_amount /* in-out */
)
Expand Down

0 comments on commit 4a71d0b

Please sign in to comment.