X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=tools%2Fquake3%2Fq3map2%2Ffacebsp.c;h=e35f289206b658ba708fa309d244a84edd1dd4fd;hp=66a009c2a99c5ddc05dbe586e7547455612baa3d;hb=7fc621fc78d0e040dc2c12f38dc53dd9048215dc;hpb=830125fad042fad35dc029b6eb57c8156ad7e176 diff --git a/tools/quake3/q3map2/facebsp.c b/tools/quake3/q3map2/facebsp.c index 66a009c2..e35f2892 100644 --- a/tools/quake3/q3map2/facebsp.c +++ b/tools/quake3/q3map2/facebsp.c @@ -88,6 +88,9 @@ static void SelectSplitPlaneNum( node_t *node, face_t *list, int *splitPlaneNum, vec3_t normal; float dist; int planenum; + float sizeBias; + + //int frontC,backC,splitsC,facingC; /* ydnar: set some defaults */ @@ -117,14 +120,15 @@ static void SelectSplitPlaneNum( node_t *node, face_t *list, int *splitPlaneNum, bestValue = -99999; bestSplit = list; - for ( split = list; split; split = split->next ) - split->checked = qfalse; + + // div0: this check causes detail/structural mixes + //for( split = list; split; split = split->next ) + // split->checked = qfalse; for ( split = list; split; split = split->next ) { - if ( split->checked ) { - continue; - } + //if ( split->checked ) + // continue; plane = &mapplanes[ split->planenum ]; splits = 0; @@ -134,7 +138,7 @@ static void SelectSplitPlaneNum( node_t *node, face_t *list, int *splitPlaneNum, for ( check = list ; check ; check = check->next ) { if ( check->planenum == split->planenum ) { facing++; - check->checked = qtrue; // won't need to test this plane again + //check->checked = qtrue; // won't need to test this plane again continue; } side = WindingOnPlaneSide( check->w, plane->normal, plane->dist ); @@ -148,15 +152,37 @@ static void SelectSplitPlaneNum( node_t *node, face_t *list, int *splitPlaneNum, back++; } } - value = 5 * facing - 5 * splits; // - abs(front-back); - if ( plane->type < 3 ) { - value += 5; // axial is better + + if ( bspAlternateSplitWeights ) { + // from 27 + + //Bigger is better + sizeBias = WindingArea( split->w ); + + //Base score = 20000 perfectly balanced + value = 20000 - ( abs( front - back ) ); + value -= plane->counter; // If we've already used this plane sometime in the past try not to use it again + value -= facing ; // if we're going to have alot of other surfs use this plane, we want to get it in quickly. + value -= splits * 5; //more splits = bad + value += sizeBias * 10; //We want a huge score bias based on plane size + } + else + { + value = 5 * facing - 5 * splits; // - abs(front-back); + if ( plane->type < 3 ) { + value += 5; // axial is better + } } + value += split->priority; // prioritize hints higher if ( value > bestValue ) { bestValue = value; bestSplit = split; + //frontC=front; + //backC=back; + //splitsC=splits; + //facingC=facing; } } @@ -165,9 +191,27 @@ static void SelectSplitPlaneNum( node_t *node, face_t *list, int *splitPlaneNum, return; } + //Sys_FPrintf (SYS_VRB, "F: %d B:%d S:%d FA:%ds\n",frontC,backC,splitsC,facingC ); + /* set best split data */ *splitPlaneNum = bestSplit->planenum; *compileFlags = bestSplit->compileFlags; + +#if 0 + if ( bestSplit->compileFlags & C_DETAIL ) { + for ( split = list; split; split = split->next ) + if ( !( split->compileFlags & C_DETAIL ) ) { + Sys_FPrintf( SYS_ERR, "DON'T DO SUCH SPLITS (1)\n" ); + } + } + if ( ( node->compileFlags & C_DETAIL ) && !( bestSplit->compileFlags & C_DETAIL ) ) { + Sys_FPrintf( SYS_ERR, "DON'T DO SUCH SPLITS (2)\n" ); + } +#endif + + if ( *splitPlaneNum > -1 ) { + mapplanes[ *splitPlaneNum ].counter++; + } } @@ -204,6 +248,9 @@ void BuildFaceTree_r( node_t *node, face_t *list ){ winding_t *frontWinding, *backWinding; int i; int splitPlaneNum, compileFlags; +#if 0 + qboolean isstruct = qfalse; +#endif /* count faces left */ @@ -215,6 +262,7 @@ void BuildFaceTree_r( node_t *node, face_t *list ){ /* if we don't have any more faces, this is a node */ if ( splitPlaneNum == -1 ) { node->planenum = PLANENUM_LEAF; + node->has_structural_children = qfalse; c_faceLeafs++; return; } @@ -222,9 +270,11 @@ void BuildFaceTree_r( node_t *node, face_t *list ){ /* partition the list */ node->planenum = splitPlaneNum; node->compileFlags = compileFlags; + node->has_structural_children = !( compileFlags & C_DETAIL ) && !node->opaque; plane = &mapplanes[ splitPlaneNum ]; childLists[0] = NULL; childLists[1] = NULL; + for ( split = list; split; split = next ) { /* set next */ @@ -236,13 +286,19 @@ void BuildFaceTree_r( node_t *node, face_t *list ){ continue; } +#if 0 + if ( !( split->compileFlags & C_DETAIL ) ) { + isstruct = 1; + } +#endif + /* determine which side the face falls on */ side = WindingOnPlaneSide( split->w, plane->normal, plane->dist ); /* switch on side */ if ( side == SIDE_CROSS ) { - ClipWindingEpsilon( split->w, plane->normal, plane->dist, CLIP_EPSILON * 2, - &frontWinding, &backWinding ); + ClipWindingEpsilonStrict( split->w, plane->normal, plane->dist, CLIP_EPSILON * 2, + &frontWinding, &backWinding ); /* strict; if no winding is left, we have a "virtually identical" plane and don't want to split by it */ if ( frontWinding ) { newFace = AllocBspFace(); newFace->w = frontWinding; @@ -288,11 +344,32 @@ void BuildFaceTree_r( node_t *node, face_t *list ){ node->children[1]->maxs[i] = plane->dist; break; } + if ( plane->normal[i] == -1 ) { + node->children[0]->maxs[i] = -plane->dist; + node->children[1]->mins[i] = -plane->dist; + break; + } + } + +#if 0 + if ( ( node->compileFlags & C_DETAIL ) && isstruct ) { + Sys_FPrintf( SYS_ERR, "I am detail, my child is structural, this is a wtf1\n", node->has_structural_children ); } +#endif for ( i = 0 ; i < 2 ; i++ ) { BuildFaceTree_r( node->children[i], childLists[i] ); + node->has_structural_children |= node->children[i]->has_structural_children; + } + +#if 0 + if ( ( node->compileFlags & C_DETAIL ) && !( node->children[0]->compileFlags & C_DETAIL ) && node->children[0]->planenum != PLANENUM_LEAF ) { + Sys_FPrintf( SYS_ERR, "I am detail, my child is structural\n", node->has_structural_children ); + } + if ( ( node->compileFlags & C_DETAIL ) && isstruct ) { + Sys_FPrintf( SYS_ERR, "I am detail, my child is structural, this is a wtf2\n", node->has_structural_children ); } +#endif } @@ -324,6 +401,11 @@ tree_t *FaceBSP( face_t *list ) { } Sys_FPrintf( SYS_VRB, "%9d faces\n", count ); + for ( i = 0; i < nummapplanes; i++ ) + { + mapplanes[ i ].counter = 0; + } + tree->headnode = AllocNode(); VectorCopy( tree->mins, tree->headnode->mins ); VectorCopy( tree->maxs, tree->headnode->maxs ); @@ -354,7 +436,7 @@ face_t *MakeStructuralBSPFaceList( brush_t *list ){ flist = NULL; for ( b = list; b != NULL; b = b->next ) { - if ( b->detail ) { + if ( !deepBSP && b->detail ) { continue; } @@ -377,6 +459,9 @@ face_t *MakeStructuralBSPFaceList( brush_t *list ){ f->w = CopyWinding( w ); f->planenum = s->planenum & ~1; f->compileFlags = s->compileFlags; /* ydnar */ + if ( b->detail ) { + f->compileFlags |= C_DETAIL; + } /* ydnar: set priority */ f->priority = 0; @@ -389,6 +474,9 @@ face_t *MakeStructuralBSPFaceList( brush_t *list ){ if ( f->compileFlags & C_AREAPORTAL ) { f->priority += AREAPORTAL_PRIORITY; } + if ( f->compileFlags & C_DETAIL ) { + f->priority += DETAIL_PRIORITY; + } /* get next face */ f->next = flist; @@ -417,7 +505,7 @@ face_t *MakeVisibleBSPFaceList( brush_t *list ){ flist = NULL; for ( b = list; b != NULL; b = b->next ) { - if ( b->detail ) { + if ( !deepBSP && b->detail ) { continue; } @@ -440,6 +528,9 @@ face_t *MakeVisibleBSPFaceList( brush_t *list ){ f->w = CopyWinding( w ); f->planenum = s->planenum & ~1; f->compileFlags = s->compileFlags; /* ydnar */ + if ( b->detail ) { + f->compileFlags |= C_DETAIL; + } /* ydnar: set priority */ f->priority = 0; @@ -452,6 +543,9 @@ face_t *MakeVisibleBSPFaceList( brush_t *list ){ if ( f->compileFlags & C_AREAPORTAL ) { f->priority += AREAPORTAL_PRIORITY; } + if ( f->compileFlags & C_DETAIL ) { + f->priority += DETAIL_PRIORITY; + } /* get next face */ f->next = flist;