Exemple #1
0
static void DoSubsector(subsector_t * sub)
{
	int i;
	sector_t * sector;
	sector_t * fakesector;
	sector_t fake;
	GLFlat glflat;
	GLSprite glsprite;
	
	// check for visibility of this entire subsector! This requires GL nodes!
	if (!clipper.CheckBox(sub->bbox)) return;

#ifdef _MSC_VER
#ifdef _DEBUG
	if (sub->sector-sectors==931)
	{
		__asm nop
	}
#endif
#endif

	sector=sub->sector;
	if (!sector) return;

	sector->MoreFlags |= SECF_DRAWN;
	fakesector=gl_FakeFlat(sector, &fake, false);

	// [RH] Add particles
	//int shade = LIGHT2SHADE((floorlightlevel + ceilinglightlevel)/2 + r_actualextralight);
	for (i = ParticlesInSubsec[sub-subsectors]; i != NO_PARTICLE; i = Particles[i].snext)
	{
		glsprite.ProcessParticle(Particles + i, fakesector);//, 0, 0);
	}
	AddLines(sub, fakesector);
	RenderThings(sub, fakesector);

	// Subsectors with only 2 lines cannot have any area!
	if (sub->numlines>2 || (sub->hacked&1)) 
	{
		// Exclude the case when it tries to render a sector with a heightsec
		// but undetermined heightsec state. This can only happen if the
		// subsector is obstructed but not excluded due to a large bounding box.
		// Due to the way a BSP works such a subsector can never be visible
		if (!sector->heightsec || sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC || in_area!=area_default)
		{
			if (sector != sub->render_sector)
			{
				sector = sub->render_sector;
				// the planes of this subsector are faked to belong to another sector
				// This means we need the heightsec parts and light info of the render sector, not the actual one!
				fakesector = gl_FakeFlat(sector, &fake, false);
			}
			SetupFlat.Clock();
			glflat.ProcessSector(fakesector, sub);
			SetupFlat.Unclock();
		}
	}
}
//==========================================================================
//
//
//
//==========================================================================
void GLSprite::SplitSprite(sector_t * frontsector, bool translucent)
{
    GLSprite copySprite;
    fixed_t lightbottom;
    float maplightbottom;
    unsigned int i;
    bool put=false;
    TArray<lightlist_t> & lightlist=frontsector->e->XFloor.lightlist;

    //y1+=y;
    //y2+=y;
    //y=0;
    for(i=0; i<lightlist.Size(); i++)
    {
        // Particles don't go through here so we can safely assume that actor is not NULL
        if (i<lightlist.Size()-1) lightbottom=lightlist[i+1].plane.ZatPoint(actor->x,actor->y);
        else lightbottom=frontsector->floorplane.ZatPoint(actor->x,actor->y);

        //maplighttop=FIXED2FLOAT(lightlist[i].height);
        maplightbottom=FIXED2FLOAT(lightbottom);
        if (maplightbottom<z2) maplightbottom=z2;

        if (maplightbottom<z1)
        {
            copySprite=*this;
            copySprite.lightlevel=*lightlist[i].p_lightlevel;
            copySprite.Colormap.CopyLightColor(*lightlist[i].p_extra_colormap);

            if (glset.nocoloredspritelighting)
            {
                int v = (copySprite.Colormap.LightColor.r + copySprite.Colormap.LightColor.g + copySprite.Colormap.LightColor.b )/3;
                copySprite.Colormap.LightColor.r=
                    copySprite.Colormap.LightColor.g=
                        copySprite.Colormap.LightColor.b=(255+v+v)/3;
            }

            if (!gl_isWhite(ThingColor))
            {
                copySprite.Colormap.LightColor.r=(copySprite.Colormap.LightColor.r*ThingColor.r)>>8;
                copySprite.Colormap.LightColor.g=(copySprite.Colormap.LightColor.g*ThingColor.g)>>8;
                copySprite.Colormap.LightColor.b=(copySprite.Colormap.LightColor.b*ThingColor.b)>>8;
            }

            z1=copySprite.z2=maplightbottom;
            vt=copySprite.vb=copySprite.vt+
                             (maplightbottom-copySprite.z1)*(copySprite.vb-copySprite.vt)/(z2-copySprite.z1);
            copySprite.PutSprite(translucent);
            put=true;
        }
void AnimationViewerPanel::renderCenterPointSprite(const GLSprite* pGlSprite, const QPoint& centerPoint, QPainter& painter)
{
    if (pGlSprite->mSpriteDescriptor.isImage())
    {
        // render center point
        GLSprite* centerPointSprite = AnimationModel::getCenterPointSprite();
        QPointF offset = QPointF(
                (pGlSprite->mSpriteDescriptor.mPosition.mX + pGlSprite->mSpriteDescriptor.center().x()),
                (pGlSprite->mSpriteDescriptor.mPosition.mY + pGlSprite->mSpriteDescriptor.center().y())
        );

        QPoint centerPointCenterPoint = centerPoint + offset.toPoint();

        painter.translate(centerPointCenterPoint.x(), centerPointCenterPoint.y());
        centerPointSprite->render(QPoint(0, 0), painter, AnimationModel::getTargetSprite(), false, mEmittedAnimationList);
        painter.translate(-centerPointCenterPoint.x(), -centerPointCenterPoint.y());
    }
}
const GLSprite* GLTextureStore::SpriteFromLunaImage(const std::shared_ptr<LunaImage>& img)
{
    img->lock();

    uint64_t uid = img->getUID();

    // Get associated texture from cache if possible
    auto it = mLunaImageTexMap.find(uid);
    if (it != mLunaImageTexMap.end()) {
        img->unlock();
        return it->second;
    }

    uint32_t w = img->getW();
    uint32_t h = img->getH();

    // Try to allocate the GLSprite
    GLSprite* sprite = nullptr;
    void* data = img->getDataPtr();
    if (data != nullptr)
    {
        sprite = GLSprite::Create(data, GL_BGRA, w, h);
        data = nullptr;
        img->notifyTextureified();
    }
    img->unlock();

    // Handle failure
    if (sprite == NULL || !sprite->IsValid())
    {
        if (sprite) delete sprite;
        return NULL;
    }

    totalMem += sprite->GetSizeBytes();

    // Cache new texture
    mLunaImageTexMap[uid] = sprite;

    return sprite;
}
Exemple #5
0
void GLSprite::SplitSprite(HWDrawInfo *di, sector_t * frontsector, bool translucent)
{
	GLSprite copySprite;
	double lightbottom;
	unsigned int i;
	bool put=false;
	TArray<lightlist_t> & lightlist=frontsector->e->XFloor.lightlist;

	for(i=0;i<lightlist.Size();i++)
	{
		// Particles don't go through here so we can safely assume that actor is not nullptr
		if (i<lightlist.Size()-1) lightbottom=lightlist[i+1].plane.ZatPoint(actor);
		else lightbottom=frontsector->floorplane.ZatPoint(actor);

		if (lightbottom<z2) lightbottom=z2;

		if (lightbottom<z1)
		{
			copySprite=*this;
			copySprite.lightlevel = hw_ClampLight(*lightlist[i].p_lightlevel);
			copySprite.Colormap.CopyLight(lightlist[i].extra_colormap);

			if (level.flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING)
			{
				copySprite.Colormap.Decolorize();
			}

			if (!ThingColor.isWhite())
			{
				copySprite.Colormap.LightColor.r = (copySprite.Colormap.LightColor.r*ThingColor.r) >> 8;
				copySprite.Colormap.LightColor.g = (copySprite.Colormap.LightColor.g*ThingColor.g) >> 8;
				copySprite.Colormap.LightColor.b = (copySprite.Colormap.LightColor.b*ThingColor.b) >> 8;
			}

			z1=copySprite.z2=lightbottom;
			vt=copySprite.vb=copySprite.vt+ 
				(lightbottom-copySprite.z1)*(copySprite.vb-copySprite.vt)/(z2-copySprite.z1);
			copySprite.PutSprite(di, translucent);
			put=true;
		}
Exemple #6
0
//==========================================================================
//
// R_RenderThings
//
//==========================================================================
static inline void RenderThings(subsector_t * sub, sector_t * sector)
{
	GLSprite glsprite;

	SetupSprite.Clock();
	sector_t * sec=sub->sector;
	// BSP is traversed by subsector.
	// A sector might have been split into several
	//	subsectors during BSP building.
	// Thus we check whether it was already added.
	if (sec->thinglist != NULL && sec->validcount != validcount)
	{
		// Well, now it will be done.
		sec->validcount = validcount;

		// Handle all things in sector.
		for (AActor * thing = sec->thinglist; thing; thing = thing->snext)
		{
			glsprite.Process(thing, sector);
		}
	}
	SetupSprite.Unclock();
}
Exemple #7
0
void FGLRenderer::ProcessParticle(particle_t *part, sector_t *sector)
{
	GLSprite glsprite;
	glsprite.ProcessParticle(part, sector);//, 0, 0);
}
Exemple #8
0
void FGLRenderer::ProcessSprite(AActor *thing, sector_t *sector)
{
	GLSprite glsprite;
	glsprite.Process(thing, sector);
}
Exemple #9
0
void FGLRenderer::ProcessSprite(AActor *thing, sector_t *sector, bool thruportal)
{
	GLSprite glsprite;
	glsprite.Process(thing, sector, thruportal);
}
void AnimationViewerPanel::renderCelSprites(const QPoint& centerPoint, QPainter& painter)
{
    KeyFrame::KeyFramePosition currentPosition = mpAnimationModel->getCurrentKeyFramePosition();

    if (mIsAnimationPlaying)
    {
        mpAnimationModel->executeCommand(currentPosition.mFrameNo);
    }

    QList<const GLSprite*>::Iterator iter = mRenderSpriteList.begin();
    while (iter != mRenderSpriteList.end())
    {
        GLSprite* glSprite = (GLSprite*)*iter;

        if (glSprite->mLineNo == AnimationModel::LINE_target)
        {
            if (!mShowTarget)
            {
                iter++;
                continue;
            }
            GLSprite::Point2 position;
            position.mX = glSprite->mSpriteDescriptor.mPosition.mX + AnimationModel::TARGET_originX;
            position.mY = glSprite->mSpriteDescriptor.mPosition.mY + AnimationModel::TARGET_originY;
            glSprite->mSpriteDescriptor.mPosition = position;
         }

        if (!mShowCamera && glSprite->mLineNo == AnimationModel::LINE_camera)
        {
           iter++;
           continue;
        }

        // render sprite
        // Move rendering position depends on targeting position option
        int dx = 0;
        int dy = 0;
//        if (glSprite->mLineNo == AnimationModel::LINE_target)
//        {
//            dx = glSprite->mSpriteDescriptor.mTextureSrcRect.width() / 2;
//            dy = glSprite->mSpriteDescriptor.mTextureSrcRect.height() / 2;
//        }

        painter.translate(centerPoint.x() + dx, centerPoint.y() + dy);
        if (glSprite)
        {
            glSprite->render(QPoint(0, 0), painter,AnimationModel::getTargetSprite(), mIsAnimationPlaying, mEmittedAnimationList);
        }

        painter.translate(-centerPoint.x() - dx, -centerPoint.y() - dy);


        if (glSprite && !mIsAnimationPlaying && mShowAnimationUI)
        {
            renderCelBox(painter, glSprite, centerPoint - glSprite->mSpriteDescriptor.center());
        }

    iter++;
    }

    if (mIsAnimationPlaying)
    {
        // update emitted animations
        for (int lineNo = 0; lineNo < AnimationModel::LINE_COUNT; lineNo++)
        {
            for (int i = mEmittedAnimationList[lineNo].count() - 1; i >= 0; i--)
            {
                mEmittedAnimationList[lineNo][i]->update();
                if (mEmittedAnimationList[lineNo][i]->isDone())
                {
                    mEmittedAnimationList[lineNo].removeAt(i);
                }
            }
        }
    }
}