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 lcMinifig;
enum class lcViewpoint;
enum class lcShadingMode;
class lcInstructions;
struct lcInstructionsPageSetup;
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));
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.Begin(ViewMatrix);

View file

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

View file

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

View file

@ -835,7 +835,11 @@ void lcView::OnDraw()
const bool DrawOverlays = mWidget != nullptr;
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->SetLODDistance(Preferences.mMeshLODDistance);