refactor enums

credits for class BitFlags go to Jelvan <3
This commit is contained in:
Garux 2021-01-25 01:33:56 +03:00
parent 661f8e53b9
commit bdfd864670
31 changed files with 312 additions and 227 deletions

View File

@ -0,0 +1,84 @@
/*
Copyright (C) 2001-2006, William Joseph.
All Rights Reserved.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if !defined( INCLUDED_BITFLAGS_H )
#define INCLUDED_BITFLAGS_H
#include <type_traits>
template <typename T, typename D>
class BitFlags
{
public:
static_assert( std::is_integral<T>::value, "Integer wrapper" );
constexpr BitFlags( T flags = 0 ) noexcept
: flags_( flags )
{
}
constexpr explicit operator T() const
{
return flags_;
}
constexpr operator D() const
{
return D{ flags_ };
}
constexpr BitFlags& operator|=( BitFlags flags )
{
flags_ |= flags.flags_;
return *this;
}
constexpr BitFlags& operator&=( BitFlags flags )
{
flags_ &= flags.flags_;
return *this;
}
constexpr BitFlags operator~() const
{
return BitFlags( ~flags_ );
}
constexpr explicit operator bool() const
{
return flags_;
}
friend constexpr BitFlags operator|( BitFlags flags1, BitFlags flags2 )
{
return BitFlags( flags1.flags_ | flags2.flags_ );
}
friend constexpr BitFlags operator&( BitFlags flags1, BitFlags flags2 )
{
return BitFlags( flags1.flags_ & flags2.flags_ );
}
private:
T flags_ = 0;
};
#endif

View File

@ -81,7 +81,7 @@
0, /* minimap sharpener */ 0, /* minimap sharpener */
0, /* minimap border */ 0, /* minimap border */
false, /* minimap keep aspect */ false, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
NULL, /* minimap name format */ NULL, /* minimap name format */
NULL, /* bsp file prefix */ NULL, /* bsp file prefix */
0, /* bsp file version */ 0, /* bsp file version */

View File

@ -72,7 +72,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"%s.tga", /* minimap name format */ "%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */

View File

@ -72,7 +72,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"%s.tga", /* minimap name format */ "%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */

View File

@ -132,7 +132,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"%s.tga", /* minimap name format */ "%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */

View File

@ -167,7 +167,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"%s.tga", /* minimap name format */ "%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
47, /* bsp file version */ 47, /* bsp file version */

View File

@ -85,7 +85,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"%s.tga", /* minimap name format */ "%s.tga", /* minimap name format */
"RBSP", /* bsp file prefix */ "RBSP", /* bsp file prefix */
1, /* bsp file version */ 1, /* bsp file version */

View File

@ -82,7 +82,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"%s.tga", /* minimap name format */ "%s.tga", /* minimap name format */
"RBSP", /* bsp file prefix */ "RBSP", /* bsp file prefix */
1, /* bsp file version */ 1, /* bsp file version */

View File

@ -81,7 +81,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
1.0f / 66.0f, /* minimap border */ 1.0f / 66.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"../gfx/%s_mini.tga", /* minimap name format */ "../gfx/%s_mini.tga", /* minimap name format */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */

View File

@ -72,7 +72,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"%s.tga", /* minimap name format */ "%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */

View File

@ -134,7 +134,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
1.0f / 66.0f, /* minimap border */ 1.0f / 66.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"../minimaps/%s.tga", /* minimap name format */ "../minimaps/%s.tga", /* minimap name format */
"FBSP", /* bsp file prefix */ "FBSP", /* bsp file prefix */
1, /* bsp file version */ 1, /* bsp file version */

View File

@ -132,7 +132,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"%s.tga", /* minimap name format */ "%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */

View File

@ -94,7 +94,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"%s.tga", /* minimap name format */ "%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
47, /* bsp file version */ 47, /* bsp file version */

View File

@ -102,7 +102,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"%s.tga", /* minimap name format */ "%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */

View File

@ -159,7 +159,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"%s.tga", /* minimap name format */ "%s.tga", /* minimap name format */
"RBSP", /* bsp file prefix */ "RBSP", /* bsp file prefix */
1, /* bsp file version */ 1, /* bsp file version */

View File

@ -131,7 +131,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"%s.tga", /* minimap name format */ "%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */

View File

@ -88,7 +88,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"%s.tga", /* minimap name format */ "%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */

View File

@ -89,7 +89,7 @@ game_t struct
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_WHITE, /* minimap mode */ EMiniMapMode::White, /* minimap mode */
"../minimaps/%s.tga", /* minimap name format */ "../minimaps/%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */

View File

@ -148,7 +148,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"%s.tga", /* minimap name format */ "%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
47, /* bsp file version */ 47, /* bsp file version */

View File

@ -84,7 +84,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
0.0f, /* minimap border */ 0.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"%s.tga", /* minimap name format */ "%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
47, /* bsp file version */ 47, /* bsp file version */

View File

@ -81,7 +81,7 @@
1.0f, /* minimap sharpener */ 1.0f, /* minimap sharpener */
1.0f / 66.0f, /* minimap border */ 1.0f / 66.0f, /* minimap border */
true, /* minimap keep aspect */ true, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */ EMiniMapMode::Gray, /* minimap mode */
"../gfx/%s_mini.tga", /* minimap name format */ "../gfx/%s_mini.tga", /* minimap name format */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */

View File

