Commit graph

185 commits

Author SHA1 Message Date
bors[bot] 49bed71932
Merge #5696
5696: Add option for parallax-aware zoom r=def- a=Fireball-Teeworlds

## How this works

Currently we have parallax X and Y parameters that control how far away a layer feels. Currently it's only taken into account for camera moving sideways.

This pull request makes zoom behave as if the camera was moving closer or further away, taking into account the distance to the layer.

In order to provide flexibility, this behaviour is using a separate parallax value, similar to how we have separate values for X and Y. Para Zoom will default to the minimum of parallax X, Y, clamped to be between 0 and 100. This seems to look well on most maps.

This pull request also introduces two new features to the Editor:
* Controls for configuring per-group Para Zoom value. If Custom Zoom is set to No, Para Zoom will automatically keep following to the default value described above, so that people new to the feature don't have to figure out how it works.
* Zoom button that previews the zoom behavior (next to Proof at the top).

## Editor Screenshots

### Para Zoom controls

![screenshot_2022-08-22_21-38-04](https://user-images.githubusercontent.com/68162181/186014490-f7b91245-460f-405f-8d5c-3f91db2a1b9a.png)

![screenshot_2022-08-22_21-37-58](https://user-images.githubusercontent.com/68162181/186014522-03b6e814-4dd9-4d07-9af9-7db5fb434a56.png)

### Zoom Button

![screenshot_2022-08-22_21-40-46](https://user-images.githubusercontent.com/68162181/186014856-2d1d499d-9011-439c-b217-536957e0c1e3.png)

![screenshot_2022-08-22_21-40-50](https://user-images.githubusercontent.com/68162181/186014874-6d2939d3-00ff-4327-a790-414b5151ba31.png)

## In-Game Screenshots

Video: https://youtu.be/W7eXQN0gRFI

This is an older version of the pull request that had an option to disable the new behaviour. The current version can only be disabled in map editor for a particular map.

### Springlobe 3

With new feature:
![screenshot_2022-08-02_04-28-19](https://user-images.githubusercontent.com/68162181/182286371-b67cee1c-73d8-4a24-a9c3-1b28340a3b42.png)

Without:
![screenshot_2022-08-02_04-28-25](https://user-images.githubusercontent.com/68162181/182286367-24555381-1700-4ff1-80c7-39e5dce63820.png)

### Beyond Dreams

With new feature:
![screenshot_2022-08-02_04-28-59](https://user-images.githubusercontent.com/68162181/182286322-114ecb90-0860-462c-9012-bb2f3ff848fb.png)

Without:
![screenshot_2022-08-02_04-28-55](https://user-images.githubusercontent.com/68162181/182286654-f34da72b-7991-4f42-89ad-679279fcb83e.png)

## Checklist

- [X] Tested the change ingame
- [X] Provided screenshots if it is a visual change
- [X] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [X] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [X] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Fireball <fireball.teeworlds@gmail.com>
2022-08-22 21:15:41 +00:00
Corantin H 29a3baaa75 Editor: added the possibility to duplicate layers 2022-08-19 13:20:50 +02:00
Robert Müller 51fb3e9a22 Merge CUIEx class into CUI
There is no need to separate the UI in two classes anymore, as the dependency on `CRenderTools` has been removed.
2022-08-12 19:59:19 +02:00
Robert Müller 7b20009980 Move CUI::CORNER_* enum to IGraphics::CORNER_*
Entirely automatic replacement in preparation for moving rect drawing methods from `CRenderTools` to `IGraphics`.
2022-08-12 17:42:04 +02:00
Fireball 5d886d80f8 Parallax Zoom: use CMapItemGroupEx to store parallax value 2022-08-10 03:05:23 +01:00
Fireball 4ed997f304 Parallax Zoom: fix QuadEnvPoint scaling (and other UI distances) 2022-08-06 16:45:03 +01:00
Fireball 54f7a9817d Parallax Zoom: Zoom preview button in Editor
Known issue: Quad Env Points are scaled incorrectly for Groups with
ParallaxZoom != 100 (in Zoom mode).
2022-08-06 02:30:37 +01:00
Fireball 5bf7f60bf6 Parallax Zoom: Add default zoom option to the editor
Safe defaults for map editing: unless opted-in, Parallax Zoom
will default to maximum(parallax{x,y}).
2022-08-06 01:31:42 +01:00
Fireball a90c86e9a5 Parallax-aware zoom
How this works: parallax values configure perceived distance from camera
when it's moving along x and y axes. Assume that zoom is moving the
camera away and scale layers accordingly, with background layers
(furtherst away) changing the least.

New per-ItemGroup (LayerGroup) setting allows to set the new parallax
value independently from the other two. This can be used to do tricks
like on Time Shop zoom correctly or make it feel like the camera is
changing the field of view at the same time as moving in space.
2022-08-05 00:40:58 +01:00
Chairn a69dc599a9 Huge variable naming format
Fix pointer and pointer array variable naming

Huge renaming to match our rules

Used regex: (?!(return|delete)\b)\b\w+ (m_|ms_|g_|gs_|s_)[^a]\w+\[
            (?!(return|delete)\b)\b\w+ (?!(m_|ms_|g_|gs_|s_))[^a]\w+\[

Further format static variables

Format almost all pointer names accordingly

Used regex: (?!(return)\b)\b\w+
\*(?!(m_p|p|s_p|m_ap|s_ap|g_p|g_ap|ap|gs_ap|ms_ap|gs_p|ms_p))\w+\b[^:\(p]

clang-format

Fix CI fail

Fix misnamed non pointer as pointer and non array as array

Used regex: (?!(return|delete)\b)\b\w+ (m_|ms_|g_|gs_|s_)p\w+\b
            (?!return\b)\b\w+ (ms_|m_|g_|gs_|s_)a\w+\b[^\[]

clang-format

Revert to SCREAMING_SNAKE_CASE and reinstate dead code
2022-07-08 18:01:29 +02:00
Chairn 32318a7c90 Reworked color system
Removed duplicate structs. Replaced 4 floats array with appropriate
struct where applicable
2022-07-06 11:39:51 +02:00
Robert Müller ac40efa263 Only apply size and color if changed, when editing multiple layers
To prevent the color of all layers from being reset to zero when changing just the size.
2022-06-27 23:20:09 +02:00
Robert Müller 70866d6d0c Fix names of SCommonPropState member variables 2022-06-27 23:20:09 +02:00
Chairn a3a85bee5f Remove useless typedef in c++ 2022-06-25 21:05:54 +02:00
Robert Müller 2add5d5c3c Organize game-client and editor includes 2022-06-17 20:32:56 +02:00
Robert Müller eb7e210fc1 Separate editor update and render to fix slow joystick input 2022-06-15 17:37:22 +02:00
ChillerDragon 3667061b68 Use nullptr in generated and editor
-Wzero-as-null-pointer-constant
2022-06-13 18:28:13 +02:00
Chairn 14f7f2e041 Remaining formatting and fix github code scanning 2022-06-11 22:03:23 +02:00
Chairn 01edaec628 Format vector variables names (fixes #5209) 2022-06-11 21:38:49 +02:00
Robert Müller e0e1f49530 Extract BrushFlipXImpl and BrushFlipYImpl 2022-06-06 11:29:52 +02:00
Robert Müller 19e97829ce Extract CLayerTiles::ShiftImpl 2022-06-06 10:59:36 +02:00
Robert Müller 91d2ba1865 Organize game-client includes 2022-05-29 21:24:43 +02:00
Robert Müller 0c69495522 Use std::vector instead of array in editor 2022-05-27 16:36:39 +02:00
Robert Müller 662cb58132 Use std::vector<CFilelistItem> instead of sorted_array 2022-05-26 23:49:30 +02:00
Jupeyy 2677949e58 Add missing nanosecond conversions 2022-05-22 16:08:11 +02:00
Jupeyy 3c597aff95 Switch to nanoseconds 2022-05-18 18:05:41 +02:00
Chairn 583d6e6c01 Mark virtual function as override using a script:
while IFS= read -r line; do file=${line%%:*}; lineno=$(echo $line | cut
-d':' -f2); echo "Treating $file line $lineno"; sed -i -e
"${lineno}s/virtual //" -e "${lineno}s/);\$/) override;/" -e
"${lineno}s/)\$/) override/" -e "${lineno}s/const\$/const override/" -e
"${lineno}s/) {/) override {/" -e "${lineno}s/) const {/) const override
{/" -e "${lineno}s/const;$/const override;/" "$file"; done < a
2022-05-17 23:47:32 +02:00
Robert Müller 52100dbbe7 Use qualified std::swap only 2022-05-15 19:25:36 +02:00
Robert Müller dee7393555 Remove unused includes of base/tl/string.h 2022-05-07 00:02:43 +02:00
ChillerDrgon fe712214a9 Editor: ctrl+leftclick tile to select layer 2022-04-08 14:59:33 +02:00
bors[bot] e632859707
Merge #4687
4687: Add Vulkan backend r=def- a=Jupeyy

This adds a Vulkan 1.0 backend and new features to the graphic settings to select the GPU(if multiple Vulkan GPUs are supported, and a new list for renderers (see screenshot below))

Mutleasy benchmark (CPU bound):
Vulkan multithreaded, single threaded vs OpenGL
(lower graphs are histograms, code by `@Chairn` )

Y = Frametimes in microseconds
lower graphs = amount of frametimes that happened (histogram)
(since the renderer speed differs, you should look at it more like a spread of values rather than the actual values)
![Figure_1](https://user-images.githubusercontent.com/6654924/153448356-941222a3-8bd3-424d-8685-a43389a4f691.png)

Vulkan is especially good in these scenarios, beating OpenGL 3.3 almost 3x with my setup (~600-700 FPS vs. ~1700-1800FPS)


Remaining TODO list:
- [x] compile shaders in cmake ( e.g. `https://gist.github.com/evilactually/a0d191701cb48f157b05be7f74d79396` )
- [ ] needs windows vulkan libraries
- [x] add build instructions (packages)
- [x] get away from coherent memory even for staging buffers (flushing memory just seems to be faster)
- [ ] a lot of testing :P

![screenshot_2022-02-10_17-13-46](https://user-images.githubusercontent.com/6654924/153449066-38d8741b-60c1-4c0c-ba50-57cc07aa2f9d.png)

![screenshot_2022-02-10_17-13-50](https://user-images.githubusercontent.com/6654924/153449075-91ef3b7b-7238-4cad-9a4c-aeb2d784238b.png)


If there are bugs and it's crashing inside the driver the best you can do is to start the client with `dbg_gfx 4` which will (if supported) add Khronos standard validation layers + verbose debugging information + validation layer extensions, e.g. a synchronization validation layer and validation errors reported by the GPU driver directly.
(setting for dbg_gfx (0: none, 1: minimal, 2: affects performance, 3: verbose, 4: all))

edits:
fixes #3547 (probably fixes it, fixed some data races)

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [x] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [x] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Jupeyy <jupjopjap@gmail.com>
Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2022-03-21 14:20:54 +00:00
Chairn 4cc815711b Added direction enumeration for the editor 2022-03-21 05:53:36 +01:00
Jupeyy 14ac5cf297 lazy load editor textures
improve entities texture flags
2022-03-20 18:03:33 +01:00
Robert Müller 74f87ee604 Remove unnecessary trailing semicolons after method declarations 2022-03-08 20:01:26 +01:00
Ravie 2745c1a694 Knife tool 2022-02-26 18:49:06 +01:00
Dennis Felsing fe1b86b173 Remove the totally unsafe editor undo
Since it causes crashes because another thread just accesses the data.

No one has wanted to fix this, so maybe we should just remove it instead
of having clients crash in editor. I'm wondering how much effort it
would be to make this safe. Would we just have to lock for a short part
or is it basically the entire threaded undo operation that has to be
serialized? (No need for a thread then)
2022-02-07 15:57:27 +01:00
def bc78ba57b9 Enable readability-inconsistent-declaration-parameter-name 2022-01-22 14:12:59 +01:00
bors[bot] 5ec6f0994d
Merge #4410
4410: Fix leak in CLayerTiles::BrushGrab (fixes #4409) r=Learath2 a=def-

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
2021-12-17 23:38:19 +00:00
Robert Müller 8887a3137c move DoClearableEditBox to CUIEx 2021-12-03 20:26:23 +01:00
Robert Müller d948a1e41f fix variable name 2021-12-03 20:26:21 +01:00
def a45829f16d Fix leak in CLayerTiles::BrushGrab (fixes #4409) 2021-11-29 14:29:24 +01:00
Robert Müller 053981ee4c refactor UI scrollbars 2021-11-26 23:03:45 +01:00
Jupeyy 0d17665137 Revert "Add new mouse state"
This reverts commit e4cb348db2.
2021-10-23 13:48:21 +02:00
Jupeyy e4cb348db2 Add new mouse state 2021-10-07 16:48:25 +02:00
ChillerDragon 3eb3dcd48b Make use of IO_MAX_PATH_LENGTH
Inspired by
0a7d0fee7c
2021-09-13 12:14:50 +02:00
HamidReza 3ca09259be New Tiles & Improvements 2021-08-28 22:21:38 +04:30
HamidReza c9018a2117 More Tiles 2021-08-28 01:50:39 +04:30
HamidReza 8b69ffef22 clang-format 2021-08-27 22:58:11 +04:30
HamidReza 8dbefa734f Editor Improvements
Added possibility to write separate explanations for different entities and fixed a bug.
2021-08-27 18:36:27 +04:30
Jupeyy a663799188 uint64 -> uint64_t, int64 -> int64_t 2021-06-24 17:19:17 +02:00