Beispiel #1
0
//==========================================================================
//
// Sets up a new drawinfo struct
//
//==========================================================================
void GLDrawInfo::StartDrawInfo(GLDrawInfo * di)
{
	if (!di)
	{
		di=di_list.GetNew();
		di->temporary=true;
	}
	di->StartScene();
}
Beispiel #2
0
FLightNode * AddLightNode(FLightNode ** thread, void * linkto, ADynamicLight * light, FLightNode *& nextnode)
{
	FLightNode * node;

	node = nextnode;
	while (node)
    {
		if (node->targ==linkto)   // Already have a node for this sector?
		{
			node->lightsource = light; // Yes. Setting m_thing says 'keep it'.
			return(nextnode);
		}
		node = node->nextTarget;
    }

	// Couldn't find an existing node for this sector. Add one at the head
	// of the list.
	
	node = freelist.GetNew();
	
	node->targ = linkto;
	node->lightsource = light; 

	node->prevTarget = &nextnode; 
	node->nextTarget = nextnode;

	if (nextnode) nextnode->prevTarget = &node->nextTarget;
	
	// Add new node at head of sector thread starting at s->touching_thinglist
	
	node->prevLight = thread;  	
	node->nextLight = *thread; 
	if (node->nextLight) node->nextLight->prevLight=&node->nextLight;
	*thread = node;
	return(node);
}
Beispiel #3
0
void FDrawInfo::HandleHackedSubsectors()
{
    lowershcount=uppershcount=0;
    totalssms.Reset();
    totalssms.Clock();

    viewsubsector = R_PointInSubsector(viewx, viewy);

    // Each subsector may only be processed once in this loop!
    validcount++;
    for(unsigned int i=0; i<SubsectorHacks.Size(); i++)
    {
        subsector_t * sub = SubsectorHacks[i].sub;
        if (sub->validcount!=validcount && CheckAnchorFloor(sub))
        {
            // Now collect everything that is connected with this subsector.
            HandledSubsectors.Clear();
            inview=false;
            lowersegs.Clear();
            if (CollectSubsectorsFloor(sub, sub->render_sector))
            {
                for(unsigned int j=0; j<HandledSubsectors.Size(); j++)
                {
                    gl_subsectorrendernode * node = SSR_List.GetNew();

                    node->sub = HandledSubsectors[j];
                    AddOtherFloorPlane(sub->render_sector->sectornum, node);
                }
                if (inview) for(unsigned int j=0; j<lowersegs.Size(); j++)
                    {
                        seg_t * seg=lowersegs[j];
                        GLRenderer->ProcessLowerMiniseg (seg, seg->Subsector->render_sector, seg->PartnerSeg->Subsector->render_sector);
                    }
                lowershcount+=HandledSubsectors.Size();
            }
        }
    }

    // Each subsector may only be processed once in this loop!
    validcount++;
    for(unsigned int i=0; i<SubsectorHacks.Size(); i++)
    {
        subsector_t * sub = SubsectorHacks[i].sub;
        if (sub->validcount!=validcount && CheckAnchorCeiling(sub))
        {
            // Now collect everything that is connected with this subsector.
            HandledSubsectors.Clear();
            if (CollectSubsectorsCeiling(sub, sub->render_sector))
            {
                for(unsigned int j=0; j<HandledSubsectors.Size(); j++)
                {
                    gl_subsectorrendernode * node = SSR_List.GetNew();

                    node->sub = HandledSubsectors[j];
                    AddOtherCeilingPlane(sub->render_sector->sectornum, node);
                }
                uppershcount+=HandledSubsectors.Size();
            }
        }
    }


    SubsectorHacks.Clear();
    totalssms.Unclock();
}
Beispiel #4
0
//==========================================================================
//
// Draws the fake planes
//
//==========================================================================
void FDrawInfo::HandleMissingTextures()
{
    sector_t fake;
    totalms.Clock();
    totalupper=MissingUpperTextures.Size();
    totallower=MissingLowerTextures.Size();

    for(unsigned int i=0; i<MissingUpperTextures.Size(); i++)
    {
        if (!MissingUpperTextures[i].seg) continue;
        HandledSubsectors.Clear();
        validcount++;

        if (MissingUpperTextures[i].planez > viewz)
        {
            // close the hole only if all neighboring sectors are an exact height match
            // Otherwise just fill in the missing textures.
            MissingUpperTextures[i].sub->validcount=validcount;
            if (DoOneSectorUpper(MissingUpperTextures[i].sub, MissingUpperTextures[i].planez))
            {
                sector_t * sec = MissingUpperTextures[i].seg->backsector;
                // The mere fact that this seg has been added to the list means that the back sector
                // will be rendered so we can safely assume that it is already in the render list

                for(unsigned int j=0; j<HandledSubsectors.Size(); j++)
                {
                    gl_subsectorrendernode * node = SSR_List.GetNew();
                    node->sub = HandledSubsectors[j];

                    AddOtherCeilingPlane(sec->sectornum, node);
                }

                if (HandledSubsectors.Size()!=1)
                {
                    // mark all subsectors in the missing list that got processed by this
                    for(unsigned int j=0; j<HandledSubsectors.Size(); j++)
                    {
                        for(unsigned int k=0; k<MissingUpperTextures.Size(); k++)
                        {
                            if (MissingUpperTextures[k].sub==HandledSubsectors[j])
                            {
                                MissingUpperTextures[k].seg=NULL;
                            }
                        }
                    }
                }
                else MissingUpperTextures[i].seg=NULL;
                continue;
            }
        }

        if (!MissingUpperTextures[i].seg->PartnerSeg) continue;
        if (!MissingUpperTextures[i].seg->PartnerSeg->Subsector) continue;
        validcount++;
        HandledSubsectors.Clear();

        {
            // It isn't a hole. Now check whether it might be a fake bridge
            sector_t * fakesector = gl_FakeFlat(MissingUpperTextures[i].seg->frontsector, &fake, false);
            fixed_t planez = fakesector->GetPlaneTexZ(sector_t::ceiling);

            MissingUpperTextures[i].seg->PartnerSeg->Subsector->validcount=validcount;
            if (DoFakeCeilingBridge(MissingUpperTextures[i].seg->PartnerSeg->Subsector, planez))
            {
                // The mere fact that this seg has been added to the list means that the back sector
                // will be rendered so we can safely assume that it is already in the render list

                for(unsigned int j=0; j<HandledSubsectors.Size(); j++)
                {
                    gl_subsectorrendernode * node = SSR_List.GetNew();
                    node->sub = HandledSubsectors[j];
                    AddOtherCeilingPlane(fakesector->sectornum, node);
                }
            }
            continue;
        }
    }

    for(unsigned int i=0; i<MissingLowerTextures.Size(); i++)
    {
        if (!MissingLowerTextures[i].seg) continue;
        HandledSubsectors.Clear();
        validcount++;

        if (MissingLowerTextures[i].planez < viewz)
        {
            // close the hole only if all neighboring sectors are an exact height match
            // Otherwise just fill in the missing textures.
            MissingLowerTextures[i].sub->validcount=validcount;
            if (DoOneSectorLower(MissingLowerTextures[i].sub, MissingLowerTextures[i].planez))
            {
                sector_t * sec = MissingLowerTextures[i].seg->backsector;
                // The mere fact that this seg has been added to the list means that the back sector
                // will be rendered so we can safely assume that it is already in the render list

                for(unsigned int j=0; j<HandledSubsectors.Size(); j++)
                {
                    gl_subsectorrendernode * node = SSR_List.GetNew();
                    node->sub = HandledSubsectors[j];
                    AddOtherFloorPlane(sec->sectornum, node);
                }

                if (HandledSubsectors.Size()!=1)
                {
                    // mark all subsectors in the missing list that got processed by this
                    for(unsigned int j=0; j<HandledSubsectors.Size(); j++)
                    {
                        for(unsigned int k=0; k<MissingLowerTextures.Size(); k++)
                        {
                            if (MissingLowerTextures[k].sub==HandledSubsectors[j])
                            {
                                MissingLowerTextures[k].seg=NULL;
                            }
                        }
                    }
                }
                else MissingLowerTextures[i].seg=NULL;
                continue;
            }
        }

        if (!MissingLowerTextures[i].seg->PartnerSeg) continue;
        if (!MissingLowerTextures[i].seg->PartnerSeg->Subsector) continue;
        validcount++;
        HandledSubsectors.Clear();

        {
            // It isn't a hole. Now check whether it might be a fake bridge
            sector_t * fakesector = gl_FakeFlat(MissingLowerTextures[i].seg->frontsector, &fake, false);
            fixed_t planez = fakesector->GetPlaneTexZ(sector_t::floor);

            MissingLowerTextures[i].seg->PartnerSeg->Subsector->validcount=validcount;
            if (DoFakeBridge(MissingLowerTextures[i].seg->PartnerSeg->Subsector, planez))
            {
                // The mere fact that this seg has been added to the list means that the back sector
                // will be rendered so we can safely assume that it is already in the render list

                for(unsigned int j=0; j<HandledSubsectors.Size(); j++)
                {
                    gl_subsectorrendernode * node = SSR_List.GetNew();
                    node->sub = HandledSubsectors[j];
                    AddOtherFloorPlane(fakesector->sectornum, node);
                }
            }
            continue;
        }
    }

    totalms.Unclock();
    showtotalms=totalms;
    totalms.Reset();
}
Beispiel #5
0
void FDrawInfo::ProcessSectorStacks()
{
    unsigned int i;

    validcount++;
    for (i=0; i<CeilingStacks.Size (); i++)
    {
        subsector_t * sub = CeilingStacks[i];

        HandledSubsectors.Clear();
        for(DWORD j=0; j<sub->numlines; j++)
        {
            seg_t * seg = sub->firstline + j;
            if (seg->PartnerSeg)
            {
                subsector_t * backsub = seg->PartnerSeg->Subsector;

                if (backsub->validcount!=validcount) CollectSectorStacksCeiling (backsub, sub->render_sector);
            }
        }

        for(unsigned int j=0; j<HandledSubsectors.Size(); j++)
        {
            ss_renderflags[DWORD(HandledSubsectors[j]-subsectors)] &= ~SSRF_RENDERCEILING;

            if (sub->render_sector->CeilingSkyBox->PlaneAlpha!=0)
            {
                gl_subsectorrendernode * node = SSR_List.GetNew();
                node->sub = HandledSubsectors[j];
                AddOtherCeilingPlane(sub->render_sector->sectornum, node);
            }
        }
    }

    validcount++;
    for (i=0; i<FloorStacks.Size (); i++)
    {
        subsector_t * sub = FloorStacks[i];

        HandledSubsectors.Clear();
        for(DWORD j=0; j<sub->numlines; j++)
        {
            seg_t * seg = sub->firstline + j;
            if (seg->PartnerSeg)
            {
                subsector_t	* backsub = seg->PartnerSeg->Subsector;

                if (backsub->validcount!=validcount) CollectSectorStacksFloor (backsub, sub->render_sector);
            }
        }

        for(unsigned int j=0; j<HandledSubsectors.Size(); j++)
        {
            //Printf("%d: ss %d, sec %d\n", j, HandledSubsectors[j]-subsectors, HandledSubsectors[j]->render_sector->sectornum);
            ss_renderflags[DWORD(HandledSubsectors[j]-subsectors)] &= ~SSRF_RENDERFLOOR;

            if (sub->render_sector->FloorSkyBox->PlaneAlpha!=0)
            {
                gl_subsectorrendernode * node = SSR_List.GetNew();
                node->sub = HandledSubsectors[j];
                AddOtherFloorPlane(sub->render_sector->sectornum, node);
            }
        }
    }

    FloorStacks.Clear();
    CeilingStacks.Clear();
}
void FDrawInfo::ProcessSectorStacks()
{
	unsigned int i;
	sector_t fake;

	validcount++;
	for (i=0;i<CeilingStacks.Size (); i++)
	{
		sector_t *sec = gl_FakeFlat(CeilingStacks[i], &fake, false);
		FPortal *portal = sec->portals[sector_t::ceiling];
		if (portal != NULL) for(int k=0;k<sec->subsectorcount;k++)
		{
			subsector_t * sub = sec->subsectors[k];
			if (ss_renderflags[sub-subsectors] & SSRF_PROCESSED)
			{
				HandledSubsectors.Clear();
				for(DWORD j=0;j<sub->numlines;j++)
				{
					seg_t * seg = sub->firstline + j;
					if (seg->PartnerSeg)
					{
						subsector_t * backsub = seg->PartnerSeg->Subsector;

						if (backsub->validcount!=validcount) CollectSectorStacksCeiling (backsub, sec);
					}
				}
				for(unsigned int j=0;j<HandledSubsectors.Size();j++)
				{				
					subsector_t *sub = HandledSubsectors[j];
					ss_renderflags[DWORD(sub-subsectors)] &= ~SSRF_RENDERCEILING;

					if (sub->portalcoverage[sector_t::ceiling].subsectors == NULL)
					{
						gl_BuildPortalCoverage(&sub->portalcoverage[sector_t::ceiling],	sub, portal);
					}

					portal->GetGLPortal()->AddSubsector(sub);

					if (sec->GetAlpha(sector_t::ceiling) != 0 && sec->GetTexture(sector_t::ceiling) != skyflatnum)
					{
						gl_subsectorrendernode * node = SSR_List.GetNew();
						node->sub = sub;
						AddOtherCeilingPlane(sec->sectornum, node);
					}
				}
			}
		}
	}

	validcount++;
	for (i=0;i<FloorStacks.Size (); i++)
	{
		sector_t *sec = gl_FakeFlat(FloorStacks[i], &fake, false);
		FPortal *portal = sec->portals[sector_t::floor];
		if (portal != NULL) for(int k=0;k<sec->subsectorcount;k++)
		{
			subsector_t * sub = sec->subsectors[k];
			if (ss_renderflags[sub-subsectors] & SSRF_PROCESSED)
			{
				HandledSubsectors.Clear();
				for(DWORD j=0;j<sub->numlines;j++)
				{
					seg_t * seg = sub->firstline + j;
					if (seg->PartnerSeg)
					{
						subsector_t	* backsub = seg->PartnerSeg->Subsector;

						if (backsub->validcount!=validcount) CollectSectorStacksFloor (backsub, sec);
					}
				}

				for(unsigned int j=0;j<HandledSubsectors.Size();j++)
				{				
					subsector_t *sub = HandledSubsectors[j];
					ss_renderflags[DWORD(sub-subsectors)] &= ~SSRF_RENDERFLOOR;

					if (sub->portalcoverage[sector_t::floor].subsectors == NULL)
					{
						gl_BuildPortalCoverage(&sub->portalcoverage[sector_t::floor], sub, portal);
					}

					GLSectorStackPortal *glportal = portal->GetGLPortal();
					glportal->AddSubsector(sub);

					if (sec->GetAlpha(sector_t::floor) != 0 && sec->GetTexture(sector_t::floor) != skyflatnum)
					{
						gl_subsectorrendernode * node = SSR_List.GetNew();
						node->sub = sub;
						AddOtherFloorPlane(sec->sectornum, node);
					}
				}
			}
		}
	}

	FloorStacks.Clear();
	CeilingStacks.Clear();
}