Compare commits

..
22 Commits
Author SHA1 Message Date
OM 93e56d968e Added clampmapx / clampmapy support
Don't determine sort order / fog color adjustment
2023-05-20 21:14:17 +02:00
OM b4e22d3040 set *r_ignoreFastPath* to 0 by default 2023-05-20 21:12:00 +02:00
OM 351f601986 Implemented *bLoadForMap* and fixed subtitle/maps parsing with *alias / aliascache* 2023-05-20 20:40:44 +02:00
OM 41fdd28d8b Refactored *Alias_ListAddParms* 2023-05-20 20:40:14 +02:00
OM d7c6cc0157 Removed scratchimage array 2023-05-20 19:33:16 +02:00
OM f1b83f1dab Added more rgbgen support 2023-05-20 19:33:00 +02:00
OM bb401d8d3c now sets tr.needsLightScale 2023-05-20 19:32:47 +02:00
OM 8bb9cd46f8 RB_SurfaceFace renders with dlight 2023-05-20 19:32:29 +02:00
OM c27695247e drawSurf sprite check fix 2023-05-20 19:32:09 +02:00
OM 7b9835a118 Corrected terrain lightmap 2023-05-20 19:31:51 +02:00
OM 2dc75b7527 Added lightmap grid data support 2023-05-20 19:30:12 +02:00
OM 6c577a7251 Fixed angle values 2023-05-20 19:29:38 +02:00
OM 5031402c2c CL_Vid_Restart_f: check if allowed, and call UI resolution change 2023-05-20 19:29:26 +02:00
OM a4bd37af8c Fixed buttons 2023-05-20 19:29:02 +02:00
OM 4dc60b9aa4 Added lighting-grid / sphere light basic implementation 2023-05-20 17:02:01 +02:00
OM ce89399824 Fixed unix compilation errors 2023-05-20 16:14:53 +02:00
OM b92d2972f6 Added RDF_FULLBRIGHT 2023-05-20 16:14:12 +02:00
OM f53680983b Spelling fix 2023-05-20 15:09:43 +02:00
OM d6fd337a07 Terrain crash fix 2023-05-20 14:57:14 +02:00
OM 95230a8d0a Added list destructor 2023-05-20 14:57:06 +02:00
OM 04524e9de9 Fixed huddraw_alpha and huddraw_color not working 2023-05-20 14:39:15 +02:00
OM df4f6f9515 Fixed crash due to null m_spawnthing 2023-05-20 14:38:54 +02:00
36 changed files with 1418 additions and 1023 deletions

No files matched your search

