mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-23 04:12:39 +00:00
Allow weapon marks on triangle meshes (default: disabled), patch by Oliver McFadden. http://bugzilla.icculus.org/show_bug.cgi?id=3774
This commit is contained in:
parent
37598962f5
commit
b3f36fc830
3 changed files with 34 additions and 17 deletions
|
@ -155,6 +155,8 @@ cvar_t *r_debugSort;
|
||||||
cvar_t *r_printShaders;
|
cvar_t *r_printShaders;
|
||||||
cvar_t *r_saveFontData;
|
cvar_t *r_saveFontData;
|
||||||
|
|
||||||
|
cvar_t *r_marksOnTriangleMeshes;
|
||||||
|
|
||||||
cvar_t *r_maxpolys;
|
cvar_t *r_maxpolys;
|
||||||
int max_polys;
|
int max_polys;
|
||||||
cvar_t *r_maxpolyverts;
|
cvar_t *r_maxpolyverts;
|
||||||
|
@ -1009,6 +1011,8 @@ void R_Register( void )
|
||||||
r_noportals = ri.Cvar_Get ("r_noportals", "0", CVAR_CHEAT);
|
r_noportals = ri.Cvar_Get ("r_noportals", "0", CVAR_CHEAT);
|
||||||
r_shadows = ri.Cvar_Get( "cg_shadows", "1", 0 );
|
r_shadows = ri.Cvar_Get( "cg_shadows", "1", 0 );
|
||||||
|
|
||||||
|
r_marksOnTriangleMeshes = ri.Cvar_Get("r_marksOnTriangleMeshes", "0", CVAR_ARCHIVE);
|
||||||
|
|
||||||
r_maxpolys = ri.Cvar_Get( "r_maxpolys", va("%d", MAX_POLYS), 0);
|
r_maxpolys = ri.Cvar_Get( "r_maxpolys", va("%d", MAX_POLYS), 0);
|
||||||
r_maxpolyverts = ri.Cvar_Get( "r_maxpolyverts", va("%d", MAX_POLYVERTS), 0);
|
r_maxpolyverts = ri.Cvar_Get( "r_maxpolyverts", va("%d", MAX_POLYVERTS), 0);
|
||||||
|
|
||||||
|
|
|
@ -1114,6 +1114,8 @@ extern cvar_t *r_debugSort;
|
||||||
extern cvar_t *r_printShaders;
|
extern cvar_t *r_printShaders;
|
||||||
extern cvar_t *r_saveFontData;
|
extern cvar_t *r_saveFontData;
|
||||||
|
|
||||||
|
extern cvar_t *r_marksOnTriangleMeshes;
|
||||||
|
|
||||||
extern cvar_t *r_GLlibCoolDownMsec;
|
extern cvar_t *r_GLlibCoolDownMsec;
|
||||||
|
|
||||||
//====================================================================
|
//====================================================================
|
||||||
|
|
|
@ -173,7 +173,9 @@ void R_BoxSurfaces_r(mnode_t *node, vec3_t mins, vec3_t maxs, surfaceType_t **li
|
||||||
surf->viewCount = tr.viewCount;
|
surf->viewCount = tr.viewCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (*(surfaceType_t *) (surf->data) != SF_GRID) surf->viewCount = tr.viewCount;
|
else if (*(surfaceType_t *) (surf->data) != SF_GRID &&
|
||||||
|
*(surfaceType_t *) (surf->data) != SF_TRIANGLES)
|
||||||
|
surf->viewCount = tr.viewCount;
|
||||||
// check the viewCount because the surface may have
|
// check the viewCount because the surface may have
|
||||||
// already been added if it spans multiple leafs
|
// already been added if it spans multiple leafs
|
||||||
if (surf->viewCount != tr.viewCount) {
|
if (surf->viewCount != tr.viewCount) {
|
||||||
|
@ -263,7 +265,6 @@ int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projectio
|
||||||
vec3_t clipPoints[2][MAX_VERTS_ON_POLY];
|
vec3_t clipPoints[2][MAX_VERTS_ON_POLY];
|
||||||
int numClipPoints;
|
int numClipPoints;
|
||||||
float *v;
|
float *v;
|
||||||
srfSurfaceFace_t *surf;
|
|
||||||
srfGridMesh_t *cv;
|
srfGridMesh_t *cv;
|
||||||
drawVert_t *dv;
|
drawVert_t *dv;
|
||||||
vec3_t normal;
|
vec3_t normal;
|
||||||
|
@ -399,25 +400,20 @@ int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projectio
|
||||||
}
|
}
|
||||||
else if (*surfaces[i] == SF_FACE) {
|
else if (*surfaces[i] == SF_FACE) {
|
||||||
|
|
||||||
surf = ( srfSurfaceFace_t * ) surfaces[i];
|
srfSurfaceFace_t *surf = ( srfSurfaceFace_t * ) surfaces[i];
|
||||||
|
|
||||||
// check the normal of this face
|
// check the normal of this face
|
||||||
if (DotProduct(surf->plane.normal, projectionDir) > -0.5) {
|
if (DotProduct(surf->plane.normal, projectionDir) > -0.5) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
VectorSubtract(clipPoints[0][0], clipPoints[0][1], v1);
|
|
||||||
VectorSubtract(clipPoints[0][2], clipPoints[0][1], v2);
|
|
||||||
CrossProduct(v1, v2, normal);
|
|
||||||
VectorNormalize(normal);
|
|
||||||
if (DotProduct(normal, projectionDir) > -0.5) continue;
|
|
||||||
*/
|
|
||||||
indexes = (int *)( (byte *)surf + surf->ofsIndices );
|
indexes = (int *)( (byte *)surf + surf->ofsIndices );
|
||||||
for ( k = 0 ; k < surf->numIndices ; k += 3 ) {
|
for ( k = 0 ; k < surf->numIndices ; k += 3 ) {
|
||||||
for ( j = 0 ; j < 3 ; j++ ) {
|
for ( j = 0 ; j < 3 ; j++ ) {
|
||||||
v = surf->points[0] + VERTEXSIZE * indexes[k+j];;
|
v = surf->points[0] + VERTEXSIZE * indexes[k+j];;
|
||||||
VectorMA( v, MARKER_OFFSET, surf->plane.normal, clipPoints[0][j] );
|
VectorMA( v, MARKER_OFFSET, surf->plane.normal, clipPoints[0][j] );
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the fragments of this face
|
// add the fragments of this face
|
||||||
R_AddMarkFragments( 3 , clipPoints,
|
R_AddMarkFragments( 3 , clipPoints,
|
||||||
numPlanes, normals, dists,
|
numPlanes, normals, dists,
|
||||||
|
@ -428,14 +424,29 @@ int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projectio
|
||||||
return returnedFragments; // not enough space for more fragments
|
return returnedFragments; // not enough space for more fragments
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
else {
|
else if(*surfaces[i] == SF_TRIANGLES && r_marksOnTriangleMeshes->integer) {
|
||||||
// ignore all other world surfaces
|
|
||||||
// might be cool to also project polygons on a triangle soup
|
srfTriangles_t *surf = (srfTriangles_t *) surfaces[i];
|
||||||
// however this will probably create huge amounts of extra polys
|
|
||||||
// even more than the projection onto curves
|
for (k = 0; k < surf->numIndexes; k += 3)
|
||||||
continue;
|
{
|
||||||
|
for(j = 0; j < 3; j++)
|
||||||
|
{
|
||||||
|
v = surf->verts[surf->indexes[k + j]].xyz;
|
||||||
|
VectorMA(v, MARKER_OFFSET, surf->verts[surf->indexes[k + j]].normal, clipPoints[0][j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the fragments of this face
|
||||||
|
R_AddMarkFragments(3, clipPoints,
|
||||||
|
numPlanes, normals, dists,
|
||||||
|
maxPoints, pointBuffer,
|
||||||
|
maxFragments, fragmentBuffer, &returnedPoints, &returnedFragments, mins, maxs);
|
||||||
|
if(returnedFragments == maxFragments)
|
||||||
|
{
|
||||||
|
return returnedFragments; // not enough space for more fragments
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return returnedFragments;
|
return returnedFragments;
|
||||||
|
|
Loading…
Reference in a new issue