leocad/common/lc_scene.cpp

515 lines
16 KiB
C++
Raw Normal View History

2017-04-02 01:53:54 +02:00
#include "lc_global.h"
#include "lc_scene.h"
#include "lc_context.h"
#include "pieceinf.h"
#include "lc_texture.h"
#include "lc_library.h"
#include "lc_application.h"
#include "object.h"
lcScene::lcScene()
: mRenderMeshes(0, 1024), mOpaqueMeshes(0, 1024), mTranslucentMeshes(0, 1024), mInterfaceObjects(0, 1024)
{
mActiveSubmodelInstance = nullptr;
2019-12-07 17:31:56 +01:00
mDrawInterface = false;
2021-01-10 01:02:23 +01:00
mShadingMode = lcShadingMode::DefaultLights;
mAllowLOD = true;
2020-08-16 01:16:26 +02:00
mMeshLODDistance = 250.0f;
mHasFadedParts = false;
mPreTranslucentCallback = nullptr;
2017-04-02 01:53:54 +02:00
}
void lcScene::Begin(const lcMatrix44& ViewMatrix)
{
mViewMatrix = ViewMatrix;
mActiveSubmodelInstance = nullptr;
mPreTranslucentCallback = nullptr;
2017-04-02 01:53:54 +02:00
mRenderMeshes.RemoveAll();
mOpaqueMeshes.RemoveAll();
mTranslucentMeshes.RemoveAll();
mInterfaceObjects.RemoveAll();
2020-04-25 21:16:37 +02:00
const lcPreferences& Preferences = lcGetPreferences();
mHighlightColor = lcVector4FromColor(Preferences.mHighlightNewPartsColor);
mFadeColor = lcVector4FromColor(Preferences.mFadeStepsColor);
mHasFadedParts = false;
mTranslucentFade = mFadeColor.w != 1.0f;
2017-04-02 01:53:54 +02:00
}
void lcScene::End()
{
2020-03-23 04:18:52 +01:00
const auto OpaqueMeshCompare = [this](int Index1, int Index2)
2017-04-02 01:53:54 +02:00
{
const lcMesh* Mesh1 = mRenderMeshes[Index1].Mesh;
const lcMesh* Mesh2 = mRenderMeshes[Index2].Mesh;
2020-03-23 04:18:52 +01:00
const int Texture1 = Mesh1->mFlags & lcMeshFlag::HasTexture;
const int Texture2 = Mesh2->mFlags & lcMeshFlag::HasTexture;
if (Texture1 == Texture2)
return Mesh1 < Mesh2;
return Texture1 ? false : true;
2017-04-02 01:53:54 +02:00
};
2019-03-29 01:59:58 +01:00
std::sort(mOpaqueMeshes.begin(), mOpaqueMeshes.end(), OpaqueMeshCompare);
2017-04-02 01:53:54 +02:00
2020-02-24 23:31:08 +01:00
auto TranslucentMeshCompare = [](const lcTranslucentMeshInstance& Mesh1, const lcTranslucentMeshInstance& Mesh2)
2017-04-02 01:53:54 +02:00
{
2019-11-23 01:47:58 +01:00
return Mesh1.Distance > Mesh2.Distance;
2017-04-02 01:53:54 +02:00
};
2019-03-29 01:59:58 +01:00
std::sort(mTranslucentMeshes.begin(), mTranslucentMeshes.end(), TranslucentMeshCompare);
2017-04-02 01:53:54 +02:00
}
2019-07-21 17:56:37 +02:00
void lcScene::AddMesh(lcMesh* Mesh, const lcMatrix44& WorldMatrix, int ColorIndex, lcRenderMeshState State)
2017-04-02 01:53:54 +02:00
{
lcRenderMesh& RenderMesh = mRenderMeshes.Add();
RenderMesh.WorldMatrix = WorldMatrix;
RenderMesh.Mesh = Mesh;
RenderMesh.ColorIndex = ColorIndex;
RenderMesh.State = State;
2020-08-16 01:16:26 +02:00
const float Distance = fabsf(lcMul31(WorldMatrix[3], mViewMatrix).z) - mMeshLODDistance;
RenderMesh.LodIndex = mAllowLOD ? RenderMesh.Mesh->GetLodIndex(Distance) : LC_MESH_LOD_HIGH;
2017-04-02 01:53:54 +02:00
2020-04-25 21:16:37 +02:00
const bool ForceTranslucent = (mTranslucentFade && State == lcRenderMeshState::Faded);
2020-04-20 05:21:18 +02:00
const bool Translucent = lcIsColorTranslucent(ColorIndex) || ForceTranslucent;
2020-03-23 04:18:52 +01:00
const lcMeshFlags Flags = Mesh->mFlags;
mHasFadedParts |= State == lcRenderMeshState::Faded;
2017-04-02 01:53:54 +02:00
2019-07-21 17:56:37 +02:00
if ((Flags & (lcMeshFlag::HasSolid | lcMeshFlag::HasLines)) || ((Flags & lcMeshFlag::HasDefault) && !Translucent))
2017-04-02 01:53:54 +02:00
mOpaqueMeshes.Add(mRenderMeshes.GetSize() - 1);
2019-07-21 17:56:37 +02:00
if ((Flags & lcMeshFlag::HasTranslucent) || ((Flags & lcMeshFlag::HasDefault) && Translucent))
2019-11-23 01:47:58 +01:00
{
const lcMeshLod& Lod = Mesh->mLods[RenderMesh.LodIndex];
for (int SectionIdx = 0; SectionIdx < Lod.NumSections; SectionIdx++)
{
const lcMeshSection* Section = &Lod.Sections[SectionIdx];
if ((Section->PrimitiveType & (LC_MESH_TRIANGLES | LC_MESH_TEXTURED_TRIANGLES)) == 0)
continue;
2020-01-19 01:53:33 +01:00
int SectionColorIndex = Section->ColorIndex;
2019-11-23 01:47:58 +01:00
2020-01-19 01:53:33 +01:00
if (SectionColorIndex == gDefaultColor)
SectionColorIndex = RenderMesh.ColorIndex;
2019-11-23 01:47:58 +01:00
2020-04-20 05:21:18 +02:00
if (!lcIsColorTranslucent(SectionColorIndex) && !ForceTranslucent)
2019-11-23 01:47:58 +01:00
continue;
2020-03-23 04:18:52 +01:00
const lcVector3 Center = (Section->BoundingBox.Min + Section->BoundingBox.Max) / 2;
const float InstanceDistance = fabsf(lcMul31(lcMul31(Center, WorldMatrix), mViewMatrix).z);
2019-11-23 01:47:58 +01:00
lcTranslucentMeshInstance& Instance = mTranslucentMeshes.Add();
Instance.Section = Section;
2020-01-19 01:53:33 +01:00
Instance.Distance = InstanceDistance;
2019-11-23 01:47:58 +01:00
Instance.RenderMeshIndex = mRenderMeshes.GetSize() - 1;
}
}
2017-04-02 01:53:54 +02:00
}
2020-03-23 04:18:52 +01:00
void lcScene::DrawDebugNormals(lcContext* Context, const lcMesh* Mesh) const
2017-04-02 01:53:54 +02:00
{
2021-03-26 04:46:37 +01:00
const lcVertex* const VertexBuffer = Mesh->GetVertexData();
const lcVertexTextured* const TexturedVertexBuffer = Mesh->GetTexturedVertexData();
lcVector3* const Vertices = (lcVector3*)malloc((Mesh->mNumVertices + Mesh->mNumTexturedVertices) * 2 * sizeof(lcVector3));
2019-11-23 01:47:58 +01:00
for (int VertexIdx = 0; VertexIdx < Mesh->mNumVertices; VertexIdx++)
{
Vertices[VertexIdx * 2] = VertexBuffer[VertexIdx].Position;
Vertices[VertexIdx * 2 + 1] = VertexBuffer[VertexIdx].Position + lcUnpackNormal(VertexBuffer[VertexIdx].Normal);
}
2021-03-26 04:46:37 +01:00
for (int VertexIdx = 0; VertexIdx < Mesh->mNumTexturedVertices; VertexIdx++)
{
Vertices[(Mesh->mNumVertices + VertexIdx) * 2] = TexturedVertexBuffer[VertexIdx].Position;
Vertices[(Mesh->mNumVertices + VertexIdx) * 2 + 1] = TexturedVertexBuffer[VertexIdx].Position + lcUnpackNormal(TexturedVertexBuffer[VertexIdx].Normal);
}
2019-11-23 01:47:58 +01:00
Context->SetVertexBufferPointer(Vertices);
Context->SetVertexFormatPosition(3);
2021-03-26 04:46:37 +01:00
Context->DrawPrimitives(GL_LINES, 0, (Mesh->mNumVertices + Mesh->mNumTexturedVertices) * 2);
2019-11-23 01:47:58 +01:00
free(Vertices);
}
2020-04-20 05:21:18 +02:00
void lcScene::DrawOpaqueMeshes(lcContext* Context, bool DrawLit, int PrimitiveTypes, bool DrawFaded, bool DrawNonFaded) const
2019-11-23 01:47:58 +01:00
{
if (mOpaqueMeshes.IsEmpty())
return;
lcMaterialType FlatMaterial, TexturedMaterial;
2019-11-23 01:47:58 +01:00
if (DrawLit)
{
2020-03-22 21:44:20 +01:00
FlatMaterial = lcMaterialType::FakeLitColor;
TexturedMaterial = lcMaterialType::FakeLitTextureDecal;
}
else
{
2020-03-22 21:44:20 +01:00
FlatMaterial = lcMaterialType::UnlitColor;
TexturedMaterial = lcMaterialType::UnlitTextureDecal;
}
2020-03-22 21:44:20 +01:00
Context->SetPolygonOffset(lcPolygonOffset::Opaque);
2017-04-02 01:53:54 +02:00
2020-03-23 04:18:52 +01:00
for (const int MeshIndex : mOpaqueMeshes)
2017-04-02 01:53:54 +02:00
{
const lcRenderMesh& RenderMesh = mRenderMeshes[MeshIndex];
const lcMesh* Mesh = RenderMesh.Mesh;
2020-03-23 04:18:52 +01:00
const int LodIndex = RenderMesh.LodIndex;
2017-04-02 01:53:54 +02:00
2020-04-20 05:21:18 +02:00
if (!DrawFaded && RenderMesh.State == lcRenderMeshState::Faded)
continue;
if (!DrawNonFaded && RenderMesh.State != lcRenderMeshState::Faded)
continue;
2017-04-02 01:53:54 +02:00
Context->BindMesh(Mesh);
Context->SetWorldMatrix(RenderMesh.WorldMatrix);
for (int SectionIdx = 0; SectionIdx < Mesh->mLods[LodIndex].NumSections; SectionIdx++)
{
2020-03-23 04:18:52 +01:00
const lcMeshSection* const Section = &Mesh->mLods[LodIndex].Sections[SectionIdx];
2017-04-02 01:53:54 +02:00
if ((Section->PrimitiveType & PrimitiveTypes) == 0)
2017-04-02 01:53:54 +02:00
continue;
int ColorIndex = Section->ColorIndex;
if (Section->PrimitiveType & (LC_MESH_TRIANGLES | LC_MESH_TEXTURED_TRIANGLES))
{
if (ColorIndex == gDefaultColor)
ColorIndex = RenderMesh.ColorIndex;
2019-11-23 01:47:58 +01:00
if (lcIsColorTranslucent(ColorIndex))
2017-04-02 01:53:54 +02:00
continue;
switch (RenderMesh.State)
{
2020-01-02 02:06:17 +01:00
case lcRenderMeshState::Default:
case lcRenderMeshState::Highlighted:
2017-04-02 01:53:54 +02:00
Context->SetColorIndex(ColorIndex);
break;
2020-01-02 02:06:17 +01:00
case lcRenderMeshState::Selected:
Context->SetColorIndexTinted(ColorIndex, LC_COLOR_SELECTED, 0.5f);
2017-04-02 01:53:54 +02:00
break;
2020-01-02 02:06:17 +01:00
case lcRenderMeshState::Focused:
Context->SetColorIndexTinted(ColorIndex, LC_COLOR_FOCUSED, 0.5f);
break;
2020-01-02 02:06:17 +01:00
case lcRenderMeshState::Faded:
2020-04-25 21:16:37 +02:00
if (mTranslucentFade)
2020-04-20 05:21:18 +02:00
continue;
2020-04-25 21:16:37 +02:00
Context->SetColorIndexTinted(ColorIndex, mFadeColor);
2017-04-02 01:53:54 +02:00
break;
}
}
2021-03-07 20:05:44 +01:00
else if (Section->PrimitiveType & (LC_MESH_LINES | LC_MESH_CONDITIONAL_LINES))
2017-04-02 01:53:54 +02:00
{
switch (RenderMesh.State)
{
2020-01-02 02:06:17 +01:00
case lcRenderMeshState::Default:
2021-01-10 01:02:23 +01:00
if (mShadingMode != lcShadingMode::Wireframe)
{
if (ColorIndex != gEdgeColor)
Context->SetColorIndex(ColorIndex);
else
Context->SetEdgeColorIndex(RenderMesh.ColorIndex);
}
2017-04-02 01:53:54 +02:00
else
2021-01-10 01:02:23 +01:00
{
if (ColorIndex == gEdgeColor)
ColorIndex = RenderMesh.ColorIndex;
2017-04-02 01:53:54 +02:00
Context->SetColorIndex(ColorIndex);
2021-01-10 01:02:23 +01:00
}
2017-04-02 01:53:54 +02:00
break;
2020-01-02 02:06:17 +01:00
case lcRenderMeshState::Selected:
2017-04-02 01:53:54 +02:00
Context->SetInterfaceColor(LC_COLOR_SELECTED);
break;
2020-01-02 02:06:17 +01:00
case lcRenderMeshState::Focused:
2017-04-02 01:53:54 +02:00
Context->SetInterfaceColor(LC_COLOR_FOCUSED);
break;
2020-01-02 02:06:17 +01:00
case lcRenderMeshState::Highlighted:
2020-04-25 21:16:37 +02:00
Context->SetColor(mHighlightColor);
break;
2020-01-02 02:06:17 +01:00
case lcRenderMeshState::Faded:
2020-04-25 21:16:37 +02:00
Context->SetEdgeColorIndexTinted(ColorIndex, mFadeColor);
break;
2017-04-02 01:53:54 +02:00
}
2021-03-07 20:05:44 +01:00
if (Section->PrimitiveType == LC_MESH_CONDITIONAL_LINES)
{
int VertexBufferOffset = Mesh->mVertexCacheOffset != -1 ? Mesh->mVertexCacheOffset : 0;
VertexBufferOffset += Mesh->mNumVertices * sizeof(lcVertex) + Mesh->mNumTexturedVertices * sizeof(lcVertexTextured);
const int IndexBufferOffset = Mesh->mIndexCacheOffset != -1 ? Mesh->mIndexCacheOffset : 0;
2017-04-02 01:53:54 +02:00
2021-03-07 20:05:44 +01:00
Context->SetMaterial(lcMaterialType::UnlitColorConditional);
Context->SetVertexFormatConditional(VertexBufferOffset);
2017-06-23 03:45:45 +02:00
2021-03-07 20:05:44 +01:00
Context->DrawIndexedPrimitives(GL_LINES, Section->NumIndices, Mesh->mIndexType, IndexBufferOffset + Section->IndexOffset);
continue;
}
2017-04-02 01:53:54 +02:00
}
lcTexture* const Texture = Section->Texture;
2017-04-02 01:53:54 +02:00
int VertexBufferOffset = Mesh->mVertexCacheOffset != -1 ? Mesh->mVertexCacheOffset : 0;
2020-03-23 04:18:52 +01:00
const int IndexBufferOffset = Mesh->mIndexCacheOffset != -1 ? Mesh->mIndexCacheOffset : 0;
2017-04-02 01:53:54 +02:00
if (!Texture)
{
Context->SetMaterial(FlatMaterial);
2019-11-23 01:47:58 +01:00
Context->SetVertexFormat(VertexBufferOffset, 3, 1, 0, 0, DrawLit);
2017-04-02 01:53:54 +02:00
}
else
{
if (Texture->NeedsUpload())
Texture->Upload(Context);
Context->SetMaterial(TexturedMaterial);
2017-04-02 01:53:54 +02:00
VertexBufferOffset += Mesh->mNumVertices * sizeof(lcVertex);
2019-11-23 01:47:58 +01:00
Context->SetVertexFormat(VertexBufferOffset, 3, 1, 2, 0, DrawLit);
2017-12-26 19:19:20 +01:00
Context->BindTexture2D(Texture->mTexture);
2017-04-02 01:53:54 +02:00
}
2020-03-23 04:18:52 +01:00
const GLenum DrawPrimitiveType = Section->PrimitiveType & (LC_MESH_TRIANGLES | LC_MESH_TEXTURED_TRIANGLES) ? GL_TRIANGLES : GL_LINES;
2017-04-02 01:53:54 +02:00
Context->DrawIndexedPrimitives(DrawPrimitiveType, Section->NumIndices, Mesh->mIndexType, IndexBufferOffset + Section->IndexOffset);
}
2019-11-23 01:47:58 +01:00
#ifdef LC_DEBUG_NORMALS
DrawDebugNormals(Context, Mesh);
#endif
}
Context->BindTexture2D(0);
2020-03-22 21:44:20 +01:00
Context->SetPolygonOffset(lcPolygonOffset::None);
2019-11-23 01:47:58 +01:00
}
2020-04-20 05:21:18 +02:00
void lcScene::DrawTranslucentMeshes(lcContext* Context, bool DrawLit, bool DrawFadePrepass, bool DrawFaded, bool DrawNonFaded) const
2019-11-23 01:47:58 +01:00
{
if (mTranslucentMeshes.IsEmpty())
return;
lcMaterialType FlatMaterial, TexturedMaterial;
if (DrawLit)
{
2020-03-22 21:44:20 +01:00
FlatMaterial = lcMaterialType::FakeLitColor;
TexturedMaterial = lcMaterialType::FakeLitTextureDecal;
2019-11-23 01:47:58 +01:00
}
else
{
2020-03-22 21:44:20 +01:00
FlatMaterial = lcMaterialType::UnlitColor;
TexturedMaterial = lcMaterialType::UnlitTextureDecal;
2019-11-23 01:47:58 +01:00
}
2020-04-20 05:21:18 +02:00
if (!DrawFadePrepass)
{
glEnable(GL_BLEND);
Context->SetDepthWrite(false);
}
else
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
2020-03-22 21:44:20 +01:00
Context->SetPolygonOffset(lcPolygonOffset::Translucent);
2019-11-23 01:47:58 +01:00
for (const lcTranslucentMeshInstance& MeshInstance : mTranslucentMeshes)
{
const lcRenderMesh& RenderMesh = mRenderMeshes[MeshInstance.RenderMeshIndex];
const lcMesh* Mesh = RenderMesh.Mesh;
2020-04-20 05:21:18 +02:00
if (!DrawFaded && RenderMesh.State == lcRenderMeshState::Faded)
continue;
if (!DrawNonFaded && RenderMesh.State != lcRenderMeshState::Faded)
continue;
2019-11-23 01:47:58 +01:00
Context->BindMesh(Mesh);
Context->SetWorldMatrix(RenderMesh.WorldMatrix);
const lcMeshSection* Section = MeshInstance.Section;
2017-04-02 01:53:54 +02:00
2019-11-23 01:47:58 +01:00
int ColorIndex = Section->ColorIndex;
if (ColorIndex == gDefaultColor)
ColorIndex = RenderMesh.ColorIndex;
if (DrawFadePrepass && lcIsColorTranslucent(ColorIndex))
continue;
2019-11-23 01:47:58 +01:00
switch (RenderMesh.State)
2017-04-02 01:53:54 +02:00
{
2020-01-02 02:06:17 +01:00
case lcRenderMeshState::Default:
case lcRenderMeshState::Highlighted:
2019-11-23 01:47:58 +01:00
Context->SetColorIndex(ColorIndex);
break;
2020-01-02 02:06:17 +01:00
case lcRenderMeshState::Selected:
2019-11-23 01:47:58 +01:00
Context->SetColorIndexTinted(ColorIndex, LC_COLOR_SELECTED, 0.5f);
break;
2020-01-02 02:06:17 +01:00
case lcRenderMeshState::Focused:
2019-11-23 01:47:58 +01:00
Context->SetColorIndexTinted(ColorIndex, LC_COLOR_FOCUSED, 0.5f);
break;
2020-01-02 02:06:17 +01:00
case lcRenderMeshState::Faded:
2020-04-25 21:16:37 +02:00
Context->SetColorIndexTinted(ColorIndex, mFadeColor);
2019-11-23 01:47:58 +01:00
break;
}
2017-04-02 01:53:54 +02:00
lcTexture* const Texture = Section->Texture;
2019-11-23 01:47:58 +01:00
int VertexBufferOffset = Mesh->mVertexCacheOffset != -1 ? Mesh->mVertexCacheOffset : 0;
2020-03-23 04:18:52 +01:00
const int IndexBufferOffset = Mesh->mIndexCacheOffset != -1 ? Mesh->mIndexCacheOffset : 0;
2017-04-02 01:53:54 +02:00
2019-11-23 01:47:58 +01:00
if (!Texture)
{
Context->SetMaterial(FlatMaterial);
Context->SetVertexFormat(VertexBufferOffset, 3, 1, 0, 0, DrawLit);
}
else
{
if (Texture->NeedsUpload())
Texture->Upload(Context);
2019-11-23 01:47:58 +01:00
Context->SetMaterial(TexturedMaterial);
VertexBufferOffset += Mesh->mNumVertices * sizeof(lcVertex);
Context->SetVertexFormat(VertexBufferOffset, 3, 1, 2, 0, DrawLit);
Context->BindTexture2D(Texture->mTexture);
2017-04-02 01:53:54 +02:00
}
2019-11-23 01:47:58 +01:00
2020-03-23 04:18:52 +01:00
const GLenum DrawPrimitiveType = Section->PrimitiveType & (LC_MESH_TRIANGLES | LC_MESH_TEXTURED_TRIANGLES) ? GL_TRIANGLES : GL_LINES;
2019-11-23 01:47:58 +01:00
Context->DrawIndexedPrimitives(DrawPrimitiveType, Section->NumIndices, Mesh->mIndexType, IndexBufferOffset + Section->IndexOffset);
#ifdef LC_DEBUG_NORMALS
DrawDebugNormals(Context, Mesh);
2017-04-02 01:53:54 +02:00
#endif
}
2019-11-18 23:32:53 +01:00
Context->BindTexture2D(0);
2020-03-22 21:44:20 +01:00
Context->SetPolygonOffset(lcPolygonOffset::None);
2019-11-18 23:32:53 +01:00
2020-04-20 05:21:18 +02:00
if (!DrawFadePrepass)
{
Context->SetDepthWrite(true);
glDisable(GL_BLEND);
}
else
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
2017-04-02 01:53:54 +02:00
}
void lcScene::Draw(lcContext* Context) const
{
// TODO: find a better place for these updates
lcGetPiecesLibrary()->UpdateBuffers(Context);
2017-04-02 01:53:54 +02:00
Context->SetViewMatrix(mViewMatrix);
const lcPreferences& Preferences = lcGetPreferences();
2021-03-07 18:53:35 +01:00
const bool DrawLines = Preferences.mDrawEdgeLines && Preferences.mLineWidth > 0.0f;
const bool DrawConditional = Preferences.mDrawConditionalLines && Preferences.mLineWidth > 0.0f;
2017-06-23 03:45:45 +02:00
2021-01-10 01:02:23 +01:00
// lcShadingMode ShadingMode = Preferences.mShadingMode;
// if (ShadingMode == lcShadingMode::Wireframe && !mAllowWireframe)
// ShadingMode = lcShadingMode::Flat;
2017-08-25 21:57:14 +02:00
2021-01-10 01:02:23 +01:00
if (mShadingMode == lcShadingMode::Wireframe)
2017-04-02 01:53:54 +02:00
{
DrawOpaqueMeshes(Context, false, LC_MESH_LINES, true, true);
if (DrawConditional)
DrawOpaqueMeshes(Context, false, LC_MESH_CONDITIONAL_LINES, true, true);
if (mPreTranslucentCallback)
mPreTranslucentCallback();
}
2021-01-10 01:02:23 +01:00
else if (mShadingMode == lcShadingMode::Flat)
{
const int SolidPrimitiveTypes = LC_MESH_TRIANGLES | LC_MESH_TEXTURED_TRIANGLES | (DrawLines ? LC_MESH_LINES : 0);
2020-04-20 05:21:18 +02:00
2020-04-25 21:16:37 +02:00
if (mTranslucentFade && mHasFadedParts)
2017-06-23 03:45:45 +02:00
{
DrawOpaqueMeshes(Context, false, SolidPrimitiveTypes, false, true);
2017-06-23 03:45:45 +02:00
2020-04-20 05:21:18 +02:00
if (mPreTranslucentCallback)
mPreTranslucentCallback();
2020-04-20 05:21:18 +02:00
DrawTranslucentMeshes(Context, false, true, true, false);
2020-04-20 05:21:18 +02:00
if (DrawLines)
DrawOpaqueMeshes(Context, false, LC_MESH_LINES, true, false);
if (DrawConditional)
DrawOpaqueMeshes(Context, false, LC_MESH_CONDITIONAL_LINES, true, false);
2020-04-20 05:21:18 +02:00
DrawTranslucentMeshes(Context, false, false, true, true);
2020-04-20 05:21:18 +02:00
}
else
{
DrawOpaqueMeshes(Context, false, SolidPrimitiveTypes, true, true);
if (DrawConditional)
DrawOpaqueMeshes(Context, false, LC_MESH_CONDITIONAL_LINES, true, true);
2020-04-20 05:21:18 +02:00
if (mPreTranslucentCallback)
mPreTranslucentCallback();
DrawTranslucentMeshes(Context, false, false, true, true);
2020-04-20 05:21:18 +02:00
}
2017-04-02 01:53:54 +02:00
}
else
{
2020-04-25 21:16:37 +02:00
if (mTranslucentFade && mHasFadedParts)
2017-04-02 01:53:54 +02:00
{
2020-04-20 05:21:18 +02:00
DrawOpaqueMeshes(Context, true, LC_MESH_TRIANGLES | LC_MESH_TEXTURED_TRIANGLES, false, true);
if (DrawLines)
DrawOpaqueMeshes(Context, false, LC_MESH_LINES, false, true);
if (DrawConditional)
DrawOpaqueMeshes(Context, false, LC_MESH_CONDITIONAL_LINES, false, true);
2020-04-20 05:21:18 +02:00
if (mPreTranslucentCallback)
mPreTranslucentCallback();
2017-06-23 03:45:45 +02:00
2020-04-20 05:21:18 +02:00
DrawTranslucentMeshes(Context, false, true, true, false);
2017-06-23 03:45:45 +02:00
2020-04-20 05:21:18 +02:00
if (DrawLines)
DrawOpaqueMeshes(Context, false, LC_MESH_LINES, true, false);
if (DrawConditional)
DrawOpaqueMeshes(Context, false, LC_MESH_CONDITIONAL_LINES, true, false);
2020-04-20 05:21:18 +02:00
DrawTranslucentMeshes(Context, true, false, true, true);
2017-04-02 01:53:54 +02:00
}
2020-04-20 05:21:18 +02:00
else
{
if (DrawLines)
DrawOpaqueMeshes(Context, false, LC_MESH_LINES, true, true);
if (DrawConditional)
DrawOpaqueMeshes(Context, false, LC_MESH_CONDITIONAL_LINES, true, true);
2017-04-02 01:53:54 +02:00
2020-04-20 05:21:18 +02:00
DrawOpaqueMeshes(Context, true, LC_MESH_TRIANGLES | LC_MESH_TEXTURED_TRIANGLES, true, true);
2020-04-20 05:21:18 +02:00
if (mPreTranslucentCallback)
mPreTranslucentCallback();
2020-04-20 05:21:18 +02:00
DrawTranslucentMeshes(Context, true, false, true, true);
}
2017-04-02 01:53:54 +02:00
}
}
void lcScene::DrawInterfaceObjects(lcContext* Context) const
{
for (const lcObject* Object : mInterfaceObjects)
Object->DrawInterface(Context, *this);
2017-04-02 01:53:54 +02:00
}