+1 -1
View File
@@ -70,7 +70,7 @@ These are the tools required for all platforms :
The installation directory can be set to MOHAA directory.
The client build and successfully be built by adding `-DWITH_CLIENT=1` to the CMake command line.
The client build can be built by adding `-DWITH_CLIENT=1` to the CMake command line. This will compile the cgame module and the full app with rendering, ui and sound suppport, alongside the dedicated server version.
### Linux
+168 -34
View File
@@ -1795,6 +1795,10 @@ void ClientGameCommandManager::SetAlignStretch(Event* ev)
void ClientGameCommandManager::SetDecalRadius(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->cgd.decal_radius = ev->GetFloat(1);
}
@@ -1806,6 +1810,10 @@ void ClientGameCommandManager::SetDecalOrientation(Event* ev)
{
str deg;
if (!m_spawnthing) {
return;
}
deg = ev->GetString(1);
if (!deg.icmp("random")) {
@@ -1820,6 +1828,10 @@ void ClientGameCommandManager::SetDecalOrientation(Event* ev)
//===============
void ClientGameCommandManager::SetBounceDecal(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->cgd.flags2 |= T2_BOUNCE_DECAL;
if (ev->NumArgs() > 1) {
m_spawnthing->cgd.maxbouncecount = ev->GetInteger(1);
@@ -1837,8 +1849,11 @@ void ClientGameCommandManager::SetBounceDecal(Event* ev)
// SetParallel
//===============
void ClientGameCommandManager::SetParallel(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->cgd.flags2 |= T2_PARALLEL;
}
@@ -1846,10 +1861,13 @@ void ClientGameCommandManager::SetParallel(Event* ev)
// PhysicsRate
//===============
void ClientGameCommandManager::SetPhysicsRate(Event* ev)
{
str rate;
if (!m_spawnthing) {
return;
}
rate = ev->GetString(1);
if (!rate.icmp(rate, "every")) {
@@ -1863,8 +1881,11 @@ void ClientGameCommandManager::SetPhysicsRate(Event* ev)
// SetLightstyle
//===============
void ClientGameCommandManager::SetLightstyle(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->cgd.lightstyle = CG_RegisterLightStyle(ev->GetString(1));
}
@@ -1872,8 +1893,11 @@ void ClientGameCommandManager::SetLightstyle(Event* ev)
// SetBeamSphere
//===============
void ClientGameCommandManager::SetBeamSphere(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->numspherebeams = ev->GetInteger(1);
m_spawnthing->beamflags = BEAM_SPHERE_EFFECT;
}
@@ -1882,8 +1906,11 @@ void ClientGameCommandManager::SetBeamSphere(Event* ev)
// SetBeamSpread
//===============
void ClientGameCommandManager::SetSpread(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->spreadx = ev->GetFloat(1);
m_spawnthing->spready = ev->GetFloat(2);
}
@@ -1892,8 +1919,11 @@ void ClientGameCommandManager::SetSpread(Event* ev)
// SetUseLastTraceEnd
//===============
void ClientGameCommandManager::SetUseLastTraceEnd(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->use_last_trace_end = qtrue;
}
@@ -1901,8 +1931,11 @@ void ClientGameCommandManager::SetUseLastTraceEnd(Event* ev)
// SetSubdivisions
//===============
void ClientGameCommandManager::SetSubdivisions(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->numSubdivisions = ev->GetInteger(1);
}
@@ -1910,8 +1943,11 @@ void ClientGameCommandManager::SetSubdivisions(Event* ev)
// SetBeamPersist
//===============
void ClientGameCommandManager::SetBeamPersist(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->beamflags |= BEAM_PERSIST_EFFECT;
}
@@ -1919,8 +1955,11 @@ void ClientGameCommandManager::SetBeamPersist(Event* ev)
// SetBeamOffsetEndponts
//===============
void ClientGameCommandManager::SetBeamOffsetEndpoints(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->beamflags |= BEAM_OFFSET_ENDPOINTS;
}
@@ -1928,8 +1967,11 @@ void ClientGameCommandManager::SetBeamOffsetEndpoints(Event* ev)
// SetBeamDelay
//===============
void ClientGameCommandManager::SetBeamDelay(Event* ev)
{
if (!m_spawnthing) {
return;
}
if (ev->NumArgs() > 1) {
str r = ev->GetString(1);
if (r.icmp("random")) {
@@ -1945,8 +1987,11 @@ void ClientGameCommandManager::SetBeamDelay(Event* ev)
// SetBeamToggleDelay
//===============
void ClientGameCommandManager::SetBeamToggleDelay(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->beamflags |= BEAM_TOGGLE;
if (ev->NumArgs() > 1) {
str r = ev->GetString(1);
@@ -1964,8 +2009,11 @@ void ClientGameCommandManager::SetBeamToggleDelay(Event* ev)
// SetBeamLength
//===============
void ClientGameCommandManager::SetLength(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->length = ev->GetFloat(1);
}
@@ -1973,8 +2021,11 @@ void ClientGameCommandManager::SetLength(Event* ev)
// SetShader
//===============
void ClientGameCommandManager::SetShader(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->cgd.shadername = ev->GetString(1);
}
@@ -1982,8 +2033,11 @@ void ClientGameCommandManager::SetShader(Event* ev)
// SetMinOffset
//===============
void ClientGameCommandManager::SetMinOffset(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->min_offset = ev->GetInteger(1);
}
@@ -1991,8 +2045,11 @@ void ClientGameCommandManager::SetMinOffset(Event* ev)
// SetSubdivisions
//===============
void ClientGameCommandManager::SetMaxOffset(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->max_offset = ev->GetInteger(1);
}
@@ -2000,8 +2057,11 @@ void ClientGameCommandManager::SetMaxOffset(Event* ev)
// SetAnim
//===============
void ClientGameCommandManager::SetAnim(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->animName = ev->GetString(1);
}
@@ -2009,8 +2069,11 @@ void ClientGameCommandManager::SetAnim(Event* ev)
// AnimateOnce
//===============
void ClientGameCommandManager::AnimateOnce(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->cgd.flags |= T_ANIMATEONCE;
}
@@ -2018,8 +2081,11 @@ void ClientGameCommandManager::AnimateOnce(Event* ev)
// EmitterStartOff
//===============
void ClientGameCommandManager::EmitterStartOff(Event* ev)
{
if (!m_spawnthing) {
return;
}
m_spawnthing->startoff = qtrue;
}
@@ -5160,10 +5226,37 @@ void AliasResource(dtiki_t* pmdl, const char* alias, const char* realname,
}
}
int bLoadForMap__FPCcT0(char* psMapsBuffer, char* name)
qboolean bLoadForMap(const char* psMapsBuffer, const char* name)
{
// FIXME: stub
return 0;
const char* token;
const char* mapname;
const char* override;
mapname = cgs.mapname;
if (!strncmp("test", mapname, strlen("test"))) {
return qtrue;
}
token = COM_GetToken((char**)&psMapsBuffer, qtrue);
override = token;
if (token && *token)
{
while (1)
{
if (!Q_stricmpn(token, mapname, strlen(token)))
{
return true;
}
token = COM_GetToken((char**)&psMapsBuffer, qtrue);
if (!token || !token[0]) {
return false;
}
}
}
Com_Printf("ERROR bLoadForMap: %s alias with empty maps specification.\n", name);
return false;
}
//===============
@@ -5173,8 +5266,9 @@ void ClientGameCommandManager::AliasCache(Event* ev)
{
int i;
char parmbuffer[512]; // this holds the parameters to be passed into the
char parmbuffer[2048]; // this holds the parameters to be passed into the
// alias command
const char* psMapsBuffer;
if (ev->NumArgs() < 2) {
return;
@@ -5185,14 +5279,23 @@ void ClientGameCommandManager::AliasCache(Event* ev)
// any additional parameters are in arguments 3-n
parmbuffer[0] = 0;
psMapsBuffer = NULL;
for (i = 3; i <= ev->NumArgs(); i++) {
strcat(parmbuffer, ev->GetToken(i));
strcat(parmbuffer, " ");
if (strcmp(ev->GetToken(i).c_str(), "maps")) {
strcat(parmbuffer, ev->GetToken(i));
strcat(parmbuffer, " ");
}
else {
psMapsBuffer = ev->GetToken(i++);
}
}
AliasResource(current_tiki, ev->GetString(1), ev->GetString(2), parmbuffer);
CacheResource(ev->GetString(2));
if (bLoadForMap(psMapsBuffer, ev->GetString(1)))
{
AliasResource(current_tiki, ev->GetString(1), ev->GetString(2), parmbuffer);
CacheResource(ev->GetString(2));
}
}
//===============
@@ -5202,8 +5305,10 @@ void ClientGameCommandManager::Alias(Event* ev)
{
int i;
char parmbuffer[512]; // this holds the parameters to be passed into the
char parmbuffer[2048]; // this holds the parameters to be passed into the
// alias command
qboolean subtitle;
const char* psMapsBuffer;
if (ev->NumArgs() < 2) {
return;
@@ -5213,14 +5318,43 @@ void ClientGameCommandManager::Alias(Event* ev)
// real path is argument 2
// any additional parameters are in arguments 3-n
parmbuffer[0] = 0;
parmbuffer[0] = 0;
subtitle = qfalse;
psMapsBuffer = NULL;
for (i = 3; i <= ev->NumArgs(); i++) {
strcat(parmbuffer, ev->GetToken(i));
strcat(parmbuffer, " ");
}
for (i = 3; i <= ev->NumArgs(); i++)
{
if (strcmp(ev->GetToken(i).c_str(), "maps"))
{
if (!subtitle)
{
if (!Q_stricmp(ev->GetToken(i), "subtitle")) {
subtitle = qtrue;
strcat(parmbuffer, ev->GetToken(i));
}
else {
strcat(parmbuffer, ev->GetToken(i));
}
}
else
{
strcat(parmbuffer, "\"");
strcat(parmbuffer, ev->GetToken(i));
strcat(parmbuffer, "\"");
subtitle = qfalse;
}
AliasResource(current_tiki, ev->GetString(1), ev->GetString(2), parmbuffer);
strcat(parmbuffer, " ");
}
else {
psMapsBuffer = ev->GetToken(i++);
}
}
if (bLoadForMap(psMapsBuffer, ev->GetString(1)))
{
AliasResource(current_tiki, ev->GetString(1), ev->GetString(2), parmbuffer);
}
}
void CacheAliasList(AliasList_t* alias_list, str& name)
@@ -6414,7 +6548,7 @@ qboolean CG_Command_ProcessFile(const char* filename, qboolean quiet, dtiki_t *c
ev->AddToken(com_token);
}
commandManager.ProcessEvent(ev);
commandManager.SelectProcessEvent(ev);
}
cgi.FS_FreeFile((void*)bufstart);
+3 -3
View File
@@ -558,8 +558,7 @@ int CG_WeaponCommandButtonBits(void)
{
int iShiftedWeaponCommand;
iShiftedWeaponCommand = cg.iWeaponCommand;
if (!iShiftedWeaponCommand) {
if (!cg.iWeaponCommand) {
return 0;
}
@@ -568,5 +567,6 @@ int CG_WeaponCommandButtonBits(void)
cg.iWeaponCommand = 0;
}
return (iShiftedWeaponCommand << 7) & WEAPON_COMMAND_MASK;
iShiftedWeaponCommand = cg.iWeaponCommand << 7;
return iShiftedWeaponCommand & WEAPON_COMMAND_MASK;
}
+3 -3
View File
@@ -495,7 +495,7 @@ void CG_SetLightStyle( int num, const char *s )
cg_lightstyle[ num ].map[ k ][ 1 ] = t / 255.0f;
k++;
}
n = max( n, k );
n = Q_max( n, k );
}
while( k < MAX_LIGHTSTYLE_LENGTH )
{
@@ -518,7 +518,7 @@ void CG_SetLightStyle( int num, const char *s )
cg_lightstyle[ num ].map[ k ][ 2 ] = t / 255.0f;
k++;
}
n = max( n, k );
n = Q_max( n, k );
}
while( k < MAX_LIGHTSTYLE_LENGTH )
{
@@ -541,7 +541,7 @@ void CG_SetLightStyle( int num, const char *s )
cg_lightstyle[ num ].map[ k ][ 3 ] = t / 255.0f;
k++;
}
n = max( n, k );
n = Q_max( n, k );
}
while( k < MAX_LIGHTSTYLE_LENGTH )
{
+4 -2
View File
@@ -580,13 +580,15 @@ void CG_ParseCGMessage()
cgi.HudDrawElements[iInfo].bVirtualScreen = cgi.MSG_ReadBits(1);
break;
case 31:
case 31:
iInfo = cgi.MSG_ReadByte();
cgi.HudDrawElements[iInfo].vColor[0] = cgi.MSG_ReadByte() / 255.0;
cgi.HudDrawElements[iInfo].vColor[1] = cgi.MSG_ReadByte() / 255.0;
cgi.HudDrawElements[iInfo].vColor[2] = cgi.MSG_ReadByte() / 255.0;
break;
case 32:
case 32:
iInfo = cgi.MSG_ReadByte();
cgi.HudDrawElements[iInfo].vColor[3] = cgi.MSG_ReadByte() / 255.0;
break;
+1
View File
@@ -34,6 +34,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// refdef flags
#define RDF_NOWORLDMODEL 1 // used for player configuration screen
#define RDF_FULLBRIGHT 2 // fullbright intensity
#define RDF_HYPERSPACE 4 // teleportation effect
typedef struct
+2 -2
View File
@@ -595,11 +595,11 @@ void CL_CmdButtons( usercmd_t *cmd ) {
// allow the game to know if any key at all is
// currently pressed, even if it isn't bound to anything
if ( anykeydown && Key_GetCatcher() == 0) {
cmd->buttons |= BUTTON_ANY;
cmd->buttons |= BUTTON_ANY2;
}
if (anykeydown) {
cmd->buttons |= BUTTON_ANY2;
cmd->buttons |= BUTTON_ANY;
}
}
+18 -13
View File
@@ -1421,6 +1421,10 @@ void CL_ResetPureClientAtServer( void ) {
CL_AddReliableCommand( va("vdr") );
}
qboolean CL_Allowed_Vid_Restart() {
return cls.state == CA_DISCONNECTED || cls.state == CA_ACTIVE;
}
/*
=================
CL_Vid_Restart_f
@@ -1432,29 +1436,28 @@ because the renderer doesn't know what graphics to reload
=================
*/
void CL_Vid_Restart_f( void ) {
// Settings may have changed so stop recording now
if( CL_VideoRecording( ) ) {
CL_CloseAVI( );
if (!CL_Allowed_Vid_Restart()) {
return;
}
if(clc.demorecording)
CL_StopRecord_f();
Com_Printf("-------- CL_Vid_Restart_f --------\n");
cls.vid_restart = qtrue;
// don't let them loop during the restart
S_StopAllSounds( qtrue );
S_StopAllSounds(qtrue);
SV_ClearSvsTimeFixups();
S_BeginRegistration();
// shutdown the renderer and clear the renderer interface
CL_ShutdownRef();
// shutdown the CGame
CL_ShutdownCGame();
// initialize the renderer interface
CL_InitRef();
// client is no longer pure untill new checksums are sent
CL_ResetPureClientAtServer();
// clear pak references
FS_ClearPakReferences( FS_UI_REF | FS_CGAME_REF );
// reinitialize the filesystem if the game directory or checksum has changed
FS_ConditionalRestart( clc.checksumFeed );
// initialize the ui library
UI_ResolutionChange();
cls.rendererRegistered = qfalse;
cls.uiStarted = qfalse;
@@ -1469,6 +1472,8 @@ void CL_Vid_Restart_f( void ) {
S_Init();
cls.vid_restart = qfalse;
Com_Printf("----- finished CL_Vid_Restart_f ----\n");
}
/*
+97 -159
View File
@@ -200,168 +200,109 @@ void Alias_ListAddParms(AliasListNode_t* node, const char* parameters)
return;
}
while (1)
for (;;)
{
while (1)
token = nptr = COM_GetToken((char**)&parameters, qtrue);
if (!token || !token[0])
{
while (1)
break;
}
if (!Q_stricmp(token, "stop"))
{
node->stop_flag = 1;
}
else if (!Q_stricmp(token, "soundparms"))
{
node->volume = getTokenFloat(&parameters, "volume", node);
node->volumeMod = getTokenFloat(&parameters, "volumeMod", node);
node->pitch = getTokenFloat(&parameters, "pitch", node);
node->pitchMod = getTokenFloat(&parameters, "pitchMod", node);
node->dist = getTokenFloat(&parameters, "dist", node);
node->maxDist = getTokenFloat(&parameters, "maxDist", node);
token = COM_GetToken((char**)&parameters, qtrue);
if (!token || !*token)
{
while (1)
{
while (1)
{
while (1)
{
while (1)
{
while (1)
{
token = nptr = COM_GetToken((char**)&parameters, qtrue);
if (!token || !*token)
{
return;
}
if (Q_stricmp(nptr, "weight"))
{
break;
}
node->stop_flag = 1;
}
if (Q_stricmp(nptr, "weight"))
{
break;
}
token = COM_GetToken((char**)&parameters, 1);
if (!token || !*token)
{
return;
}
temp_float = atof(token);
if (temp_float < 0.0f)
{
Com_Printf("Weight value out of range in %s alias\n", node->alias_name);
continue;
}
node->weight = temp_float;
}
if (Q_stricmp(nptr, "soundparms"))
{
break;
}
node->volume = getTokenFloat(&parameters, "volume", node);
node->volumeMod = getTokenFloat(&parameters, "volumeMod", node);
node->pitch = getTokenFloat(&parameters, "pitch", node);
node->pitchMod = getTokenFloat(&parameters, "pitchMod", node);
node->dist = getTokenFloat(&parameters, "dist", node);
node->maxDist = getTokenFloat(&parameters, "maxDist", node);
token = COM_GetToken((char**)&parameters, 1);
if (!token || !*token)
{
return;
}
node->channel = S_ChannelNameToNum(token);
if (node->channel == -1)
{
Com_Printf("%s is not avalid channel on %s alias.\n", token, node->alias_name);
node->channel = 0;
}
token = COM_GetToken((char**)&parameters, 1);
if (!token || !*token)
{
Com_Printf("ERROR: defaulting %s to not streamed - please setup alias properly.\n", node->alias_name);
return;
}
if (!Q_stricmp(token, "streamed"))
{
node->streamed = 1;
}
else if (!Q_stricmp(token, "loaded"))
{
node->streamed = 0;
}
else
{
Com_Printf("ERROR: Expecting streamed or loaded in ubersound and got %s on alias %s\n", token, node->alias_name);
continue;
}
}
if (Q_stricmp(nptr, "subtitle"))
{
break;
}
token = COM_GetToken((char**)&parameters, qtrue);
if (!token || !*token)
{
Com_Printf("NULL subtitle on %s alias.\n", node->alias_name);
return;
}
node->subtitle = Z_TagMalloc(strlen(token) + 1, TAG_TIKI);
strcpy(node->subtitle, token);
}
if (Q_stricmp(nptr, "pitch"))
{
break;
}
token = COM_GetToken((char**)&parameters, qtrue);
if (!token || !*token)
{
return;
}
temp_float = atof(token);
if (temp_float < 0.0f)
{
Com_Printf("Pitch value out of range in %s alias\n", node->alias_name);
continue;
}
node->pitch = temp_float;
}
if (Q_stricmp(nptr, "pitchmod"))
{
break;
}
token = COM_GetToken((char**)&parameters, qtrue);
if (!token || !*token)
{
return;
}
temp_float = atof(token);
if (temp_float < 0.0f)
{
Com_Printf("PitchMod value out of range in %s alias\n", node->alias_name);
continue;
}
node->pitchMod = temp_float;
return;
}
if (Q_stricmp(nptr, "volumemod"))
node->channel = S_ChannelNameToNum(token);
if (node->channel == -1)
{
break;
Com_Printf("%s is not avalid channel on %s alias.\n", token, node->alias_name);
node->channel = 0;
}
token = COM_GetToken((char**)&parameters, qtrue);
if (!token || !*token)
{
Com_Printf("ERROR: defaulting %s to not streamed - please setup alias properly.\n", node->alias_name);
return;
}
if (!Q_stricmp(token, "streamed"))
{
node->streamed = qtrue;
}
else if (!Q_stricmp(token, "loaded"))
{
node->streamed = qfalse;
}
else
{
Com_Printf("ERROR: Expecting streamed or loaded in ubersound and got %s on alias %s\n", token, node->alias_name);
continue;
}
}
else if (!Q_stricmp(token, "subtitle"))
{
token = COM_GetToken((char**)&parameters, qtrue);
if (!token || !*token)
{
Com_Printf("NULL subtitle on %s alias.\n", node->alias_name);
return;
}
node->subtitle = Z_TagMalloc(strlen(token) + 1, TAG_TIKI);
strcpy(node->subtitle, token);
}
else if (!Q_stricmp(token, "pitch"))
{
token = COM_GetToken((char**)&parameters, qtrue);
if (!token || !*token)
{
return;
}
temp_float = atof(token);
if (temp_float < 0.0f)
{
Com_Printf("Pitch value out of range in %s alias\n", node->alias_name);
continue;
}
node->pitch = temp_float;
}
else if (!Q_stricmp(token, "pitchmod"))
{
token = COM_GetToken((char**)&parameters, qtrue);
if (!token || !*token)
{
return;
}
temp_float = atof(token);
if (temp_float < 0.0f)
{
Com_Printf("PitchMod value out of range in %s alias\n", node->alias_name);
continue;
}
node->pitchMod = temp_float;
}
else if (!Q_stricmp(token, "volumemod"))
{
token = COM_GetToken((char**)&parameters, qtrue);
if (!token || !*token)
{
@@ -377,8 +318,7 @@ void Alias_ListAddParms(AliasListNode_t* node, const char* parameters)
node->volumeMod = temp_float;
}
if (!Q_stricmp(nptr, "dist"))
else if (!Q_stricmp(token, "dist"))
{
token = COM_GetToken((char**)&parameters, qtrue);
if (!token || !*token)
@@ -396,7 +336,7 @@ void Alias_ListAddParms(AliasListNode_t* node, const char* parameters)
node->dist = temp_float;
}
else if (!Q_stricmp(nptr, "channel"))
else if (!Q_stricmp(token, "channel"))
{
token = COM_GetToken((char**)&parameters, qtrue);
if (!token || !*token)
@@ -418,8 +358,6 @@ void Alias_ListAddParms(AliasListNode_t* node, const char* parameters)
continue;
}
}
// FIXME: stub
}
qboolean Alias_ListAdd(AliasList_t* list, const char* alias, const char* name, const char* parameters)
+1 -1
View File
@@ -108,7 +108,7 @@ void* MEM_TempAlloc::CreateBlock(size_t len)
// allocate a new block
tempBlock_t* prev_block = m_CurrentMemoryBlock;
m_CurrentMemoryBlock = (tempBlock_t*)MEM_TempAllocate(
sizeof(tempBlock_t) + max(m_BlockSize, len));
sizeof(tempBlock_t) + Q_max(m_BlockSize, len));
m_CurrentMemoryBlock->prev = prev_block;
return m_CurrentMemoryBlock->GetData();
}
+33 -18
View File
@@ -2202,15 +2202,22 @@ void MSG_ReadDeltaEntity( msg_t *msg, entityState_t *from, entityState_t *to,
}
else bits = field->bits;
result = MSG_ReadBits( msg, bits );
if ( bits == 12 )
*(float *)toF = result * 0.087890625f * tmp;
else if ( bits == 8 )
*(float *)toF = result * 1.411764705882353f * tmp;
else if ( bits == 16 )
*(float *)toF = result * 0.0054931640625f * tmp;
else
*(float *)toF = result * (1 << bits) * tmp / 360.0f;
result = MSG_ReadBits(msg, bits);
switch (bits)
{
case 8:
*(float*)toF = tmp * 360.f / 256.f;
break;
case 12:
*(float*)toF = tmp * result * 360.f / 4096.f;
break;
case 16:
*(float*)toF = tmp * result * 360.f / 65536.f;
break;
default:
*(float*)toF = tmp * 360.f / (1 << bits) * result;
break;
}
break;
case netFieldType_e::animTime: // time
*(float *)toF = MSG_ReadBits( msg, 15 ) * 0.0099999998f;
@@ -2842,15 +2849,23 @@ void MSG_ReadDeltaPlayerstate(msg_t *msg, playerState_t *from, playerState_t *to
}
else bits = field->bits;
result = MSG_ReadBits( msg, bits );
if ( field->bits == 12 )
*(float *)toF = result * 0.087890625f * tmp;
else if ( field->bits == 8 )
*(float *)toF = result * 1.411764705882353f * tmp;
else if ( field->bits == 16 )
*(float *)toF = result * 0.0054931640625f * tmp;
else
*(float *)toF = result * (1 << bits) * tmp / 360.0f;
result = MSG_ReadBits(msg, bits);
switch (bits)
{
case 8:
*(float*)toF = tmp * 360.f / 256.f;
break;
case 12:
*(float*)toF = tmp * result * 360.f / 4096.f;
break;
case 16:
*(float*)toF = tmp * result * 360.f / 65536.f;
break;
default:
*(float*)toF = tmp * 360.f / (1 << bits) * result;
break;
}
break;
case netFieldType_e::coord:
tmp = 1.0f;
+5 -5
View File
@@ -503,11 +503,11 @@ extern vec4_t g_color_table[8];
#define LERP( a, b, w ) ( ( a ) * ( 1.0f - ( w ) ) + ( b ) * ( w ) )
#define LUMA( red, green, blue ) ( 0.2126f * ( red ) + 0.7152f * ( green ) + 0.0722f * ( blue ) )
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#ifndef Q_min
#define Q_min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#ifndef Q_max
#define Q_max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#define bound(a,minval,maxval) ( ((a) > (minval)) ? ( ((a) < (maxval)) ? (a) : (maxval) ) : (minval) )
@@ -1758,7 +1758,7 @@ typedef struct playerState_s {
#define WEAPON_COMMAND_HOLSTER 14
#define WEAPON_COMMAND_DROP 15
#define WEAPON_COMMAND_MAX 15
#define WEAPON_COMMAND_MASK WEAPON_COMMAND_MAX << 7
#define WEAPON_COMMAND_MASK (WEAPON_COMMAND_MAX << 7)
#define MOVE_RUN 120 // if forwardmove or rightmove are >= MOVE_RUN,
+13 -28
View File
@@ -717,7 +717,14 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
continue;
}
oldSort = drawSurf->sort;
R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &dlightMap, &bStaticModel );
if (*drawSurf->surface != SF_SPRITE) {
R_DecomposeSort(drawSurf->sort, &entityNum, &shader, &dlightMap, &bStaticModel);
} else {
shader = tr.sortedShaders[((refSprite_t*)drawSurf->surface)->shaderNum];
entityNum = ENTITYNUM_WORLD;
dlightMap = 0;
bStaticModel = qfalse;
}
//
// change the tess parameters if needed
@@ -743,6 +750,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
oldDlightMap = dlightMap;
}
backEnd.currentSphere = &backEnd.spareSphere;
//
// change the modelview matrix if needed
//
@@ -970,12 +978,12 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, int componen
ri.Error (ERR_DROP, "Draw_StretchRaw: size not a power of 2: %i by %i", cols, rows);
}
GL_Bind( tr.scratchImage[0] );
GL_Bind( tr.scratchImage );
// if the scratchImage isn't in the format we want, specify it as a new texture
if ( cols != tr.scratchImage[0]->width || rows != tr.scratchImage[0]->height ) {
tr.scratchImage[0]->width = tr.scratchImage[0]->uploadWidth = cols;
tr.scratchImage[0]->height = tr.scratchImage[0]->uploadHeight = rows;
if ( cols != tr.scratchImage->width || rows != tr.scratchImage->height ) {
tr.scratchImage->width = tr.scratchImage->uploadWidth = cols;
tr.scratchImage->height = tr.scratchImage->uploadHeight = rows;
qglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
@@ -1008,29 +1016,6 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, int componen
qglEnd ();
}
void RE_UploadCinematic (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) {
GL_Bind( tr.scratchImage[client] );
// if the scratchImage isn't in the format we want, specify it as a new texture
if ( cols != tr.scratchImage[client]->width || rows != tr.scratchImage[client]->height ) {
tr.scratchImage[client]->width = tr.scratchImage[client]->uploadWidth = cols;
tr.scratchImage[client]->height = tr.scratchImage[client]->uploadHeight = rows;
qglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
} else {
if (dirty) {
// otherwise, just subimage upload it so that drivers can tell we are going to be changing
// it and don't try and do a texture compression
qglTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_RGBA, GL_UNSIGNED_BYTE, data );
}
}
}
/*
=============
RB_SetColor
+92 -145
View File
@@ -261,6 +261,14 @@ static void R_LoadLightmaps(gamelump_t* l) {
if ( r_lightmap->integer == 2 ) {
ri.Printf( PRINT_ALL, "Brightest lightmap value: %d\n", ( int ) ( maxIntensity * 255 ) );
}
if (r_fastdlights->integer) {
s_worldData.lighting = NULL;
}
else {
s_worldData.lighting = ri.Hunk_Alloc(l->length);
Com_Memcpy(s_worldData.lighting, l->buffer, l->length);
}
}
@@ -478,7 +486,7 @@ void R_UnpackTerraPatch(cTerraPatch_t* pPacked, cTerraPatchUnpacked_t* pUnpacked
pUnpacked->t = ((float)pPacked->t + 0.5) * 0.0078125;
if( s_worldData.lighting ) {
pUnpacked->drawinfo.lmData = &s_worldData.lighting[ 3 * ( ( pPacked->t << 7 ) + pPacked->s + ( pPacked->iLightMap << 14 ) ) ];
pUnpacked->drawinfo.lmData = &s_worldData.lighting[pPacked->iLightMap * (LIGHTMAP_SIZE * LIGHTMAP_SIZE * 3) + 3 * pPacked->s + 3 * 128 * pPacked->t];
} else {
pUnpacked->drawinfo.lmData = NULL;
}
@@ -607,9 +615,6 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int
lightmapNum = LittleLong( ds->lightmapNum );
// get fog volume
surf->fogIndex = LittleLong( ds->fogNum ) + 1;
// get shader value
surf->shader = ShaderForShaderNum( ds->shaderNum, lightmapNum );
if ( r_singleShader->integer && !surf->shader->isSky ) {
@@ -661,6 +666,42 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int
SetPlaneSignbits( &cv->plane );
cv->plane.type = PlaneTypeForNormal( cv->plane.normal );
if (tr.numLightmaps && lightmapNum != -1 && surf->shader->lightmapIndex >= 0)
{
float inv;
cv->lmX = LittleLong(ds->lightmapX);
cv->lmY = LittleLong(ds->lightmapY);
cv->lmWidth = LittleLong(ds->lightmapWidth);
cv->lmHeight = LittleLong(ds->lightmapHeight);
if (s_worldData.lighting) {
cv->lmData = &s_worldData.lighting[lightmapNum * (LIGHTMAP_SIZE * LIGHTMAP_SIZE * 3) + 3 * cv->lmX + 3 * 128 * cv->lmY];
} else {
cv->lmData = NULL;
}
for (i = 0; i < 3; i++)
{
cv->lmOrigin[j] = LittleFloat(ds->lightmapOrigin[j]);
cv->lmVecs[0][j] = LittleFloat(ds->lightmapVecs[0][j]);
cv->lmVecs[1][j] = LittleFloat(ds->lightmapVecs[1][j]);
}
inv = VectorNormalize2(cv->lmVecs[0], cv->lmInverseVecs[0]);
cv->lmInverseVecs[0][0] *= 1.0 / inv;
cv->lmInverseVecs[0][1] *= 1.0 / inv;
cv->lmInverseVecs[0][2] *= 1.0 / inv;
inv = VectorNormalize2(cv->lmVecs[1], cv->lmInverseVecs[1]);
cv->lmInverseVecs[1][0] *= 1.0 / inv;
cv->lmInverseVecs[1][1] *= 1.0 / inv;
cv->lmInverseVecs[1][2] *= 1.0 / inv;
}
else
{
cv->lmData = NULL;
}
surf->data = (surfaceType_t *)cv;
}
@@ -719,6 +760,19 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, msurface_t *surf ) {
grid = R_SubdividePatchToGrid( width, height, points );
surf->data = (surfaceType_t *)grid;
if (tr.numLightmaps && lightmapNum != -1 && surf->shader->lightmapIndex >= 0)
{
grid->lmX = LittleLong(ds->lightmapX);
grid->lmY = LittleLong(ds->lightmapY);
grid->lmWidth = LittleLong(ds->lightmapWidth);
grid->lmHeight = LittleLong(ds->lightmapHeight);
if (s_worldData.lighting) {
grid->lmData = &s_worldData.lighting[lightmapNum * (LIGHTMAP_SIZE * LIGHTMAP_SIZE * 3) + 3 * grid->lmX + 3 * 128 * grid->lmY];
} else {
grid->lmData = NULL;
}
}
// copy the level of detail origin, which is the center
// of the group of all curves that must subdivide the same
// to avoid cracking
@@ -1903,129 +1957,13 @@ static void R_LoadPlanes(gamelump_t* l) {
}
}
/*
=================
R_LoadFogs
=================
*/
static void R_LoadFogs(gamelump_t* l, gamelump_t* brushesLump, gamelump_t* sidesLump) {
int i;
fog_t* out;
dfog_t* fogs;
dbrush_t* brushes, * brush;
dbrushside_t* sides;
int count, brushesCount, sidesCount;
int sideNum;
int planeNum;
shader_t* shader;
float d;
int firstSide;
fogs = l->buffer;
if (l->length % sizeof(*fogs)) {
ri.Error(ERR_DROP, "LoadMap: funny lump size in %s", s_worldData.name);
}
count = l->length / sizeof(*fogs);
// create fog strucutres for them
s_worldData.numfogs = count + 1;
s_worldData.fogs = ri.Hunk_Alloc(s_worldData.numfogs * sizeof(*out));
out = s_worldData.fogs + 1;
if (!count) {
return;
}
brushes = brushesLump->buffer;
if (brushesLump->length % sizeof(*brushes)) {
ri.Error(ERR_DROP, "LoadMap: funny lump size in %s", s_worldData.name);
}
brushesCount = brushesLump->length / sizeof(*brushes);
sides = sidesLump->buffer;
if (sidesLump->length % sizeof(*sides)) {
ri.Error(ERR_DROP, "LoadMap: funny lump size in %s", s_worldData.name);
}
sidesCount = sidesLump->length / sizeof(*sides);
for (i = 0; i < count; i++, fogs++) {
out->originalBrushNumber = LittleLong(fogs->brushNum);
if ((unsigned)out->originalBrushNumber >= brushesCount) {
ri.Error(ERR_DROP, "fog brushNumber out of range");
}
brush = brushes + out->originalBrushNumber;
firstSide = LittleLong(brush->firstSide);
if ((unsigned)firstSide > sidesCount - 6) {
ri.Error(ERR_DROP, "fog brush sideNumber out of range");
}
// brushes are always sorted with the axial sides first
sideNum = firstSide + 0;
planeNum = LittleLong(sides[sideNum].planeNum);
out->bounds[0][0] = -s_worldData.planes[planeNum].dist;
sideNum = firstSide + 1;
planeNum = LittleLong(sides[sideNum].planeNum);
out->bounds[1][0] = s_worldData.planes[planeNum].dist;
sideNum = firstSide + 2;
planeNum = LittleLong(sides[sideNum].planeNum);
out->bounds[0][1] = -s_worldData.planes[planeNum].dist;
sideNum = firstSide + 3;
planeNum = LittleLong(sides[sideNum].planeNum);
out->bounds[1][1] = s_worldData.planes[planeNum].dist;
sideNum = firstSide + 4;
planeNum = LittleLong(sides[sideNum].planeNum);
out->bounds[0][2] = -s_worldData.planes[planeNum].dist;
sideNum = firstSide + 5;
planeNum = LittleLong(sides[sideNum].planeNum);
out->bounds[1][2] = s_worldData.planes[planeNum].dist;
// get information from the shader for fog parameters
shader = R_FindShader(fogs->shader, LIGHTMAP_NONE, qtrue, qtrue, qtrue, qtrue);
out->parms = shader->fogParms;
out->colorInt = ColorBytes4(shader->fogParms.color[0] * tr.identityLight,
shader->fogParms.color[1] * tr.identityLight,
shader->fogParms.color[2] * tr.identityLight, 1.0);
d = shader->fogParms.depthForOpaque < 1 ? 1 : shader->fogParms.depthForOpaque;
out->tcScale = 1.0f / (d * 8);
// set the gradient vector
sideNum = LittleLong(fogs->visibleSide);
if (sideNum == -1) {
out->hasSurface = qfalse;
}
else {
out->hasSurface = qtrue;
planeNum = LittleLong(sides[firstSide + sideNum].planeNum);
VectorSubtract(vec3_origin, s_worldData.planes[planeNum].normal, out->surface);
out->surface[3] = -s_worldData.planes[planeNum].dist;
}
out++;
}
}
/*
================
R_LoadLightGrid
================
*/
void R_LoadLightGrid(gamelump_t* l) {
void R_LoadLightGrid(gamelump_t* plPal, gamelump_t* plOffsets, gamelump_t* plData) {
int i;
vec3_t maxs;
int numGridPoints;
@@ -2034,35 +1972,51 @@ void R_LoadLightGrid(gamelump_t* l) {
w = &s_worldData;
w->lightGridInverseSize[0] = 1.0f / w->lightGridSize[0];
w->lightGridInverseSize[1] = 1.0f / w->lightGridSize[1];
w->lightGridInverseSize[2] = 1.0f / w->lightGridSize[2];
if (!plPal->buffer || !plOffsets->buffer || !plData->buffer) {
ri.Printf(PRINT_WARNING, "WARNING: No light grid data present\n");
w->lightGridOffsets = 0;
w->lightGridData = 0;
return;
}
w->lightGridSize[0] = 32.0;
w->lightGridSize[1] = 32.0;
w->lightGridSize[2] = 32.0;
w->lightGridOOSize[0] = 1.0f / w->lightGridSize[0];
w->lightGridOOSize[1] = 1.0f / w->lightGridSize[1];
w->lightGridOOSize[2] = 1.0f / w->lightGridSize[2];
wMins = w->bmodels[0].bounds[0];
wMaxs = w->bmodels[0].bounds[1];
for ( i = 0 ; i < 3 ; i++ ) {
w->lightGridOrigin[i] = w->lightGridSize[i] * ceil( wMins[i] / w->lightGridSize[i] );
w->lightGridMins[i] = w->lightGridSize[i] * ceil( wMins[i] / w->lightGridSize[i] );
maxs[i] = w->lightGridSize[i] * floor( wMaxs[i] / w->lightGridSize[i] );
w->lightGridBounds[i] = (maxs[i] - w->lightGridOrigin[i])/w->lightGridSize[i] + 1;
w->lightGridBounds[i] = (maxs[i] - w->lightGridMins[i])/w->lightGridSize[i] + 1;
}
numGridPoints = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2];
numGridPoints = w->lightGridBounds[0] * w->lightGridBounds[1] + w->lightGridBounds[0];
if (l->length != numGridPoints * 8) {
ri.Printf(PRINT_WARNING, "WARNING: light grid mismatch\n");
if (plOffsets->length != numGridPoints * 2) {
ri.Printf(PRINT_WARNING, "WARNING: light grid offset size mismatch\n");
w->lightGridOffsets = NULL;
w->lightGridData = NULL;
return;
}
w->lightGridData = ri.Hunk_Alloc(l->length);
Com_Memcpy(w->lightGridData, (void*)l->buffer, l->length);
// deal with overbright bits
for ( i = 0 ; i < numGridPoints ; i++ ) {
R_ColorShiftLightingBytesAlpha( &w->lightGridData[i*8], &w->lightGridData[i*8] );
R_ColorShiftLightingBytesAlpha( &w->lightGridData[i*8+3], &w->lightGridData[i*8+3] );
if (plPal->length != 768) {
ri.Printf(PRINT_WARNING, "WARNING: light grid palette size mismatch\n");
w->lightGridOffsets = NULL;
w->lightGridData = NULL;
return;
}
w->lightGridOffsets = ri.Hunk_Alloc(plOffsets->length);
Com_Memcpy(w->lightGridOffsets, plOffsets->buffer, plOffsets->length);
Com_Memcpy(w->lightGridPalette, plPal->buffer, sizeof(s_worldData.lightGridPalette));
w->lightGridData = ri.Hunk_Alloc(plData->length);
Com_Memcpy(w->lightGridData, plData->buffer, plData->length);
}
/*
@@ -2339,13 +2293,7 @@ void RE_LoadWorldMap( const char *name ) {
_R(75);
R_FreeLump(&lump2);
_R(76);
numbrushsides = R_LoadLump(h, &header.lumps[LUMP_BRUSHSIDES], &lump2, sizeof(dbrushside_t));
numbrushes = R_LoadLump(h, &header.lumps[LUMP_BRUSHES], &lump, sizeof(dbrush_t));
numFogs = R_LoadLump(h, &header.lumps[LUMP_DUMMY10], &lump3, sizeof(dfog_t));
R_LoadFogs(&lump3, &lump, &lump2);
R_FreeLump(&lump);
R_FreeLump(&lump2);
R_FreeLump(&lump3);
numFogs = 0;
nummodels = R_LoadLump(h, &header.lumps[LUMP_MODELS], &lump, sizeof(bmodel_t));
_R(77);
R_LoadSubmodels(&lump);
@@ -2364,8 +2312,7 @@ void RE_LoadWorldMap( const char *name ) {
_R(84);
g_iGridDataSize = R_LoadLump(h, &header.lumps[LUMP_LIGHTGRIDDATA], &lump3, sizeof(byte));
_R(85);
//R_LoadLightGrid( &lump, &lump2, &lump3 );
R_LoadLightGrid(&lump3);
R_LoadLightGrid( &lump, &lump2, &lump3 );
_R(86);
R_FreeLump(&lump);
_R(87);
+1 -1
View File
@@ -46,7 +46,7 @@ void R_PerformanceCounters( void ) {
ri.SetPerformanceCounters(
backEnd.pc.c_totalIndexes / 3,
backEnd.pc.c_vertexes,
R_SumOfUsedImages(pc_save.c_totalIndexes / 3, pc_save.c_vertexes),
R_SumOfUsedImages(),
pc_save.c_totalIndexes / 3,
pc_save.c_vertexes,
backEnd.pc.c_characterlights
+5 -5
View File
@@ -236,17 +236,17 @@ void RE_DrawBackground_TexSubImage(int cols, int rows, int bgr, byte* data) {
format = GL_RGB;
}
GL_Bind(tr.scratchImage[0]);
GL_Bind(tr.scratchImage);
if (cols == tr.scratchImage[0]->width && rows == tr.scratchImage[0]->height && format == tr.scratchImage[0]->internalFormat)
if (cols == tr.scratchImage->width && rows == tr.scratchImage->height && format == tr.scratchImage->internalFormat)
{
qglTexSubImage2D(3553, 0, 0, 0, cols, rows, format, 5121, data);
}
else
{
tr.scratchImage[0]->uploadWidth = cols;
tr.scratchImage[0]->uploadHeight = rows;
tr.scratchImage[0]->internalFormat = format;
tr.scratchImage->uploadWidth = cols;
tr.scratchImage->uploadHeight = rows;
tr.scratchImage->internalFormat = format;
qglTexImage2D(GL_TEXTURE_2D, 0, 3, cols, rows, 0, format, 5121, data);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 9729.0);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 9729.0);
-19
View File
@@ -197,32 +197,13 @@ RB_AddDlightFlares
void RB_AddDlightFlares( void ) {
dlight_t *l;
int i, j, k;
fog_t *fog;
if ( !r_flares->integer ) {
return;
}
l = backEnd.refdef.dlights;
fog = tr.world->fogs;
for (i=0 ; i<backEnd.refdef.num_dlights ; i++, l++) {
// find which fog volume the light is in
for ( j = 1 ; j < tr.world->numfogs ; j++ ) {
fog = &tr.world->fogs[j];
for ( k = 0 ; k < 3 ; k++ ) {
if ( l->origin[k] < fog->bounds[0][k] || l->origin[k] > fog->bounds[1][k] ) {
break;
}
}
if ( k == 3 ) {
break;
}
}
if ( j == tr.world->numfogs ) {
j = 0;
}
RB_AddFlare( (void *)l, j, l->origin, l->color, NULL );
}
}
+31 -7
View File
@@ -299,6 +299,10 @@ lighting range
*/
void R_LightScaleTexture (unsigned *in, int inwidth, int inheight, qboolean only_gamma )
{
if (!tr.needsLightScale) {
return;
}
if ( only_gamma )
{
if ( !glConfig.deviceSupportsGamma )
@@ -2100,6 +2104,7 @@ static void R_CreateDefaultImage( void ) {
data[x][DEFAULT_SIZE-1][3] = 255;
}
tr.defaultImage = R_CreateImage("*default", (byte *)data, DEFAULT_SIZE, DEFAULT_SIZE, 1, 1, qfalse, qfalse, qfalse, qfalse, GL_REPEAT, GL_REPEAT);
tr.defaultImage->r_sequence = -1;
}
/*
@@ -2109,6 +2114,8 @@ R_CreateBuiltinImages
*/
void R_CreateBuiltinImages( void ) {
int x,y;
int i;
byte lightmap_buffer[128 * 128 * 4];
byte data[DEFAULT_SIZE][DEFAULT_SIZE][4];
R_CreateDefaultImage();
@@ -2116,6 +2123,7 @@ void R_CreateBuiltinImages( void ) {
// we use a solid white image instead of disabling texturing
Com_Memset( data, 255, sizeof( data ) );
tr.whiteImage = R_CreateImage("*white", (byte *)data, 8, 8, 0, 1, qfalse, qfalse, qfalse, qfalse, GL_REPEAT, GL_REPEAT);
tr.whiteImage->r_sequence = -1;
// with overbright bits active, we need an image which is some fraction of full color,
// for default lightmaps, etc
@@ -2128,14 +2136,18 @@ void R_CreateBuiltinImages( void ) {
}
}
tr.identityLightImage = R_CreateImage("*identityLight", (byte *)data, 8, 8, 0, 1, qfalse, qfalse, qfalse, qfalse, GL_REPEAT, GL_REPEAT);
for(x=0;x<32;x++) {
// scratchimage is usually used for cinematic drawing
tr.scratchImage[x] = R_CreateImage("*scratch", (byte *)data, DEFAULT_SIZE, DEFAULT_SIZE, 0, 1, qtrue, qfalse, qfalse, qfalse, GL_REPEAT, GL_REPEAT);
Com_Memset(lightmap_buffer, 0xFFFFFFFF, sizeof(lightmap_buffer));
for (i = 0; i < 15; i++) {
tr.dlightImages[i] = R_CreateImage("*lightmapD%i", lightmap_buffer, LIGHTMAP_SIZE, LIGHTMAP_SIZE, 0, 1, qfalse, qfalse, qfalse, 0, GL_CLAMP, GL_CLAMP);
tr.dlightImages[i]->r_sequence = -1;
}
tr.identityLightImage = R_CreateImage("*identityLight", (byte *)data, 8, 8, 0, 1, qfalse, qfalse, qfalse, qfalse, GL_REPEAT, GL_REPEAT);
tr.identityLightImage->r_sequence = -1;
tr.scratchImage = R_CreateImage("*scratch", (byte*)data, DEFAULT_SIZE, DEFAULT_SIZE, 0, 1, qtrue, qfalse, qfalse, qfalse, GL_CLAMP, GL_CLAMP);
tr.scratchImage->r_sequence = -1;
R_CreateDlightImage();
}
@@ -2182,7 +2194,6 @@ void R_SetColorMappings( void ) {
tr.identityLight = 1.0f / (1 << tr.overbrightBits);
tr.identityLightByte = 255 * tr.identityLight;
if ( r_intensity->value <= 1 ) {
ri.Cvar_Set( "r_intensity", "1" );
}
@@ -2194,6 +2205,15 @@ void R_SetColorMappings( void ) {
}
g = r_gamma->value;
if (!glConfig.deviceSupportsGamma && g != 1.0) {
tr.needsLightScale = qtrue;
}
else if (r_intensity->value != 1.0) {
tr.needsLightScale = qtrue;
}
else {
tr.needsLightScale = qfalse;
}
shift = tr.overbrightBits;
@@ -2234,6 +2254,10 @@ R_InitImages
*/
void R_InitImages( void ) {
Com_Memset(hashTable, 0, sizeof(hashTable));
// clear images
Com_Memset(tr.images, 0, sizeof(tr.images));
tr.numImages = 0;
// build brightness translation tables
R_SetColorMappings();
+1 -1
View File
@@ -1016,7 +1016,7 @@ void R_Register( void )
#else
r_smp = ri.Cvar_Get( "r_smp", "0", CVAR_ARCHIVE | CVAR_LATCH);
#endif
r_ignoreFastPath = ri.Cvar_Get("r_ignoreFastPath", "1", CVAR_ARCHIVE | CVAR_LATCH);
r_ignoreFastPath = ri.Cvar_Get("r_ignoreFastPath", "0", CVAR_ARCHIVE | CVAR_LATCH);
r_subdivisions = ri.Cvar_Get("r_subdivisions", "4", CVAR_ARCHIVE | CVAR_LATCH);
//
+208 -246
View File
@@ -47,6 +47,8 @@ typedef struct {
dlightInfo_t dli;
void R_SetupEntityLightingGrid(trRefEntity_t* ent);
/*
===============
R_TransformDlights
@@ -126,12 +128,17 @@ static byte* R_GetLightGridPalettedColor(int iColor)
// FIXME: unimplemented
}
void R_GetLightingGridValue(vec3_t vPos, vec3_t vLight)
void R_GetLightingGridValue(const vec3_t vPos, vec3_t vLight)
{
if (!tr.world || !tr.world->lightGridData || !tr.world->lightGridOffsets) {
vLight[0] = vLight[1] = vLight[2] = tr.identityLightByte;
}
vLight[0] = vLight[1] = vLight[2] = tr.identityLightByte;
// FIXME: unimplemented
}
void R_GetLightingGridValueFast(vec3_t vPos, vec3_t vLight)
void R_GetLightingGridValueFast(const vec3_t vPos, vec3_t vLight)
{
// FIXME: unimplemented
}
@@ -146,6 +153,205 @@ void R_GetLightingForSmoke(vec3_t vLight, vec3_t vOrigin)
// FIXME: unimplemented
}
static int RB_GetEntityGridLighting()
{
int iColor;
int i;
dlight_t* dl;
float power;
vec3_t vLight;
vec3_t dir;
float d;
float* lightOrigin;
lightOrigin = backEnd.currentSphere->traceOrigin;
if (!(backEnd.refdef.rdflags & RDF_NOWORLDMODEL) && tr.world->lightGridData) {
R_GetLightingGridValue(backEnd.currentSphere->traceOrigin, vLight);
} else {
vLight[0] = vLight[1] = vLight[2] = tr.identityLight * 150.0;
}
for (i = 0; i < backEnd.refdef.num_dlights; i++) {
dl = &backEnd.refdef.dlights[i];
VectorSubtract(dl->origin, lightOrigin, dir);
d = VectorLengthSquared(dir);
power = dl->radius * dl->radius;
if (power >= d) {
d = dl->radius * 7500.0 / d;
VectorMA(vLight, d, dl->color, vLight);
}
}
if (tr.overbrightShift)
{
vLight[0] = tr.overbrightMult * vLight[0];
vLight[1] = tr.overbrightMult * vLight[1];
vLight[2] = tr.overbrightMult * vLight[2];
}
// normalize
if (vLight[0] < 255.0 || vLight[1] < 255.0 || vLight[2] < 255.0) {
float scale = 255.0 / fmin(vLight[0], fmin(vLight[1], vLight[2]));
VectorScale(vLight, scale, vLight);
}
// clamp ambient
for (i = 0; i < 3; i++) {
if (vLight[i] > tr.identityLightByte) {
vLight[i] = tr.identityLightByte;
}
}
// save out the byte packet version
((byte*)&iColor)[0] = myftol(vLight[0]);
((byte*)&iColor)[1] = myftol(vLight[1]);
((byte*)&iColor)[2] = myftol(vLight[2]);
((byte*)&iColor)[3] = 0xff;
return iColor;
#if 0
int i;
dlight_t* dl;
float power;
vec3_t dir;
float d;
vec3_t lightDir;
vec3_t lightOrigin;
int ambientlightInt = 0;
trRefEntity_t *ent = backEnd.currentEntity;
trRefdef_t *refdef = &backEnd.refdef;
//
// trace a sample point down to find ambient light
//
if (ent->e.renderfx & RF_LIGHTING_ORIGIN) {
// seperate lightOrigins are needed so an object that is
// sinking into the ground can still be lit, and so
// multi-part models can be lit identically
VectorCopy(ent->e.lightingOrigin, lightOrigin);
}
else {
VectorCopy(ent->e.origin, lightOrigin);
}
// if NOWORLDMODEL, only use dynamic lights (menu system, etc)
if (!(refdef->rdflags & RDF_NOWORLDMODEL)
&& tr.world->lightGridData) {
R_SetupEntityLightingGrid(ent);
}
else {
ent->ambientLight[0] = ent->ambientLight[1] =
ent->ambientLight[2] = tr.identityLight * 150;
ent->directedLight[0] = ent->directedLight[1] =
ent->directedLight[2] = tr.identityLight * 150;
VectorCopy(tr.sunDirection, ent->lightDir);
}
// bonus items and view weapons have a fixed minimum add
if (1 /* ent->e.renderfx & RF_MINLIGHT */) {
// give everything a minimum light add
ent->ambientLight[0] += tr.identityLight * 32;
ent->ambientLight[1] += tr.identityLight * 32;
ent->ambientLight[2] += tr.identityLight * 32;
}
//
// modify the light by dynamic lights
//
d = VectorLength(ent->directedLight);
VectorScale(ent->lightDir, d, lightDir);
for (i = 0; i < refdef->num_dlights; i++) {
dl = &refdef->dlights[i];
VectorSubtract(dl->origin, lightOrigin, dir);
d = VectorNormalize(dir);
power = DLIGHT_AT_RADIUS * (dl->radius * dl->radius);
if (d < DLIGHT_MINIMUM_RADIUS) {
d = DLIGHT_MINIMUM_RADIUS;
}
d = power / (d * d);
VectorMA(ent->directedLight, d, dl->color, ent->directedLight);
VectorMA(lightDir, d, dir, lightDir);
}
// clamp ambient
for (i = 0; i < 3; i++) {
if (ent->ambientLight[i] > tr.identityLightByte) {
ent->ambientLight[i] = tr.identityLightByte;
}
}
// save out the byte packet version
((byte*)&ambientlightInt)[0] = myftol(ent->ambientLight[0]);
((byte*)&ambientlightInt)[1] = myftol(ent->ambientLight[1]);
((byte*)&ambientlightInt)[2] = myftol(ent->ambientLight[2]);
((byte*)&ambientlightInt)[3] = 0xff;
// transform the direction to local space
VectorNormalize(lightDir);
ent->lightDir[0] = DotProduct(lightDir, ent->e.axis[0]);
ent->lightDir[1] = DotProduct(lightDir, ent->e.axis[1]);
ent->lightDir[2] = DotProduct(lightDir, ent->e.axis[2]);
return ambientlightInt;
#endif
// FIXME: unimplemented
}
void RB_SetupEntityGridLighting()
{
trRefEntity_t* ent;
int iColor;
if (backEnd.currentEntity->bLightGridCalculated) {
return;
}
for (ent = backEnd.currentEntity; ent->e.parentEntity != ENTITYNUM_NONE; ent = &backEnd.refdef.entities[ent->e.parentEntity])
{
trRefEntity_t* newref = &backEnd.refdef.entities[ent->e.parentEntity];
if (newref == ent) {
assert(!"backEnd.refdef.entities[ent->e.parentEntity] refers to itself\n");
iColor = newref->iGridLighting;
break;
}
if (newref->bLightGridCalculated) {
iColor = newref->iGridLighting;
break;
}
}
if (ent->e.parentEntity == ENTITYNUM_NONE) {
iColor = RB_GetEntityGridLighting();
}
ent = backEnd.currentEntity;
for (;;)
{
ent->bLightGridCalculated = 1;
ent->iGridLighting = iColor;
if (ent->e.parentEntity == ENTITYNUM_NONE) {
break;
}
if (ent == &backEnd.refdef.entities[ent->e.parentEntity]) {
assert(!"backEnd.refdef.entities[ent->e.parentEntity] refers to itself\n");
break;
}
ent = &backEnd.refdef.entities[ent->e.parentEntity];
}
}
void RB_SetupStaticModelGridLighting(trRefdef_t* refdef, cStaticModelUnpacked_t* ent, const vec3_t lightOrigin)
{
// FIXME: unimplemented
}
/*
=============================================================================
@@ -158,131 +364,6 @@ LIGHT SAMPLING
extern cvar_t *r_ambientScale;
extern cvar_t *r_directedScale;
/*
=================
R_SetupEntityLightingGrid
=================
*/
static void R_SetupEntityLightingGrid( trRefEntity_t *ent ) {
vec3_t lightOrigin;
int pos[3];
int i, j;
byte *gridData;
float frac[3];
int gridStep[3];
vec3_t direction;
float totalFactor;
if ( ent->e.renderfx & RF_LIGHTING_ORIGIN ) {
// seperate lightOrigins are needed so an object that is
// sinking into the ground can still be lit, and so
// multi-part models can be lit identically
VectorCopy( ent->e.lightingOrigin, lightOrigin );
} else {
VectorCopy( ent->e.origin, lightOrigin );
}
VectorSubtract( lightOrigin, tr.world->lightGridOrigin, lightOrigin );
for ( i = 0 ; i < 3 ; i++ ) {
float v;
v = lightOrigin[i]*tr.world->lightGridInverseSize[i];
pos[i] = floor( v );
frac[i] = v - pos[i];
if ( pos[i] < 0 ) {
pos[i] = 0;
} else if ( pos[i] >= tr.world->lightGridBounds[i] - 1 ) {
pos[i] = tr.world->lightGridBounds[i] - 1;
}
}
VectorClear( ent->ambientLight );
VectorClear( ent->directedLight );
VectorClear( direction );
assert( tr.world->lightGridData ); // bk010103 - NULL with -nolight maps
// trilerp the light value
gridStep[0] = 8;
gridStep[1] = 8 * tr.world->lightGridBounds[0];
gridStep[2] = 8 * tr.world->lightGridBounds[0] * tr.world->lightGridBounds[1];
gridData = tr.world->lightGridData + pos[0] * gridStep[0]
+ pos[1] * gridStep[1] + pos[2] * gridStep[2];
totalFactor = 0;
for ( i = 0 ; i < 8 ; i++ ) {
float factor;
byte *data;
int lat, lng;
vec3_t normal;
#if idppc
float d0, d1, d2, d3, d4, d5;
#endif
factor = 1.0;
data = gridData;
for ( j = 0 ; j < 3 ; j++ ) {
if ( i & (1<<j) ) {
factor *= frac[j];
data += gridStep[j];
} else {
factor *= (1.0f - frac[j]);
}
}
if ( !(data[0]+data[1]+data[2]) ) {
continue; // ignore samples in walls
}
totalFactor += factor;
#if idppc
d0 = data[0]; d1 = data[1]; d2 = data[2];
d3 = data[3]; d4 = data[4]; d5 = data[5];
ent->ambientLight[0] += factor * d0;
ent->ambientLight[1] += factor * d1;
ent->ambientLight[2] += factor * d2;
ent->directedLight[0] += factor * d3;
ent->directedLight[1] += factor * d4;
ent->directedLight[2] += factor * d5;
#else
ent->ambientLight[0] += factor * data[0];
ent->ambientLight[1] += factor * data[1];
ent->ambientLight[2] += factor * data[2];
ent->directedLight[0] += factor * data[3];
ent->directedLight[1] += factor * data[4];
ent->directedLight[2] += factor * data[5];
#endif
lat = data[7];
lng = data[6];
lat *= (FUNCTABLE_SIZE/256);
lng *= (FUNCTABLE_SIZE/256);
// decode X as cos( lat ) * sin( long )
// decode Y as sin( lat ) * sin( long )
// decode Z as cos( long )
normal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];
normal[1] = tr.sinTable[lat] * tr.sinTable[lng];
normal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];
VectorMA( direction, factor, normal, direction );
}
if ( totalFactor > 0 && totalFactor < 0.99 ) {
totalFactor = 1.0f / totalFactor;
VectorScale( ent->ambientLight, totalFactor, ent->ambientLight );
VectorScale( ent->directedLight, totalFactor, ent->directedLight );
}
VectorScale( ent->ambientLight, r_ambientScale->value, ent->ambientLight );
VectorScale( ent->directedLight, r_directedScale->value, ent->directedLight );
VectorNormalize2( direction, ent->lightDir );
}
/*
===============
LogLight
@@ -312,125 +393,6 @@ static void LogLight( trRefEntity_t *ent ) {
ri.Printf( PRINT_ALL, "amb:%i dir:%i\n", max1, max2 );
}
/*
=================
R_SetupEntityLighting
Calculates all the lighting values that will be used
by the Calc_* functions
=================
*/
void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) {
int i;
dlight_t *dl;
float power;
vec3_t dir;
float d;
vec3_t lightDir;
vec3_t lightOrigin;
// lighting calculations
if ( ent->bLightGridCalculated ) {
return;
}
ent->bLightGridCalculated = qtrue;
//
// trace a sample point down to find ambient light
//
if ( ent->e.renderfx & RF_LIGHTING_ORIGIN ) {
// seperate lightOrigins are needed so an object that is
// sinking into the ground can still be lit, and so
// multi-part models can be lit identically
VectorCopy( ent->e.lightingOrigin, lightOrigin );
} else {
VectorCopy( ent->e.origin, lightOrigin );
}
// if NOWORLDMODEL, only use dynamic lights (menu system, etc)
if ( !(refdef->rdflags & RDF_NOWORLDMODEL )
&& tr.world->lightGridData ) {
R_SetupEntityLightingGrid( ent );
} else {
ent->ambientLight[0] = ent->ambientLight[1] =
ent->ambientLight[2] = tr.identityLight * 150;
ent->directedLight[0] = ent->directedLight[1] =
ent->directedLight[2] = tr.identityLight * 150;
VectorCopy( tr.sunDirection, ent->lightDir );
}
// bonus items and view weapons have a fixed minimum add
if ( 1 /* ent->e.renderfx & RF_MINLIGHT */ ) {
// give everything a minimum light add
ent->ambientLight[0] += tr.identityLight * 32;
ent->ambientLight[1] += tr.identityLight * 32;
ent->ambientLight[2] += tr.identityLight * 32;
}
//
// modify the light by dynamic lights
//
d = VectorLength( ent->directedLight );
VectorScale( ent->lightDir, d, lightDir );
for ( i = 0 ; i < refdef->num_dlights ; i++ ) {
dl = &refdef->dlights[i];
VectorSubtract( dl->origin, lightOrigin, dir );
d = VectorNormalize( dir );
power = DLIGHT_AT_RADIUS * ( dl->radius * dl->radius );
if ( d < DLIGHT_MINIMUM_RADIUS ) {
d = DLIGHT_MINIMUM_RADIUS;
}
d = power / ( d * d );
VectorMA( ent->directedLight, d, dl->color, ent->directedLight );
VectorMA( lightDir, d, dir, lightDir );
}
// clamp ambient
for ( i = 0 ; i < 3 ; i++ ) {
if ( ent->ambientLight[i] > tr.identityLightByte ) {
ent->ambientLight[i] = tr.identityLightByte;
}
}
// save out the byte packet version
((byte *)&ent->ambientLightInt)[0] = myftol( ent->ambientLight[0] );
((byte *)&ent->ambientLightInt)[1] = myftol( ent->ambientLight[1] );
((byte *)&ent->ambientLightInt)[2] = myftol( ent->ambientLight[2] );
((byte *)&ent->ambientLightInt)[3] = 0xff;
// transform the direction to local space
VectorNormalize( lightDir );
ent->lightDir[0] = DotProduct( lightDir, ent->e.axis[0] );
ent->lightDir[1] = DotProduct( lightDir, ent->e.axis[1] );
ent->lightDir[2] = DotProduct( lightDir, ent->e.axis[2] );
}
/*
=================
R_LightForPoint
=================
*/
int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir )
{
trRefEntity_t ent;
// bk010103 - this segfaults with -nolight maps
if ( tr.world->lightGridData == NULL )
return qfalse;
Com_Memset(&ent, 0, sizeof(ent));
VectorCopy( point, ent.e.origin );
R_SetupEntityLightingGrid( &ent );
VectorCopy(ent.ambientLight, ambientLight);
VectorCopy(ent.directedLight, directedLight);
VectorCopy(ent.lightDir, lightDir);
return qtrue;
}
void R_ClearRealDlights() {
memset(dli.allocated, 0, sizeof(dli.allocated));
dli.dlightMap = 0;
+19 -12
View File
@@ -1050,13 +1050,11 @@ typedef struct {
int nummarksurfaces;
msurface_t **marksurfaces;
int numfogs;
fog_t *fogs;
vec3_t lightGridOrigin;
vec3_t lightGridMins;
vec3_t lightGridSize;
vec3_t lightGridInverseSize;
vec3_t lightGridOOSize;
int lightGridBounds[3];
unsigned short* lightGridOffsets;
byte *lightGridData;
byte lightGridPalette[768];
@@ -1259,7 +1257,7 @@ typedef struct {
const byte *externalVisData; // from RE_SetWorldVisData, shared with CM_Load
image_t *defaultImage;
image_t *scratchImage[32];
image_t *scratchImage;
image_t *fogImage;
image_t *dlightImage; // inverse-quare highlight for projective adding
image_t *flareImage;
@@ -1822,8 +1820,8 @@ void RB_CheckOverflow( int verts, int indexes );
void RB_StageIteratorGeneric( void );
void RB_StageIteratorSky( void );
void RB_StageIteratorVertexLitTexture( void );
void RB_StageIteratorLightmappedMultitexture( void );
void RB_StageIteratorVertexLitTextureUnfogged( void );
void RB_StageIteratorLightmappedMultitextureUnfogged( void );
void RB_AddQuadStamp( vec3_t origin, vec3_t left, vec3_t up, byte *color );
void RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, byte *color, float s1, float t1, float s2, float t2 );
@@ -1844,6 +1842,7 @@ extern terrainVert_t* g_pVert;
void R_AddBrushModelSurfaces( trRefEntity_t *e );
void R_GetInlineModelBounds(int iIndex, vec3_t vMins, vec3_t vMaxs);
int R_SphereInLeafs(vec_t* p, float r, mnode_t** nodes, int nMaxNodes);
mnode_t* R_PointInLeaf(const vec3_t p);
int R_DlightTerrain(cTerraPatchUnpacked_t* surf, int dlightBits);
int R_CheckDlightTerrain(cTerraPatchUnpacked_t* surf, int dlightBits);
@@ -1874,17 +1873,18 @@ LIGHTS
*/
void R_DlightBmodel( bmodel_t *bmodel );
void R_GetLightingGridValue(const vec3_t vPos, vec3_t vLight);
void R_GetLightingForDecal(vec3_t vLight, vec3_t vFacing, vec3_t vOrigin);
void R_GetLightingForSmoke(vec3_t vLight, vec3_t vOrigin);
void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent );
void RB_SetupEntityGridLighting();
void R_TransformDlights( int count, dlight_t *dl, orientationr_t *ori );
int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );
void RB_Light_Real(const color4ub_t colors);
void RB_Light_Real(unsigned char* colors);
void RB_Sphere_BuildDLights();
void RB_Sphere_SetupEntity();
void RB_Grid_SetupEntity();
void RB_Grid_SetupStaticModel();
void RB_Light_Fullbright(const color4ub_t colors);
void RB_Light_Fullbright(unsigned char* colors);
void R_Sphere_InitLights();
int R_GatherLightSources(const vec3_t vPos, vec3_t* pvLightPos, vec3_t* pvLightIntensity, int iMaxLights);
void R_UploadDlights();
@@ -2134,7 +2134,6 @@ void R_TransformClipToWindow( const vec4_t clip, const viewParms_t *view, vec4_t
void RB_DeformTessGeometry( void );
void RB_CalcEnvironmentTexCoords( float *dstTexCoords );
void RB_CalcFogTexCoords( float *dstTexCoords );
void RB_CalcScrollTexCoords( const float scroll[2], float *dstTexCoords );
void RB_CalcRotateTexCoords( float rotSpeed, float *dstTexCoords );
void RB_CalcScaleTexCoords( const float scale[2], float *dstTexCoords );
@@ -2182,6 +2181,14 @@ RENDERER BACK END COMMAND QUEUE
#define MAX_RENDER_COMMANDS 0x40000
typedef struct suninfo_s {
vec3_t color;
vec3_t direction;
vec3_t flaredirection;
char szFlareName[64];
qboolean exists;
} suninfo_t;
typedef struct {
byte cmds[MAX_RENDER_COMMANDS];
int used;
-33
View File
@@ -1094,39 +1094,6 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) {
return qtrue;
}
/*
=================
R_SpriteFogNum
See if a sprite is inside a fog volume
=================
*/
int R_SpriteFogNum( trRefEntity_t *ent ) {
int i, j;
fog_t *fog;
if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) {
return 0;
}
for ( i = 1 ; i < tr.world->numfogs ; i++ ) {
fog = &tr.world->fogs[i];
for ( j = 0 ; j < 3 ; j++ ) {
if ( ent->e.origin[j] - ent->e.radius >= fog->bounds[1][j] ) {
break;
}
if ( ent->e.origin[j] + ent->e.radius <= fog->bounds[0][j] ) {
break;
}
}
if ( j == 3 ) {
return i;
}
}
return 0;
}
/*
==========================================================================================
-7
View File
@@ -871,13 +871,6 @@ void R_AddSkelSurfaces( trRefEntity_t *ent ) {
ent->e.hasMorph = qtrue;
}
//
// set up lighting now that we know we aren't culled
//
if( !personalModel || r_shadows->integer > 1 ) {
R_SetupEntityLighting( &tr.refdef, ent );
}
//
// draw all meshes
//
+13 -61
View File
@@ -682,43 +682,6 @@ static void ProjectDlightTexture( void ) {
}
}
/*
===================
RB_FogPass
Blends a fog texture on top of everything else
===================
*/
static void RB_FogPass( void ) {
fog_t *fog;
int i;
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, tess.svars.colors );
qglEnableClientState( GL_TEXTURE_COORD_ARRAY);
qglTexCoordPointer( 2, GL_FLOAT, 0, tess.svars.texcoords[0] );
fog = tr.world->fogs + tess.fogNum;
for ( i = 0; i < tess.numVertexes; i++ ) {
* ( int * )&tess.svars.colors[i] = fog->colorInt;
}
RB_CalcFogTexCoords( ( float * ) tess.svars.texcoords[0] );
GL_Bind( tr.fogImage );
if ( tess.shader->fogPass == FP_EQUAL ) {
GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL );
} else {
GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
}
R_DrawElements( tess.numIndexes, tess.indexes );
}
/*
===============
ComputeColors
@@ -875,7 +838,7 @@ static void ComputeColors( shaderStage_t *pStage )
{
float t;
t = 255.0 / (float)max(r, max(g, b));
t = 255.0 / (float)Q_max(r, Q_max(g, b));
r = (int)((float)r * t);
g = (int)((float)g * t);
@@ -1113,9 +1076,6 @@ static void ComputeTexCoords( shaderStage_t *pStage ) {
tess.svars.texcoords[b][i][1] = DotProduct( tess.xyz[i], pStage->bundle[b].tcGenVectors[1] );
}
break;
case TCGEN_FOG:
RB_CalcFogTexCoords( ( float * ) tess.svars.texcoords[b] );
break;
case TCGEN_ENVIRONMENT_MAPPED:
RB_CalcEnvironmentTexCoords( ( float * ) tess.svars.texcoords[b] );
break;
@@ -1373,7 +1333,7 @@ void RB_StageIteratorGeneric( void )
/*
** RB_StageIteratorVertexLitTexture
*/
void RB_StageIteratorVertexLitTexture( void )
void RB_StageIteratorVertexLitTextureUnfogged( void )
{
shaderCommands_t *input;
shader_t *shader;
@@ -1382,10 +1342,16 @@ void RB_StageIteratorVertexLitTexture( void )
shader = input->shader;
//
// compute colors
//
RB_CalcDiffuseColor( ( unsigned char * ) tess.svars.colors );
if (backEnd.currentSphere->TessFunction && r_drawspherelights->integer) {
backEnd.currentSphere->TessFunction((unsigned char*)tess.svars.colors);
}
else
{
//
// compute colors
//
RB_CalcLightGridColor((unsigned char*)tess.svars.colors);
}
//
// log this call
@@ -1432,13 +1398,6 @@ void RB_StageIteratorVertexLitTexture( void )
ProjectDlightTexture();
}
//
// now do fog
//
if ( tess.fogNum && tess.shader->fogPass ) {
RB_FogPass();
}
//
// unlock arrays
//
@@ -1451,7 +1410,7 @@ void RB_StageIteratorVertexLitTexture( void )
//define REPLACE_MODE
void RB_StageIteratorLightmappedMultitexture( void ) {
void RB_StageIteratorLightmappedMultitextureUnfogged( void ) {
shaderCommands_t *input;
input = &tess;
@@ -1537,13 +1496,6 @@ void RB_StageIteratorLightmappedMultitexture( void ) {
ProjectDlightTexture();
}
//
// now do fog
//
if ( tess.fogNum && tess.shader->fogPass ) {
RB_FogPass();
}
//
// unlock arrays
//
+30 -90
View File
@@ -801,95 +801,6 @@ TEX COORDS
====================================================================
*/
/*
========================
RB_CalcFogTexCoords
To do the clipped fog plane really correctly, we should use
projected textures, but I don't trust the drivers and it
doesn't fit our shader data.
========================
*/
void RB_CalcFogTexCoords( float *st ) {
int i;
float *v;
float s, t;
float eyeT;
qboolean eyeOutside;
fog_t *fog;
vec3_t local;
vec4_t fogDistanceVector, fogDepthVector;
fog = tr.world->fogs + tess.fogNum;
// all fogging distance is based on world Z units
VectorSubtract( backEnd.ori.origin, backEnd.viewParms.ori.origin, local );
fogDistanceVector[0] = -backEnd.ori.modelMatrix[2];
fogDistanceVector[1] = -backEnd.ori.modelMatrix[6];
fogDistanceVector[2] = -backEnd.ori.modelMatrix[10];
fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.ori.axis[0] );
// scale the fog vectors based on the fog's thickness
fogDistanceVector[0] *= fog->tcScale;
fogDistanceVector[1] *= fog->tcScale;
fogDistanceVector[2] *= fog->tcScale;
fogDistanceVector[3] *= fog->tcScale;
// rotate the gradient vector for this orientation
if ( fog->hasSurface ) {
fogDepthVector[0] = fog->surface[0] * backEnd.ori.axis[0][0] +
fog->surface[1] * backEnd.ori.axis[0][1] + fog->surface[2] * backEnd.ori.axis[0][2];
fogDepthVector[1] = fog->surface[0] * backEnd.ori.axis[1][0] +
fog->surface[1] * backEnd.ori.axis[1][1] + fog->surface[2] * backEnd.ori.axis[1][2];
fogDepthVector[2] = fog->surface[0] * backEnd.ori.axis[2][0] +
fog->surface[1] * backEnd.ori.axis[2][1] + fog->surface[2] * backEnd.ori.axis[2][2];
fogDepthVector[3] = -fog->surface[3] + DotProduct( backEnd.ori.origin, fog->surface );
eyeT = DotProduct( backEnd.ori.viewOrigin, fogDepthVector ) + fogDepthVector[3];
} else {
eyeT = 1; // non-surface fog always has eye inside
}
// see if the viewpoint is outside
// this is needed for clipping distance even for constant fog
if ( eyeT < 0 ) {
eyeOutside = qtrue;
} else {
eyeOutside = qfalse;
}
fogDistanceVector[3] += 1.0/512;
// calculate density for each point
for (i = 0, v = tess.xyz[0] ; i < tess.numVertexes ; i++, v += 4) {
// calculate the length in fog
s = DotProduct( v, fogDistanceVector ) + fogDistanceVector[3];
t = DotProduct( v, fogDepthVector ) + fogDepthVector[3];
// partially clipped fogs use the T axis
if ( eyeOutside ) {
if ( t < 1.0 ) {
t = 1.0/32; // point is outside, so no fogging
} else {
t = 1.0/32 + 30.0/32 * t / ( t - eyeT ); // cut the distance at the fog plane
}
} else {
if ( t < 0 ) {
t = 1.0/32; // point is outside, so no fogging
} else {
t = 31.0/32;
}
}
st[0] = s;
st[1] = t;
st += 2;
}
}
/*
** RB_CalcEnvironmentTexCoords
*/
@@ -1099,7 +1010,36 @@ void RB_CalcSpecularAlpha(unsigned char* alphas, float alphaMax, vec3_t lightOri
void RB_CalcLightGridColor(unsigned char* colors)
{
// FIXME/ unimplemented
int i;
if (!backEnd.currentEntity) {
for (i = 0; i < tess.numVertexes; i++) {
colors[i * 4] = backEnd.currentStaticModel->iGridLighting;
colors[i * 4 + 1] = backEnd.currentStaticModel->iGridLighting;
colors[i * 4 + 2] = backEnd.currentStaticModel->iGridLighting;
colors[i * 4 + 3] = backEnd.currentStaticModel->iGridLighting;
}
}
else if (backEnd.currentEntity != &tr.worldEntity) {
for (i = 0; i < tess.numVertexes; i++) {
colors[i * 4] = backEnd.currentEntity->iGridLighting;
colors[i * 4 + 1] = backEnd.currentEntity->iGridLighting;
colors[i * 4 + 2] = backEnd.currentEntity->iGridLighting;
colors[i * 4 + 3] = backEnd.currentEntity->iGridLighting;
}
}
else {
Com_Printf(
"##### shader '%s' incorrectly uses rgbGen lightingGrid or lightingSpherical; was rgbGen vertex intended?\n",
tess.shader->name);
for (i = 0; i < tess.numVertexes; i++) {
colors[i * 4] = 0xFF;
colors[i * 4 + 1] = 0xFF;
colors[i * 4 + 2] = 0xFF;
colors[i * 4 + 3] = 0xFF;
}
}
}
void RB_CalcAlphaFromDotView(unsigned char* colors, float alphaMin, float alphaMax)
+230 -101
View File
@@ -625,7 +625,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage, int cntBundle )
}
else
{
ri.Printf( PRINT_WARNING, "WARNING: unknown tcMod '%s' in shader '%s'\n", token, shader.name );
ri.Printf(PRINT_WARNING, "WARNING: unknown tcMod '%s' in shader '%s'\n", token, shader.name);
}
}
@@ -635,9 +635,9 @@ static void ParseTexMod( char *_text, shaderStage_t *stage, int cntBundle )
ParseStage
===================
*/
static qboolean ParseStage( shaderStage_t *stage, char **text )
static qboolean ParseStage(shaderStage_t* stage, char** text)
{
char *token;
char* token;
int depthMaskBits = GLS_DEPTHMASK_TRUE, blendSrcBits = 0, blendDstBits = 0, atestBits = 0, depthFuncBits = 0;
qboolean depthMaskExplicit = qfalse;
int cntBundle = 0;
@@ -649,33 +649,33 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
stage->noPicMip = shader_noPicMip;
stage->force32bit = shader_force32bit;
while ( 1 )
while (1)
{
token = COM_ParseExt( text, qtrue );
if ( !token[0] )
token = COM_ParseExt(text, qtrue);
if (!token[0])
{
ri.Printf( PRINT_WARNING, "WARNING: no matching '}' found\n" );
ri.Printf(PRINT_WARNING, "WARNING: no matching '}' found\n");
return qfalse;
}
if ( token[0] == '}' )
if (token[0] == '}')
{
break;
}
// no picmip adjustment
else if ( !Q_stricmp( token, "nomipmaps" ) )
else if (!Q_stricmp(token, "nomipmaps"))
{
stage->noMipMaps = qtrue;
continue;
}
// no picmip adjustment
else if ( !Q_stricmp( token, "nopicmip" ) )
else if (!Q_stricmp(token, "nopicmip"))
{
stage->noPicMip = qtrue;
continue;
}
// no picmip adjustment
else if ( !Q_stricmp( token, "nofog" ) )
else if (!Q_stricmp(token, "nofog"))
{
fogBits = GLS_FOG;
continue;
@@ -683,36 +683,37 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
//
// map <name>
//
else if ( !Q_stricmp( token, "map" ) )
else if (!Q_stricmp(token, "map"))
{
token = COM_ParseExt( text, qfalse );
if ( !token[0] )
token = COM_ParseExt(text, qfalse);
if (!token[0])
{
ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'map' keyword in shader '%s'\n", shader.name );
ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'map' keyword in shader '%s'\n", shader.name);
return qfalse;
}
if ( !Q_stricmp( token, "$whiteimage" ) )
if (!Q_stricmp(token, "$whiteimage"))
{
stage->bundle[cntBundle].image[0] = tr.whiteImage;
continue;
}
else if ( !Q_stricmp( token, "$lightmap" ) )
else if (!Q_stricmp(token, "$lightmap"))
{
stage->bundle[cntBundle].isLightmap = qtrue;
if ( shader.lightmapIndex < 0 ) {
if (shader.lightmapIndex < 0) {
stage->bundle[cntBundle].image[0] = tr.whiteImage;
} else {
}
else {
stage->bundle[cntBundle].image[0] = tr.lightmaps[shader.lightmapIndex];
}
continue;
}
else
{
stage->bundle[cntBundle].image[0] = R_FindImageFile( token, !stage->noMipMaps, !stage->noPicMip, qfalse, GL_REPEAT, GL_REPEAT );
if ( !stage->bundle[cntBundle].image[0] )
stage->bundle[cntBundle].image[0] = R_FindImageFile(token, !stage->noMipMaps, !stage->noPicMip, qfalse, GL_REPEAT, GL_REPEAT);
if (!stage->bundle[cntBundle].image[0])
{
ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name );
ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name);
return qfalse;
}
}
@@ -720,19 +721,58 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
//
// clampmap <name>
//
else if ( !Q_stricmp( token, "clampmap" ) )
else if (!Q_stricmpn(token, "clampmap", 8))
{
token = COM_ParseExt( text, qfalse );
if ( !token[0] )
int clampx, clampy;
if (!token[8]) {
if (!r_forceClampToEdge->value) {
clampx = GL_CLAMP;
clampy = GL_CLAMP;
}
else {
clampx = GL_CLAMP_TO_EDGE;
clampy = GL_CLAMP_TO_EDGE;
}
}
else {
if (token[8] == 'x')
{
if (!r_forceClampToEdge->value) {
clampx = GL_CLAMP;
}
else {
clampx = GL_CLAMP_TO_EDGE;
}
clampy = GL_CLAMP;
}
else if (token[8] == 'y')
{
clampx = GL_CLAMP;
if (!r_forceClampToEdge->value) {
clampy = GL_CLAMP;
}
else {
clampy = GL_CLAMP_TO_EDGE;
}
}
else {
ri.Printf(PRINT_WARNING, "WARNING: Converting unknown clampmap type to clampmap\n");
continue;
}
}
token = COM_ParseExt(text, qfalse);
if (!token[0])
{
ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'clampmap' keyword in shader '%s'\n", shader.name );
ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'clampmap' keyword in shader '%s'\n", shader.name);
return qfalse;
}
stage->bundle[cntBundle].image[0] = R_FindImageFile(token, !stage->noMipMaps, !stage->noPicMip, qfalse, r_forceClampToEdge->value ? GL_CLAMP_TO_EDGE : GL_CLAMP, r_forceClampToEdge->value ? GL_CLAMP_TO_EDGE : GL_CLAMP);
if ( !stage->bundle[cntBundle].image[0] )
stage->bundle[cntBundle].image[0] = R_FindImageFile(token, !stage->noMipMaps, !stage->noPicMip, qfalse, clampx, clampy);
if (!stage->bundle[cntBundle].image[0])
{
ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name );
ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name);
return qfalse;
}
}
@@ -871,6 +911,60 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
ParseWaveForm( text, &stage->rgbWave );
stage->rgbGen = CGEN_WAVEFORM;
}
else if (!Q_stricmp(token, "colorwave"))
{
vec3_t v;
ParseVector(text, 3, v);
stage->colorConst[0] = v[0] * 255.0;
stage->colorConst[1] = v[1] * 255.0;
stage->colorConst[2] = v[2] * 255.0;
stage->rgbGen = CGEN_MULTIPLY_BY_WAVEFORM;
shader.flags |= 2;
}
else if (!Q_stricmp(token, "identity"))
{
stage->rgbGen = CGEN_IDENTITY;
}
else if (!Q_stricmp(token, "identityLighting"))
{
stage->rgbGen = CGEN_IDENTITY_LIGHTING;
}
else if (!Q_stricmp(token, "global"))
{
stage->rgbGen = CGEN_GLOBAL_COLOR;
}
else if (!Q_stricmp(token, "entity") || !Q_stricmp(token, "fromentity"))
{
stage->rgbGen = CGEN_ENTITY;
}
else if (!Q_stricmp(token, "oneMinusEntity"))
{
stage->rgbGen = CGEN_ONE_MINUS_ENTITY;
}
else if (!Q_stricmp(token, "vertex") || !Q_stricmp(token, "fromclient"))
{
stage->rgbGen = CGEN_VERTEX;
if (stage->alphaGen == 0) {
stage->alphaGen = AGEN_VERTEX;
}
}
else if (!Q_stricmp(token, "exactVertex"))
{
stage->rgbGen = CGEN_EXACT_VERTEX;
}
else if (!Q_stricmp(token, "lightingGrid"))
{
stage->rgbGen = CGEN_LIGHTING_GRID;
}
else if (!Q_stricmp(token, "lightingSpherical"))
{
stage->rgbGen = CGEN_LIGHTING_SPHERICAL;
}
else if (!Q_stricmp(token, "oneMinusVertex"))
{
stage->rgbGen = CGEN_ONE_MINUS_VERTEX;
}
else if ( !Q_stricmp( token, "const" ) || !Q_stricmp(token, "constant"))
{
vec3_t color;
@@ -882,44 +976,91 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
stage->rgbGen = CGEN_CONSTANT;
}
else if ( !Q_stricmp( token, "identity" ) )
else if (!Q_stricmp(token, "static"))
{
stage->rgbGen = CGEN_IDENTITY;
}
else if ( !Q_stricmp( token, "identityLighting" ) )
{
stage->rgbGen = CGEN_IDENTITY_LIGHTING;
}
else if ( !Q_stricmp( token, "entity" ) )
{
stage->rgbGen = CGEN_ENTITY;
}
else if ( !Q_stricmp( token, "oneMinusEntity" ) )
{
stage->rgbGen = CGEN_ONE_MINUS_ENTITY;
}
else if ( !Q_stricmp( token, "vertex" ) )
{
stage->rgbGen = CGEN_VERTEX;
if ( stage->alphaGen == 0 ) {
stage->rgbGen = CGEN_STATIC;
if (stage->alphaGen == AGEN_IDENTITY) {
stage->alphaGen = AGEN_VERTEX;
}
}
else if ( !Q_stricmp( token, "exactVertex" ) )
else if (!Q_stricmp(token, "sCoord") || !Q_stricmp(token, "tCoord"))
{
stage->rgbGen = CGEN_EXACT_VERTEX;
if (!Q_stricmp(token, "sCoord")) {
stage->rgbGen = CGEN_SCOORD;
}
else {
stage->rgbGen = CGEN_TCOORD;
}
stage->alphaMin = 0.0;
stage->alphaMax = 1.0;
stage->alphaConstMin = 0;
stage->alphaConst = -1;
token = COM_ParseExt(text, qfalse);
if (token[0] == 0) {
continue;
}
stage->alphaMin = atof(token);
token = COM_ParseExt(text, qfalse);
if (token[0] == 0) {
continue;
}
stage->alphaMax = atof(token);
token = COM_ParseExt(text, qfalse);
if (token[0] == 0) {
continue;
}
stage->alphaConstMin = atof(token) * 255.0;
token = COM_ParseExt(text, qfalse);
if (token[0] == 0) {
ri.Printf(PRINT_WARNING, "WARNING: missing rgbGen sCoord or tCoord parm 'max' in shader '%s'\n", shader.name);
continue;
}
stage->alphaConst = atof(token) * 255.0;
}
else if ( !Q_stricmp( token, "lightingGrid" ) )
else if (!Q_stricmp(token, "dot"))
{
stage->rgbGen = CGEN_LIGHTING_GRID;
}
else if ( !Q_stricmp( token, "lightingSpherical" ) )
stage->rgbGen = CGEN_DOT;
stage->alphaMin = 0.0;
stage->alphaMax = 1.0;
token = COM_ParseExt(text, qfalse);
if (token[0] == 0) {
continue;
}
stage->alphaMin = atof(token);
token = COM_ParseExt(text, qfalse);
if (token[0] == 0) {
continue;
}
stage->alphaMax = atof(token);
}
else if (!Q_stricmp(token, "oneminusdot"))
{
stage->rgbGen = CGEN_LIGHTING_SPHERICAL;
}
else if ( !Q_stricmp( token, "oneMinusVertex" ) )
{
stage->rgbGen = CGEN_ONE_MINUS_VERTEX;
stage->rgbGen = CGEN_ONE_MINUS_DOT;
stage->alphaMin = 0.0;
stage->alphaMax = 1.0;
token = COM_ParseExt(text, qfalse);
if (token[0] == 0) {
continue;
}
stage->alphaMin = atof(token);
token = COM_ParseExt(text, qfalse);
if (token[0] == 0) {
continue;
}
stage->alphaMax = atof(token);
}
else
{
@@ -1953,6 +2094,14 @@ static qboolean ParseShader( char **text )
return qfalse;
}
if (!(shader.flags & 2)) {
shader.flags &= ~1;
}
if ((shader.contentFlags & CONTENTS_FENCE) != 0 && shader.cullType == CT_TWO_SIDED) {
shader.cullType = CT_FRONT_SIDED;
}
shader.explicitlyDefined = qtrue;
return qtrue;
@@ -2009,7 +2158,7 @@ static void ComputeStageIteratorFunc( void )
{
if ( !shader.numDeforms )
{
shader.optimalStageIteratorFunc = RB_StageIteratorVertexLitTexture;
shader.optimalStageIteratorFunc = RB_StageIteratorVertexLitTextureUnfogged;
goto done;
}
}
@@ -2035,7 +2184,7 @@ static void ComputeStageIteratorFunc( void )
{
if (unfoggedStages[0].multitextureEnv )
{
shader.optimalStageIteratorFunc = RB_StageIteratorLightmappedMultitexture;
shader.optimalStageIteratorFunc = RB_StageIteratorLightmappedMultitextureUnfogged;
goto done;
}
}
@@ -2530,16 +2679,16 @@ static shader_t *FinishShader( void ) {
//
// default texture coordinate generation
//
for (bundle = 2; bundle > 0; bundle--) {
if (pStage->bundle[bundle - 1].isLightmap) {
if (pStage->bundle[bundle - 1].tcGen == TCGEN_BAD) {
pStage->bundle[bundle - 1].tcGen = TCGEN_LIGHTMAP;
for (bundle = 0; bundle < 2; bundle++) {
if (pStage->bundle[bundle].isLightmap) {
if (pStage->bundle[bundle].tcGen == TCGEN_BAD) {
pStage->bundle[bundle].tcGen = TCGEN_LIGHTMAP;
}
hasLightmapStage = qtrue;
}
else {
if (pStage->bundle[bundle - 1].tcGen == TCGEN_BAD) {
pStage->bundle[bundle - 1].tcGen = TCGEN_TEXTURE;
if (pStage->bundle[bundle].tcGen == TCGEN_BAD) {
pStage->bundle[bundle].tcGen = TCGEN_TEXTURE;
}
}
}
@@ -2552,31 +2701,6 @@ static shader_t *FinishShader( void ) {
pStage->bundle[0] = pStage->bundle[1];
pStage->bundle[1] = tmpBundle;
}
//
// determine sort order and fog color adjustment
//
if ( ( pStage->stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) &&
( unfoggedStages[0].stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) ) {
int blendSrcBits = pStage->stateBits & GLS_SRCBLEND_BITS;
int blendDstBits = pStage->stateBits & GLS_DSTBLEND_BITS;
// don't screw with sort order if this is a portal or environment
if ( !shader.sort ) {
// see through item, like a grill or grate
if ( pStage->stateBits & GLS_DEPTHMASK_TRUE ) {
shader.sort = SS_SEE_THROUGH;
} else {
shader.sort = SS_BLEND0;
}
}
}
}
// there are times when you will need to manually apply a sort to
// opaque alpha tested shaders that have later blend passes
if ( !shader.sort ) {
shader.sort = SS_OPAQUE;
}
//
@@ -2645,7 +2769,7 @@ static shader_t *FinishShader( void ) {
}
// fogonly shaders don't have any normal passes
if (shader.sort == SS_BAD) {
if (!shader.sort) {
shader.sort = SS_OPAQUE;
}
@@ -2735,17 +2859,22 @@ shader_t* R_FindShader(const char* name, int lightmapIndex, qboolean mipRawImage
// with that same strippedName a new default shader is created.
if (!Q_stricmp(currentShader->name, strippedName))
{
if (currentShader->shader && (currentShader->shader->lightmapIndex == lightmapIndex || currentShader->shader->defaultShader))
{
// match found
return currentShader->shader;
}
// shader text found, but it has no shared assigned
break;
}
}
if (!currentShader) {
if (currentShader)
{
for (sh = currentShader->shader; sh; sh = sh->next)
{
if (sh->lightmapIndex == lightmapIndex || sh == tr.defaultShader) {
return sh;
}
}
}
else
{
// create a new shader text
currentShader = AddShaderTextToHash(strippedName, hash);
}
@@ -3016,9 +3145,9 @@ void R_ShaderList_f (void) {
ri.Printf( PRINT_ALL, "gen " );
} else if ( shader->optimalStageIteratorFunc == RB_StageIteratorSky ) {
ri.Printf( PRINT_ALL, "sky " );
} else if ( shader->optimalStageIteratorFunc == RB_StageIteratorLightmappedMultitexture ) {
} else if ( shader->optimalStageIteratorFunc == RB_StageIteratorLightmappedMultitextureUnfogged ) {
ri.Printf( PRINT_ALL, "lmmt" );
} else if ( shader->optimalStageIteratorFunc == RB_StageIteratorVertexLitTexture ) {
} else if ( shader->optimalStageIteratorFunc == RB_StageIteratorVertexLitTextureUnfogged ) {
ri.Printf( PRINT_ALL, "vlt " );
} else {
ri.Printf( PRINT_ALL, " " );
+206 -7
View File
@@ -24,13 +24,40 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "tr_local.h"
vec3_t spheredef[6];
suninfo_t s_sun;
static vec3_t ambientlight;
static qboolean bEntityOverbright;
static int iEntityLightingMax;
static int light_reference_count = 0;
int compare_light_intensities(const void* p1, const void* p2)
{
return ((const reallightinfo_t*)p2)->fIntensity - ((const reallightinfo_t*)p1)->fIntensity;
}
static void RB_OptimizeLights()
{
// FIXME: unimplemented
}
static void RB_Light_CubeMap(const color4ub_t colors)
{
// FIXME: unimplemented
}
void RB_Light_Real(const color4ub_t colors)
void RB_Light_Real(unsigned char* colors)
{
int i, j;
float* normal;
float* xyz;
unsigned char* color;
vec3_t v;
vec3_t colorout;
float fDot;
reallightinfo_t* pLight;
// FIXME: unimplemented
}
@@ -42,16 +69,90 @@ static void RB_Sphere_Light_Sun()
static qboolean RB_Sphere_CalculateSphereOrigin()
{
// FIXME: unimplemented
return qfalse;
}
static bool RB_Sphere_SetupGlobals()
{
// FIXME: unimplemented
int i;
if (backEnd.refdef.rdflags & RDF_NOWORLDMODEL) {
if (!(backEnd.refdef.rdflags & RDF_FULLBRIGHT)) {
backEnd.currentSphere->TessFunction = &RB_Light_Fullbright;
return false;
}
}
else if (!(backEnd.refdef.rdflags & RDF_FULLBRIGHT)) {
if (!RB_Sphere_CalculateSphereOrigin()) {
backEnd.currentSphere->TessFunction = &RB_CalcLightGridColor;
if (!backEnd.currentEntity->bLightGridCalculated) {
RB_SetupEntityGridLighting();
}
return false;
}
}
else
{
if (backEnd.refdef.vieworg[0] == 0 && backEnd.refdef.vieworg[1] == 0 && backEnd.refdef.vieworg[2] == 0) {
backEnd.currentSphere->TessFunction = &RB_Light_Fullbright;
return false;
}
VectorCopy(backEnd.refdef.vieworg, backEnd.currentSphere->worldOrigin);
VectorClear(backEnd.currentSphere->origin);
backEnd.currentSphere->radius = 2.0;
}
light_reference_count++;
for (i = 0; i < 8; i++) {
backEnd.currentSphere->leaves[i] = 0;
}
R_SphereInLeafs(backEnd.currentSphere->worldOrigin, backEnd.currentSphere->radius, backEnd.currentSphere->leaves, 8);
backEnd.currentSphere->TessFunction = &RB_Light_Real;
return true;
}
static bool RB_Sphere_ResetPointColors()
{
// FIXME: unimplemented
vec3_t light_offset, amb;
R_GetLightingGridValue(backEnd.currentSphere->worldOrigin, light_offset);
light_offset[0] = ambientlight[0] + light_offset[0] * 0.18;
light_offset[1] = ambientlight[1] + light_offset[1] * 0.18;
light_offset[2] = ambientlight[2] + light_offset[2] * 0.18;
if (tr.refdef.rdflags & RDF_FULLBRIGHT)
{
float fMin = tr.identityLight * 20.0;
if (fMin <= light_offset[0] || fMin <= light_offset[1] || fMin <= light_offset[2]) {
light_offset[0] += fMin;
light_offset[1] += fMin;
light_offset[2] += fMin;
}
}
backEnd.currentSphere->ambient.level[0] = r_entlight_scale->value * tr.overbrightMult * light_offset[0];
if (backEnd.currentSphere->ambient.level[0] >= 255.0) {
backEnd.currentSphere->ambient.level[0] = -1;
}
backEnd.currentSphere->ambient.level[1] = r_entlight_scale->value * tr.overbrightMult * light_offset[0];
if (backEnd.currentSphere->ambient.level[1] >= 255.0) {
backEnd.currentSphere->ambient.level[1] = -1;
}
backEnd.currentSphere->ambient.level[2] = r_entlight_scale->value * tr.overbrightMult * light_offset[0];
if (backEnd.currentSphere->ambient.level[2] >= 255.0) {
backEnd.currentSphere->ambient.level[2] = -1;
}
backEnd.currentSphere->ambient.level[3] = -1;
return true;
}
static void RB_Sphere_DrawDebugLine(const spherel_t* thislight, float falloff, const vec3_t origin)
@@ -81,7 +182,19 @@ void RB_Sphere_BuildDLights()
void RB_Sphere_SetupEntity()
{
// FIXME: unimplemented
if (r_light_nolight->integer)
{
backEnd.currentSphere->TessFunction = &RB_Light_Fullbright;
}
else if (RB_Sphere_SetupGlobals() && RB_Sphere_ResetPointColors())
{
backEnd.currentSphere->numRealLights = 0;
RB_Sphere_Light_Sun();
RB_Sphere_BuildStaticLights();
RB_Sphere_BuildDLights();
backEnd.pc.c_characterlights += backEnd.currentSphere->numRealLights;
RB_OptimizeLights();
}
}
void RB_Grid_SetupEntity()
@@ -94,14 +207,100 @@ void RB_Grid_SetupStaticModel()
// FIXME: unimplemented
}
void RB_Light_Fullbright(const color4ub_t colors)
void RB_Light_Fullbright(unsigned char* colors)
{
// FIXME: unimplemented
memset((void*)colors, 0xFF, tess.numVertexes);
}
void R_Sphere_InitLights()
{
// FIXME: unimplemented
const char* ents;
const char* ret;
qboolean bFlareDirSet;
ents = ri.CM_EntityString();
bFlareDirSet = qfalse;
s_sun.szFlareName[0] = 0;
s_sun.exists = qfalse;
for (int i = 0; i < 128; i++) {
backEnd.spheres[i].TessFunction = &RB_Light_Real;
}
VectorClear(ambientlight);
backEnd.spareSphere.TessFunction = &RB_Light_Real;
backEnd.currentSphere = &backEnd.spareSphere;
bEntityOverbright = qfalse;
iEntityLightingMax = tr.identityLightByte;
s_sun.color[0] = s_sun.color[1] = s_sun.color[2] = tr.overbrightMult * 70;
while (ents)
{
ret = COM_Parse((char**)&ents);
if (*ret == '{' || *ret == '}') {
continue;
}
if (!strcmp(ret, "suncolor") || !strcmp(ret, "sunlight"))
{
sscanf(COM_Parse((char**)&ents), "%f %f %f", &s_sun.color[0], &s_sun.color[1], &s_sun.color[2]);
s_sun.color[0] *= tr.overbrightMult;
s_sun.color[1] *= tr.overbrightMult;
s_sun.color[2] *= tr.overbrightMult;
s_sun.exists = qtrue;
}
else if (!strcmp(ret, "sundirection"))
{
vec3_t dir;
sscanf(COM_Parse((char**)&ents), "%f %f %f", &dir[0], &dir[1], &dir[2]);
AngleVectorsLeft(dir, s_sun.direction, 0, 0);
s_sun.exists = qtrue;
if (!bFlareDirSet)
{
s_sun.flaredirection[0] = s_sun.direction[0];
s_sun.flaredirection[1] = s_sun.direction[1];
s_sun.flaredirection[2] = s_sun.direction[2];
}
}
else if (!strcmp(ret, "sunflaredirection"))
{
vec3_t dir;
sscanf(COM_Parse((char**)&ents), "%f %f %f", &dir[0], &dir[1], &dir[2]);
AngleVectorsLeft(dir, s_sun.flaredirection, 0, 0);
bFlareDirSet = qtrue;
}
else if (!strcmp(ret, "sunflarename"))
{
strcpy(s_sun.szFlareName, COM_Parse((char**)&ents));
}
else if (!strcmp(ret, "ambientlight"))
{
sscanf(COM_Parse((char**)&ents), "%f %f %f", &ambientlight[0], &ambientlight[1], &ambientlight[2]);
}
else if (!strcmp(ret, "overbright"))
{
ret = COM_Parse((char**)&ents);
if (strcmp(ret, "world") || strcmp(ret, "none"))
{
bEntityOverbright = qtrue;
iEntityLightingMax = 0xFF;
}
}
else
{
COM_Parse((char**)&ents);
}
}
if (s_sun.exists)
{
if (!s_sun.szFlareName[0]) {
strcpy(s_sun.szFlareName, "sun");
}
}
}
int R_GatherLightSources(const vec3_t vPos, vec3_t* pvLightPos, vec3_t* pvLightIntensity, int iMaxLights)
+2 -2
View File
@@ -60,7 +60,7 @@ void R_InitStaticModels(void) {
{
float t;
t = 255.0 / (float)max(r, max(g, b));
t = 255.0 / (float)Q_max(r, Q_max(g, b));
r = (int)((float)r * t);
g = (int)((float)g * t);
@@ -114,7 +114,7 @@ void R_InitStaticModels(void) {
surf->hShader[k] = sh->index;
}
else {
surf->hShader[k] = NULL;
surf->hShader[k] = 0;
}
}
}
+33 -11
View File
@@ -343,6 +343,7 @@ RB_SurfaceFace
*/
void RB_SurfaceFace( srfSurfaceFace_t *surf ) {
int i;
qboolean needsNormal;
unsigned *indices, *tessIndexes;
float *v;
float *normal;
@@ -366,27 +367,48 @@ void RB_SurfaceFace( srfSurfaceFace_t *surf ) {
tess.numIndexes += surf->numIndices;
numPoints = surf->numPoints;
needsNormal = qfalse;
if (tess.shader->needsNormal || tess.shader->needsLSpherical || tr.refdef.num_dlights) {
needsNormal = qtrue;
}
v = surf->points[0];
ndx = tess.numVertexes;
numPoints = surf->numPoints;
if ( tess.shader->needsNormal || tess.shader->needsLSpherical || tr.refdef.num_dlights ) {
if (needsNormal) {
normal = surf->plane.normal;
for ( i = 0, ndx = tess.numVertexes; i < numPoints; i++, ndx++ ) {
VectorCopy( normal, tess.normal[ndx] );
}
}
for ( i = 0, v = surf->points[0], ndx = tess.numVertexes; i < numPoints; i++, v += VERTEXSIZE, ndx++ ) {
VectorCopy( v, tess.xyz[ndx]);
tess.texCoords[ndx][0][0] = v[3];
tess.texCoords[ndx][0][1] = v[4];
tess.texCoords[ndx][1][0] = v[5];
tess.texCoords[ndx][1][1] = v[6];
* ( unsigned int * ) &tess.vertexColors[ndx] = * ( unsigned int * ) &v[7];
tess.vertexDlightBits[ndx] = dlightBits;
if (tess.dlightMap)
{
for (i = 0, v = surf->points[0], ndx = tess.numVertexes; i < numPoints; i++, v += VERTEXSIZE, ndx++) {
VectorCopy(v, tess.xyz[ndx]);
tess.texCoords[ndx][0][0] = v[3];
tess.texCoords[ndx][0][1] = v[4];
tess.texCoords[ndx][1][0] = v[5] + surf->lightmapOffset[0];
tess.texCoords[ndx][1][1] = v[6] + surf->lightmapOffset[1];
*(unsigned int*)&tess.vertexColors[ndx] = *(unsigned int*)&v[7];
tess.vertexDlightBits[ndx] = dlightBits;
}
}
else
{
for (i = 0, v = surf->points[0], ndx = tess.numVertexes; i < numPoints; i++, v += VERTEXSIZE, ndx++) {
VectorCopy(v, tess.xyz[ndx]);
tess.texCoords[ndx][0][0] = v[3];
tess.texCoords[ndx][0][1] = v[4];
tess.texCoords[ndx][1][0] = v[5];
tess.texCoords[ndx][1][1] = v[6];
*(unsigned int*)&tess.vertexColors[ndx] = *(unsigned int*)&v[7];
tess.vertexDlightBits[ndx] = dlightBits;
}
}
+6 -5
View File
@@ -86,7 +86,7 @@ static void R_ValidateHeightmapForVertex(terraTri_t* pTri)
}
}
static int R_AllocateVert(cTerraPatchUnpacked_t* patch)
static terraInt R_AllocateVert(cTerraPatchUnpacked_t* patch)
{
terraInt iVert = g_vert.iFreeHead;
@@ -227,12 +227,13 @@ static void R_ReleaseTri(cTerraPatchUnpacked_t* patch, terraInt iTri)
static int R_ConstChecksForTri(terraTri_t* pTri)
{
varnodeUnpacked_t vn = *pTri->varnode;
varnodeUnpacked_t vn;
if (pTri->lod == MAX_TERRAIN_LOD) {
return 2;
}
vn = *pTri->varnode;
vn.s.flags &= 0xF0u;
if (vn.fVariance == 0.0 && !(pTri->varnode->s.flags & 8)) {
@@ -340,7 +341,7 @@ void R_SplitTri(terraInt iSplit, terraInt iNewPt, terraInt iLeft, terraInt iRigh
int iNextLod = pSplit->lod + 1;
int index = pSplit->index;
varnodeUnpacked_t* varnode = pSplit->varnode + index;
varnodeUnpacked_t* varnode = &pSplit->varnode[index];
if (pLeft)
{
@@ -747,8 +748,8 @@ static void R_PreTessellateTerrain()
const float t11 = patch->texCoord[1][1][1] - tMin;
const float lmapSize = (float)(patch->drawinfo.lmapSize - 1) / TERRAIN_LIGHTMAP_SIZE;
const float ls = patch->s * lmapSize;
const float lt = patch->t * lmapSize;
const float ls = patch->s + lmapSize;
const float lt = patch->t + lmapSize;
terraInt iTri0 = R_AllocateTri(patch, qfalse);
terraInt iTri1 = R_AllocateTri(patch, qfalse);
+4 -1
View File
@@ -539,7 +539,10 @@ static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits )
}
int R_SphereInLeafs(vec_t* p, float r, mnode_t** nodes, int nMaxNodes) {
// FIXME: unimplemented
return 0;
}
/*
===============
R_PointInLeaf
+13
View File
@@ -55,6 +55,19 @@ UIList::UIList()
}
}
UIList::~UIList()
{
for (int i = m_itemlist.NumObjects(); i > 0; i--)
{
UIListItem* item = m_itemlist.ObjectAt(i);
m_itemlist.RemoveObjectAt(i);
delete item;
}
if (m_prev_arrow_region) delete m_prev_arrow_region;
if (m_next_arrow_region) delete m_next_arrow_region;
}
void UIList::Draw
(
void
+1
View File
@@ -59,6 +59,7 @@ protected:
void AddItem( str item, str alias );
public:
UIList();
~UIList();
void UpdateUIElement( void );
void UpdateData( void );
+8
View File
@@ -52,6 +52,14 @@ UIListCtrl::UIListCtrl()
m_foreground_color = UHudColor;
}
UIListCtrl::~UIListCtrl()
{
if (m_headerfont) {
delete m_headerfont;
m_headerfont = NULL;
}
}
int UIListCtrl::StringCompareFunction
(
const UIListCtrlItem *i1,
+1
View File
@@ -87,6 +87,7 @@ protected:
void DrawContent( void );
public:
UIListCtrl();
~UIListCtrl();
void FrameInitialized( void );
void SetDrawHeader( qboolean bDrawHeader );
+165
View File
@@ -81,6 +81,14 @@ static int tty_eof;
static struct termios tty_tc;
#define MAX_EDIT_LINE 256
typedef struct {
int cursor;
int scroll;
int widthInChars;
char buffer[MAX_EDIT_LINE];
} field_t;
static field_t tty_con;
// history
@@ -459,6 +467,163 @@ void floating_point_exception_handler(int whatever)
signal(SIGFPE, floating_point_exception_handler);
}
/*
===========================================
command line completion
===========================================
*/
/*
==================
Field_Clear
==================
*/
void Field_Clear(field_t* edit) {
memset(edit->buffer, 0, MAX_EDIT_LINE);
edit->cursor = 0;
edit->scroll = 0;
}
static const char* completionString;
static char shortestMatch[MAX_TOKEN_CHARS];
static int matchCount;
// field we are working on, passed to Field_CompleteCommand (&g_consoleCommand for instance)
static field_t* completionField;
/*
===============
FindMatches
===============
*/
static void FindMatches(const char* s) {
int i;
if (Q_stricmpn(s, completionString, strlen(completionString))) {
return;
}
matchCount++;
if (matchCount == 1) {
Q_strncpyz(shortestMatch, s, sizeof(shortestMatch));
return;
}
// cut shortestMatch to the amount common with s
for (i = 0; s[i]; i++) {
if (tolower(shortestMatch[i]) != tolower(s[i])) {
shortestMatch[i] = 0;
}
}
}
/*
===============
PrintMatches
===============
*/
static void PrintMatches(const char* s) {
if (!Q_stricmpn(s, shortestMatch, strlen(shortestMatch))) {
Com_Printf(" %s\n", s);
}
}
static void keyConcatArgs(void) {
int i;
char* arg;
for (i = 1; i < Cmd_Argc(); i++) {
Q_strcat(completionField->buffer, sizeof(completionField->buffer), " ");
arg = Cmd_Argv(i);
while (*arg) {
if (*arg == ' ') {
Q_strcat(completionField->buffer, sizeof(completionField->buffer), "\"");
break;
}
arg++;
}
Q_strcat(completionField->buffer, sizeof(completionField->buffer), Cmd_Argv(i));
if (*arg == ' ') {
Q_strcat(completionField->buffer, sizeof(completionField->buffer), "\"");
}
}
}
static void ConcatRemaining(const char* src, const char* start) {
char* str;
str = strstr(src, start);
if (!str) {
keyConcatArgs();
return;
}
str += strlen(start);
Q_strcat(completionField->buffer, sizeof(completionField->buffer), str);
}
/*
===============
Field_CompleteCommand
perform Tab expansion
NOTE TTimo this was originally client code only
moved to common code when writing tty console for *nix dedicated server
===============
*/
void Field_CompleteCommand(field_t* field) {
field_t temp;
completionField = field;
// only look at the first token for completion purposes
Cmd_TokenizeString(completionField->buffer);
completionString = Cmd_Argv(0);
if (completionString[0] == '\\' || completionString[0] == '/') {
completionString++;
}
matchCount = 0;
shortestMatch[0] = 0;
if (strlen(completionString) == 0) {
return;
}
Cmd_CommandCompletion(FindMatches);
Cvar_CommandCompletion(FindMatches);
if (matchCount == 0) {
return; // no matches
}
Com_Memcpy(&temp, completionField, sizeof(field_t));
if (matchCount == 1) {
Com_sprintf(completionField->buffer, sizeof(completionField->buffer), "\\%s", shortestMatch);
if (Cmd_Argc() == 1) {
Q_strcat(completionField->buffer, sizeof(completionField->buffer), " ");
}
else {
ConcatRemaining(temp.buffer, completionString);
}
completionField->cursor = strlen(completionField->buffer);
return;
}
// multiple matches, complete to shortest
Com_sprintf(completionField->buffer, sizeof(completionField->buffer), "\\%s", shortestMatch);
completionField->cursor = strlen(completionField->buffer);
ConcatRemaining(temp.buffer, completionString);
Com_Printf("]%s\n", completionField->buffer);
// run through again, printing matches
Cmd_CommandCompletion(PrintMatches);
Cvar_CommandCompletion(PrintMatches);
}
// initialize the console input (tty mode if wanted and possible)
void Sys_ConsoleInputInit()
{