Commit graph

2447 commits

Author SHA1 Message Date
Bill Currie
c6b79d49a4 [client] Fix incorrect function component setup
Need to pass the address of the pointer :/
2022-11-10 21:23:04 +09:00
Bill Currie
2fb5b67012 [vulkan] Implement line graph rendering
I should probably just use the line rendering for all renderers and pull
the graph drawing out to the client code.
2022-11-10 21:19:01 +09:00
Bill Currie
39074ba3c1 [qw] Implement hud ping and pl indicators
As well as the periodic update of pings when the scoreboard or hud ping
are shown.
2022-11-10 15:34:31 +09:00
Bill Currie
c07b2e4d1f Make item masks easier to read
When values are bit masks, they're much easier to read when expressed as
a shift than as a raw decimal number, especially when knowing the index
of the bit is important.
2022-11-10 15:08:36 +09:00
Bill Currie
e0fa853f47 [client] Implement the update functions
nq's frags don't update properly yet, and there's still a lot of
optimization to sort out, but it seems to be fairly usable again.
2022-11-10 01:35:33 +09:00
Bill Currie
1b90f2320e [client] Extend sbar's api
I think this makes the purpose of the functions more clear and makes the
protocol logic less dependent on the meaning of some of the updates.
Most of the update functions are not fully implemented yet.
2022-11-09 19:41:59 +09:00
Bill Currie
73e62de2fb [client] Clean up sbar's globals access
I had forgotten that the cl structs in nq and qw were different layouts,
which resulted in qw's sbar/hud being quite broken. Rather than messing
with the structs, I decided it would be far better in the long run to
clean up sbar's access to the cl struct and the few other nq/qw specific
globals it used. There are still plenty of bugs to fix, but now almost
everything is in the one place.
2022-11-09 19:38:54 +09:00
Bill Currie
34f0a59441 [client] Merge sbar
At long last, the status bar code is now shared between nq and qw. There
are many bugs to fix, but at least now they're all in the one place.
2022-11-08 17:42:27 +09:00
Bill Currie
9bf506fec6 [ui] Implement View_Delete
As per the pre-ECS view code, the entire sub-hierarchy of views is
deleted along with the parent view.
2022-11-08 00:20:02 +09:00
Bill Currie
24d8d864a2 [ecs] Optionally delete entities on hierarchy removal
Useful for deleting an entire sub-hierarchy of entities.
2022-11-08 00:16:29 +09:00
Bill Currie
57cd30fca3 [ecs] Move parent setting logic into hierarchy
It should have always been here, but when I first created the hierarchy
and transform objects, I didn't know where things would go. Having two
chunks of code for setting an entity's parent was too already too much,
and I expect to have other hierarchy types. Doesn't fix the issues
encountered with sbar, of course.
2022-11-05 17:54:49 +09:00
Bill Currie
42963f97c0 [client] Clean up some hud redundancies
hud_view is set up by sbar, and the other views are no longer used.
2022-11-05 16:47:52 +09:00
Bill Currie
5f98dac214 [client] Add a hud outline component for debug
Very handy for verifying views are placed correctly. Also fix some type
issues with the func and update components.
2022-11-05 10:55:45 +09:00
Bill Currie
472b6995b7 [ui] Set passage text object start and size
The text object covering the whole passage was not being initialized,
thus center print tried to print rubbish when (incorrectly) printing the
entire message.
2022-11-04 15:26:01 +09:00
Bill Currie
1d51c05f90 [ui] Make passage objects reusable
I had intended to do this for a while, but now that I want it for center
print strings, it was time to make the change.
2022-11-04 13:06:20 +09:00
Bill Currie
c0cfeec5d6 [nq] Clean up sbar updates for info changes
Most of the update functions are scheduled by Sbar_Changed() using
tables to determine what update functions need to be called for which
view entities. As hud_updateonce is called, and an entity can have only
one of any component, this becomes a set of updates to call when during
hud/sbar rendering.
2022-11-04 11:31:11 +09:00
Bill Currie
5f01dc9fb5 [client] Make the hud update function type explicit 2022-11-04 11:10:56 +09:00
Bill Currie
99e12872e5 [console] Get menu rendering working again
For certain values of working. The whole thing needs a rewrite but it's
nice that using an ECS doesn't force everything to conform to that
model.
2022-11-04 10:38:07 +09:00
Bill Currie
6b99697e82 [ui] Get flowed views working with ECS
I'm not particularly happy with the way onresize is handled, but at this
stage a better way of dealing with resizing views and getting the child
views to flow correctly hasn't come to mind. However, the system should
at least be usable.
2022-11-04 00:29:13 +09:00
Bill Currie
bdbb8f1e0b [nq] Get intermission view working again
This is currently just the basic intermission view (not the finale view
or the deathmatch intermission view).
2022-11-03 17:49:05 +09:00
Bill Currie
82d407e3c2 [nq] Get hud time and fps displays working
This includes moving the related cvars from botn nq and qw into the
client hud code. In addition, the hud code supports update and
update-once function components. The update component is for updates
that occur every frame, but update-once components (not used yet) are
for one-shot updates (eg, when a value updates very infrequently).
2022-11-03 14:46:44 +09:00
Bill Currie
0626ec6469 [nq] Get scores display working again
Now only the time portion updates every frame, and then only when the
scores are shown (no real change for that one). Not really a significant
optimization, as the information was updated only while the scores were
shown, but it's still nice.
2022-11-03 11:38:32 +09:00
Bill Currie
4491ce213b [client] Merge cl_screen.c
The client state that was accessed by cl_screen is now put in viewstate
and maintained by the client before calling CL_UpdateScreen.
2022-11-02 15:11:09 +09:00
Bill Currie
9c6c59b370 [qw] Move view hight adjustment out of screen update
cl_screen.c is that little bit closer to being merged.
2022-11-02 09:52:35 +09:00
Bill Currie
efee9c87a9 [nq,qw] Minimize differences in cl_screen.c 2022-11-01 21:00:40 +09:00
Bill Currie
817aeb334e [ui] Convert view_t to an ECS entity
Much of the nq/qw HUD system is quite broken, but the basic status bar
seems to be working nicely. As is the console (both client and server).
Possibly the biggest benefit is separating the rendering of HUD elements
from the updating of them, and much less traversing of invisible views
whose only purpose is to control the positioning of the visible views.

