Commit graph

821 commits

Author SHA1 Message Date
Bill Currie
331f3320e2 [gatest] Rearrange the 2d PGA groups
Following the suggestions of Hamish Todd, group 0 forms the planar
quaternions (with the "complex number" in the first two components) and
transflections in group 1.
2023-06-08 22:46:02 +09:00
Bill Currie
0fbcd90e37 [gatest] Fix up layout issues for null vectors
e0 is created only if there are null vectors in the algebra, and the 3d
and 2d basis groups have been rearranged to compensate in the changed
ordering in the basis blade array.
2023-06-08 22:13:23 +09:00
Bill Currie
a40fee2513 [gatest] Calculate correct sign for duals
I was aware in the beginning that the signs were probably incorrect, but
I had left them as I wasn't sure how they worked.  Thanks to enki
(bivector community), I was pointed in the right direction for getting
the calculations right: the product of a basis blade with its dual
(x !x) must product the positive pseudo-scalar.
2023-06-08 13:02:13 +09:00
Bill Currie
2858870153 [gatest] Fix use of uninitialized multivector components
I guess I had forgotten that new_mv() does *NOT* initialize the
components. Things just happened to work (usually) because memory was
not getting recycled.
2023-06-08 13:00:32 +09:00
Bill Currie
68ca8c7016 [gatest] Switch to using e0 for the null vector
According to enki (bivector community) when there are more than one null
vector in a geometry, usually all vectors are null, and it was what to
do with multiple null vectors that caused me to balk at using e0 for the
null vector. However, using e0 for the null vector makes life much
easier, especially as that's what most of the literature does. There
are plenty of places, particularly in layout handling, that still need
adjustment for the change, but things seem to work (minus duals, but
they were broken in the first place, thus the discussion with enki).
2023-06-08 12:56:23 +09:00
Bill Currie
d0e2c0a9d9 [gatest] Allow specifying the algebra on the command line
Saves having to recompile for a different algebra. Right now, just
`-a p,m,z` is supported.
2023-05-29 15:14:59 +09:00
Bill Currie
65764a06c0 [gatest] Don't lex . as a single character
Lexing . as a single character makes it impossible to enter fractions.
Unfortunately, this means that . as dot product requires white space on
either side.
2023-05-29 15:13:27 +09:00
Bill Currie
6bd9aceb28 [ruamoko] Correct signatures of strtol and strtoul
I had forgotten the base parameter in the ruamoko definitions (verified
there in the C wrapper).
2023-05-29 15:12:20 +09:00
Bill Currie
681629a5d1 [gatest] Parse division and dual operations 2023-05-29 09:52:10 +09:00
Bill Currie
4e441d359a [gatest] Write a simple parser for playing with GA
Currently only PGA(3) is supported, but that's because the parser is
rather simple (recursive descent with a lame lexer), but it works well
enough for playing with geometric algebra without having to recompile
every time.
2023-05-27 12:47:33 +09:00
Bill Currie
582423a019 [ruamoko] Extend the string api
Wrap the strtod, strtof, strtol, strtoul functions, supporting the end
pointer as well (if not nil, the int offset of the end pointer relative
to the string start is returned).

Also, str_unmutable creates a return string from a mutable string
(copying it).
2023-05-27 12:47:33 +09:00
Bill Currie
a22c2224e0 [ruamoko] Fortify and extend the script api
Meaning some leaks have been plugged, and some useful functions added:
loading a file (avoids polluting progs memory), setting the single
character lexeme string, and getting the line number.
2023-05-27 12:47:33 +09:00
Bill Currie
6d5e8922a5 [qfcc] Add a handle type for engine resources
I never liked the various hacks I had come up with for representing
resource handles in Ruamoko. Structs with an int were awkward to test,
pointers and ints could be modified, etc etc. The new @handle keyword (@
used to keep handle free for use) works just like struct, union and
enum in syntax, but creates an opaque type suitable for a 32-bit handle.
The backing type is a function so v6 progs can use it without (all the
necessary opcodes exist) and no modifications were needed for
type-checking in binary expressions, but only assignment and comparisons
are supported, and (of course) nil. Tested using cbuf_t and QFile: seems
to work as desired.

