Compare commits

...
132 Commits
Author SHA1 Message Date
Alug 3b07022379 remove spritecliphack shader and readd fickle fix
the shader aint working out that well so just do this for now
2024-06-22 20:43:27 +02:00
Alug a4fce0b3b1 add shader for shadows to also fix sprite shadows in pal render 2024-06-03 16:19:41 +02:00
Alug 79ad1f8d51 readd sprite shadows and give dropshadows their own cvar 2024-06-03 15:46:30 +02:00
Alug 73aef11554 make shadow hack less noticable lul 2024-06-03 15:24:59 +02:00
Alug 318916abc9 Merge branch 'Saturn-Next' into nomobjshadows 2024-06-03 15:24:54 +02:00
Alug 1ab7a2acf4 add toggle for beta intermission screen + smol cleanup 2024-06-03 15:13:46 +02:00
Alug f977af6a80 fix le dispoffset 2024-06-03 15:13:39 +02:00
indev cae40928ad Use Z_Calloc to allocate wadfile_t to avoid having uninitialized fields 2024-06-03 00:18:11 +03:00
Alug ee2ec01eb9 use shader to prevent sprite floor clipping
from durr lul
2024-06-02 22:16:09 +02:00
Alug 164a9d604a conflict moment 2024-06-02 22:15:58 +02:00
Alug 7696b115ae add maxinterpdist to shadows 2024-06-02 22:15:28 +02:00
Alug b8ecaf336c fix ogl shadows for the 500th time 2024-06-02 22:15:25 +02:00
Alug 1ea8ebf84c o 2024-06-02 22:15:23 +02:00
Alug 9f70fe5373 fix ogl whiteshadows 2024-06-02 22:15:20 +02:00
Alug 9695ede7c2 reenable shadow skewing in software 2024-06-02 22:15:17 +02:00
Alug a5cd72d5db smth smth shader 2024-06-02 22:15:14 +02:00
Alug f87e282981 readd shadowscale since some things need manual scale 2024-06-02 22:15:11 +02:00
Alug 4b15972543 make software shadows more opague 2024-06-02 22:15:09 +02:00
Alug d5753bb15a smol fix and dont colormap software shadows either 2024-06-02 22:15:06 +02:00
Alug a92e5b3f7b dont colourmap shadows
todo software renderer ugh
2024-06-02 22:14:56 +02:00
Alug 72d2357560 use shader to prevent sprite floor clipping
from durr lul
2024-06-02 22:14:53 +02:00
Alug d306b560b1 dont rotate shadows with sprite rotation off
theres prob a better way to get an interpolated floorz but this works
also adds a small offset to not let stuff clip into the ground
2024-06-02 22:14:42 +02:00
Alug 4d331d9c9f change shadowscale a little 2024-06-02 22:13:47 +02:00
indev 932f6d83f7 Allow all mobjs to have shadow 2024-06-02 22:13:45 +02:00
Alug d57783aa3a port neat render based shadows
what an absolute arsepain
shearing in software is disabled cause it is inverted for whatever reason
also if someone ever wants to reeimplement lua spawnshadows idk go ahead kek
2024-06-02 22:13:41 +02:00
Alug 1d79854d3b Merge branch 'Saturn-Next' into nomobjshadows 2024-06-02 22:13:30 +02:00
Alug bf75644144 make r_fps if else hell a bit more bearable to look at
lol lmao
2024-06-02 22:12:39 +02:00
Alug 38633a8516 stuffs 2024-06-01 17:03:39 +02:00
Alug 957159d485 forgor to remove that 2024-06-01 16:31:55 +02:00
Alug 8052eb1c3a fix papersprites in software (hopefully)
lul
2024-06-01 16:30:03 +02:00
Alug 37a394ebaa flexible array stuff for columnofs
hopefully this fixes some crashes or smth
2024-06-01 16:29:55 +02:00
Alug b01a2836ea cleanup some super old stuff that did nothing
lul
2024-06-01 16:29:40 +02:00
Alug dc03359f3a theres no value 3 oops
i shouldnt do stuff after waking up at 4 in the morning lol
2024-05-30 19:59:14 +02:00
indev 6269c7c827 Use tmp variable for searchWad since envstr doesn't get changed 2024-05-30 19:32:18 +03:00
indev 040ddb1f40 Revert "Revert "Don't traverse the entire HOME directory to find wads""
This reverts commit 443905ffb3.
2024-05-30 19:23:14 +03:00
Alug faa5dbd0e7 split sprite draw loops
so crap doesent constantly check for papersprites on all sprites
2024-05-28 23:53:28 +02:00
Alug 37d3e2ae1a scale sprite draw distance with mapobjscale 2024-05-28 23:52:13 +02:00
Alug 455bbe47c2 smth smth encore magic numbers idk 2024-05-28 22:55:43 +02:00
Alug 4847e4e3cb that should be there lul 2024-05-28 22:55:40 +02:00
Alug 67aa71170f when not using screentextures draw kart bg on intermission screen 2024-05-28 00:52:52 +02:00
Alug ddddc7a898 draw a black screen instead of "nothing" during wipes on disabled screentextures
should resolve the intense flashing that can occur
2024-05-28 00:52:48 +02:00
indev 7c17f3a93c Merge pull request #130 from GenericHeroGuy/lua-hudinterpolate-redux
Lua HUD interpolation
2024-05-25 19:09:02 +03:00
GenericHeroGuy 05a5651260 Finishing touches
Some cleanup, also interpolate drawfill size
(dunno why it wasn't before)
2024-05-25 17:05:08 +02:00
Alug 8774b14fdf move some cvars to be registerrerd latur in ogl 2024-05-25 14:52:58 +02:00
Alug 518ac3ca28 Turn of FBO downsampling when you turn off screen textures
fbo downsampling needs those and if theyre disabled youre essentially seeing nothing at all lol
2024-05-25 14:44:03 +02:00
Alug 157c95a785 super smol optimization to R_DrawRepeatMaskedColumn
only maths once not twice lul
2024-05-25 14:44:00 +02:00
GenericHeroGuy 142c01f516 Update docs for interpLatch 2024-05-25 14:09:20 +02:00
GenericHeroGuy a17a5387ff Rename interpString to interpLatch 2024-05-25 14:08:52 +02:00
Alug d794de3e83 Cull BSP behind a raised floor or lowered ceiling that covers the entire screen
https://git.do.srb2.org/KartKrew/RingRacers/-/commit/7b8a564f69688515319ccd425f2b88ffe8b7b120
2024-05-25 02:21:04 +02:00
Alug 837746c0a9 declare outside of lööp also add const in r_ 2024-05-25 02:14:20 +02:00
Alug 9f692c1f6a change names to be less basic 2024-05-23 23:28:54 +02:00
Alug 8de340edbe allow gamepad dpad to hold scroll shit in menu aaa
absolute arsepain cant wait to see this breaking kek
2024-05-23 23:28:47 +02:00
GenericHeroGuy 9cd1233c32 Dust this crap off a bit 2024-05-23 16:47:29 +02:00
GenericHeroGuy 3f6575e41f Merge branch 'Saturn-Next' into lua-hudinterpolate-redux 2024-05-23 15:44:46 +02:00
Alug f939b02fd3 Merge branch 'Saturn' into Saturn-Next 2024-05-21 21:01:11 +02:00
Alug 73d0154b6c encore flipcam support 2024-05-21 21:00:33 +02:00
Alug cda7475058 unhack the animated votescreen a little
also make it pause when the game is paused like it was intended originally
2024-05-20 18:42:03 +02:00
Alug 33a31d0ad8 this should be here aswell i suppose 2024-05-20 13:31:13 +02:00
Alug 8dafc2d3d9 Merge pull request #129 from Indev450/Saturn-Next
Saturn v6.2
2024-05-20 13:21:16 +02:00
Alug 5f36557a18 change version string stuff per define lul 2024-05-19 21:31:05 +02:00
Alug 9b4e64011b make this a scroll menu
tbh not gonna bother with moving stuff depending on renderer
2024-05-19 18:43:12 +02:00
Alug 3ca313c14d Merge pull request #125 from Indev450/fborender
Use FBO to allow downsampling in Opengl
2024-05-19 18:20:01 +02:00
Alug 6fcea2f98e RefreshOGLSDLSurface
to make it a little more clearer this is ogl only
2024-05-18 23:52:05 +02:00
Alug c605906408 some stuffs 2024-05-18 23:49:36 +02:00
Alug de6511abe0 dont compile with that with NOHW 2024-05-18 23:40:28 +02:00
Alug c966b5defb forgor 2024-05-18 23:38:04 +02:00
Alug 3c8c273e51 add ogl version check + grey out in menu + turn it off when not avilible 2024-05-18 23:34:27 +02:00
Alug eaeb2575f7 add stuff to experimental menu 2024-05-18 23:22:30 +02:00
Alug 978cc57889 Add NOSCREENFBO compiler flag to be able to build without fbo support 2024-05-18 22:57:25 +02:00
Alug 6db73bfd63 Merge branch 'Saturn-Next' into fborender 2024-05-18 22:33:41 +02:00
Alug af5c3e4201 revert this thing 2024-05-15 17:56:58 +02:00
Alug 39e6668e20 change version 2024-05-15 17:51:11 +02:00
Alug 1ab63613a9 forgor this crap 2024-05-15 16:54:27 +02:00
Alug 57e72db1f8 support gcc14 ig 2024-05-15 16:46:59 +02:00
Alug d1d00d7ec6 shut up compiler 2024-05-05 22:00:22 +02:00
Alug 169e7cd462 Render precip through blockmap instead of during BSP
from RR
2024-05-05 21:54:00 +02:00
Alug e19f6f6656 fix some interpolation issues
minus P_spec change since that aint netsafe
2024-05-05 20:52:06 +02:00
Alug 13249f7ad4 fix potential crash in ogl vissprite sorting 2024-05-05 20:50:36 +02:00
Alug 22166ceccb fix precip overflow 2024-05-05 20:50:32 +02:00
Alug 75ed11a8b6 simplify SOFTLIGHT alot
also should make sure it gets applied everywhere lul
2024-04-29 10:12:58 +02:00
Alug 641cd6b8db use bigfloat for driftgauge offset too 2024-04-27 20:32:52 +02:00
Alug 62fa60e399 fix rare precip crash 2024-04-27 20:03:38 +02:00
Alug 17a6c4191d Merge pull request #128 from Indev450/it-cv-bigfloat
Add IT_CV_BIGFLOAT to use bigger increment for some CV_FLOAT cvars (a…
2024-04-27 20:01:57 +02:00
Alug 3acdcb09f1 inline those 2024-04-24 11:02:25 +02:00
GenericHeroGuy 1abf6a4ce1 Add interpolation docs to LUASTUFF 2024-04-23 21:24:47 +02:00
Alug 836890968c Revert "Merge pull request #121 from Indev450/texload"
This reverts commit b6a5c5b720, reversing
changes made to bcf2b3bab2.
2024-04-23 09:06:51 +02:00
Alug 7110de4b5b Merge branch 'Saturn' into Saturn-Next 2024-04-22 05:25:52 +02:00
Alug b4dfebac58 fix some visual issues with fofs 2024-04-22 05:25:46 +02:00
Alug 38d5ee5ae7 a 2024-04-20 22:54:03 +02:00
Alug d0c50006bc some stuff from ceepeepeecheck 2024-04-20 22:54:00 +02:00
indev 2147951a16 Add IT_CV_BIGFLOAT to use bigger increment for some CV_FLOAT cvars (added only to fov atm) 2024-04-20 11:41:17 +03:00
indev ea0cc41d04 For MIN/MAX value of cvar, convert it to float before saving for CV_FLOAT variables 2024-04-20 10:30:34 +03:00
Alug b6a5c5b720 Merge pull request #121 from Indev450/texload
Do not reload every texture when adding a wad
2024-04-20 01:33:50 +02:00
Alug bcf2b3bab2 disable palette rendering if screentextures aint enabled 2024-04-19 06:23:12 +02:00
Alug a238b19c75 z 2024-04-19 06:22:48 +02:00
Alug 9317ccd0be more things
-Fix a division by zero in BCZ2 Metal Sonic's routine
-Fix a bug where adding the same mod multiple times counted towards the mod limit
and other thigns
2024-04-19 06:22:44 +02:00
Alug 463dccab8b some smol fixes 2024-04-19 06:22:22 +02:00
Alug 2ccf91fbfc Make FixedRem less laggy by just using the modulo operator. 2024-04-19 06:22:20 +02:00
indev 36e06e5d6b Fix possible buffer overflow in 'va' function 2024-04-13 21:55:22 +03:00
Alug 45d73a2ad6 add qs22j to cmakelist 2024-04-13 18:40:00 +02:00
GenericHeroGuy 995777c676 Exclude string mode flags from olditem search 2024-04-12 22:36:23 +02:00
Alug dacfe376e1 smth smth paranthesis 2024-04-12 21:55:53 +02:00
GenericHeroGuy 60e42472e3 Do string coordinate calcs on all functions (and fix) 2024-04-12 21:00:54 +02:00
Alug c92ef4d757 fix software crash
Zzz...
2024-04-12 20:41:25 +02:00
indev 7cd6a031cd Fix compilation warning regarding calloc and sizeof 2024-04-11 19:12:14 +03:00
indev af265d017d Fix potential negative array index in V_ThinStringWidth 2024-04-11 18:55:55 +03:00
Alug 9e104a8632 ok dont use this at all then 2024-04-10 18:18:47 +02:00
Alug 4a1523da57 Zzz... 2024-04-10 18:15:29 +02:00
Alug 6a3987c8f7 fix ifdefs 2024-04-10 17:57:55 +02:00
Alug 1df6c4d4da move this to first init too 2024-04-10 17:47:37 +02:00
Alug 3cab29085a Merge branch 'Saturn-Next' into fborender 2024-04-10 17:46:40 +02:00
Alug 1391e556d6 that wasnt the onchange im sleepy 2024-04-10 17:40:43 +02:00
Alug 94340e6634 forgor to remove those Zzz... 2024-04-10 17:32:13 +02:00
Alug 64f10c36fa should throw that into onchange oops 2024-04-10 17:29:16 +02:00
Alug 955f73d9e8 throw stuff into own function, also check on game start 2024-04-10 17:24:46 +02:00
Alug 40c356395a simplify this crap 2024-04-10 07:02:18 +02:00
indev aac74cf93a Don't call menu drawer in wipes on dedicated servers 2024-04-06 01:31:43 +03:00
GenericHeroGuy 18e0485f39 Make this less insufferable
* Zero is now a valid tag for v.interpolate
* Reset lerp coordinates when v.interpString is called again
* Leaving string mode enabled on exit no longer breaks other scripts
* Fix fadeScreen having an uninitialized ID
2024-04-04 23:39:23 +02:00
GenericHeroGuy aeb5ae994e Subpixel interpolation for strings and drawfill 2024-04-04 00:27:47 +02:00
GenericHeroGuy b2f9a29eb0 Lua HUD interpolation 2024-04-02 21:00:23 +02:00
GenericHeroGuy 5f69bfcf22 Split game drawlist per displayplayer 2024-04-02 03:22:24 +02:00
GenericHeroGuy 9442a463d4 Shrink drawlists, take 2
Approximately 2/3rds smaller
2024-04-01 23:24:09 +02:00
Alug d7a1cc6702 Read only header bytes when creating textures list 2024-03-27 21:31:56 +01:00
Alug a779191feb beter 2024-03-27 18:45:59 +01:00
Alug 23cc0dfc3a add some comments cause i WILL forger what this crap even does 2024-03-27 18:44:32 +01:00
Alug c7a258f32f clean up 2024-03-27 18:34:58 +01:00
Alug a28f025d40 Stuff from displaycrap branch to detect downsampling automatically 2024-03-27 18:33:29 +01:00
Alug 91a3b288ef conflict moment 2024-03-27 18:08:09 +01:00
Alug 200d971d35 Toggle to render to screenFBO
fixes downsampling from higher resolutions
TODO: make this activate automatically if game detects it runs at higher res than desktop res
2024-03-27 18:05:48 +01:00
indev 54ee3f2961 R_LoadTexturesPwad: don't do anything wad has no textures 2024-03-26 20:40:11 +03:00
Alug c3a71b60b0 Do not reload every texture when adding a wad
https://git.do.srb2.org/STJr/SRB2/-/merge_requests/1725?commit_id=37add34b9c729b21e624e22d64159073c9258e25
2024-03-26 14:12:05 +01:00
Alug 205bfc0262 Split R_LoadTextures 2024-03-26 14:11:49 +01:00
69 changed files with 2215 additions and 796 deletions

No files matched your search

+64
View File
@@ -52,6 +52,70 @@ Returns the displayplayer's HUD color.
Returns true if colorization is enabled, false otherwise.
## v.interpolate(true)
Enables HUD interpolation. Each call to a drawing function will have its coordinates interpolated
by assigning an unique ID to every call.
For example, three successive calls to `v.draw` will each have their own ID and interpolation offsets.
Pass `true` to enable interpolation, `false` to disable.
Alternatively, pass a number to enable interpolation with the specified tag.
Tags allow HUD items drawn by the same call to a drawing function to be differentiated.
Valid tags range from 0-255.
For example, when iterating players, use a unique tag for each player to avoid artifacting:
```lua
for p in players.iterate do
-- enable interpolation, using player numbers as the tag
-- every draw will have different interp offsets per player
v.interpolate(#p)
-- doesn't matter for unconditional draws like this one...
v.draw(...)
-- but it does matter if there's a condition!
-- without tags, this patch would warp between players
-- whenever their `someVar` changes
if p.someVar then v.draw(...) end
end
-- don't want interpolation anymore? then disable it
v.interpolate(false)
```
NOTE: The default tag for `true` is 0.
## v.interpLatch(true)
Enables interpolation offset latching. The next call to a drawing function will have its lerp offsets
saved and reused for all following draw calls. Disable with `false` when done.
Interpolation cannot easily "snap" between two points; latching can help overcome this by manually
setting the lerp offsets.
```lua
v.interpolate(true)
-- X coordinate for the HUD item
-- every so often, this will wrap around to zero
local x = (leveltime*4) % 256
-- draw an interpolated patch, but... when X rolls back to zero,
-- the patch will slide all the way across the screen!
v.draw(x, 100, ...)
-- this is where interpLatch comes into play
-- enable latching, then draw an invisible patch,
-- moving at the same speed as the visible patch
-- the exact coordinates don't matter, it just has to move at the right speed
v.interpLatch(true)
v.draw(leveltime*4, 0, v.cachePatch("K_TRNULL"))
-- now we can draw the patch again, and when X becomes zero,
-- it'll snap right back without sliding across the screen
v.draw(x, 150, ...)
-- don't forget to turn off latching!
v.interpLatch(false)
```
When using a custom string drawer, enable this mode to avoid interpolation artifacting when the string changes.
## mobj.spritexscale, mobj.spriteyscale, mobj.spritexoffset, mobj.spriteyoffset, mobj.rollangle, mobj.sloperoll, mobj.rollmodel fields
Same fields as in SRB2 2.2
+8
View File
@@ -216,6 +216,8 @@ set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
"Enable hardware rendering through OpenGL.")
set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
"Use statically linked OpenGL. NOT RECOMMENDED.")
set(SRB2_CONFIG_USE_FBO_OGL ON CACHE BOOL
"Enable OpenGL FBO Downsampling support.")
### use internal libraries?
if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only
@@ -510,6 +512,12 @@ if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
endif()
endif()
if(${SRB2_CONFIG_HWRENDER})
if(${SRB2_CONFIG_USE_FBO_OGL})
set(SRB2_USE_FBO_OGL ON)
add_definitions(-DUSE_FBO_OGL)
endif()
endif()
# Targets
+12
View File
@@ -199,6 +199,12 @@ ifndef NOOPENMPT
HAVE_OPENMPT=1
endif
ifndef NOHW
ifndef NOSCREENFBO
USE_FBO_OGL=1
endif
endif
ifdef MINGW
include win32/Makefile.cfg
endif #ifdef MINGW
@@ -372,6 +378,12 @@ ifdef STATIC
LIBS:=-static $(LIBS)
endif
ifndef NOHW
ifdef USE_FBO_OGL
OPTS+=-DUSE_FBO_OGL
endif
endif
ifdef HAVE_MINIUPNPC
ifdef NONET
HAVE_MINIUPNPC=''
+10 -1
View File
@@ -12,6 +12,7 @@
# to avoid a false positive with the version detection...
SUPPORTED_GCC_VERSIONS:=\
141 14\
132 131 130 13\
123 122 121 120 12\
114 113 112 111 110 11\
@@ -23,7 +24,7 @@ SUPPORTED_GCC_VERSIONS:=\
55 54 53 52 51 50\
49 48 47 46 45 44 43 42 41 40
LATEST_GCC_VERSION=13.2
LATEST_GCC_VERSION=14.1
# gcc or g++
ifdef PREFIX
@@ -77,6 +78,14 @@ ifeq (,$(filter GCC%,$(.VARIABLES)))
endif
endif
ifdef GCC141
GCC141=1
endif
ifdef GCC14
GCC14=1
endif
ifdef GCC132
GCC131=1
endif
+1 -1
View File
@@ -71,7 +71,7 @@ apng_create_info_struct (png_structp pngp)
{
apng_infop ainfop;
(void)pngp;
if (( ainfop = calloc(sizeof (apng_info),1) ))
if (( ainfop = calloc(1, sizeof (apng_info)) ))
{
apng_set_write_fn(pngp, ainfop, 0, 0, 0, 0, 0);
apng_set_set_acTL_fn(pngp, ainfop, 0);
+6 -1
View File
@@ -2132,7 +2132,12 @@ void CV_SaveVariables(FILE *f)
// Silly hack for Min/Max vars
if (!strcmp(cvar->string, "MAX") || !strcmp(cvar->string, "MIN"))
sprintf(stringtowrite, "%d", cvar->value);
{
if (cvar->flags & CV_FLOAT)
sprintf(stringtowrite, "%f", FixedToFloat(cvar->value));
else
sprintf(stringtowrite, "%d", cvar->value);
}
else
strcpy(stringtowrite, cvar->string);
+39
View File
@@ -617,6 +617,7 @@ static void D_Display(void)
// =========================================================================
tic_t rendergametic;
static int menuInputDelayTimer = 0;
void D_SRB2Loop(void)
{
@@ -779,6 +780,44 @@ void D_SRB2Loop(void)
}
#endif
// this is absolutely awful and i hate it lmao
if (menuactive && (DPADUPSCROLL || DPADDOWNSCROLL || DPADLEFTSCROLL || DPADRIGHTSCROLL))
{
event_t myev;
myev.type = ev_keydown;
if (renderisnewtic)
{
menuInputDelayTimer++;
if (menuInputDelayTimer >= 19) // TICRATE * ( (k+2) (1 - [wz + h + j - q]^2 - [(gk + 2g + k + 1)(h + j) + h - z]^2 - [16(k + 1)^3(k + 2)(n + 1)^2 + 1 - f^2]^2 calculated by my butt
{
if (DPADUPSCROLL)
{
myev.data1 = KEY_UPARROW;
M_Responder(&myev);
}
else if (DPADDOWNSCROLL)
{
myev.data1 = KEY_DOWNARROW;
M_Responder(&myev);
}
else if (DPADLEFTSCROLL)
{
myev.data1 = KEY_LEFTARROW;
M_Responder(&myev);
}
else if (DPADRIGHTSCROLL)
{
myev.data1 = KEY_RIGHTARROW;
M_Responder(&myev);
}
}
}
}
else
menuInputDelayTimer = 0;
// Fully completed frame made.
finishprecise = I_GetPreciseTime();
if (!singletics)
+6
View File
@@ -1445,6 +1445,12 @@ void Command_Ping_f(void)
pingv[pingc].ms = ms;
pingc++;
}
else
{
pingv[pingc].num = 0;
pingv[pingc].f = 0;
pingv[pingc].ms = 0;
}
}
if (f_width < 10) f_width = 1;
+5 -5
View File
@@ -577,6 +577,8 @@ static CV_PossibleValue_t skinselectgridsort_t[] ={
};
consvar_t cv_skinselectgridsort ={ "skinselectgridsort", "Real name", CV_SAVE|CV_CALL|CV_NOINIT, skinselectgridsort_t, sortSkinGrid, 0, NULL, NULL, 0, 0, NULL };
consvar_t cv_betainterscreen = {"betaintermissionscreen", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
INT16 gametype = GT_RACE; // SRB2kart
boolean forceresetplayers = false;
boolean deferencoremode = false;
@@ -822,6 +824,8 @@ void D_RegisterServerCommands(void)
CV_RegisterVar(&cv_netdemosyncquality);
CV_RegisterVar(&cv_maxdemosize);
CV_RegisterVar(&cv_keyboardlayout);
CV_RegisterVar(&cv_betainterscreen);
}
// =========================================================================
@@ -2659,13 +2663,9 @@ void D_ModifyClientVote(SINT8 voted, UINT8 splitplayer)
{
char buf[2];
char *p = buf;
UINT8 player = consoleplayer;
if (splitplayer > 0)
player = displayplayers[splitplayer];
WRITESINT8(p, voted);
WRITEUINT8(p, player);
WRITEUINT8(p, splitplayer);
SendNetXCmd(XD_MODIFYVOTE, &buf, 2);
}
+2
View File
@@ -205,6 +205,8 @@ extern consvar_t cv_showtrackaddon;
extern consvar_t cv_showspecstuff;
extern consvar_t cv_betainterscreen;
typedef enum
{
SKINMENUTYPE_SCROLL = 0,
+6 -2
View File
@@ -334,7 +334,7 @@ static void readPlayer(MYFILE *f, INT32 num)
// It works down here, though.
{
INT32 numline = 0;
for (i = 0; i < MAXLINELEN-1; i++)
for (i = 0; (size_t)i < sizeof(description[num].notes)-1; i++)
{
if (numline < 20 && description[num].notes[i] == '\n')
numline++;
@@ -8940,7 +8940,11 @@ static char *lua_enumlib_sprintf_upper(char **buf, int* size, const char *format
if (length > *size)
{
void *ptr = realloc(*buf, length+1);
if (!ptr) return NULL;
if (!ptr)
{
va_end(va);
return NULL;
}
*buf = ptr;
*size = length+1;
+7 -2
View File
@@ -127,8 +127,13 @@ extern char logfilename[1024];
#else
#define VERSION 1 // Game version
#define SUBVERSION 6 // more precise version number
#define VERSIONSTRING "Saturn v6.1 "
#define VERSIONSTRINGW L"Saturn v6.1"
#ifndef USE_FBO_OGL
#define VERSIONSTRING "Saturn v6.2 "
#define VERSIONSTRINGW L"Saturn v6.2"
#else
#define VERSIONSTRING "Saturn v6.2 - FBO "
#define VERSIONSTRINGW L"Saturn v6.2 - FBO"
#endif
// Hey! If you change this, add 1 to the MODVERSION below! Otherwise we can't force updates!
// And change CMakeLists.txt (not src/, but in root), for CMake users!
// AND appveyor.yml, for the build bots!
+2 -1
View File
@@ -349,7 +349,8 @@ typedef enum
postimg_motion,
postimg_flip,
postimg_heat,
postimg_mirror
postimg_mirror,
postimg_mirrorflip
} postimg_t;
typedef UINT32 lumpnum_t; // 16 : 16 unsigned long (wad num: lump num)
+7 -2
View File
@@ -2117,6 +2117,8 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive)
{
camerap = &camera[viewnum-1];
P_ResetCamera(&players[(*displayplayerp)], camerap);
R_ResetViewInterpolation(viewnum);
}
if (viewnum > splits)
@@ -6221,7 +6223,10 @@ void G_ReadMetalTic(mobj_t *metal)
// Read changes from the tic
if (ziptic & GZT_XYZ)
{
P_MoveOrigin(metal, READFIXED(metal_p), READFIXED(metal_p), READFIXED(metal_p));
oldmetal.x = READFIXED(metal_p);
oldmetal.y = READFIXED(metal_p);
oldmetal.z = READFIXED(metal_p);
P_MoveOrigin(metal, oldmetal.x, oldmetal.y, oldmetal.z);
oldmetal.x = metal->x;
oldmetal.y = metal->y;
oldmetal.z = metal->z;
@@ -8374,7 +8379,7 @@ void G_SaveDemo(void)
size_t i, strindex = 0;
boolean dash = true;
for (i = 0; demo.titlename[i] && i < 127; i++)
for (i = 0; i < 127 && demo.titlename[i]; i++)
{
if ((demo.titlename[i] >= 'a' && demo.titlename[i] <= 'z') ||
(demo.titlename[i] >= '0' && demo.titlename[i] <= '9'))
+5 -3
View File
@@ -26,6 +26,7 @@
#include "../z_zone.h"
#include "../v_video.h"
#include "../r_draw.h"
#include "../r_main.h"
#include "../r_patch.h" // patch rotation
INT32 patchformat = GL_TEXFMT_AP_88; // use alpha for holes
@@ -344,7 +345,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, boolean noe
#ifdef GLENCORE
if (encoremap && !noencore)
grtex->mipmap.colormap += (256*32);
grtex->mipmap.colormap += COLORMAP_REMAPOFFSET;
#endif
blockwidth = texture->width;
@@ -647,7 +648,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap)
#ifdef GLENCORE
if (!noencoremap && encoremap)
grmip->colormap += (256*32);
grmip->colormap += COLORMAP_REMAPOFFSET;
#endif
if (!grmip->downloaded && !grmip->data)
@@ -729,7 +730,8 @@ void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap)
{
GLMipmap_t *grmip, *newmip;
if (colormap == colormaps || colormap == NULL)
// Blatant hack for encore colormapping aside...
if (colormap == colormaps || colormap == NULL || colormap == (const UINT8*)(COLORMAP_REMAPOFFSET))
{
// Load the default (green) color in doom cache (temporary?) AND hardware cache
HWR_GetPatch(gpatch);
+5
View File
@@ -153,6 +153,7 @@ typedef struct
FLOAT centerx, centery;
#ifdef USE_FTRANSFORM_MIRROR
boolean mirror; // SRB2Kart: Encore Mode
boolean mirrorflip; // Encore Mode with Flipcam
#endif
boolean shearing; // 14042019
angle_t viewaiming; // 17052019
@@ -172,6 +173,7 @@ enum
{
SHADER_NONE = -1,
SHADER_FLOOR = 0,
SHADER_SHADOW,
SHADER_WALL,
SHADER_MODEL,
SHADER_SPRITE,
@@ -287,6 +289,9 @@ typedef struct FSurfaceInfo FSurfaceInfo;
enum hwdsetspecialstate
{
#ifdef USE_FBO_OGL
HWD_SET_FRAMEBUFFER,
#endif
HWD_SET_SHADERS,
HWD_SET_TEXTUREFILTERMODE,
-2
View File
@@ -30,11 +30,9 @@ typedef struct gr_vissprite_s
float gz, gzt;
float tz, ty;
float scale;
//lumpnum_t patchlumpnum;
float spritexscale, spriteyscale;
float spritexoffset, spriteyoffset;
UINT32 renderflags;
UINT8 rotateflags;
GLPatch_t *gpatch;
boolean flip;
UINT8 translucency; //alpha level 0-255
+283 -76
View File
@@ -46,6 +46,7 @@
#include "../i_system.h"
#include "../m_cheat.h"
#include "../m_argv.h" // parm functions for msaa
#include "../r_things.h" // R_GetShadowZ
#include "../p_slopes.h"
#include <stdlib.h> // qsort
@@ -69,6 +70,9 @@ static boolean gr_palette_rendering_state = false;
// Commands and console variables
// ==========================================================================
#ifdef USE_FBO_OGL
static void CV_grframebuffer_OnChange(void);
#endif
static void CV_filtermode_ONChange(void);
static void CV_anisotropic_ONChange(void);
static void CV_screentextures_ONChange(void);
@@ -96,6 +100,10 @@ consvar_t cv_grsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL,
consvar_t cv_grbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
#ifdef USE_FBO_OGL
consvar_t cv_grframebuffer = {"gr_framebuffer", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, CV_grframebuffer_OnChange, 0, NULL, NULL, 0, 0, NULL};
#endif
consvar_t cv_grfofcut = {"gr_fofcut", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_fofzfightfix = {"fofzfightfix", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -177,6 +185,13 @@ static void CV_anisotropic_ONChange(void)
static void CV_screentextures_ONChange(void)
{
ONLY_IF_GL_LOADED
if (cv_grscreentextures.value != 2)
{
#ifdef USE_FBO_OGL
CV_Set(&cv_grframebuffer, "Off");
#endif
CV_Set(&cv_grpaletterendering, "Off");
}
HWD.pfnSetSpecialState(HWD_SET_SCREEN_TEXTURES, cv_grscreentextures.value);
}
@@ -208,6 +223,16 @@ static void CV_grpalettedepth_OnChange(void)
HWR_SetPalette(pLocalPalette);
}
#ifdef USE_FBO_OGL
static void CV_grframebuffer_OnChange(void)
{
ONLY_IF_GL_LOADED
HWD.pfnSetSpecialState(HWD_SET_FRAMEBUFFER, cv_grframebuffer.value);
I_DownSample();
RefreshOGLSDLSurface();
}
#endif
//
// Sets the shader state.
//
@@ -263,6 +288,8 @@ ps_metric_t ps_hw_numcolors = {0};
ps_metric_t ps_hw_batchsorttime = {0};
ps_metric_t ps_hw_batchdrawtime = {0};
static void HWR_AddPrecipitationSprites(void);
// ==========================================================================
// View position
// ==========================================================================
@@ -494,6 +521,8 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
poly_color.s.blue = (UINT8)blue;
}
light_level = SOFTLIGHT(light_level);
// Clamp the light level, since it can sometimes go out of the 0-255 range from animations
light_level = min(max(light_level, cv_secbright.value), 255);
@@ -1109,7 +1138,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
{
if (HWR_ShouldUsePaletteRendering())
{
lightnum = SOFTLIGHT(pfloor->master->frontsector->lightlevel);
lightnum = pfloor->master->frontsector->lightlevel;
colormap = pfloor->master->frontsector->extra_colormap;
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y);
}else{
@@ -1121,7 +1150,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
{
if (HWR_ShouldUsePaletteRendering())
{
lightnum = SOFTLIGHT(*list[i].lightlevel);
lightnum = *list[i].lightlevel;
colormap = list[i].extra_colormap;
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y);
}else{
@@ -1496,7 +1525,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (HWR_ShouldUsePaletteRendering())
{
lightnum = SOFTLIGHT(gr_frontsector->lightlevel);
lightnum = gr_frontsector->lightlevel;
colormap = gr_frontsector->extra_colormap;
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
}
@@ -2227,7 +2256,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (HWR_ShouldUsePaletteRendering())
{
lightnum = SOFTLIGHT(rover->master->frontsector->lightlevel);
lightnum = rover->master->frontsector->lightlevel;
colormap = rover->master->frontsector->extra_colormap;
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
}else{
@@ -2235,7 +2264,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
colormap = rover->master->frontsector->extra_colormap;
}
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(SOFTLIGHT(rover->master->frontsector->lightlevel), rover->master->frontsector->extra_colormap);
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap);
if (gr_frontsector->numlights)
HWR_SplitWall(gr_frontsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0);
@@ -2366,7 +2395,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (HWR_ShouldUsePaletteRendering())
{
lightnum = SOFTLIGHT(rover->master->frontsector->lightlevel);
lightnum = rover->master->frontsector->lightlevel;
colormap = rover->master->frontsector->extra_colormap;
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
}else{
@@ -2374,7 +2403,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
colormap = rover->master->frontsector->extra_colormap;
}
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(SOFTLIGHT(rover->master->frontsector->lightlevel), rover->master->frontsector->extra_colormap);
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap);
if (gr_backsector->numlights)
HWR_SplitWall(gr_backsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0);
@@ -3051,13 +3080,13 @@ void HWR_AddPolyObjectPlanes(void)
FSurfaceInfo Surf;
FBITFIELD blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], false, polyobjsector->floorheight,
SOFTLIGHT(polyobjsector->lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL);
polyobjsector->lightlevel, Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL);
}
else
{
HWR_GetFlat(levelflats[polyobjsector->floorpic].lumpnum, R_NoEncore(polyobjsector, false));
HWR_RenderPolyObjectPlane(po_ptrs[i], false, polyobjsector->floorheight, PF_Occlude,
SOFTLIGHT(polyobjsector->lightlevel), levelflats[polyobjsector->floorpic].lumpnum,
polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum,
polyobjsector, 255, NULL);
}
}
@@ -3073,13 +3102,13 @@ void HWR_AddPolyObjectPlanes(void)
memset(&Surf, 0x00, sizeof(Surf));
blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], true, polyobjsector->ceilingheight,
SOFTLIGHT(polyobjsector->lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL);
polyobjsector->lightlevel, Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL);
}
else
{
HWR_GetFlat(levelflats[polyobjsector->ceilingpic].lumpnum, R_NoEncore(polyobjsector, true));
HWR_RenderPolyObjectPlane(po_ptrs[i], true, polyobjsector->ceilingheight, PF_Occlude,
SOFTLIGHT(polyobjsector->lightlevel), levelflats[polyobjsector->ceilingpic].lumpnum,
polyobjsector->lightlevel, levelflats[polyobjsector->ceilingpic].lumpnum,
polyobjsector, 255, NULL);
}
}
@@ -3221,12 +3250,12 @@ static void HWR_Subsector(size_t num)
light = R_GetPlaneLight(gr_frontsector, locFloorHeight, false);
if (gr_frontsector->floorlightsec == -1)
floorlightlevel = SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel);
floorlightlevel = *gr_frontsector->lightlist[light].lightlevel;
floorcolormap = gr_frontsector->lightlist[light].extra_colormap;
light = R_GetPlaneLight(gr_frontsector, locCeilingHeight, false);
if (gr_frontsector->ceilinglightsec == -1)
ceilinglightlevel = SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel);
ceilinglightlevel = *gr_frontsector->lightlist[light].lightlevel;
ceilingcolormap = gr_frontsector->lightlist[light].extra_colormap;
}
@@ -3294,7 +3323,7 @@ static void HWR_Subsector(size_t num)
centerHeight = P_GetFFloorBottomZAt(rover, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y);
if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight &&
((viewz < bottomCullHeight && (rover->flags & FF_BOTHPLANES || !(rover->flags & FF_INVERTPLANES))) ||
((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) ||
(viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))))
{
if (rover->flags & FF_FOG)
@@ -3303,13 +3332,13 @@ static void HWR_Subsector(size_t num)
light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < bottomCullHeight ? true : false);
alpha = HWR_FogBlockAlpha(SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), rover->master->frontsector->extra_colormap);
alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap);
HWR_AddTransparentFloor(0,
&extrasubsectors[num],
false,
*rover->bottomheight,
SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel),
*gr_frontsector->lightlist[light].lightlevel,
alpha, rover->master->frontsector, PF_Fog|PF_NoTexture,
true, rover->master->frontsector->extra_colormap);
}
@@ -3320,7 +3349,7 @@ static void HWR_Subsector(size_t num)
&extrasubsectors[num],
false,
*rover->bottomheight,
SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel),
*gr_frontsector->lightlist[light].lightlevel,
max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent,
false, gr_frontsector->lightlist[light].extra_colormap);
}
@@ -3328,7 +3357,7 @@ static void HWR_Subsector(size_t num)
{
HWR_GetFlat(levelflats[*rover->bottompic].lumpnum, R_NoEncore(gr_frontsector, false));
light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < bottomCullHeight ? true : false);
HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), levelflats[*rover->bottompic].lumpnum,
HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum,
rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap);
}
}
@@ -3338,7 +3367,7 @@ static void HWR_Subsector(size_t num)
if (centerHeight >= locFloorHeight &&
centerHeight <= locCeilingHeight &&
((viewz > topCullHeight && (rover->flags & FF_BOTHPLANES || !(rover->flags & FF_INVERTPLANES))) ||
((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) ||
(viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))))
{
if (rover->flags & FF_FOG)
@@ -3347,13 +3376,13 @@ static void HWR_Subsector(size_t num)
light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < topCullHeight ? true : false);
alpha = HWR_FogBlockAlpha(SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), rover->master->frontsector->extra_colormap);
alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap);
HWR_AddTransparentFloor(0,
&extrasubsectors[num],
true,
*rover->topheight,
SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel),
*gr_frontsector->lightlist[light].lightlevel,
alpha, rover->master->frontsector, PF_Fog|PF_NoTexture,
true, rover->master->frontsector->extra_colormap);
}
@@ -3364,7 +3393,7 @@ static void HWR_Subsector(size_t num)
&extrasubsectors[num],
true,
*rover->topheight,
SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel),
*gr_frontsector->lightlist[light].lightlevel,
max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent,
false, gr_frontsector->lightlist[light].extra_colormap);
}
@@ -3372,7 +3401,7 @@ static void HWR_Subsector(size_t num)
{
HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gr_frontsector, true));
light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < topCullHeight ? true : false);
HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), levelflats[*rover->toppic].lumpnum,
HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum,
rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap);
}
}
@@ -3507,14 +3536,16 @@ static boolean HWR_PortalCheckBBox(const fixed_t *bspcoord)
static void HWR_RenderBSPNode(INT32 bspnum)
{
const node_t *bsp;
INT32 side;
ps_numbspcalls.value.i++;
while (!(bspnum & NF_SUBSECTOR)) // Found a subsector?
{
const node_t *bsp = &nodes[bspnum];
bsp = &nodes[bspnum];
// Decide which side the view point is on.
INT32 side = R_PointOnSide(viewx, viewy, bsp);
side = R_PointOnSide(viewx, viewy, bsp);
// Recursively divide front space.
if (HWR_PortalCheckBBox(bsp->bbox[side]))
@@ -3530,7 +3561,8 @@ static void HWR_RenderBSPNode(INT32 bspnum)
// PORTAL CULLING
if (portalclipline && portalcullsector)
{
if (portalcullsector != subsectors[bspnum & ~NF_SUBSECTOR].sector)
sector_t *sect = subsectors[bspnum & ~NF_SUBSECTOR].sector;
if (sect != portalcullsector)
return;
portalcullsector = NULL;
}
@@ -3616,6 +3648,7 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t
{
FOutVector swallVerts[4];
FSurfaceInfo sSurf;
FBITFIELD blendmode = 0;
fixed_t floorheight, mobjfloor;
pslope_t *floorslope;
fixed_t slopez;
@@ -3771,16 +3804,140 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t
if (sSurf.PolyColor.s.alpha > floorheight/4)
{
sSurf.PolyColor.s.alpha = (UINT8)(sSurf.PolyColor.s.alpha - floorheight/4);
if (HWR_UseShader())
{
shader = SHADER_FLOOR; // floor shader
shader = SHADER_SHADOW;
blendmode |= PF_ColorMapped;
}
HWR_ProcessPolygon(&sSurf, swallVerts, 4, PF_Translucent|PF_Modulated, shader, false);
HWR_ProcessPolygon(&sSurf, swallVerts, 4, blendmode|PF_Translucent|PF_Modulated, shader, false);
}
}
static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
{
GLPatch_t *gpatch;
FOutVector shadowVerts[4];
FSurfaceInfo sSurf;
float fscale; float fx; float fy; float offset;
float ph;
FBITFIELD blendmode = 0;
INT32 shader = SHADER_NONE;
UINT8 i;
SINT8 flip = P_MobjFlip(thing);
UINT8 lightlevel = 0;
INT32 dist = -1;
fixed_t scalemul;
fixed_t floordiff;
fixed_t groundz;
fixed_t slopez;
pslope_t *groundslope;
// uncapped/interpolation
interpmobjstate_t interp = {0};
if (cv_grmaxinterpdist.value)
dist = R_QuickCamDist(thing->x, thing->y);
// do interpolation
if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value))
{
R_InterpolateMobjState(thing, rendertimefrac, &interp);
}
else
{
R_InterpolateMobjState(thing, FRACUNIT, &interp);
}
if (cv_sloperoll.value && cv_spriteroll.value)
groundz = R_GetShadowZ(thing, &groundslope);
else
groundz = interp.floorz;
floordiff = abs((flip < 0 ? thing->height : 0) + interp.z - groundz);
if (thing->whiteshadow)
gpatch = W_CachePatchNum(sprites[SPR_SHAD].spriteframes[1].lumppat[0], PU_CACHE);
else
gpatch = W_CachePatchNum(sprites[SPR_SHAD].spriteframes[0].lumppat[0], PU_CACHE);
if (!(gpatch && gpatch->mipmap->format)) return;
HWR_GetPatch(gpatch);
scalemul = FixedMul(FRACUNIT - floordiff/640, scale);
scalemul = FixedMul(scalemul, (thing->radius*2) / SHORT(gpatch->height));
ph = (float)gpatch->height;
fscale = FIXED_TO_FLOAT(scalemul);
fx = FIXED_TO_FLOAT(interp.x);
fy = FIXED_TO_FLOAT(interp.y);
if (fscale > 0.0)
{
offset = (ph / 2) * fscale;
}
else
{
return;
}
// 3--2
// | /|
// |/ |
// 0--1
shadowVerts[2].x = shadowVerts[3].x = fx + offset;
shadowVerts[1].x = shadowVerts[0].x = fx - offset;
shadowVerts[1].z = shadowVerts[2].z = fy - offset;
shadowVerts[0].z = shadowVerts[3].z = fy + offset;
for (i = 0; i < 4; i++)
{
float oldx = shadowVerts[i].x;
float oldy = shadowVerts[i].z;
shadowVerts[i].x = fx + ((oldx - fx) * gr_viewcos) - ((oldy - fy) * gr_viewsin);
shadowVerts[i].z = fy + ((oldx - fx) * gr_viewsin) + ((oldy - fy) * gr_viewcos);
}
if (groundslope && cv_sloperoll.value && cv_spriteroll.value)
{
for (i = 0; i < 4; i++)
{
slopez = P_GetZAt(groundslope, FLOAT_TO_FIXED(shadowVerts[i].x), FLOAT_TO_FIXED(shadowVerts[i].z));
shadowVerts[i].y = FIXED_TO_FLOAT(slopez) + 3 + flip * 0.05f;
}
}
else
{
for (i = 0; i < 4; i++)
shadowVerts[i].y = FIXED_TO_FLOAT(groundz) + 3 + flip * 0.05f;
}
shadowVerts[0].s = shadowVerts[3].s = 0;
shadowVerts[2].s = shadowVerts[1].s = gpatch->max_s;
shadowVerts[3].t = shadowVerts[2].t = 0;
shadowVerts[0].t = shadowVerts[1].t = gpatch->max_t;
if (thing->whiteshadow)
lightlevel = 255; // make crap FULLBRIGHT
HWR_Lighting(&sSurf, lightlevel, NULL);
sSurf.PolyColor.s.alpha = 0x80;
if (HWR_UseShader())
{
shader = SHADER_SHADOW;
blendmode |= PF_ColorMapped;
}
HWR_ProcessPolygon(&sSurf, shadowVerts, 4, blendmode|PF_Translucent|PF_Modulated, shader, false); // sprite shader
}
// This is expecting a pointer to an array containing 4 wallVerts for a sprite
static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts, const boolean precip)
{
@@ -3943,11 +4100,12 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
{
float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->ty - gr_viewz)*(spr->ty - gr_viewz));
float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist;
size_t i;
for (i = 0; i < 4; i++)
{
baseWallVerts[i].x += (gr_viewx - baseWallVerts[i].x)*distfact;
baseWallVerts[i].z += (gr_viewy - baseWallVerts[i].z)*distfact;
baseWallVerts[i].y += (gr_viewz - baseWallVerts[i].y)*distfact;
wallVerts[i].x += (gr_viewx - wallVerts[i].x)*distfact;
wallVerts[i].z += (gr_viewy - wallVerts[i].z)*distfact;
wallVerts[i].y += (gr_viewz - wallVerts[i].y)*distfact;
}
}
@@ -3996,7 +4154,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
alpha = Surf.PolyColor.s.alpha;
// Start with the lightlevel and colormap from the top of the sprite
lightlevel = SOFTLIGHT(*list[sector->numlights - 1].lightlevel);
lightlevel = *list[sector->numlights - 1].lightlevel;
colormap = list[sector->numlights - 1].extra_colormap;
i = 0;
@@ -4011,7 +4169,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
if (h <= temp)
{
if (!(spr->mobj->frame & FF_FULLBRIGHT))
lightlevel = *list[i-1].lightlevel > 255 ? 255 : SOFTLIGHT(*list[i-1].lightlevel);
lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel;
colormap = list[i-1].extra_colormap;
break;
}
@@ -4026,7 +4184,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES))
{
if (!(spr->mobj->frame & FF_FULLBRIGHT))
lightlevel = *list[i].lightlevel > 255 ? 255 : SOFTLIGHT(*list[i].lightlevel);
lightlevel = *list[i].lightlevel > 255 ? 255 : *list[i].lightlevel;
colormap = list[i].extra_colormap;
}
@@ -4218,7 +4376,6 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
}
// Let dispoffset work first since this adjust each vertex
// ...nah
HWR_RotateSpritePolyToAim(spr, wallVerts, false);
// push it toward the camera to mitigate floor-clipping sprites
@@ -4245,7 +4402,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
extracolormap_t *colormap = sector->extra_colormap;
if (!(spr->mobj->frame & FF_FULLBRIGHT))
lightlevel = sector->lightlevel > 255 ? 255 : SOFTLIGHT(sector->lightlevel);
lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel;
HWR_Lighting(&Surf, lightlevel, colormap);
}
@@ -4346,7 +4503,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr)
light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before
if (!(spr->mobj->frame & FF_FULLBRIGHT))
lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : SOFTLIGHT(*sector->lightlist[light].lightlevel);
lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel;
if (sector->lightlist[light].extra_colormap)
colormap = sector->lightlist[light].extra_colormap;
@@ -4354,7 +4511,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr)
else
{
if (!(spr->mobj->frame & FF_FULLBRIGHT))
lightlevel = sector->lightlevel > 255 ? 255 : SOFTLIGHT(sector->lightlevel);
lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel;
if (sector->extra_colormap)
colormap = sector->extra_colormap;
@@ -4402,8 +4559,9 @@ static int CompareVisSprites(const void *p1, const void *p2)
// make transparent sprites last
// "boolean to int"
int transparency1 = (spr1->mobj->flags2 & MF2_SHADOW) || (spr1->mobj->frame & FF_TRANSMASK);
int transparency2 = (spr2->mobj->flags2 & MF2_SHADOW) || (spr2->mobj->frame & FF_TRANSMASK);
int transparency1 = (!spr1->precip && (spr1->mobj->flags2 & MF2_SHADOW)) || (spr1->mobj->frame & FF_TRANSMASK);
int transparency2 = (!spr2->precip && (spr2->mobj->flags2 & MF2_SHADOW)) || (spr2->mobj->frame & FF_TRANSMASK);
idiff = transparency1 - transparency2;
if (idiff != 0) return idiff;
@@ -4416,8 +4574,6 @@ static int CompareVisSprites(const void *p1, const void *p2)
return -1;
}
#undef SOFTLIGHT
static void HWR_SortVisSprites(void)
{
UINT32 i;
@@ -4710,6 +4866,13 @@ void HWR_DrawSprites(void)
if (spr->precip)
HWR_DrawPrecipitationSprite(spr);
else
{
if (spr->mobj && cv_dropshadow.value)
{
if (spr->mobj->haveshadow)
HWR_DrawDropShadow(spr->mobj, spr->mobj->shadowscale);
}
if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
{
md2_t *md2;
@@ -4736,6 +4899,7 @@ void HWR_DrawSprites(void)
else
HWR_DrawMD2(spr);
}
}
}
}
@@ -4746,8 +4910,7 @@ void HWR_DrawSprites(void)
void HWR_AddSprites(sector_t *sec)
{
mobj_t *thing;
precipmobj_t *precipthing;
fixed_t approx_dist, limit_dist, precip_limit_dist;
fixed_t approx_dist, limit_dist;
INT32 splitflags;
boolean split_drawsprite; // drawing with splitscreen flags
@@ -4766,16 +4929,12 @@ void HWR_AddSprites(sector_t *sec)
{
// Use the smaller setting
if (cv_drawdist.value)
limit_dist = min(current_bsp_culling_distance, cv_drawdist.value << FRACBITS);
limit_dist = min(current_bsp_culling_distance, (fixed_t)(cv_drawdist.value) * mapobjectscale);
else
limit_dist = current_bsp_culling_distance;
precip_limit_dist = min(current_bsp_culling_distance, cv_drawdist_precip.value << FRACBITS);
}
else
{
limit_dist = cv_drawdist.value << FRACBITS;
precip_limit_dist = cv_drawdist_precip.value << FRACBITS;
}
limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale;
// Handle all things in sector.
// If a limit exists, handle things a tiny bit different.
@@ -4783,7 +4942,6 @@ void HWR_AddSprites(sector_t *sec)
{
for (thing = sec->thinglist; thing; thing = thing->snext)
{
split_drawsprite = false;
if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW)
@@ -4828,7 +4986,6 @@ void HWR_AddSprites(sector_t *sec)
// Draw everything in sector, no checks
for (thing = sec->thinglist; thing; thing = thing->snext)
{
split_drawsprite = false;
if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW)
@@ -4863,21 +5020,46 @@ void HWR_AddSprites(sector_t *sec)
HWR_ProjectSprite(thing);
}
}
}
// --------------------------------------------------------------------------
// HWR_AddPrecipitationSprites
// This renders through the blockmap instead of BSP to avoid
// iterating a huge amount of precipitation sprites in sectors
// that are beyond drawdist.
// --------------------------------------------------------------------------
static void HWR_AddPrecipitationSprites(void)
{
//const fixed_t drawdist = cv_drawdist_precip.value * mapobjectscale;
fixed_t drawdist;
INT32 xl, xh, yl, yh, bx, by;
precipmobj_t *th;
if (current_bsp_culling_distance)
drawdist = min(current_bsp_culling_distance, (fixed_t)(cv_drawdist_precip.value) * mapobjectscale);
else
drawdist = (fixed_t)(cv_drawdist_precip.value) * mapobjectscale;
// No to infinite precipitation draw distance.
if (precip_limit_dist)
if (drawdist == 0)
{
for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext)
return;
}
R_GetRenderBlockMapDimensions(drawdist, &xl, &xh, &yl, &yh);
for (bx = xl; bx <= xh; bx++)
{
for (by = yl; by <= yh; by++)
{
if (precipthing->precipflags & PCF_INVISIBLE)
continue;
for (th = precipblocklinks[(by * bmapwidth) + bx]; th; th = th->bnext)
{
if (th->precipflags & PCF_INVISIBLE)
continue;
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
if (approx_dist > precip_limit_dist)
continue;
HWR_ProjectPrecipitationSprite(precipthing);
HWR_ProjectPrecipitationSprite(th);
}
}
}
}
@@ -4906,11 +5088,11 @@ void HWR_ProjectSprite(mobj_t *thing)
size_t lumpoff;
unsigned rot;
UINT8 flip;
boolean mirrored = thing->mirrored;
boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored);
boolean mirrored;
boolean hflip;
angle_t ang, camang;
const boolean papersprite = (thing->frame & FF_PAPERSPRITE);
boolean papersprite;
INT32 heightsec, phs;
INT32 dist = -1;
@@ -4929,6 +5111,10 @@ void HWR_ProjectSprite(mobj_t *thing)
if (!thing)
return;
mirrored = thing->mirrored;
hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored);
papersprite = (thing->frame & FF_PAPERSPRITE);
if (cv_grmaxinterpdist.value)
dist = R_QuickCamDist(thing->x, thing->y);
@@ -5085,10 +5271,10 @@ void HWR_ProjectSprite(mobj_t *thing)
if (rotsprite != NULL)
{
spr_width = rotsprite->width << FRACBITS;
spr_height = rotsprite->height << FRACBITS;
spr_offset = rotsprite->leftoffset << FRACBITS;
spr_topoffset = rotsprite->topoffset << FRACBITS;
spr_width = SHORT(rotsprite->width) << FRACBITS;
spr_height = SHORT(rotsprite->height) << FRACBITS;
spr_offset = SHORT(rotsprite->leftoffset) << FRACBITS;
spr_topoffset = SHORT(rotsprite->topoffset) << FRACBITS;
spr_topoffset += FEETADJUST;
// flip -> rotate, not rotate -> flip
@@ -5233,7 +5419,7 @@ void HWR_ProjectSprite(mobj_t *thing)
vis->colormap = colormaps;
#ifdef GLENCORE
if (encoremap && !(thing->flags & MF_DONTENCOREMAP))
vis->colormap += (256*32);
vis->colormap += COLORMAP_REMAPOFFSET;
#endif
}
@@ -5364,7 +5550,7 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
#ifdef GLENCORE
if (encoremap && !(thing->flags & MF_DONTENCOREMAP))
vis->colormap += (256*32);
vis->colormap += COLORMAP_REMAPOFFSET;
#endif
// set top/bottom coords
@@ -5405,6 +5591,7 @@ void HWR_DrawSkyBackground(float fpov)
dometransform.flip = atransform.flip;
dometransform.mirror = atransform.mirror;
dometransform.mirrorflip = atransform.mirrorflip;
dometransform.shearing = atransform.shearing;
dometransform.viewaiming = atransform.viewaiming;
@@ -5531,6 +5718,10 @@ void HWR_SetTransform(float fpov, player_t *player)
if (*postprocessor == postimg_mirror)
atransform.mirror = true;
atransform.mirrorflip = false;
if (*postprocessor == postimg_mirrorflip)
atransform.mirrorflip = true;
// Set transform.
HWD.pfnSetTransform(&atransform);
}
@@ -5701,6 +5892,8 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe
if (cv_grbatching.value)
HWR_StartBatching();
HWR_AddPrecipitationSprites();
ps_numbspcalls.value.i = 0;
ps_numpolyobjects.value.i = 0;
PS_START_TIMING(ps_bsptime);
@@ -5720,7 +5913,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe
gr_portal = oldgl_portal_state;
PS_STOP_TIMING(ps_bsptime);
if (cv_grbatching.value)
HWR_RenderBatches();
@@ -5945,9 +6138,7 @@ void HWR_AddCommands(void)
CV_RegisterVar(&cv_fofzfightfix);
CV_RegisterVar(&cv_splitwallfix);
CV_RegisterVar(&cv_slopepegfix);
CV_RegisterVar(&cv_grscreentextures);
CV_RegisterVar(&cv_grrenderdistance);
CV_RegisterVar(&cv_grfakecontrast);
@@ -5975,6 +6166,12 @@ void HWR_AddCommands(void)
CV_RegisterVar(&cv_grpaletterendering);
CV_RegisterVar(&cv_grpalettedepth);
CV_RegisterVar(&cv_grflashpal);
#ifdef USE_FBO_OGL
CV_RegisterVar(&cv_grframebuffer);
#endif
CV_RegisterVar(&cv_grscreentextures);
}
// --------------------------------------------------------------------------
@@ -5999,6 +6196,10 @@ void HWR_Startup(void)
HWR_TogglePaletteRendering();
#ifdef USE_FBO_OGL
HWD.pfnSetSpecialState(HWD_SET_FRAMEBUFFER, cv_grframebuffer.value);
#endif
if (msaa)
{
if (a2c)
@@ -6180,6 +6381,12 @@ void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum)
lumpnum_t lumpnum;
size_t lsize;
if (cv_grscreentextures.value == 0)
{
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // just draw a black screen instead of flashing and crap
return;
}
if (wipenum > 99 || scrnnum > 99) // not a valid wipe number
return; // shouldn't end up here really, the loop should've stopped running beforehand
+3
View File
@@ -152,6 +152,9 @@ void HWR_SetShaderState(void);
// Console variables
extern consvar_t cv_grshaders;
#ifdef USE_FBO_OGL
extern consvar_t cv_grframebuffer;
#endif
extern consvar_t cv_grfofcut;
extern consvar_t cv_fofzfightfix;
extern consvar_t cv_splitwallfix;
+4
View File
@@ -29,6 +29,9 @@ static struct {
// Floor shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_FLOOR_FRAGMENT_SHADER},
// Shadow shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_SHADOW_FRAGMENT_SHADER},
// Wall shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER},
@@ -422,6 +425,7 @@ static inline UINT16 HWR_FindShaderDefs(UINT16 wadnum)
customshaderxlat_t shaderxlat[] =
{
{"Flat", SHADER_FLOOR},
{"Shadow", SHADER_SHADOW},
{"WallTexture", SHADER_WALL},
{"Sprite", SHADER_SPRITE},
{"Model", SHADER_MODEL},
+24
View File
@@ -133,6 +133,26 @@
"gl_FragColor = final_color;\n" \
"}\n" \
"#endif\0"
#define GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL \
"uniform sampler2D tex;\n" \
"uniform vec4 poly_color;\n" \
"uniform vec4 tint_color;\n" \
"uniform vec4 fade_color;\n" \
"uniform float lighting;\n" \
"uniform float fade_start;\n" \
"uniform float fade_end;\n" \
GLSL_DOOM_COLORMAP \
GLSL_DOOM_LIGHT_EQUATION \
"void main(void) {\n" \
"vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \
"vec4 base_color = texel * poly_color;\n" \
"vec4 final_color = base_color;\n" \
GLSL_SOFTWARE_TINT_EQUATION \
GLSL_SOFTWARE_FADE_EQUATION \
"final_color.a = texel.a * poly_color.a;\n" \
"gl_FragColor = final_color;\n" \
"}\n" \
// hand tuned adjustments for light level calculation
#define GLSL_FLOOR_FUDGES \
@@ -150,6 +170,10 @@
#define GLSL_WALL_FRAGMENT_SHADER \
GLSL_WALL_FUDGES \
GLSL_SOFTWARE_FRAGMENT_SHADER
#define GLSL_SHADOW_FRAGMENT_SHADER \
GLSL_FLOOR_FUDGES \
GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL
//
// Water surface shader
+189 -8
View File
@@ -119,6 +119,14 @@ static GLfloat modelMatrix[16];
GLfloat projMatrix[16];
static GLint viewport[4];
#ifdef USE_FBO_OGL
static boolean GLFramebuffer_IsFuncAvailible(void);
GLuint FramebufferObject, FramebufferTexture, RenderbufferObject;
GLboolean FrameBufferEnabled = GL_FALSE, RenderToFramebuffer = GL_FALSE;
boolean supportFBO = false;
#endif
// Sryder: NextTexAvail is broken for these because palette changes or changes to the texture filter or antialiasing
// flush all of the stored textures, leaving them unavailable at times such as between levels
@@ -428,7 +436,32 @@ typedef void (APIENTRY * PFNglCopyTexImage2D) (GLenum target, GLint level, GLenu
static PFNglCopyTexImage2D pglCopyTexImage2D;
typedef void (APIENTRY * PFNglCopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
static PFNglCopyTexSubImage2D pglCopyTexSubImage2D;
#endif
#ifdef USE_FBO_OGL
/* 3.0 functions for framebuffers and renderbuffers */
typedef void (APIENTRY * PFNglGenFramebuffers) (GLsizei n, GLuint *ids);
static PFNglGenFramebuffers pglGenFramebuffers;
typedef void (APIENTRY * PFNglBindFramebuffer) (GLenum target, GLuint framebuffer);
static PFNglBindFramebuffer pglBindFramebuffer;
typedef void (APIENTRY * PFNglDeleteFramebuffers) (GLsizei n, GLuint *ids);
static PFNglDeleteFramebuffers pglDeleteFramebuffers;
typedef void (APIENTRY * PFNglFramebufferTexture2D) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
static PFNglFramebufferTexture2D pglFramebufferTexture2D;
typedef GLenum (APIENTRY * PFNglCheckFramebufferStatus) (GLenum target);
static PFNglCheckFramebufferStatus pglCheckFramebufferStatus;
typedef void (APIENTRY * PFNglGenRenderbuffers) (GLsizei n, GLuint *renderbuffers);
static PFNglGenRenderbuffers pglGenRenderbuffers;
typedef void (APIENTRY * PFNglBindRenderbuffer) (GLenum target, GLuint renderbuffer);
static PFNglBindRenderbuffer pglBindRenderbuffer;
typedef void (APIENTRY * PFNglDeleteRenderbuffers) (GLsizei n, GLuint *renderbuffers);
static PFNglDeleteRenderbuffers pglDeleteRenderbuffers;
typedef void (APIENTRY * PFNglRenderbufferStorage) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
static PFNglRenderbufferStorage pglRenderbufferStorage;
typedef void (APIENTRY * PFNglFramebufferRenderbuffer) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLenum renderbuffer);
static PFNglFramebufferRenderbuffer pglFramebufferRenderbuffer;
#endif // USE_FBO_OGL
#endif //!STATIC_OPENGL
/* 1.2 functions for 3D textures */
typedef void (APIENTRY * PFNglTexImage3D) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
@@ -712,8 +745,39 @@ void SetupGLFunc4(void)
pglUniform2fv = GetGLFunc("glUniform2fv");
pglUniform3fv = GetGLFunc("glUniform3fv");
pglGetUniformLocation = GetGLFunc("glGetUniformLocation");
#ifdef USE_FBO_OGL
if (GLFramebuffer_IsFuncAvailible())
{
pglGenFramebuffers = GetGLFunc("glGenFramebuffers");
pglBindFramebuffer = GetGLFunc("glBindFramebuffer");
pglDeleteFramebuffers = GetGLFunc("glDeleteFramebuffers");
pglFramebufferTexture2D = GetGLFunc("glFramebufferTexture2D");
pglCheckFramebufferStatus = GetGLFunc("glCheckFramebufferStatus");
pglGenRenderbuffers = GetGLFunc("glGenRenderbuffers");
pglBindRenderbuffer = GetGLFunc("glBindRenderbuffer");
pglDeleteRenderbuffers = GetGLFunc("glDeleteRenderbuffers");
pglRenderbufferStorage = GetGLFunc("glRenderbufferStorage");
pglFramebufferRenderbuffer = GetGLFunc("glFramebufferRenderbuffer");
}
#endif
}
#ifdef USE_FBO_OGL
static boolean GLFramebuffer_IsFuncAvailible(void)
{
//this stuff needs atleast OGL 3.0
if (majorGL < 3)
return false;
return((isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions)) &&
(isExtAvailable("GL_ARB_framebuffer_object",gl_extensions)) &&
(isExtAvailable("GL_ARB_framebuffer_sRGB",gl_extensions)));
return false;
}
#endif
EXPORT boolean HWRAPI(InitShaders) (void)
{
if (!pglUseProgram)
@@ -889,13 +953,6 @@ void SetModelView(GLint w, GLint h)
{
//GL_DBG_Printf("SetModelView(): %dx%d\n", (int)w, (int)h);
// The screen textures need to be flushed if the width or height change so that they be remade for the correct size
if (screen_width != w || screen_height != h)
FlushScreenTextures();
screen_width = w;
screen_height = h;
pglViewport(0, 0, w, h);
pglMatrixMode(GL_PROJECTION);
@@ -980,6 +1037,117 @@ EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *pTexInfo)
pTexInfo->downloaded = 0;
}
#ifdef USE_FBO_OGL
void GLFramebuffer_Generate(void)
{
if (!GLFramebuffer_IsFuncAvailible())
return;
// Generate the framebuffer
if (FramebufferObject == 0)
pglGenFramebuffers(1, &FramebufferObject);
if (pglCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE)
GLFramebuffer_GenerateAttachments();
}
void GLFramebuffer_Delete(void)
{
if (!GLFramebuffer_IsFuncAvailible())
return;
// Unbind the framebuffer
pglBindFramebuffer(GL_FRAMEBUFFER, 0);
if (FramebufferObject)
pglDeleteFramebuffers(1, &FramebufferObject);
GLFramebuffer_DeleteAttachments();
FramebufferObject = 0;
}
void GLFramebuffer_GenerateAttachments(void)
{
if (!GLFramebuffer_IsFuncAvailible())
return;
// Bind the framebuffer
pglBindFramebuffer(GL_FRAMEBUFFER, FramebufferObject);
// Generate the framebuffer texture
if (FramebufferTexture == 0)
{
pglGenTextures(1, &FramebufferTexture);
pglBindTexture(GL_TEXTURE_2D, FramebufferTexture);
pglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, screen_width, screen_height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
pglBindTexture(GL_TEXTURE_2D, 0);
// Attach the framebuffer texture to the framebuffer
pglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, FramebufferTexture, 0);
}
// Generate the renderbuffer
if (RenderbufferObject == 0)
{
pglGenRenderbuffers(1, &RenderbufferObject);
pglBindRenderbuffer(GL_RENDERBUFFER, RenderbufferObject);
pglRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, screen_width, screen_height);
pglFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, RenderbufferObject);
// Clear the renderbuffer
ClearBuffer(true, true, true, NULL);
pglBindRenderbuffer(GL_RENDERBUFFER, 0);
}
// Unbind the framebuffer
pglBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void GLFramebuffer_DeleteAttachments(void)
{
if (!GLFramebuffer_IsFuncAvailible())
return;
// Unbind the framebuffer
pglBindFramebuffer(GL_FRAMEBUFFER, 0);
if (FramebufferTexture)
pglDeleteTextures(1, &FramebufferTexture);
if (RenderbufferObject)
pglDeleteRenderbuffers(1, &RenderbufferObject);
FramebufferTexture = 0;
RenderbufferObject = 0;
}
void GLFramebuffer_Enable(void)
{
if (!GLFramebuffer_IsFuncAvailible())
return;
if (FramebufferObject == 0)
GLFramebuffer_Generate();
else if (FramebufferTexture == 0 || RenderbufferObject == 0)
GLFramebuffer_GenerateAttachments();
pglBindFramebuffer(GL_FRAMEBUFFER, FramebufferObject);
pglBindRenderbuffer(GL_RENDERBUFFER, RenderbufferObject);
}
void GLFramebuffer_Disable(void)
{
if (!GLFramebuffer_IsFuncAvailible())
return;
pglBindFramebuffer(GL_FRAMEBUFFER, 0);
pglBindRenderbuffer(GL_RENDERBUFFER, 0);
}
#endif
// -----------------+
// Flush : flush OpenGL textures
@@ -2156,7 +2324,18 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
case HWD_SET_SHADERS:
gl_allowshaders = Value;
break;
#ifdef USE_FBO_OGL
case HWD_SET_FRAMEBUFFER:
FrameBufferEnabled = Value ? GL_TRUE : GL_FALSE;
supportFBO = GLFramebuffer_IsFuncAvailible();
if (!supportFBO)
{
FrameBufferEnabled = GL_FALSE;
CV_Set(&cv_grframebuffer, "Off");
}
break;
#endif
case HWD_SET_TEXTUREFILTERMODE:
switch (Value)
{
@@ -2748,6 +2927,8 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform)
// mirroring from Kart
if (stransform->mirror)
pglScalef(-stransform->scalex, stransform->scaley, -stransform->scalez);
else if (stransform->mirrorflip)
pglScalef(-stransform->scalex, -stransform->scaley, -stransform->scalez);
else
#endif
if (stransform->flip)
+15
View File
@@ -104,6 +104,21 @@ static PFNglEnableClientState pglEnableClientState;
#endif
#endif
#ifdef USE_FBO_OGL
void GLFramebuffer_Generate(void);
void GLFramebuffer_Delete(void);
void GLFramebuffer_GenerateAttachments(void);
void GLFramebuffer_DeleteAttachments(void);
void GLFramebuffer_Enable(void);
void GLFramebuffer_Disable(void);
extern GLuint FramebufferObject, FramebufferTexture, RenderbufferObject;
extern GLboolean FrameBufferEnabled, RenderToFramebuffer;
extern boolean supportFBO;
#endif
// ==========================================================================
// GLOBAL
// ==========================================================================
+9 -2
View File
@@ -531,7 +531,8 @@ static void HU_removeChatText_Log(void)
free(chat_log[0]);
size_t i;
for(i=0;i<chat_nummsg_log-1;i++) {
for(i=0;i<chat_nummsg_log-1;i++)
{
chat_log[i] = chat_log[i+1];
}
chat_nummsg_log--; // lost 1 msg.
@@ -549,7 +550,13 @@ static void Chatlogsize_OnChange(void)
#define reallocarray(ptr, nmemb, size) realloc(ptr, (nmemb)*(size))
// TODO - use z_zone allocators?
chat_log = reallocarray(chat_log, cv_chatlogsize.value, sizeof(char*));
char **new_chat_log = reallocarray(chat_log, cv_chatlogsize.value, sizeof(char*));
if (new_chat_log == NULL)
{
free(chat_log);
return;
}
chat_log = new_chat_log;
#undef reallocarray
chat_nummsg_log = min(chat_nummsg_log, (UINT32)cv_chatlogsize.value);
+6
View File
@@ -139,4 +139,10 @@ UINT32 I_GetRefreshRate(void);
boolean I_UseNativeKeyboard(void);
#ifdef USE_FBO_OGL
void RefreshOGLSDLSurface(void);
void I_DownSample(void);
extern boolean downsample;
#endif
#endif
+2 -2
View File
@@ -655,7 +655,7 @@ static int lib_pSpawnShadowMobj(lua_State *L)
NOHUD
if (!caster)
return LUA_ErrInvalid(L, "mobj_t");
P_SpawnShadowMobj(caster);
caster->haveshadow = true;
return 0;
}
@@ -3266,4 +3266,4 @@ int LUA_BaseLib(lua_State *L)
lua_pushvalue(L, LUA_GLOBALSINDEX);
luaL_register(L, NULL, lib);
return 0;
}
}
+7 -1
View File
@@ -42,9 +42,15 @@ enum hud {
extern boolean hud_running;
extern boolean hud_interpolate; // interpolation enabled
extern UINT8 hud_interptag; // current tag
extern UINT32 hud_interpcounter; // number of HUD hooks ran
extern boolean hud_interpstring; // string mode
extern boolean hud_interplatch; // string mode was toggled
boolean LUA_HudEnabled(enum hud option);
void LUAh_GameHUD(player_t *stplyr, huddrawlist_h list);
void LUAh_GameHUD(huddrawlist_h list);
void LUAh_ScoresHUD(huddrawlist_h list);
void LUAh_IntermissionHUD(huddrawlist_h list);
void LUAh_VoteHUD(huddrawlist_h list);
+60 -24
View File
@@ -32,6 +32,12 @@
#define HUDONLY if (!hud_running) return luaL_error(L, "HUD rendering code should not be called outside of rendering hooks!");
boolean hud_running = false;
boolean hud_interpolate = false;
UINT8 hud_interptag = 0;
UINT32 hud_interpcounter = 0;
boolean hud_interpstring = false;
boolean hud_interplatch = false;
static UINT8 hud_enabled[(hud_MAX/8)+1];
static UINT8 hudAvailable; // hud hooks field
@@ -1178,6 +1184,41 @@ static int libd_getDrawInfo(lua_State *L)
return 3;
}
static int libd_interpolate(lua_State *L)
{
HUDONLY
// do type checking even if interpolation is disabled
boolean newinterpolate;
UINT8 newtag;
if (lua_isnumber(L, 1))
{
newinterpolate = true;
newtag = luaL_checkinteger(L, 1);
}
else
{
newinterpolate = luaL_checkboolean(L, 1);
newtag = 0;
}
if (!cv_uncappedhud.value)
return 0;
hud_interpolate = newinterpolate;
hud_interptag = newtag;
return 0;
}
static int libd_interpLatch(lua_State *L)
{
HUDONLY
hud_interpstring = hud_interplatch = luaL_checkboolean(L, 1);
return 0;
}
static luaL_Reg lib_draw[] = {
{"patchExists", libd_patchExists},
{"cachePatch", libd_cachePatch},
@@ -1205,6 +1246,8 @@ static luaL_Reg lib_draw[] = {
{"getDrawInfo", libd_getDrawInfo},
{"getHudColor", libd_getHudColor},
{"useColorHud", libd_useColorHud},
{"interpolate", libd_interpolate},
{"interpLatch", libd_interpLatch},
{NULL, NULL}
};
@@ -1413,7 +1456,7 @@ boolean LUA_HudEnabled(enum hud option)
}
// Hook for HUD rendering
void LUAh_GameHUD(player_t *stplayr, huddrawlist_h list)
void LUAh_GameHUD(huddrawlist_h list)
{
if (!gL || !(hudAvailable & (1<<hudhook_game)))
return;
@@ -1434,33 +1477,17 @@ void LUAh_GameHUD(player_t *stplayr, huddrawlist_h list)
lua_rawgeti(gL, -2, 1); // HUD[1] = lib_draw
I_Assert(lua_istable(gL, -1));
lua_remove(gL, -3); // pop HUD
LUA_PushUserdata(gL, stplayr, META_PLAYER);
if (splitscreen > 2 && stplayr == &players[displayplayers[3]])
{
LUA_PushUserdata(gL, &camera[3], META_CAMERA);
camnum = 4;
}
else if (splitscreen > 1 && stplayr == &players[displayplayers[2]])
{
LUA_PushUserdata(gL, &camera[2], META_CAMERA);
camnum = 3;
}
else if (splitscreen && stplayr == &players[displayplayers[1]])
{
LUA_PushUserdata(gL, &camera[1], META_CAMERA);
camnum = 2;
}
else
{
LUA_PushUserdata(gL, &camera[0], META_CAMERA);
camnum = 1;
}
LUA_PushUserdata(gL, stplyr, META_PLAYER);
LUA_PushUserdata(gL, &camera[stplyrnum], META_CAMERA);
camnum = stplyrnum + 1;
hud_interpcounter = 0;
lua_pushnil(gL);
while (lua_next(gL, -5) != 0) {
hud_interpolate = hud_interpstring = hud_interplatch = false;
hud_interpcounter++;
lua_pushvalue(gL, -5); // graphics library (HUD[1])
lua_pushvalue(gL, -5); // stplayr
lua_pushvalue(gL, -5); // stplyr
lua_pushvalue(gL, -5); // camera
LUA_Call(gL, 3, 0, 1);
}
@@ -1493,7 +1520,10 @@ void LUAh_ScoresHUD(huddrawlist_h list)
I_Assert(lua_istable(gL, -1));
lua_remove(gL, -3); // pop HUD
lua_pushnil(gL);
hud_interpcounter = 0;
while (lua_next(gL, -3) != 0) {
hud_interpolate = hud_interpstring = hud_interplatch = false;
hud_interpcounter++;
lua_pushvalue(gL, -3); // graphics library (HUD[1])
LUA_Call(gL, 1, 0, 1);
}
@@ -1526,7 +1556,10 @@ void LUAh_IntermissionHUD(huddrawlist_h list)
I_Assert(lua_istable(gL, -1));
lua_remove(gL, -3); // pop HUD
lua_pushnil(gL);
hud_interpcounter = 0;
while (lua_next(gL, -3) != 0) {
hud_interpolate = hud_interpstring = hud_interplatch = false;
hud_interpcounter++;
lua_pushvalue(gL, -3); // graphics library (HUD[1])
LUA_Call(gL, 1, 0, 1);
}
@@ -1559,7 +1592,10 @@ void LUAh_VoteHUD(huddrawlist_h list)
I_Assert(lua_istable(gL, -1));
lua_remove(gL, -3); // pop HUD
lua_pushnil(gL);
hud_interpcounter = 0;
while (lua_next(gL, -3) != 0) {
hud_interpolate = hud_interpstring = hud_interplatch = false;
hud_interpcounter++;
lua_pushvalue(gL, -3); // graphics library (HUD[1])
LUA_Call(gL, 1, 0, 1);
}
+287 -52
View File
@@ -11,11 +11,16 @@
/// \brief a data structure for managing cached drawlists for the Lua hud lib
#include "lua_hudlib_drawlist.h"
#include "lua_hud.h"
#include "blua/lstate.h" // shhhhhh
#include "lua_libs.h"
#include <string.h>
#include "v_video.h"
#include "z_zone.h"
#include "r_main.h"
#include "r_fps.h"
enum drawitem_e {
DI_Draw = 0,
@@ -34,37 +39,45 @@ enum drawitem_e {
// A single draw item with all possible arguments needed for a draw call.
typedef struct drawitem_s {
UINT64 id;
enum drawitem_e type;
fixed_t x;
fixed_t y;
fixed_t w;
fixed_t h;
INT32 c;
fixed_t scale;
fixed_t hscale;
fixed_t vscale;
patch_t *patch;
INT32 flags;
UINT16 basecolor;
UINT16 outlinecolor;
union {
INT32 flags;
INT32 c;
};
union {
fixed_t scale; // drawScaled
fixed_t hscale; // drawStretched
fixed_t w; // drawFill
INT32 align; // drawString
INT32 num; // drawNum, drawPaddedNum, drawPingNum
UINT16 color; // fadeScreen
};
union {
fixed_t vscale; // drawStretched
fixed_t h; // drawFill
INT32 digits; // drawPaddedNum
UINT8 strength; // fadeScreen
};
// pointers (and size_t's) last, for potentially better packing
union {
patch_t *patch;
size_t stroffset; // offset into strbuf to get str
};
const UINT8 *colormap;
UINT8 *basecolormap;
UINT8 *outlinecolormap;
fixed_t sx;
fixed_t sy;
INT32 num;
INT32 digits;
size_t stroffset; // offset into strbuf to get str
UINT16 color;
UINT8 strength;
INT32 align;
} drawitem_t;
// The internal structure of a drawlist.
struct huddrawlist_s {
drawitem_t *items;
size_t items_capacity;
size_t items_len;
drawitem_t *olditems;
size_t olditems_len;
size_t capacity;
char *strbuf;
size_t strbuf_capacity;
size_t strbuf_len;
@@ -88,8 +101,10 @@ huddrawlist_h LUA_HUD_CreateDrawList(void)
drawlist = (huddrawlist_h) Z_Calloc(sizeof(struct huddrawlist_s), PU_STATIC, NULL);
drawlist->items = NULL;
drawlist->items_capacity = 0;
drawlist->items_len = 0;
drawlist->olditems = NULL;
drawlist->olditems_len = 0;
drawlist->capacity = 0;
drawlist->strbuf = NULL;
drawlist->strbuf_capacity = 0;
drawlist->strbuf_len = 0;
@@ -99,15 +114,14 @@ huddrawlist_h LUA_HUD_CreateDrawList(void)
void LUA_HUD_ClearDrawList(huddrawlist_h list)
{
// swap the old and new lists
void *tmp = list->olditems;
list->olditems = list->items;
list->items = tmp;
// rather than deallocate, we'll just save the existing allocation and empty
// it out for reuse
// this memset probably isn't necessary
if (list->items)
{
memset(list->items, 0, sizeof(drawitem_t) * list->items_capacity);
}
list->olditems_len = list->items_len;
list->items_len = 0;
if (list->strbuf)
@@ -125,6 +139,10 @@ void LUA_HUD_DestroyDrawList(huddrawlist_h list)
{
Z_Free(list->items);
}
if (list->olditems)
{
Z_Free(list->olditems);
}
if (list->strbuf)
{
Z_Free(list->strbuf);
@@ -143,11 +161,11 @@ boolean LUA_HUD_IsDrawListValid(huddrawlist_h list)
static size_t AllocateDrawItem(huddrawlist_h list)
{
if (!list) I_Error("can't allocate draw item: invalid list");
if (list->items_capacity <= list->items_len + 1)
if (list->capacity <= list->items_len)
{
if (list->items_capacity == 0) list->items_capacity = 128;
else list->items_capacity *= 2;
list->items = (drawitem_t *) Z_Realloc(list->items, sizeof(struct drawitem_s) * list->items_capacity, PU_STATIC, NULL);
list->capacity = list->capacity == 0 ? 128 : list->capacity * 2;
list->items = Z_Realloc(list->items, sizeof(struct drawitem_s) * list->capacity, PU_STATIC, NULL);
list->olditems = Z_Realloc(list->olditems, sizeof(struct drawitem_s) * list->capacity, PU_STATIC, NULL);
}
return list->items_len++;
@@ -178,6 +196,149 @@ static size_t CopyString(huddrawlist_h list, const char* str)
}
}
static void CalcStringCoords(drawitem_t *item, const char *string)
{
if (!(item->flags & V_NOSCALESTART) && cv_uncappedhud.value)
{
INT32 dupx = vid.dupx;
INT32 dupy = vid.dupy;
item->flags |= V_NOSCALESTART;
if (item->flags & V_SCALEPATCHMASK) switch ((item->flags & V_SCALEPATCHMASK) >> V_SCALEPATCHSHIFT)
{
case 1: // V_NOSCALEPATCH
dupx = dupy = 1;
break;
case 2: // V_SMALLSCALEPATCH
dupx = vid.smalldupx;
dupy = vid.smalldupy;
break;
case 3: // V_MEDSCALEPATCH
dupx = vid.meddupx;
dupy = vid.meddupy;
break;
default:
break;
}
// only use one dup, to avoid stretching (har har)
dupx = dupy = (dupx < dupy ? dupx : dupy);
INT32 x = item->x * dupx;
INT32 y = item->y * dupy;
if (item->flags & V_SPLITSCREEN)
y += (BASEVIDHEIGHT * (dupy - 1))/2;
if (item->flags & V_HORZSCREEN)
x += (BASEVIDWIDTH * (dupx - 1))/2;
if (vid.width != BASEVIDWIDTH * dupx)
{
// dupx adjustments pretend that screen width is BASEVIDWIDTH * dupx,
// so center this imaginary screen
if ((item->flags & (V_HORZSCREEN|V_SNAPTOLEFT)) == (V_HORZSCREEN|V_SNAPTOLEFT))
x += (vid.width/2 - (BASEVIDWIDTH/2 * dupx));
else if (item->flags & V_SNAPTORIGHT)
x += (vid.width - (BASEVIDWIDTH * dupx));
else if (!(item->flags & V_SNAPTOLEFT))
x += (vid.width - (BASEVIDWIDTH * dupx)) / 2;
}
if (vid.height != BASEVIDHEIGHT * dupy)
{
// same thing here
if ((item->flags & (V_SPLITSCREEN|V_SNAPTOTOP)) == (V_SPLITSCREEN|V_SNAPTOTOP))
y += (vid.height/2 - (BASEVIDHEIGHT/2 * dupy));
else if (item->flags & V_SNAPTOBOTTOM)
y += (vid.height - (BASEVIDHEIGHT * dupy));
else if (!(item->flags & V_SNAPTOTOP))
y += (vid.height - (BASEVIDHEIGHT * dupy)) / 2;
}
// need to compensate for dup here
if (item->type == DI_DrawString)
{
if (item->align == align_center)
x -= (V_StringWidth(string, item->flags) * (dupx - 1))/2;
if (item->align == align_right)
x -= V_StringWidth(string, item->flags) * (dupx - 1);
if (item->align == align_smallright)
x -= V_SmallStringWidth(string, item->flags) * (dupx - 1);
if (item->align == align_thinright)
x -= V_ThinStringWidth(string, item->flags) * (dupx - 1);
}
item->x = x;
item->y = y;
}
}
static void CalcFillCoords(drawitem_t *item)
{
if (!(item->flags & V_NOSCALESTART) && cv_uncappedhud.value)
{
INT32 dupx = vid.dupx;
INT32 dupy = vid.dupy;
INT32 x = item->x * dupx;
INT32 y = item->y * dupy;
INT32 c = item->c;
item->flags |= V_NOSCALESTART;
item->w *= dupx;
item->h *= dupy;
// Center it if necessary
if (vid.width != BASEVIDWIDTH * dupx)
{
// dupx adjustments pretend that screen width is BASEVIDWIDTH * dupx,
// so center this imaginary screen
if (c & V_SNAPTORIGHT)
x += (vid.width - (BASEVIDWIDTH * dupx));
else if (!(c & V_SNAPTOLEFT))
x += (vid.width - (BASEVIDWIDTH * dupx)) / 2;
}
if (vid.height != BASEVIDHEIGHT * dupy)
{
// same thing here
if (c & V_SNAPTOBOTTOM)
y += (vid.height - (BASEVIDHEIGHT * dupy));
else if (!(c & V_SNAPTOTOP))
y += (vid.height - (BASEVIDHEIGHT * dupy)) / 2;
}
if (c & V_SPLITSCREEN)
y += (BASEVIDHEIGHT * dupy)/2;
if (c & V_HORZSCREEN)
x += (BASEVIDWIDTH * dupx)/2;
item->x = x;
item->y = y;
}
}
#define INTERP_LATCH 1
#define INTERP_STRING 2
#define INTERP_FLAGMASK 0x3
static UINT64 GetItemId(void)
{
if (!hud_interpolate)
return 0;
// leave bits 0 and 1 free for the string mode
UINT64 id = ((uintptr_t)gL->savedpc << 32) | (hud_interpcounter << 10) | (hud_interptag << 2);
if (hud_interplatch)
{
id |= INTERP_LATCH;
hud_interplatch = false;
}
if (hud_interpstring)
id |= INTERP_STRING;
return id;
}
void LUA_HUD_AddDraw(
huddrawlist_h list,
INT32 x,
@@ -189,9 +350,10 @@ void LUA_HUD_AddDraw(
{
size_t i = AllocateDrawItem(list);
drawitem_t *item = &list->items[i];
item->id = GetItemId();
item->type = DI_Draw;
item->x = x;
item->y = y;
item->x = x << FRACBITS;
item->y = y << FRACBITS;
item->patch = patch;
item->flags = flags;
item->colormap = colormap;
@@ -209,6 +371,7 @@ void LUA_HUD_AddDrawScaled(
{
size_t i = AllocateDrawItem(list);
drawitem_t *item = &list->items[i];
item->id = GetItemId();
item->type = DI_DrawScaled;
item->x = x;
item->y = y;
@@ -231,6 +394,7 @@ void LUA_HUD_AddDrawStretched(
{
size_t i = AllocateDrawItem(list);
drawitem_t *item = &list->items[i];
item->id = GetItemId();
item->type = DI_DrawStretched;
item->x = x;
item->y = y;
@@ -251,11 +415,13 @@ void LUA_HUD_AddDrawNum(
{
size_t i = AllocateDrawItem(list);
drawitem_t *item = &list->items[i];
item->id = GetItemId();
item->type = DI_DrawNum;
item->x = x;
item->y = y;
item->num = num;
item->flags = flags;
CalcStringCoords(item, NULL);
}
void LUA_HUD_AddDrawPaddedNum(
@@ -269,12 +435,14 @@ void LUA_HUD_AddDrawPaddedNum(
{
size_t i = AllocateDrawItem(list);
drawitem_t *item = &list->items[i];
item->id = GetItemId();
item->type = DI_DrawPaddedNum;
item->x = x;
item->y = y;
item->num = num;
item->digits = digits;
item->flags = flags;
CalcStringCoords(item, NULL);
}
void LUA_HUD_AddDrawPingNum(
@@ -288,12 +456,14 @@ void LUA_HUD_AddDrawPingNum(
{
size_t i = AllocateDrawItem(list);
drawitem_t *item = &list->items[i];
item->id = GetItemId();
item->type = DI_DrawPingNum;
item->x = x;
item->y = y;
item->num = num;
item->flags = flags;
item->colormap = colormap;
CalcStringCoords(item, NULL);
}
void LUA_HUD_AddDrawFill(
@@ -307,12 +477,14 @@ void LUA_HUD_AddDrawFill(
{
size_t i = AllocateDrawItem(list);
drawitem_t *item = &list->items[i];
item->id = GetItemId();
item->type = DI_DrawFill;
item->x = x;
item->y = y;
item->w = w;
item->h = h;
item->c = c;
CalcFillCoords(item);
}
void LUA_HUD_AddDrawString(
@@ -326,12 +498,15 @@ void LUA_HUD_AddDrawString(
{
size_t i = AllocateDrawItem(list);
drawitem_t *item = &list->items[i];
item->id = GetItemId();
item->type = DI_DrawString;
item->x = x;
item->y = y;
item->stroffset = CopyString(list, str);
item->flags = flags;
item->align = align;
if (item->align != align_fixed)
CalcStringCoords(item, str);
}
void LUA_HUD_AddDrawKartString(
@@ -344,11 +519,13 @@ void LUA_HUD_AddDrawKartString(
{
size_t i = AllocateDrawItem(list);
drawitem_t *item = &list->items[i];
item->id = GetItemId();
item->type = DI_DrawKartString;
item->x = x;
item->y = y;
item->stroffset = CopyString(list, str);
item->flags = flags;
CalcStringCoords(item, str);
}
void LUA_HUD_AddDrawLevelTitle(
@@ -361,11 +538,13 @@ void LUA_HUD_AddDrawLevelTitle(
{
size_t i = AllocateDrawItem(list);
drawitem_t *item = &list->items[i];
item->id = GetItemId();
item->type = DI_DrawLevelTitle;
item->x = x;
item->y = y;
item->stroffset = CopyString(list, str);
item->flags = flags;
CalcStringCoords(item, str);
}
void LUA_HUD_AddFadeScreen(
@@ -376,6 +555,8 @@ void LUA_HUD_AddFadeScreen(
{
size_t i = AllocateDrawItem(list);
drawitem_t *item = &list->items[i];
// nothing to interpolate here
item->id = 0;
item->type = DI_FadeScreen;
item->color = color;
item->strength = strength;
@@ -384,6 +565,11 @@ void LUA_HUD_AddFadeScreen(
void LUA_HUD_DrawList(huddrawlist_h list)
{
size_t i;
size_t j = 0;
fixed_t frac = R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT;
fixed_t lerpx = 0, lerpy = 0;
drawitem_t *latchitem = NULL;
drawitem_t *oldlatchitem = NULL;
if (!list) I_Error("HUD drawlist invalid");
if (list->items_len <= 0) return;
@@ -392,68 +578,117 @@ void LUA_HUD_DrawList(huddrawlist_h list)
for (i = 0; i < list->items_len; i++)
{
drawitem_t *item = &list->items[i];
drawitem_t *olditem = NULL;
const char *itemstr = &list->strbuf[item->stroffset];
if (item->id)
{
// find the old one too
// this is kinda cursed... we need to check every item
// but stop when the first-checked item is reached again
size_t stop = j;
do
{
if (j == list->olditems_len)
{
j = 0;
continue;
}
drawitem_t *old = &list->olditems[j++];
if ((old->id & ~INTERP_FLAGMASK) == (item->id & ~INTERP_FLAGMASK))
{
// gotcha!
olditem = old;
if (item->id & INTERP_LATCH)
{
lerpx = FixedMul(frac, item->x - olditem->x);
lerpy = FixedMul(frac, item->y - olditem->y);
latchitem = item;
oldlatchitem = olditem;
}
else if (!(item->id & INTERP_STRING))
{
lerpx = FixedMul(frac, item->x - olditem->x);
lerpy = FixedMul(frac, item->y - olditem->y);
latchitem = NULL;
}
break;
}
}
while (j != stop);
}
else
{
lerpx = lerpy = 0;
latchitem = NULL;
}
#define LERP(it) (olditem ? olditem->it + FixedMul(frac, item->it - olditem->it) : item->it)
// half of this could be done when the coordinates are latched... zzzzzz
#define LERPS(it) (latchitem ? ((latchitem->it + (item->it - latchitem->it)) - (latchitem->it - oldlatchitem->it)) + lerp##it : (olditem ? olditem->it + lerp##it : item->it))
//define LERPS(it) (olditem ? (latchitem ? (latchitem->it + (item->it - latchitem->it)) - (latchitem->it - oldlatchitem->it) : olditem->it) + lerp##it : item->it)
switch (item->type)
{
case DI_Draw:
V_DrawFixedPatch(item->x<<FRACBITS, item->y<<FRACBITS, FRACUNIT, item->flags, item->patch, item->colormap);
V_DrawFixedPatch(LERPS(x), LERPS(y), FRACUNIT, item->flags, item->patch, item->colormap);
break;
case DI_DrawScaled:
V_DrawFixedPatch(item->x, item->y, item->scale, item->flags, item->patch, item->colormap);
V_DrawFixedPatch(LERPS(x), LERPS(y), LERP(scale), item->flags, item->patch, item->colormap);
break;
case DI_DrawStretched:
V_DrawStretchyFixedPatch(item->x, item->y, item->hscale, item->vscale, item->flags, item->patch, item->colormap);
V_DrawStretchyFixedPatch(LERPS(x), LERPS(y), LERP(hscale), LERP(vscale), item->flags, item->patch, item->colormap);
break;
case DI_DrawNum:
V_DrawTallNum(item->x, item->y, item->flags, item->num);
V_DrawTallNum(LERPS(x), LERPS(y), item->flags, item->num);
break;
case DI_DrawPaddedNum:
V_DrawPaddedTallNum(item->x, item->y, item->flags, item->num, item->digits);
V_DrawPaddedTallNum(LERPS(x), LERPS(y), item->flags, item->num, item->digits);
break;
case DI_DrawPingNum:
V_DrawPingNum(item->x, item->y, item->flags, item->num, item->colormap);
V_DrawPingNum(LERPS(x), LERPS(y), item->flags, item->num, item->colormap);
break;
case DI_DrawFill:
V_DrawFill(item->x, item->y, item->w, item->h, item->c);
V_DrawFill(LERPS(x), LERPS(y), LERP(w), LERP(h), item->c);
break;
case DI_DrawString:
switch(item->align)
{
// hu_font
case align_left:
V_DrawString(item->x, item->y, item->flags, itemstr);
V_DrawString(LERPS(x), LERPS(y), item->flags, itemstr);
break;
case align_center:
V_DrawCenteredString(item->x, item->y, item->flags, itemstr);
V_DrawCenteredString(LERPS(x), LERPS(y), item->flags, itemstr);
break;
case align_right:
V_DrawRightAlignedString(item->x, item->y, item->flags, itemstr);
V_DrawRightAlignedString(LERPS(x), LERPS(y), item->flags, itemstr);
break;
case align_fixed:
V_DrawStringAtFixed(item->x, item->y, item->flags, itemstr);
V_DrawStringAtFixed(LERPS(x), LERPS(y), item->flags, itemstr);
break;
// hu_font, 0.5x scale
case align_small:
V_DrawSmallString(item->x, item->y, item->flags, itemstr);
V_DrawSmallString(LERPS(x), LERPS(y), item->flags, itemstr);
break;
case align_smallright:
V_DrawRightAlignedSmallString(item->x, item->y, item->flags, itemstr);
V_DrawRightAlignedSmallString(LERPS(x), LERPS(y), item->flags, itemstr);
break;
// tny_font
case align_thin:
V_DrawThinString(item->x, item->y, item->flags, itemstr);
V_DrawThinString(LERPS(x), LERPS(y), item->flags, itemstr);
break;
case align_thinright:
V_DrawRightAlignedThinString(item->x, item->y, item->flags, itemstr);
V_DrawRightAlignedThinString(LERPS(x), LERPS(y), item->flags, itemstr);
break;
}
break;
case DI_DrawKartString:
V_DrawKartString(item->x, item->y, item->flags, itemstr);
V_DrawKartString(LERPS(x), LERPS(y), item->flags, itemstr);
break;
case DI_DrawLevelTitle:
V_DrawLevelTitle(item->x, item->y, item->flags, itemstr);
V_DrawLevelTitle(LERPS(x), LERPS(y), item->flags, itemstr);
break;
case DI_FadeScreen:
V_DrawFadeScreen(item->color, item->strength);
+1 -8
View File
@@ -121,14 +121,7 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedDiv(fixed_t a, fixed_t b)
*/
FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRem(fixed_t x, fixed_t y)
{
const boolean n = x < 0;
x = abs(x);
while (x >= y)
x -= y;
if (n)
return -x;
else
return x;
return x % y;
}
/** \brief The FixedSqrt function
+82 -22
View File
@@ -58,6 +58,7 @@
#ifdef HWRENDER
#include "hardware/hw_main.h"
#include "hardware/r_opengl/r_opengl.h"
#endif
#include "d_net.h"
@@ -1339,9 +1340,9 @@ static menuitem_t OP_VideoOptionsMenu[] =
{IT_SUBMENU|IT_STRING, NULL, "Advanced Color Settings...", &OP_ColorOptionsDef, 50},
{IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 65},
{IT_STRING | IT_CVAR, NULL, "Weather Draw Distance",&cv_drawdist_precip, 75},
{IT_STRING | IT_CVAR, NULL, "Field of View", &cv_fov, 95},
{IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 65},
{IT_STRING | IT_CVAR, NULL, "Weather Draw Distance",&cv_drawdist_precip, 75},
{IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Field of View", &cv_fov, 95},
{IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 105},
{IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 115},
@@ -1451,26 +1452,29 @@ static menuitem_t OP_ColorOptionsMenu[] =
static menuitem_t OP_ExpOptionsMenu[] =
{
{IT_HEADER, NULL, "Experimental Options", NULL, 10},
{IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_grmaxinterpdist, 25},
{IT_STRING|IT_CVAR, NULL, "Mobj Subsector Interpolation", &cv_mobjssector, 35},
{IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 45},
{IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 55},
{IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_grmaxinterpdist, 20},
{IT_STRING|IT_CVAR, NULL, "Mobj Subsector Interpolation", &cv_mobjssector, 25},
{IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 30},
{IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 35},
{IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 70},
{IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 42},
{IT_STRING | IT_CVAR, NULL, "Clipping R_PointToAngle Version", &cv_pointoangleexor64, 85},
{IT_STRING | IT_CVAR, NULL, "Clipping R_PointToAngle Version", &cv_pointoangleexor64, 49},
{IT_STRING | IT_CVAR, NULL, "FFloorclip", &cv_ffloorclip, 95},
{IT_STRING | IT_CVAR, NULL, "Spriteclip", &cv_spriteclip, 105},
{IT_STRING | IT_CVAR, NULL, "FFloorclip", &cv_ffloorclip, 56},
{IT_STRING | IT_CVAR, NULL, "Spriteclip", &cv_spriteclip, 61},
#ifdef HWRENDER
{IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 95},
{IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 68},
#ifdef USE_FBO_OGL
{IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_grframebuffer, 73},
#endif
{IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 105},
{IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 80},
{IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 125},
{IT_STRING | IT_CVAR, NULL, "Slope midtexture peg fix", &cv_slopepegfix, 135},
{IT_STRING | IT_CVAR, NULL, "ZFighting fix for fofs", &cv_fofzfightfix, 145},
{IT_STRING | IT_CVAR, NULL, "FOF wall cutoff for slopes", &cv_grfofcut, 155},
{IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 87},
{IT_STRING | IT_CVAR, NULL, "Slope midtexture peg fix", &cv_slopepegfix, 92},
{IT_STRING | IT_CVAR, NULL, "ZFighting fix for fofs", &cv_fofzfightfix, 97},
{IT_STRING | IT_CVAR, NULL, "FOF wall cutoff for slopes", &cv_grfofcut, 102},
#endif
};
@@ -1487,6 +1491,9 @@ static const char* OP_ExpTooltips[] =
"Hides Sprites which are not visible\npotentially resulting in a performance boost.",
#ifdef HWRENDER
"Should the game do Screen Textures? Provides a good boost to frames\nat the cost of some visual effects not working when disabled.",
#ifdef USE_FBO_OGL
"Allows the game to downsample from a higher resolution than your display in OpenGL renderer mode\nrequires a GPU with atleast OpenGL 3.0 support.",
#endif
"Change the depth of the Palette in Palette rendering mod\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.",
"Fixes issues that resulted in Textures sticking from the ground sometimes.\n This may be CPU heavy and result in worse performance in some cases.",
"Fixes issues that resulted in Textures not being properly skewed\n example: Fences on slopes that didnt show proper.\n This may be CPU heavy and result in worse performance in some cases.",
@@ -1508,6 +1515,10 @@ enum
op_exp_sprclip,
#ifdef HWRENDER
op_exp_grscrtx,
#ifdef USE_FBO_OGL
op_exp_fbo,
#endif
op_exp_paldepth,
op_exp_spltwal,
op_exp_pegging,
op_exp_fofzfight,
@@ -2351,7 +2362,7 @@ static menuitem_t OP_DriftGaugeMenu[] =
{IT_HEADER, NULL, "Driftgauge", NULL, 0},
{IT_STRING | IT_CVAR, NULL, "Driftgauge", &cv_driftgauge, 20},
{IT_STRING | IT_CVAR, NULL, "Driftgauge Transparency", &cv_driftgaugetrans, 30},
{IT_STRING | IT_CVAR, NULL, "Driftgauge Offset", &cv_driftgaugeofs, 40},
{IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Driftgauge Offset", &cv_driftgaugeofs, 40},
{IT_STRING | IT_CVAR, NULL, "Driftgauge Style", &cv_driftgaugestyle, 50},
};
@@ -2909,7 +2920,7 @@ menu_t OP_MonitorToggleDef =
menu_t OP_OpenGLOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_OpenGLOptionsMenu, &OP_VideoOptionsDef, 30, 30);
#endif
menu_t OP_ExpOptionsDef = DEFAULTMENUSTYLE("M_VIDEO", OP_ExpOptionsMenu, &OP_VideoOptionsDef, 30, 20);
menu_t OP_ExpOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_ExpOptionsMenu, &OP_VideoOptionsDef, 30, 35);
menu_t OP_DataOptionsDef = DEFAULTMENUSTYLE("M_DATA", OP_DataOptionsMenu, &OP_MainDef, 60, 30);
menu_t OP_ScreenshotOptionsDef = DEFAULTMENUSTYLE("M_SCSHOT", OP_ScreenshotOptionsMenu, &OP_DataOptionsDef, 30, 30);
@@ -3305,7 +3316,11 @@ static void M_ChangeCvar(INT32 choice)
else if (cv->flags & CV_FLOAT)
{
char s[20];
sprintf(s,"%f",FIXED_TO_FLOAT(cv->value)+(choice)*(1.0f/16.0f));
float increment;
increment = (currentMenu->menuitems[itemOn].status & IT_CV_BIGFLOAT) ? 0.5 : (1.f/16);
sprintf(s,"%f",FIXED_TO_FLOAT(cv->value)+(choice)*increment);
CV_Set(cv,s);
}
else
@@ -3418,6 +3433,11 @@ static void Command_Manual_f(void)
itemOn = 0;
}
boolean DPADUPSCROLL = false;
boolean DPADDOWNSCROLL = false;
boolean DPADLEFTSCROLL = false;
boolean DPADRIGHTSCROLL = false;
//
// M_Responder
//
@@ -3449,7 +3469,6 @@ boolean M_Responder(event_t *ev)
{
ch = ev->data1;
// added 5-2-98 remap virtual keys (mouse & joystick buttons)
switch (ch)
{
case KEY_MOUSE1:
@@ -3477,6 +3496,40 @@ boolean M_Responder(event_t *ev)
ch = KEY_RIGHTARROW;
break;
}
switch (ev->data1) // if you pressed it set those to true
{
case KEY_HAT1:
DPADUPSCROLL = true;
break;
case KEY_HAT1 + 1:
DPADDOWNSCROLL = true;
break;
case KEY_HAT1 + 2:
DPADLEFTSCROLL = true;
break;
case KEY_HAT1 + 3:
DPADRIGHTSCROLL = true;
break;
}
}
else if (ev->type == ev_keyup)
{
switch (ev->data1) // if you let go of those set those to false
{
case KEY_HAT1:
DPADUPSCROLL = false;
break;
case KEY_HAT1 + 1:
DPADDOWNSCROLL = false;
break;
case KEY_HAT1 + 2:
DPADLEFTSCROLL = false;
break;
case KEY_HAT1 + 3:
DPADRIGHTSCROLL = false;
break;
}
}
else if (menuactive)
{
@@ -4464,16 +4517,23 @@ void M_Init(void)
{
OP_VideoOptionsMenu[op_video_ogl].status = IT_DISABLED;
OP_ExpOptionsMenu[op_exp_grscrtx].status = IT_DISABLED;
#ifdef USE_FBO_OGL
OP_ExpOptionsMenu[op_exp_fbo].status = IT_DISABLED;
#endif
OP_ExpOptionsMenu[op_exp_spltwal].status = IT_DISABLED;
OP_ExpOptionsMenu[op_exp_pegging].status = IT_DISABLED;
OP_ExpOptionsMenu[op_exp_fofzfight].status = IT_DISABLED;
OP_ExpOptionsMenu[op_exp_fofcut].status = IT_DISABLED;
}
if (rendermode == render_opengl)
{
OP_ExpOptionsMenu[op_exp_ffclip].status = IT_DISABLED;
OP_ExpOptionsMenu[op_exp_sprclip].status = IT_DISABLED;
#ifdef USE_FBO_OGL
if (!supportFBO)
OP_ExpOptionsMenu[op_exp_fbo].status = IT_GRAYEDOUT;
#endif
}
#endif
+9
View File
@@ -74,6 +74,11 @@ typedef enum
} menumessagetype_t;
void M_StartMessage(const char *string, void *routine, menumessagetype_t itemtype);
extern boolean DPADUPSCROLL;
extern boolean DPADDOWNSCROLL;
extern boolean DPADLEFTSCROLL;
extern boolean DPADRIGHTSCROLL;
typedef enum
{
M_NOT_WAITING,
@@ -129,6 +134,10 @@ extern boolean menu_text_input;
#define IT_CV_NOMOD 2048
#define IT_CV_INVISSLIDER 2560
// For cv_float's, will use 1/2 as increment instead of 1/16
// Not sure if i should add it to cvartype, since its more a flag than type
#define IT_CV_BIGFLOAT 4096
//call/submenu specific
// There used to be a lot more here but ...
// A lot of them became redundant with the advent of the Pause menu, so they were removed
+1 -1
View File
@@ -1589,7 +1589,7 @@ char *va(const char *format, ...)
static char string[1024];
va_start(argptr, format);
vsprintf(string, format, argptr);
vsnprintf(string, 1024, format, argptr);
va_end(argptr);
return string;
+1
View File
@@ -1936,6 +1936,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source)
target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SPECIAL);
target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL);
target->health = 0; // This makes it easy to check if something's dead elsewhere.
target->shadowscale = 0;
if (LUAh_MobjDeath(target, inflictor, source) || P_MobjWasRemoved(target))
return;
+3 -2
View File
@@ -239,7 +239,7 @@ void P_RespawnSpecials(void);
mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type);
mobj_t *P_SpawnShadowMobj(mobj_t * caster);
//mobj_t *P_SpawnShadowMobj(mobj_t * caster);
void P_RecalcPrecipInSector(sector_t *sector);
void P_PrecipitationEffects(void);
@@ -251,7 +251,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state);
boolean P_SetMobjState(mobj_t *mobj, statenum_t state);
//void P_RunShields(void);
void P_RunOverlays(void);
void P_RunShadows(void);
//void P_RunShadows(void);
void P_MobjThinker(mobj_t *mobj);
boolean P_RailThinker(mobj_t *mobj);
void P_PushableThinker(mobj_t *mobj);
@@ -387,6 +387,7 @@ extern INT32 bmapheight; // in mapblocks
extern fixed_t bmaporgx;
extern fixed_t bmaporgy; // origin of block map
extern mobj_t **blocklinks; // for thing chains
extern precipmobj_t **precipblocklinks; // special blockmap for precip rendering
//
// P_INTER
+40 -30
View File
@@ -754,15 +754,45 @@ void P_UnsetThingPosition(mobj_t *thing)
void P_UnsetPrecipThingPosition(precipmobj_t *thing)
{
precipmobj_t **sprev = thing->sprev;
precipmobj_t *snext = thing->snext;
if ((*sprev = snext) != NULL) // unlink from sector list
snext->sprev = sprev;
precipmobj_t **bprev = thing->bprev;
precipmobj_t *bnext = thing->bnext;
if (bprev && (*bprev = bnext) != NULL) // unlink from block map
bnext->bprev = bprev;
precipsector_list = thing->touching_sectorlist;
thing->touching_sectorlist = NULL; //to be restored by P_SetPrecipThingPosition
}
static void P_LinkToBlockMap(mobj_t *thing, mobj_t **bmap)
{
const INT32 blockx = (unsigned)(thing->x - bmaporgx) >> MAPBLOCKSHIFT;
const INT32 blocky = (unsigned)(thing->y - bmaporgy) >> MAPBLOCKSHIFT;
if (blockx >= 0 && blockx < bmapwidth
&& blocky >= 0 && blocky < bmapheight)
{
// killough 8/11/98: simpler scheme using
// pointer-to-pointer prev pointers --
// allows head nodes to be treated like everything else
mobj_t **link = &bmap[(blocky * bmapwidth) + blockx];
mobj_t *bnext = *link;
thing->bnext = bnext;
if (bnext != NULL)
bnext->bprev = &thing->bnext;
thing->bprev = link;
*link = thing;
}
else // thing is off the map
{
thing->bnext = NULL, thing->bprev = NULL;
}
}
//
// P_SetThingPosition
// Links a thing into both a block and a subsector
@@ -819,24 +849,7 @@ void P_SetThingPosition(mobj_t *thing)
if (!(thing->flags & MF_NOBLOCKMAP))
{
// inert things don't need to be in blockmap
const INT32 blockx = (unsigned)(thing->x - bmaporgx)>>MAPBLOCKSHIFT;
const INT32 blocky = (unsigned)(thing->y - bmaporgy)>>MAPBLOCKSHIFT;
if (blockx >= 0 && blockx < bmapwidth
&& blocky >= 0 && blocky < bmapheight)
{
// killough 8/11/98: simpler scheme using
// pointer-to-pointer prev pointers --
// allows head nodes to be treated like everything else
mobj_t **link = &blocklinks[blocky*bmapwidth + blockx];
mobj_t *bnext = *link;
if ((thing->bnext = bnext) != NULL)
bnext->bprev = &thing->bnext;
thing->bprev = link;
*link = thing;
}
else // thing is off the map
thing->bnext = NULL, thing->bprev = NULL;
P_LinkToBlockMap(thing, blocklinks);
}
// Allows you to 'step' on a new linedef exec when the previous
@@ -891,18 +904,15 @@ void P_SetUnderlayPosition(mobj_t *thing)
void P_SetPrecipitationThingPosition(precipmobj_t *thing)
{
subsector_t *ss = thing->subsector = R_PointInSubsector(thing->x, thing->y);
precipmobj_t **link = &ss->sector->preciplist;
precipmobj_t *snext = *link;
if ((thing->snext = snext) != NULL)
snext->sprev = &thing->snext;
thing->sprev = link;
*link = thing;
thing->subsector = R_PointInSubsector(thing->x, thing->y);
P_CreatePrecipSecNodeList(thing, thing->x, thing->y);
thing->touching_sectorlist = precipsector_list; // Attach to Thing's precipmobj_t
precipsector_list = NULL; // clear for next time
// NOTE: this works because bnext/bprev are at the same
// offsets in precipmobj_t and mobj_t
P_LinkToBlockMap((mobj_t*)thing, (mobj_t**)precipblocklinks);
}
//
+110 -27
View File
@@ -46,7 +46,7 @@ consvar_t cv_splats = {"splats", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0
actioncache_t actioncachehead;
static mobj_t *overlaycap = NULL;
static mobj_t *shadowcap = NULL;
//static mobj_t *shadowcap = NULL;
mobj_t *waypointcap = NULL;
void P_InitCachedActions(void)
@@ -1329,7 +1329,7 @@ void P_XYMovement(mobj_t *mo)
fixed_t oldx, oldy; // reducing bobbing/momentum on ice when up against walls
boolean moved;
pslope_t *oldslope = NULL;
vector3_t slopemom;
vector3_t slopemom = {0,0,0};
fixed_t predictedz = 0;
I_Assert(mo != NULL);
@@ -3232,6 +3232,7 @@ void P_DestroyRobots(void)
boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled)
{
boolean itsatwodlevel = false;
boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP);
postimg_t postimg = postimg_none;
UINT8 i;
@@ -3254,10 +3255,12 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
}
}
if (encoremode)
if (encoremode && !flipcam)
postimg = postimg_mirror;
else if (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP)
else if (!encoremode && flipcam)
postimg = postimg_flip;
else if (encoremode && flipcam)
postimg = postimg_mirrorflip;
else if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist
{
camera_t dummycam;
@@ -3409,11 +3412,15 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
mobj->z += mobj->momz;
P_SetThingPosition(mobj);
P_CheckPosition(mobj, mobj->x, mobj->y);
mobj->floorz = tmfloorz;
mobj->ceilingz = tmceilingz;
goto animonly;
}
else if (mobj->player->pflags & PF_MACESPIN && mobj->tracer)
{
P_CheckPosition(mobj, mobj->x, mobj->y);
mobj->floorz = tmfloorz;
mobj->ceilingz = tmceilingz;
goto animonly;
}
@@ -4978,18 +4985,17 @@ static void P_Boss9Thinker(mobj_t *mobj)
mobj->angle -= InvAngle(angle)/8;
// Spawn energy particles
for (spawner = mobj->hnext; spawner; spawner = spawner->hnext) {
for (spawner = mobj->hnext; spawner; spawner = spawner->hnext)
{
dist = P_AproxDistance(spawner->x - mobj->x, spawner->y - mobj->y);
if (P_RandomRange(1,(dist>>FRACBITS)/16) == 1)
break;
}
if (spawner) {
if (spawner && dist)
{
mobj_t *missile = P_SpawnMissile(spawner, mobj, MT_MSGATHER);
missile->momz = FixedDiv(missile->momz, 7*FRACUNIT/4);
if (dist == 0)
missile->fuse = 0;
else
missile->fuse = (dist/P_AproxDistance(missile->momx, missile->momy));
missile->fuse = (dist/P_AproxDistance(missile->momx, missile->momy));
if (missile->fuse > mobj->fuse)
P_RemoveMobj(missile);
}
@@ -5768,7 +5774,7 @@ static void P_RemoveOverlay(mobj_t *thing)
}
}
void P_RunShadows(void)
/*void P_RunShadows(void)
{
mobj_t *mobj, *next, *dest;
@@ -5835,11 +5841,11 @@ void P_RunShadows(void)
P_SetScale(mobj, mobj->scale/3);
}
P_SetTarget(&shadowcap, NULL);
}
}*/
// called whenever shadows think
// It must be done this way so that level changes don't break when the shadowcap can't be reset
static void P_AddShadow(mobj_t *thing)
/*static void P_AddShadow(mobj_t *thing)
{
I_Assert(thing != NULL);
@@ -5879,7 +5885,7 @@ static void P_RemoveShadow(mobj_t *thing)
P_SetTarget(&thing->hnext, NULL);
return;
}
}
}*/
void A_BossDeath(mobj_t *mo);
// AI for the Koopa boss.
@@ -6172,7 +6178,7 @@ void P_MobjThinker(mobj_t *mobj)
P_AddOverlay(mobj);
break;
case MT_SHADOW:
/*case MT_SHADOW:
if (!mobj->target)
{
P_RemoveMobj(mobj);
@@ -6185,7 +6191,7 @@ void P_MobjThinker(mobj_t *mobj)
mobj->sloperoll = mobj->target->sloperoll;
}
P_AddShadow(mobj);
break;
break;*/
//{ SRB2kart mobs
case MT_ORBINAUT_SHIELD: // Kart orbit/trail items
case MT_JAWZ_SHIELD:
@@ -9283,6 +9289,65 @@ void P_SceneryThinker(mobj_t *mobj)
// GAME SPAWN FUNCTIONS
//
static void P_DefaultMobjShadowScale(mobj_t *thing)
{
thing->shadowscale = 0;
thing->whiteshadow = (thing->frame & FF_FULLBRIGHT);
// Those have shadow by default
switch (thing->type)
{
case MT_PLAYER:
case MT_SMALLMACE:
case MT_BIGMACE:
case MT_PUMA:
case MT_BIGPUMA:
case MT_FALLINGROCK:
case MT_SMK_MOLE:
case MT_SMK_THWOMP:
case MT_BATTLEBUMPER:
case MT_BANANA:
case MT_ORBINAUT:
case MT_ORBINAUT_SHIELD:
case MT_JAWZ:
case MT_JAWZ_DUD:
case MT_JAWZ_SHIELD:
case MT_SSMINE:
case MT_SSMINE_SHIELD:
case MT_BALLHOG:
case MT_SINK:
case MT_THUNDERSHIELD:
case MT_ROCKETSNEAKER:
case MT_SPB:
thing->shadowscale = 4*FRACUNIT/3;
thing->haveshadow = true;
break;
case MT_BANANA_SHIELD:
thing->shadowscale = 12*FRACUNIT/5;
thing->haveshadow = true;
break;
/*case MT_RANDOMITEM:
thing->shadowscale = FRACUNIT/2;
thing->whiteshadow = false;
break;
case MT_EGGMANITEM:
thing->shadowscale = FRACUNIT;
thing->whiteshadow = false;
break;
case MT_EGGMANITEM_SHIELD:
thing->shadowscale = 3*FRACUNIT/2;
thing->whiteshadow = false;
break;*/
case MT_FLOATINGITEM:
thing->shadowscale = FRACUNIT/2;
thing->haveshadow = true;
break;
default:
thing->shadowscale = 4*FRACUNIT/3;;
break;
}
}
//
// P_SpawnMobj
//
@@ -9393,6 +9458,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
mobj->colorized = false;
// Set shadowscale here, before spawn hook so that Lua can change it
P_DefaultMobjShadowScale(mobj);
// DANGER! This can cause P_SpawnMobj to return NULL!
// Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks!
if (LUAh_MobjSpawn(mobj))
@@ -9686,7 +9754,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
if (!(mobj->flags & MF_NOTHINK))
P_AddThinker(&mobj->thinker); // Needs to come before the shadow spawn, or else the shadow's reference gets forgotten
switch (mobj->type)
/*switch (mobj->type)
{
case MT_PLAYER:
case MT_SMALLMACE: case MT_BIGMACE:
@@ -9707,7 +9775,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
P_SpawnShadowMobj(mobj);
default:
break;
}
}*/
// Call action functions when the state is set
if (st->action.acp1 && (mobj->flags & MF_RUNSPAWNFUNC))
@@ -9746,7 +9814,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
// P_SpawnShadowMobj
// warning: Do not send a shadow mobj as a caster into here, or try to spawn spawn shadows for shadows in P_SpawnMobj, we do not want recursive shadows
//
mobj_t *P_SpawnShadowMobj(mobj_t * caster)
/*mobj_t *P_SpawnShadowMobj(mobj_t * caster)
{
const mobjinfo_t *info = &mobjinfo[MT_SHADOW];
state_t *st;
@@ -9856,7 +9924,7 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster)
R_AddMobjInterpolator(mobj);
return mobj;
}
}*/
static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
{
@@ -9973,8 +10041,8 @@ void P_RemoveMobj(mobj_t *mobj)
if (mobj->type == MT_OVERLAY)
P_RemoveOverlay(mobj);
if (mobj->type == MT_SHADOW)
P_RemoveShadow(mobj);
//if (mobj->type == MT_SHADOW)
//P_RemoveShadow(mobj);
if (mobj->type == MT_SPB)
spbplace = -1;
@@ -10147,6 +10215,9 @@ void P_SpawnPrecipitation(void)
//for (j = 0; j < cv_precipdensity.value; ++j) -- density is 1 for kart always
{
INT32 floorz;
INT32 ceilingz;
x = ((cv_lessprecip.value ? basex*1.5 : basex) + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3));
y = ((cv_lessprecip.value ? basey*1.5 : basey) + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3));
@@ -10180,8 +10251,19 @@ void P_SpawnPrecipitation(void)
else // everything else.
rainmo = P_SpawnRainMobj(x, y, height, MT_RAIN);
// Randomly assign a height, now that floorz is set.
rainmo->z = M_RandomRange(rainmo->floorz>>FRACBITS, rainmo->ceilingz>>FRACBITS)<<FRACBITS;
floorz = rainmo->floorz >> FRACBITS;
ceilingz = rainmo->ceilingz >> FRACBITS;
if (floorz < ceilingz)
{
// Randomly assign a height, now that floorz is set.
rainmo->z = M_RandomRange(floorz, ceilingz) << FRACBITS;
}
else
{
// ...except if the floor is above the ceiling.
rainmo->z = ceilingz << FRACBITS;
}
}
}
@@ -10270,7 +10352,8 @@ void P_PrecipitationEffects(void)
volume = 255; // Sky above? We get it full blast.
else
{
fixed_t x, y, yl, yh, xl, xh;
/* GCC is optimizing away y >= yl, FUCK YOU */
volatile fixed_t x, y, yl, yh, xl, xh;
fixed_t closedist, newdist;
// Essentially check in a 1024 unit radius of the player for an outdoor area.
@@ -10279,8 +10362,8 @@ void P_PrecipitationEffects(void)
xl = players[displayplayers[0]].mo->x - 1024*FRACUNIT;
xh = players[displayplayers[0]].mo->x + 1024*FRACUNIT;
closedist = 2048*FRACUNIT;
for (y = yl; y <= yh; y += FRACUNIT*64)
for (x = xl; x <= xh; x += FRACUNIT*64)
for (y = yl; y >= yl && y <= yh; y += FRACUNIT*64)
for (x = xl; x >= xl && x <= xh; x += FRACUNIT*64)
{
if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum) // Found the outdoors!
{
+13 -8
View File
@@ -275,12 +275,12 @@ typedef struct mobj_s
// Info for drawing: position.
fixed_t x, y, z;
fixed_t old_x, old_y, old_z; // position interpolation
fixed_t old_x, old_y, old_z, old_floorz; // position interpolation
fixed_t old_x2, old_y2, old_z2;
// More list: links in sector (if needed)
struct mobj_s *snext;
struct mobj_s **sprev; // killough 8/11/98: change to ptr-to-ptr
struct mobj_s *bnext;
struct mobj_s **bprev; // killough 8/11/98: change to ptr-to-ptr
// More drawing info: to determine current sprite.
angle_t angle, pitch, roll; // orientation
@@ -338,8 +338,8 @@ typedef struct mobj_s
// Interaction info, by BLOCKMAP.
// Links in blocks (if needed).
struct mobj_s *bnext;
struct mobj_s **bprev; // killough 8/11/98: change to ptr-to-ptr
struct mobj_s *snext;
struct mobj_s **sprev; // killough 8/11/98: change to ptr-to-ptr
// Additional pointers for NiGHTS hoops
struct mobj_s *hnext;
@@ -398,6 +398,11 @@ typedef struct mobj_s
boolean resetinterp; // if true, some fields should not be interpolated (see R_InterpolateMobjState implementation)
boolean colorized; // Whether the mobj uses the rainbow colormap
boolean haveshadow;
fixed_t shadowscale; // If this object casts a shadow, and the size relative to radius
boolean whiteshadow; // Use white shadow, set to true by default for fullbright objects
boolean mirrored; // The object's rotations will be mirrored left to right, e.g., see frame AL from the right and AR from the left
boolean rollmodel; // OpenGL: Should this model rotate?
@@ -428,12 +433,12 @@ typedef struct precipmobj_s
// Info for drawing: position.
fixed_t x, y, z;
fixed_t old_x, old_y, old_z; // position interpolation
fixed_t old_x, old_y, old_z, old_floorz; // position interpolation
fixed_t old_x2, old_y2, old_z2;
// More list: links in sector (if needed)
struct precipmobj_s *snext;
struct precipmobj_s **sprev; // killough 8/11/98: change to ptr-to-ptr
struct precipmobj_s *bnext;
struct precipmobj_s **bprev; // killough 8/11/98: change to ptr-to-ptr
// More drawing info: to determine current sprite.
angle_t angle, pitch, roll; // orientation
+3 -3
View File
@@ -1206,7 +1206,7 @@ static boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y)
// http://www.inversereality.org/tutorials/graphics%20programming/2dtransformations.html
// It is, of course, just a vector-matrix multiplication.
//
static inline void Polyobj_rotatePoint(vertex_t *v, const vertex_t *c, angle_t ang)
static inline void Polyobj_rotatePoint(vertex_t *v, const vector2_t *c, angle_t ang)
{
vertex_t tmp = *v;
@@ -1267,7 +1267,7 @@ static void Polyobj_rotateLine(line_t *ld)
//
// Causes objects resting on top of the rotating polyobject to 'ride' with its movement.
//
static void Polyobj_rotateThings(polyobj_t *po, vertex_t origin, angle_t delta, UINT8 turnthings)
static void Polyobj_rotateThings(polyobj_t *po, vector2_t origin, angle_t delta, UINT8 turnthings)
{
static INT32 pomovecount = 10000;
INT32 x, y;
@@ -1367,7 +1367,7 @@ static boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings)
{
size_t i;
angle_t angle;
vertex_t origin;
vector2_t origin;
INT32 hitflags = 0;
// don't move bad polyobjects
+13 -32
View File
@@ -127,6 +127,7 @@ INT32 *blockmaplump; // Big blockmap
fixed_t bmaporgx, bmaporgy;
// for thing chains
mobj_t **blocklinks;
precipmobj_t **precipblocklinks;
// REJECT
// For fast sight rejection.
@@ -714,7 +715,7 @@ static void P_LoadRawSectors(UINT8 *data, size_t i)
ss->thinglist = NULL;
ss->touching_thinglist = NULL;
ss->preciplist = NULL;
ss->touching_preciplist = NULL;
ss->floordata = NULL;
@@ -1948,6 +1949,9 @@ static void P_CreateBlockMap(void)
// haleyjd 2/22/06: setup polyobject blockmap
count = sizeof(*polyblocklinks) * bmapwidth * bmapheight;
polyblocklinks = Z_Calloc(count, PU_LEVEL, NULL);
count = sizeof (*precipblocklinks)* bmapwidth*bmapheight;
precipblocklinks = Z_Calloc(count, PU_LEVEL, NULL);
}
}
@@ -1982,10 +1986,6 @@ static void P_ReadBlockMapLump(INT16 *wadblockmaplump, size_t count)
// this should return false.
static boolean P_LoadBlockMap(lumpnum_t lumpnum)
{
#if 0
(void)lumpnum;
return false;
#else
size_t count;
const char *lumpname = W_CheckNameForNum(lumpnum);
@@ -2023,27 +2023,11 @@ static boolean P_LoadBlockMap(lumpnum_t lumpnum)
// haleyjd 2/22/06: setup polyobject blockmap
count = sizeof(*polyblocklinks) * bmapwidth * bmapheight;
polyblocklinks = Z_Calloc(count, PU_LEVEL, NULL);
count = sizeof (*precipblocklinks)* bmapwidth*bmapheight;
precipblocklinks = Z_Calloc(count, PU_LEVEL, NULL);
return true;
/* Original
blockmaplump = W_CacheLumpNum(lump, PU_LEVEL);
blockmap = blockmaplump+4;
count = W_LumpLength (lump)/2;
for (i = 0; i < count; i++)
blockmaplump[i] = SHORT(blockmaplump[i]);
bmaporgx = blockmaplump[0]<<FRACBITS;
bmaporgy = blockmaplump[1]<<FRACBITS;
bmapwidth = blockmaplump[2];
bmapheight = blockmaplump[3];
}
// clear out mobj chains
count = sizeof (*blocklinks)*bmapwidth*bmapheight;
blocklinks = Z_Calloc(count, PU_LEVEL, NULL);
return true;
*/
#endif
}
// This needs to be a separate function
@@ -2052,12 +2036,6 @@ static boolean P_LoadBlockMap(lumpnum_t lumpnum)
// -- Monster Iestyn 09/01/18
static boolean P_LoadRawBlockMap(UINT8 *data, size_t count, const char *lumpname)
{
#if 0
(void)data;
(void)count;
(void)lumpname;
return false;
#else
// Check if the lump is named "BLOCKMAP"
if (!lumpname || memcmp(lumpname, "BLOCKMAP", 8) != 0)
{
@@ -2087,8 +2065,11 @@ static boolean P_LoadRawBlockMap(UINT8 *data, size_t count, const char *lumpname
// haleyjd 2/22/06: setup polyobject blockmap
count = sizeof(*polyblocklinks) * bmapwidth * bmapheight;
polyblocklinks = Z_Calloc(count, PU_LEVEL, NULL);
count = sizeof (*precipblocklinks)* bmapwidth*bmapheight;
precipblocklinks = Z_Calloc(count, PU_LEVEL, NULL);
return true;
#endif
}
//
+5 -1
View File
@@ -82,8 +82,12 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
// move chasecam at new player location
for (i = 0; i <= splitscreen; i++)
{
if (thing->player == &players[displayplayers[i]] && camera[i].chase)
if (thing->player != &players[displayplayers[i]])
continue;
if (camera[i].chase)
P_ResetCamera(thing->player, &camera[i]);
R_ResetViewInterpolation(i + 1);
break;
}
// don't run in place after a teleport
+9 -3
View File
@@ -581,6 +581,13 @@ void P_Ticker(boolean run)
if (playeringame[i])
++players[i].jointime;
if (run)
{
// Update old view state BEFORE ticking so resetting
// the old interpolation state from game logic works.
R_UpdateViewInterpolation();
}
if (objectplacing)
{
if (OP_FreezeObjectplace())
@@ -694,7 +701,7 @@ void P_Ticker(boolean run)
//P_RunShields();
P_RunOverlays();
P_RunShadows();
//P_RunShadows();
P_UpdateSpecials();
P_RespawnSpecials();
@@ -827,7 +834,6 @@ void P_Ticker(boolean run)
if (run)
{
R_UpdateLevelInterpolators();
R_UpdateViewInterpolation();
// Hack: ensure newview is assigned every tic.
// Ensures view interpolation is T-1 to T in poor network conditions
@@ -902,7 +908,7 @@ void P_PreTicker(INT32 frames)
LUAh_ThinkFrame();
P_RunOverlays();
P_RunShadows();
//P_RunShadows();
P_UpdateSpecials();
P_RespawnSpecials();
+19 -16
View File
@@ -2510,18 +2510,15 @@ static void P_MovePlayer(player_t *player)
if ((player->mo->ceilingz - player->mo->floorz < player->mo->height)
&& !(player->mo->flags & MF_NOCLIP))
{
if (player->mo->ceilingz - player->mo->floorz < player->mo->height)
if ((netgame || multiplayer) && player->spectator)
P_DamageMobj(player->mo, NULL, NULL, 42000); // Respawn crushed spectators
else
{
if ((netgame || multiplayer) && player->spectator)
P_DamageMobj(player->mo, NULL, NULL, 42000); // Respawn crushed spectators
else
{
K_SquishPlayer(player, NULL, NULL); // SRB2kart - we don't kill when squished, we squish when squished.
}
if (player->playerstate == PST_DEAD)
return;
K_SquishPlayer(player, NULL, NULL); // SRB2kart - we don't kill when squished, we squish when squished.
}
if (player->playerstate == PST_DEAD)
return;
}
#ifdef HWRENDER
@@ -3962,7 +3959,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
{
P_MoveChaseCamera(player, thiscam, false);
R_ResetViewInterpolation(num + 1);
R_ResetViewInterpolation(num + 1);
}
return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming);
@@ -4147,8 +4143,18 @@ static void P_CalcPostImg(player_t *player)
}
}
if (player->mo->eflags & MFE_VERTICALFLIP)
*type = postimg_flip;
if (!encoremode) // srb2kart
{
if (player->mo->eflags & MFE_VERTICALFLIP)
*type = postimg_flip;
}
else
{
if (player->mo->eflags & MFE_VERTICALFLIP)
*type = postimg_mirrorflip;
else
*type = postimg_mirror;
}
#if 1
(void)param;
@@ -4163,9 +4169,6 @@ static void P_CalcPostImg(player_t *player)
*param = 5;
}
#endif
if (encoremode) // srb2kart
*type = postimg_mirror;
}
void P_DoTimeOver(player_t *player)
+6 -6
View File
@@ -41,33 +41,33 @@ typedef void *pref_typ;
#define COMP(a, b) ((*compar)((void *)(a), (void *)(b)))
static void swapbytes(void *a0, void *b0, size_t n)
static inline void swapbytes(void *a0, void *b0, size_t n)
{
char *a = a0, *b = b0, t;
do {ASWAP(*a, *b, t); a++; b++;} while (--n);
}
static void swapdword(void *a0, void *b0, size_t n)
static inline void swapdword(void *a0, void *b0, size_t n)
{
DWORD *a = a0, *b = b0, t;
ASWAP(*a, *b, t);
(void)n;
}
static void swapdwords(void *a0, void *b0, size_t n)
static inline void swapdwords(void *a0, void *b0, size_t n)
{
DWORD *a = a0, *b = b0, t;
do {ASWAP(*a, *b, t); a++; b++;} while (n -= sizeof(DWORD));
}
static void swapword(void *a0, void *b0, size_t n)
static inline void swapword(void *a0, void *b0, size_t n)
{
WORD *a = a0, *b = b0, t;
ASWAP(*a, *b, t);
(void)n;
}
static void swapwords(void *a0, void *b0, size_t n)
static inline void swapwords(void *a0, void *b0, size_t n)
{
WORD *a = a0, *b = b0, t;
do {ASWAP(*a, *b, t); a++; b++;} while (n -= sizeof(WORD));
@@ -75,7 +75,7 @@ static void swapwords(void *a0, void *b0, size_t n)
typedef void (*swapf_typ)(void *, void *, size_t);
static char *med3(char *a, char *b, char *c, int (*compar)(const void *, const void *))
static inline char *med3(char *a, char *b, char *c, int (*compar)(const void *, const void *))
{
return COMP(a, b) < 0 ?
(COMP(b, c) < 0 ? b : COMP(a, c) < 0 ? c : a) :
+20 -7
View File
@@ -39,6 +39,10 @@ drawseg_t *ds_p = NULL;
// indicates doors closed wrt automap bugfix:
INT32 doorclosed;
// A wall was drawn covering the whole screen, which means we
// can block off the BSP across that seg.
boolean g_walloffscreen;
boolean R_NoEncore(sector_t *sector, boolean ceiling)
{
boolean invertencore = (GETSECSPECIAL(sector->special, 2) == 15);
@@ -163,7 +167,7 @@ crunch:
// Clips the given range of columns, but does not include it in the clip list.
// Does handle windows, e.g. LineDefs with upper and lower texture.
//
static inline void R_ClipPassWallSegment(INT32 first, INT32 last)
static inline void R_ClipPassWallSegment(INT32 first, INT32 last, boolean soliddontrender)
{
cliprange_t *start;
@@ -178,12 +182,14 @@ static inline void R_ClipPassWallSegment(INT32 first, INT32 last)
if (last < start->first - 1)
{
// Post is entirely visible (above start).
R_StoreWallRange(first, last);
if (!soliddontrender)
R_StoreWallRange(first, last);
return;
}
// There is a fragment above *start.
R_StoreWallRange(first, start->first - 1);
if (!soliddontrender)
R_StoreWallRange(first, start->first - 1);
}
// Bottom contained in start?
@@ -193,7 +199,8 @@ static inline void R_ClipPassWallSegment(INT32 first, INT32 last)
while (last >= (start+1)->first - 1)
{
// There is a fragment between two posts.
R_StoreWallRange(start->last + 1, (start+1)->first - 1);
if (!soliddontrender)
R_StoreWallRange(start->last + 1, (start+1)->first - 1);
start++;
if (last <= start->last)
@@ -201,7 +208,8 @@ static inline void R_ClipPassWallSegment(INT32 first, INT32 last)
}
// There is a fragment after *next.
R_StoreWallRange(start->last + 1, last);
if (!soliddontrender)
R_StoreWallRange(start->last + 1, last);
}
//
@@ -579,10 +587,15 @@ static void R_AddLine(seg_t *line)
return;
clippass:
R_ClipPassWallSegment(x1, x2 - 1);
g_walloffscreen = false;
if (g_walloffscreen)
R_ClipPassWallSegment(x1, x2 - 1, true);
else
R_ClipPassWallSegment(x1, x2 - 1, false);
return;
clipsolid:
g_walloffscreen = false;
R_ClipSolidWallSegment(x1, x2 - 1);
}
@@ -1311,7 +1324,7 @@ INT32 R_GetPlaneLight(sector_t *sector, fixed_t planeheight, boolean underside)
void R_RenderBSPNode(INT32 bspnum)
{
node_t *bsp;
const node_t *bsp;
INT32 side;
ps_numbspcalls.value.i++;
+1
View File
@@ -32,6 +32,7 @@ extern INT32 checkcoord[12][4];
extern drawseg_t *drawsegs;
extern drawseg_t *ds_p;
extern INT32 doorclosed;
extern boolean g_walloffscreen;
// BSP?
void R_ClearClipSegs(void);
+11 -2
View File
@@ -1088,6 +1088,7 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap)
{
char colormap[9] = "COLORMAP";
lumpnum_t lump;
const lumpnum_t basecolormaplump = W_GetNumForName(colormap);
if (num > 0 && num <= 10000)
snprintf(colormap, 8, "CLM%04u", num-1);
@@ -1095,8 +1096,16 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap)
// Load in the light tables, now 64k aligned for smokie...
lump = W_GetNumForName(colormap);
if (lump == LUMPERROR)
lump = W_GetNumForName("COLORMAP");
W_ReadLump(lump, colormaps);
lump = basecolormaplump;
else
{
if (W_LumpLength(lump) != W_LumpLength(basecolormaplump))
{
CONS_Alert(CONS_WARNING, "%s lump size does not match COLORMAP, results may be unexpected.\n", colormap);
}
}
W_ReadLumpHeader(lump, colormaps, W_LumpLength(basecolormaplump), 0U);
// Encore mode.
if (newencoremap != LUMPERROR)
+2 -10
View File
@@ -350,7 +350,6 @@ typedef struct sector_s
fixed_t floorspeed, ceilspeed;
// list of precipitation mobjs in sector
precipmobj_t *preciplist;
struct mprecipsecnode_s *touching_preciplist;
// Eternity engine slope
@@ -649,16 +648,9 @@ typedef struct
INT16 height;
INT16 leftoffset; // pixels to the left of origin
INT16 topoffset; // pixels below the origin
INT32 columnofs[8]; // only [width] used
UINT8 *columns; // Software column data
INT32 columnofs[]; // only [width] used
// the [0] is &columnofs[width]
void *hardware; // OpenGL patch, allocated whenever necessary
#ifdef ROTSPRITE
rotsprite_t *rotated; // Rotated patches
#endif
} patch_t;
}ATTRPACK patch_t;
#ifdef _MSC_VER
#pragma warning(disable : 4200)
+1
View File
@@ -148,6 +148,7 @@ void R_DrawColumn_8(void);
#define R_DrawWallColumn_8 R_DrawColumn_8
void R_DrawShadeColumn_8(void);
void R_DrawTranslucentColumn_8(void);
void R_DrawDropShadowColumn_8(void);
void R_DrawTranslatedColumn_8(void);
void R_DrawTranslatedTranslucentColumn_8(void);
+35 -2
View File
@@ -417,6 +417,39 @@ void R_DrawTranslucentColumn_8(void)
}
}
// Hack: A cut-down copy of R_DrawTranslucentColumn_8 that does not read texture
// data since something about calculating the texture reading address for drop shadows is broken.
// dc_texturemid and dc_iscale get wrong values for drop shadows, however those are not strictly
// needed for the current design of the shadows, so this function bypasses the issue
// by not using those variables at all.
void R_DrawDropShadowColumn_8(void)
{
register INT32 count;
register UINT8 *dest;
count = dc_yh - dc_yl + 1;
if (count <= 0) // Zero length, column does not exceed a pixel.
return;
dest = &topleft[dc_yl*vid.width + dc_x];
{
#define DSCOLOR 15 // palette index for the color of the shadow
register const UINT8 *transmap_offset = dc_transmap + (dc_colormap[DSCOLOR] << 8);
#undef DSCOLOR
while ((count -= 2) >= 0)
{
*dest = *(transmap_offset + (*dest));
dest += vid.width;
*dest = *(transmap_offset + (*dest));
dest += vid.width;
}
if (count & 1)
*dest = *(transmap_offset + (*dest));
}
}
/** \brief The R_DrawTranslatedTranslucentColumn_8 function
Spiffy function. Not only does it colormap a sprite, but does translucency as well.
Uber-kudos to Cyan Helkaraxe
@@ -1696,7 +1729,7 @@ void R_DrawColumnShadowed_8(void)
{
dc_colormap = dc_lightlist[i].rcolormap;
if (encoremap)
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
if (solid && dc_yl < bheight)
dc_yl = bheight;
continue;
@@ -1714,7 +1747,7 @@ void R_DrawColumnShadowed_8(void)
dc_colormap = dc_lightlist[i].rcolormap;
if (encoremap)
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
}
dc_yh = realyh;
if (dc_yl <= realyh)
+45 -46
View File
@@ -23,6 +23,8 @@
#include "r_state.h"
#include "z_zone.h"
#include "console.h" // con_startup_loadprogress
#include "i_time.h"
#ifdef HWRENDER
#include "hardware/hw_main.h" // for cv_grshearing
#endif
@@ -80,6 +82,7 @@ static viewvars_t skyview_old[MAXSPLITSCREENPLAYERS];
static viewvars_t skyview_new[MAXSPLITSCREENPLAYERS];
static viewvars_t *oldview = &pview_old[0];
static tic_t last_view_update;
static int oldview_invalid[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0};
viewvars_t *newview = &pview_new[0];
@@ -200,21 +203,27 @@ void R_UpdateViewInterpolation(void)
if (oldview_invalid[i]) oldview_invalid[i]--;
}
last_view_update = I_GetTime();
}
void R_ResetViewInterpolation(UINT8 p)
{
// Wait an extra tic if the interpolation state hasn't
// updated yet.
int t = last_view_update == I_GetTime() ? 1 : 2;
if (p == 0)
{
UINT8 i;
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
oldview_invalid[i]++;
oldview_invalid[i] = t;
}
}
else
{
oldview_invalid[p - 1]++;
oldview_invalid[p - 1] = t;
}
}
@@ -278,6 +287,11 @@ angle_t R_InterpolateAngle(angle_t from, angle_t to)
return (R_LerpAngle(from, to, rendertimefrac));
}*/
#define IFCHANGED(a, b)\
if (mobj->a == mobj->b)\
(out->a = mobj->b);\
else
void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
{
if (frac == FRACUNIT)
@@ -285,6 +299,7 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
out->x = mobj->x;
out->y = mobj->y;
out->z = mobj->z;
out->floorz = mobj->floorz;
out->scale = mobj->scale;
out->subsector = mobj->subsector;
out->angle = mobj->player ? mobj->player->frameangle : mobj->angle;
@@ -299,44 +314,36 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
return;
}
if (mobj->x == mobj->old_x)
out->x = mobj->x;
else
IFCHANGED(x, old_x)
out->x = R_LerpFixed(mobj->old_x, mobj->x, frac);
if (mobj->y == mobj->old_y)
out->y = mobj->y;
else
IFCHANGED(y, old_y)
out->y = R_LerpFixed(mobj->old_y, mobj->y, frac);
if (mobj->z == mobj->old_z)
out->z = mobj->z;
else
IFCHANGED(z, old_z)
out->z = R_LerpFixed(mobj->old_z, mobj->z, frac);
if (mobj->spritexscale == mobj->old_spritexscale)
out->spritexscale = mobj->spritexscale;
if (!(cv_sloperoll.value && cv_spriteroll.value))
{
IFCHANGED(floorz, old_floorz)
out->floorz = R_LerpFixed(mobj->old_floorz, mobj->floorz, frac);
}
else
out->floorz = mobj->floorz;
IFCHANGED(spritexscale, old_spritexscale)
out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac);
if (mobj->spriteyscale == mobj->old_spriteyscale)
out->spriteyscale = mobj->spriteyscale;
else
IFCHANGED(spriteyscale, old_spriteyscale)
out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac);
if (mobj->spritexoffset == mobj->old_spritexoffset)
out->spritexoffset = mobj->spritexoffset;
else
IFCHANGED(spritexoffset, old_spritexoffset)
out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac);
if (mobj->spriteyoffset == mobj->old_spriteyoffset)
out->spriteyoffset = mobj->spriteyoffset;
else
IFCHANGED(spriteyoffset, old_spriteyoffset)
out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac);
if (mobj->scale == mobj->old_scale) // Tiny optimisation - scale is usually unchanging, so let's skip a lerp, two FixedMuls, and two FixedDivs
out->scale = mobj->scale;
else
IFCHANGED(scale, old_scale)
out->scale = mobj->resetinterp ? mobj->scale : R_LerpFixed(mobj->old_scale, mobj->scale, frac);
if (cv_mobjssector.value)
@@ -346,39 +353,27 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
if (mobj->player)
{
if (mobj->angle == mobj->player->old_frameangle)
out->angle = mobj->player->frameangle;
else
IFCHANGED(angle, player->old_frameangle)
out->angle = mobj->resetinterp ? mobj->player->frameangle : R_LerpAngle(mobj->player->old_frameangle, mobj->player->frameangle, frac);
}
else
{
if (mobj->angle == mobj->old_angle)
out->angle = mobj->angle;
else
IFCHANGED(angle, old_angle)
out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac);
}
// pitch roll stuff
if (mobj->pitch == mobj->old_pitch)
out->pitch = mobj->pitch;
else
IFCHANGED(pitch, old_pitch)
out->pitch = mobj->resetinterp ? mobj->pitch : R_LerpAngle(mobj->old_pitch, mobj->pitch, frac);
if (mobj->roll == mobj->old_roll)
out->roll = mobj->roll;
else
IFCHANGED(roll, old_roll)
out->roll = mobj->resetinterp ? mobj->roll : R_LerpAngle(mobj->old_roll, mobj->roll, frac);
// and the slope stuff
if (mobj->slopepitch == mobj->old_slopepitch)
out->slopepitch = mobj->slopepitch;
else
IFCHANGED(slopepitch, old_slopepitch)
out->slopepitch = mobj->resetinterp ? mobj->slopepitch : R_LerpAngle(mobj->old_slopepitch, mobj->slopepitch, frac);
if (mobj->sloperoll == mobj->old_sloperoll)
out->sloperoll = mobj->sloperoll;
else
IFCHANGED(sloperoll, old_sloperoll)
out->sloperoll = mobj->resetinterp ? mobj->sloperoll : R_LerpAngle(mobj->old_sloperoll, mobj->sloperoll, frac);
}
@@ -389,6 +384,7 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst
out->x = mobj->x;
out->y = mobj->y;
out->z = mobj->z;
out->floorz = mobj->floorz;
out->scale = FRACUNIT;
out->subsector = mobj->subsector;
out->angle = mobj->angle;
@@ -402,6 +398,7 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst
out->x = R_LerpFixed(mobj->old_x, mobj->x, frac);
out->y = R_LerpFixed(mobj->old_y, mobj->y, frac);
out->z = R_LerpFixed(mobj->old_z, mobj->z, frac);
out->floorz = mobj->floorz;
out->scale = FRACUNIT;
out->spritexscale = mobj->spritexscale;
out->spriteyscale = mobj->spriteyscale;
@@ -413,12 +410,12 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst
else
out->subsector = mobj->subsector;
if (mobj->angle == mobj->old_angle)
out->angle = mobj->angle;
else
IFCHANGED(angle, old_angle)
out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac);
}
#undef IFCHANGED
static void AddInterpolator(levelinterpolator_t* interpolator)
{
if (levelinterpolators_len >= levelinterpolators_size)
@@ -880,6 +877,7 @@ void R_ResetMobjInterpolationState(mobj_t *mobj)
mobj->old_x = mobj->x;
mobj->old_y = mobj->y;
mobj->old_z = mobj->z;
mobj->old_floorz = mobj->floorz;
mobj->old_angle = mobj->angle;
// rotation humor, again
@@ -920,6 +918,7 @@ void R_ResetPrecipitationMobjInterpolationState(precipmobj_t *mobj)
mobj->old_x = mobj->x;
mobj->old_y = mobj->y;
mobj->old_z = mobj->z;
mobj->old_floorz = mobj->floorz;
mobj->old_angle = mobj->angle;
mobj->old_spritexscale = mobj->spritexscale;
mobj->old_spriteyscale = mobj->spriteyscale;
+1
View File
@@ -59,6 +59,7 @@ typedef struct {
fixed_t x;
fixed_t y;
fixed_t z;
fixed_t floorz;
subsector_t *subsector;
angle_t angle;
fixed_t scale;
+31 -1
View File
@@ -32,6 +32,7 @@
#include "m_random.h" // quake camera shake
#include "doomstat.h" // MAXSPLITSCREENPLAYERS
#include "r_fps.h" // Frame interpolation/uncapped
#include "tables.h"
#ifdef HWRENDER
#include "hardware/hw_main.h"
@@ -193,6 +194,7 @@ consvar_t cv_flipcam2 = {"flipcam2", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo,
consvar_t cv_flipcam3 = {"flipcam3", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam3_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_flipcam4 = {"flipcam4", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam4_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_dropshadow = {"dropshadows", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_shadow = {"shadow", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_shadowoffs = {"offsetshadows", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_skybox = {"skybox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -594,6 +596,33 @@ boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixe
return false;
}
// Returns search dimensions within a blockmap, in the direction of viewangle and out to a certain distance.
void R_GetRenderBlockMapDimensions(fixed_t drawdist, INT32 *xl, INT32 *xh, INT32 *yl, INT32 *yh)
{
const angle_t left = viewangle - clipangle;
const angle_t right = viewangle + clipangle;
const fixed_t vxleft = viewx + FixedMul(drawdist, FCOS(left));
const fixed_t vyleft = viewy + FixedMul(drawdist, FSIN(left));
const fixed_t vxright = viewx + FixedMul(drawdist, FCOS(right));
const fixed_t vyright = viewy + FixedMul(drawdist, FSIN(right));
// Try to narrow the search to within only the field of view
*xl = (unsigned)(min(viewx, min(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT;
*xh = (unsigned)(max(viewx, max(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT;
*yl = (unsigned)(min(viewy, min(vyleft, vyright)) - bmaporgy)>>MAPBLOCKSHIFT;
*yh = (unsigned)(max(viewy, max(vyleft, vyright)) - bmaporgy)>>MAPBLOCKSHIFT;
if (*xh >= bmapwidth)
*xh = bmapwidth - 1;
if (*yh >= bmapheight)
*yh = bmapheight - 1;
BMBOUNDFIX(*xl, *xh, *yl, *yh);
}
//
// R_InitTextureMapping
//
@@ -1728,6 +1757,7 @@ void R_RenderPlayerView(player_t *player)
PS_START_TIMING(ps_bsptime);
R_RenderBSPNode((INT32)numnodes - 1);
PS_STOP_TIMING(ps_bsptime);
R_AddPrecipitationSprites();
PS_START_TIMING(ps_sw_spritecliptime);
R_ClipSprites();
PS_STOP_TIMING(ps_sw_spritecliptime);
@@ -1826,7 +1856,7 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_chasecam3);
CV_RegisterVar(&cv_chasecam4);
CV_RegisterVar(&cv_shadow);
CV_RegisterVar(&cv_shadowoffs);
CV_RegisterVar(&cv_dropshadow);
CV_RegisterVar(&cv_skybox);
CV_RegisterVar(&cv_ffloorclip);
CV_RegisterVar(&cv_spriteclip);
+5 -1
View File
@@ -64,6 +64,9 @@ extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
// There a 0-31, i.e. 32 LUT in the COLORMAP lump.
#define NUMCOLORMAPS 32
#define COLORMAP_SIZE (256*LIGHTLEVELS)
#define COLORMAP_REMAPOFFSET COLORMAP_SIZE
// Utility functions.
INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *node);
INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line);
@@ -80,6 +83,7 @@ subsector_t *R_PointInSubsector(fixed_t x, fixed_t y);
subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y);
boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixed_t bottomh, fixed_t toph);
void R_GetRenderBlockMapDimensions(fixed_t drawdist, INT32 *xl, INT32 *xh, INT32 *yl, INT32 *yh);
// Performance stats
extern precise_t ps_prevframetime;// time when previous frame was rendered
@@ -109,7 +113,7 @@ extern consvar_t cv_showhud, cv_translucenthud, cv_uncappedhud;
extern consvar_t cv_homremoval;
extern consvar_t cv_chasecam, cv_chasecam2, cv_chasecam3, cv_chasecam4;
extern consvar_t cv_flipcam, cv_flipcam2, cv_flipcam3, cv_flipcam4;
extern consvar_t cv_shadow, cv_shadowoffs;
extern consvar_t cv_dropshadow, cv_shadow, cv_shadowoffs;
extern consvar_t cv_ffloorclip, cv_spriteclip;
extern consvar_t cv_translucency;
extern consvar_t cv_drawdist, cv_drawdist_precip, cv_lessprecip;
+17 -21
View File
@@ -48,8 +48,8 @@ boolean R_CheckIfPatch(lumpnum_t lump)
patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC);
width = patch->width;
height = patch->height;
width = SHORT(patch->width);
height = SHORT(patch->height);
result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < (INT16)(size / 4));
@@ -772,6 +772,17 @@ static UINT16 GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip)
return 0xFF00;
}
#ifdef HWRENDER
static patch_t *R_CreateHardwarePatch(patch_t *patch)
{
GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL);
grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL);
grPatch->rawpatch = patch;
HWR_MakePatch(patch, grPatch, grPatch->mipmap, false);
return (patch_t *)grPatch;
}
#endif
#ifdef ROTSPRITE
//
// R_GetRollAngle
@@ -792,11 +803,7 @@ INT32 R_GetRollAngle(angle_t rollangle)
return ra;
}
patch_t *Patch_GetRotatedSprite(
spriteframe_t *sprite,
size_t frame, size_t spriteangle,
boolean flip, boolean adjustfeet,
void *info, INT32 rotationangle)
patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, boolean adjustfeet, void *info, INT32 rotationangle)
{
rotsprite_t *rotsprite;
spriteinfo_t *sprinfo = (spriteinfo_t *)info;
@@ -882,17 +889,6 @@ static void RotatedPatch_CalculateDimensions(
*newheight = max(height, max(h1, h2));
}
#ifdef HWRENDER
static patch_t *R_CreateHardwarePatch(patch_t *patch)
{
GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL);
grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL);
grPatch->rawpatch = patch;
HWR_MakePatch(patch, grPatch, grPatch->mipmap, false);
return (patch_t *)grPatch;
}
#endif
void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip)
{
UINT32 i;
@@ -906,9 +902,9 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle
size_t size;
INT32 bflip = (flip != 0x00);
INT32 width = patch->width;
INT32 height = patch->height;
INT32 leftoffset = patch->leftoffset;
INT32 width = SHORT(patch->width);
INT32 height = SHORT(patch->height);
INT32 leftoffset = SHORT(patch->leftoffset);
INT32 newwidth, newheight;
fixed_t ca = rollcosang[angle];
+2 -2
View File
@@ -295,7 +295,7 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
ds_colormap = planezlight[pindex];
}
if (encoremap && !currentplane->noencore)
ds_colormap += (256*32);
ds_colormap += COLORMAP_REMAPOFFSET;
if (currentplane->extra_colormap)
ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps);
@@ -675,7 +675,7 @@ static void R_DrawSkyPlane(visplane_t *pl)
// by INVUL inverse mapping.
dc_colormap = colormaps;
if (encoremap)
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
dc_texturemid = skytexturemid;
dc_texheight = textureheight[skytexture]
>>FRACBITS;
+28 -22
View File
@@ -208,7 +208,7 @@ static void R_DrawWallSplats(void)
pindex = MAXLIGHTSCALE - 1;
dc_colormap = walllights[pindex];
if (encoremap && !(seg->linedef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
if (frontsector->extra_colormap)
dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
@@ -573,7 +573,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
{
dc_colormap = rlight->rcolormap;
if (encoremap && !(ldef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
continue;
}
@@ -594,7 +594,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
windowtop = windowbottom + 1;
dc_colormap = rlight->rcolormap;
if (encoremap && !(ldef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
}
windowbottom = realbot;
if (windowtop < windowbottom)
@@ -612,7 +612,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
dc_colormap = walllights[pindex];
if (encoremap && !(ldef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
if (frontsector->extra_colormap)
dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
@@ -634,12 +634,15 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
// Loop through R_DrawMaskedColumn calls
static void R_DrawRepeatMaskedColumn(column_t *col)
{
while (sprtopscreen < sprbotscreen) {
INT64 z;
while (sprtopscreen < sprbotscreen)
{
R_DrawMaskedColumn(col);
if (sprtopscreen + (INT64)dc_texheight*spryscale > (INT64)INT32_MAX) // prevent overflow
z = sprtopscreen + (INT64)dc_texheight*spryscale;
if (z > (INT64)INT32_MAX) // prevent overflow
sprtopscreen = INT32_MAX;
else
sprtopscreen += dc_texheight*spryscale;
sprtopscreen = z;
}
}
@@ -1104,7 +1107,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
{
dc_colormap = rlight->rcolormap;
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
}
if (solid && windowtop < bheight)
windowtop = bheight;
@@ -1136,7 +1139,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
{
dc_colormap = rlight->rcolormap;
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
}
}
windowbottom = sprbotscreen;
@@ -1157,7 +1160,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
dc_colormap = walllights[pindex];
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
if (pfloor->flags & FF_FOG && pfloor->master->frontsector->extra_colormap)
dc_colormap = pfloor->master->frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
@@ -1393,7 +1396,7 @@ static void R_RenderSegLoop (void)
dc_colormap = walllights[pindex];
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
dc_x = rw_x;
dc_iscale = 0xffffffffu / (unsigned)rw_scale;
@@ -2596,23 +2599,26 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (toptexture)
{
pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale);
pixhighstep = -FixedMul (rw_scalestep,worldhigh);
fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldhighslope, ds_p->scale2);
if (backsector->c_slope) {
fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldhighslope, ds_p->scale2);
pixhighstep = (topfracend-pixhigh)/(range);
}
pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale);
pixhighstep = (topfracend-pixhigh)/(range);
// If the lowest part of a ceiling stretching down covers the entire screen
if (min(pixhigh, topfracend)>>HEIGHTBITS >= viewheight-1)
g_walloffscreen = true;
}
if (bottomtexture)
{
fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldlowslope, ds_p->scale2);
pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale);
pixlowstep = -FixedMul (rw_scalestep,worldlow);
if (backsector->f_slope) {
fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldlowslope, ds_p->scale2);
pixlowstep = (bottomfracend-pixlow)/(range);
}
pixlowstep = (bottomfracend-pixlow)/(range);
// If the highest part of a floor stretching up covers the entire screen
if ((max(pixlow, bottomfracend)+HEIGHTUNIT-1)>>HEIGHTBITS <= 0)
g_walloffscreen = true;
}
{
+432 -143
View File
@@ -152,7 +152,6 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch
}
#endif/*ROTSPRITE*/
if (rotation == 0)
{
// the lump should be used for all rotations
@@ -300,8 +299,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef,
spritecachedinfo[numspritelumps].height = SHORT(patch.height)<<FRACBITS;
//BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer
if (rendermode != render_none) // not for psprite
spritecachedinfo[numspritelumps].topoffset += 4<<FRACBITS;
spritecachedinfo[numspritelumps].topoffset += FEETADJUST;
// Being selective with this causes bad things. :( Like the special stage tokens breaking apart.
/*if (rendermode != render_none // not for psprite
@@ -578,10 +576,8 @@ static vissprite_t *R_GetVisSprite(UINT32 num)
static vissprite_t *R_NewVisSprite(void)
{
if (visspritecount == MAXVISSPRITES) {
//CONS_Alert(CONS_ERROR, M_GetText("R_NewVisSprite: too many vissprites requested (maximum is %i)\n"), MAXVISSPRITES);
if (visspritecount == MAXVISSPRITES)
return &overflowsprite;
}
return R_GetVisSprite(visspritecount++);
}
@@ -656,8 +652,6 @@ void R_DrawMaskedColumn(column_t *column)
dc_texturemid = basetexturemid;
}
INT32 lengthcol; // column->length : for flipped column function pointers and multi-patch on 2sided wall = texture->height
static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight)
{
INT32 topscreen;
@@ -724,9 +718,7 @@ static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight)
static void R_DrawVisSprite(vissprite_t *vis)
{
column_t *column;
#ifdef RANGECHECK
INT32 texturecolumn;
#endif
fixed_t frac;
patch_t *patch = vis->patch;
fixed_t this_scale = vis->thingscale;
@@ -751,7 +743,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
// TODO This check should not be necessary. But Papersprites near to the camera will sometimes create invalid values
// for the vissprite's startfrac. This happens because they are not depth culled like other sprites.
// Someone who is more familiar with papersprites pls check and try to fix <3
if (vis->startfrac < 0 || vis->startfrac > (patch->width << FRACBITS))
if (vis->startfrac < 0 || vis->startfrac > (SHORT(patch->width) << FRACBITS))
{
// never draw vissprites with startfrac out of patch range
return;
@@ -759,7 +751,16 @@ static void R_DrawVisSprite(vissprite_t *vis)
colfunc = basecolfunc; // hack: this isn't resetting properly somewhere.
dc_colormap = vis->colormap;
if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash"
// Hack: Use a special column function for drop shadows that bypasses
// invalid memory access crashes caused by R_ProjectDropShadow putting wrong values
// in dc_texturemid and dc_iscale when the shadow is sloped.
if (vis->cut & SC_SHADOW)
{
colfunc = dropshadowcolfunc;
dc_transmap = vis->transmap;
}
else if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash"
{
// translate certain pixels to white
colfunc = transcolfunc;
@@ -816,7 +817,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
dc_colormap = colormaps;
if (encoremap && !vis->mobj->color && !(vis->mobj->flags & MF_DONTENCOREMAP))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
dc_texturemid = vis->texturemid;
dc_texheight = 0;
@@ -828,16 +829,18 @@ static void R_DrawVisSprite(vissprite_t *vis)
this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->localskin)->highresscale);
else if (vis->mobj->skin && ((skin_t *)vis->mobj->skin)->flags & SF_HIRES)
this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->skin)->highresscale);
if (this_scale <= 0)
this_scale = 1;
if (this_scale != FRACUNIT)
{
if (!vis->isScaled)
if (!(vis->cut & SC_ISSCALED))
{
vis->scale = FixedMul(vis->scale, this_scale);
vis->scalestep = FixedMul(vis->scalestep, this_scale);
vis->xiscale = FixedDiv(vis->xiscale, this_scale);
vis->isScaled = true;
vis->xiscale = FixedDiv(vis->xiscale,this_scale);
vis->cut |= SC_ISSCALED;
}
dc_texturemid = FixedDiv(dc_texturemid, this_scale);
}
@@ -847,6 +850,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
if (!(vis->scalestep))
{
sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale);
sprtopscreen += vis->shear.tan * vis->shear.offset;
dc_iscale = FixedDiv(FRACUNIT, vis->scale);
}
@@ -862,9 +866,6 @@ static void R_DrawVisSprite(vissprite_t *vis)
if (vis->x2 >= vid.width)
vis->x2 = vid.width-1;
lengthcol = SHORT(patch->height);
#if 1
// Something is occasionally setting 1px-wide sprites whose frac is exactly the width of the sprite, causing crashes due to
// accessing invalid column info. Until the cause is found, let's try to correct those manually...
{
@@ -872,35 +873,51 @@ static void R_DrawVisSprite(vissprite_t *vis)
if (temp > 0)
vis->x2 -= temp;
}
#endif
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale)
// Split drawing loops for paper and non-paper to reduce conditional checks per sprite
if (vis->scalestep)
{
fixed_t horzscale = FixedMul(vis->spritexscale, this_scale);
fixed_t scalestep = FixedMul(vis->scalestep, vis->spriteyscale);
if (vis->scalestep) // currently papersprites only
{
#ifndef RANGECHECK
if ((frac>>FRACBITS) < 0 || (frac>>FRACBITS) >= SHORT(patch->width)) // if this doesn't work i'm removing papersprites
break;
#endif
// Papersprite drawing loop
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += scalestep)
{
angle_t angle = ((vis->centerangle + xtoviewangle[dc_x]) >> ANGLETOFINESHIFT) & 0xFFF;
texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale;
if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width))
continue;
if (vis->xiscale < 0) // Flipped sprite
texturecolumn = SHORT(patch->width) - 1 - texturecolumn;
sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale));
dc_iscale = (0xffffffffu / (unsigned)spryscale);
spryscale += scalestep;
}
#ifdef RANGECHECK
texturecolumn = frac>>FRACBITS;
if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width))
I_Error("R_DrawSpriteRange: bad texturecolumn");
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn]));
#else
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[frac>>FRACBITS]));
#endif
if (vis->vflip)
R_DrawFlippedMaskedColumn(column, patch->height);
else
R_DrawMaskedColumn(column);
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn]));
if (vis->vflip)
R_DrawFlippedMaskedColumn(column, patch->height);
else
R_DrawMaskedColumn(column);
}
}
else
{
// Non-paper drawing loop
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale)
{
#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x)))
texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1);
#undef CLAMP
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn]));
if (vis->vflip)
R_DrawFlippedMaskedColumn(column, patch->height);
else
R_DrawMaskedColumn(column);
}
}
colfunc = basecolfunc;
@@ -914,9 +931,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
{
column_t *column;
#ifdef RANGECHECK
INT32 texturecolumn;
#endif
fixed_t frac;
patch_t *patch;
INT64 overflow_test;
@@ -939,7 +954,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
dc_colormap = colormaps;
if (encoremap)
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
dc_iscale = FixedDiv(FRACUNIT, vis->scale);
dc_texturemid = vis->texturemid;
@@ -956,20 +971,15 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
if (vis->x2 >= vid.width)
vis->x2 = vid.width-1;
#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x)))
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale)
{
#ifdef RANGECHECK
texturecolumn = frac>>FRACBITS;
if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width))
I_Error("R_DrawPrecipitationSpriteRange: bad texturecolumn");
texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1);
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn]));
#else
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[frac>>FRACBITS]));
#endif
R_DrawMaskedColumn(column);
}
#undef CLAMP
colfunc = basecolfunc;
}
@@ -1064,19 +1074,46 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing)
}
}
//
// R_GetShadowZ(thing, shadowslope)
// Get the first visible floor below the object for shadows
// shadowslope is filled with the floor's slope, if provided
//
fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope)
fixed_t R_GetShadowZ(
mobj_t *thing, pslope_t **shadowslope)
{
fixed_t halfHeight;
boolean isflipped = thing->eflags & MFE_VERTICALFLIP;
fixed_t floorz;
fixed_t ceilingz;
fixed_t z, groundz = isflipped ? INT32_MAX : INT32_MIN;
pslope_t *slope, *groundslope = NULL;
msecnode_t *node;
sector_t *sector;
ffloor_t *rover;
#define CHECKZ (isflipped ? z > thing->z+thing->height/2 && z < groundz : z < thing->z+thing->height/2 && z > groundz)
INT32 dist = -1;
// for frame interpolation
interpmobjstate_t interp = {0};
if (cv_grmaxinterpdist.value)
dist = R_QuickCamDist(thing->x, thing->y);
// do interpolation
if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value))
{
R_InterpolateMobjState(thing, rendertimefrac, &interp);
}
else
{
R_InterpolateMobjState(thing, FRACUNIT, &interp);
}
halfHeight = interp.z + (thing->height >> 1);
floorz = P_GetFloorZ(thing, interp.subsector->sector, interp.x, interp.y, NULL);
ceilingz = P_GetCeilingZ(thing, interp.subsector->sector, interp.x, interp.y, NULL);
#define CHECKZ (isflipped ? z > halfHeight && z < groundz : z < halfHeight && z > groundz)
for (node = thing->touching_sectorlist; node; node = node->m_sectorlist_next)
{
@@ -1087,7 +1124,7 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope)
if (sector->heightsec != -1)
z = isflipped ? sectors[sector->heightsec].ceilingheight : sectors[sector->heightsec].floorheight;
else
z = isflipped ? P_GetSectorCeilingZAt(sector, thing->x, thing->y) : P_GetSectorFloorZAt(sector, thing->x, thing->y);
z = isflipped ? P_GetSectorCeilingZAt(sector, interp.x, interp.y) : P_GetSectorFloorZAt(sector, interp.x, interp.y);
if CHECKZ
{
@@ -1101,7 +1138,7 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope)
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || (rover->alpha < 90 && !(rover->flags & FF_SWIMMABLE)))
continue;
z = isflipped ? P_GetFFloorBottomZAt(rover, thing->x, thing->y) : P_GetFFloorTopZAt(rover, thing->x, thing->y);
z = isflipped ? P_GetFFloorBottomZAt(rover, interp.x, interp.y) : P_GetFFloorTopZAt(rover, interp.x, interp.y);
if CHECKZ
{
groundz = z;
@@ -1110,18 +1147,178 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope)
}
}
if (isflipped ? (thing->ceilingz < groundz - (!groundslope ? 0 : FixedMul(abs(groundslope->zdelta), thing->radius*3/2)))
: (thing->floorz > groundz + (!groundslope ? 0 : FixedMul(abs(groundslope->zdelta), thing->radius*3/2))))
if (isflipped ? (ceilingz < groundz - (!groundslope ? 0 : FixedMul(abs(groundslope->zdelta), thing->radius*3/2)))
: (floorz > groundz + (!groundslope ? 0 : FixedMul(abs(groundslope->zdelta), thing->radius*3/2))))
{
groundz = isflipped ? thing->ceilingz : thing->floorz;
groundz = isflipped ? ceilingz : floorz;
groundslope = NULL;
}
if (shadowslope != NULL)
*shadowslope = groundslope;
return groundz;
#undef CHECKZ
return groundz;
}
static void R_SkewShadowSprite(
mobj_t *thing, pslope_t *groundslope,
fixed_t groundz, INT32 spriteheight, fixed_t scalemul,
fixed_t *shadowyscale, fixed_t *shadowskew)
{
// haha let's try some dumb stuff
fixed_t xslope, zslope;
angle_t sloperelang;
// for frame interpolation
interpmobjstate_t interp = {0};
if (R_UsingFrameInterpolation() && !paused)
{
R_InterpolateMobjState(thing, rendertimefrac, &interp);
}
else
{
R_InterpolateMobjState(thing, FRACUNIT, &interp);
}
sloperelang = (R_PointToAngle(interp.x, interp.y) - groundslope->xydirection) >> ANGLETOFINESHIFT;
xslope = FixedMul(FINESINE(sloperelang), groundslope->zdelta);
zslope = FixedMul(FINECOSINE(sloperelang), groundslope->zdelta);
//CONS_Printf("Shadow is sloped by %d %d\n", xslope, zslope);
if (viewz < groundz)
*shadowyscale += FixedMul(FixedMul(thing->radius*2 / spriteheight, scalemul), zslope);
else
*shadowyscale -= FixedMul(FixedMul(thing->radius*2 / spriteheight, scalemul), zslope);
*shadowyscale = abs(*shadowyscale);
*shadowskew = xslope;
}
static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fixed_t tz, fixed_t scale)
{
vissprite_t *shadow;
patch_t *patch;
fixed_t xscale, yscale, shadowxscale, shadowyscale, shadowskew, x1, x2;
fixed_t scalemul;
fixed_t floordiff;
fixed_t groundz;
pslope_t *groundslope;
boolean isflipped = thing->eflags & MFE_VERTICALFLIP;
INT32 dist = -1;
interpmobjstate_t interp = {0};
groundz = R_GetShadowZ(thing, &groundslope);
if (abs(groundz-viewz)/tz > 4) return; // Prevent stretchy shadows and possible crashes
if (cv_grmaxinterpdist.value)
dist = R_QuickCamDist(thing->x, thing->y);
// do interpolation
if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value))
{
R_InterpolateMobjState(thing, rendertimefrac, &interp);
}
else
{
R_InterpolateMobjState(thing, FRACUNIT, &interp);
}
floordiff = abs((isflipped ? thing->height : 0) + interp.z - groundz);
scalemul = FixedMul(FRACUNIT - floordiff/640, scale);
patch = W_CachePatchNum(sprites[SPR_SHAD].spriteframes[0].lumppat[0], PU_CACHE);
xscale = FixedDiv(projection, tz);
yscale = FixedDiv(projectiony, tz);
shadowxscale = FixedMul(thing->radius*2, scalemul);
shadowyscale = FixedMul(FixedMul(thing->radius*2, scalemul), FixedDiv(abs(groundz - viewz), tz));
shadowyscale = min(shadowyscale, shadowxscale) / SHORT(patch->height);
shadowxscale /= SHORT(patch->width);
shadowskew = 0;
if (groundslope && cv_sloperoll.value && cv_spriteroll.value)
R_SkewShadowSprite(thing, groundslope, groundz, SHORT(patch->height), scalemul, &shadowyscale, &shadowskew); // idk whats up with this thing
tx -= SHORT(patch->width) * shadowxscale/2;
x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
if (x1 >= viewwidth) return;
tx += SHORT(patch->width) * shadowxscale;
x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--;
if (x2 < 0 || x2 <= x1) return;
if (shadowyscale < FRACUNIT/SHORT(patch->height)) return; // fix some crashes?
shadow = R_NewVisSprite();
shadow->patch = patch;
shadow->heightsec = vis->heightsec;
shadow->thingheight = FRACUNIT;
shadow->pz = groundz + (isflipped ? -shadow->thingheight : 0);
shadow->pzt = shadow->pz + shadow->thingheight;
shadow->mobjflags = 0;
shadow->sortscale = vis->sortscale;
shadow->dispoffset = vis->dispoffset - 5;
shadow->gx = interp.x;
shadow->gy = interp.y;
shadow->gzt = (isflipped ? shadow->pzt : shadow->pz) + SHORT(patch->height) * shadowyscale / 2;
shadow->gz = shadow->gzt - SHORT(patch->height) * shadowyscale;
shadow->texturemid = FixedMul(interp.scale, FixedDiv(shadow->gzt - viewz, shadowyscale));
if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES)
shadow->texturemid = FixedMul(shadow->texturemid, ((skin_t *)thing->skin)->highresscale);
shadow->scalestep = 0;
shadow->shear.tan = shadowskew; // repurposed variable
shadow->mobj = thing; // Easy access! Tails 06-07-2002
shadow->x1 = x1 < 0 ? 0 : x1;
shadow->x2 = x2 >= viewwidth ? viewwidth-1 : x2;
// PORTAL SEMI-CLIPPING
if (portalrender && portalclipline)
{
if (shadow->x1 < portalclipstart)
shadow->x1 = portalclipstart;
if (shadow->x2 >= portalclipend)
shadow->x2 = portalclipend-1;
}
shadow->xscale = FixedMul(xscale, shadowxscale); //SoM: 4/17/2000
shadow->scale = FixedMul(yscale, shadowyscale);
shadow->thingscale = interp.scale;
shadow->sector = vis->sector;
shadow->szt = (INT16)((centeryfrac - FixedMul(shadow->gzt - viewz, yscale))>>FRACBITS);
shadow->sz = (INT16)((centeryfrac - FixedMul(shadow->gz - viewz, yscale))>>FRACBITS);
shadow->cut = SC_ISSCALED|SC_SHADOW; //check this
shadow->startfrac = 0;
//shadow->xiscale = 0x7ffffff0 / (shadow->xscale/2);
shadow->xiscale = (SHORT(patch->width)<<FRACBITS)/(x2-x1+1); // fuck it
if (shadow->x1 > x1)
shadow->startfrac += shadow->xiscale*(shadow->x1-x1);
// reusing x1 variable
x1 += (x2-x1)/2;
shadow->shear.offset = shadow->x1-x1;
shadow->extra_colormap = NULL;
shadow->transmap = transtables + (tr_trans20<<FF_TRANSSHIFT);
if (thing->whiteshadow)
shadow->colormap = scalelight[LIGHTLEVELS - 1][0]; // full bright!
else
shadow->colormap = scalelight[0][0]; // full dark!
objectsdrawn++;
}
//
@@ -1132,6 +1329,7 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope)
static void R_ProjectSprite(mobj_t *thing)
{
mobj_t *oldthing = thing;
fixed_t tr_x, tr_y;
fixed_t gxt, gyt;
fixed_t tx, tz;
@@ -1148,7 +1346,6 @@ static void R_ProjectSprite(mobj_t *thing)
size_t rot;
UINT8 flip;
/*boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !R_ThingVerticallyFlipped(thing));*/
boolean mirrored = thing->mirrored;
boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored);
@@ -1162,7 +1359,11 @@ static void R_ProjectSprite(mobj_t *thing)
fixed_t iscale;
fixed_t scalestep; // toast '16
fixed_t offset, offset2;
boolean papersprite = (thing->frame & FF_PAPERSPRITE);
fixed_t basetx, basetz; // drop shadows
boolean papersprite = !!(thing->frame & FF_PAPERSPRITE);
fixed_t paperoffset = 0, paperdistance = 0; angle_t centerangle = 0;
//SoM: 3/17/2000
fixed_t gz, gzt;
@@ -1174,6 +1375,7 @@ static void R_ProjectSprite(mobj_t *thing)
// rotsprite
fixed_t spr_width, spr_height;
fixed_t spr_offset, spr_topoffset;
#ifdef ROTSPRITE
patch_t *rotsprite = NULL;
INT32 rollangle = 0;
@@ -1181,8 +1383,6 @@ static void R_ProjectSprite(mobj_t *thing)
angle_t pitchnroll = 0;
angle_t sliptiderollangle = 0;
#endif
fixed_t ang_scale = FRACUNIT;
INT32 dist = -1;
@@ -1211,15 +1411,15 @@ static void R_ProjectSprite(mobj_t *thing)
gxt = FixedMul(tr_x, viewcos);
gyt = -FixedMul(tr_y, viewsin);
tz = gxt-gyt;
basetz = tz = gxt-gyt;
// thing is behind view plane?
if (!(papersprite) && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later
if (!papersprite && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later
return;
gxt = -FixedMul(tr_x, viewsin);
gyt = FixedMul(tr_y, viewcos);
tx = -(gyt + gxt);
basetx = tx = -(gyt + gxt);
// too far off the side?
if (!papersprite && abs(tx) > tz<<2) // papersprite clipping is handled later
@@ -1285,14 +1485,9 @@ static void R_ProjectSprite(mobj_t *thing)
{
ang = R_PointToAngle (interp.x, interp.y) - interp.angle;
camang = R_PointToAngle (interp.x, interp.y);
}
if (sprframe->rotate != SRF_SINGLE || papersprite)
{
if (mirrored)
ang = InvAngle(ang);
if (papersprite)
ang_scale = abs(FINESINE(ang>>ANGLETOFINESHIFT));
}
if (sprframe->rotate == SRF_SINGLE)
@@ -1375,15 +1570,14 @@ static void R_ProjectSprite(mobj_t *thing)
rollsum += thing->rollangle;
rollangle = R_GetRollAngle(rollsum);
rotsprite = Patch_GetRotatedSprite(
sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle);
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle);
if (rotsprite != NULL)
{
spr_width = rotsprite->width << FRACBITS;
spr_height = rotsprite->height << FRACBITS;
spr_offset = rotsprite->leftoffset << FRACBITS;
spr_topoffset = rotsprite->topoffset << FRACBITS;
spr_width = SHORT(rotsprite->width) << FRACBITS;
spr_height = SHORT(rotsprite->height) << FRACBITS;
spr_offset = SHORT(rotsprite->leftoffset) << FRACBITS;
spr_topoffset = SHORT(rotsprite->topoffset) << FRACBITS;
spr_topoffset += FEETADJUST;
// flip -> rotate, not rotate -> flip
@@ -1393,10 +1587,11 @@ static void R_ProjectSprite(mobj_t *thing)
}
#endif
flip = !flip != !hflip;
// calculate edges of the shape
spritexscale = interp.spritexscale;
spriteyscale = interp.spriteyscale;
if (spritexscale < 1 || spriteyscale < 1)
return;
@@ -1415,39 +1610,19 @@ static void R_ProjectSprite(mobj_t *thing)
spr_offset += interp.spritexoffset * flipoffset;
spr_topoffset += interp.spriteyoffset * flipoffset;
}
flip = !flip != !hflip;
if (flip)
offset = spr_offset - spr_width;
else
offset = -spr_offset;
//offset = FixedMul(offset, FixedMul(spritexscale, this_scale));
//offset2 = FixedMul(spr_width, FixedMul(spritexscale, this_scale)); // OH GOD I'M REVOOOOORTINGGGG AHHHHHHH
offset = FixedMul(offset, FixedMul(spritexscale, this_scale));
tx += FixedMul(offset, ang_scale);
x1 = (centerxfrac + FixedMul (tx,xscale)) >>FRACBITS;
// off the right side?
if (x1 > viewwidth)
return;
offset2 = FixedMul(spr_width, FixedMul(spritexscale, this_scale));
tx += FixedMul(offset2, ang_scale);
x2 = ((centerxfrac + FixedMul (tx,xscale)) >> FRACBITS) - 1;
// off the left side
if (x2 < 0)
return;
if (papersprite)
{
fixed_t yscale2, cosmul, sinmul, tz2;
if (x2 <= x1)
return;
fixed_t xscale2, yscale2, cosmul, sinmul, tx2, tz2;
INT32 range;
if (ang >= ANGLE_180)
{
@@ -1464,7 +1639,22 @@ static void R_ProjectSprite(mobj_t *thing)
gyt = -FixedMul(tr_y, viewsin);
tz = gxt-gyt;
yscale = FixedDiv(projectiony, tz);
if (yscale < 64) return; // Fix some funky visuals
gxt = -FixedMul(tr_x, viewsin);
gyt = FixedMul(tr_y, viewcos);
tx = -(gyt + gxt);
xscale = FixedDiv(projection, tz);
x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
// Get paperoffset (offset) and paperoffset (distance)
paperoffset = -FixedMul(tr_x, cosmul) - FixedMul(tr_y, sinmul);
paperdistance = -FixedMul(tr_x, sinmul) + FixedMul(tr_y, cosmul);
if (paperdistance < 0)
{
paperoffset = -paperoffset;
paperdistance = -paperdistance;
}
centerangle = viewangle - interp.angle;
tr_x += FixedMul(offset2, cosmul);
tr_y += FixedMul(offset2, sinmul);
@@ -1472,14 +1662,72 @@ static void R_ProjectSprite(mobj_t *thing)
gyt = -FixedMul(tr_y, viewsin);
tz2 = gxt-gyt;
yscale2 = FixedDiv(projectiony, tz2);
if (yscale2 < 64) return; // ditto
//if (yscale2 < 64) return; // ditto
gxt = -FixedMul(tr_x, viewsin);
gyt = FixedMul(tr_y, viewcos);
tx2 = -(gyt + gxt);
xscale2 = FixedDiv(projection, tz2);
x2 = ((centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS);
if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier
return;
scalestep = (yscale2 - yscale)/(x2 - x1);
scalestep = scalestep ? scalestep : 1;
// Needs partially clipped
if (tz < FixedMul(MINZ, this_scale))
{
fixed_t div = FixedDiv(tz2-tz, FixedMul(MINZ, this_scale)-tz);
tx += FixedDiv(tx2-tx, div);
tz = FixedMul(MINZ, this_scale);
}
else if (tz2 < FixedMul(MINZ, this_scale))
{
fixed_t div = FixedDiv(tz-tz2, FixedMul(MINZ, this_scale)-tz2);
tx2 += FixedDiv(tx-tx2, div);
tz2 = FixedMul(MINZ, this_scale);
}
if ((tx2 / 4) < -(FixedMul(tz2, fovtan)) || (tx / 4) > FixedMul(tz, fovtan)) // too far off the side?
return;
yscale = FixedDiv(projectiony, tz);
xscale = FixedDiv(projection, tz);
x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
// off the right side?
if (x1 > viewwidth)
return;
yscale2 = FixedDiv(projectiony, tz2);
xscale2 = FixedDiv(projection, tz2);
x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS;
// off the left side
if (x2 < 0)
return;
range = x2 - x1;
if (range < 0)
return;
range++; // fencepost problem
if (range > 32767)
{
// If the range happens to be too large for fixed_t,
// abort the draw to avoid xscale becoming negative due to arithmetic overflow.
return;
}
scalestep = ((yscale2 - yscale)/range) ?: 1;
if (scalestep == 0)
scalestep = 1;
xscale = FixedDiv(range<<FRACBITS, abs(offset2));
// The following two are alternate sorting methods which might be more applicable in some circumstances. TODO - maybe enable via MF2?
// sortscale = max(yscale, yscale2);
@@ -1489,12 +1737,25 @@ static void R_ProjectSprite(mobj_t *thing)
{
scalestep = 0;
yscale = sortscale;
tx += offset;
//x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
x1 = centerx + (FixedMul(tx,xscale) / FRACUNIT);
// off the right side?
if (x1 > viewwidth)
return;
tx += offset2;
//x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--;
x2 = (centerx + (FixedMul(tx,xscale) / FRACUNIT)) - 1;
// off the left side
if (x2 < 0)
return;
}
xscale = FixedMul(xscale, ang_scale);
// PORTAL SPRITE CLIPPING
if (portalrender)
if (portalrender && portalclipline)
{
if (x2 < portalclipstart || x1 > portalclipend)
return;
@@ -1555,16 +1816,13 @@ static void R_ProjectSprite(mobj_t *thing)
if (heightsec != -1 && phs != -1) // only clip things which are in special sectors
{
fixed_t top = gzt;
fixed_t bottom = interp.z;
if (viewz < sectors[phs].floorheight ?
bottom >= sectors[heightsec].floorheight :
top < sectors[heightsec].floorheight)
interp.z >= sectors[heightsec].floorheight :
gzt < sectors[heightsec].floorheight)
return;
if (viewz > sectors[phs].ceilingheight ?
top < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight :
bottom >= sectors[heightsec].ceilingheight)
gzt < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight :
interp.z >= sectors[heightsec].ceilingheight)
return;
}
@@ -1585,12 +1843,26 @@ static void R_ProjectSprite(mobj_t *thing)
vis->pzt = vis->pz + vis->thingheight;
vis->texturemid = FixedDiv(gzt - viewz, spriteyscale);
vis->scalestep = scalestep;
vis->paperoffset = paperoffset;
vis->paperdistance = paperdistance;
vis->centerangle = centerangle;
vis->shear.tan = 0;
vis->shear.offset = 0;
vis->mobj = thing; // Easy access! Tails 06-07-2002
vis->x1 = x1 < 0 ? 0 : x1;
vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2;
// PORTAL SEMI-CLIPPING
if (portalrender && portalclipline)
{
if (vis->x1 < portalclipstart)
vis->x1 = portalclipstart;
if (vis->x2 > portalclipend)
vis->x2 = portalclipend;
}
vis->sector = thing->subsector->sector;
vis->szt = (INT16)((centeryfrac - FixedMul(vis->gzt - viewz, sortscale))>>FRACBITS);
vis->sz = (INT16)((centeryfrac - FixedMul(vis->gz - viewz, sortscale))>>FRACBITS);
@@ -1601,15 +1873,6 @@ static void R_ProjectSprite(mobj_t *thing)
else
vis->extra_colormap = thing->subsector->sector->extra_colormap;
// PORTAL SEMI-CLIPPING
if (portalrender)
{
if (vis->x1 < portalclipstart)
vis->x1 = portalclipstart;
if (vis->x2 > portalclipend)
vis->x2 = portalclipend;
}
vis->xscale = FixedMul(spritexscale, xscale); //SoM: 4/17/2000
vis->scale = FixedMul(spriteyscale, yscale); //<<detailshift;
vis->thingscale = interp.scale;
@@ -1684,11 +1947,15 @@ static void R_ProjectSprite(mobj_t *thing)
else
vis->vflip = false;
vis->isScaled = false;
if (thing->subsector->sector->numlights)
R_SplitSprite(vis, thing);
if (cv_dropshadow.value)
{
if (oldthing->haveshadow)
R_ProjectDropShadow(oldthing, vis, basetx, basetz, oldthing->shadowscale);
}
// Debug
++objectsdrawn;
}
@@ -1749,7 +2016,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
tx = -(gyt + gxt);
// too far off the side?
if (abs(tx) > tz<<2)
if (abs(tx) > FixedMul(tz, fovtan)<<2)
return;
// aspect ratio stuff :
@@ -1797,7 +2064,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
return;
// PORTAL SPRITE CLIPPING
if (portalrender)
if (portalrender && portalclipline)
{
if (x2 < portalclipstart || x1 > portalclipend)
return;
@@ -1829,12 +2096,15 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
vis->pzt = vis->pz + vis->thingheight;
vis->texturemid = vis->gzt - viewz;
vis->scalestep = 0;
vis->paperdistance = 0;
vis->shear.tan = 0;
vis->shear.offset = 0;
vis->x1 = x1 < 0 ? 0 : x1;
vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2;
// PORTAL SEMI-CLIPPING
if (portalrender)
if (portalrender && portalclipline)
{
if (vis->x1 < portalclipstart)
vis->x1 = portalclipstart;
@@ -1876,7 +2146,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
vis->colormap = colormaps;
vis->precip = true;
vis->vflip = false;
vis->isScaled = false;
weatherthink:
// okay... this is a hack, but weather isn't networked, so it should be ok
@@ -1897,7 +2166,6 @@ weatherthink:
void R_AddSprites(sector_t *sec, INT32 lightlevel)
{
mobj_t *thing;
precipmobj_t *precipthing; // Tails 08-25-2002
INT32 lightnum;
fixed_t approx_dist, limit_dist;
@@ -1933,7 +2201,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
// Handle all things in sector.
// If a limit exists, handle things a tiny bit different.
if ((limit_dist = (fixed_t)(/*(maptol & TOL_NIGHTS) ? cv_drawdist_nights.value : */cv_drawdist.value) << FRACBITS))
if ((limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale))
{
for (thing = sec->thinglist; thing; thing = thing->snext)
{
@@ -2016,21 +2284,42 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
R_ProjectSprite(thing);
}
}
}
// R_AddPrecipitationSprites
// This renders through the blockmap instead of BSP to avoid
// iterating a huge amount of precipitation sprites in sectors
// that are beyond drawdist.
//
void R_AddPrecipitationSprites(void)
{
const fixed_t drawdist = (fixed_t)(cv_drawdist_precip.value) * mapobjectscale;
INT32 xl, xh, yl, yh, bx, by;
precipmobj_t *th, *next;
// no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off
if ((limit_dist = (fixed_t)cv_drawdist_precip.value << FRACBITS))
if (drawdist == 0)
{
for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext)
return;
}
R_GetRenderBlockMapDimensions(drawdist, &xl, &xh, &yl, &yh);
for (bx = xl; bx <= xh; bx++)
{
for (by = yl; by <= yh; by++)
{
if (precipthing->precipflags & PCF_INVISIBLE)
continue;
for (th = precipblocklinks[(by * bmapwidth) + bx]; th; th = next)
{
// Store this beforehand because R_ProjectPrecipitionSprite may free th (see P_PrecipThinker)
next = th->bnext;
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
if (th->precipflags & PCF_INVISIBLE)
continue;
if (approx_dist > limit_dist)
continue;
R_ProjectPrecipitationSprite(precipthing);
R_ProjectPrecipitationSprite(th);
}
}
}
}
+17 -8
View File
@@ -67,6 +67,7 @@ void R_AddSpriteDefs(UINT16 wadnum);
//SoM: 6/5/2000: Light sprites correctly!
void R_AddSprites(sector_t *sec, INT32 lightlevel);
void R_AddPrecipitationSprites(void);
void R_InitSprites(void);
void R_ClearSprites(void);
void R_DrawMasked(void);
@@ -118,11 +119,14 @@ extern CV_PossibleValue_t Forceskin_cons_t[];
// -----------
typedef enum
{
SC_NONE = 0,
SC_TOP = 1,
SC_BOTTOM = 2,
SC_VFLIP = 3,
SC_NOTVISIBLE = 4,
// actual cuts
SC_NONE = 0,
SC_TOP = 1,
SC_BOTTOM = 1<<1,
SC_VFLIP = 1<<2,
SC_ISSCALED = 1<<3,
SC_SHADOW = 1<<4,
SC_NOTVISIBLE = 1<<5,
SC_CUTMASK = SC_TOP|SC_BOTTOM|SC_NOTVISIBLE,
SC_FLAGMASK = ~SC_CUTMASK
} spritecut_e;
@@ -148,8 +152,16 @@ typedef struct vissprite_s
fixed_t thingscale; // the object's scale
fixed_t sortscale; // sortscale only differs from scale for flat sprites
fixed_t scalestep; // only for flat sprites, 0 otherwise
fixed_t paperoffset, paperdistance; // for paper sprites, offset/dist relative to the angle
fixed_t xiscale; // negative if flipped
angle_t centerangle; // for paper sprites
struct {
fixed_t tan; // The amount to shear the sprite vertically per row
INT32 offset; // The center of the shearing location offset from x1
} shear;
fixed_t texturemid;
patch_t *patch;
@@ -171,17 +183,14 @@ typedef struct vissprite_s
spritecut_e cut;
UINT32 renderflags;
UINT8 rotateflags;
fixed_t spritexscale, spriteyscale;
fixed_t spritexoffset, spriteyoffset;
INT16 clipbot[MAXVIDWIDTH], cliptop[MAXVIDWIDTH];
boolean precip;
boolean vflip; // Flip vertically
boolean isScaled;
INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing
} vissprite_t;
+2
View File
@@ -49,6 +49,7 @@ void (*basespanfunc)(void); // default span func for color mode
void (*transtransfunc)(void); // translucent translated column drawer
void (*twosmultipatchfunc)(void); // for cols with transparent pixels
void (*twosmultipatchtransfunc)(void); // for cols with transparent pixels AND translucency
void (*dropshadowcolfunc)(void);
// ------------------
// global video state
@@ -124,6 +125,7 @@ void SCR_SetMode(void)
walldrawerfunc = R_DrawWallColumn_8;
twosmultipatchfunc = R_Draw2sMultiPatchColumn_8;
twosmultipatchtransfunc = R_Draw2sMultiPatchTranslucentColumn_8;
dropshadowcolfunc = R_DrawDropShadowColumn_8;
}
/* else if (vid.bpp > 1)
{
+1
View File
@@ -133,6 +133,7 @@ extern void (*splatfunc)(void);
extern void (*transtransfunc)(void);
extern void (*twosmultipatchfunc)(void);
extern void (*twosmultipatchtransfunc)(void);
extern void (*dropshadowcolfunc)(void);
// ----------------
// screen variables
+7 -2
View File
@@ -4039,10 +4039,15 @@ static const char *locateWad(void)
#endif
#ifndef NOHOME
// find in $HOME
I_OutputMsg(",HOME");
I_OutputMsg(",HOME/" DEFAULTDIR);
if ((envstr = I_GetEnv("HOME")) != NULL)
{
WadPath = searchWad(envstr);
char *tmp = malloc(strlen(envstr) + sizeof(PATHSEP) + sizeof(DEFAULTDIR));
strcpy(tmp, envstr);
strcat(tmp, PATHSEP);
strcat(tmp, DEFAULTDIR);
WadPath = searchWad(tmp);
free(tmp);
if (WadPath)
return WadPath;
}
+56
View File
@@ -80,6 +80,7 @@
#ifdef HWRENDER
#include "../hardware/hw_main.h"
#include "../hardware/hw_drv.h"
#include "../hardware/r_opengl/r_opengl.h" //for supportFBO
// For dynamic referencing of HW rendering functions
#include "hwsym_sdl.h"
#include "ogl_sdl.h"
@@ -215,6 +216,15 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen);
//static void Impl_SetWindowName(const char *title);
static void Impl_SetWindowIcon(void);
#ifdef USE_FBO_OGL
boolean downsample = false;
void RefreshOGLSDLSurface(void)
{
if (rendermode == render_opengl)
OglSdlSurface(vid.width, vid.height);
}
#endif
static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
{
static SDL_bool wasfullscreen = SDL_FALSE;
@@ -736,11 +746,41 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
return raxis;
}
#ifdef USE_FBO_OGL
void I_DownSample(void)
{
if (!cv_grframebuffer.value || !(rendermode == render_opengl) || (!supportFBO)) //no sense to do this crap if we cant benefit from it
{
downsample = false;
return;
}
int currentDisplayIndex = SDL_GetWindowDisplayIndex(window);
SDL_DisplayMode curmode;
if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) == 0)
{
if ((vid.width > curmode.w) || (vid.height > curmode.h)) //check if current resolution is higher than current display resolution
{
downsample = true;
RefreshOGLSDLSurface();
}
else
downsample = false; // its not so no need to do crap
}
else
downsample = false; // couldnt get display info so turn the thing off
}
#endif
static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
{
static SDL_bool firsttimeonmouse = SDL_TRUE;
static SDL_bool mousefocus = SDL_TRUE;
static SDL_bool kbfocus = SDL_TRUE;
#ifdef USE_FBO_OGL
static SDL_bool windowmoved = SDL_FALSE;
#endif
switch (evt.event)
{
@@ -760,6 +800,11 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
break;
case SDL_WINDOWEVENT_MAXIMIZED:
break;
#ifdef USE_FBO_OGL
case SDL_WINDOWEVENT_MOVED:
windowmoved = SDL_TRUE;
break;
#endif
}
if (mousefocus && kbfocus)
@@ -799,6 +844,12 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
}
}
#ifdef USE_FBO_OGL
if (windowmoved && rendermode == render_opengl)
{
I_DownSample();
}
#endif
}
static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
@@ -1877,6 +1928,11 @@ INT32 VID_SetMode(INT32 modeNum)
}
//Impl_SetWindowName("SRB2Kart "VERSIONSTRING);
#ifdef USE_FBO_OGL
if (rendermode == render_opengl)
I_DownSample();
#endif
SDLSetMode(vid.width, vid.height, USE_FULLSCREEN);
Impl_VideoSetupBuffer();
+52 -17
View File
@@ -42,6 +42,7 @@
#include "../i_system.h"
#include "hwsym_sdl.h"
#include "../m_argv.h"
#include "../i_video.h"
#ifdef DEBUG_TO_FILE
#include <stdarg.h>
@@ -149,31 +150,54 @@ boolean OglSdlSurface(INT32 w, INT32 h)
"- GPU vendor has dropped OpenGL support on your GPU and OS. (Old GPU?)\n"
"- GPU drivers are missing or broken. You may need to update your drivers.");
}
SetupGLInfo();
SetupGLFunc4();
if (majorGL == 1 && minorGL <= 3) // GL_GENERATE_MIPMAP is unavailible for OGL 1.3 and below
supportMipMap = false;
else
supportMipMap = true;
if (isExtAvailable("GL_EXT_texture_filter_anisotropic", gl_extensions))
pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy);
else
maximumAnisotropy = 1;
granisotropicmode_cons_t[1].value = maximumAnisotropy;
#ifdef USE_FBO_OGL
I_DownSample();
#endif
}
first_init = true;
if (isExtAvailable("GL_EXT_texture_filter_anisotropic", gl_extensions))
pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy);
else
maximumAnisotropy = 1;
SetupGLInfo();
SetupGLFunc4();
if (majorGL == 1 && minorGL <= 3) // GL_GENERATE_MIPMAP is unavailible for OGL 1.3 and below
supportMipMap = false;
else
supportMipMap = true;
granisotropicmode_cons_t[1].value = maximumAnisotropy;
SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0);
// The screen textures need to be flushed if the width or height change so that they be remade for the correct size
if (screen_width != w || screen_height != h)
{
FlushScreenTextures();
#ifdef USE_FBO_OGL
GLFramebuffer_DeleteAttachments();
#endif
}
screen_width = (GLint)w;
screen_height = (GLint)h;
SetModelView(w, h);
SetStates();
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
#ifdef USE_FBO_OGL
RenderToFramebuffer = FrameBufferEnabled;
GLFramebuffer_Disable();
if (RenderToFramebuffer && downsample)
GLFramebuffer_Enable();
#endif
HWR_Startup();
textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1;
@@ -198,9 +222,20 @@ void OglSdlFinishUpdate(boolean waitvbl)
oldwaitvbl = waitvbl;
SDL_GetWindowSize(window, &sdlw, &sdlh);
HWR_MakeScreenFinalTexture();
#ifdef USE_FBO_OGL
GLFramebuffer_Disable();
RenderToFramebuffer = FrameBufferEnabled;
#endif
HWR_DrawScreenFinalTexture(sdlw, sdlh);
#ifdef USE_FBO_OGL
if (RenderToFramebuffer && downsample)
GLFramebuffer_Enable();
#endif
SDL_GL_SwapWindow(window);
GClipRect(0, 0, realwidth, realheight, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT);
+8 -142
View File
@@ -153,7 +153,6 @@ player_t *stplyr;
UINT8 stplyrnum;
// SRB2kart
hudinfo_t hudinfo[NUMHUDITEMS] =
{
{ 34, 176}, // HUD_LIVESNAME
@@ -193,7 +192,7 @@ hudinfo_t hudinfo[NUMHUDITEMS] =
{ 240, 160}, // HUD_LAP
};
static huddrawlist_h luahuddrawlist_game;
static huddrawlist_h luahuddrawlist_game[MAXSPLITSCREENPLAYERS];
// variable to stop mayonaka static from flickering
consvar_t cv_lessflicker = {"lessflicker", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -473,7 +472,8 @@ void ST_Init(void)
ST_LoadGraphics();
luahuddrawlist_game = LUA_HUD_CreateDrawList();
for (int i = 0; i < MAXSPLITSCREENPLAYERS; i++)
luahuddrawlist_game[i] = LUA_HUD_CreateDrawList();
}
// change the status bar too, when pressing F12 while viewing a demo.
@@ -525,17 +525,7 @@ static void ST_drawDebugInfo(void)
if (cv_debug & DBG_DETAILED)
{
//V_DrawRightAlignedString(320, height - 104, V_MONOSPACE, va("SHIELD: %5x", stplyr->powers[pw_shield]));
V_DrawRightAlignedString(320, height - 96, V_MONOSPACE, va("SCALE: %5d%%", (stplyr->mo->scale*100)/FRACUNIT));
//V_DrawRightAlignedString(320, height - 88, V_MONOSPACE, va("DASH: %3d/%3d", stplyr->dashspeed>>FRACBITS, FixedMul(stplyr->maxdash,stplyr->mo->scale)>>FRACBITS));
//V_DrawRightAlignedString(320, height - 80, V_MONOSPACE, va("AIR: %4d, %3d", stplyr->powers[pw_underwater], stplyr->powers[pw_spacetime]));
// Flags
//V_DrawRightAlignedString(304-64, height - 72, V_MONOSPACE, "Flags:");
//V_DrawString(304-60, height - 72, (stplyr->jumping) ? V_GREENMAP : V_REDMAP, "JM");
//V_DrawString(304-40, height - 72, (stplyr->pflags & PF_JUMPED) ? V_GREENMAP : V_REDMAP, "JD");
//V_DrawString(304-20, height - 72, (stplyr->pflags & PF_SPINNING) ? V_GREENMAP : V_REDMAP, "SP");
//V_DrawString(304, height - 72, (stplyr->pflags & PF_STARTDASH) ? V_GREENMAP : V_REDMAP, "ST");
V_DrawRightAlignedString(320, height - 64, V_MONOSPACE, va("CEILZ: %6d", stplyr->mo->ceilingz>>FRACBITS));
V_DrawRightAlignedString(320, height - 56, V_MONOSPACE, va("FLOORZ: %6d", stplyr->mo->floorz>>FRACBITS));
@@ -569,132 +559,6 @@ static void ST_drawDebugInfo(void)
V_DrawRightAlignedString(320, height, V_MONOSPACE, va("Heap used: %7sKB", sizeu1(Z_TagsUsage(0, INT32_MAX)>>10)));
}
/*
static void ST_drawScore(void)
{
// SCORE:
ST_DrawPatchFromHud(HUD_SCORE, sboscore);
if (objectplacing)
{
if (op_displayflags > UINT16_MAX)
ST_DrawOverlayPatch(SCX(hudinfo[HUD_SCORENUM].x-tallminus->width), SCY(hudinfo[HUD_SCORENUM].y), tallminus);
else
ST_DrawNumFromHud(HUD_SCORENUM, op_displayflags);
}
else
ST_DrawNumFromHud(HUD_SCORENUM, stplyr->score);
}
*/
/*
static void ST_drawTime(void)
{
INT32 seconds, minutes, tictrn, tics;
// TIME:
ST_DrawPatchFromHudWS(HUD_TIME, sbotime);
if (objectplacing)
{
tics = objectsdrawn;
seconds = objectsdrawn%100;
minutes = objectsdrawn/100;
tictrn = 0;
}
else
{
tics = stplyr->realtime;
seconds = G_TicsToSeconds(tics);
minutes = G_TicsToMinutes(tics, true);
tictrn = G_TicsToCentiseconds(tics);
}
if (cv_timetic.value == 1) // Tics only -- how simple is this?
ST_DrawNumFromHudWS(HUD_SECONDS, tics);
else
{
ST_DrawNumFromHudWS(HUD_MINUTES, minutes); // Minutes
ST_DrawPatchFromHudWS(HUD_TIMECOLON, sbocolon); // Colon
ST_DrawPadNumFromHudWS(HUD_SECONDS, seconds, 2); // Seconds
if (!splitscreen && (cv_timetic.value == 2 || modeattacking)) // there's not enough room for tics in splitscreen, don't even bother trying!
{
ST_DrawPatchFromHud(HUD_TIMETICCOLON, sboperiod); // Period
ST_DrawPadNumFromHud(HUD_TICS, tictrn, 2); // Tics
}
}
}
*/
/*
static inline void ST_drawRings(void) // SRB2kart - unused.
{
INT32 ringnum = max(stplyr->health-1, 0);
ST_DrawPatchFromHudWS(HUD_RINGS, ((stplyr->health <= 1 && leveltime/5 & 1) ? rrings : sborings));
if (objectplacing)
ringnum = op_currentdoomednum;
else if (!useNightsSS && G_IsSpecialStage(gamemap))
{
INT32 i;
ringnum = 0;
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && players[i].mo->health > 1)
ringnum += players[i].mo->health - 1;
}
ST_DrawNumFromHudWS(HUD_RINGSNUM, ringnum);
}
*/
/*
static void ST_drawLives(void) // SRB2kart - unused.
{
const INT32 v_splitflag = (splitscreen && stplyr == &players[displayplayers[0]] ? V_SPLITSCREEN : 0);
if (!stplyr->skincolor)
return; // Just joined a server, skin isn't loaded yet!
// face background
V_DrawSmallScaledPatch(hudinfo[HUD_LIVESPIC].x, hudinfo[HUD_LIVESPIC].y + (v_splitflag ? -12 : 0),
V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, livesback);
// face
if (stplyr->mo && stplyr->mo->color)
{
// skincolor face/super
UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, stplyr->mo->color, GTC_CACHE);
patch_t *face = facerankprefix[stplyr->skin];
if (stplyr->powers[pw_super] || stplyr->pflags & PF_NIGHTSMODE)
face = facewantprefix[stplyr->skin];
V_DrawSmallMappedPatch(hudinfo[HUD_LIVESPIC].x, hudinfo[HUD_LIVESPIC].y + (v_splitflag ? -12 : 0),
V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag,face, colormap);
}
else if (stplyr->skincolor)
{
// skincolor face
UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, stplyr->skincolor, GTC_CACHE);
V_DrawSmallMappedPatch(hudinfo[HUD_LIVESPIC].x, hudinfo[HUD_LIVESPIC].y + (v_splitflag ? -12 : 0),
V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag,facerankprefix[stplyr->skin], colormap);
}
// name
if (strlen(skins[stplyr->skin].hudname) > 8)
V_DrawThinString(hudinfo[HUD_LIVESNAME].x, hudinfo[HUD_LIVESNAME].y + (v_splitflag ? -12 : 0),
V_HUDTRANS|V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_MONOSPACE|V_YELLOWMAP|v_splitflag, skins[stplyr->skin].hudname);
else
V_DrawString(hudinfo[HUD_LIVESNAME].x, hudinfo[HUD_LIVESNAME].y + (v_splitflag ? -12 : 0),
V_HUDTRANS|V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_MONOSPACE|V_YELLOWMAP|v_splitflag, skins[stplyr->skin].hudname);
// x
V_DrawScaledPatch(hudinfo[HUD_LIVESX].x, hudinfo[HUD_LIVESX].y + (v_splitflag ? -4 : 0),
V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, stlivex);
// lives
V_DrawRightAlignedString(hudinfo[HUD_LIVESNUM].x, hudinfo[HUD_LIVESNUM].y + (v_splitflag ? -4 : 0),
V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, va("%d",stplyr->lives));
}
*/
static void ST_drawLevelTitle(void)
{
char *lvlttl = mapheaderinfo[gamemap-1]->lvlttl;
@@ -846,7 +710,7 @@ static void ST_overlayDrawer(void)
{
if (renderisnewtic)
{
LUAh_GameHUD(stplyr, luahuddrawlist_game);
LUAh_GameHUD(luahuddrawlist_game[stplyrnum]);
}
}
@@ -1024,7 +888,8 @@ void ST_Drawer(void)
{
if (renderisnewtic)
{
LUA_HUD_ClearDrawList(luahuddrawlist_game);
for (i = 0; i <= splitscreen; i++)
LUA_HUD_ClearDrawList(luahuddrawlist_game[i]);
}
// No deadview!
@@ -1035,7 +900,8 @@ void ST_Drawer(void)
ST_overlayDrawer();
}
LUA_HUD_DrawList(luahuddrawlist_game);
for (i = 0; i <= splitscreen; i++)
LUA_HUD_DrawList(luahuddrawlist_game[i]);
// draw Midnight Channel's overlay ontop
if (mapheaderinfo[gamemap-1]->typeoflevel & TOL_TV) // Very specific Midnight Channel stuff.
+5
View File
@@ -24,6 +24,7 @@
#define FINEMASK (FINEANGLES - 1)
#define ANGLETOFINESHIFT 19 // 0x100000000 to 0x2000
#define FINEANGLE_C(x) ((FixedAngle((x)*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK) // ((x*(ANGLE_45/45))>>ANGLETOFINESHIFT) & FINEMASK
#define ANGLETOFINE(x) (((x)>>ANGLETOFINESHIFT) & FINEMASK)
// Effective size is 10240.
extern fixed_t finesine[5*FINEANGLES/4];
@@ -121,4 +122,8 @@ void FM_Rotate(matrix_t *dest, angle_t angle, fixed_t x, fixed_t y, fixed_t z);
#define FINECOSINE(n) (finecosine[n]>>(FINE_FRACBITS-FRACBITS))
#define FINETANGENT(n) (finetangent[n]>>(FINE_FRACBITS-FRACBITS))
// FSIN(ANGLE_90) = FRACUNIT
#define FSIN(n) FINESINE(ANGLETOFINE(n))
#define FCOS(n) FINECOSINE(ANGLETOFINE(n))
#endif
+19 -3
View File
@@ -631,7 +631,7 @@ static inline UINT8 transmappedpdraw(const UINT8 *dest, const UINT8 *source, fix
void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap)
{
UINT8 (*patchdrawfunc)(const UINT8*, const UINT8*, fixed_t);
UINT32 alphalevel = 0;
UINT32 alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT);
fixed_t col, ofs, colfrac, rowfrac, fdup, vdup;
INT32 dupx, dupy;
@@ -656,7 +656,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
patchdrawfunc = standardpdraw;
v_translevel = NULL;
if ((alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT)))
if (alphalevel)
{
if (alphalevel == 13)
alphalevel = hudminusalpha[hudtrans];
@@ -2944,6 +2944,9 @@ INT32 V_ThinStringWidth(const char *string, INT32 option)
if ((UINT8)c >= 0x80 && (UINT8)c <= 0x8F) //color parsing! -Inuyasha 2.16.09
continue;
if (c < HU_FONTSTART)
continue;
if (!lowercase || !tny_font[c-HU_FONTSTART])
c = toupper(c);
c -= HU_FONTSTART;
@@ -3311,6 +3314,19 @@ Unoptimized version
tmpscr[y*vid.width + x2] = srcscr[y*vid.width + x];
}
VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset,
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width);
}
else if (type == postimg_mirrorflip) // Flip the screen upside-down and on the x axis
{
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
INT32 y, x;
for (y = yoffset; y < yoffset + viewheight; y++)
for (x = xoffset; x < xoffset + viewwidth; x++)
tmpscr[((yoffset + viewheight - 1 - y) * vid.width) + xoffset + viewwidth - (x - xoffset) - 1] = srcscr[(y * vid.width) + x];
VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset,
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width);
}
@@ -3367,7 +3383,7 @@ void V_Init(void)
#ifdef DEBUG
CONS_Debug(DBG_RENDER, "V_Init done:\n");
for (i = 0; i < NUMSCREENS+1; i++)
for (i = 0; i < NUMSCREENS; i++)
CONS_Debug(DBG_RENDER, " screens[%d] = %x\n", i, screens[i]);
#endif
}
+3 -4
View File
@@ -186,9 +186,9 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors)
if (filenamebuf != *filename) {
// avoid overlap
strncpy(filenamebuf, *filename, MAX_WADPATH);
filenamebuf[MAX_WADPATH - 1] = '\0';
*filename = filenamebuf;
}
filenamebuf[MAX_WADPATH - 1] = '\0';
*filename = filenamebuf;
// open wad file
if ((handle = fopen_utf8(*filename, "rb")) == NULL)
@@ -789,7 +789,7 @@ UINT16 W_InitFile(const char *filename, boolean local)
//
// link wad file to search files
//
wadfile = Z_Malloc(sizeof (*wadfile), PU_STATIC, NULL);
wadfile = Z_Calloc(sizeof (*wadfile), PU_STATIC, NULL);
wadfile->filename = Z_StrDup(filename);
wadfile->handle = handle;
wadfile->numlumps = (UINT16)numlumps;
@@ -798,7 +798,6 @@ UINT16 W_InitFile(const char *filename, boolean local)
fseek(handle, 0, SEEK_END);
wadfile->filesize = (unsigned)ftell(handle);
wadfile->type = type;
wadfile->majormod = false;
// already generated, just copy it over
M_Memcpy(&wadfile->md5sum, &md5sum, 16);
+25 -19
View File
@@ -100,10 +100,10 @@ static y_data data;
static patch_t *bgpatch = NULL; // INTERSCR
static patch_t *widebgpatch = NULL; // INTERSCW
static patch_t *bgtile = NULL; // SPECTILE/SRB2BACK
static patch_t *interpic = NULL; // custom picture defined in map header
static boolean usetile;
//static patch_t *interpic = NULL; // custom picture defined in map header
//static boolean usetile;
boolean usebuffer = false;
static boolean useinterpic;
//static boolean useinterpic;
static INT32 timer;
static INT32 intertic;
@@ -163,7 +163,6 @@ typedef struct
static y_votelvlinfo levelinfo[5];
static y_voteclient voteclient;
static INT32 votetic;
static INT32 lastvotetic;
static INT32 voteendtic = -1;
static patch_t *cursor = NULL;
static patch_t *cursor1 = NULL;
@@ -393,9 +392,16 @@ void Y_IntermissionDrawer(void)
if (!usebuffer)
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
if (useinterpic)
V_DrawScaledPatch(0, 0, 0, interpic);
else if (!usetile)
if (cv_betainterscreen.value
#ifdef HWRENDER
|| (rendermode == render_opengl && cv_grscreentextures.value != 2) // use the neato kart bg for intermission on disabled screen textures
#endif
)
V_DrawPatchFill(bgtile); // use the neato kart bg for intermission on disabled screen textures
//else if (useinterpic)
//V_DrawScaledPatch(0, 0, 0, interpic);
//else if (!usetile)
else
{
if (rendermode == render_soft && usebuffer)
VID_BlitLinearScreen(screens[1], screens[0], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes);
@@ -413,8 +419,8 @@ void Y_IntermissionDrawer(void)
V_DrawScaledPatch(0, 0, 0, bgpatch);
}
}
else if (bgtile)
V_DrawPatchFill(bgtile);
//else if (bgtile)
//V_DrawPatchFill(bgtile);
if (usebuffer) // Fade everything out
V_DrawFadeScreen(0xFF00, 22);
@@ -938,8 +944,8 @@ void Y_StartIntermission(void)
//if (intertype == int_race || intertype == int_match)
{
//bgtile = W_CachePatchName("SRB2BACK", PU_STATIC);
usetile = useinterpic = false;
bgtile = W_CachePatchName("SRB2BACK", PU_STATIC);
//usetile = useinterpic = false;
usebuffer = true;
}
@@ -989,7 +995,7 @@ static void Y_UnloadData(void)
UNLOAD(bgpatch);
UNLOAD(widebgpatch);
UNLOAD(bgtile);
UNLOAD(interpic);
//UNLOAD(interpic);
}
// SRB2Kart: Voting!
@@ -1016,11 +1022,13 @@ static inline void Y_DrawAnimatedVoteScreenPatch(boolean widePatch)
currentAnimFrame = 0;
}
patch_t *background = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame + 1), PU_CACHE);
V_DrawScaledPatch(160 - (background->width / 2), (200 - (background->height)), V_SNAPTOBOTTOM|V_SNAPTOTOP, background);
patch_t *background = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame + 1), PU_CACHE);
V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(background->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?)
(vid.height / vid.dupy) - SHORT(background->height),
V_SNAPTOTOP|V_SNAPTOLEFT, background);
if (lastvotetic != votetic && lastvotetic % 2 == 0)
currentAnimFrame = (currentAnimFrame + 1 > tempFoundAnimVoteFrames - 1) ? 0 : currentAnimFrame + 1; // jeez no fucking idea how to make this shit not go nuts with interpolation
if (renderisnewtic && votetic % 2 == 0 && !paused)
currentAnimFrame = (currentAnimFrame + 1 > tempFoundAnimVoteFrames - 1) ? 0 : currentAnimFrame + 1;
}
//
@@ -1287,8 +1295,6 @@ void Y_VoteDrawer(void)
V_DrawCenteredString(BASEVIDWIDTH/2, 188, hilicol,
va("Vote ends in %d", tickdown));
}
lastvotetic = votetic;
if (renderisnewtic)
{
@@ -1486,7 +1492,7 @@ void Y_VoteTicker(void)
if ((InputDown(gc_accelerate, i+1) || JoyAxis(AXISMOVE, i+1) > 0) && !pressed)
{
D_ModifyClientVote(voteclient.playerinfo[i].selection, i);
D_ModifyClientVote(voteclient.playerinfo[i].selection, p);
pressed = true;
}
}