src.recvShadows = ds->recvShadows;
src.fogNum = ds->fogNum;
src.sampleSize = ds->sampleSize;
+ src.shadeAngleDegrees = ds->shadeAngleDegrees;
VectorCopy( ds->lightmapAxis, src.lightmapAxis );
/* copy drawverts */
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 */
based on SurfaceAsTriStrip()
*/
-#define MAX_INDEXES 4096
+#define MAX_INDEXES 1024
void StripFaceSurface( mapDrawSurface_t *ds )
{
/* classify it */
ClassifySurfaces( 1, ds );
}
+
+
+/*
+EmitMetaStatictics
+vortex: prints meta statistics in general output
+*/
-
+void EmitMetaStats()
+{
+ Sys_Printf( "--- EmitMetaStats ---\n" );
+ Sys_Printf( "%9d total meta surfaces\n", numMetaSurfaces );
+ Sys_Printf( "%9d stripped surfaces\n", numStripSurfaces );
+ Sys_Printf( "%9d fanned surfaces\n", numFanSurfaces );
+ Sys_Printf( "%9d patch meta surfaces\n", numPatchMetaSurfaces );
+ Sys_Printf( "%9d meta verts\n", numMetaVerts );
+ Sys_Printf( "%9d meta triangles\n", numMetaTriangles );
+}
/*
MakeEntityMetaTriangles()
break;
case SURFACE_PATCH:
- TriangulatePatchSurface( ds );
+ TriangulatePatchSurface(e, ds );
break;
case SURFACE_TRIANGLES:
break;
-
+
case SURFACE_FORCED_META:
case SURFACE_META:
SurfaceToMetaTriangles( ds );
int indexes[ MAX_SAMPLES ];
vec3_t votes[ MAX_SAMPLES ];
-
/* note it */
Sys_FPrintf( SYS_VRB, "--- SmoothMetaTriangles ---\n" );
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;
#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;
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;
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 );