diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a46ed462f..dbb35c80c2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -395,6 +395,26 @@ jobs: artifact_name: OpenJO-rend2-macos-x86_64.tar.gz zip: false + - artifact_dir: OpenJO-windows-x86-Release-Non-Portable/JediOutcast + artifact_name: OpenJO-windows-x86.zip + zip: true + + - artifact_dir: OpenJO-windows-x86_64-Release-Non-Portable/JediOutcast + artifact_name: OpenJO-windows-x86_64.zip + zip: true + + - artifact_dir: OpenJO-linux-x86-Release-Non-Portable + artifact_name: OpenJO-linux-x86.tar.gz + zip: false + + - artifact_dir: OpenJO-linux-x86_64-Release-Non-Portable + artifact_name: OpenJO-linux-x86_64.tar.gz + zip: false + + - artifact_dir: OpenJO-macos-x86_64-Release-Non-Portable + artifact_name: OpenJO-macos-x86_64.tar.gz + zip: false + steps: - uses: actions/checkout@v3 with: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4dbb097d33..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ -language: cpp -sudo: required -dist: bionic - -addons: - homebrew: - update: true - packages: - - libpng - - sdl2 - -install: - - if [[ "${TRAVIS_OS_NAME}" != "osx" ]]; then ./scripts/travis/install.sh "${host:-native}" $opts; fi -script: ./scripts/travis/build.sh "${host:-native}" "${flavour:-Release}" $opts - -matrix: - include: - # Linux x64 Release - - os: linux - compiler: gcc - - # macOS - - os: osx - osx_image: xcode9.4 - compiler: clang - - # Linux x64 Debug - - os: linux - compiler: gcc - env: flavour=Debug - - # Linux i686 gcc - - os: linux - compiler: gcc - env: host=i686-linux-gnu - - # Linux x64 mingw32 - - os: linux - compiler: gcc - env: host=x86_64-w64-mingw32 - - # Linux i686 mingw32 - - os: linux - compiler: gcc - env: host=i686-w64-mingw32 - - # Linux clang - - os: linux - compiler: clang diff --git a/CMakeLists.txt b/CMakeLists.txt index a28062e896..2be755ea6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,17 @@ #============================================================================ # Copyright (C) 2013 - 2018, OpenJK contributors -# +# # This file is part of the OpenJK source code. -# +# # OpenJK is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, see . #============================================================================ @@ -67,7 +67,7 @@ set(UseInternalPNGDefault OFF) set(UseInternalJPEGDefault OFF) set(UseInternalSDL2Default OFF) -if(WIN32) +if(UseInternalLibs OR WIN32) set(UseInternalOpenALDefault ON) set(UseInternalZlibDefault ON) set(UseInternalPNGDefault ON) @@ -252,7 +252,7 @@ elseif (("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" M # enable somewhat modern C++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - + if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-comment") diff --git a/Dockerfile b/Dockerfile index a63a4c6199..37614696e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ RUN mkdir /usr/src/openjk/build.i386 &&\ cmake -DCMAKE_TOOLCHAIN_FILE=/usr/src/openjk/cmake/Toolchains/linux-i686.cmake \ -DCMAKE_INSTALL_PREFIX=/opt \ -DBuildMPCGame=OFF -DBuildMPEngine=OFF -DBuildMPRdVanilla=OFF -DBuildMPUI=OFF \ - -DBuildSPEngine=OFF -DBuildSPGame=OFF -DBuildSPRdVanilla=OFF \ + -DBuildSPEngine=OFF -DBuildSPGame=OFF -DBuildSPRdVanilla=OFF -DBuildMPRend2=OFF \ .. &&\ make &&\ make install @@ -26,7 +26,7 @@ RUN mkdir /usr/src/openjk/build.x86_64 &&\ cd /usr/src/openjk/build.x86_64 &&\ cmake -DCMAKE_INSTALL_PREFIX=/opt \ -DBuildMPCGame=OFF -DBuildMPEngine=OFF -DBuildMPRdVanilla=OFF -DBuildMPUI=OFF \ - -DBuildSPEngine=OFF -DBuildSPGame=OFF -DBuildSPRdVanilla=OFF \ + -DBuildSPEngine=OFF -DBuildSPGame=OFF -DBuildSPRdVanilla=OFF -DBuildMPRend2=OFF \ .. &&\ make &&\ make install diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index e0b9601c6e..0000000000 --- a/appveyor.yml +++ /dev/null @@ -1,74 +0,0 @@ -version: 1.0.{build} - -branches: - except: - - release/1.0 - -clone_depth: 1 -shallow_clone: true - -#do not build on tags -skip_tags: true - -os: Visual Studio 2013 - -environment: - VisualStudioVersion: "12.0" - CMAKE_GENERATOR: "Visual Studio 12 2013" - -matrix: - fast_finish: false #finish build once one of the jobs fails - -platform: - - Win32 - - x64 - -configuration: - - Debug - - Release - -init: - - ps: $env:SHORT_COMMIT_HASH=$env:appveyor_repo_commit.substring(0,8) - - ps: Update-AppveyorBuild -Version "1.0-git-$env:SHORT_COMMIT_HASH" - - ps: $env:ARTIFACT_FILE="openjk-$(Get-Date -UFormat "%Y-%m-%d")-$env:SHORT_COMMIT_HASH-windows.zip" - - echo "Artifact file='%ARTIFACT_FILE%'" - - cmake --version - - msbuild /version - -clone_folder: C:\projects\OpenJK - -#scripts to run before build -before_build: - - cd %APPVEYOR_BUILD_FOLDER% - - if "%Platform%"=="x64" set "CMAKE_GENERATOR=%CMAKE_GENERATOR% Win64" - - echo "Generator='%CMAKE_GENERATOR%'" - - echo "Platform='%Platform%'" - - if exist build rmdir /q /s build #remove build dir - - mkdir build - - cd build - - cmake -DCMAKE_INSTALL_PREFIX=install -G "%CMAKE_GENERATOR%" "%APPVEYOR_BUILD_FOLDER%" - - ls - -build: - parallel: true - project: C:\projects\OpenJK\build\OpenJK.sln - verbosity: normal - -after_build: - - cmake --build . --target INSTALL --config %CONFIGURATION% - - cd %APPVEYOR_BUILD_FOLDER% - - 7z a %ARTIFACT_FILE% %APPVEYOR_BUILD_FOLDER%/build/install/JediAcademy/* - - 7z l %ARTIFACT_FILE% # list files in the zip file - -artifacts: - - path: openjk-*-windows.zip - name: OpenJK Jedi Academy ZIP - type: zip - -deploy_script: - - ps: $key = $env:DeploymentKey - - ps: $fileContent = "-----BEGIN RSA PRIVATE KEY-----" + "`n" - - ps: for ($i = 0; $i -lt $key.Length / 64; $i++) { $min = [math]::min(64, $key.Length - ($i * 64)); $fileContent += $key.substring($i*64, $min) + "`n"; } - - ps: $fileContent += "-----END RSA PRIVATE KEY-----" + "`n" - - ps: Set-Content C:\users\appveyor\.ssh\id_rsa $fileContent - - scripts/appveyor/deploy.bat %ARTIFACT_FILE% diff --git a/cmake/Modules/InstallConfig.cmake b/cmake/Modules/InstallConfig.cmake index a25f87f0f5..c8c493b61b 100644 --- a/cmake/Modules/InstallConfig.cmake +++ b/cmake/Modules/InstallConfig.cmake @@ -1,17 +1,17 @@ #============================================================================ # Copyright (C) 2015, OpenJK contributors -# +# # This file is part of the OpenJK source code. -# +# # OpenJK is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, see . #============================================================================ @@ -71,7 +71,7 @@ if(WIN32) set(CPACK_NSIS_PACKAGE_NAME "OpenJK") set(CPACK_NSIS_MUI_ICON "${SharedDir}/icons/icon.ico") set(CPACK_NSIS_MUI_UNIICON "${SharedDir}/icons/icon.ico") - set(CPACK_NSIS_URL_INFO_ABOUT "http://openjk.org") + set(CPACK_NSIS_URL_INFO_ABOUT "https://openjk.org") set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) include(InstallRequiredSystemLibraries) @@ -121,8 +121,8 @@ if(WIN32) endif() # Don't run this for now until we have JK2 SP working - if(FALSE AND BuildJK2SPEngine) - string(REPLACE "/" "\\\\" ICON "${SPDir}/win32/starwars.ico") + if(BuildJK2SPEngine) + string(REPLACE "/" "\\\\" ICON "${JK2SPDir}/win32/starwars.ico") set(CPACK_NSIS_CREATE_ICONS_EXTRA "${CPACK_NSIS_CREATE_ICONS_EXTRA} CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Jedi Outcast SP.lnk' \\\\ diff --git a/code/client/cl_cgame.cpp b/code/client/cl_cgame.cpp index b9d7b6fc11..c57c3ba010 100644 --- a/code/client/cl_cgame.cpp +++ b/code/client/cl_cgame.cpp @@ -1006,7 +1006,7 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) { case CG_R_GETLIGHTING: return re.GetLighting( (const float * ) VMA(1), (float *) VMA(2), (float *) VMA(3), (float *) VMA(4) ); case CG_R_ADDPOLYTOSCENE: - re.AddPolyToScene( args[1], args[2], (const polyVert_t *) VMA(3) ); + re.AddPolyToScene( args[1], args[2], (const polyVert_t *) VMA(3), 1 ); return 0; case CG_R_ADDLIGHTTOSCENE: re.AddLightToScene( (const float *) VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); diff --git a/code/client/cl_cin.cpp b/code/client/cl_cin.cpp index 7cf2db8c2f..b2c34a74f8 100644 --- a/code/client/cl_cin.cpp +++ b/code/client/cl_cin.cpp @@ -1667,7 +1667,7 @@ static void CIN_AddTextCrawl() // render it out re.ClearScene(); - re.AddPolyToScene( cinTable[CL_handle].hCRAWLTEXT, 4, verts ); + re.AddPolyToScene( cinTable[CL_handle].hCRAWLTEXT, 4, verts, 1 ); re.RenderScene( &refdef ); //time's up diff --git a/code/client/cl_ui.cpp b/code/client/cl_ui.cpp index 80d002f1f3..743aeb3381 100644 --- a/code/client/cl_ui.cpp +++ b/code/client/cl_ui.cpp @@ -264,7 +264,7 @@ void CL_InitUI( void ) { #endif uii.R_ClearScene = re.ClearScene; uii.R_AddRefEntityToScene = re.AddRefEntityToScene; - uii.R_AddPolyToScene = re.AddPolyToScene; + uii.R_AddPolyToScene = re.AddPolyToScene; uii.R_AddLightToScene = re.AddLightToScene; uii.R_RenderScene = re.RenderScene; diff --git a/code/rd-common/tr_public.h b/code/rd-common/tr_public.h index 4b05a5eca4..94ffc4ae2a 100644 --- a/code/rd-common/tr_public.h +++ b/code/rd-common/tr_public.h @@ -178,7 +178,7 @@ typedef struct { // Nothing is drawn until R_RenderScene is called. void (*ClearScene)( void ); void (*AddRefEntityToScene)( const refEntity_t *re ); - void (*AddPolyToScene)( qhandle_t hShader , int numVerts, const polyVert_t *verts ); + void (*AddPolyToScene)( qhandle_t hShader , int numVerts, const polyVert_t *verts, int numPolys ); void (*AddLightToScene)( const vec3_t org, float intensity, float r, float g, float b ); void (*RenderScene)( const refdef_t *fd ); qboolean(*GetLighting)( const vec3_t org, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir); diff --git a/code/rd-common/tr_types.h b/code/rd-common/tr_types.h index 56e8704c49..6e6d63eba9 100644 --- a/code/rd-common/tr_types.h +++ b/code/rd-common/tr_types.h @@ -35,8 +35,10 @@ along with this program; if not, see . #define MAX_REFENTITIES ((1<. #define RF_SHADOW_PLANE 0x00100 // use refEntity->shadowPlane #define RF_WRAP_FRAMES 0x00200 // mod the model frames by the maxframes to allow continuous // animation without needing to know the frame count -#define RF_CAP_FRAMES 0x00400 // cap the model frames by the maxframes for one shot anims -#define RF_ALPHA_FADE 0x00800 // hacks blend mode and uses whatever the set alpha is. -#define RF_PULSATE 0x01000 // for things like a dropped saber, where we want to add an extra visual clue -#define RF_RGB_TINT 0x02000 // overrides ent RGB color to the specified color +#define RF_FORCE_ENT_ALPHA 0x00400 // override shader alpha settings +#define RF_RGB_TINT 0x00800 // override shader rgb settings + +#define RF_SHADOW_ONLY 0x01000 //add surfs for shadowing but don't draw them -rww + +#define RF_DISTORTION 0x02000 //area distortion effect -rww #define RF_FORKED 0x04000 // override lightning to have forks #define RF_TAPERED 0x08000 // lightning tapers #define RF_GROW 0x10000 // lightning grows from start to end during its life -#define RF_SETANIMINDEX 0x20000 //use backEnd.currentEntity->e.skinNum for R_BindAnimatedImage - -#define RF_DISINTEGRATE1 0x40000 // does a procedural hole-ripping thing. -#define RF_DISINTEGRATE2 0x80000 // does a procedural hole-ripping thing with scaling at the ripping point +#define RF_DISINTEGRATE1 0x20000 // does a procedural hole-ripping thing. +#define RF_DISINTEGRATE2 0x40000 // does a procedural hole-ripping thing with scaling at the ripping point -#define RF_G2MINLOD 0x100000 // force Lowest lod on g2 +#define RF_SETANIMINDEX 0x80000 //use backEnd.currentEntity->e.skinNum for R_BindAnimatedImage -#define RF_SHADOW_ONLY 0x200000 //add surfs for shadowing but don't draw them normally -rww +#define RF_ALPHA_DEPTH 0x100000 //depth write on alpha model -#define RF_DISTORTION 0x400000 //area distortion effect -rww +#define RF_FORCEPOST 0x200000 //force it to post-render -rww -#define RF_FORCE_ENT_ALPHA 0x800000 // override shader alpha settings +// SP renderfx flags, only use in SP! +#define RF_CAP_FRAMES 0x400000 // cap the model frames by the maxframes for one shot anims +#define RF_ALPHA_FADE 0x800000 // hacks blend mode and uses whatever the set alpha is. +#define RF_PULSATE 0x1000000 // for things like a dropped saber, where we want to add an extra visual clue +#define RF_G2MINLOD 0x2000000 // force Lowest lod on g2 +#define RF_MORELIGHT 0x4000000 // allways have some light (viewmodel, some items) | SP version which is different from MP // refdef flags #define RDF_NOWORLDMODEL 1 // used for player configuration screen @@ -83,9 +90,12 @@ along with this program; if not, see . #define RDF_SKYBOXPORTAL 8 #define RDF_DRAWSKYBOX 16 // the above marks a scene as being a 'portal sky'. this flag says to draw it or not -#define RDF_doLAGoggles 32 // Light Amp goggles -#define RDF_doFullbright 64 // Light Amp goggles -#define RDF_ForceSightOn 128 // using force sight +#define RDF_AUTOMAP 32 // MP only means this scene is to draw the automap -rww +#define RDF_NOFOG 64 // MP only no global fog in this scene (but still brush fog) -rww +#define RDF_ForceSightOn 128 //using force sight + +#define RDF_doLAGoggles 256 // SP only Light Amp goggles +#define RDF_doFullbright 512 // SP only Light Amp goggles extern int skyboxportal; @@ -105,77 +115,178 @@ typedef struct poly_s { polyVert_t *verts; } poly_t; -typedef enum -{ +typedef enum { RT_MODEL, RT_POLY, RT_SPRITE, RT_ORIENTED_QUAD, - RT_LINE, - RT_ELECTRICITY, - RT_CYLINDER, - RT_LATHE, RT_BEAM, RT_SABER_GLOW, + RT_ELECTRICITY, RT_PORTALSURFACE, // doesn't draw anything, just info for portals + RT_LINE, + RT_ORIENTEDLINE, + RT_CYLINDER, + RT_ENT_CHAIN, + + RT_MAX_MP_REF_ENTITY_TYPE, + // SP ONLY Entity Types! + RT_LATHE, RT_CLOUDS, - RT_MAX_REF_ENTITY_TYPE + RT_MAX_SP_REF_ENTITY_TYPE } refEntityType_t; -typedef struct { - refEntityType_t reType; - int renderfx; +typedef struct miniRefEntity_s +{ + refEntityType_t reType; + int renderfx; - qhandle_t hModel; // opaque type outside refresh + qhandle_t hModel; // opaque type outside refresh // most recent data - vec3_t lightingOrigin; // so multi-part models can be lit identically (RF_LIGHTING_ORIGIN) - float shadowPlane; // projection shadows go here, stencils go slightly lower + matrix3_t axis; // rotation vectors + qboolean nonNormalizedAxes; // axis are not normalized, i.e. they have scale + vec3_t origin; // also used as MODEL_BEAM's "from" + + // previous data for frame interpolation + vec3_t oldorigin; // also used as MODEL_BEAM's "to" + + // texturing + qhandle_t customShader; // use one image for the entire thing - vec3_t axis[3]; // rotation vectors - qboolean nonNormalizedAxes; // axis are not normalized, i.e. they have scale - float origin[3]; // also used as MODEL_BEAM's "from" + // misc + byte shaderRGBA[4]; // colors used by rgbgen entity shaders + vec2_t shaderTexCoord; // texture coordinates used by tcMod entity modifiers + + // extra sprite information + float radius; + float rotation; // size 2 for RT_CYLINDER or number of verts in RT_ELECTRICITY + + // misc + float shaderTime; // subtracted from refdef time to control effect start times int frame; // also used as MODEL_BEAM's diameter +} miniRefEntity_t; + +typedef struct refEntity_s { + // this stucture must remain identical as the miniRefEntity_t + // + // + refEntityType_t reType; + int renderfx; + + qhandle_t hModel; // opaque type outside refresh + + // most recent data + matrix3_t axis; // rotation vectors + qboolean nonNormalizedAxes; // axis are not normalized, i.e. they have scale + vec3_t origin; // also used as MODEL_BEAM's "from" + // previous data for frame interpolation - float oldorigin[3]; // also used as MODEL_BEAM's "to" - int oldframe; - float backlerp; // 0.0 = current, 1.0 = old + vec3_t oldorigin; // also used as MODEL_BEAM's "to" // texturing - int skinNum; // inline skin index + qhandle_t customShader; // use one image for the entire thing - qhandle_t customSkin; // NULL for default skin - qhandle_t customShader; // use one image for the entire thing + // misc + byte shaderRGBA[4]; // colors used by rgbgen entity shaders + vec2_t shaderTexCoord; // texture coordinates used by tcMod entity modifiers + + // extra sprite information + float radius; + float rotation; // misc - byte shaderRGBA[4]; // colors used by colorSrc=vertex shaders - float shaderTexCoord[2]; // texture coordinates used by tcMod=vertex modifiers float shaderTime; // subtracted from refdef time to control effect start times + int frame; // also used as MODEL_BEAM's diameter + // + // + // end miniRefEntity_t - // extra sprite information - float radius; + // + // + // specific full refEntity_t data + // + // + + // most recent data + vec3_t lightingOrigin; // so multi-part models can be lit identically (RF_LIGHTING_ORIGIN) + float shadowPlane; // projection shadows go here, stencils go slightly lower - // This doesn't have to be unioned, but it does make for more meaningful variable names :) + // previous data for frame interpolation + int oldframe; + float backlerp; // 0.0 = current, 1.0 = old + + // texturing + int skinNum; // inline skin index + qhandle_t customSkin; // NULL for default skin + + // texturing union { - float rotation; - float endTime; - float saberLength; - }; + // int skinNum; // inline skin index + // ivec3_t terxelCoords; // coords of patch for RT_TERXELS + struct + { + int miniStart; + int miniCount; + } uMini; + } uRefEnt; -/* -Ghoul2 Insert Start -*/ + // extra sprite information + union { + struct + { + float rotation; + float radius; + byte vertRGBA[4][4]; + } sprite; + struct + { + float width; + float width2; + float stscale; + } line; + struct // that whole put-the-opening-brace-on-the-same-line-as-the-beginning-of-the-definition coding style is fecal + { + float width; + vec3_t control1; + vec3_t control2; + } bezier; + struct + { + float width; + float width2; + float stscale; + float height; + float bias; + qboolean wrap; + } cylinder; + struct + { + float width; + float deviation; + float stscale; + qboolean wrap; + qboolean taper; + } electricity; + } data; + + float endTime; + float saberLength; + + /* + Ghoul2 Insert Start + */ vec3_t angles; // rotation angles - used for Ghoul2 vec3_t modelScale; // axis scale for models - CGhoul2Info_v *ghoul2; // has to be at the end of the ref-ent in order for it to be created properly +// CGhoul2Info_v *ghoul2; // has to be at the end of the ref-ent in order for it to be created properly + void *ghoul2; // has to be at the end of the ref-ent in order for it to be created properly /* Ghoul2 Insert End */ - } refEntity_t; #define MAX_RENDER_STRINGS 8 @@ -185,7 +296,8 @@ typedef struct { int x, y, width, height; float fov_x, fov_y; vec3_t vieworg; - vec3_t viewaxis[3]; // transformation matrix + vec3_t viewangles; + matrix3_t viewaxis; // transformation matrix int viewContents; // world contents at vieworg // time in milliseconds for shader effects and other time dependent rendering issues @@ -195,6 +307,9 @@ typedef struct { // 1 bits will prevent the associated area from rendering at all byte areamask[MAX_MAP_AREA_BYTES]; + + // text messages for deform text shaders + char text[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH]; } refdef_t; @@ -224,6 +339,7 @@ typedef struct glconfig_s { const char *vendor_string; const char *version_string; const char *extensions_string; + int maxTextureSize; // queried from GL int maxActiveTextures; // multitexture ability float maxTextureFilterAnisotropy; @@ -233,15 +349,12 @@ typedef struct glconfig_s { qboolean deviceSupportsGamma; textureCompression_t textureCompression; qboolean textureEnvAddAvailable; - qboolean textureFilterAnisotropicAvailable; qboolean clampToEdgeAvailable; int vidWidth, vidHeight; int displayFrequency; - qboolean doStencilShadowsInOneDrawcall; - // synonymous with "does rendering consume the entire screen?", therefore // a Voodoo or Voodoo2 will have this set to TRUE, as will a Win32 ICD that // used CDS. diff --git a/code/rd-vanilla/tr_ghoul2.cpp b/code/rd-vanilla/tr_ghoul2.cpp index b1f6d43a6b..d51432f223 100644 --- a/code/rd-vanilla/tr_ghoul2.cpp +++ b/code/rd-vanilla/tr_ghoul2.cpp @@ -2575,7 +2575,7 @@ void R_AddGhoulSurfaces( trRefEntity_t *ent ) { } assert (ent->e.ghoul2); //entity is foo if it has a glm model handle but no ghoul2 pointer! - CGhoul2Info_v &ghoul2 = *ent->e.ghoul2; + CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)ent->e.ghoul2); if (!G2_SetupModelPointers(ghoul2)) { diff --git a/code/rd-vanilla/tr_init.cpp b/code/rd-vanilla/tr_init.cpp index 13c72e66ee..b5423dc1b6 100644 --- a/code/rd-vanilla/tr_init.cpp +++ b/code/rd-vanilla/tr_init.cpp @@ -33,6 +33,7 @@ along with this program; if not, see . #include "tr_WorldEffects.h" glconfig_t glConfig; +glconfigExt_t glConfigExt; glstate_t glState; window_t window; @@ -677,10 +678,10 @@ static void GLimp_InitExtensions( void ) qglStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)ri.GL_GetProcAddress("glStencilOpSeparate"); if (qglStencilOpSeparate) { - glConfig.doStencilShadowsInOneDrawcall = qtrue; + glConfigExt.doStencilShadowsInOneDrawcall = qtrue; } #else - glConfig.doStencilShadowsInOneDrawcall = qtrue; + glConfigExt.doStencilShadowsInOneDrawcall = qtrue; #endif } diff --git a/code/rd-vanilla/tr_local.h b/code/rd-vanilla/tr_local.h index 34dd319a0e..9ded5e3de3 100644 --- a/code/rd-vanilla/tr_local.h +++ b/code/rd-vanilla/tr_local.h @@ -1066,6 +1066,16 @@ typedef struct { float distanceCull; } trGlobals_t; +struct glconfigExt_t +{ + glconfig_t *glConfig; + + qboolean textureFilterAnisotropicAvailable; + qboolean doGammaCorrectionWithShaders; + qboolean doStencilShadowsInOneDrawcall; + const char *originalExtensionString; +}; + int R_Images_StartIteration(void); image_t *R_Images_GetNextIteration(void); void R_Images_Clear(void); @@ -1076,6 +1086,7 @@ void R_Images_DeleteImage(image_t *pImage); extern backEndState_t backEnd; extern trGlobals_t tr; extern glconfig_t glConfig; // outside of TR since it shouldn't be cleared during ref re-init +extern glconfigExt_t glConfigExt; extern glstate_t glState; // outside of TR since it shouldn't be cleared during ref re-init extern window_t window; @@ -1555,7 +1566,7 @@ void R_InitNextFrame( void ); void RE_ClearScene( void ); void RE_AddRefEntityToScene( const refEntity_t *ent ); -void RE_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts ); +void RE_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int numPolys ); void RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ); void RE_RenderScene( const refdef_t *fd ); diff --git a/code/rd-vanilla/tr_scene.cpp b/code/rd-vanilla/tr_scene.cpp index d0b6b54977..ff78895241 100644 --- a/code/rd-vanilla/tr_scene.cpp +++ b/code/rd-vanilla/tr_scene.cpp @@ -116,9 +116,9 @@ RE_AddPolyToScene ===================== */ -void RE_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts ) { +void RE_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int numPolys ) { srfPoly_t *poly; - int i; + int i, j; int fogIndex = 0; fog_t *fog; vec3_t bounds[2]; @@ -134,67 +134,70 @@ void RE_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *vert return; } - if ( r_numpolyverts + numVerts >= MAX_POLYVERTS || r_numpolys >= MAX_POLYS ) { - /* - NOTE TTimo this was initially a PRINT_WARNING - but it happens a lot with high fighting scenes and particles - since we don't plan on changing the const and making for room for those effects - simply cut this message to developer only - */ - ri.Printf( PRINT_DEVELOPER, S_COLOR_YELLOW "WARNING: RE_AddPolyToScene: r_max_polys or r_max_polyverts reached\n"); - return; - } + for (j = 0; j < numPolys; j++) { + if (r_numpolyverts + numVerts >= MAX_POLYVERTS || r_numpolys >= MAX_POLYS) { + /* + NOTE TTimo this was initially a PRINT_WARNING + but it happens a lot with high fighting scenes and particles + since we don't plan on changing the const and making for room for those effects + simply cut this message to developer only + */ + ri.Printf(PRINT_DEVELOPER, S_COLOR_YELLOW "WARNING: RE_AddPolyToScene: r_max_polys or r_max_polyverts reached\n"); + return; + } + + poly = &backEndData->polys[r_numpolys]; + poly->surfaceType = SF_POLY; + poly->hShader = hShader; + poly->numVerts = numVerts; + poly->verts = &backEndData->polyVerts[r_numpolyverts]; + + memcpy( poly->verts, &verts[numVerts*j], numVerts * sizeof( *verts ) ); + r_numpolys++; + r_numpolyverts += numVerts; - poly = &backEndData->polys[r_numpolys]; - poly->surfaceType = SF_POLY; - poly->hShader = hShader; - poly->numVerts = numVerts; - poly->verts = &backEndData->polyVerts[r_numpolyverts]; - - memcpy( poly->verts, verts, numVerts * sizeof( *verts ) ); - r_numpolys++; - r_numpolyverts += numVerts; - - // see if it is in a fog volume - if ( !tr.world || tr.world->numfogs == 1) { - fogIndex = 0; - } else { - // find which fog volume the poly is in - VectorCopy( poly->verts[0].xyz, bounds[0] ); - VectorCopy( poly->verts[0].xyz, bounds[1] ); - for ( i = 1 ; i < poly->numVerts ; i++ ) { - AddPointToBounds( poly->verts[i].xyz, bounds[0], bounds[1] ); + // see if it is in a fog volume + if (!tr.world || tr.world->numfogs == 1) { + fogIndex = 0; } - for ( int fI = 1 ; fI < tr.world->numfogs ; fI++ ) { - fog = &tr.world->fogs[fI]; - if ( bounds[0][0] >= fog->bounds[0][0] - && bounds[0][1] >= fog->bounds[0][1] - && bounds[0][2] >= fog->bounds[0][2] - && bounds[1][0] <= fog->bounds[1][0] - && bounds[1][1] <= fog->bounds[1][1] - && bounds[1][2] <= fog->bounds[1][2] ) - {//completely in this one - fogIndex = fI; - break; + else { + // find which fog volume the poly is in + VectorCopy(poly->verts[0].xyz, bounds[0]); + VectorCopy(poly->verts[0].xyz, bounds[1]); + for (i = 1; i < poly->numVerts; i++) { + AddPointToBounds(poly->verts[i].xyz, bounds[0], bounds[1]); } - else if ( ( bounds[0][0] >= fog->bounds[0][0] && bounds[0][1] >= fog->bounds[0][1] && bounds[0][2] >= fog->bounds[0][2] && - bounds[0][0] <= fog->bounds[1][0] && bounds[0][1] <= fog->bounds[1][1] && bounds[0][2] <= fog->bounds[1][2]) || - ( bounds[1][0] >= fog->bounds[0][0] && bounds[1][1] >= fog->bounds[0][1] && bounds[1][2] >= fog->bounds[0][2] && - bounds[1][0] <= fog->bounds[1][0] && bounds[1][1] <= fog->bounds[1][1] && bounds[1][2] <= fog->bounds[1][2] ) ) - {//partially in this one - if ( tr.refdef.fogIndex == fI || R_FogParmsMatch( tr.refdef.fogIndex, fI ) ) - {//take new one only if it's the same one that the viewpoint is in + for (int fI = 1; fI < tr.world->numfogs; fI++) { + fog = &tr.world->fogs[fI]; + if (bounds[0][0] >= fog->bounds[0][0] + && bounds[0][1] >= fog->bounds[0][1] + && bounds[0][2] >= fog->bounds[0][2] + && bounds[1][0] <= fog->bounds[1][0] + && bounds[1][1] <= fog->bounds[1][1] + && bounds[1][2] <= fog->bounds[1][2]) + {//completely in this one fogIndex = fI; break; } - else if ( !fogIndex ) - {//didn't find one yet, so use this one - fogIndex = fI; + else if ((bounds[0][0] >= fog->bounds[0][0] && bounds[0][1] >= fog->bounds[0][1] && bounds[0][2] >= fog->bounds[0][2] && + bounds[0][0] <= fog->bounds[1][0] && bounds[0][1] <= fog->bounds[1][1] && bounds[0][2] <= fog->bounds[1][2]) || + (bounds[1][0] >= fog->bounds[0][0] && bounds[1][1] >= fog->bounds[0][1] && bounds[1][2] >= fog->bounds[0][2] && + bounds[1][0] <= fog->bounds[1][0] && bounds[1][1] <= fog->bounds[1][1] && bounds[1][2] <= fog->bounds[1][2])) + {//partially in this one + if (tr.refdef.fogIndex == fI || R_FogParmsMatch(tr.refdef.fogIndex, fI)) + {//take new one only if it's the same one that the viewpoint is in + fogIndex = fI; + break; + } + else if (!fogIndex) + {//didn't find one yet, so use this one + fogIndex = fI; + } } } } + poly->fogIndex = fogIndex; } - poly->fogIndex = fogIndex; } @@ -217,7 +220,13 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { #endif return; } - if ( ent->reType < 0 || ent->reType >= RT_MAX_REF_ENTITY_TYPE ) { + + if (ent->reType == RT_ENT_CHAIN) + { //minirefents must die. + return; + } + + if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_SP_REF_ENTITY_TYPE || ent->reType == RT_MAX_MP_REF_ENTITY_TYPE ) { Com_Error( ERR_DROP, "RE_AddRefEntityToScene: bad reType %i", ent->reType ); } @@ -228,6 +237,38 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { } +/************************************************************************************************ + * RE_AddMiniRefEntityToScene * + * Adds a mini ref ent to the scene. If the input parameter is null, it signifies the end * + * of the chain. Otherwise, if there is a valid chain parent, it will be added to that. * + * If there is no parent, it will be added as a regular ref ent. * + * * + * Input * + * ent: the mini ref ent to be added * + * * + * Output / Return * + * none * + * * + ************************************************************************************************/ +void RE_AddMiniRefEntityToScene(const miniRefEntity_t *ent) +{ + if (!tr.registered) + { + return; + } + if (!ent) + { + return; + } + + refEntity_t tempEnt; + + memcpy(&tempEnt, ent, sizeof(*ent)); + memset(((char *)&tempEnt) + sizeof(*ent), 0, sizeof(tempEnt) - sizeof(*ent)); + RE_AddRefEntityToScene(&tempEnt); +} + + /* ===================== RE_AddLightToScene diff --git a/code/rd-vanilla/tr_shadows.cpp b/code/rd-vanilla/tr_shadows.cpp index c0331e9763..4e415e9d84 100644 --- a/code/rd-vanilla/tr_shadows.cpp +++ b/code/rd-vanilla/tr_shadows.cpp @@ -350,7 +350,7 @@ void RB_DoShadowTessEnd( vec3_t lightPos ) qglDepthFunc(GL_LESS); //now using the Carmack Reverse -rww - if (glConfig.doStencilShadowsInOneDrawcall) + if (glConfigExt.doStencilShadowsInOneDrawcall) { GL_Cull(CT_TWO_SIDED); qglStencilOpSeparate(GL_FRONT, GL_KEEP, GL_INCR_WRAP, GL_KEEP); diff --git a/code/rd-vanilla/tr_surface.cpp b/code/rd-vanilla/tr_surface.cpp index 1e51e71c90..207a99986e 100644 --- a/code/rd-vanilla/tr_surface.cpp +++ b/code/rd-vanilla/tr_surface.cpp @@ -366,6 +366,62 @@ static void DoLine2( const vec3_t start, const vec3_t end, const vec3_t up, floa tess.indexes[tess.numIndexes++] = vbase + 3; } +static void DoLine_Oriented(const vec3_t start, const vec3_t end, const vec3_t up, float spanWidth) +{ + float spanWidth2; + int vbase; + + vbase = tess.numVertexes; + + spanWidth2 = -spanWidth; + + // FIXME: use quad stamp? + VectorMA(start, spanWidth, up, tess.xyz[tess.numVertexes]); + tess.texCoords[tess.numVertexes][0][0] = 0; + tess.texCoords[tess.numVertexes][0][1] = 0; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];// * 0.25; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];// * 0.25; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];// * 0.25; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + tess.numVertexes++; + + VectorMA(start, spanWidth2, up, tess.xyz[tess.numVertexes]); + tess.texCoords[tess.numVertexes][0][0] = 1; + tess.texCoords[tess.numVertexes][0][1] = 0; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + tess.numVertexes++; + + VectorMA(end, spanWidth, up, tess.xyz[tess.numVertexes]); + + tess.texCoords[tess.numVertexes][0][0] = 0; + tess.texCoords[tess.numVertexes][0][1] = backEnd.currentEntity->e.data.line.stscale; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + tess.numVertexes++; + + VectorMA(end, spanWidth2, up, tess.xyz[tess.numVertexes]); + tess.texCoords[tess.numVertexes][0][0] = 1; + tess.texCoords[tess.numVertexes][0][1] = backEnd.currentEntity->e.data.line.stscale; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + tess.numVertexes++; + + tess.indexes[tess.numIndexes++] = vbase; + tess.indexes[tess.numIndexes++] = vbase + 1; + tess.indexes[tess.numIndexes++] = vbase + 2; + + tess.indexes[tess.numIndexes++] = vbase + 2; + tess.indexes[tess.numIndexes++] = vbase + 1; + tess.indexes[tess.numIndexes++] = vbase + 3; +} + //----------------- // RB_SurfaceLine //----------------- @@ -390,6 +446,23 @@ static void RB_SurfaceLine( void ) DoLine( start, end, right, e->radius); } +static void RB_SurfaceOrientedLine(void) +{ + refEntity_t *e; + vec3_t right; + vec3_t start, end; + + e = &backEnd.currentEntity->e; + + VectorCopy(e->oldorigin, end); + VectorCopy(e->origin, start); + + // compute side vector + VectorNormalize(e->axis[1]); + VectorCopy(e->axis[1], right); + DoLine_Oriented(start, end, right, e->data.line.width*0.5); +} + /* ============== RB_SurfaceCylinder @@ -1951,14 +2024,17 @@ void RB_SurfaceEntity( surfaceType_t *surfType ) { case RT_ORIENTED_QUAD: RB_SurfaceOrientedQuad(); break; - case RT_LINE: - RB_SurfaceLine(); + case RT_BEAM: + RB_SurfaceBeam(); break; case RT_ELECTRICITY: RB_SurfaceElectricity(); break; - case RT_BEAM: - RB_SurfaceBeam(); + case RT_LINE: + RB_SurfaceLine(); + break; + case RT_ORIENTEDLINE: + RB_SurfaceOrientedLine(); break; case RT_SABER_GLOW: RB_SurfaceSaberGlow(); @@ -1966,6 +2042,30 @@ void RB_SurfaceEntity( surfaceType_t *surfType ) { case RT_CYLINDER: RB_SurfaceCylinder(); break; + case RT_ENT_CHAIN: + { + static trRefEntity_t tempEnt = *backEnd.currentEntity; + + //rww - if not static then currentEntity is garbage because + //this is a local. This was not static in sof2.. but I guess + //they never check ce.renderfx so it didn't show up. + + const int start = backEnd.currentEntity->e.uRefEnt.uMini.miniStart; + const int count = backEnd.currentEntity->e.uRefEnt.uMini.miniCount; + assert(count > 0); + backEnd.currentEntity = &tempEnt; + + assert(backEnd.currentEntity->e.renderfx >= 0); + + for (int i = 0, j = start; i < count; i++, j++) + { + backEnd.currentEntity->e = backEnd.refdef.entities[j].e; + assert(backEnd.currentEntity->e.renderfx >= 0); + + RB_SurfaceEntity(surfType); + } + } + break; case RT_LATHE: RB_SurfaceLathe(); break; diff --git a/code/ui/ui_public.h b/code/ui/ui_public.h index 24031e46a5..326afa0cd8 100644 --- a/code/ui/ui_public.h +++ b/code/ui/ui_public.h @@ -84,7 +84,7 @@ typedef struct { // Nothing is drawn until R_RenderScene is called. void (*R_ClearScene)( void ); void (*R_AddRefEntityToScene)( const refEntity_t *re ); - void (*R_AddPolyToScene)( qhandle_t hShader , int numVerts, const polyVert_t *verts ); + void (*R_AddPolyToScene)( qhandle_t hShader , int numVerts, const polyVert_t *verts, int numPolys ); void (*R_AddLightToScene)( const vec3_t org, float intensity, float r, float g, float b ); void (*R_RenderScene)( const refdef_t *fd ); diff --git a/codeJK2/win32/starwars.ico b/codeJK2/win32/starwars.ico new file mode 100644 index 0000000000..c07f6c314e Binary files /dev/null and b/codeJK2/win32/starwars.ico differ diff --git a/codemp/rd-common/tr_types.h b/codemp/rd-common/tr_types.h index 119d1a27b8..d35e9030b3 100644 --- a/codemp/rd-common/tr_types.h +++ b/codemp/rd-common/tr_types.h @@ -75,6 +75,13 @@ along with this program; if not, see . #define RF_FORCEPOST 0x200000 //force it to post-render -rww +// SP renderfx flags, only use in SP! +#define RF_CAP_FRAMES 0x400000 // cap the model frames by the maxframes for one shot anims +#define RF_ALPHA_FADE 0x800000 // hacks blend mode and uses whatever the set alpha is. +#define RF_PULSATE 0x1000000 // for things like a dropped saber, where we want to add an extra visual clue +#define RF_G2MINLOD 0x2000000 // force Lowest lod on g2 +#define RF_MORELIGHT 0x4000000 // allways have some light (viewmodel, some items) | SP version which is different from MP + // refdef flags #define RDF_NOWORLDMODEL 1 // used for player configuration screen #define RDF_HYPERSPACE 4 // teleportation effect @@ -86,6 +93,10 @@ along with this program; if not, see . #define RDF_NOFOG 64 //no global fog in this scene (but still brush fog) -rww #define RDF_ForceSightOn 128 //using force sight +// SP refdef flags, only use in SP! +#define RDF_doLAGoggles 256 // SP only Light Amp goggles +#define RDF_doFullbright 512 // SP only Light Amp goggles + extern int skyboxportal; extern int drawskyboxportal; @@ -117,7 +128,12 @@ typedef enum { RT_CYLINDER, RT_ENT_CHAIN, - RT_MAX_REF_ENTITY_TYPE + RT_MAX_MP_REF_ENTITY_TYPE, + // SP ONLY Entity Types! + RT_LATHE, + RT_CLOUDS, + + RT_MAX_SP_REF_ENTITY_TYPE } refEntityType_t; typedef struct miniRefEntity_s diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 490eda6664..b1c17f3461 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1727,7 +1727,7 @@ static void R_InitGoreVao() { tr.goreVBO = R_CreateVBO( nullptr, - sizeof(g2GoreVert_t) * MAX_LODS * MAX_GORE_RECORDS * MAX_GORE_VERTS * MAX_FRAMES, + sizeof(g2GoreVert_t) * MAX_GORE_RECORDS * MAX_GORE_VERTS * MAX_FRAMES, VBO_USAGE_DYNAMIC); tr.goreVBO->offsets[ATTR_INDEX_POSITION] = offsetof(g2GoreVert_t, position); tr.goreVBO->offsets[ATTR_INDEX_NORMAL] = offsetof(g2GoreVert_t, normal); diff --git a/codemp/rd-vanilla/tr_local.h b/codemp/rd-vanilla/tr_local.h index 2c55d9bfb1..70a27297ca 100644 --- a/codemp/rd-vanilla/tr_local.h +++ b/codemp/rd-vanilla/tr_local.h @@ -554,7 +554,6 @@ typedef struct trRefdef_s { int num_entities; trRefEntity_t *entities; - trMiniRefEntity_t *miniEntities; int num_dlights; struct dlight_s *dlights; @@ -1103,6 +1102,7 @@ struct glconfigExt_t { glconfig_t *glConfig; + qboolean textureFilterAnisotropicAvailable; qboolean doGammaCorrectionWithShaders; qboolean doStencilShadowsInOneDrawcall; const char *originalExtensionString; diff --git a/codemp/rd-vanilla/tr_scene.cpp b/codemp/rd-vanilla/tr_scene.cpp index 9c0025485a..473d01e182 100644 --- a/codemp/rd-vanilla/tr_scene.cpp +++ b/codemp/rd-vanilla/tr_scene.cpp @@ -36,8 +36,6 @@ static int r_firstSceneDlight; static int r_numentities; static int r_firstSceneEntity; static int r_numminientities; -static int r_firstSceneMiniEntity; -static int refEntParent = -1; static int r_numpolys; static int r_firstScenePoly; @@ -63,9 +61,7 @@ void R_InitNextFrame( void ) { r_numentities = 0; r_firstSceneEntity = 0; - refEntParent = -1; r_numminientities = 0; - r_firstSceneMiniEntity = 0; r_numpolys = 0; r_firstScenePoly = 0; @@ -84,8 +80,6 @@ void RE_ClearScene( void ) { r_firstSceneDlight = r_numdlights; r_firstSceneEntity = r_numentities; r_firstScenePoly = r_numpolys; - refEntParent = -1; - r_firstSceneMiniEntity = r_numminientities; } /* @@ -238,8 +232,8 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { assert(ent->hModel || ent->ghoul2 || ent->customShader); } #endif - - if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_REF_ENTITY_TYPE ) { + // TODO: We could implement RT_LATHE and RT_CLOUDS here in MP too to check the same as in the SP renderer -> less differences + if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_MP_REF_ENTITY_TYPE ) { Com_Error( ERR_DROP, "RE_AddRefEntityToScene: bad reType %i", ent->reType ); } @@ -256,19 +250,6 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { } } - /* - if (ent->reType == RT_ENT_CHAIN) - { - refEntParent = r_numentities; - backEndData->entities[r_numentities].e.uRefEnt.uMini.miniStart = r_numminientities - r_firstSceneMiniEntity; - backEndData->entities[r_numentities].e.uRefEnt.uMini.miniCount = 0; - } - else - { - */ - refEntParent = -1; - //} - r_numentities++; } @@ -288,50 +269,20 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { ************************************************************************************************/ void RE_AddMiniRefEntityToScene( const miniRefEntity_t *ent ) { -#if 0 - refEntity_t *parent; -#endif - if ( !tr.registered ) { return; } if (!ent) { - refEntParent = -1; return; } -#if 1 //i hate you minirefent! refEntity_t tempEnt; memcpy(&tempEnt, ent, sizeof(*ent)); memset(((char *)&tempEnt)+sizeof(*ent), 0, sizeof(tempEnt) - sizeof(*ent)); RE_AddRefEntityToScene(&tempEnt); -#else - - if ( ent->reType < 0 || ent->reType >= RT_MAX_REF_ENTITY_TYPE ) - { - Com_Error( ERR_DROP, "RE_AddMiniRefEntityToScene: bad reType %i", ent->reType ); - } - - if (!r_numentities || refEntParent == -1 || r_numminientities >= MAX_MINI_ENTITIES) - { //rww - add it as a refent also if we run out of minis -// Com_Error( ERR_DROP, "RE_AddMiniRefEntityToScene: mini without parent ref ent"); - refEntity_t tempEnt; - - memcpy(&tempEnt, ent, sizeof(*ent)); - memset(((char *)&tempEnt)+sizeof(*ent), 0, sizeof(tempEnt) - sizeof(*ent)); - RE_AddRefEntityToScene(&tempEnt); - return; - } - - parent = &backEndData->entities[refEntParent].e; - parent->uRefEnt.uMini.miniCount++; - - backEndData->miniEntities[r_numminientities].e = *ent; - r_numminientities++; -#endif } /* @@ -491,7 +442,6 @@ void RE_RenderScene( const refdef_t *fd ) { tr.refdef.num_entities = r_numentities - r_firstSceneEntity; tr.refdef.entities = &backEndData->entities[r_firstSceneEntity]; - tr.refdef.miniEntities = &backEndData->miniEntities[r_firstSceneMiniEntity]; tr.refdef.num_dlights = r_numdlights - r_firstSceneDlight; tr.refdef.dlights = &backEndData->dlights[r_firstSceneDlight]; @@ -549,12 +499,9 @@ void RE_RenderScene( const refdef_t *fd ) { // the next scene rendered in this frame will tack on after this one r_firstSceneDrawSurf = tr.refdef.numDrawSurfs; r_firstSceneEntity = r_numentities; - r_firstSceneMiniEntity = r_numminientities; r_firstSceneDlight = r_numdlights; r_firstScenePoly = r_numpolys; - refEntParent = -1; - tr.frontEndMsec += ri.Milliseconds()*ri.Cvar_VariableValue( "timescale" ) - startTime; RE_RenderWorldEffects(); diff --git a/codemp/rd-vanilla/tr_surface.cpp b/codemp/rd-vanilla/tr_surface.cpp index 3be021dce6..ab8bf97303 100644 --- a/codemp/rd-vanilla/tr_surface.cpp +++ b/codemp/rd-vanilla/tr_surface.cpp @@ -1622,22 +1622,22 @@ void RB_SurfaceEntity( surfaceType_t *surfType ) { break; case RT_ENT_CHAIN: { - int i, count, start; - static trRefEntity_t tempEnt = *backEnd.currentEntity; + static trRefEntity_t tempEnt = *backEnd.currentEntity; + //rww - if not static then currentEntity is garbage because //this is a local. This was not static in sof2.. but I guess //they never check ce.renderfx so it didn't show up. - start = backEnd.currentEntity->e.uRefEnt.uMini.miniStart; - count = backEnd.currentEntity->e.uRefEnt.uMini.miniCount; + const int start = backEnd.currentEntity->e.uRefEnt.uMini.miniStart; + const int count = backEnd.currentEntity->e.uRefEnt.uMini.miniCount; assert(count > 0); backEnd.currentEntity = &tempEnt; assert(backEnd.currentEntity->e.renderfx >= 0); - for(i=0;ie, &backEnd.refdef.miniEntities[start+i], sizeof(backEnd.refdef.miniEntities[start+i])); + backEnd.currentEntity->e = backEnd.refdef.entities[j].e; assert(backEnd.currentEntity->e.renderfx >= 0); diff --git a/scripts/appveyor/deploy.bat b/scripts/appveyor/deploy.bat deleted file mode 100644 index 57d2d3a2b6..0000000000 --- a/scripts/appveyor/deploy.bat +++ /dev/null @@ -1,20 +0,0 @@ -setlocal -set CYGWIN_ROOT=C:\cygwin -set WIN32_ROOT=/cygdrive/c -set DEPLOY_LOCATION=ojkwinbuilder@upload.openjk.org:/home/ojkwinbuilder/builds/ -set ZIP_FILE=%1 - -echo Scheduled build: "%APPVEYOR_SCHEDULED_BUILD%" -echo Platform: "%PLATFORM%" -echo Configuration: "%CONFIGURATION%" - -if not "%APPVEYOR_SCHEDULED_BUILD%"=="True" goto end -if not "%PLATFORM%"=="Win32" goto end -if not "%CONFIGURATION%"=="Release" goto end - -echo Deploying %ZIP_FILE% -%CYGWIN_ROOT%\setup-x86.exe -qnNdO -R %CYGWIN_ROOT% -s http://cygwin.mirror.constant.com -l %CYGWIN_ROOT%/var/cache/setup -P rsync -%CYGWIN_ROOT%\bin\bash -lc 'rsync -avz --progress -e "ssh -p 29022 -o StrictHostKeyChecking=no -i %WIN32_ROOT%/users/appveyor/.ssh/id_rsa" -p --chmod=0644 --protocol=29 %WIN32_ROOT%/projects/openjk/%ZIP_FILE% "%DEPLOY_LOCATION%"' - -:end - diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh deleted file mode 100755 index a887e97f00..0000000000 --- a/scripts/travis/build.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh - -set -e -set -x - -host="$1" -flavour="$2" -shift 2 - -mkdir deps build - -case "${host}" in - (*-w64-mingw32) - export CC=${host}-gcc - export CXX=${host}-g++ - set -- \ - -D CMAKE_TOOLCHAIN_FILE=$(pwd)/cmake/Toolchains/${host}.cmake \ - "$@" - ;; - - (i?86-linux-gnu) - set -- \ - -D CMAKE_TOOLCHAIN_FILE=$(pwd)/cmake/Toolchains/linux-i686.cmake \ - "$@" - ;; - - (native) - ;; - - (*) - set +x - echo "Error: don't know how to cross-compile for ${host} host" - exit 1 - ;; -esac - -set -- -D CMAKE_BUILD_TYPE="$flavour" "$@" - -# Build JK2, so that the CI build is testing everything -( cd build && cmake \ - -D BuildJK2SPEngine=ON \ - -D BuildJK2SPGame=ON \ - -D BuildJK2SPRdVanilla=ON \ - -D CMAKE_INSTALL_PREFIX=/prefix \ - "$@" .. ) -make -C build -make -C build install DESTDIR=$(pwd)/build/DESTDIR -( cd $(pwd)/build/DESTDIR && find . -ls ) diff --git a/scripts/travis/install.sh b/scripts/travis/install.sh deleted file mode 100755 index 9bcabc73fd..0000000000 --- a/scripts/travis/install.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -set -e -set -x - -host="$1" -shift 1 - -sudo apt-get update -yq - -# This is what Travis does using the apt-addon. Didn't want to duplicate a load -# of packages in the .travis.yml file though so we have this script instead. -APT_INSTALL='sudo apt-get -yq --no-install-suggests --no-install-recommends --force-yes install' - -${APT_INSTALL} cmake - -case "${host}" in - (native) - ${APT_INSTALL} \ - libsdl2-dev \ - libjpeg-turbo8-dev \ - zlib1g-dev \ - libpng-dev - ;; - - (i686-w64-mingw32) - ${APT_INSTALL} g++-mingw-w64-i686 - ;; - - (x86_64-w64-mingw32) - ${APT_INSTALL} g++-mingw-w64-x86-64 - ;; - - (i?86-linux-gnu) - ${APT_INSTALL} \ - libglib2.0-dev:i386 \ - libgl1-mesa-dev:i386 \ - libpulse-dev:i386 \ - libglu1-mesa-dev:i386 \ - libsdl2-dev:i386 \ - libjpeg-turbo8-dev:i386 \ - zlib1g-dev:i386 \ - libc6-dev:i386 \ - libpng-dev:i386 \ - cpp \ - g++ \ - g++-multilib \ - gcc \ - gcc-multilib \ - ${NULL+} - ;; -esac diff --git a/shared/rd-rend2/glsl/fogpass.glsl b/shared/rd-rend2/glsl/fogpass.glsl index 633feaae54..519e4d9223 100644 --- a/shared/rd-rend2/glsl/fogpass.glsl +++ b/shared/rd-rend2/glsl/fogpass.glsl @@ -27,12 +27,11 @@ layout(std140) uniform Entity mat4 u_ModelMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; - float u_LocalLightRadius; + float u_entityTime; vec3 u_DirectedLight; float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; - vec3 u_LocalViewOrigin; }; layout(std140) uniform ShaderInstance @@ -226,10 +225,11 @@ void main() normal = DeformNormal( position, normal ); #endif - mat4 MVP = u_viewProjectionMatrix * u_ModelMatrix; - gl_Position = MVP * vec4(position, 1.0); + vec4 wsPosition = u_ModelMatrix * vec4(position, 1.0); + gl_Position = u_viewProjectionMatrix * wsPosition; + + var_WSPosition = wsPosition.xyz; - var_WSPosition = (u_ModelMatrix * vec4(position, 1.0)).xyz; #if defined(USE_ALPHA_TEST) var_TexCoords = attr_TexCoord0; #endif @@ -281,12 +281,11 @@ layout(std140) uniform Entity mat4 u_ModelMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; - float u_LocalLightRadius; + float u_entityTime; vec3 u_DirectedLight; float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; - vec3 u_LocalViewOrigin; }; uniform int u_FogIndex; diff --git a/shared/rd-rend2/glsl/generic.glsl b/shared/rd-rend2/glsl/generic.glsl index 4958bc9ffc..419eda295a 100644 --- a/shared/rd-rend2/glsl/generic.glsl +++ b/shared/rd-rend2/glsl/generic.glsl @@ -46,13 +46,11 @@ layout(std140) uniform Entity mat4 u_ModelMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; - float u_LocalLightRadius; + float u_entityTime; vec3 u_DirectedLight; float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; - vec3 u_LocalViewOrigin; - float u_entityTime; }; #if defined(USE_DEFORM_VERTEXES) || defined(USE_RGBAGEN) @@ -285,7 +283,7 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 case TCGEN_ENVIRONMENT_MAPPED: { - vec3 viewer = normalize(u_LocalViewOrigin - position); + vec3 viewer = normalize(u_ViewOrigin - position); vec2 ref = reflect(viewer, normal).yz; tex.s = ref.x * -0.5 + 0.5; tex.t = ref.y * 0.5 + 0.5; @@ -294,7 +292,7 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 case TCGEN_ENVIRONMENT_MAPPED_SP: { - vec3 viewer = normalize(u_LocalViewOrigin - position); + vec3 viewer = normalize(u_ViewOrigin - position); vec2 ref = reflect(viewer, normal).xy; tex.s = ref.x * -0.5; tex.t = ref.y * -0.5; @@ -381,10 +379,11 @@ vec4 CalcColor(vec3 position, vec3 normal) return color; } - vec3 viewer = u_LocalViewOrigin - position; + vec3 viewer = u_ViewOrigin - position; if (u_AlphaGen == AGEN_LIGHTING_SPECULAR) { + // TODO: Handle specular on player models and misc_model_statics correctly vec3 lightDir = normalize(vec3(-960.0, 1980.0, 96.0) - position); vec3 reflected = -reflect(lightDir, normal); @@ -438,11 +437,11 @@ void main() normal = DeformNormal( position, normal ); #endif - mat4 MVP = u_viewProjectionMatrix * u_ModelMatrix; - gl_Position = MVP * vec4(position, 1.0); + vec4 wsPosition = u_ModelMatrix * vec4(position, 1.0); + gl_Position = u_viewProjectionMatrix * wsPosition; #if defined(USE_TCGEN) - vec2 tex = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1); + vec2 tex = GenTexCoords(u_TCGen0, wsPosition.xyz, normal, u_TCGen0Vector0, u_TCGen0Vector1); #else vec2 tex = attr_TexCoord0.st; #endif @@ -465,14 +464,14 @@ void main() else { #if defined(USE_RGBAGEN) - var_Color = CalcColor(position, normal); + var_Color = CalcColor(wsPosition.xyz, normal); #else var_Color = u_VertColor * attr_Color + u_BaseColor; #endif } #if defined(USE_FOG) - var_WSPosition = (u_ModelMatrix * vec4(position, 1.0)).xyz; + var_WSPosition = wsPosition.xyz; #endif } @@ -509,13 +508,11 @@ layout(std140) uniform Entity mat4 u_ModelMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; - float u_LocalLightRadius; + float u_entityTime; vec3 u_DirectedLight; float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; - vec3 u_LocalViewOrigin; - float u_entityTime; }; uniform sampler2D u_DiffuseMap; diff --git a/shared/rd-rend2/glsl/lightall.glsl b/shared/rd-rend2/glsl/lightall.glsl index 685c40ef39..05f0e7dd64 100644 --- a/shared/rd-rend2/glsl/lightall.glsl +++ b/shared/rd-rend2/glsl/lightall.glsl @@ -45,13 +45,11 @@ layout(std140) uniform Entity mat4 u_ModelMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; - float u_LocalLightRadius; + float u_entityTime; vec3 u_DirectedLight; float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; - vec3 u_LocalViewOrigin; - float u_entityTime; }; #if defined(USE_SKELETAL_ANIMATION) @@ -159,7 +157,7 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 case TCGEN_ENVIRONMENT_MAPPED: { - vec3 viewer = normalize(u_LocalViewOrigin - position); + vec3 viewer = normalize(u_ViewOrigin - position); vec2 ref = reflect(viewer, normal).yz; tex.s = ref.x * -0.5 + 0.5; tex.t = ref.y * 0.5 + 0.5; @@ -168,7 +166,7 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 case TCGEN_ENVIRONMENT_MAPPED_SP: { - vec3 viewer = normalize(u_LocalViewOrigin - position); + vec3 viewer = normalize(u_ViewOrigin - position); vec2 ref = reflect(viewer, normal).xy; tex.s = ref.x * -0.5; tex.t = ref.y * -0.5; @@ -258,8 +256,10 @@ void main() #endif #endif + vec4 wsPosition = u_ModelMatrix * vec4(position, 1.0); + #if defined(USE_TCGEN) - vec2 texCoords = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1); + vec2 texCoords = GenTexCoords(u_TCGen0, wsPosition.xyz, normal, u_TCGen0Vector0, u_TCGen0Vector1); #else vec2 texCoords = attr_TexCoord0.st; #endif @@ -272,10 +272,9 @@ void main() vec4 disintegration = CalcColor(position); - mat4 MVP = u_viewProjectionMatrix * u_ModelMatrix; - gl_Position = MVP * vec4(position, 1.0); + gl_Position = u_viewProjectionMatrix * wsPosition; - position = (u_ModelMatrix * vec4(position, 1.0)).xyz; + position = wsPosition.xyz; normal = normalize(mat3(u_ModelMatrix) * normal); #if defined(PER_PIXEL_LIGHTING) tangent = normalize(mat3(u_ModelMatrix) * tangent); @@ -367,13 +366,11 @@ layout(std140) uniform Entity mat4 u_ModelMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; - float u_LocalLightRadius; + float u_entityTime; vec3 u_DirectedLight; float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; - vec3 u_LocalViewOrigin; - float u_entityTime; }; struct Light diff --git a/shared/rd-rend2/glsl/refraction.glsl b/shared/rd-rend2/glsl/refraction.glsl index 7c78cdf187..eedfef223f 100644 --- a/shared/rd-rend2/glsl/refraction.glsl +++ b/shared/rd-rend2/glsl/refraction.glsl @@ -43,13 +43,11 @@ layout(std140) uniform Entity mat4 u_ModelMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; - float u_LocalLightRadius; + float u_entityTime; vec3 u_DirectedLight; float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; - vec3 u_LocalViewOrigin; - float u_entityTime; }; #if defined(USE_DEFORM_VERTEXES) || defined(USE_RGBAGEN) @@ -231,14 +229,14 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 } else if (TCGen == TCGEN_ENVIRONMENT_MAPPED) { - vec3 viewer = normalize(u_LocalViewOrigin - position); + vec3 viewer = normalize(u_ViewOrigin - position); vec2 ref = reflect(viewer, normal).yz; tex.s = ref.x * -0.5 + 0.5; tex.t = ref.y * 0.5 + 0.5; } else if (TCGen == TCGEN_ENVIRONMENT_MAPPED_SP) { - vec3 viewer = normalize(u_LocalViewOrigin - position); + vec3 viewer = normalize(u_ViewOrigin - position); vec2 ref = reflect(viewer, normal).xy; tex.s = ref.x * -0.5; tex.t = ref.y * -0.5; @@ -288,7 +286,7 @@ vec4 CalcColor(vec3 position, vec3 normal) color.rgb = clamp(u_DirectedLight * incoming + u_AmbientLight, 0.0, 1.0); } - vec3 viewer = u_LocalViewOrigin - position; + vec3 viewer = u_ViewOrigin - position; if (u_AlphaGen == AGEN_LIGHTING_SPECULAR) { @@ -349,11 +347,11 @@ void main() normal = DeformNormal( position, normal ); #endif - mat4 MVP = u_viewProjectionMatrix * u_ModelMatrix; - gl_Position = MVP * vec4(position, 1.0); + vec4 wsPosition = u_ModelMatrix * vec4(position, 1.0); + gl_Position = u_viewProjectionMatrix * wsPosition; #if defined(USE_TCGEN) - vec2 tex = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1); + vec2 tex = GenTexCoords(u_TCGen0, wsPosition.xyz, normal, u_TCGen0Vector0, u_TCGen0Vector1); #else vec2 tex = attr_TexCoord0.st; #endif @@ -382,7 +380,6 @@ void main() #endif } - vec3 ws_Position = mat3(u_ModelMatrix) * position; vec3 ws_Normal = normalize(mat3(u_ModelMatrix) * normal); vec3 ws_ViewDir = (u_ViewForward + u_ViewLeft * -gl_Position.x) + u_ViewUp * gl_Position.y; @@ -393,19 +390,20 @@ void main() #endif mat3 inverseModel = inverse(mat3(u_ModelMatrix)); + mat4 MVP = u_viewProjectionMatrix * u_ModelMatrix; vec3 refraction_vec = normalize(refract(ws_ViewDir, ws_Normal, etaR)); - vec3 new_pos = (distance * refraction_vec) + ws_Position; + vec3 new_pos = (distance * refraction_vec) + wsPosition.xyz; var_RefractPosR = vec4(inverseModel * new_pos, 1.0); var_RefractPosR = MVP * var_RefractPosR; refraction_vec = normalize(refract(ws_ViewDir, ws_Normal, etaG)); - new_pos = (distance * refraction_vec) + ws_Position; + new_pos = (distance * refraction_vec) + wsPosition.xyz; var_RefractPosG = vec4(inverseModel * new_pos, 1.0); var_RefractPosG = MVP * var_RefractPosG; refraction_vec = normalize(refract(ws_ViewDir, ws_Normal, etaB)); - new_pos = (distance * refraction_vec) + ws_Position; + new_pos = (distance * refraction_vec) + wsPosition.xyz; var_RefractPosB = vec4(inverseModel * new_pos, 1.0); var_RefractPosB = MVP * var_RefractPosB; } @@ -428,13 +426,11 @@ layout(std140) uniform Entity mat4 u_ModelMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; - float u_LocalLightRadius; + float u_entityTime; vec3 u_DirectedLight; float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; - vec3 u_LocalViewOrigin; - float u_entityTime; }; uniform sampler2D u_TextureMap; diff --git a/shared/rd-rend2/glsl/shadowvolume.glsl b/shared/rd-rend2/glsl/shadowvolume.glsl index e0a1dcbb03..53c8676333 100644 --- a/shared/rd-rend2/glsl/shadowvolume.glsl +++ b/shared/rd-rend2/glsl/shadowvolume.glsl @@ -12,12 +12,11 @@ layout(std140) uniform Entity mat4 u_ModelMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; - float u_LocalLightRadius; + float u_entityTime; vec3 u_DirectedLight; float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; - vec3 u_LocalViewOrigin; }; #if defined(USE_SKELETAL_ANIMATION) @@ -76,12 +75,11 @@ layout(std140) uniform Entity mat4 u_ModelMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; - float u_LocalLightRadius; + float u_entityTime; vec3 u_DirectedLight; float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; - vec3 u_LocalViewOrigin; }; in vec3 var_Position[]; @@ -107,14 +105,14 @@ void main() mat4 MVP = u_viewProjectionMatrix * u_ModelMatrix; if (dot(cross(BmA,CmA), -u_ModelLightDir.xyz) > 0.0) { - vec3 L = u_ModelLightDir.xyz*u_LocalLightRadius; + vec3 L = u_ModelLightDir.xyz*u_LocalLightOrigin.w; - // front cap - gl_Position = MVP * vec4(var_Position[0].xyz, 1.0); + // front cap, avoids z-fighting with other shaders by NOT using the MVP, the other surfaces won't create z-fighting + gl_Position = u_viewProjectionMatrix * u_ModelMatrix * vec4(var_Position[0].xyz, 1.0); EmitVertex(); - gl_Position = MVP * vec4(var_Position[1].xyz, 1.0); + gl_Position = u_viewProjectionMatrix * u_ModelMatrix * vec4(var_Position[1].xyz, 1.0); EmitVertex(); - gl_Position = MVP * vec4(var_Position[2].xyz, 1.0); + gl_Position = u_viewProjectionMatrix * u_ModelMatrix * vec4(var_Position[2].xyz, 1.0); EmitVertex(); EndPrimitive(); diff --git a/shared/rd-rend2/glsl/weather.glsl b/shared/rd-rend2/glsl/weather.glsl index 0c6eef6372..64280b15aa 100644 --- a/shared/rd-rend2/glsl/weather.glsl +++ b/shared/rd-rend2/glsl/weather.glsl @@ -18,9 +18,10 @@ void main() attr_Position.z, 1.0); var_Velocity = attr_Color; + var_Velocity.z = min(-0.00001, var_Velocity.z); vec4 velocitiyOffset = u_ViewInfo.y * vec4(-var_Velocity.xy/var_Velocity.z, var_Velocity.z, 0.0); - velocitiyOffset.xyz = mix(vec3(0.0), velocitiyOffset.xyz, float(var_Velocity.z != 0.0)); + velocitiyOffset.xyz = mix(vec3(0.0), velocitiyOffset.xyz, float(attr_Color.z != 0.0)); var_Velocity.z *= u_ViewInfo.z; vec4 depthPosition = u_ShadowMvp * (gl_Position + velocitiyOffset); diff --git a/shared/rd-rend2/tr_backend.cpp b/shared/rd-rend2/tr_backend.cpp index b2f5dbf683..0009e72003 100644 --- a/shared/rd-rend2/tr_backend.cpp +++ b/shared/rd-rend2/tr_backend.cpp @@ -2361,8 +2361,7 @@ static void RB_UpdateEntityLightConstants( } VectorCopy(lightDir, entityBlock.modelLightDir); - entityBlock.lightOrigin[3] = 0.0f; - entityBlock.lightRadius = lightRadius; + entityBlock.lightOrigin[3] = lightRadius; } static void RB_UpdateEntityMatrixConstants( @@ -2372,7 +2371,6 @@ static void RB_UpdateEntityMatrixConstants( orientationr_t ori; R_RotateForEntity(refEntity, &backEnd.viewParms, &ori); Matrix16Copy(ori.modelMatrix, entityBlock.modelMatrix); - VectorCopy(ori.viewOrigin, entityBlock.localViewOrigin); } static void RB_UpdateEntityModelConstants( diff --git a/shared/rd-rend2/tr_bsp.cpp b/shared/rd-rend2/tr_bsp.cpp index 89438f6b35..fa45e4a656 100644 --- a/shared/rd-rend2/tr_bsp.cpp +++ b/shared/rd-rend2/tr_bsp.cpp @@ -4301,6 +4301,7 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) &header->lumps[LUMP_BRUSHES], &header->lumps[LUMP_BRUSHSIDES]); + R_LoadWeatherImages(); R_GenerateSurfaceSprites(worldData, worldIndex + 1); // load cubemaps diff --git a/shared/rd-rend2/tr_ghoul2.cpp b/shared/rd-rend2/tr_ghoul2.cpp index 04f48b81b9..409dc613f6 100644 --- a/shared/rd-rend2/tr_ghoul2.cpp +++ b/shared/rd-rend2/tr_ghoul2.cpp @@ -4464,6 +4464,8 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & surf_indices ); + Hunk_FreeTempMemory(surf_indices); + surf = (mdxmSurface_t *)((byte *)surf + surf->ofsEnd); } diff --git a/shared/rd-rend2/tr_image.cpp b/shared/rd-rend2/tr_image.cpp index 9fdf8148ab..94ef2fbc0b 100644 --- a/shared/rd-rend2/tr_image.cpp +++ b/shared/rd-rend2/tr_image.cpp @@ -3266,7 +3266,7 @@ static void R_CreateEnvBrdfLUT(void) { scale /= numSamples; bias /= numSamples; - velvet /= numSamples; + velvet /= numSamples * 2.0f * M_PI; data[y][x][0] = FloatToHalf(scale); data[y][x][1] = FloatToHalf(bias); diff --git a/shared/rd-rend2/tr_light.cpp b/shared/rd-rend2/tr_light.cpp index f4700b2882..6c4b481106 100644 --- a/shared/rd-rend2/tr_light.cpp +++ b/shared/rd-rend2/tr_light.cpp @@ -90,9 +90,10 @@ void R_DlightBmodel( bmodel_t *bmodel, trRefEntity_t *ent ) { ent->needDlights = (qboolean)(mask != 0); + world_t *world = R_GetWorld(bmodel->worldIndex); // set the dlight bits in all the surfaces for ( i = 0 ; i < bmodel->numSurfaces ; i++ ) { - surf = tr.world->surfaces + bmodel->firstSurface + i; + surf = world->surfaces + bmodel->firstSurface + i; switch(*surf->data) { @@ -368,15 +369,6 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { // only do min lighting when there is no hdr light data if (tr.hdrLighting != qtrue) { -#ifndef REND2_SP - // bonus items and view weapons have a fixed minimum add - if (1/*!r_hdr->integer*/) { - // give everything a minimum light add - ent->ambientLight[0] += tr.identityLight * 32; - ent->ambientLight[1] += tr.identityLight * 32; - ent->ambientLight[2] += tr.identityLight * 32; - } - if (ent->e.renderfx & RF_MINLIGHT) { //the minlight flag is now for items rotating on their holo thing if (ent->e.shaderRGBA[0] == 255 && @@ -394,9 +386,8 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { ent->ambientLight[2] += tr.identityLight * 150; } } -#else // bonus items and view weapons have a fixed minimum add - if (ent->e.renderfx & RF_MORELIGHT) { + else if (ent->e.renderfx & RF_MORELIGHT) { ent->ambientLight[0] += tr.identityLight * 96; ent->ambientLight[1] += tr.identityLight * 96; ent->ambientLight[2] += tr.identityLight * 96; @@ -407,7 +398,6 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { ent->ambientLight[1] += tr.identityLight * 32; ent->ambientLight[2] += tr.identityLight * 32; } -#endif } d = VectorLength( ent->directedLight ); diff --git a/shared/rd-rend2/tr_local.h b/shared/rd-rend2/tr_local.h index 4cb53e6af4..8497853afd 100644 --- a/shared/rd-rend2/tr_local.h +++ b/shared/rd-rend2/tr_local.h @@ -776,13 +776,11 @@ struct EntityBlock matrix_t modelMatrix; vec4_t lightOrigin; vec3_t ambientLight; - float lightRadius; + float entityTime; vec3_t directedLight; float fxVolumetricBase; vec3_t modelLightDir; float vertexLerp; - vec3_t localViewOrigin; - float entityTime; }; struct ShaderInstanceBlock @@ -2664,12 +2662,16 @@ struct glconfigExt_t { glconfig_t *glConfig; + qboolean textureFilterAnisotropicAvailable; + qboolean doGammaCorrectionWithShaders; + qboolean doStencilShadowsInOneDrawcall; const char *originalExtensionString; }; extern backEndState_t backEnd; extern trGlobals_t tr; extern glstate_t glState; // outside of TR since it shouldn't be cleared during ref re-init +extern glconfigExt_t glConfigExt; extern glRefConfig_t glRefConfig; extern window_t window; @@ -3328,12 +3330,8 @@ void R_InitNextFrame( void ); void RE_ClearScene( void ); void RE_AddRefEntityToScene( const refEntity_t *ent ); -#ifndef REND2_SP void RE_AddMiniRefEntityToScene( const miniRefEntity_t *miniRefEnt ); void RE_AddPolyToScene(qhandle_t hShader, int numVerts, const polyVert_t *verts, int num = 1); -#else -void RE_AddPolyToScene(qhandle_t hShader, int numVerts, const polyVert_t *verts); -#endif void RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ); void RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b ); void RE_BeginScene( const refdef_t *fd ); diff --git a/shared/rd-rend2/tr_main.cpp b/shared/rd-rend2/tr_main.cpp index c445a45a96..958e5502e2 100644 --- a/shared/rd-rend2/tr_main.cpp +++ b/shared/rd-rend2/tr_main.cpp @@ -2003,7 +2003,6 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, trRefEntity_t *ent, int } } break; -#ifndef REND2_SP case RT_ENT_CHAIN: shader = R_GetShaderByHandle(ent->e.customShader); R_AddDrawSurf( @@ -2015,7 +2014,6 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, trRefEntity_t *ent, int R_IsPostRenderEntity(ent), 0 /* cubeMap */ ); break; -#endif default: ri.Error( ERR_DROP, "R_AddEntitySurfaces: Bad reType" ); } @@ -2633,9 +2631,7 @@ qboolean R_AddPortalView(const trRefdef_t *refdef) case RT_ORIENTED_QUAD: case RT_ELECTRICITY: case RT_LINE: -#ifndef REND2_SP case RT_ORIENTEDLINE: -#endif case RT_CYLINDER: case RT_SABER_GLOW: break; @@ -2682,10 +2678,8 @@ qboolean R_AddPortalView(const trRefdef_t *refdef) } } break; -#ifndef REND2_SP case RT_ENT_CHAIN: break; -#endif default: break; } diff --git a/shared/rd-rend2/tr_scene.cpp b/shared/rd-rend2/tr_scene.cpp index e475746f53..672505aac7 100644 --- a/shared/rd-rend2/tr_scene.cpp +++ b/shared/rd-rend2/tr_scene.cpp @@ -118,12 +118,8 @@ RE_AddPolyToScene ===================== */ -#ifndef REND2_SP + void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys ) { -#else -void RE_AddPolyToScene(qhandle_t hShader, int numVerts, const polyVert_t *verts) { - int numPolys = 1; -#endif srfPoly_t *poly; int i, j; int fogIndex; @@ -215,7 +211,13 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { } return; } - if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_REF_ENTITY_TYPE ) { + + if (ent->reType == RT_ENT_CHAIN) + { //minirefents must die. + return; + } + + if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_SP_REF_ENTITY_TYPE || ent->reType == RT_MAX_MP_REF_ENTITY_TYPE ) { ri.Error( ERR_DROP, "RE_AddRefEntityToScene: bad reType %i", ent->reType ); } diff --git a/shared/rd-rend2/tr_shader.cpp b/shared/rd-rend2/tr_shader.cpp index 9eaddf70f9..68e7a9df58 100644 --- a/shared/rd-rend2/tr_shader.cpp +++ b/shared/rd-rend2/tr_shader.cpp @@ -2788,6 +2788,13 @@ static qboolean ParseShader( const char **text ) return qfalse; } + if (tr.hdrLighting) + { + shader.fogParms.color[0] = sRGBtoRGB(shader.fogParms.color[0]); + shader.fogParms.color[1] = sRGBtoRGB(shader.fogParms.color[1]); + shader.fogParms.color[2] = sRGBtoRGB(shader.fogParms.color[2]); + } + token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { @@ -4222,6 +4229,9 @@ static shader_t *FinishShader( void ) { if (!pStage->active) continue; + if (pStage->stateBits & (GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS)) + break; + if (pStage->alphaTestType == ALPHA_TEST_NONE) shader.useSimpleDepthShader = qtrue; break; diff --git a/shared/rd-rend2/tr_surface.cpp b/shared/rd-rend2/tr_surface.cpp index 63443be5e7..5ca4ae638e 100644 --- a/shared/rd-rend2/tr_surface.cpp +++ b/shared/rd-rend2/tr_surface.cpp @@ -860,7 +860,6 @@ static void DoLine2(const vec3_t start, const vec3_t end, const vec3_t up, float tess.indexes[tess.numIndexes++] = vbase + 3; } -#ifndef REND2_SP static void DoLine_Oriented( const vec3_t start, const vec3_t end, const vec3_t up, float spanWidth ) { float spanWidth2; @@ -921,7 +920,6 @@ static void RB_SurfaceOrientedLine(void) VectorCopy(e->axis[1], right); DoLine_Oriented(start, end, right, e->data.line.width*0.5); } -#endif //----------------- // RB_SurfaceLine @@ -2010,7 +2008,6 @@ static void RB_SurfaceBSPGrid( srfBspSurface_t *srf ) { } } -#ifdef REND2_SP #define LATHE_SEG_STEP 10 #define BEZIER_STEP 0.05f // must be in the range of 0 to 1 @@ -2336,7 +2333,6 @@ static void RB_SurfaceClouds() } } } -#endif /* =========================================================================== @@ -2406,7 +2402,6 @@ static void RB_SurfaceEntity( surfaceType_t *surfType ) { case RT_CYLINDER: RB_SurfaceCylinder(); break; -#ifndef REND2_SP case RT_ORIENTEDLINE: RB_SurfaceOrientedLine(); break; @@ -2434,14 +2429,12 @@ static void RB_SurfaceEntity( surfaceType_t *surfType ) { } } break; -#else case RT_LATHE: RB_SurfaceLathe(); break; case RT_CLOUDS: RB_SurfaceClouds(); break; -#endif default: RB_SurfaceAxis(); break; diff --git a/shared/rd-rend2/tr_weather.cpp b/shared/rd-rend2/tr_weather.cpp index 84c3ea6140..36b8ed65ea 100644 --- a/shared/rd-rend2/tr_weather.cpp +++ b/shared/rd-rend2/tr_weather.cpp @@ -553,6 +553,29 @@ void R_AddWeatherBrush(uint8_t numPlanes, vec4_t *planes) tr.weatherSystem->numWeatherBrushes++; } +void R_LoadWeatherImages() +{ + if (!tr.weatherSystem) + return; + + // Image flags and type + imgType_t type = IMGTYPE_COLORALPHA; + int flags = IMGFLAG_CLAMPTOEDGE; + if (tr.hdrLighting) + flags |= IMGFLAG_SRGB; + + if (tr.weatherSystem->weatherSlots[WEATHER_RAIN].active) + tr.weatherSystem->weatherSlots[WEATHER_RAIN].drawImage = R_FindImageFile("gfx/world/rain.jpg", type, flags); + if (tr.weatherSystem->weatherSlots[WEATHER_SNOW].active) + tr.weatherSystem->weatherSlots[WEATHER_SNOW].drawImage = R_FindImageFile("gfx/effects/snowflake1", type, flags); + if (tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].active) + tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].drawImage = R_FindImageFile("gfx/effects/snowpuff1", type, flags); + if (tr.weatherSystem->weatherSlots[WEATHER_SAND].active) + tr.weatherSystem->weatherSlots[WEATHER_SAND].drawImage = R_FindImageFile("gfx/effects/alpha_smoke2b", type, flags); + if (tr.weatherSystem->weatherSlots[WEATHER_FOG].active) + tr.weatherSystem->weatherSlots[WEATHER_FOG].drawImage = R_FindImageFile("gfx/effects/alpha_smoke2b", type, flags); +} + void RE_WorldEffectCommand(const char *command) { if (!command) @@ -690,10 +713,6 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_RAIN].velocityOrientationScale = 1.0f; - imgType_t type = IMGTYPE_COLORALPHA; - int flags = IMGFLAG_CLAMPTOEDGE; - tr.weatherSystem->weatherSlots[WEATHER_RAIN].drawImage = R_FindImageFile("gfx/world/rain.jpg", type, flags); - VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, 0.5f, 0.5f, 0.5f, 0.5f); VectorScale( tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, @@ -728,10 +747,6 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_RAIN].velocityOrientationScale = 1.0f; - imgType_t type = IMGTYPE_COLORALPHA; - int flags = IMGFLAG_CLAMPTOEDGE; - tr.weatherSystem->weatherSlots[WEATHER_RAIN].drawImage = R_FindImageFile("gfx/world/rain.jpg", type, flags); - VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, 0.5f, 0.5f, 0.5f, 0.5f); VectorScale( tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, @@ -773,10 +788,6 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->pain = 0.1f; - imgType_t type = IMGTYPE_COLORALPHA; - int flags = IMGFLAG_CLAMPTOEDGE; - tr.weatherSystem->weatherSlots[WEATHER_RAIN].drawImage = R_FindImageFile("gfx/world/rain.jpg", type, flags); - VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, 0.34f, 0.7f, 0.34f, 0.7f); VectorScale( tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, @@ -811,10 +822,6 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_RAIN].velocityOrientationScale = 1.0f; - imgType_t type = IMGTYPE_COLORALPHA; - int flags = IMGFLAG_CLAMPTOEDGE; - tr.weatherSystem->weatherSlots[WEATHER_RAIN].drawImage = R_FindImageFile("gfx/world/rain", type, flags); - VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, 0.5f, 0.5f, 0.5f, 0.5f); VectorScale( tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, @@ -844,10 +851,6 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_SNOW].velocityOrientationScale = 0.0f; - imgType_t type = IMGTYPE_COLORALPHA; - int flags = IMGFLAG_CLAMPTOEDGE; - tr.weatherSystem->weatherSlots[WEATHER_SNOW].drawImage = R_FindImageFile("gfx/effects/snowflake1", type, flags); - VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_SNOW].color, 0.75f, 0.75f, 0.75f, 0.75f); VectorScale( tr.weatherSystem->weatherSlots[WEATHER_SNOW].color, @@ -892,10 +895,6 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].velocityOrientationScale = 0.0f; - imgType_t type = IMGTYPE_COLORALPHA; - int flags = IMGFLAG_CLAMPTOEDGE; - tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].drawImage = R_FindImageFile("gfx/effects/snowpuff1", type, flags); - VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].color, 0.75f, 0.75f, 0.75f, 0.75f); VectorScale( tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].color, @@ -936,10 +935,6 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_SAND].velocityOrientationScale = 0.0f; - imgType_t type = IMGTYPE_COLORALPHA; - int flags = IMGFLAG_CLAMPTOEDGE; - tr.weatherSystem->weatherSlots[WEATHER_SAND].drawImage = R_FindImageFile("gfx/effects/alpha_smoke2b", type, flags); - VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_SAND].color, 0.9f, 0.6f, 0.0f, 0.5f); } @@ -973,10 +968,6 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_FOG].velocityOrientationScale = 0.0f; - imgType_t type = IMGTYPE_COLORALPHA; - int flags = IMGFLAG_CLAMPTOEDGE; - tr.weatherSystem->weatherSlots[WEATHER_FOG].drawImage = R_FindImageFile("gfx/effects/alpha_smoke2b", type, flags); - VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_FOG].color, 0.2f, 0.2f, 0.2f, 0.2f); VectorScale(tr.weatherSystem->weatherSlots[WEATHER_FOG].color, 0.2f, tr.weatherSystem->weatherSlots[WEATHER_FOG].color); } @@ -1014,10 +1005,6 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_FOG].velocityOrientationScale = 0.0f; - imgType_t type = IMGTYPE_COLORALPHA; - int flags = IMGFLAG_CLAMPTOEDGE; - tr.weatherSystem->weatherSlots[WEATHER_FOG].drawImage = R_FindImageFile("gfx/effects/alpha_smoke2b", type, flags); - VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_FOG].color, 0.3f, 0.3f, 0.3f, 0.3f); VectorScale(tr.weatherSystem->weatherSlots[WEATHER_FOG].color, 0.3f, tr.weatherSystem->weatherSlots[WEATHER_FOG].color); } @@ -1055,10 +1042,6 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_FOG].velocityOrientationScale = 0.0f; - imgType_t type = IMGTYPE_COLORALPHA; - int flags = IMGFLAG_CLAMPTOEDGE; - tr.weatherSystem->weatherSlots[WEATHER_FOG].drawImage = R_FindImageFile("gfx/effects/alpha_smoke2b", type, flags); - VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_FOG].color, 0.19f, 0.6f, 0.7f, 0.12f); VectorScale(tr.weatherSystem->weatherSlots[WEATHER_FOG].color, 0.12f, tr.weatherSystem->weatherSlots[WEATHER_FOG].color); } @@ -1106,6 +1089,8 @@ void RE_WorldEffectCommand(const char *command) #ifdef REND2_SP COM_EndParseSession(); #endif + if (tr.world) + R_LoadWeatherImages(); } void R_WorldEffect_f(void) diff --git a/shared/rd-rend2/tr_weather.h b/shared/rd-rend2/tr_weather.h index 2d31823614..3ac889c455 100644 --- a/shared/rd-rend2/tr_weather.h +++ b/shared/rd-rend2/tr_weather.h @@ -117,6 +117,7 @@ void R_InitWeatherSystem(); void R_InitWeatherForMap(); void R_AddWeatherSurfaces(); void R_AddWeatherBrush(uint8_t numPlanes, vec4_t *planes); +void R_LoadWeatherImages(); void R_ShutdownWeatherSystem(); void RB_SurfaceWeather( srfWeather_t *surfaceType ); bool R_IsOutside(vec3_t pos); diff --git a/shared/rd-rend2/tr_world.cpp b/shared/rd-rend2/tr_world.cpp index bd21855a4e..e08527efb4 100644 --- a/shared/rd-rend2/tr_world.cpp +++ b/shared/rd-rend2/tr_world.cpp @@ -833,7 +833,7 @@ void R_MarkLeaves( void ) const byte *vis = R_ClusterPVS(tr.visClusters[tr.visIndex]); int i; - for (i = 0, leaf = (tr.world->nodes + tr.world->numDecisionNodes); i < (tr.world->numnodes - tr.world->numDecisionNodes); i++, leaf++) { + for (i = 0, leaf = tr.world->nodes; i < tr.world->numnodes; i++, leaf++) { cluster = leaf->cluster; if ( cluster < 0 || cluster >= tr.world->numClusters ) { continue; diff --git a/shared/sys/sys_public.h b/shared/sys/sys_public.h index bad8218531..c93006a698 100644 --- a/shared/sys/sys_public.h +++ b/shared/sys/sys_public.h @@ -141,8 +141,8 @@ char *Sys_DefaultAppPath(void); #endif char *Sys_DefaultHomePath(void); -const char *Sys_Dirname( char *path ); -const char *Sys_Basename( char *path ); +const char *Sys_Dirname( const char *path ); +const char *Sys_Basename( const char *path ); bool Sys_PathCmp( const char *path1, const char *path2 ); diff --git a/shared/sys/sys_unix.cpp b/shared/sys/sys_unix.cpp index 96f5b7aab3..e3149819fc 100644 --- a/shared/sys/sys_unix.cpp +++ b/shared/sys/sys_unix.cpp @@ -164,9 +164,11 @@ qboolean Sys_LowPhysicalMemory( void ) Sys_Basename ================== */ -const char *Sys_Basename( char *path ) +const char *Sys_Basename( const char *path ) { - return basename( path ); + static char buf[ MAX_OSPATH ]; + Q_strncpyz( buf, path, sizeof(buf) ); + return basename( buf ); } /* @@ -174,9 +176,11 @@ const char *Sys_Basename( char *path ) Sys_Dirname ================== */ -const char *Sys_Dirname( char *path ) +const char *Sys_Dirname( const char *path ) { - return dirname( path ); + static char buf[ MAX_OSPATH ]; + Q_strncpyz( buf, path, sizeof(buf) ); + return dirname( buf ); } /* diff --git a/shared/sys/sys_win32.cpp b/shared/sys/sys_win32.cpp index 5b6c234cf5..4a8768130f 100644 --- a/shared/sys/sys_win32.cpp +++ b/shared/sys/sys_win32.cpp @@ -38,7 +38,7 @@ static UINT timerResolution = 0; Sys_Basename ============== */ -const char *Sys_Basename( char *path ) +const char *Sys_Basename( const char *path ) { static char base[ MAX_OSPATH ] = { 0 }; int length; @@ -68,7 +68,7 @@ const char *Sys_Basename( char *path ) Sys_Dirname ============== */ -const char *Sys_Dirname( char *path ) +const char *Sys_Dirname( const char *path ) { static char dir[ MAX_OSPATH ] = { 0 }; int length;