- add two-sided culling support in software and poly

This commit is contained in:
Magnus Norddahl 2018-05-24 01:39:36 +02:00
commit 8098657cf4
4 changed files with 47 additions and 0 deletions

View file

@ -79,6 +79,11 @@ void PolyTriangleDrawer::SetCullCCW(const DrawerCommandQueuePtr &queue, bool ccw
queue->Push<PolySetCullCCWCommand>(ccw);
}
void PolyTriangleDrawer::SetTwoSided(const DrawerCommandQueuePtr &queue, bool twosided)
{
queue->Push<PolySetTwoSidedCommand>(twosided);
}
void PolyTriangleDrawer::SetWeaponScene(const DrawerCommandQueuePtr &queue, bool enable)
{
queue->Push<PolySetWeaponSceneCommand>(enable);
@ -348,6 +353,14 @@ void PolyTriangleThreadData::DrawShadedTriangle(const ShadedTriVertex *vert, boo
}
}
if (twosided && numclipvert > 2)
{
args->v1 = &clippedvert[0];
args->v2 = &clippedvert[1];
args->v3 = &clippedvert[2];
ccw = !IsFrontfacing(args);
}
// Draw screen triangles
if (ccw)
{
@ -588,6 +601,17 @@ void PolySetCullCCWCommand::Execute(DrawerThread *thread)
/////////////////////////////////////////////////////////////////////////////
PolySetTwoSidedCommand::PolySetTwoSidedCommand(bool twosided) : twosided(twosided)
{
}
void PolySetTwoSidedCommand::Execute(DrawerThread *thread)
{
PolyTriangleThreadData::Get(thread)->SetTwoSided(twosided);
}
/////////////////////////////////////////////////////////////////////////////
PolySetWeaponSceneCommand::PolySetWeaponSceneCommand(bool value) : value(value)
{
}