havoc [Wed, 3 Jun 2020 02:26:30 +0000 (02:26 +0000)]
Fix gamedir command by removing the forced video subsystem shutdown, it was trying to load the loading screen without a running video subsystem and erroring out on the texturearray having mempool == NULL.
havoc [Mon, 1 Jun 2020 03:02:26 +0000 (03:02 +0000)]
Fix a bug with r_batch_debugdynamicvertexpath in R_DrawTextureSurfaceList_Sky where it was trying to use the surface->num_firstvertex rather than the batch info.
havoc [Sun, 31 May 2020 05:41:15 +0000 (05:41 +0000)]
Fix multiple bugs with r_viewscale in r_shadow_deferred and r_bloom - they were relying on vid.width/vid.height rather than r_fb.screentexturewidth/r_fb.screentextureheight.
Thanks to Cloudwalk for debugging this a fair bit already.
cloudwalk [Thu, 28 May 2020 13:53:30 +0000 (13:53 +0000)]
Implement experimental hook-like system, with working example.
This system allows you to call functions that may or may not exist at runtime
and compile-time. You create hook_t pointers and register them during
initialization, and point them to a function. If they're not registered,
no problem. This could potentially allow different subsystems to function
independently of each other, such as the client and server.
It's using a union to allow functions to have any return type they want.
However, for obvious reasons, functions cannot have any parameters they want
and must accept a pointer to the union type where the actual args are stored.
This is experimental and there may be bugs, but the current working example
should be stable.
cloudwalk [Wed, 27 May 2020 01:07:28 +0000 (01:07 +0000)]
Fix major regression preventing connect to any server using curl for custom CSQC
The command interpreters must be executed in sequence with clientfromserver
being the first, otherwise curl won't get a chance to run before the client
continues connecting. A few more commands were also missing from the
interpreter and were added.
havoc [Tue, 26 May 2020 08:34:12 +0000 (08:34 +0000)]
Added lightgrid texture based lighting in q3bsp maps by uploading it as a 3D texture, to make more accurate and continuous model lighting throughout a scene. Can be disabled via the mod_q3bsp_lightgrid_texture cvar.
The lightgrid texture based lighting can also be enabled on world surfaces if one desires (mod_q3bsp_lightgrid_world_surfaces cvar) which gives levels a dream-like quality that is globally consistent, can also be enabled for bsp models that are not the world (mod_q3bsp_lightgrid_bsp_surfaces cvar) which may be more useful for ammo pickup models that are bsp or similar.
This frobs the shader glsl crc so expect to update any modified combined*.glsl files as per usual with updates to the embedded shader code.
havoc [Mon, 25 May 2020 22:46:47 +0000 (22:46 +0000)]
With MATERIALFLAG_ALPHAGEN_VERTEX we should basically always use MATERIALFLAG_ALPHA | MATERIALFLAG_BLENDED | MATERIALFLAG_NOSHADOW - this should fix UI rendering issues with alpha being ignored on DrawQ_Pic et al.
Minor shuffling of flag order in lightning beam texture loading to be consistent with the other uses - no behavior changes.
cloudwalk [Mon, 25 May 2020 13:51:59 +0000 (13:51 +0000)]
Fix most Q3 & QL glow maps
From bones_was_here: "Very few glow maps work in unmodified Q3 maps as they do not use the _glow darkplaces convention, instead Q3 shaders specify the file name to use which is not currently supported.
Fortunately there is a naming convention started in id software's pak0 and continued in QL and most 3rd party maps. It uses these forms: foo_texture.blend.ext and bar_texture_blend.ext
It's not possible to fix 100% of glow maps without parsing Q3 shaders and using the specified file name, but this is a big improvement.
This also fixes a few glow maps in nexcompat, which are originally Q3 textures that were not renamed to _glow."
cloudwalk [Mon, 25 May 2020 12:51:08 +0000 (12:51 +0000)]
Fix visual regression where parts of the Xonotic menu lacked transparency.
Set ent->render.alpha to its old value of 0.999999f. This doesn't seem to break
anything else, or anything that was recently fixed. There's probably a better
fix, but this is simple and seems to work for now.
havoc [Mon, 25 May 2020 08:13:16 +0000 (08:13 +0000)]
Forcibly disable the alphatocoverage feature because we don't currently use MSAA antialiasing and it only works for that, resulting in broken rendering.
havoc [Mon, 25 May 2020 08:11:22 +0000 (08:11 +0000)]
Allow r_viewscale to be set to values higher than 1 for super-sample antialiasing, also integrate vid_samples into this calculation to restore old behavior somewhat (super-sampling is more expensive than multisampling, so this isn't a great solution yet, but it brings back the quality). Still need to implement a better SSAA filter for when the antialiasing is in effect.
havoc [Mon, 25 May 2020 08:10:04 +0000 (08:10 +0000)]
Add csqc_polygons_defaultmaterial_nocullface cvar which defaults to 1 in nexuiz and xonotic derived games, this restores the compatible behavior with older versions of the engine. It defaults to 0 in other games (and would be recommended to set to 0 in those games when they make a new release) as it seems like that would be the better default for efficiency (and matches FTEQW engine).
Fixed a bug in CL_MeshEntities_FinalizeRenderEntity where it skipped finalize when the entity has no surfaces, but since it is still included in the render entities list it was rendering garbage when unused.
Use the "$whiteimage" texture for CSQC/UI polygons (VM_CL_R_PolygonBegin) that specify texture "", to be compatible with older versions.
Clarify the name of a parameter on Mod_Mesh_GetTexture prototype to match the implementation as it was misleading otherwise.
havoc [Mon, 25 May 2020 04:18:02 +0000 (04:18 +0000)]
Reworked VM_CL_PolygonBegin/Vertex/End functions to do the commit to the mesh in PolygonEnd, this allows it to examine if alpha is used on vertices and request different variants of a material according to such discoveries.
Refactored CL_MeshEntities_AddToScene and CL_MeshEntities_Reset to be the more distinct stages of CL_MeshEntities_Scene_Clear (which is called in VM_CL_R_ClearScene), CL_MeshEntities_Scene_AddRenderEntity (which is called during VM_CL_R_AddEntities), and CL_MeshEntities_Scene_FinalizeRenderEntity (which is called during VM_CL_R_RenderScene) - this fixes issues with CSQC predraw functions adding polygons which were not subject to Finalize and thus not rendered.
Fixed Mod_LoadTextureFromQ3Shader handling of texture name "" to properly set basematerialflags, this fixes invisible polygons in some games such as Xonotic.
Refactored CL_Mesh_CSQC and CL_Mesh_Debug into CL_Mesh_Scene - not really a need for more than one mesh to overlay on the world.
cloudwalk [Sun, 24 May 2020 14:18:15 +0000 (14:18 +0000)]
Fix FS_Seek for compressed file from PK3
From Slava: "Currently FS_Seek works incorrectly with compressed files from PK3 but this issue isn't noticed because in most cases engine is using FS_LoadFile which reads file sequentially without seeking."
havoc [Sun, 24 May 2020 07:06:25 +0000 (07:06 +0000)]
Rework r_shadow_shadowmode to be more maintainable and understandable - it now caches the values of r_shadow_shadowmapping and r_shadow_deferred, and is now updated when those change, rather than just at startup, and changing those now also causes a recompile of world lights (which always had different bounds when shadowing was on/off, toggling shadows had weird behavior as a result, so this is a bugfix).
This fixes a massive fps drain with settings that disabled shadows entirely by disabling shadowmapping (where r_shadow_shadowmapping 0 and r_shadow_deferred 0 together caused it to reallocate the shadowmap texture every frame and do other bad stuff)
cloudwalk [Sat, 23 May 2020 22:22:30 +0000 (22:22 +0000)]
Fix Windows-specific use-after-free causing crash after disconnecting
This explicitly deregisters CSQC commands every time CSQC shuts down. This patch
also avoids Z_Malloc'ing the cmd names for each CSQC command and avoids forcing
a Cmd_AddCommand if the command exists.
CSQC was force-adding a command even if it already existed, and when it did,
it would pass a pointer from a mempool that would later get freed when
CSQC shuts down, and Windows' strcasecmp doesn't like dangling pointers.
The Z_Malloc wasn't much better because it could have caused a memory leak.
So the best solution was to only pass the pointer but make sure the commands
are freed when CSQC shuts down.
cloudwalk [Wed, 20 May 2020 15:22:06 +0000 (15:22 +0000)]
Make connections atomic. Disconnect before trying to connect.
Fixes an issue where a demo freezes in place if you try to connect while one is
running. This also has the side effect of eliminating a duplicate call to
CL_StopPlayback, which is called by both CL_EstablishConnection and
CL_Disconnect (which is itself called by NetConn_ConnectionEstablished).
cloudwalk [Tue, 19 May 2020 18:52:55 +0000 (18:52 +0000)]
Reset r_shadow_occlusion_buf on vid_restart. Fixes query buffer dangling pointer
Basically, when coronas appear when r_coronas_occlusionquery is 1, the engine
binds to a query buffer and stores a pointer to it in r_shadow_occlusion_buf.
Upon vid_restart, somewhere along the way, the buffer is cleared but the
original pointer is kept, resulting in a crash next time a corona appears.
cloudwalk [Mon, 18 May 2020 15:48:37 +0000 (15:48 +0000)]
Implement chromatic aberration, configurable with r_colorfringe cvar.
Do note that it is disabled by default and values higher than 0.025 will distort the image.
cloudwalk [Mon, 18 May 2020 14:26:20 +0000 (14:26 +0000)]
Fix invalid offset spam when r_showbboxes_client is > 0
This checks for server progs before touching viewmodelforclient as it's apparently not a client field.
cloudwalk [Mon, 18 May 2020 03:10:15 +0000 (03:10 +0000)]
Fix a few bugs detected by Cppcheck
(warning) Logical conjunction always evaluates to false: matchrule < 0 && matchrule > 5.
(style) Condition 'k<16' is always true
(style) Variable 'settings->bounceminimumintensity2' is reassigned a value before the old one has been used.
cloudwalk [Sun, 17 May 2020 20:53:49 +0000 (20:53 +0000)]
Use SDL_GameController instead of SDL_Joystick where possible
SDL_GameController provides mappings between axis and button indices and a
general layout that is similar to a XBox 360 controller. Since this layout is
common, these changes allow creating proper controller mappings for a large
variety of gamepad/OS combinations out of the box.
Change initially provided by EACFreddy. Fixed multiple crashes due to a stale
pointer. Also made a Con_Printf a DPrintf and removed ifdefs for SDL2 since
master doesn't support SDL1 anymore.
There's a strange stick drift problem. It might be my controller but
it'll have to be investigated further.