Exemplo n.º 1
0
void CFilterer::forceDetailBrushes()
{
	list<CBrushPlane>::iterator pIter, pEnd;

	bool forceItDetail;
	CBrush *brush;
	int brushesMadeDetail = 0;
	for(int i=0;i<worldEntity->getBrushesNo();i++) {
		brush = &worldEntity->getBrush(i);
		if(!brush->isStructural())
			continue;
		forceItDetail = true;
		pIter = brush->planesBegin();
		pEnd = brush->planesEnd();

		while(pIter!=pEnd){
			if(!pIter->canBeDetail()){
				forceItDetail = false;
				break;
			}
			++pIter;
		}

		if(forceItDetail){
			brush->setStructural(false);
			brushesMadeDetail++;
		}
	}
	cout << brushesMadeDetail<<" forced detail"<<endl;
}
Exemplo n.º 2
0
void CFilterer::mergeDetails(CBTree<CBspNode *>::Node *node){
    if(!node->isLeaf())	{
        mergeDetails(node->child(0));
        mergeDetails(node->child(1));
        return;
    }

    //NOW LEAF
    CBspLeaf *leaf = (CBspLeaf *)node->data;
    if(!leaf->getArea())
        return;
    vector<CBrush *>::iterator i, e;
    list < CBrushPlane >::iterator dpi, dpe;
    CPolygon *detailP, structuralP;

    e=leaf->bEnd();
    CBrush *db;//detail part brush
    //VertsVector::iterator v, ve;
    vector<CBrush *> allNb; //these are these and neigbor brushes
    vector<CBspLeaf *>::iterator li, le;
    vector<CBrush *>::iterator brushI, brushE;
    li=leaf->oLeafsBegin();
    le=leaf->oLeafsEnd();
    while(li!=le){
        (*li)->appendYourBrushes(allNb, worldEntity);
        li++;
    }
    leaf->appendYourBrushes(allNb, worldEntity);

    brushE = allNb.end();

    bool isAllInBrush;

    // this holds brushes which contains at least one vertex of a poly
    // but not all vertices
    list<CBrush *> brushesIn;

    list<CPolygon *>::iterator pi, pe;
    pi=leaf->polygonsBegin();
    pe=leaf->polygonsEnd();
    while(pi!=pe){
        if(!(*pi)->isKeep() || (*pi)->isLeak()){
            ++pi;
            continue;
        }
        for(brushI=allNb.begin(); brushI!=brushE;++brushI){
            assert((*brushI)->getBrushId()!=-1);
            assert((*pi)->getBrushId()!=-1);
            /*
            if((*brushI)->getBrushId() == (*i)->getBrushId())//if is the brush of this polygon do nothing
            continue;
            */ 
            if((*brushI)->getBrushId() == (*pi)->getBrushId())
                continue;
            if((*brushI)->isOpaque()){
                if((*brushI)->subPolygon(*pi)){
                    leaf->erasePolygon(pi);
                    break;
                }
            }
        }
        ++pi;
    }

    for(i=leaf->bBegin();i!=e;++i){
        brushesIn.clear();
        db  = *i;
        dpi = db->planesBegin();
        dpe = db->planesEnd();
        for( ; dpi != dpe ; ++dpi ){
            detailP = dpi->getPolygon();
            if(!detailP->isKeep())
                continue;

            isAllInBrush=false;
            for(brushI=allNb.begin(); brushI!=brushE;++brushI){
                assert((*brushI)->getBrushId()!=-1);
                assert((*i)->getBrushId()!=-1);
                if((*brushI)->getBrushId() == (*i)->getBrushId())//if is the brush of this polygon do nothing
                    continue;

                if((*brushI)->isOpaque()){
                    isAllInBrush = (*brushI)->subPolygon(detailP);
                    if(isAllInBrush)
                        break;
                }
            }

            if(isAllInBrush)
                continue;
            detailP->merge();
        }
    }
}