X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=tools%2Fquake3%2Fq3map2%2Fsurface_meta.c;h=315b67d1220759aad00ae4b5fa9a8f11625a1753;hb=d40c79f30c4029daa1f92e07b728518911a98d5e;hp=8d3d64562bca72b784b9728b483a4b535476ae9e;hpb=c3fb8e6e16559be1777c4682219cce0ebfb1effd;p=xonotic%2Fnetradiant.git diff --git a/tools/quake3/q3map2/surface_meta.c b/tools/quake3/q3map2/surface_meta.c index 8d3d6456..315b67d1 100644 --- a/tools/quake3/q3map2/surface_meta.c +++ b/tools/quake3/q3map2/surface_meta.c @@ -288,6 +288,7 @@ static void SurfaceToMetaTriangles( mapDrawSurface_t *ds ) src.recvShadows = ds->recvShadows; src.fogNum = ds->fogNum; src.sampleSize = ds->sampleSize; + src.shadeAngleDegrees = ds->shadeAngleDegrees; VectorCopy( ds->lightmapAxis, src.lightmapAxis ); /* copy drawverts */ @@ -312,23 +313,41 @@ TriangulatePatchSurface() creates triangles from a patch */ -void TriangulatePatchSurface( mapDrawSurface_t *ds ) +void TriangulatePatchSurface( entity_t *e , mapDrawSurface_t *ds ) { int iterations, x, y, pw[ 5 ], r; mapDrawSurface_t *dsNew; mesh_t src, *subdivided, *mesh; - - + int forcePatchMeta; + int patchQuality; + int patchSubdivision; + + /* vortex: _patchMeta, _patchQuality, _patchSubdivide support */ + forcePatchMeta = IntForKey(e, "_patchMeta" ); + if (!forcePatchMeta) + forcePatchMeta = IntForKey(e, "patchMeta" ); + patchQuality = IntForKey(e, "_patchQuality" ); + if (!patchQuality) + patchQuality = IntForKey(e, "patchQuality" ); + if (!patchQuality) + patchQuality = 1.0; + patchSubdivision = IntForKey(e, "_patchSubdivide" ); + if (!patchSubdivision) + patchSubdivision = IntForKey(e, "patchSubdivide" ); + /* try to early out */ - if( ds->numVerts == 0 || ds->type != SURFACE_PATCH || patchMeta == qfalse ) + if(ds->numVerts == 0 || ds->type != SURFACE_PATCH || ( patchMeta == qfalse && !forcePatchMeta) ) return; - /* make a mesh from the drawsurf */ src.width = ds->patchWidth; src.height = ds->patchHeight; src.verts = ds->verts; //% subdivided = SubdivideMesh( src, 8, 999 ); - iterations = IterationsForCurve( ds->longestCurve, patchSubdivisions ); + if (patchSubdivision) + iterations = IterationsForCurve( ds->longestCurve, patchSubdivision ); + else + iterations = IterationsForCurve( ds->longestCurve, patchSubdivisions / patchQuality ); + subdivided = SubdivideMesh2( src, iterations ); //% ds->maxIterations /* fit it to the curve and remove colinear verts on rows/columns */ @@ -667,12 +686,12 @@ void MakeEntityMetaTriangles( entity_t *e ) break; case SURFACE_PATCH: - TriangulatePatchSurface( ds ); + TriangulatePatchSurface(e, ds ); break; case SURFACE_TRIANGLES: break; - + case SURFACE_FORCED_META: case SURFACE_META: SurfaceToMetaTriangles( ds ); @@ -988,7 +1007,6 @@ void SmoothMetaTriangles( void ) int indexes[ MAX_SAMPLES ]; vec3_t votes[ MAX_SAMPLES ]; - /* note it */ Sys_FPrintf( SYS_VRB, "--- SmoothMetaTriangles ---\n" ); @@ -1009,11 +1027,18 @@ void SmoothMetaTriangles( void ) and set per-vertex smoothing angle */ for( i = 0, tri = &metaTriangles[ i ]; i < numMetaTriangles; i++, tri++ ) { - /* get shader for shade angle */ + shadeAngle = defaultShadeAngle; + + /* get shade angle from shader */ if( tri->si->shadeAngleDegrees > 0.0f ) shadeAngle = DEG2RAD( tri->si->shadeAngleDegrees ); - else + /* get shade angle from entity */ + else if( tri->shadeAngleDegrees > 0.0f ) + shadeAngle = DEG2RAD( tri->shadeAngleDegrees ); + + if( shadeAngle <= 0.0f ) shadeAngle = defaultShadeAngle; + if( shadeAngle > maxShadeAngle ) maxShadeAngle = shadeAngle; @@ -1201,14 +1226,15 @@ returns the score of the triangle added #define ST_SCORE2 (2 * (ST_SCORE)) #define ADEQUATE_SCORE ((AXIS_MIN) + 1 * (VERT_SCORE)) -#define GOOD_SCORE ((AXIS_MIN) + 2 * (VERT_SCORE) + 4 * (ST_SCORE)) -#define PERFECT_SCORE ((AXIS_MIN) + + 3 * (VERT_SCORE) + (SURFACE_SCORE) + 4 * (ST_SCORE)) +#define GOOD_SCORE ((AXIS_MIN) + 2 * (VERT_SCORE) + 4 * (ST_SCORE)) +#define PERFECT_SCORE ((AXIS_MIN) + 3 * (VERT_SCORE) + (SURFACE_SCORE) + 4 * (ST_SCORE)) +//#define MAX_BBOX_DISTANCE 16 static int AddMetaTriangleToSurface( mapDrawSurface_t *ds, metaTriangle_t *tri, qboolean testAdd ) { int i, score, coincident, ai, bi, ci, oldTexRange[ 2 ]; float lmMax; - vec3_t mins, maxs; + vec3_t mins, maxs, p; qboolean inTexRange, es, et; mapDrawSurface_t old; @@ -1239,6 +1265,32 @@ static int AddMetaTriangleToSurface( mapDrawSurface_t *ds, metaTriangle_t *tri, if( tri->planeNum >= 0 && tri->planeNum != ds->planeNum ) return 0; } + +#if MAX_BBOX_DISTANCE > 0 + VectorCopy( ds->mins, mins ); + VectorCopy( ds->maxs, maxs ); + mins[0] -= MAX_BBOX_DISTANCE; + mins[1] -= MAX_BBOX_DISTANCE; + mins[2] -= MAX_BBOX_DISTANCE; + maxs[0] += MAX_BBOX_DISTANCE; + maxs[1] += MAX_BBOX_DISTANCE; + maxs[2] += MAX_BBOX_DISTANCE; +#define CHECK_1D(mins, v, maxs) ((mins) <= (v) && (v) <= (maxs)) +#define CHECK_3D(mins, v, maxs) (CHECK_1D((mins)[0], (v)[0], (maxs)[0]) && CHECK_1D((mins)[1], (v)[1], (maxs)[1]) && CHECK_1D((mins)[2], (v)[2], (maxs)[2])) + VectorCopy(metaVerts[ tri->indexes[ 0 ] ].xyz, p); + if(!CHECK_3D(mins, p, maxs)) + { + VectorCopy(metaVerts[ tri->indexes[ 1 ] ].xyz, p); + if(!CHECK_3D(mins, p, maxs)) + { + VectorCopy(metaVerts[ tri->indexes[ 2 ] ].xyz, p); + if(!CHECK_3D(mins, p, maxs)) + return 0; + } + } +#undef CHECK_3D +#undef CHECK_1D +#endif /* set initial score */ score = tri->surfaceNum == ds->surfaceNum ? SURFACE_SCORE : 0; @@ -1437,6 +1489,7 @@ static void MetaTrianglesToSurface( int numPossibles, metaTriangle_t *possibles, ds->planeNum = seed->planeNum; ds->fogNum = seed->fogNum; ds->sampleSize = seed->sampleSize; + ds->shadeAngleDegrees = seed->shadeAngleDegrees; ds->verts = verts; ds->indexes = indexes; VectorCopy( seed->lightmapAxis, ds->lightmapAxis );