示例#1
0
void RenderPolyScene::AddModel(PolyRenderThread *thread, AActor *thing, double sortDistance, DVector2 pos)
{
	if (PolyRenderer::Instance()->Level->nodes.Size() == 0)
	{
		subsector_t *sub = &PolyRenderer::Instance()->Level->subsectors[0];
		if (Cull.SubsectorDepths[sub->Index()] != 0xffffffff)
			thread->TranslucentObjects.push_back(thread->FrameMemory->NewObject<PolyTranslucentThing>(thing, sub, Cull.SubsectorDepths[sub->Index()], sortDistance, 0.0f, 1.0f, CurrentViewpoint->StencilValue));
	}
	else
	{
		void *node = PolyRenderer::Instance()->Level->HeadNode();

		while (!((size_t)node & 1))  // Keep going until found a subsector
		{
			node_t *bsp = (node_t *)node;

			DVector2 planePos(FIXED2DBL(bsp->x), FIXED2DBL(bsp->y));
			DVector2 planeNormal = DVector2(FIXED2DBL(-bsp->dy), FIXED2DBL(bsp->dx));
			double planeD = planeNormal | planePos;

			int side = (pos | planeNormal) > planeD;
			node = bsp->children[side];
		}

		subsector_t *sub = (subsector_t *)((uint8_t *)node - 1);

		if (Cull.SubsectorDepths[sub->Index()] != 0xffffffff)
			thread->TranslucentObjects.push_back(thread->FrameMemory->NewObject<PolyTranslucentThing>(thing, sub, Cull.SubsectorDepths[sub->Index()], sortDistance, 0.0f, 1.0f, CurrentViewpoint->StencilValue));
	}
}
示例#2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void Clipping::configureClipPlaneSetFromProperties()
{
    CVF_ASSERT(m_clipPlaneSet.notNull());
    m_clipPlaneSet->clear();

    if (m_propEnableXClip->value())
    {
        m_clipPlaneSet->addPlane(Plane(1, 0, 0, -0.02));
    }

    if (m_propEnableYClip->value())
    {
        m_clipPlaneSet->addPlane(Plane(0, 1, 0, -0.07));
    }

    if (m_propEnableZClip->value())
    {
        m_clipPlaneSet->addPlane(Plane(0, 0, 1, 0.02));
    }

    if (m_propEnableUserClip->value())
    {
        Vec3d planePos(m_propPosX->value(), m_propPosY->value(), m_propPosZ->value());
        Vec3d planeNorm(m_propNormalX->value(), m_propNormalY->value(), m_propNormalZ->value());
        if (!planeNorm.isZero())
        {
            Plane wcClipPlane;
            wcClipPlane.setFromPointAndNormal(planePos, planeNorm);
            m_clipPlaneSet->addPlane(wcClipPlane);
        }
    }
}
示例#3
0
void RenderPolyScene::AddSprite(PolyRenderThread *thread, AActor *thing, double sortDistance, DVector2 left, DVector2 right, double t1, double t2, void *node)
{
	while (!((size_t)node & 1))  // Keep going until found a subsector
	{
		node_t *bsp = (node_t *)node;
		
		DVector2 planePos(FIXED2DBL(bsp->x), FIXED2DBL(bsp->y));
		DVector2 planeNormal = DVector2(FIXED2DBL(-bsp->dy), FIXED2DBL(bsp->dx));
		double planeD = planeNormal | planePos;
		
		int sideLeft = (left | planeNormal) > planeD;
		int sideRight = (right | planeNormal) > planeD;
		
		if (sideLeft != sideRight)
		{
			double dotLeft = planeNormal | left;
			double dotRight = planeNormal | right;
			double t = (planeD - dotLeft) / (dotRight - dotLeft);
			
			DVector2 mid = left * (1.0 - t) + right * t;
			double tmid = t1 * (1.0 - t) + t2 * t;
			
			AddSprite(thread, thing, sortDistance, mid, right, tmid, t2, bsp->children[sideRight]);
			right = mid;
			t2 = tmid;
		}
		node = bsp->children[sideLeft];
	}
	
	subsector_t *sub = (subsector_t *)((uint8_t *)node - 1);
	
	if (Cull.SubsectorDepths[sub->Index()] != 0xffffffff)
		thread->TranslucentObjects.push_back(thread->FrameMemory->NewObject<PolyTranslucentThing>(thing, sub, Cull.SubsectorDepths[sub->Index()], sortDistance, (float)t1, (float)t2, CurrentViewpoint->StencilValue));
}
示例#4
0
	uint32_t VisibleSpriteList::FindSubsectorDepth(RenderThread *thread, const DVector2 &worldPos, void *node)
	{
		while (!((size_t)node & 1))  // Keep going until found a subsector
		{
			node_t *bsp = (node_t *)node;

			DVector2 planePos(FIXED2DBL(bsp->x), FIXED2DBL(bsp->y));
			DVector2 planeNormal = DVector2(FIXED2DBL(-bsp->dy), FIXED2DBL(bsp->dx));
			double planeD = planeNormal | planePos;

			int side = (worldPos | planeNormal) > planeD;
			node = bsp->children[side];
		}

		subsector_t *sub = (subsector_t *)((uint8_t *)node - 1);
		return thread->OpaquePass->GetSubsectorDepth(sub->Index());
	}