555 Commits

Author SHA1 Message Date
Joshua Barretto
98ed7416f7 Fixed typo 2019-09-26 14:03:41 +01:00
Joshua Barretto
d473a00957 Prevented pickups with full inventory 2019-09-26 00:15:07 +01:00
Joshua Barretto
6409d35f9e Added flower and grass items 2019-09-26 00:15:07 +01:00
Joshua Barretto
07568eb0d2 Added block collection, improved controls for it 2019-09-26 00:15:07 +01:00
Joshua Barretto
04de98286e Added velorite 2019-09-26 00:15:07 +01:00
Joshua Barretto
97d27e8a36 Made consumable items have an effect, better damage animation 2019-09-26 00:15:07 +01:00
Joshua Barretto
d14c9ca1bb Added apple and mushroom collection 2019-09-26 00:15:07 +01:00
Joshua Barretto
f536a5f13c Floodfill shadows, smooth shadow lighting 2019-09-26 00:15:07 +01:00
Acrimon
0ee4e1505b Formatted code. 2019-09-24 11:56:19 +02:00
Acrimon
698e70366d Added some tests. 2019-09-24 11:36:35 +02:00
Acrimon
d12e7a6337 Fast powf for sgrb. 2019-09-24 11:05:01 +02:00
Monty Marz
1cab8f638a Character assets Part 1 2019-09-18 16:46:12 +00:00
Joshua Yanovski
f5c4000b1b Allow canceling chunk generation.
Currently we only do this when no players are in range of the chunk.  We
also send the first client who posted the chunk a message indicating
that it's canceled, the hope being that this will be a performance win
in single player mode since you don't have to wait three seconds to
realize that the server won't generate the chunk for you.

We now check an atomic flag for every column sample in a chunk.  We
could probably do this less frequently, but since it's a relaxed load it
has essentially no performance impact on Intel architectures.
2019-09-16 03:41:33 +02:00
haslersn
c7a1bbc00f Bugfix: DefaultPosIterator now starts at lower_bound
Previosly the first iteration was skipped.
2019-09-11 01:48:28 +02:00
Joshua Barretto
e6d8b4b8d8 Exponential interpolation for linear damping
With an additional approximation to allow for the same size jumps given different framerates.
2019-09-09 19:11:40 +00:00
Marcel Märtens
b0ff977297 adjust metrics to rebased Chunks 2019-09-09 10:47:40 +02:00
Marcel Märtens
ae51f9f9dd update version, revert from static prometheus back to normal because static doesnt supprot registries, and implement most of the metrics except for entity count 2019-09-09 09:54:30 +02:00
Joshua Barretto
89b637e94e Merge branch 'fix-jump-height' into 'master'
Fix jump height

See merge request veloren/veloren!485
2019-09-08 15:50:08 +00:00
Timo Koesters
f241bc6b82 Merge branch 'timo-attack' into 'master'
Fix wolfs not attacking and adjust movement while attacking

See merge request veloren/veloren!484
2019-09-07 10:25:57 +00:00
timokoesters
e5e29b490b
Make npcs attack in a smarter way 2019-09-07 12:16:55 +02:00
haslersn
db691b37d1 common: Rework Chunk and Chonk implementation
Previously, voxels in sparsely populated chunks were stored in a `HashMap`.
However, during usage oftentimes block accesses are followed by subsequent
nearby voxel accesses. Therefore it's possible to provide cache friendliness,
but not with `HashMap`.

