Commit Graph

2001 Commits

Author SHA1 Message Date
haslersn
9a488c4a25 common, voxygen: 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)`.
  On the lower bound in z direction, there's no restriction. An
  `RectRasterableVol` can be used with `VolGrid2d`.
2019-08-30 19:46:01 +02:00
haslersn
28c5886841 common: Rename VolMap{2d, 3d} -> VolGrid{2d, 3d} 2019-08-30 16:51:27 +02:00
haslersn
4bc1a644ec common, voxygen: Consistent Err/Error naming
* Types are named `...Error`
* Enum variants are named `...Err`
2019-08-30 16:51:27 +02:00
haslersn
e6ed834882 common: Impl IntoVolIterator for Chunk and Chonk 2019-08-30 16:51:27 +02:00
haslersn
504cc592a2 common: Add IntoVolIterator trait 2019-08-29 21:17:40 +02:00
haslersn
cddccc5fc1 common: Use index buffered chunks utilizing morton order
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`.

This commit replaces the `HashMap` by a data structure where the voxels are
ordered by a morton curve (see https://en.wikipedia.org/wiki/Z-order_curve ).
In sparsely populated chunks (i.e. where most of the voxels are some default
voxel like air) we of course don't want to store the default voxels.
Therefore, we also use an index buffer.

More specifically, the new data structure works as follows.

The voxels of a `Chunk` are conceptually ordered by morton order and then
subdivided into 256 groups along the order. The constant `BLOCK_GROUP_SIZE`
contains the number of voxels per group. The field `vox : Vec<V>` contains
concatenated groups, i.e. its `len()` is invariantly divisable by
`BLOCK_GROUP_SIZE` and every (aligned) sequence of `BLOCK_GROUP_SIZE` voxels
in `self.vox` is a group.

Furthermore there's an index buffer `indices : [u8; 256]` which contains for
each group

* (a) the order in which it has been inserted into `Chunk::vox`,
  if the group is contained in `Chunk::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.)

Concerning morton order:

* (1) The index buffer `Chunk::indices` unconditionally exists for every
  chunk and is sorted by morton order.
* (2) The groups in `Chunk::vox` are not sorted by morton order, but rather
  by their insertion order in order to prevent insertions in the middle of
  a big vector.
* (3) The voxels inside a group in `Chunk::vox` are sorted by
  morton order.

Rationale:

We hope that sorting indices and voxels by morton order provides cache
friendliness for local access patterns. Note that, as mentioned in (2),
`self.vox` is not fully sorted by morton order. Only individual groups
therein are. This is because otherwise most insertions would be expensive.
(As it is, still insertions that trigger a reallocation of `Chunk::vox` are
expensive.) As a future optimization, we could possibly provide an
`self.optimize()` method to sort the groups by morton order (and update the
index buffer accordingly). One could then clone a `Chunk`, run mentioned
method in a background thread and afterwards, if the original `Chunk` wasn't
altered in the meantime, replace it by its optimized version.

The number of groups is 256 such that the index buffer can consist of `u8`s.
This keeps the space requirement for the index buffer low and hence an empty
or almost empty `Chunk` doesn't consume too much memory.
2019-08-29 21:17:40 +02:00
haslersn
97037a672c common: prepend/append multiple SubChunks in a batch 2019-08-29 21:17:40 +02:00
haslersn
95c4f17eb7 common: Calculate magic number in Chonk 2019-08-29 21:17:40 +02:00
haslersn
9225d0c0de common: Set TerrainChunk::SIZE.z = std::i32::MAX 2019-08-29 21:17:40 +02:00
haslersn
b88be88ad5 common: For trait ReadVol remove get_unchecked() 2019-08-29 21:17:40 +02:00
Joshua Barretto
b53c882dc7 Merge branch 'haslersn/no-cheetah' into 'master'
common: Stop abusing wild animals for bit shifts

See merge request veloren/veloren!467
2019-08-29 17:07:52 +00:00
haslersn
9844e95e5f common: Stop abusing wild animals for bit shifts 2019-08-29 18:06:52 +02:00
Joshua Barretto
2cf52b7093 Merge branch 'xp-226' into 'master'
Make XP a u32 rather than f32

Closes #226

See merge request veloren/veloren!465
2019-08-27 22:33:14 +00:00
yashaslokesh
be71aea20b Changed exp type from f64 to u32 and altered exp calculations and function signatures to adhere to the new types
Signed-off-by: Yashas Lokesh <yashas.lokesh@gmail.com>
2019-08-27 22:33:14 +00:00
Timo Koesters
1bd3f0ab28 Merge branch 'timo-keybinds' into 'master'
Timo keybinds

See merge request veloren/veloren!464
2019-08-27 14:10:56 +00:00
timokoesters
cd061aba85
Make respawn hint text base on key bindings 2019-08-27 14:42:53 +02:00
timokoesters
6b4dfcc533
Allow mapping the same key to multile actions (LMB = attack + respawn) 2019-08-27 14:03:40 +02:00
timokoesters
186db16707
Rename attack, block to main, alt 2019-08-27 14:03:39 +02:00
Timo Koesters
838eab8637 Merge branch 'timo-attack-delay' into 'master'
Timo attack delay

See merge request veloren/veloren!463
2019-08-27 12:01:45 +00:00
timokoesters
b725b0e9ea
End rolling when player is in the air 2019-08-27 11:06:55 +02:00
timokoesters
74677784c0
Add attack buildup duration (Delay before hit) 2019-08-27 11:06:54 +02:00
timokoesters
72564cf8b4
Make action durations constants 2019-08-27 11:06:54 +02:00
timokoesters
869535e5a2
Rename tool strength/damage to power 2019-08-26 20:05:13 +02:00
Timo Koesters
e5413360b6 Merge branch 'timo-components' into 'master'
Better component states

See merge request veloren/veloren!458
2019-08-26 15:47:43 +00:00
timokoesters
269d179243
Remove vek patch, it's on crates.io now 2019-08-26 17:26:16 +02:00
timokoesters
84d0f61596
Make pipeline succeed 2019-08-26 14:05:17 +02:00
timokoesters
a7747fe965
Simplify code 2019-08-26 13:12:45 +02:00
timokoesters
c4879307af
Update to github vek repo 2019-08-26 13:12:45 +02:00
timokoesters
b89bfcbfc1
Remove unnecessary map 2019-08-26 13:12:44 +02:00
timokoesters
08fa6a3414
Prevent problems with no vel while rolling in the future 2019-08-26 13:12:44 +02:00
timokoesters
c278ac9927
Add todo making glide an ability/item 2019-08-26 13:12:44 +02:00
timokoesters
98f8196a16
Put combat related values into constants 2019-08-26 13:12:43 +02:00
timokoesters
05f2f168fd
Make falldamage local, don't use force update for local, cleanup 2019-08-26 13:12:43 +02:00
timokoesters
eb34e5bb27
fmt 2019-08-26 13:12:43 +02:00
timokoesters
b96557d012
Fix roll from cliff bug 2019-08-26 13:12:42 +02:00
timokoesters
a715a84ea7
Implement unstoppable rolling 2019-08-26 13:12:42 +02:00
timokoesters
01410569a4
Use look_dir when blocking 2019-08-26 13:12:41 +02:00
timokoesters
3258fa3a3c
Add basis for projectiles
But we have no controller action to spawn them yet
2019-08-26 13:12:41 +02:00
Songtronix
814e858720
Split Events in ServerEvent and LocalEvent 2019-08-26 13:12:41 +02:00
timokoesters
75368dbac1
Remove dbg 2019-08-26 13:12:40 +02:00
timokoesters
62745c4cad
Only use look_dir for ori when wielded or attacking 2019-08-26 13:12:40 +02:00
timokoesters
295969517c
Improve combat range 2019-08-26 13:12:40 +02:00
timokoesters
e8ccbe75fa
Clean up entity spawning code 2019-08-26 13:12:39 +02:00
timokoesters
b826edf6e8
Make aiming 2D 2019-08-26 13:12:39 +02:00
timokoesters
0912de2a26
Make aiming more precise 2019-08-26 13:12:38 +02:00
timokoesters
e90f95bc75
Look in the direction of the camera 2019-08-26 13:12:38 +02:00
jshipsey
39bd888a7c
idle block animation 2019-08-26 13:12:38 +02:00
timokoesters
e7c61c30cc
Block when pressing right click while looking at the attacker 2019-08-26 13:12:37 +02:00
timokoesters
e42ffb362a
Remove unnecessary components 2019-08-26 13:12:37 +02:00
timokoesters
b748c1a6e5
Make gliding the error animation 2019-08-26 13:12:37 +02:00