I had considered 64-bit handles, but really, if more than 4G resource
objects are needed, I'm not sure QF can handle the game. However, that
limit is per resource manager, not total.
2023-05-25 10:41:28 +09:00
Bill Currie
db9a6a9a5c [ruamoko] Make cbuf functions take a cbuf param
A nil param refers to the default cbuf if it has been set by the engine,
otherwise it is invalid. This is the first step to fleshing out the cbuf
API.
2023-05-24 21:01:07 +09:00
Bill Currie
b9cff7aae0 [gatest] Implement and use multi-vector reverse
This gives the resultant point the correct sign.  Though the projective
divide would take care of the sign, this makes reading the point a
little less confusing (still need to sort out automatic blade reversals
for the likes of e31).
2023-05-24 18:25:47 +09:00
Bill Currie
42b0608e65 [qwaq] Get the console working for qwaq-x11
And other graphics versions too, of course. A lot of it feels rather
like a hack, but I think the entire canvas/console setup and console
related event handling may need a rethink (it's not horribly wrong, but
it doesn't feel right), particularly the initial sizing and binding for
toggling the console.
2023-05-24 12:44:16 +09:00
Bill Currie
7c9b6aa0cc [gatest] Use the metric when computing the dot product
As the dot product is a metric product, using the metric is vital to
getting the correct results. This fixes the calculation of the closest
point on a line to a point other than the origin (and a whole pile of
other issues, I imagine).
2023-05-22 13:03:35 +09:00
Bill Currie
d01fc27dd5 [gatest] Remove the workarounds for array lifetime
Now that arrays work well enough for this case, no point in having the
workarounds (other than they're actually faster, but I'd like to
optimize *that* sometime).
2023-05-21 22:20:38 +09:00
Bill Currie
008a64ee9b [gatest] Add multivector constructors to Algebra
This makes it much easier to create vectors of a specific grade or
grouping. It even found some mistakes in the multivector product
implementations.
2023-05-19 11:15:29 +09:00
Bill Currie
c1c77bd64a [gatest] Add basic geometric algebra test
This is for developing methods of implementing geometric algebra and
eventually playing with it visually.
2023-05-19 00:34:05 +09:00
Bill Currie
5f75616655 [ruamoko] Implement -describe for Set
Being able to use printf directly is nice :)
2023-05-17 21:09:00 +09:00
Bill Currie
451a98d391 [ruamoko] Avoid copying a block of memory to itself
Not a big deal, but valgrind didn't like it.
2023-03-28 13:23:14 +09:00
Bill Currie
7d4c1d79b1 [plist] Use reference counts for items
This makes it much easier to share items between property lists (eg,
targets and the main entity list in cl_light).
2023-03-13 11:26:13 +09:00
Bill Currie
8f87407133 [ruamoko] Add wrappers for the new plist functions
With both file and string versions (as per PL_GetPropertyList).
2023-03-12 14:35:17 +09:00
Bill Currie
9982eb629d [ruamoko] Plug another memory leak
Now running vkgen is leak-free (and, by extension, qwaq-cmd, it seems).