The view flow tests are currently disabled until I adapt the flow code
to ECS.

There seems to be a problem with view resizing in that some gravities
don't follow resizing correctly.
2022-11-01 00:40:52 +09:00
Bill Currie
cf911884c6 [ecs] Add support for sorting component pools
As the bookkeeping data is spread between three arrays, sorting a
component pool is not trivial and thus not something to duplicate around
the codebase.
2022-10-31 13:10:53 +09:00
Bill Currie
962319af09 [ecs] Make Ent_HasComponent more robust
It doesn't check that the entity itself is valid, but it does at least
check that the index fetched from the sparse array is valid. Fixes a
segfault when a valid entity never had the component.
2022-10-31 13:06:55 +09:00
Bill Currie
7c06012383 [util] Support custom swap function for heapsort
Sorting ECS component pools needs to swap multiple chunks of data for
each element being swapped, so the standard swap function isn't enough.
2022-10-31 10:52:03 +09:00
Bill Currie
45e47a6df0 [ui] Update passage code to use an ECS hierarchy
It's not quite complete in that entities need to be created for the
objects, and passage text object might get additional components in the
hierarchy, but the direct use of views has been replaced by the use of a
hierarchy object with the same tree structure, and now has text objects
for paragraphs and the entire passage.
2022-10-27 19:47:10 +09:00
Bill Currie
fa057cb121 [vulkan] Record resource memory size
It's useful mainly for information reports, but might be useful
elsewhere.
2022-10-27 11:32:00 +09:00
Bill Currie
6952f6860d [vulkan] Use the resource functions for shadow maps
Another step towards moving all resource creation into the one place.
The motivation for doing the change was getting my test scene to work
with only ambient lights or no lights at all.
2022-10-27 11:02:45 +09:00
Bill Currie
db7f8a461e [ecs] Move ECS core into its own library
While the libraries are probably getting a little out of hand, the
separation into its own directory is probably a good thing as an ECS
should not be tied to scenes. This should make the ECS more generally
useful.
2022-10-26 17:24:03 +09:00
Bill Currie
4df145d76a [scene] Improve entity component check
For a component to be on an entity, the entity id in the component
pool's dense array must match the entity.
2022-10-26 12:34:09 +09:00
Bill Currie
20c861027e [sw] Take advantage of the ECS for edge rendering
This fixes the segfault due to the world entity not actually existing,
without adding a world entity. It takes advantage of the ECS in that the
edge renderer needs only the world matrix, brush model pointer, and the
animation frame number (which is just 0/1 for brush models), thus the
inherent SOA of ECS helps out, though benchmarking is needed to see if
it made any real difference.

