minor tweaks
This commit is contained in:
parent
357f67f237
commit
99f4a4a767
|
|
@ -581,7 +581,6 @@ void ProcessSubModel( void ){
|
||||||
|
|
||||||
void ProcessModels( void ){
|
void ProcessModels( void ){
|
||||||
bool oldVerbose;
|
bool oldVerbose;
|
||||||
entity_t *entity;
|
|
||||||
|
|
||||||
|
|
||||||
/* preserve -v setting */
|
/* preserve -v setting */
|
||||||
|
|
@ -597,8 +596,8 @@ void ProcessModels( void ){
|
||||||
for ( mapEntityNum = 0; mapEntityNum < entities.size(); mapEntityNum++ )
|
for ( mapEntityNum = 0; mapEntityNum < entities.size(); mapEntityNum++ )
|
||||||
{
|
{
|
||||||
/* get entity */
|
/* get entity */
|
||||||
entity = &entities[ mapEntityNum ];
|
const entity_t& entity = entities[ mapEntityNum ];
|
||||||
if ( entity->brushes == NULL && entity->patches == NULL ) {
|
if ( entity.brushes == NULL && entity.patches == NULL ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -557,8 +557,7 @@ bool ParseEntity( void ){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create new entity */
|
/* create new entity */
|
||||||
entities.emplace_back();
|
mapEnt = &entities.emplace_back();
|
||||||
mapEnt = &entities.back();
|
|
||||||
|
|
||||||
/* parse */
|
/* parse */
|
||||||
while ( 1 )
|
while ( 1 )
|
||||||
|
|
|
||||||
|
|
@ -789,16 +789,16 @@ void AddBrushBevels( void ){
|
||||||
and links it to the current entity
|
and links it to the current entity
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void MergeOrigin( entity_t *ent, const Vector3& origin ){
|
static void MergeOrigin( entity_t& ent, const Vector3& origin ){
|
||||||
char string[128];
|
char string[128];
|
||||||
|
|
||||||
/* we have not parsed the brush completely yet... */
|
/* we have not parsed the brush completely yet... */
|
||||||
ent->origin = ent->vectorForKey( "origin" ) + origin - ent->originbrush_origin;
|
ent.origin = ent.vectorForKey( "origin" ) + origin - ent.originbrush_origin;
|
||||||
|
|
||||||
ent->originbrush_origin = origin;
|
ent.originbrush_origin = origin;
|
||||||
|
|
||||||
sprintf( string, "%f %f %f", ent->origin[0], ent->origin[1], ent->origin[2] );
|
sprintf( string, "%f %f %f", ent.origin[0], ent.origin[1], ent.origin[2] );
|
||||||
ent->setKeyValue( "origin", string );
|
ent.setKeyValue( "origin", string );
|
||||||
}
|
}
|
||||||
|
|
||||||
brush_t *FinishBrush( bool noCollapseGroups ){
|
brush_t *FinishBrush( bool noCollapseGroups ){
|
||||||
|
|
@ -822,7 +822,7 @@ brush_t *FinishBrush( bool noCollapseGroups ){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MergeOrigin( &entities.back(), buildBrush->minmax.origin() );
|
MergeOrigin( entities.back(), buildBrush->minmax.origin() );
|
||||||
|
|
||||||
/* don't keep this brush */
|
/* don't keep this brush */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -1602,8 +1602,7 @@ static bool ParseMapEntity( bool onlyLights, bool noCollapseGroups ){
|
||||||
|
|
||||||
/* setup */
|
/* setup */
|
||||||
entitySourceBrushes = 0;
|
entitySourceBrushes = 0;
|
||||||
entities.emplace_back();
|
mapEnt = &entities.emplace_back();
|
||||||
mapEnt = &entities.back();
|
|
||||||
|
|
||||||
/* ydnar: true entity numbering */
|
/* ydnar: true entity numbering */
|
||||||
mapEnt->mapEntityNum = numMapEntities;
|
mapEnt->mapEntityNum = numMapEntities;
|
||||||
|
|
|
||||||
|
|
@ -1430,27 +1430,27 @@ void AddTriangleModels( entity_t *eparent ){
|
||||||
for ( std::size_t i = 1; i < entities.size(); ++i )
|
for ( std::size_t i = 1; i < entities.size(); ++i )
|
||||||
{
|
{
|
||||||
/* get entity */
|
/* get entity */
|
||||||
entity_t *e = &entities[ i ];
|
const entity_t& e = entities[ i ];
|
||||||
|
|
||||||
/* convert misc_models into raw geometry */
|
/* convert misc_models into raw geometry */
|
||||||
if ( !e->classname_is( "misc_model" ) ) {
|
if ( !e.classname_is( "misc_model" ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ydnar: added support for md3 models on non-worldspawn models */
|
/* ydnar: added support for md3 models on non-worldspawn models */
|
||||||
if ( !strEqual( e->valueForKey( "target" ), targetName ) ) {
|
if ( !strEqual( e.valueForKey( "target" ), targetName ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get model name */
|
/* get model name */
|
||||||
const char *model;
|
const char *model;
|
||||||
if ( !e->read_keyvalue( model, "model" ) ) {
|
if ( !e.read_keyvalue( model, "model" ) ) {
|
||||||
Sys_Warning( "entity#%d misc_model without a model key\n", e->mapEntityNum );
|
Sys_Warning( "entity#%d misc_model without a model key\n", e.mapEntityNum );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get model frame */
|
/* get model frame */
|
||||||
const int frame = e->intForKey( "_frame", "frame" );
|
const int frame = e.intForKey( "_frame", "frame" );
|
||||||
|
|
||||||
int castShadows, recvShadows;
|
int castShadows, recvShadows;
|
||||||
if ( eparent == &entities[0] ) { /* worldspawn (and func_groups) default to cast/recv shadows in worldspawn group */
|
if ( eparent == &entities[0] ) { /* worldspawn (and func_groups) default to cast/recv shadows in worldspawn group */
|
||||||
|
|
@ -1463,26 +1463,26 @@ void AddTriangleModels( entity_t *eparent ){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get explicit shadow flags */
|
/* get explicit shadow flags */
|
||||||
GetEntityShadowFlags( e, eparent, &castShadows, &recvShadows );
|
GetEntityShadowFlags( &e, eparent, &castShadows, &recvShadows );
|
||||||
|
|
||||||
/* get spawnflags */
|
/* get spawnflags */
|
||||||
const int spawnFlags = e->intForKey( "spawnflags" );
|
const int spawnFlags = e.intForKey( "spawnflags" );
|
||||||
|
|
||||||
/* get origin */
|
/* get origin */
|
||||||
const Vector3 origin = e->vectorForKey( "origin" ) - eparent->origin; /* offset by parent */
|
const Vector3 origin = e.vectorForKey( "origin" ) - eparent->origin; /* offset by parent */
|
||||||
|
|
||||||
/* get scale */
|
/* get scale */
|
||||||
Vector3 scale( 1 );
|
Vector3 scale( 1 );
|
||||||
if( !e->read_keyvalue( scale, "modelscale_vec" ) )
|
if( !e.read_keyvalue( scale, "modelscale_vec" ) )
|
||||||
if( e->read_keyvalue( scale[0], "modelscale" ) )
|
if( e.read_keyvalue( scale[0], "modelscale" ) )
|
||||||
scale[1] = scale[2] = scale[0];
|
scale[1] = scale[2] = scale[0];
|
||||||
|
|
||||||
/* get "angle" (yaw) or "angles" (pitch yaw roll), store as (roll pitch yaw) */
|
/* get "angle" (yaw) or "angles" (pitch yaw roll), store as (roll pitch yaw) */
|
||||||
const char *value;
|
const char *value;
|
||||||
Vector3 angles( 0 );
|
Vector3 angles( 0 );
|
||||||
if ( !e->read_keyvalue( value, "angles" ) ||
|
if ( !e.read_keyvalue( value, "angles" ) ||
|
||||||
3 != sscanf( value, "%f %f %f", &angles[ 1 ], &angles[ 2 ], &angles[ 0 ] ) )
|
3 != sscanf( value, "%f %f %f", &angles[ 1 ], &angles[ 2 ], &angles[ 0 ] ) )
|
||||||
e->read_keyvalue( angles[ 2 ], "angle" );
|
e.read_keyvalue( angles[ 2 ], "angle" );
|
||||||
|
|
||||||
/* set transform matrix (thanks spog) */
|
/* set transform matrix (thanks spog) */
|
||||||
Matrix4 transform( g_matrix4_identity );
|
Matrix4 transform( g_matrix4_identity );
|
||||||
|
|
@ -1490,7 +1490,7 @@ void AddTriangleModels( entity_t *eparent ){
|
||||||
|
|
||||||
/* get shader remappings */
|
/* get shader remappings */
|
||||||
std::list<remap_t> remaps;
|
std::list<remap_t> remaps;
|
||||||
for ( const auto& ep : e->epairs )
|
for ( const auto& ep : e.epairs )
|
||||||
{
|
{
|
||||||
/* look for keys prefixed with "_remap" */
|
/* look for keys prefixed with "_remap" */
|
||||||
if ( striEqualPrefix( ep.key.c_str(), "_remap" ) ) {
|
if ( striEqualPrefix( ep.key.c_str(), "_remap" ) ) {
|
||||||
|
|
@ -1529,7 +1529,7 @@ void AddTriangleModels( entity_t *eparent ){
|
||||||
|
|
||||||
/* ydnar: cel shader support */
|
/* ydnar: cel shader support */
|
||||||
shaderInfo_t *celShader;
|
shaderInfo_t *celShader;
|
||||||
if( e->read_keyvalue( value, "_celshader" ) ||
|
if( e.read_keyvalue( value, "_celshader" ) ||
|
||||||
entities[ 0 ].read_keyvalue( value, "_celshader" ) ){
|
entities[ 0 ].read_keyvalue( value, "_celshader" ) ){
|
||||||
celShader = ShaderInfoForShader( String64()( "textures/", value ) );
|
celShader = ShaderInfoForShader( String64()( "textures/", value ) );
|
||||||
}
|
}
|
||||||
|
|
@ -1538,25 +1538,25 @@ void AddTriangleModels( entity_t *eparent ){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* jal : entity based _samplesize */
|
/* jal : entity based _samplesize */
|
||||||
const int lightmapSampleSize = std::max( 0, e->intForKey( "_lightmapsamplesize", "_samplesize", "_ss" ) );
|
const int lightmapSampleSize = std::max( 0, e.intForKey( "_lightmapsamplesize", "_samplesize", "_ss" ) );
|
||||||
if ( lightmapSampleSize != 0 )
|
if ( lightmapSampleSize != 0 )
|
||||||
Sys_Printf( "misc_model has lightmap sample size of %.d\n", lightmapSampleSize );
|
Sys_Printf( "misc_model has lightmap sample size of %.d\n", lightmapSampleSize );
|
||||||
|
|
||||||
/* get lightmap scale */
|
/* get lightmap scale */
|
||||||
const float lightmapScale = std::max( 0.f, e->floatForKey( "lightmapscale", "_lightmapscale", "_ls" ) );
|
const float lightmapScale = std::max( 0.f, e.floatForKey( "lightmapscale", "_lightmapscale", "_ls" ) );
|
||||||
if ( lightmapScale != 0 )
|
if ( lightmapScale != 0 )
|
||||||
Sys_Printf( "misc_model has lightmap scale of %.4f\n", lightmapScale );
|
Sys_Printf( "misc_model has lightmap scale of %.4f\n", lightmapScale );
|
||||||
|
|
||||||
/* jal : entity based _shadeangle */
|
/* jal : entity based _shadeangle */
|
||||||
const float shadeAngle = std::max( 0.f, e->floatForKey( "_shadeangle",
|
const float shadeAngle = std::max( 0.f, e.floatForKey( "_shadeangle",
|
||||||
"_smoothnormals", "_sn", "_sa", "_smooth" ) ); /* vortex' aliases */
|
"_smoothnormals", "_sn", "_sa", "_smooth" ) ); /* vortex' aliases */
|
||||||
if ( shadeAngle != 0 )
|
if ( shadeAngle != 0 )
|
||||||
Sys_Printf( "misc_model has shading angle of %.4f\n", shadeAngle );
|
Sys_Printf( "misc_model has shading angle of %.4f\n", shadeAngle );
|
||||||
|
|
||||||
const int skin = e->intForKey( "_skin", "skin" );
|
const int skin = e.intForKey( "_skin", "skin" );
|
||||||
|
|
||||||
float clipDepth = clipDepthGlobal;
|
float clipDepth = clipDepthGlobal;
|
||||||
if ( e->read_keyvalue( clipDepth, "_clipdepth" ) )
|
if ( e.read_keyvalue( clipDepth, "_clipdepth" ) )
|
||||||
Sys_Printf( "misc_model %s has autoclip depth of %.3f\n", model, clipDepth );
|
Sys_Printf( "misc_model %s has autoclip depth of %.3f\n", model, clipDepth );
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -991,13 +991,13 @@ struct epair_t
|
||||||
|
|
||||||
struct entity_t
|
struct entity_t
|
||||||
{
|
{
|
||||||
Vector3 origin;
|
Vector3 origin{ 0 };
|
||||||
brush_t *brushes, *lastBrush, *colorModBrushes;
|
brush_t *brushes, *lastBrush, *colorModBrushes;
|
||||||
parseMesh_t *patches;
|
parseMesh_t *patches;
|
||||||
int mapEntityNum, firstDrawSurf;
|
int mapEntityNum, firstDrawSurf;
|
||||||
int firstBrush, numBrushes; /* only valid during BSP compile */
|
int firstBrush, numBrushes; /* only valid during BSP compile */
|
||||||
std::list<epair_t> epairs;
|
std::list<epair_t> epairs;
|
||||||
Vector3 originbrush_origin;
|
Vector3 originbrush_origin{ 0 };
|
||||||
|
|
||||||
void setKeyValue( const char *key, const char *value );
|
void setKeyValue( const char *key, const char *value );
|
||||||
const char *valueForKey( const char *key ) const;
|
const char *valueForKey( const char *key ) const;
|
||||||
|
|
|
||||||
|
|
@ -271,7 +271,6 @@ void SetModelNumbers( void ){
|
||||||
|
|
||||||
void SetLightStyles( void ){
|
void SetLightStyles( void ){
|
||||||
int j, numStyles;
|
int j, numStyles;
|
||||||
entity_t *e;
|
|
||||||
char value[ 10 ];
|
char value[ 10 ];
|
||||||
char lightTargets[ MAX_SWITCHED_LIGHTS ][ 64 ];
|
char lightTargets[ MAX_SWITCHED_LIGHTS ][ 64 ];
|
||||||
int lightStyles[ MAX_SWITCHED_LIGHTS ];
|
int lightStyles[ MAX_SWITCHED_LIGHTS ];
|
||||||
|
|
@ -288,16 +287,16 @@ void SetLightStyles( void ){
|
||||||
numStyles = 0;
|
numStyles = 0;
|
||||||
for ( std::size_t i = 1; i < entities.size(); ++i )
|
for ( std::size_t i = 1; i < entities.size(); ++i )
|
||||||
{
|
{
|
||||||
e = &entities[ i ];
|
entity_t& e = entities[ i ];
|
||||||
|
|
||||||
if ( !e->classname_prefixed( "light" ) ) {
|
if ( !e.classname_prefixed( "light" ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const char *t;
|
const char *t;
|
||||||
if ( !e->read_keyvalue( t, "targetname" ) ) {
|
if ( !e.read_keyvalue( t, "targetname" ) ) {
|
||||||
/* ydnar: strip the light from the BSP file */
|
/* ydnar: strip the light from the BSP file */
|
||||||
if ( !keepLights ) {
|
if ( !keepLights ) {
|
||||||
e->epairs.clear();
|
e.epairs.clear();
|
||||||
numStrippedLights++;
|
numStrippedLights++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -306,7 +305,7 @@ void SetLightStyles( void ){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get existing style */
|
/* get existing style */
|
||||||
const int style = e->intForKey( "style" );
|
const int style = e.intForKey( "style" );
|
||||||
if ( style < LS_NORMAL || style > LS_NONE ) {
|
if ( style < LS_NORMAL || style > LS_NONE ) {
|
||||||
Error( "Invalid lightstyle (%d) on entity %zu", style, i );
|
Error( "Invalid lightstyle (%d) on entity %zu", style, i );
|
||||||
}
|
}
|
||||||
|
|
@ -329,12 +328,12 @@ void SetLightStyles( void ){
|
||||||
|
|
||||||
/* set explicit style */
|
/* set explicit style */
|
||||||
sprintf( value, "%d", 32 + j );
|
sprintf( value, "%d", 32 + j );
|
||||||
e->setKeyValue( "style", value );
|
e.setKeyValue( "style", value );
|
||||||
|
|
||||||
/* set old style */
|
/* set old style */
|
||||||
if ( style != LS_NORMAL ) {
|
if ( style != LS_NORMAL ) {
|
||||||
sprintf( value, "%d", style );
|
sprintf( value, "%d", style );
|
||||||
e->setKeyValue( "switch_style", value );
|
e.setKeyValue( "switch_style", value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user