Commit graph

13637 commits

Author SHA1 Message Date
Bill Currie
313aa116f8 [console] Get a debug camera working
It's now possible to move around the world separate from the player. The
debug ui has its own set of button and axis bindings for navigation.
2023-07-12 00:55:44 +09:00
Bill Currie
d0d39ecee0 [renderer] Allow the camera to be overridden
Necessary for a debug camera.
2023-07-12 00:47:40 +09:00
Bill Currie
706995f6b3 [client] Correct the description of move.up axis
My 3d mouse has +Z as down (makes sense, really), which is what I set
the code to, but I guess I forgot to correct the description.
2023-07-12 00:40:37 +09:00
Bill Currie
4522264c57 [ui] Fix an include order issue
Concrete sized arrays need concrete types.
2023-07-11 12:04:32 +09:00
Bill Currie
1b89598b28 [renderer] Clean up SCR_UpdateScreen a little
SCR_UpdateScreen_Legacy now takes only the screen functions pointer (it
didn't need camera or realtime), and the camera sizzle code has been
moved into one place to make cleaning it up easier (when I get around to
auditing AngleVectors etc).
2023-07-11 11:41:14 +09:00
Bill Currie
d848a73aee [ui] Layout the entire hierarchy
Skipping the root view (widget) sort of made sense before windows became
separate canvases as there was only the one hierarchy, but doing so
prevented windows (panels) from fitting themselves to their children.
However, now I need to think of a good way of specifying a minimum size
for panels.
2023-07-11 10:04:07 +09:00
Bill Currie
d8b59656aa [ui] Reset active widget when UI context is hidden
WIdgets can't possibly be active when the entire UI is hidden, and
resetting the active widget when hiding the UI helps when the state gets
broken due to widget id conflicts.
2023-07-11 10:04:07 +09:00
Bill Currie
24b5066760 [ui] Implement panel widgets and use for windows
The intent is to use them for menus, tooltips and anything else along
those lines, but windows was a good starting point (and puts a border
along the top of the window too).
2023-07-11 10:04:07 +09:00
Bill Currie
698ce157b3 [ecs] Move correct number of subpool ranges
Fixes yet another segfault when deleting the last range in the subpool.
Also, initialize the subpool's next index.
2023-07-11 00:06:21 +09:00
Bill Currie
5ad6ec2757 [ui] Distribute remaining space over expand children
It's not perfect as the first N expanding children get grown by 1 pixel
regarless of weight, but it's much better than leaving a (possibly quite
large) gap at the edge of the layout.
2023-07-10 22:13:58 +09:00
Bill Currie
c18e432e0f [ui] Make windows fit to children
I'm not sure this is what I want, especially in the long run, but it
does make simple windows much easier to create (and not look broken due
to being specified too small).
2023-07-10 22:12:45 +09:00
Bill Currie
48cc4db45d [ui] Give windows a small border
It's currently hard-coded to black, but it makes the windows much easier
to see when overlapping.
2023-07-10 22:10:04 +09:00
Bill Currie
7e758327f6 [glsl] Use a unified queue for batched quads
This makes the glsl renderer compatible with canvases, and thus imui. It
also makes for much saner draw call counts.
2023-07-10 19:12:41 +09:00
Bill Currie
4e7bd11415 [build] Clean up make distcheck issues 2023-07-10 11:12:22 +09:00
Bill Currie
55705dac83 [qfcc] Only compile in the compile-only tests
The source tree is made read-only by `make distcheck`, so writing
temporary files to the source directory is a no-no (really, it's a bit
of a bug in qfcc, as per #51).
2023-07-10 11:04:17 +09:00
Bill Currie
ac625830c8 [ui] Raise a window when its title bar is clicked
Getting to have a real UI here.
2023-07-10 00:11:24 +09:00
Bill Currie
79e4a5f6a8 [ui] Add the concept of draw order to canvases
Canvas draw order is sorted by group then order within the group. As a
fallback, the canvas entity id is used to keep the sort stable, but
that's only as stable as the ids themselves (if the canvases are
destroyed and recreated, the ids may switch around).
2023-07-09 23:27:26 +09:00
Bill Currie
c2d68f5495 [ui] Avoid creating a subpool for the canvas component
It's never used and just not needed.
2023-07-09 22:22:05 +09:00
Bill Currie
9f737000a8 [ui] Put windows on separate canvases
This fixes the draw order issues shown by overlapping windows.
2023-07-09 22:22:05 +09:00
Bill Currie
f359f47e54 [ui] Add a formatted label (like printf)
Formatted printing is just too handy, and having to use va all the time
is a bit of a pain.
2023-07-09 12:10:28 +09:00
Bill Currie
a8b80c4be5 [ui] Delete subpools when a canvas is deleted
Yet another finger in the memory dyke.
2023-07-09 12:06:08 +09:00
Bill Currie
76b6d3141b [ecs] Use correct index when deleting subpool ranges
Coming up with tests is hard. Breaking code with real code is easy.
2023-07-09 11:52:11 +09:00
Bill Currie
ad9e85b8d4 [ui] Access the canvas visibility flag safely
That wasn't so well thought out as adding fields before the flag made
for some rather interesting behavior.
2023-07-09 11:49:05 +09:00
Bill Currie
bf05da26cc [ui] Make Canvas_SetLen operate on only one canvas
I plan on using sub-canvases to fix the imui window overlap issue and
don't want the windows being affected by (eg) hud canvas size changes.
2023-07-08 20:56:40 +09:00
Bill Currie
c32ffce886 [ecs] Add a function to move a subpool to be the last
This has use when the order of components in the pool affects draw order
(or has other significance), especially at the subpool level. I plan to
use it for fixing overlapping windows in imui.
2023-07-08 19:55:37 +09:00
Bill Currie
9ff38418d3 [client] Move cshift into client screen canvas
This fixes cshifts affecting the console and debug canvases. The
crosshair and center print have also been moved for the same reason.
2023-07-08 14:32:02 +09:00
Bill Currie
3138c7ae3b [client] Clean up screen view creation 2023-07-08 14:04:29 +09:00
Bill Currie
8bb5d2e1c9 [vulkan] Plug a memory leak in capture
I probably need to do this for other subsystems as well, but it stood
out when chasing down another memory leak.
2023-07-08 11:15:51 +09:00
Bill Currie
79ab2f7ba7 [ui] Add a shaped text cache system
Shaped text is cached using all the shaping parameters as well as the
text itself as a key. This makes text shaping a non-issue for imui when
the text is stable, taking my simple test from 120fps to 1000fps
(optimized build).
2023-07-08 11:15:51 +09:00
Bill Currie
0360e33a00 [ecs] Add "tree mode" to hierarchies
As I had long suspected, building large hierarchies is fiendishly
expensive (at least O(N^2)). However, this is because the hierarchies
are structured such that adding high-level nodes results in a lot of
copying due to the flattened (breadth-first) layout (which does make for
excellent breadth-first performance when working with a hierarchy).

