must be within an epsilon distance of the plane
*/
-int FindFloatPlane( vec3_t normal, vec_t dist, int numPoints, vec3_t *points ) // NOTE: this has a side effect on the normal. Good or bad?
+int FindFloatPlane( vec3_t innormal, vec_t dist, int numPoints, vec3_t *points ) // NOTE: this has a side effect on the normal. Good or bad?
#ifdef USE_HASHING
plane_t *p;
vec_t d;
vec3_t centerofweight;
+ vec3_t normal;
VectorClear(centerofweight);
for(i = 0; i < numPoints; ++i)
VectorMA(centerofweight, 1.0 / numPoints, points[i], centerofweight);
/* hash the plane */
+ VectorCopy(innormal, normal);
SnapPlane( normal, &dist, centerofweight );
hash = (PLANE_HASHES - 1) & (int) fabs( dist );
{
int i;
plane_t *p;
+ vec3_t normal;
vec3_t centerofweight;
for(i = 0; i < numPoints; ++i)
VectorMA(centerofweight, 1.0 / numPoints, points[i], centerofweight);
+ VectorCopy(innormal, normal);
SnapPlane( normal, &dist, centerofweight );
for( i = 0, p = mapplanes; i < nummapplanes; i++, p++ )
{
continue;
if( s->contentFlags != contentFlags || s->compileFlags != compileFlags )
mixed = qtrue;
+
+ contentFlags |= s->contentFlags;
+ compileFlags |= s->compileFlags;
}
/* ydnar: getting rid of this stupid warning */
SetKeyValue(ent, "origin", string);
}
-brush_t *FinishBrush( void )
+brush_t *FinishBrush( qboolean noCollapseGroups )
{
brush_t *b;
after the entire entity is parsed, the planenums and texinfos will be adjusted for the origin brush */
if( buildBrush->compileFlags & C_ORIGIN )
{
- char string[ 32 ];
vec3_t origin;
Sys_Printf( "Entity %i, Brush %i: origin brush detected\n",
}
/* add bevel planes */
- AddBrushBevels();
+ if(!noCollapseGroups)
+ AddBrushBevels();
/* keep it */
b = CopyBrush( buildBrush );
int planenum;
shaderInfo_t *si;
vec_t shift[ 2 ];
- vec_t rotate;
+ vec_t rotate = 0;
vec_t scale[ 2 ];
char name[ MAX_QPATH ];
char shader[ MAX_QPATH ];
parses a brush out of a map file and sets it up
*/
-static void ParseBrush( qboolean onlyLights )
+static void ParseBrush( qboolean onlyLights, qboolean noCollapseGroups )
{
brush_t *b;
}
/* finish the brush */
- b = FinishBrush();
+ b = FinishBrush(noCollapseGroups);
}
parses a single entity out of a map file
*/
-static qboolean ParseMapEntity( qboolean onlyLights )
+static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups )
{
epair_t *ep;
const char *classname, *value;
- float lightmapScale;
+ float lightmapScale, shadeAngle;
+ int lightmapSampleSize;
char shader[ MAX_QPATH ];
shaderInfo_t *celShader = NULL;
brush_t *brush;
g_bBrushPrimit = BPRIMIT_NEWBRUSHES;
/* parse brush primitive */
- ParseBrush( onlyLights );
+ ParseBrush( onlyLights, noCollapseGroups );
}
else
{
/* parse old brush format */
UnGetToken();
- ParseBrush( onlyLights );
+ ParseBrush( onlyLights, noCollapseGroups );
}
entitySourceBrushes++;
}
/* vortex: added _ls key (short name of lightmapscale) */
/* ydnar: get lightmap scaling value for this entity */
+ lightmapScale = 0.0f;
if( strcmp( "", ValueForKey( mapEnt, "lightmapscale" ) ) ||
strcmp( "", ValueForKey( mapEnt, "_lightmapscale" ) ) ||
strcmp( "", ValueForKey( mapEnt, "_ls" ) ) )
lightmapScale = FloatForKey( mapEnt, "_lightmapscale" );
if( lightmapScale <= 0.0f )
lightmapScale = FloatForKey( mapEnt, "_ls" );
+ if( lightmapScale < 0.0f )
+ lightmapScale = 0.0f;
if( lightmapScale > 0.0f )
Sys_Printf( "Entity %d (%s) has lightmap scale of %.4f\n", mapEnt->mapEntityNum, classname, lightmapScale );
}
- else
- lightmapScale = 0.0f;
/* ydnar: get cel shader :) for this entity */
value = ValueForKey( mapEnt, "_celshader" );
value = ValueForKey( &entities[ 0 ], "_celshader" );
if( value[ 0 ] != '\0' )
{
- sprintf( shader, "textures/%s", value );
- celShader = ShaderInfoForShader( shader );
- Sys_Printf( "Entity %d (%s) has cel shader %s\n", mapEnt->mapEntityNum, classname, celShader->shader );
+ if(strcmp(value, "none"))
+ {
+ sprintf( shader, "textures/%s", value );
+ celShader = ShaderInfoForShader( shader );
+ Sys_Printf( "Entity %d (%s) has cel shader %s\n", mapEnt->mapEntityNum, classname, celShader->shader );
+ }
+ else
+ {
+ celShader = NULL;
+ }
}
else
- celShader = *globalCelShader ? ShaderInfoForShader(globalCelShader) : NULL;
+ celShader = (*globalCelShader ? ShaderInfoForShader(globalCelShader) : NULL);
+
+ /* jal : entity based _shadeangle */
+ shadeAngle = 0.0f;
+ if ( strcmp( "", ValueForKey( mapEnt, "_shadeangle" ) ) )
+ shadeAngle = FloatForKey( mapEnt, "_shadeangle" );
+ /* vortex' aliases */
+ else if ( strcmp( "", ValueForKey( mapEnt, "_smoothnormals" ) ) )
+ shadeAngle = FloatForKey( mapEnt, "_smoothnormals" );
+ else if ( strcmp( "", ValueForKey( mapEnt, "_sn" ) ) )
+ shadeAngle = FloatForKey( mapEnt, "_sn" );
+ else if ( strcmp( "", ValueForKey( mapEnt, "_smooth" ) ) )
+ shadeAngle = FloatForKey( mapEnt, "_smooth" );
+
+ if( shadeAngle < 0.0f )
+ shadeAngle = 0.0f;
+
+ if( shadeAngle > 0.0f )
+ Sys_Printf( "Entity %d (%s) has shading angle of %.4f\n", mapEnt->mapEntityNum, classname, shadeAngle );
+
+ /* jal : entity based _samplesize */
+ lightmapSampleSize = 0;
+ if ( strcmp( "", ValueForKey( mapEnt, "_lightmapsamplesize" ) ) )
+ lightmapSampleSize = IntForKey( mapEnt, "_lightmapsamplesize" );
+ else if ( strcmp( "", ValueForKey( mapEnt, "_samplesize" ) ) )
+ lightmapSampleSize = IntForKey( mapEnt, "_samplesize" );
+
+ if( lightmapSampleSize < 0 )
+ lightmapSampleSize = 0;
+
+ if( lightmapSampleSize > 0 )
+ Sys_Printf( "Entity %d (%s) has lightmap sample size of %d\n", mapEnt->mapEntityNum, classname, lightmapSampleSize );
/* attach stuff to everything in the entity */
for( brush = mapEnt->brushes; brush != NULL; brush = brush->next )
brush->entityNum = mapEnt->mapEntityNum;
brush->castShadows = castShadows;
brush->recvShadows = recvShadows;
+ brush->lightmapSampleSize = lightmapSampleSize;
brush->lightmapScale = lightmapScale;
brush->celShader = celShader;
+ brush->shadeAngleDegrees = shadeAngle;
}
for( patch = mapEnt->patches; patch != NULL; patch = patch->next )
patch->entityNum = mapEnt->mapEntityNum;
patch->castShadows = castShadows;
patch->recvShadows = recvShadows;
+ patch->lightmapSampleSize = lightmapSampleSize;
patch->lightmapScale = lightmapScale;
patch->celShader = celShader;
}
AdjustBrushesForOrigin( mapEnt );
/* group_info entities are just for editor grouping (fixme: leak!) */
- if( !Q_stricmp( "group_info", classname ) )
+ if( !noCollapseGroups && !Q_stricmp( "group_info", classname ) )
{
numEntities--;
return qtrue;
}
/* group entities are just for editor convenience, toss all brushes into worldspawn */
- if( funcGroup )
+ if( !noCollapseGroups && funcGroup )
{
MoveBrushesToWorld( mapEnt );
numEntities--;
loads a map file into a list of entities
*/
-void LoadMapFile( char *filename, qboolean onlyLights )
+void LoadMapFile( char *filename, qboolean onlyLights, qboolean noCollapseGroups )
{
FILE *file;
brush_t *b;
- int oldNumEntities, numMapBrushes;
+ int oldNumEntities = 0, numMapBrushes;
/* note it */
buildBrush = AllocBrush( MAX_BUILD_SIDES );
/* parse the map file */
- while( ParseMapEntity( onlyLights ) );
+ while( ParseMapEntity( onlyLights, noCollapseGroups ) );
/* light loading */
if( onlyLights )