The previous merge request [!469](https://gitlab.com/veloren/veloren/merge_requests/469)
proposed to order voxels by their morton order (see https://en.wikipedia.org/wiki/Z-order_curve ).
This provided excellent cache friendliness. However, benchmarks showed that
the required indexing calculations are quite expensive. Particular results
on my _Intel(R) Core(TM) i7-7500U CPU @ 2.70 GHz_ were:

| Benchmark                                | Before this commit @ d322384becac | Morton Order @ ec8a7caf42ba | This commit          |
| ---------------------------------------- | --------------------------------- | --------------------------- | -------------------- |
| `full read` (81920 voxels)               | 17.7ns per voxel                  | 8.9ns per voxel             | **3.6ns** per voxel  |
| `constrained read` (4913 voxels)         | 67.0ns per voxel                  | 40.1ns per voxel            | **14.1ns** per voxel |
| `local read` (125 voxels)                | 17.5ns per voxel                  | 14.7ns per voxel            | **3.8ns** per voxel  |
| `X-direction read` (17 voxels)           | 17.8ns per voxel                  | 25.9ns per voxel            | **4.2ns** per voxel  |
| `Y-direction read` (17 voxels)           | 18.4ns per voxel                  | 33.3ns per voxel            | **4.5ns** per voxel  |
| `Z-direction read` (17 voxels)           | 18.6ns per voxel                  | 38.2ns per voxel            | **5.4ns** per voxel  |
| `long Z-direction read` (65 voxels)      | 18.0ns per voxel                  | 37.7ns per voxel            | **5.1ns** per voxel  |
| `full write (dense)` (81920 voxels)      | 17.9ns per voxel                  | **10.3ns** per voxel        | 12.4ns per voxel     |

This commit (instead of utilizing morton order) replaces `HashMap` in the
`Chunk` implementation by the following data structure:

The volume is spatially subdivided into groups of `4*4*4` blocks. Since a
`Chunk` is of total size `32*32*16`, this implies that there are `8*8*4`
groups. (These numbers are generic in the actual code such that there are
always `256` groups. I.e. the group size is chosen depending on the desired
total size of the `Chunk`.)

There's a single vector `self.vox` which consecutively stores these groups.
Each group might or might not be contained in `self.vox`. A group that is
not contained represents that the full group consists only of `self.default`
voxels. This saves a lot of memory because oftentimes a `Chunk` consists of
either a lot of air or a lot of stone.

To track whether a group is contained in `self.vox`, there's an index buffer
`self.indices : [u8; 256]`. It contains for each group

* (a) the order in which it has been inserted into `self.vox`, if the group
    is contained in `self.vox` or
* (b) 255, otherwise. That case represents that the whole group consists
    only of `self.default` voxels.

(Note that 255 is a valid insertion order for case (a) only if `self.vox` is
full and then no other group has the index 255. Therefore there's no
ambiguity.)

Rationale:

The index buffer should be small because:

* Small size increases the probability that it will always be in cache.
* The index buffer is allocated for every `Chunk` and an almost empty `Chunk`
    shall not consume too much memory.

The number of 256 groups is particularly nice because it means that the index
buffer can consist of `u8`s. This keeps the space requirement for the index
buffer as low as 4 cache lines.
2019-09-06 18:20:15 +02:00
haslersn
231302e16b common: Add benchmark for Chonk 2019-09-06 15:44:36 +02:00
haslersn
351b8c91c7 common: Rework volume API
See the doc comments in `common/src/vol.rs` for more information on
the API itself.

The changes include:

* Consistent `Err`/`Error` naming.
  * Types are named `...Error`.
  * `enum` variants are named `...Err`.
* Rename `VolMap{2d, 3d}` -> `VolGrid{2d, 3d}`. This is in preparation
  to an upcoming change where a “map” in the game related sense will
  be added.
* Add volume iterators. There are two types of them:
  * _Position_ iterators obtained from the trait `IntoPosIterator`
    using the method
    `fn pos_iter(self, lower_bound: Vec3<i32>, upper_bound: Vec3<i32>) -> ...`
    which returns an iterator over `Vec3<i32>`.
  * _Volume_ iterators obtained from the trait `IntoVolIterator`
    using the method
    `fn vol_iter(self, lower_bound: Vec3<i32>, upper_bound: Vec3<i32>) -> ...`
    which returns an iterator over `(Vec3<i32>, &Self::Vox)`.
  Those traits will usually be implemented by references to volume
  types (i.e. `impl IntoVolIterator<'a> for &'a T` where `T` is some
  type which usually implements several volume traits, such as `Chunk`).
  * _Position_ iterators iterate over the positions valid for that
    volume.
  * _Volume_ iterators do the same but return not only the position
    but also the voxel at that position, in each iteration.
* Introduce trait `RectSizedVol` for the use case which we have with
  `Chonk`: A `Chonk` is sized only in x and y direction.
* Introduce traits `RasterableVol`, `RectRasterableVol`
  * `RasterableVol` represents a volume that is compile-time sized and has
    its lower bound at `(0, 0, 0)`. The name `RasterableVol` was chosen
    because such a volume can be used with `VolGrid3d`.
  * `RectRasterableVol` represents a volume that is compile-time sized at
    least in x and y direction and has its lower bound at `(0, 0, z)`.
    There's no requirement on he lower bound or size in z direction.
    The name `RectRasterableVol` was chosen because such a volume can be
    used with `VolGrid2d`.
2019-09-06 15:43:31 +02:00
haslersn
fb72faf56b common: prepend/append multiple SubChunks in a batch 2019-09-06 15:33:36 +02:00
haslersn
f16cb02503 common: Calculate magic number in Chonk 2019-09-06 15:33:36 +02:00
haslersn
da40445156 common: Set TerrainChunk::SIZE.z = std::i32::MAX 2019-09-06 15:33:36 +02:00
haslersn
b56de5631f common: For trait ReadVol remove get_unchecked() 2019-09-06 15:33:36 +02:00
Joshua Barretto
fa67696fcd Merge branch 'scott-c/first-person-model' into 'master'
Add first person models

See merge request veloren/veloren!443
2019-09-06 13:02:03 +00:00
scott-c
84516afff1 Fix first person weapon visible while not wielding 2019-09-06 18:22:26 +08:00
Andrew Pritchard
0f7c914222 Deref instead of clone vel 2019-09-06 14:22:58 +08:00
Andrew Pritchard
c408c46448 Vec3 is apprently *not* Copy, Set near plane to 0.1 to prevent tirangle flickering 2019-09-06 13:24:42 +08:00
Andrew Pritchard
90bcdacfd8 Vec3 is copy 2019-09-06 12:04:20 +08:00
Andrew Pritchard
cf2ec6a4a4 Merge branch 'master' into 'fix-jump-height'
# Conflicts:
#   common/src/sys/phys.rs
2019-09-05 13:07:46 +00:00
Andrew Pritchard
72f6145aaa Revert "Revert "Exponential interpolation for linear damping""
This reverts commit 8b9a3ae1df3adee5da0243ff5f7d4de1e0ade1d8.
2019-09-05 18:24:38 +08:00
Andrew Pritchard
fd62f3e89d Revert "Exponential interpolation for linear damping"
This reverts commit 94b9f50efa502ea872c71dea62db71b19be60069.
2019-09-05 18:24:22 +08:00
Andrew Pritchard
713c3c0e39 Exponential interpolation for linear damping
With an additional approximation to allow for the same size jumps given different framerates.
2019-09-05 17:07:15 +08:00
Imbris
80d0884492 Remove all warnings 2019-09-04 19:03:49 -04:00
Imbris
be6584399d Fix some warnings, cleanup comment 2019-09-03 23:09:29 -04:00
Imbris
2946b452f4 Remove derpy eyes :( , fix undead eye indices, fmt 2019-09-03 23:06:15 -04:00
jshipsey
d052add569 fixing eyes, cleanup on offsets 2019-09-03 23:06:13 -04:00
jshipsey
9328ac4f72 tweaked hair colors, head offsets, skin colors 2019-09-03 23:06:11 -04:00
Imbris
3707e49e01 Remove use of empty.vox 2019-09-03 23:06:09 -04:00
Imbris
ef3ff6f21c Add pants coloring, chest and pants sliders 2019-09-03 23:06:06 -04:00
Imbris
96cee60664 Add separate eye color lists for each race 2019-09-03 23:06:02 -04:00
Pfauenauge90
ab715a2bbc hair and skin colours 2019-09-03 23:05:59 -04:00
Imbris
a1c8a4a2f9 adjust how figure head coloring is done 2019-09-03 23:05:58 -04:00
Imbris
0be9d41b0f Add basic index based coloring for figures 2019-09-03 23:05:56 -04:00
Imbris
f263ecd880 Fix sliders, remove uneeded method, fix aspect ratio in character creation 2019-09-03 23:05:54 -04:00
Imbris
6c47c458d8 Add ron file for head offsets, segment unionizer 2019-09-03 23:05:52 -04:00
Imbris
c37646e0e2 Add basic segment combination 2019-09-03 23:05:50 -04:00