Using tree mode allows adding new nodes to be O(1) (I guess O(N) for the
size of the sub-tree being added, but that's not supported yet) and
costs only an additional 8 bytes per node. Switching from flat mode to
tree mode is very cheap as only the additional tree-related indices need
to be fixed up (they're almost entirely ignored in flat mode). Switching
from tree to flat mode is a little more expensive as the entire tree
needs to be copied, but it seems to be an O(N) (size of the tree).

With this, building the style editor window went from about 25% to about
5% (and most of that is realloc!), with a 1.3% cost for switching from
tree mode to flat mode.

There's still a lot of work to do (supporting removal and tree inserts).
2023-07-07 14:42:49 +09:00
Bill Currie
008aebf344 [console] Implement a very lame style editor
Lame partly because the color selection is not nice. However, it has
shown how slow hierarchy creation can be (it swamps font layout even).
2023-07-06 19:39:26 +09:00
Bill Currie
d8eef0be34 [ui] Avoid adding empty labels for radio buttons
More places will need it, but this fixes a problem with a large array of
just buttons.
2023-07-06 19:36:03 +09:00
Bill Currie
d4b11923b9 [ui] Add inactive labels and a style api
Labels are always good and the style api allows pushing/popping and
modifying the current style.
2023-07-06 19:34:48 +09:00
Bill Currie
b58c373f3e [ui] Use correct type for expansion calculations
Using unsigned in the calculations makes for some very large views.
2023-07-06 19:31:18 +09:00
Bill Currie
08cd03e632 [ui] Allow the parent layout rules to be modified
This makes it easy to control whether a window is a fixed size or fits
its children (or any other scheme, though those are the two most
likely).
2023-07-06 19:24:23 +09:00
Bill Currie
9b81ac1d38 [ui] Use macros for component ids
Saves me having to write the calculation every time they're needed.
2023-07-06 19:06:09 +09:00
Bill Currie
df40a50b91 [ui] Implement dragable collapsible windows
And of course, closable.
2023-07-06 12:21:14 +09:00
Bill Currie
300badc96a Fix a couple of windows build issues
There's still the problem with unused variables when building for
windows because of vulkan debug stuff, but this fixes the important
errors. It actually still works (at least under wine).
2023-07-06 02:04:47 +09:00
Bill Currie
a6e75b7617 [ui] Add a very basic style system
Nothing can be changed at the moment, but it actually looks a little
like a UI.
2023-07-06 01:27:46 +09:00
Bill Currie
b34d3cae91 [ui] Rename the imui size control enumerators
I didn't particularly like the "kind" in the name. I'm not super happy
with percent, but it will do for now.
2023-07-06 00:15:34 +09:00
Bill Currie
0fab830be6 [ui] Implement auto-expand layout
By default, horizontal and vertical layouts expand to fill their parent
in their on-axis direction (horizontally for horizontal layouts), but
fit to their child views in their off-axis.

Flexible space views take advantage of auto-expansion, pushing sibling
views such that the grandparent view is filled on the parent view's
on-axis, and the parent view is filled by the space in the parent view's
off-axis. Flexible views currently have a background fill, allowing them
to provide background filling of the overall view with minimal overdraw
(ancestor views don't need to have any fill at all).
2023-07-05 19:33:00 +09:00
Bill Currie
a92754caf1 [ui] Free the label when freeing the state
Plugs a memory leak.
2023-07-04 17:24:45 +09:00
Bill Currie
104fba13a6 [ui] Add a text color component
Despite the current rendering API taking only byte color, the component
holds a uint32_t to allow for rgba color when I figure out a suitable
API.
2023-07-04 17:17:16 +09:00
Bill Currie
6701f921a4 [ecs] Add a function to safely get a component
It returns null if the entity is invalid or doesn't have the component.
Useful when the component is optional.
2023-07-04 16:48:15 +09:00
Bill Currie
7e338b7e29 [ecs] Delay calculation of last index
Removing a hierarchy from an entity can result in a large number of
component removes in the same pool, thus changing index of the lest
element of the pool. This *seems* to fix the memory corruption I've been
experiencing with the debug UI.
2023-07-04 16:37:09 +09:00
Bill Currie
71bc708030 [ecs] Use nullindex for hierarchy indices
Even though nullindex and nulent have the same value, they have very
different meanings (and I might shift to 0 for nulent).
2023-07-04 14:43:20 +09:00
Bill Currie
5000004f7d [util] Integrate sys_mem into the build
Nicely, all that was needed was a couple of includes and renaming the
functions.
2023-07-04 14:39:36 +09:00
Bill Currie
d9362e81ae [util] Add functions to get the memory usage
Found on stackexchange
(https://stackoverflow.com/questions/669438/how-to-get-memory-usage-at-runtime-using-c)
but written by David Robert Nadeau. Currently unmodified (so changes
can be tracked properly).
2023-07-04 12:49:05 +09:00
Bill Currie
403cf72f52 [ui] Implement a layout stack and radio buttons
Also, remove an intermittent double free caused by deleting views that
have already been deleted.
2023-07-04 01:31:04 +09:00
Bill Currie
6fa016e23b [vulkan] Delay main render resizes by 2s
This makes window resizing a little more responsive (though it could be
better yet (maybe, could be an X11 limitation)).
2023-07-03 23:38:57 +09:00