Use part color for wireframe lines.

This commit is contained in:
Leonardo Zide 2021-01-09 16:02:23 -08:00
parent 601eb56322
commit 138f749053
5 changed files with 34 additions and 13 deletions

View file

@ -66,6 +66,7 @@ typedef std::map<const PieceInfo*, std::map<int, int>> lcPartsList;
struct lcModelPartsEntry; struct lcModelPartsEntry;
struct lcMinifig; struct lcMinifig;
enum class lcViewpoint; enum class lcViewpoint;
enum class lcShadingMode;
class lcInstructions; class lcInstructions;
struct lcInstructionsPageSetup; struct lcInstructionsPageSetup;
struct lcObjectRayTest; struct lcObjectRayTest;

View file

@ -1389,7 +1389,13 @@ QImage lcModel::GetPartsListImage(int MaxWidth, lcStep Step) const
Context->ClearColorAndDepth(lcVector4(1.0f, 1.0f, 1.0f, 0.0f)); Context->ClearColorAndDepth(lcVector4(1.0f, 1.0f, 1.0f, 0.0f));
lcScene Scene; lcScene Scene;
Scene.SetAllowWireframe(false);
const lcPreferences& Preferences = lcGetPreferences();
lcShadingMode ShadingMode = Preferences.mShadingMode;
if (ShadingMode == lcShadingMode::Wireframe)
ShadingMode = lcShadingMode::Flat;
Scene.SetShadingMode(ShadingMode);
Scene.SetAllowLOD(false); Scene.SetAllowLOD(false);
Scene.Begin(ViewMatrix); Scene.Begin(ViewMatrix);

View file

@ -12,7 +12,7 @@ lcScene::lcScene()
{ {
mActiveSubmodelInstance = nullptr; mActiveSubmodelInstance = nullptr;
mDrawInterface = false; mDrawInterface = false;
mAllowWireframe = true; mShadingMode = lcShadingMode::DefaultLights;
mAllowLOD = true; mAllowLOD = true;
mMeshLODDistance = 250.0f; mMeshLODDistance = 250.0f;
mHasFadedParts = false; mHasFadedParts = false;
@ -207,10 +207,20 @@ void lcScene::DrawOpaqueMeshes(lcContext* Context, bool DrawLit, int PrimitiveTy
switch (RenderMesh.State) switch (RenderMesh.State)
{ {
case lcRenderMeshState::Default: case lcRenderMeshState::Default:
if (ColorIndex == gEdgeColor) if (mShadingMode != lcShadingMode::Wireframe)
Context->SetEdgeColorIndex(RenderMesh.ColorIndex); {
if (ColorIndex != gEdgeColor)
Context->SetColorIndex(ColorIndex);
else
Context->SetEdgeColorIndex(RenderMesh.ColorIndex);
}
else else
{
if (ColorIndex == gEdgeColor)
ColorIndex = RenderMesh.ColorIndex;
Context->SetColorIndex(ColorIndex); Context->SetColorIndex(ColorIndex);
}
break; break;
case lcRenderMeshState::Selected: case lcRenderMeshState::Selected:
@ -423,11 +433,11 @@ void lcScene::Draw(lcContext* Context) const
constexpr bool DrawConditional = false; constexpr bool DrawConditional = false;
const lcPreferences& Preferences = lcGetPreferences(); const lcPreferences& Preferences = lcGetPreferences();
lcShadingMode ShadingMode = Preferences.mShadingMode; // lcShadingMode ShadingMode = Preferences.mShadingMode;
if (ShadingMode == lcShadingMode::Wireframe && !mAllowWireframe) // if (ShadingMode == lcShadingMode::Wireframe && !mAllowWireframe)
ShadingMode = lcShadingMode::Flat; // ShadingMode = lcShadingMode::Flat;
if (ShadingMode == lcShadingMode::Wireframe) if (mShadingMode == lcShadingMode::Wireframe)
{ {
int PrimitiveTypes = LC_MESH_LINES; int PrimitiveTypes = LC_MESH_LINES;
@ -439,7 +449,7 @@ void lcScene::Draw(lcContext* Context) const
if (mPreTranslucentCallback) if (mPreTranslucentCallback)
mPreTranslucentCallback(); mPreTranslucentCallback();
} }
else if (ShadingMode == lcShadingMode::Flat) else if (mShadingMode == lcShadingMode::Flat)
{ {
const bool DrawLines = Preferences.mDrawEdgeLines && Preferences.mLineWidth != 0.0f; const bool DrawLines = Preferences.mDrawEdgeLines && Preferences.mLineWidth != 0.0f;

View file

@ -59,9 +59,9 @@ public:
return mDrawInterface; return mDrawInterface;
} }
void SetAllowWireframe(bool AllowWireframe) void SetShadingMode(lcShadingMode ShadingMode)
{ {
mAllowWireframe = AllowWireframe; mShadingMode = ShadingMode;
} }
void SetAllowLOD(bool AllowLOD) void SetAllowLOD(bool AllowLOD)
@ -104,8 +104,8 @@ protected:
lcMatrix44 mViewMatrix; lcMatrix44 mViewMatrix;
lcMatrix44 mActiveSubmodelTransform; lcMatrix44 mActiveSubmodelTransform;
lcPiece* mActiveSubmodelInstance; lcPiece* mActiveSubmodelInstance;
lcShadingMode mShadingMode;
bool mDrawInterface; bool mDrawInterface;
bool mAllowWireframe;
bool mAllowLOD; bool mAllowLOD;
float mMeshLODDistance; float mMeshLODDistance;

View file

@ -835,7 +835,11 @@ void lcView::OnDraw()
const bool DrawOverlays = mWidget != nullptr; const bool DrawOverlays = mWidget != nullptr;
const bool DrawInterface = mWidget != nullptr && mViewType == lcViewType::View; const bool DrawInterface = mWidget != nullptr && mViewType == lcViewType::View;
mScene->SetAllowWireframe(mWidget != nullptr); lcShadingMode ShadingMode = Preferences.mShadingMode;
if (ShadingMode == lcShadingMode::Wireframe && !mWidget)
ShadingMode = lcShadingMode::Flat;
mScene->SetShadingMode(ShadingMode);
mScene->SetAllowLOD(Preferences.mAllowLOD && mWidget != nullptr); mScene->SetAllowLOD(Preferences.mAllowLOD && mWidget != nullptr);
mScene->SetLODDistance(Preferences.mMeshLODDistance); mScene->SetLODDistance(Preferences.mMeshLODDistance);