With this, all 4 renderers are working again.
2022-10-25 19:36:09 +09:00
Bill Currie
2a9fcf4f5f [renderer] Tidy up entity component access
Since entity_t has a pointer to the registry owning the entity, there's
no need to access a global to get at the registry. Also move component
getting closer to where it's used.
2022-10-25 12:53:30 +09:00
Bill Currie
5b0810f4c2 [scene] Make Ent_AddComponent more raw
It no longer initializes the new component. For that, use
Ent_SetComponent which will copy in the provided data or call the
component's create function if the data pointer is null (in which case,
Ent_SetComponent acts as Ent_SetComponent used to).
2022-10-25 11:41:14 +09:00
Bill Currie
8acd5c558b [scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).

While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 22:24:36 +09:00
Bill Currie
de786ce197 [scene] Use hierref_t instead of transform_t in hierarchy
Hierarchies are now much closer to being more general in that they are
not tied to 3d transforms. This is a major step to moving the whole
entity/transform system into an ECS.
2022-10-22 13:04:07 +09:00
Bill Currie
b607fe0878 [scene] Add has/get component functions
And define nullent as 0 is a valid entity.
2022-10-21 19:12:20 +09:00
Bill Currie
6189142c60 [renderer] Remove rglyph_t struct
It didn't really add anything of value as the glyph bitmap rects and the
bearings were never used together, and the rest of the fields were
entirely redundant. A small step towards using a component system for
text.
2022-10-20 15:50:53 +09:00
Bill Currie
06ccc3023b [scene] Start work on a full-on ECS system
That does feel a little redundant, but I think the System in ECS is
referring to the systems that run on the components, while the other
system is the support code for the ECS. Anyway...

This is based heavily on the information provided by @skipjack in his
github blog about EnTT. Currently, entity recycling and sparse arrays
for component pools have been implemented, and adding components to an
entity has been tested.
2022-10-16 18:29:25 +09:00
Bill Currie
0c54b0652b Abandon support for clang
The inconsistencies in clang's handling of casts was bad enough, and its
silliness with certain extensions, but discovering that it doesn't
support raw strings was just too much. Yes, it gives a 3s boost to qfvis
on gmsp3v2.bsp, but it's not worth the hassle.
2022-10-16 18:02:25 +09:00
Bill Currie
8ec4a18f5d [scene] Swtich from - to ~ for entity id index
It saves only 1 bit in the set, but it could save on allocations. Also
takes care of a FIXME :P
2022-10-15 14:48:39 +09:00
Bill Currie
6552d76a5f Clarify FIXME on qdefs.h include 2022-10-15 14:42:04 +09:00
Bill Currie
2c9da25e17 Clean up some FIXMEs and XXXs
They seemed to be generally unnecessary. Also fixes some typos in
related comments.
2022-10-15 14:40:29 +09:00
Bill Currie
8464d71264 [scene] Move hierarchies to an ECS-based system
This is the beginning of adding ECS to QF. While the previous iteration
of hierarchies was a start in the direction towards ECS, this pulls most
of the 3d-specific transform stuff out of the hierarchy "objects",
making all the matrices and vectors/quaternions actual components (in
the ECS sense). There's more work to be done with respect to the
transform and entity members of hierarchy_t (entity should probably go
away entirely, and transform should become hierref_t (or whatever its
final name becomes), but I wanted to get things working sooner than
later.

The motivation for the effort was to allow views to use hierarchy_t,
which should be possible once I get entity and transform sorted out.

I am really glad I already had automated tests for hierarchies, as
things proved to be a little tricky to get working due to forgetting why
certain things were there.
2022-10-10 02:00:33 +09:00
Bill Currie
f16fc15605 [scene] Correct some typos in hierarchy.h
Lost the y somewhere
2022-10-09 01:08:48 +09:00
Bill Currie
c9e7810864 [vulkan] Add resource memory offset to qfv_resobj_s
Its value on input is ignored. QFV_CreateResource writes the resource
object's offset relative to the beginning of the shared memory block.
Needed for the Draw overhaul.
2022-10-03 09:14:29 +09:00
Bill Currie
c028e15943 [vulkan] Add a couple of staging helper functions
I got tired of writing the same 13 or so lines of code over and over (it
actually put me off experimenting with Vulkan). Thus...

QFV_PacketCopyBuffer does the work of handling barriers and a (full
packet) copy from the staging buffer to a GPU buffer.

QFV_PacketCopyImage does a similar job, but for images. However, it
still needs a lot of work, but it does make getting a basic texture onto
the GPU much less of a hassle.

Both functions should make staging data much less error-prone.
2022-10-03 09:09:34 +09:00