@ -112,8 +112,8 @@ static void CreateSunLight( sun_t *sun ){
lights = light; lights = light;
/* initialize the light */ /* initialize the light */
light->flags = LIGHT_SUN_DEFAULT; light->flags = LightFlags::DefaultSun;
light->type = EMIT_SUN; light->type = ELightType::Sun;
light->fade = 1.0f; light->fade = 1.0f;
light->falloffTolerance = falloffTolerance; light->falloffTolerance = falloffTolerance;
light->filterRadius = sun->filterRadius / sun->numSamples; light->filterRadius = sun->filterRadius / sun->numSamples;
@ -251,21 +251,21 @@ void CreateEntityLights( void ){
/* handle spawnflags */ /* handle spawnflags */
const int spawnflags = IntForKey( e, "spawnflags" ); const int spawnflags = IntForKey( e, "spawnflags" );
int flags; LightFlags flags;
/* ydnar: quake 3+ light behavior */ /* ydnar: quake 3+ light behavior */
if ( !wolfLight ) { if ( !wolfLight ) {
/* set default flags */ /* set default flags */
flags = LIGHT_Q3A_DEFAULT; flags = LightFlags::DefaultQ3A;
/* linear attenuation? */ /* linear attenuation? */
if ( spawnflags & 1 ) { if ( spawnflags & 1 ) {
flags |= LIGHT_ATTEN_LINEAR; flags |= LightFlags::AttenLinear;
flags &= ~LIGHT_ATTEN_ANGLE; flags &= ~LightFlags::AttenAngle;
} }
/* no angle attenuate? */ /* no angle attenuate? */
if ( spawnflags & 2 ) { if ( spawnflags & 2 ) {
flags &= ~LIGHT_ATTEN_ANGLE; flags &= ~LightFlags::AttenAngle;
} }
} }
@ -273,17 +273,17 @@ void CreateEntityLights( void ){
else else
{ {
/* set default flags */ /* set default flags */
flags = LIGHT_WOLF_DEFAULT; flags = LightFlags::DefaultWolf;
/* inverse distance squared attenuation? */ /* inverse distance squared attenuation? */
if ( spawnflags & 1 ) { if ( spawnflags & 1 ) {
flags &= ~LIGHT_ATTEN_LINEAR; flags &= ~LightFlags::AttenLinear;
flags |= LIGHT_ATTEN_ANGLE; flags |= LightFlags::AttenAngle;
} }
/* angle attenuate? */ /* angle attenuate? */
if ( spawnflags & 2 ) { if ( spawnflags & 2 ) {
flags |= LIGHT_ATTEN_ANGLE; flags |= LightFlags::AttenAngle;
} }
} }
@ -291,28 +291,28 @@ void CreateEntityLights( void ){
/* wolf dark light? */ /* wolf dark light? */
if ( ( spawnflags & 4 ) || ( spawnflags & 8 ) ) { if ( ( spawnflags & 4 ) || ( spawnflags & 8 ) ) {
flags |= LIGHT_DARK; flags |= LightFlags::Dark;
} }
/* nogrid? */ /* nogrid? */
if ( spawnflags & 16 ) { if ( spawnflags & 16 ) {
flags &= ~LIGHT_GRID; flags &= ~LightFlags::Grid;
} }
/* junior? */ /* junior? */
if ( junior ) { if ( junior ) {
flags |= LIGHT_GRID; flags |= LightFlags::Grid;
flags &= ~LIGHT_SURFACES; flags &= ~LightFlags::Surfaces;
} }
/* vortex: unnormalized? */ /* vortex: unnormalized? */
if ( spawnflags & 32 ) { if ( spawnflags & 32 ) {
flags |= LIGHT_UNNORMALIZED; flags |= LightFlags::Unnormalized;
} }
/* vortex: distance atten? */ /* vortex: distance atten? */
if ( spawnflags & 64 ) { if ( spawnflags & 64 ) {
flags |= LIGHT_ATTEN_DISTANCE; flags |= LightFlags::AttenDistance;
} }
/* store the flags */ /* store the flags */
@ -320,7 +320,7 @@ void CreateEntityLights( void ){
/* ydnar: set fade key (from wolf) */ /* ydnar: set fade key (from wolf) */
light->fade = 1.0f; light->fade = 1.0f;
if ( light->flags & LIGHT_ATTEN_LINEAR ) { if ( light->flags & LightFlags::AttenLinear ) {
light->fade = FloatForKey( e, "fade" ); light->fade = FloatForKey( e, "fade" );
if ( light->fade == 0.0f ) { if ( light->fade == 0.0f ) {
light->fade = 1.0f; light->fade = 1.0f;
@ -330,7 +330,7 @@ void CreateEntityLights( void ){
/* ydnar: set angle scaling (from vlight) */ /* ydnar: set angle scaling (from vlight) */
light->angleScale = FloatForKey( e, "_anglescale" ); light->angleScale = FloatForKey( e, "_anglescale" );
if ( light->angleScale != 0.0f ) { if ( light->angleScale != 0.0f ) {
light->flags |= LIGHT_ATTEN_ANGLE; light->flags |= LightFlags::AttenAngle;
} }
/* set origin */ /* set origin */
@ -375,7 +375,7 @@ void CreateEntityLights( void ){
light->color[1] = Image_LinearFloatFromsRGBFloat( light->color[1] ); light->color[1] = Image_LinearFloatFromsRGBFloat( light->color[1] );
light->color[2] = Image_LinearFloatFromsRGBFloat( light->color[2] ); light->color[2] = Image_LinearFloatFromsRGBFloat( light->color[2] );
} }
if ( !( light->flags & LIGHT_UNNORMALIZED ) ) { if ( !( light->flags & LightFlags::Unnormalized ) ) {
ColorNormalize( light->color, light->color ); ColorNormalize( light->color, light->color );
} }
} }
@ -389,7 +389,7 @@ void CreateEntityLights( void ){
light->photons = intensity; light->photons = intensity;
light->type = EMIT_POINT; light->type = ELightType::Point;
/* set falloff threshold */ /* set falloff threshold */
light->falloffTolerance = falloffTolerance / numSamples; light->falloffTolerance = falloffTolerance / numSamples;
@ -423,11 +423,11 @@ void CreateEntityLights( void ){
dist = 64; dist = 64;
} }
light->radiusByDist = ( radius + 16 ) / dist; light->radiusByDist = ( radius + 16 ) / dist;
light->type = EMIT_SPOT; light->type = ELightType::Spot;
/* ydnar: wolf mods: spotlights always use nonlinear + angle attenuation */ /* ydnar: wolf mods: spotlights always use nonlinear + angle attenuation */
light->flags &= ~LIGHT_ATTEN_LINEAR; light->flags &= ~LightFlags::AttenLinear;
light->flags |= LIGHT_ATTEN_ANGLE; light->flags |= LightFlags::AttenAngle;
light->fade = 1.0f; light->fade = 1.0f;
/* ydnar: is this a sun? */ /* ydnar: is this a sun? */
@ -478,7 +478,7 @@ void CreateEntityLights( void ){
lights = light2; lights = light2;
/* add to counts */ /* add to counts */
if ( light->type == EMIT_SPOT ) { if ( light->type == ELightType::Spot ) {
numSpotLights++; numSpotLights++;
} }
else{ else{
@ -555,8 +555,8 @@ void CreateSurfaceLights( void ){
lights = light; lights = light;
/* set it up */ /* set it up */
light->flags = LIGHT_Q3A_DEFAULT; light->flags = LightFlags::DefaultQ3A;
light->type = EMIT_POINT; light->type = ELightType::Point;
light->photons = si->value * pointScale; light->photons = si->value * pointScale;
light->fade = 1.0f; light->fade = 1.0f;
light->si = si; light->si = si;
@ -747,12 +747,12 @@ int LightContributionToSample( trace_t *trace ){
colorBrightness = RGBTOGRAY( light->color ) * ( 1.0f / 255.0f ); colorBrightness = RGBTOGRAY( light->color ) * ( 1.0f / 255.0f );
/* ydnar: early out */ /* ydnar: early out */
if ( !( light->flags & LIGHT_SURFACES ) || light->envelope <= 0.0f ) { if ( !( light->flags & LightFlags::Surfaces ) || light->envelope <= 0.0f ) {
return 0; return 0;
} }
/* do some culling checks */ /* do some culling checks */
if ( light->type != EMIT_SUN ) { if ( light->type != ELightType::Sun ) {
/* MrE: if the light is behind the surface */ /* MrE: if the light is behind the surface */
if ( !trace->twoSided ) { if ( !trace->twoSided ) {
if ( DotProduct( light->origin, trace->normal ) - DotProduct( trace->origin, trace->normal ) < 0.0f ) { if ( DotProduct( light->origin, trace->normal ) - DotProduct( trace->origin, trace->normal ) < 0.0f ) {
@ -767,7 +767,7 @@ int LightContributionToSample( trace_t *trace ){
} }
/* exact point to polygon form factor */ /* exact point to polygon form factor */
if ( light->type == EMIT_AREA ) { if ( light->type == ELightType::Area ) {
float factor; float factor;
float d; float d;
vec3_t pushedOrigin; vec3_t pushedOrigin;
@ -776,7 +776,7 @@ int LightContributionToSample( trace_t *trace ){
d = DotProduct( trace->origin, light->normal ) - light->dist; d = DotProduct( trace->origin, light->normal ) - light->dist;
if ( d < 3.0f ) { if ( d < 3.0f ) {
/* sample point behind plane? */ /* sample point behind plane? */
if ( !( light->flags & LIGHT_TWOSIDED ) && d < -1.0f ) { if ( !( light->flags & LightFlags::Twosided ) && d < -1.0f ) {
return 0; return 0;
} }
@ -821,7 +821,7 @@ int LightContributionToSample( trace_t *trace ){
return 0; return 0;
} }
else if ( angle < 0.0f && else if ( angle < 0.0f &&
( trace->twoSided || ( light->flags & LIGHT_TWOSIDED ) ) ) { ( trace->twoSided || ( light->flags & LightFlags::Twosided ) ) ) {
angle = -angle; angle = -angle;
/* no deluxemap contribution from "other side" light */ /* no deluxemap contribution from "other side" light */
@ -854,7 +854,7 @@ int LightContributionToSample( trace_t *trace ){
} }
else if ( factor < 0.0f ) { else if ( factor < 0.0f ) {
/* twosided lighting */ /* twosided lighting */
if ( trace->twoSided || ( light->flags & LIGHT_TWOSIDED ) ) { if ( trace->twoSided || ( light->flags & LightFlags::Twosided ) ) {
factor = -factor; factor = -factor;
/* push light origin to other side of the plane */ /* push light origin to other side of the plane */
@ -888,7 +888,7 @@ int LightContributionToSample( trace_t *trace ){
} }
/* point/spot lights */ /* point/spot lights */
else if ( light->type == EMIT_POINT || light->type == EMIT_SPOT ) { else if ( light->type == ELightType::Point || light->type == ELightType::Spot ) {
/* get direction and distance */ /* get direction and distance */
VectorCopy( light->origin, trace->end ); VectorCopy( light->origin, trace->end );
dist = SetupTrace( trace ); dist = SetupTrace( trace );
@ -903,7 +903,7 @@ int LightContributionToSample( trace_t *trace ){
} }
/* angle attenuation */ /* angle attenuation */
if ( light->flags & LIGHT_ATTEN_ANGLE ) { if ( light->flags & LightFlags::AttenAngle ) {
/* standard Lambert attenuation */ /* standard Lambert attenuation */
float dot = DotProduct( trace->normal, trace->direction ); float dot = DotProduct( trace->normal, trace->direction );
@ -943,7 +943,7 @@ int LightContributionToSample( trace_t *trace ){
} }
/* attenuate */ /* attenuate */
if ( light->flags & LIGHT_ATTEN_LINEAR ) { if ( light->flags & LightFlags::AttenLinear ) {
add = angle * light->photons * linearScale - ( dist * light->fade ); add = angle * light->photons * linearScale - ( dist * light->fade );
if ( add < 0.0f ) { if ( add < 0.0f ) {
add = 0.0f; add = 0.0f;
@ -984,7 +984,7 @@ int LightContributionToSample( trace_t *trace ){
} }
/* handle spotlights */ /* handle spotlights */
if ( light->type == EMIT_SPOT ) { if ( light->type == ELightType::Spot ) {
float distByNormal, radiusAtDist, sampleRadius; float distByNormal, radiusAtDist, sampleRadius;
vec3_t pointAtDist, distToSample; vec3_t pointAtDist, distToSample;
@ -1020,13 +1020,13 @@ int LightContributionToSample( trace_t *trace ){
} }
/* ydnar: sunlight */ /* ydnar: sunlight */
else if ( light->type == EMIT_SUN ) { else if ( light->type == ELightType::Sun ) {
/* get origin and direction */ /* get origin and direction */
VectorAdd( trace->origin, light->origin, trace->end ); VectorAdd( trace->origin, light->origin, trace->end );
dist = SetupTrace( trace ); dist = SetupTrace( trace );
/* angle attenuation */ /* angle attenuation */
if ( light->flags & LIGHT_ATTEN_ANGLE ) { if ( light->flags & LightFlags::AttenAngle ) {
/* standard Lambert attenuation */ /* standard Lambert attenuation */
float dot = DotProduct( trace->normal, trace->direction ); float dot = DotProduct( trace->normal, trace->direction );
@ -1120,7 +1120,7 @@ int LightContributionToSample( trace_t *trace ){
VectorScale( light->color, add, trace->colorNoShadow ); VectorScale( light->color, add, trace->colorNoShadow );
/* ydnar: changed to a variable number */ /* ydnar: changed to a variable number */
if ( add <= 0.0f || ( add <= light->falloffTolerance && ( light->flags & LIGHT_FAST_ACTUAL ) ) ) { if ( add <= 0.0f || ( add <= light->falloffTolerance && ( light->flags & LightFlags::FastActual ) ) ) {
return 0; return 0;
} }
@ -1223,7 +1223,7 @@ void LightingAtSample( trace_t *trace, byte styles[ MAX_LIGHTMAPS ], vec3_t colo
} }
/* handle negative light */ /* handle negative light */
if ( trace->light->flags & LIGHT_NEGATIVE ) { if ( trace->light->flags & LightFlags::Negative ) {
VectorScale( trace->color, -1.0f, trace->color ); VectorScale( trace->color, -1.0f, trace->color );
} }
@ -1263,12 +1263,12 @@ bool LightContributionToPoint( trace_t *trace ){
VectorClear( trace->color ); VectorClear( trace->color );
/* ydnar: early out */ /* ydnar: early out */
if ( !( light->flags & LIGHT_GRID ) || light->envelope <= 0.0f ) { if ( !( light->flags & LightFlags::Grid ) || light->envelope <= 0.0f ) {
return false; return false;
} }
/* is this a sun? */ /* is this a sun? */
if ( light->type != EMIT_SUN ) { if ( light->type != ELightType::Sun ) {
/* sun only? */ /* sun only? */
if ( sunOnly ) { if ( sunOnly ) {
return false; return false;
@ -1289,7 +1289,7 @@ bool LightContributionToPoint( trace_t *trace ){
} }
/* set light origin */ /* set light origin */
if ( light->type == EMIT_SUN ) { if ( light->type == ELightType::Sun ) {
VectorAdd( trace->origin, light->origin, trace->end ); VectorAdd( trace->origin, light->origin, trace->end );
} }
else{ else{
@ -1306,7 +1306,7 @@ bool LightContributionToPoint( trace_t *trace ){
} }
/* ptpff approximation */ /* ptpff approximation */
if ( light->type == EMIT_AREA && faster ) { if ( light->type == ELightType::Area && faster ) {
/* clamp the distance to prevent super hot spots */ /* clamp the distance to prevent super hot spots */
dist = sqrt( dist * dist + light->extraDist * light->extraDist ); dist = sqrt( dist * dist + light->extraDist * light->extraDist );
if ( dist < 16.0f ) { if ( dist < 16.0f ) {
@ -1318,14 +1318,14 @@ bool LightContributionToPoint( trace_t *trace ){
} }
/* exact point to polygon form factor */ /* exact point to polygon form factor */
else if ( light->type == EMIT_AREA ) { else if ( light->type == ELightType::Area ) {
float factor, d; float factor, d;
vec3_t pushedOrigin; vec3_t pushedOrigin;
/* see if the point is behind the light */ /* see if the point is behind the light */
d = DotProduct( trace->origin, light->normal ) - light->dist; d = DotProduct( trace->origin, light->normal ) - light->dist;
if ( !( light->flags & LIGHT_TWOSIDED ) && d < -1.0f ) { if ( !( light->flags & LightFlags::Twosided ) && d < -1.0f ) {
return false; return false;
} }
@ -1344,7 +1344,7 @@ bool LightContributionToPoint( trace_t *trace ){
return false; return false;
} }
else if ( factor < 0.0f ) { else if ( factor < 0.0f ) {
if ( light->flags & LIGHT_TWOSIDED ) { if ( light->flags & LightFlags::Twosided ) {
factor = -factor; factor = -factor;
} }
else{ else{
@ -1357,7 +1357,7 @@ bool LightContributionToPoint( trace_t *trace ){
} }
/* point/spot lights */ /* point/spot lights */
else if ( light->type == EMIT_POINT || light->type == EMIT_SPOT ) { else if ( light->type == ELightType::Point || light->type == ELightType::Spot ) {
/* clamp the distance to prevent super hot spots */ /* clamp the distance to prevent super hot spots */
dist = sqrt( dist * dist + light->extraDist * light->extraDist ); dist = sqrt( dist * dist + light->extraDist * light->extraDist );
if ( dist < 16.0f ) { if ( dist < 16.0f ) {
@ -1365,7 +1365,7 @@ bool LightContributionToPoint( trace_t *trace ){
} }
/* attenuate */ /* attenuate */
if ( light->flags & LIGHT_ATTEN_LINEAR ) { if ( light->flags & LightFlags::AttenLinear ) {
add = light->photons * linearScale - ( dist * light->fade ); add = light->photons * linearScale - ( dist * light->fade );
if ( add < 0.0f ) { if ( add < 0.0f ) {
add = 0.0f; add = 0.0f;
@ -1376,7 +1376,7 @@ bool LightContributionToPoint( trace_t *trace ){
} }
/* handle spotlights */ /* handle spotlights */
if ( light->type == EMIT_SPOT ) { if ( light->type == ELightType::Spot ) {
float distByNormal, radiusAtDist, sampleRadius; float distByNormal, radiusAtDist, sampleRadius;
vec3_t pointAtDist, distToSample; vec3_t pointAtDist, distToSample;
@ -1404,7 +1404,7 @@ bool LightContributionToPoint( trace_t *trace ){
} }
/* ydnar: sunlight */ /* ydnar: sunlight */
else if ( light->type == EMIT_SUN ) { else if ( light->type == ELightType::Sun ) {
/* attenuate */ /* attenuate */
add = light->photons; add = light->photons;
if ( add <= 0.0f ) { if ( add <= 0.0f ) {
@ -1435,7 +1435,7 @@ bool LightContributionToPoint( trace_t *trace ){
} }
/* ydnar: changed to a variable number */ /* ydnar: changed to a variable number */
if ( add <= 0.0f || ( add <= light->falloffTolerance && ( light->flags & LIGHT_FAST_ACTUAL ) ) ) { if ( add <= 0.0f || ( add <= light->falloffTolerance && ( light->flags & LightFlags::FastActual ) ) ) {
return false; return false;
} }
@ -1559,7 +1559,7 @@ void TraceGrid( int num ){
} }
/* handle negative light */ /* handle negative light */
if ( trace.light->flags & LIGHT_NEGATIVE ) { if ( trace.light->flags & LightFlags::Negative ) {
VectorScale( trace.color, -1.0f, trace.color ); VectorScale( trace.color, -1.0f, trace.color );
} }

View File

@ -540,8 +540,8 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw
ThreadUnlock(); ThreadUnlock();
/* initialize the light */ /* initialize the light */
light->flags = LIGHT_AREA_DEFAULT; light->flags = LightFlags::DefaultArea;
light->type = EMIT_AREA; light->type = ELightType::Area;
light->si = si; light->si = si;
light->fade = 1.0f; light->fade = 1.0f;
light->w = w; light->w = w;
@ -586,8 +586,8 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw
/* set it up */ /* set it up */
splash->flags = LIGHT_Q3A_DEFAULT; splash->flags = LightFlags::DefaultQ3A;
splash->type = EMIT_POINT; splash->type = ELightType::Point;
splash->photons = light->photons * si->backsplashFraction; splash->photons = light->photons * si->backsplashFraction;
splash->fade = 1.0f; splash->fade = 1.0f;
@ -615,8 +615,8 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw
ThreadUnlock(); ThreadUnlock();
/* set it up */ /* set it up */
splash->flags = LIGHT_AREA_DEFAULT; splash->flags = LightFlags::DefaultArea;
splash->type = EMIT_AREA; splash->type = ELightType::Area;
splash->photons = light->photons * 7.0f * si->backsplashFraction; splash->photons = light->photons * 7.0f * si->backsplashFraction;
splash->add = light->add * 7.0f * si->backsplashFraction; splash->add = light->add * 7.0f * si->backsplashFraction;
splash->fade = 1.0f; splash->fade = 1.0f;
@ -640,7 +640,7 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw
VectorNegate( normal, splash->normal ); VectorNegate( normal, splash->normal );
splash->dist = DotProduct( splash->origin, splash->normal ); splash->dist = DotProduct( splash->origin, splash->normal );
// splash->flags |= LIGHT_TWOSIDED; // splash->flags |= LightFlags::Twosided;
} }
#endif #endif
@ -672,7 +672,7 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw
/* emit light from both sides? */ /* emit light from both sides? */
if ( si->compileFlags & C_FOG || si->twoSided ) { if ( si->compileFlags & C_FOG || si->twoSided ) {
light->flags |= LIGHT_TWOSIDED; light->flags |= LightFlags::Twosided;
} }
//% Sys_Printf( "\nAL: C: (%6f, %6f, %6f) [%6f] N: (%6f, %6f, %6f) %s\n", //% Sys_Printf( "\nAL: C: (%6f, %6f, %6f) [%6f] N: (%6f, %6f, %6f) %s\n",

View File

@ -2036,7 +2036,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){
} }
/* create a culled light list for this raw lightmap */ /* create a culled light list for this raw lightmap */
CreateTraceLightsForBounds( lm->mins, lm->maxs, lm->plane, lm->numLightClusters, lm->lightClusters, LIGHT_SURFACES, &trace ); CreateTraceLightsForBounds( lm->mins, lm->maxs, lm->plane, lm->numLightClusters, lm->lightClusters, LightFlags::Surfaces, &trace );
/* ----------------------------------------------------------------- /* -----------------------------------------------------------------
fill pass fill pass
@ -2484,7 +2484,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){
luxel[ 3 ] = 1.0f; luxel[ 3 ] = 1.0f;
/* handle negative light */ /* handle negative light */
if ( trace.light->flags & LIGHT_NEGATIVE ) { if ( trace.light->flags & LightFlags::Negative ) {
luxel[ 0 ] -= averageColor[ 0 ] / samples; luxel[ 0 ] -= averageColor[ 0 ] / samples;
luxel[ 1 ] -= averageColor[ 1 ] / samples; luxel[ 1 ] -= averageColor[ 1 ] / samples;
luxel[ 2 ] -= averageColor[ 2 ] / samples; luxel[ 2 ] -= averageColor[ 2 ] / samples;
@ -2517,7 +2517,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){
deluxel = SUPER_DELUXEL( x, y ); deluxel = SUPER_DELUXEL( x, y );
/* handle negative light */ /* handle negative light */
if ( trace.light->flags & LIGHT_NEGATIVE ) { if ( trace.light->flags & LightFlags::Negative ) {
VectorScale( averageColor, -1.0f, averageColor ); VectorScale( averageColor, -1.0f, averageColor );
} }
@ -2525,7 +2525,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){
luxel[ 3 ] = 1.0f; luxel[ 3 ] = 1.0f;
/* handle negative light */ /* handle negative light */
if ( trace.light->flags & LIGHT_NEGATIVE ) { if ( trace.light->flags & LightFlags::Negative ) {
VectorSubtract( luxel, lightLuxel, luxel ); VectorSubtract( luxel, lightLuxel, luxel );
} }
@ -3627,11 +3627,11 @@ void SetupEnvelopes( bool forGrid, bool fastFlag ){
if ( light->photons < 0.0f || light->add < 0.0f ) { if ( light->photons < 0.0f || light->add < 0.0f ) {
light->photons *= -1.0f; light->photons *= -1.0f;
light->add *= -1.0f; light->add *= -1.0f;
light->flags |= LIGHT_NEGATIVE; light->flags |= LightFlags::Negative;
} }
/* sunlight? */ /* sunlight? */
if ( light->type == EMIT_SUN ) { if ( light->type == ELightType::Sun ) {
/* special cased */ /* special cased */
light->cluster = 0; light->cluster = 0;
light->envelope = MAX_WORLD_COORD * 8.0f; light->envelope = MAX_WORLD_COORD * 8.0f;
@ -3683,27 +3683,27 @@ void SetupEnvelopes( bool forGrid, bool fastFlag ){
if ( light->cluster >= 0 ) { if ( light->cluster >= 0 ) {
/* set light fast flag */ /* set light fast flag */
if ( fastFlag ) { if ( fastFlag ) {
light->flags |= LIGHT_FAST_TEMP; light->flags |= LightFlags::FastTemp;
} }
else{ else{
light->flags &= ~LIGHT_FAST_TEMP; light->flags &= ~LightFlags::FastTemp;
} }
if ( fastpoint && ( light->type != EMIT_AREA ) ) { if ( fastpoint && ( light->type != ELightType::Area ) ) {
light->flags |= LIGHT_FAST_TEMP; light->flags |= LightFlags::FastTemp;
} }
if ( light->si && light->si->noFast ) { if ( light->si && light->si->noFast ) {
light->flags &= ~( LIGHT_FAST | LIGHT_FAST_TEMP ); light->flags &= ~( LightFlags::Fast | LightFlags::FastTemp );
} }
/* clear light envelope */ /* clear light envelope */
light->envelope = 0; light->envelope = 0;
/* handle area lights */ /* handle area lights */
if ( exactPointToPolygon && light->type == EMIT_AREA && light->w != NULL ) { if ( exactPointToPolygon && light->type == ELightType::Area && light->w != NULL ) {
light->envelope = MAX_WORLD_COORD * 8.0f; light->envelope = MAX_WORLD_COORD * 8.0f;
/* check for fast mode */ /* check for fast mode */
if ( ( light->flags & LIGHT_FAST ) || ( light->flags & LIGHT_FAST_TEMP ) ) { if ( ( light->flags & LightFlags::Fast ) || ( light->flags & LightFlags::FastTemp ) ) {
/* ugly hack to calculate extent for area lights, but only done once */ /* ugly hack to calculate extent for area lights, but only done once */
VectorScale( light->normal, -1.0f, dir ); VectorScale( light->normal, -1.0f, dir );
for ( radius = 100.0f; radius < MAX_WORLD_COORD * 8.0f; radius += 10.0f ) for ( radius = 100.0f; radius < MAX_WORLD_COORD * 8.0f; radius += 10.0f )
@ -3733,13 +3733,13 @@ void SetupEnvelopes( bool forGrid, bool fastFlag ){
/* other calcs */ /* other calcs */
if ( light->envelope <= 0.0f ) { if ( light->envelope <= 0.0f ) {
/* solve distance for non-distance lights */ /* solve distance for non-distance lights */
if ( !( light->flags & LIGHT_ATTEN_DISTANCE ) ) { if ( !( light->flags & LightFlags::AttenDistance ) ) {
light->envelope = MAX_WORLD_COORD * 8.0f; light->envelope = MAX_WORLD_COORD * 8.0f;
} }
else if ( ( light->flags & LIGHT_FAST ) || ( light->flags & LIGHT_FAST_TEMP ) ) { else if ( ( light->flags & LightFlags::Fast ) || ( light->flags & LightFlags::FastTemp) ) {
/* solve distance for linear lights */ /* solve distance for linear lights */
if ( ( light->flags & LIGHT_ATTEN_LINEAR ) ) { if ( ( light->flags & LightFlags::AttenLinear ) ) {
light->envelope = ( ( intensity * linearScale ) - light->falloffTolerance ) / light->fade; light->envelope = ( ( intensity * linearScale ) - light->falloffTolerance ) / light->fade;
} }
@ -3766,7 +3766,7 @@ void SetupEnvelopes( bool forGrid, bool fastFlag ){
else else
{ {
/* solve distance for linear lights */ /* solve distance for linear lights */
if ( ( light->flags & LIGHT_ATTEN_LINEAR ) ) { if ( ( light->flags & LightFlags::AttenLinear ) ) {
light->envelope = ( intensity * linearScale ) / light->fade; light->envelope = ( intensity * linearScale ) / light->fade;
} }
@ -3816,7 +3816,7 @@ void SetupEnvelopes( bool forGrid, bool fastFlag ){
} }
/* chop the bounds by a plane for area lights and spotlights */ /* chop the bounds by a plane for area lights and spotlights */
if ( light->type == EMIT_AREA || light->type == EMIT_SPOT ) { if ( light->type == ELightType::Area || light->type == ELightType::Spot ) {
ChopBounds( mins, maxs, light->origin, light->normal ); ChopBounds( mins, maxs, light->origin, light->normal );
} }
@ -3849,13 +3849,13 @@ void SetupEnvelopes( bool forGrid, bool fastFlag ){
/* add grid/surface only check */ /* add grid/surface only check */
if ( forGrid ) { if ( forGrid ) {
if ( !( light->flags & LIGHT_GRID ) ) { if ( !( light->flags & LightFlags::Grid ) ) {
light->envelope = 0.0f; light->envelope = 0.0f;
} }
} }
else else
{ {
if ( !( light->flags & LIGHT_SURFACES ) ) { if ( !( light->flags & LightFlags::Surfaces ) ) {
light->envelope = 0.0f; light->envelope = 0.0f;
} }
} }
@ -3928,7 +3928,7 @@ void SetupEnvelopes( bool forGrid, bool fastFlag ){
creates a list of lights that affect the given bounding box and pvs clusters (bsp leaves) creates a list of lights that affect the given bounding box and pvs clusters (bsp leaves)
*/ */
void CreateTraceLightsForBounds( vec3_t mins, vec3_t maxs, vec3_t normal, int numClusters, int *clusters, int flags, trace_t *trace ){ void CreateTraceLightsForBounds( vec3_t mins, vec3_t maxs, vec3_t normal, int numClusters, int *clusters, LightFlags flags, trace_t *trace ){
int i; int i;
light_t *light; light_t *light;
vec3_t origin, dir, nullVector = { 0.0f, 0.0f, 0.0f }; vec3_t origin, dir, nullVector = { 0.0f, 0.0f, 0.0f };
@ -3979,7 +3979,7 @@ void CreateTraceLightsForBounds( vec3_t mins, vec3_t maxs, vec3_t normal, int nu
} }
/* sunlight skips all this nonsense */ /* sunlight skips all this nonsense */
if ( light->type != EMIT_SUN ) { if ( light->type != ELightType::Sun ) {
/* sun only? */ /* sun only? */
if ( sunOnly ) { if ( sunOnly ) {
continue; continue;
@ -4030,7 +4030,7 @@ void CreateTraceLightsForBounds( vec3_t mins, vec3_t maxs, vec3_t normal, int nu
/* planar surfaces (except twosided surfaces) have a couple more checks */ /* planar surfaces (except twosided surfaces) have a couple more checks */
if ( length > 0.0f && !trace->twoSided ) { if ( length > 0.0f && !trace->twoSided ) {
/* lights coplanar with a surface won't light it */ /* lights coplanar with a surface won't light it */
if ( !( light->flags & LIGHT_TWOSIDED ) && DotProduct( light->normal, normal ) > 0.999f ) { if ( !( light->flags & LightFlags::Twosided ) && DotProduct( light->normal, normal ) > 0.999f ) {
lightsPlaneCulled++; lightsPlaneCulled++;
continue; continue;
} }
@ -4093,7 +4093,7 @@ void CreateTraceLightsForSurface( int num, trace_t *trace ){
} }
/* create the lights for the bounding box */ /* create the lights for the bounding box */
CreateTraceLightsForBounds( mins, maxs, normal, info->numSurfaceClusters, &surfaceClusters[ info->firstSurfaceCluster ], LIGHT_SURFACES, trace ); CreateTraceLightsForBounds( mins, maxs, normal, info->numSurfaceClusters, &surfaceClusters[ info->firstSurfaceCluster ], LightFlags::Surfaces, trace );
} }
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////

View File

@ -3385,7 +3385,7 @@ void StoreSurfaceLightmaps( bool fastAllocate ){
dv = &bspDrawVerts[ ds->firstVert ]; dv = &bspDrawVerts[ ds->firstVert ];
/* depthFunc equal? */ /* depthFunc equal? */
const bool dfEqual = ( info->si->styleMarker == 2 || info->si->implicitMap == IM_MASKED ); const bool dfEqual = ( info->si->styleMarker == 2 || info->si->implicitMap == EImplicitMap::Masked );
/* generate stages for styled lightmaps */ /* generate stages for styled lightmaps */
for ( lightmapNum = 1; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ ) for ( lightmapNum = 1; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )

View File

@ -934,7 +934,7 @@ brush_t *FinishBrush( bool noCollapseGroups ){
/* link colorMod volume brushes to the entity directly */ /* link colorMod volume brushes to the entity directly */
if ( b->contentShader != NULL && if ( b->contentShader != NULL &&
b->contentShader->colorMod != NULL && b->contentShader->colorMod != NULL &&
b->contentShader->colorMod->type == CM_VOLUME ) { b->contentShader->colorMod->type == EColorMod::Volume ) {
b->nextColorModBrush = mapEnt->colorModBrushes; b->nextColorModBrush = mapEnt->colorModBrushes;
mapEnt->colorModBrushes = b; mapEnt->colorModBrushes = b;
} }
@ -1093,7 +1093,7 @@ static void ParseRawBrush( bool onlyLights ){
buildBrush->detail = false; buildBrush->detail = false;
/* bp */ /* bp */
if ( g_brushType == BPRIMIT_BP ) { if ( g_brushType == EBrushType::Bp ) {
MatchToken( "{" ); MatchToken( "{" );
} }
@ -1108,7 +1108,7 @@ static void ParseRawBrush( bool onlyLights ){
} }
/* ttimo : bp: here we may have to jump over brush epairs (only used in editor) */ /* ttimo : bp: here we may have to jump over brush epairs (only used in editor) */
if ( g_brushType == BPRIMIT_BP ) { if ( g_brushType == EBrushType::Bp ) {
while ( 1 ) while ( 1 )
{ {
if ( !strEqual( token, "(" ) ) { if ( !strEqual( token, "(" ) ) {
@ -1138,7 +1138,7 @@ static void ParseRawBrush( bool onlyLights ){
Parse1DMatrix( 3, planePoints[ 2 ] ); Parse1DMatrix( 3, planePoints[ 2 ] );
/* bp: read the texture matrix */ /* bp: read the texture matrix */
if ( g_brushType == BPRIMIT_BP ) { if ( g_brushType == EBrushType::Bp ) {
Parse2DMatrix( 2, 3, (float*) side->texMat ); Parse2DMatrix( 2, 3, (float*) side->texMat );
} }
@ -1147,20 +1147,20 @@ static void ParseRawBrush( bool onlyLights ){
const auto shader = String64()( "textures/", token ); const auto shader = String64()( "textures/", token );
/* AP or 220? */ /* AP or 220? */
if ( g_brushType == BPRIMIT_UNDEFINED ){ if ( g_brushType == EBrushType::Undefined ){
GetToken( false ); GetToken( false );
if ( strEqual( token, "[" ) ){ if ( strEqual( token, "[" ) ){
g_brushType = BPRIMIT_VALVE220; g_brushType = EBrushType::Valve220;
Sys_FPrintf( SYS_VRB, "detected brushType = VALVE 220\n" ); Sys_FPrintf( SYS_VRB, "detected brushType = VALVE 220\n" );
} }
else{ else{
g_brushType = BPRIMIT_QUAKE; g_brushType = EBrushType::Quake;
Sys_FPrintf( SYS_VRB, "detected brushType = QUAKE (Axial Projection)\n" ); Sys_FPrintf( SYS_VRB, "detected brushType = QUAKE (Axial Projection)\n" );
} }
UnGetToken(); UnGetToken();
} }
if ( g_brushType == BPRIMIT_QUAKE ) { if ( g_brushType == EBrushType::Quake ) {
GetToken( false ); GetToken( false );
shift[ 0 ] = atof( token ); shift[ 0 ] = atof( token );
GetToken( false ); GetToken( false );
@ -1172,7 +1172,7 @@ static void ParseRawBrush( bool onlyLights ){
GetToken( false ); GetToken( false );
scale[ 1 ] = atof( token ); scale[ 1 ] = atof( token );
} }
else if ( g_brushType == BPRIMIT_VALVE220 ){ else if ( g_brushType == EBrushType::Valve220 ){
int axis, comp; int axis, comp;
for ( axis = 0; axis < 2; ++axis ){ for ( axis = 0; axis < 2; ++axis ){
MatchToken( "[" ); MatchToken( "[" );
@ -1246,13 +1246,13 @@ static void ParseRawBrush( bool onlyLights ){
side->planenum = planenum; side->planenum = planenum;
/* bp: get the texture mapping for this texturedef / plane combination */ /* bp: get the texture mapping for this texturedef / plane combination */
if ( g_brushType == BPRIMIT_QUAKE ) { if ( g_brushType == EBrushType::Quake ) {
QuakeTextureVecs( &mapplanes[ planenum ], shift, rotate, scale, side->vecs ); QuakeTextureVecs( &mapplanes[ planenum ], shift, rotate, scale, side->vecs );
} }
} }
/* bp */ /* bp */
if ( g_brushType == BPRIMIT_BP ) { if ( g_brushType == EBrushType::Bp ) {
UnGetToken(); UnGetToken();
MatchToken( "}" ); MatchToken( "}" );
MatchToken( "}" ); MatchToken( "}" );
@ -1719,9 +1719,9 @@ static bool ParseMapEntity( bool onlyLights, bool noCollapseGroups ){
Sys_Warning( "Terrain entity parsing not supported in this build.\n" ); /* ydnar */ Sys_Warning( "Terrain entity parsing not supported in this build.\n" ); /* ydnar */
} }
else if ( strEqual( token, "brushDef" ) ) { else if ( strEqual( token, "brushDef" ) ) {
if ( g_brushType == BPRIMIT_UNDEFINED ) { if ( g_brushType == EBrushType::Undefined ) {
Sys_FPrintf( SYS_VRB, "detected brushType = BRUSH PRIMITIVES\n" ); Sys_FPrintf( SYS_VRB, "detected brushType = BRUSH PRIMITIVES\n" );
g_brushType = BPRIMIT_BP; g_brushType = EBrushType::Bp;
} }
ParseBrush( onlyLights, noCollapseGroups ); ParseBrush( onlyLights, noCollapseGroups );
} }
@ -1888,7 +1888,7 @@ void LoadMapFile( char *filename, bool onlyLights, bool noCollapseGroups ){
/* initial setup */ /* initial setup */
numMapDrawSurfs = 0; numMapDrawSurfs = 0;
c_detail = 0; c_detail = 0;
g_brushType = BPRIMIT_UNDEFINED; g_brushType = EBrushType::Undefined;
/* allocate a very large temporary brush for building the brushes as they are loaded */ /* allocate a very large temporary brush for building the brushes as they are loaded */
buildBrush = AllocBrush( MAX_BUILD_SIDES ); buildBrush = AllocBrush( MAX_BUILD_SIDES );

View File

@ -467,7 +467,7 @@ int MiniMapBSPMain( int argc, char **argv ){
float *q; float *q;
int x, y; int x, y;
int i; int i;
miniMapMode_t mode; EMiniMapMode mode;
vec3_t mins, maxs; vec3_t mins, maxs;
bool keepaspect; bool keepaspect;
@ -560,15 +560,15 @@ int MiniMapBSPMain( int argc, char **argv ){
Sys_Printf( "Map mins/maxs overridden\n" ); Sys_Printf( "Map mins/maxs overridden\n" );
} }
else if ( strEqual( argv[ i ], "-gray" ) ) { else if ( strEqual( argv[ i ], "-gray" ) ) {
mode = MINIMAP_MODE_GRAY; mode = EMiniMapMode::Gray;
Sys_Printf( "Writing as white-on-black image\n" ); Sys_Printf( "Writing as white-on-black image\n" );
} }
else if ( strEqual( argv[ i ], "-black" ) ) { else if ( strEqual( argv[ i ], "-black" ) ) {
mode = MINIMAP_MODE_BLACK; mode = EMiniMapMode::Black;
Sys_Printf( "Writing as black alpha image\n" ); Sys_Printf( "Writing as black alpha image\n" );
} }
else if ( strEqual( argv[ i ], "-white" ) ) { else if ( strEqual( argv[ i ], "-white" ) ) {
mode = MINIMAP_MODE_WHITE; mode = EMiniMapMode::White;
Sys_Printf( "Writing as white alpha image\n" ); Sys_Printf( "Writing as white alpha image\n" );
} }
else if ( strEqual( argv[ i ], "-boost" ) && i < ( argc - 2 ) ) { else if ( strEqual( argv[ i ], "-boost" ) && i < ( argc - 2 ) ) {
@ -701,7 +701,7 @@ int MiniMapBSPMain( int argc, char **argv ){
switch ( mode ) switch ( mode )
{ {
case MINIMAP_MODE_GRAY: case EMiniMapMode::Gray:
p = data4b; p = data4b;
for ( y = 0; y < minimap.height; ++y ) for ( y = 0; y < minimap.height; ++y )
for ( x = 0; x < minimap.width; ++x ) for ( x = 0; x < minimap.width; ++x )
@ -720,7 +720,7 @@ int MiniMapBSPMain( int argc, char **argv ){
Sys_Printf( " writing to %s...", minimapFilename ); Sys_Printf( " writing to %s...", minimapFilename );
WriteTGAGray( minimapFilename, data4b, minimap.width, minimap.height ); WriteTGAGray( minimapFilename, data4b, minimap.width, minimap.height );
break; break;
case MINIMAP_MODE_BLACK: case EMiniMapMode::Black:
p = data4b; p = data4b;
for ( y = 0; y < minimap.height; ++y ) for ( y = 0; y < minimap.height; ++y )
for ( x = 0; x < minimap.width; ++x ) for ( x = 0; x < minimap.width; ++x )
@ -742,7 +742,7 @@ int MiniMapBSPMain( int argc, char **argv ){
Sys_Printf( " writing to %s...", minimapFilename ); Sys_Printf( " writing to %s...", minimapFilename );
WriteTGA( minimapFilename, data4b, minimap.width, minimap.height ); WriteTGA( minimapFilename, data4b, minimap.width, minimap.height );
break; break;
case MINIMAP_MODE_WHITE: case EMiniMapMode::White:
p = data4b; p = data4b;
for ( y = 0; y < minimap.height; ++y ) for ( y = 0; y < minimap.height; ++y )
for ( x = 0; x < minimap.width; ++x ) for ( x = 0; x < minimap.width; ++x )

View File

@ -266,7 +266,7 @@ void ParsePatch( bool onlyLights ){
// if brush primitives format, we may have some epairs to ignore here // if brush primitives format, we may have some epairs to ignore here
GetToken( true ); GetToken( true );
if ( !strEqual( token, "}" ) && ( g_brushType == BPRIMIT_BP || g_brushType == BPRIMIT_UNDEFINED ) ) { if ( !strEqual( token, "}" ) && ( g_brushType == EBrushType::Bp || g_brushType == EBrushType::Undefined ) ) {
std::list<epair_t> dummy; std::list<epair_t> dummy;
ParseEPair( dummy ); ParseEPair( dummy );
} }

View File

@ -86,6 +86,7 @@
#include "stringfixedsize.h" #include "stringfixedsize.h"
#include "stream/stringstream.h" #include "stream/stringstream.h"
#include "bitflags.h"
#include <list> #include <list>
#include <stddef.h> #include <stddef.h>
@ -199,13 +200,13 @@
#define PSIDE_BOTH ( PSIDE_FRONT | PSIDE_BACK ) #define PSIDE_BOTH ( PSIDE_FRONT | PSIDE_BACK )
#define PSIDE_FACING 4 #define PSIDE_FACING 4
typedef enum{ enum class EBrushType
BPRIMIT_UNDEFINED = 0, {
BPRIMIT_QUAKE, Undefined,
BPRIMIT_BP, Quake,
BPRIMIT_VALVE220 Bp,
} Valve220
brushType_t; };
/* vis */ /* vis */
#define VIS_HEADER_SIZE 8 #define VIS_HEADER_SIZE 8
@ -221,29 +222,6 @@ brushType_t;
/* light */ /* light */
#define EMIT_POINT 0
#define EMIT_AREA 1
#define EMIT_SPOT 2
#define EMIT_SUN 3
#define LIGHT_ATTEN_LINEAR 1
#define LIGHT_ATTEN_ANGLE 2
#define LIGHT_ATTEN_DISTANCE 4
#define LIGHT_TWOSIDED 8
#define LIGHT_GRID 16
#define LIGHT_SURFACES 32
#define LIGHT_DARK 64 /* probably never use this */
#define LIGHT_FAST 256
#define LIGHT_FAST_TEMP 512
#define LIGHT_FAST_ACTUAL ( LIGHT_FAST | LIGHT_FAST_TEMP )
#define LIGHT_NEGATIVE 1024
#define LIGHT_UNNORMALIZED 2048 /* vortex: do not normalize _color */
#define LIGHT_SUN_DEFAULT ( LIGHT_ATTEN_ANGLE | LIGHT_GRID | LIGHT_SURFACES )
#define LIGHT_AREA_DEFAULT ( LIGHT_ATTEN_ANGLE | LIGHT_ATTEN_DISTANCE | LIGHT_GRID | LIGHT_SURFACES ) /* q3a and wolf are the same */
#define LIGHT_Q3A_DEFAULT ( LIGHT_ATTEN_ANGLE | LIGHT_ATTEN_DISTANCE | LIGHT_GRID | LIGHT_SURFACES | LIGHT_FAST )
#define LIGHT_WOLF_DEFAULT ( LIGHT_ATTEN_LINEAR | LIGHT_ATTEN_DISTANCE | LIGHT_GRID | LIGHT_SURFACES | LIGHT_FAST )
#define MAX_TRACE_TEST_NODES 256 #define MAX_TRACE_TEST_NODES 256
#define DEFAULT_INHIBIT_RADIUS 1.5f #define DEFAULT_INHIBIT_RADIUS 1.5f
@ -513,13 +491,12 @@ struct surfaceParm_t
int compileFlags, compileFlagsClear; int compileFlags, compileFlagsClear;
}; };
typedef enum enum class EMiniMapMode
{ {
MINIMAP_MODE_GRAY, Gray,
MINIMAP_MODE_BLACK, Black,
MINIMAP_MODE_WHITE White
} };
miniMapMode_t;
struct game_t struct game_t
{ {
@ -554,7 +531,7 @@ struct game_t
float miniMapSharpen; /* minimap sharpening coefficient */ float miniMapSharpen; /* minimap sharpening coefficient */
float miniMapBorder; /* minimap border amount */ float miniMapBorder; /* minimap border amount */
bool miniMapKeepAspect; /* minimap keep aspect ratio by letterboxing */ bool miniMapKeepAspect; /* minimap keep aspect ratio by letterboxing */
miniMapMode_t miniMapMode; /* minimap mode */ EMiniMapMode miniMapMode; /* minimap mode */
const char *miniMapNameFormat; /* minimap name format */ const char *miniMapNameFormat; /* minimap name format */
const char *bspIdent; /* 4-letter bsp file prefix */ const char *bspIdent; /* 4-letter bsp file prefix */
int bspVersion; /* bsp version to use */ int bspVersion; /* bsp version to use */
@ -616,45 +593,40 @@ struct remap_t
}; };
/* wingdi.h hack, it's the same: 0 */ enum class EColorMod
#undef CM_NONE
typedef enum
{ {
CM_NONE, None,
CM_VOLUME, Volume,
CM_COLOR_SET, ColorSet,
CM_ALPHA_SET, AlphaSet,
CM_COLOR_SCALE, ColorScale,
CM_ALPHA_SCALE, AlphaScale,
CM_COLOR_DOT_PRODUCT, ColorDotProduct,
CM_ALPHA_DOT_PRODUCT, AlphaDotProduct,
CM_COLOR_DOT_PRODUCT_SCALE, ColorDotProductScale,
CM_ALPHA_DOT_PRODUCT_SCALE, AlphaDotProductScale,
CM_COLOR_DOT_PRODUCT_2, ColorDotProduct2,
CM_ALPHA_DOT_PRODUCT_2, AlphaDotProduct2,
CM_COLOR_DOT_PRODUCT_2_SCALE, ColorDotProduct2Scale,
CM_ALPHA_DOT_PRODUCT_2_SCALE AlphaDotProduct2Scale
} };
colorModType_t;
struct colorMod_t struct colorMod_t
{ {
colorMod_t *next; colorMod_t *next;
colorModType_t type; EColorMod type;
vec_t data[ 16 ]; vec_t data[ 16 ];
}; };
typedef enum enum class EImplicitMap
{ {
IM_NONE, None,
IM_OPAQUE, Opaque,
IM_MASKED, Masked,
IM_BLEND Blend
} };
implicitMap_t;
struct shaderInfo_t struct shaderInfo_t
@ -734,7 +706,7 @@ struct shaderInfo_t
String64 lightImagePath; /* use this image to generate color / averageColor */ String64 lightImagePath; /* use this image to generate color / averageColor */
String64 normalImagePath; /* ydnar: normalmap image for bumpmapping */ String64 normalImagePath; /* ydnar: normalmap image for bumpmapping */
implicitMap_t implicitMap; /* ydnar: enemy territory implicit shaders */ EImplicitMap implicitMap; /* ydnar: enemy territory implicit shaders */
String64 implicitImagePath; String64 implicitImagePath;
image_t *shaderImage; image_t *shaderImage;
@ -1238,13 +1210,42 @@ struct threaddata_t
------------------------------------------------------------------------------- */ ------------------------------------------------------------------------------- */
enum class ELightType
{
Point,
Area,
Spot,
Sun
};
struct LightFlags : BitFlags<std::uint32_t, LightFlags>
{
constexpr static BitFlags AttenLinear {1 << 0};
constexpr static BitFlags AttenAngle {1 << 1};
constexpr static BitFlags AttenDistance {1 << 2};
constexpr static BitFlags Twosided {1 << 3};
constexpr static BitFlags Grid {1 << 4};
constexpr static BitFlags Surfaces {1 << 5};
constexpr static BitFlags Dark {1 << 6}; /* probably never use this */
constexpr static BitFlags Fast {1 << 7};
constexpr static BitFlags FastTemp {1 << 8};
constexpr static BitFlags FastActual { Fast | FastTemp };
constexpr static BitFlags Negative {1 << 9};
constexpr static BitFlags Unnormalized {1 << 10}; /* vortex: do not normalize _color */
constexpr static BitFlags DefaultSun { AttenAngle | Grid | Surfaces };
constexpr static BitFlags DefaultArea { AttenAngle | AttenDistance | Grid | Surfaces }; /* q3a and wolf are the same */
constexpr static BitFlags DefaultQ3A { AttenAngle | AttenDistance | Grid | Surfaces | Fast };
constexpr static BitFlags DefaultWolf { AttenLinear | AttenDistance | Grid | Surfaces | Fast };
};
/* ydnar: new light struct with flags */ /* ydnar: new light struct with flags */
struct light_t struct light_t
{ {
light_t *next; light_t *next;
int type; ELightType type;
int flags; /* ydnar: condensed all the booleans into one flags int */ LightFlags flags; /* ydnar: condensed all the booleans into one flags int */
shaderInfo_t *si; shaderInfo_t *si;
vec3_t origin; vec3_t origin;
@ -1757,7 +1758,7 @@ int ClusterForPointExtFilter( vec3_t point, float epsilo
int ShaderForPointInLeaf( vec3_t point, int leafNum, float epsilon, int wantContentFlags, int wantSurfaceFlags, int *contentFlags, int *surfaceFlags ); int ShaderForPointInLeaf( vec3_t point, int leafNum, float epsilon, int wantContentFlags, int wantSurfaceFlags, int *contentFlags, int *surfaceFlags );
void SetupEnvelopes( bool forGrid, bool fastFlag ); void SetupEnvelopes( bool forGrid, bool fastFlag );
void FreeTraceLights( trace_t *trace ); void FreeTraceLights( trace_t *trace );
void CreateTraceLightsForBounds( vec3_t mins, vec3_t maxs, vec3_t normal, int numClusters, int *clusters, int flags, trace_t *trace ); void CreateTraceLightsForBounds( vec3_t mins, vec3_t maxs, vec3_t normal, int numClusters, int *clusters, LightFlags flags, trace_t *trace );
void CreateTraceLightsForSurface( int num, trace_t *trace ); void CreateTraceLightsForSurface( int num, trace_t *trace );
@ -2073,7 +2074,7 @@ Q_EXTERN fog_t mapFogs[ MAX_MAP_FOGS ];
Q_EXTERN entity_t *mapEnt; Q_EXTERN entity_t *mapEnt;
Q_EXTERN brush_t *buildBrush; Q_EXTERN brush_t *buildBrush;
Q_EXTERN brushType_t g_brushType; Q_EXTERN EBrushType g_brushType Q_ASSIGN( EBrushType::Undefined );
Q_EXTERN int numStrippedLights Q_ASSIGN( 0 ); Q_EXTERN int numStrippedLights Q_ASSIGN( 0 );

View File

@ -75,64 +75,64 @@ void ColorMod( colorMod_t *cm, int numVerts, bspDrawVert_t *drawVerts ){
/* switch on type */ /* switch on type */
switch ( cm2->type ) switch ( cm2->type )
{ {
case CM_COLOR_SET: case EColorMod::ColorSet:
VectorClear( mult ); VectorClear( mult );
VectorScale( cm2->data, 255.0f, add ); VectorScale( cm2->data, 255.0f, add );
break; break;
case CM_ALPHA_SET: case EColorMod::AlphaSet:
mult[ 3 ] = 0.0f; mult[ 3 ] = 0.0f;
add[ 3 ] = cm2->data[ 0 ] * 255.0f; add[ 3 ] = cm2->data[ 0 ] * 255.0f;
break; break;
case CM_COLOR_SCALE: case EColorMod::ColorScale:
VectorCopy( cm2->data, mult ); VectorCopy( cm2->data, mult );
break; break;
case CM_ALPHA_SCALE: case EColorMod::AlphaScale:
mult[ 3 ] = cm2->data[ 0 ]; mult[ 3 ] = cm2->data[ 0 ];
break; break;
case CM_COLOR_DOT_PRODUCT: case EColorMod::ColorDotProduct:
c = DotProduct( dv->normal, cm2->data ); c = DotProduct( dv->normal, cm2->data );
VectorSet( mult, c, c, c ); VectorSet( mult, c, c, c );
break; break;
case CM_COLOR_DOT_PRODUCT_SCALE: case EColorMod::ColorDotProductScale:
c = DotProduct( dv->normal, cm2->data ); c = DotProduct( dv->normal, cm2->data );
c = ( c - cm2->data[3] ) / ( cm2->data[4] - cm2->data[3] ); c = ( c - cm2->data[3] ) / ( cm2->data[4] - cm2->data[3] );
VectorSet( mult, c, c, c ); VectorSet( mult, c, c, c );
break; break;
case CM_ALPHA_DOT_PRODUCT: case EColorMod::AlphaDotProduct:
mult[ 3 ] = DotProduct( dv->normal, cm2->data ); mult[ 3 ] = DotProduct( dv->normal, cm2->data );
break; break;
case CM_ALPHA_DOT_PRODUCT_SCALE: case EColorMod::AlphaDotProductScale:
c = DotProduct( dv->normal, cm2->data ); c = DotProduct( dv->normal, cm2->data );
c = ( c - cm2->data[3] ) / ( cm2->data[4] - cm2->data[3] ); c = ( c - cm2->data[3] ) / ( cm2->data[4] - cm2->data[3] );
mult[ 3 ] = c; mult[ 3 ] = c;
break; break;
case CM_COLOR_DOT_PRODUCT_2: case EColorMod::ColorDotProduct2:
c = DotProduct( dv->normal, cm2->data ); c = DotProduct( dv->normal, cm2->data );
c *= c; c *= c;
VectorSet( mult, c, c, c ); VectorSet( mult, c, c, c );
break; break;
case CM_COLOR_DOT_PRODUCT_2_SCALE: case EColorMod::ColorDotProduct2Scale:
c = DotProduct( dv->normal, cm2->data ); c = DotProduct( dv->normal, cm2->data );
c *= c; c *= c;
c = ( c - cm2->data[3] ) / ( cm2->data[4] - cm2->data[3] ); c = ( c - cm2->data[3] ) / ( cm2->data[4] - cm2->data[3] );
VectorSet( mult, c, c, c ); VectorSet( mult, c, c, c );
break; break;
case CM_ALPHA_DOT_PRODUCT_2: case EColorMod::AlphaDotProduct2:
mult[ 3 ] = DotProduct( dv->normal, cm2->data ); mult[ 3 ] = DotProduct( dv->normal, cm2->data );
mult[ 3 ] *= mult[ 3 ]; mult[ 3 ] *= mult[ 3 ];
break; break;
case CM_ALPHA_DOT_PRODUCT_2_SCALE: case EColorMod::AlphaDotProduct2Scale:
c = DotProduct( dv->normal, cm2->data ); c = DotProduct( dv->normal, cm2->data );
c *= c; c *= c;
c = ( c - cm2->data[3] ) / ( cm2->data[4] - cm2->data[3] ); c = ( c - cm2->data[3] ) / ( cm2->data[4] - cm2->data[3] );
@ -433,7 +433,7 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, const char *find, char *replace ){
srcShaderText = si->shaderText; srcShaderText = si->shaderText;
/* et: implicitMap */ /* et: implicitMap */
if ( si->implicitMap == IM_OPAQUE ) { if ( si->implicitMap == EImplicitMap::Opaque ) {
srcShaderText = temp; srcShaderText = temp;
sprintf( temp, "\n" sprintf( temp, "\n"
"{ // Q3Map2 defaulted (implicitMap)\n" "{ // Q3Map2 defaulted (implicitMap)\n"
@ -452,7 +452,7 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, const char *find, char *replace ){
} }
/* et: implicitMask */ /* et: implicitMask */
else if ( si->implicitMap == IM_MASKED ) { else if ( si->implicitMap == EImplicitMap::Masked ) {
srcShaderText = temp; srcShaderText = temp;
sprintf( temp, "\n" sprintf( temp, "\n"
"{ // Q3Map2 defaulted (implicitMask)\n" "{ // Q3Map2 defaulted (implicitMask)\n"
@ -480,7 +480,7 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, const char *find, char *replace ){
} }
/* et: implicitBlend */ /* et: implicitBlend */
else if ( si->implicitMap == IM_BLEND ) { else if ( si->implicitMap == EImplicitMap::Blend ) {
srcShaderText = temp; srcShaderText = temp;
sprintf( temp, "\n" sprintf( temp, "\n"
"{ // Q3Map2 defaulted (implicitBlend)\n" "{ // Q3Map2 defaulted (implicitBlend)\n"
@ -1169,7 +1169,7 @@ static void ParseShaderFile( const char *filename ){
/* ydnar: enemy territory implicit shaders */ /* ydnar: enemy territory implicit shaders */
else if ( striEqual( token, "implicitMap" ) ) { else if ( striEqual( token, "implicitMap" ) ) {
si->implicitMap = IM_OPAQUE; si->implicitMap = EImplicitMap::Opaque;
GetTokenAppend( shaderText, false ); GetTokenAppend( shaderText, false );
if ( strEqual( token, "-" ) ) { if ( strEqual( token, "-" ) ) {
si->implicitImagePath = si->shader; si->implicitImagePath = si->shader;
@ -1180,7 +1180,7 @@ static void ParseShaderFile( const char *filename ){
} }
else if ( striEqual( token, "implicitMask" ) ) { else if ( striEqual( token, "implicitMask" ) ) {
si->implicitMap = IM_MASKED; si->implicitMap = EImplicitMap::Masked;
GetTokenAppend( shaderText, false ); GetTokenAppend( shaderText, false );
if ( strEqual( token, "-" ) ) { if ( strEqual( token, "-" ) ) {
si->implicitImagePath = si->shader; si->implicitImagePath = si->shader;
@ -1191,7 +1191,7 @@ static void ParseShaderFile( const char *filename ){
} }
else if ( striEqual( token, "implicitBlend" ) ) { else if ( striEqual( token, "implicitBlend" ) ) {
si->implicitMap = IM_MASKED; si->implicitMap = EImplicitMap::Blend;
GetTokenAppend( shaderText, false ); GetTokenAppend( shaderText, false );
if ( strEqual( token, "-" ) ) { if ( strEqual( token, "-" ) ) {
si->implicitImagePath = si->shader; si->implicitImagePath = si->shader;
@ -1741,14 +1741,14 @@ static void ParseShaderFile( const char *filename ){
/* alpha set|const A */ /* alpha set|const A */
if ( alpha && ( striEqual( token, "set" ) || striEqual( token, "const" ) ) ) { if ( alpha && ( striEqual( token, "set" ) || striEqual( token, "const" ) ) ) {
cm->type = CM_ALPHA_SET; cm->type = EColorMod::AlphaSet;
GetTokenAppend( shaderText, false ); GetTokenAppend( shaderText, false );
cm->data[ 0 ] = atof( token ); cm->data[ 0 ] = atof( token );
} }
/* color|rgb set|const ( X Y Z ) */ /* color|rgb set|const ( X Y Z ) */
else if ( striEqual( token, "set" ) || striEqual( token, "const" ) ) { else if ( striEqual( token, "set" ) || striEqual( token, "const" ) ) {
cm->type = CM_COLOR_SET; cm->type = EColorMod::ColorSet;
Parse1DMatrixAppend( shaderText, 3, cm->data ); Parse1DMatrixAppend( shaderText, 3, cm->data );
if ( colorsRGB ) { if ( colorsRGB ) {
cm->data[0] = Image_LinearFloatFromsRGBFloat( cm->data[0] ); cm->data[0] = Image_LinearFloatFromsRGBFloat( cm->data[0] );
@ -1759,45 +1759,45 @@ static void ParseShaderFile( const char *filename ){
/* alpha scale A */ /* alpha scale A */
else if ( alpha && striEqual( token, "scale" ) ) { else if ( alpha && striEqual( token, "scale" ) ) {
cm->type = CM_ALPHA_SCALE; cm->type = EColorMod::AlphaScale;
GetTokenAppend( shaderText, false ); GetTokenAppend( shaderText, false );
cm->data[ 0 ] = atof( token ); cm->data[ 0 ] = atof( token );
} }
/* color|rgb scale ( X Y Z ) */ /* color|rgb scale ( X Y Z ) */
else if ( striEqual( token, "scale" ) ) { else if ( striEqual( token, "scale" ) ) {
cm->type = CM_COLOR_SCALE; cm->type = EColorMod::ColorScale;
Parse1DMatrixAppend( shaderText, 3, cm->data ); Parse1DMatrixAppend( shaderText, 3, cm->data );
} }
/* dotProduct ( X Y Z ) */ /* dotProduct ( X Y Z ) */
else if ( striEqual( token, "dotProduct" ) ) { else if ( striEqual( token, "dotProduct" ) ) {
cm->type = alpha? CM_ALPHA_DOT_PRODUCT : CM_COLOR_DOT_PRODUCT; cm->type = alpha? EColorMod::AlphaDotProduct : EColorMod::ColorDotProduct;
Parse1DMatrixAppend( shaderText, 3, cm->data ); Parse1DMatrixAppend( shaderText, 3, cm->data );
} }
/* dotProductScale ( X Y Z MIN MAX ) */ /* dotProductScale ( X Y Z MIN MAX ) */
else if ( striEqual( token, "dotProductScale" ) ) { else if ( striEqual( token, "dotProductScale" ) ) {
cm->type = alpha? CM_ALPHA_DOT_PRODUCT_SCALE : CM_COLOR_DOT_PRODUCT_SCALE; cm->type = alpha? EColorMod::AlphaDotProductScale : EColorMod::ColorDotProductScale;
Parse1DMatrixAppend( shaderText, 5, cm->data ); Parse1DMatrixAppend( shaderText, 5, cm->data );
} }
/* dotProduct2 ( X Y Z ) */ /* dotProduct2 ( X Y Z ) */
else if ( striEqual( token, "dotProduct2" ) ) { else if ( striEqual( token, "dotProduct2" ) ) {
cm->type = alpha? CM_ALPHA_DOT_PRODUCT_2 : CM_COLOR_DOT_PRODUCT_2; cm->type = alpha? EColorMod::AlphaDotProduct2 : EColorMod::ColorDotProduct2;
Parse1DMatrixAppend( shaderText, 3, cm->data ); Parse1DMatrixAppend( shaderText, 3, cm->data );
} }
/* dotProduct2scale ( X Y Z MIN MAX ) */ /* dotProduct2scale ( X Y Z MIN MAX ) */
else if ( striEqual( token, "dotProduct2scale" ) ) { else if ( striEqual( token, "dotProduct2scale" ) ) {
cm->type = alpha? CM_ALPHA_DOT_PRODUCT_2_SCALE : CM_COLOR_DOT_PRODUCT_2_SCALE; cm->type = alpha? EColorMod::AlphaDotProduct2Scale : EColorMod::ColorDotProduct2Scale;
Parse1DMatrixAppend( shaderText, 5, cm->data ); Parse1DMatrixAppend( shaderText, 5, cm->data );
} }
/* volume */ /* volume */
else if ( striEqual( token, "volume" ) ) { else if ( striEqual( token, "volume" ) ) {
/* special stub mode for flagging volume brushes */ /* special stub mode for flagging volume brushes */
cm->type = CM_VOLUME; cm->type = EColorMod::Volume;
} }
/* unknown */ /* unknown */

View File

@ -970,7 +970,7 @@ mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, windin
} }
/* brush primitive texturing */ /* brush primitive texturing */
else if ( g_brushType == BPRIMIT_BP ) { else if ( g_brushType == EBrushType::Bp ) {
/* calculate texture s/t from brush primitive texture matrix */ /* calculate texture s/t from brush primitive texture matrix */
x = DotProduct( vTranslated, texX ); x = DotProduct( vTranslated, texX );
y = DotProduct( vTranslated, texY ); y = DotProduct( vTranslated, texY );