I'm really not sure why I used a dynamic array for that case.
2023-03-05 22:41:59 +09:00
Bill Currie
b84bf16cab [util] Add a function to reverse delete cbuf stacks
I'm not 100% sure this is the best fix for the issue, but the way the
cbuf interpreter stack works (especially in the console code) meant that
the stack was built in the order opposite to how it could be safely
deleted with the existing function. Yeah, more leaks :P
2023-03-05 18:31:30 +09:00
Bill Currie
340127fff2 [ruamoko] Plug yet more memory leaks
Some of them, especially in rua_obj, were quite legitimate and even a
problem for thread-safety (rua_cmd is currently not thread-safe, but it
needs a lock, which I don't feel like doing at this stage).
2023-03-05 18:31:30 +09:00
Bill Currie
3e30b7b9e2 [image] Allow color conversion caches to be cleaned up
More leaks, but only ruamoko takes advantage of it so far.
2023-03-05 18:31:30 +09:00
Bill Currie
3f9873a754 [console] Plug more memory leaks 2023-03-05 18:31:30 +09:00
Bill Currie
f9e442d323 [util] Make sys globals all thread-local
This was mainly for the shutdown functions, thus allowing Sys_Shutdown
(and Sys_RegisterShutdown) to be per-thread, but it seemed like a good
idea to make everything per-thread.
2023-03-05 18:31:30 +09:00
Bill Currie
be9e6893e5 [util] Free up hash links
Finally, hash links can be freed when the hash context is no longer
relevant. The context is created automatically when needed, and the
owner can delete the context when its done with the relevant hash
tables.
2023-03-04 02:07:31 +09:00
Bill Currie
44ad372adb [ruamoko] Clean up some memory leaks
So many sieves.
2023-03-04 00:50:27 +09:00
Bill Currie
8b8bc42038 [ruamoko] Own created property list objects
If the PLItem classes create a property list object, they own it. Plugs
more leaks.
2023-03-04 00:39:37 +09:00
Bill Currie
70aa970c32 [gamecode] Make modules responsible for freeing resources
It should have been this way all along, and it seems I thought they were
when I did rua_gui.c as it already freed its resource block, which would
have been a double free (oops). Fixes an invalid write when shutting
down progs in qwaq-cmd (relevant change not committed).
2023-03-03 20:26:00 +09:00
Bill Currie
2748f1c9f7 [ruamoko] Add support for PL_KeyAtIndex
I'd forgotten to wrap the function when I added it, but didn't need it
until now.
2023-02-14 12:45:04 +09:00
Bill Currie
35df90cb3f [ruamoko] Add qfot_basic_t to qfot_type_t
qfot_basic_t is necessary for getting at the width of basic value types
(int, uint, float, long, ulong, double) in order to distinguish between
scalars and vectors of those types.

I had forgotten this when doing the Ruamoko VM and qfcc changes.
2023-02-14 12:45:04 +09:00
Bill Currie
a561558748 [console] Switch to using a canvas for the console
While the console background is broken in that alpha doesn't work, it's
now rendered correctly in all renderers.
2023-01-22 03:45:50 +09:00
Bill Currie
68c7003991 [console] Separate loading and initialization
This will make it easy for client code to set up data needed by the
console before the console initializes. It already separates console
cvar setup and initialization, which has generally been a good thing.
2023-01-20 13:27:17 +09:00
Bill Currie
41d25df0d2 [ui] Attach text views to passage entities
Instead of creating new entities for the text views. This approximately
halves the number of entities required to display flowed text, but also
tests the ability to have an entity in multiple hierarchies (the goal of
the ECS component and system changes).
2022-12-14 22:38:37 +09:00
Bill Currie
b93ab95c47 [ruamoko] Add some builtins for passages and text
Just some basic implementation so I can test shaping of passage text.
2022-12-09 15:18:47 +09:00
Bill Currie
136bf882f6 [ui] Move font loading into new gui library
Font and text handling is very much part of user interface and at least
partially independent of rendering, but does fit it better with GUI than
genera UI (ie, both graphics and text mode), thus libQFgui as well as
libQFui are built in the ui directory.

The existing font related builtins have been moved into the ruamoko
client library.
2022-12-07 17:38:38 +09:00
Bill Currie
8fa6167a57 [vid] Add a function to set the palette and colormap
Mostly for qwaq as it uses the default VGA palette but I need to do some
testing with the quake palette.
2022-11-14 19:39:55 +09:00
Bill Currie
07f897122f [ruamoko] Fix several builtin declarations
Trying to build and run frikbot with ruamoko progs found a pile off
issues.
2022-11-12 14:39:18 +09:00
Bill Currie
e504079938 [qwaq] Disable console screen view set for now
The renderer currently does not have a view, and the qwaq console isn't
used right now anyway.
2022-11-01 10:18:47 +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
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
a1813868fc [qwaq] Copy only those bytes in the colormap tex
The fullbright count byte in a colormap is not in the generated colormap
texture data. Attempting to read it results in an angry valgrind.
2022-09-22 10:39:03 +09:00
Bill Currie
3147443617 [qwaq] Set the console's screen view
I had forgotten to test qwaq when removing console view from viddef_t.
2022-09-22 10:39:03 +09:00
Bill Currie
20ee47404f Merge branch 'master' into wip-twod 2022-09-22 10:06:00 +09:00
Bill Currie
125821fcdd [render] Add basic 2d line drawing
The software renderer uses Bresenham's line slice algorithm as presented
by Michael Abrash in his Graphics Programming Black Book Special Edition
with the serial numbers filed off (as such, more just so *I* can read
the code easily), along with the Chen-Sutherland line clipping
algorithm. The other renderers were more or less trivial in comparison.
2022-09-22 09:35:56 +09:00