Skip to content

Commit

Permalink
Insert display model - fade colour for display step #704
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsandy committed May 8, 2023
1 parent 5ca9126 commit ea21ecc
Show file tree
Hide file tree
Showing 31 changed files with 278 additions and 195 deletions.
2 changes: 1 addition & 1 deletion builds/linux/obs/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Last Update: July 19, 2020
# Copyright (C) 2017 - 2023 by Trevor SANDY
pkgname=lpub3d
pkgver=2.4.6.3305
pkgver=2.4.6.3306
pkgrel=1
pkgdesc="An LDraw Building Instruction Editor"
url="https://github.com/trevorsandy/lpub3d.git"
Expand Down
2 changes: 1 addition & 1 deletion builds/linux/obs/alldeps/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Last Update: July 19, 2020
# Copyright (C) 2017 - 2023 by Trevor SANDY
pkgname=lpub3d
pkgver=2.4.6.3305
pkgver=2.4.6.3306
pkgrel=1
pkgdesc="An LDraw Building Instruction Editor"
url="https://github.com/trevorsandy/lpub3d.git"
Expand Down
6 changes: 3 additions & 3 deletions builds/linux/obs/alldeps/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lpub3d (2.4.6.3305) debian; urgency=medium
lpub3d (2.4.6.3306) debian; urgency=medium

* LPub3D version 2.4.6.194.3305_20230508 for Linux
* LPub3D version 2.4.6.195.3306_20230508 for Linux

-- Trevor SANDY <trevor.sandy@gmail.com> Mon, 08 May 2023 05:55:13 +0200
-- Trevor SANDY <trevor.sandy@gmail.com> Mon, 08 May 2023 05:55:36 +0200
2 changes: 1 addition & 1 deletion builds/linux/obs/alldeps/debian/lpub3d.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Format: 1.0
Source: lpub3d
Binary: lpub3d
Architecture: any
Version: 2.4.6.3305
Version: 2.4.6.3306
Maintainer: Trevor SANDY <trevor.sandy@gmail.com>
Homepage: https://trevorsandy.github.io/lpub3d/
Standards-Version: 3.9.7
Expand Down
4 changes: 2 additions & 2 deletions builds/linux/obs/alldeps/lpub3d.spec
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ BuildRequires: fdupes
Summary: An LDraw Building Instruction Editor
Name: lpub3d
Icon: lpub3d.xpm
Version: 2.4.6.3305
Version: 2.4.6.3306
Release: <B_CNT>%{?dist}
URL: https://trevorsandy.github.io/lpub3d
Vendor: Trevor SANDY
Expand Down Expand Up @@ -797,7 +797,7 @@ update-desktop-database || true
%endif

%changelog
* Mon May 08 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3305
* Mon May 08 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3306
- LPub3D 2.4.4 enhancements and fixes - see RELEASE_NOTES for details

* Tue May 31 2022 - trevor dot sandy at gmail dot com 2.4.4.2670
Expand Down
6 changes: 3 additions & 3 deletions builds/linux/obs/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lpub3d (2.4.6.3305) debian; urgency=medium
lpub3d (2.4.6.3306) debian; urgency=medium

* LPub3D version 2.4.6.194.3305_20230508 for Linux
* LPub3D version 2.4.6.195.3306_20230508 for Linux

-- Trevor SANDY <trevor.sandy@gmail.com> Mon, 08 May 2023 05:55:15 +0200
-- Trevor SANDY <trevor.sandy@gmail.com> Mon, 08 May 2023 05:55:38 +0200
2 changes: 1 addition & 1 deletion builds/linux/obs/debian/lpub3d.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Format: 1.0
Source: lpub3d
Binary: lpub3d
Architecture: any
Version: 2.4.6.3305
Version: 2.4.6.3306
Maintainer: Trevor SANDY <trevor.sandy@gmail.com>
Homepage: https://trevorsandy.github.io/lpub3d/
Standards-Version: 3.9.7
Expand Down
4 changes: 2 additions & 2 deletions builds/linux/obs/lpub3d.spec
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ BuildRequires: fdupes
Summary: An LDraw Building Instruction Editor
Name: lpub3d
Icon: lpub3d.xpm
Version: 2.4.6.3305
Version: 2.4.6.3306
Release: 1%{?dist}
URL: https://trevorsandy.github.io/lpub3d
Vendor: Trevor SANDY
Expand Down Expand Up @@ -313,7 +313,7 @@ update-desktop-database || true
%endif

%changelog
* Mon May 08 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3305
* Mon May 08 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3306
- LPub3D 2.4.4 enhancements and fixes - see RELEASE_NOTES for details

* Tue May 31 2022 - trevor dot sandy at gmail dot com 2.4.4.2670
Expand Down
2 changes: 1 addition & 1 deletion builds/utilities/version.info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2 4 6 194 3305 fb121c69a
2 4 6 195 3306 5ca912615
6 changes: 3 additions & 3 deletions gitversion.pri
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ equals(GIT_DIR, undefined) {

# Check if we do not have a valid version number (i.e. no version tag found)
isEmpty(GIT_VERSION) {
GIT_REVISION = 194
GIT_REVISION = 195
GIT_SHA = $$system($$GIT_BASE_COMMAND rev-parse --short HEAD 2> $$NULL_DEVICE)
GIT_COMMIT = $$system($$GIT_BASE_COMMAND rev-list --count HEAD 2> $$NULL_DEVICE)
GIT_VERSION = v$${VERSION}-$${GIT_REVISION}-$${GIT_SHA}
Expand Down Expand Up @@ -69,7 +69,7 @@ equals(GIT_DIR, undefined) {
# Get commit count
GIT_COMMIT = $$system($$GIT_BASE_COMMAND rev-list --count HEAD 2> $$NULL_DEVICE)
isEmpty(GIT_COMMIT) {
GIT_COMMIT = 3305
GIT_COMMIT = 3306
message("~~~ ERROR! GIT_COMMIT NOT DEFINED, USING $$GIT_COMMIT ~~~")
}

Expand Down Expand Up @@ -117,7 +117,7 @@ if (equals(USE_GIT_VER_FILE, true)|equals(USE_VERSION_INFO_VAR, true)) {
GIT_VERSION = $$cat($$GIT_VER_FILE, lines)
} else {
message("~~~ ERROR! $$GIT_DIR_ENV VERSION_INFO FILE $$GIT_VER_FILE NOT FOUND ~~~")
GIT_VERSION = $${VERSION}.194.3305.fb121c69a
GIT_VERSION = $${VERSION}.195.3306.5ca912615
message("~~~ GIT_DIR [$$GIT_DIR_ENV, USING VERSION] $$GIT_VERSION ~~~")
GIT_VERSION ~= s/\./" "
}
Expand Down
21 changes: 19 additions & 2 deletions lclib/common/lc_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,20 +337,37 @@ lcApplication::lcApplication(const lcCommandLineOptions &Options)
/*** LPub3D Mod - load color entry ***/
bool lcApplication::LPubHighlightStep()
{
return Preferences::enableHighlightStep;
if (mProject)
return mProject->mHighlightStep;
else
return Preferences::enableHighlightStep;
}
/*** LPub3D Mod end ***/
/*** LPub3D Mod - true fade ***/
// used by lcScene::Draw
bool lcApplication::LPubFadeSteps()
{
return Preferences::enableFadeSteps;
if (mProject)
return mProject->mFadeSteps;
else
return Preferences::enableFadeSteps;
}

bool lcApplication::UseLPubTrueFade()
{
if (mProject)
return mProject->mTrueFade;
else
return mPreferences.mLPubTrueFade;
}

// used by lcTimeLineWidget::Update
bool lcApplication::UseLPubFadeColour()
{
return Preferences::fadeStepsUseColour;
}

// used by lcTimeLineWidget::Update
QString lcApplication::LPubFadeColour()
{
return LDrawColor::code(Preferences::validFadeStepsColour);
Expand Down
1 change: 1 addition & 0 deletions lclib/common/lc_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ class lcApplication : public QObject
/*** LPub3D Mod end ***/
/*** LPub3D Mod - true fade ***/
bool LPubFadeSteps();
bool UseLPubTrueFade();
bool UseLPubFadeColour();
QString LPubFadeColour();
/*** LPub3D Mod end ***/
Expand Down
1 change: 1 addition & 0 deletions lclib/common/lc_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ void lcContext::EnableColorBlend(bool Enable)

/*** LPub3D Mod - true fade ***/
void lcContext::EnableCullFace(bool Enable, bool LPubFade)
/*** LPub3D Mod end ***/
{
if (Enable == mCullFace)
return;
Expand Down
12 changes: 0 additions & 12 deletions lclib/common/lc_meshloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#include "lc_library.h"
#include "lc_application.h"
#include "lc_texture.h"
/*** LPub3D Mod - true fade ***/
#include "QsLog.h"
/*** LPub3D Mod ***/

static void lcCheckTexCoordsWrap(const lcVector4& Plane2, const lcVector3 (&Positions)[3], lcVector2 (&TexCoords)[3])
{
Expand Down Expand Up @@ -1146,15 +1143,6 @@ bool lcMeshLoader::ReadMeshData(lcFile& File, const lcMatrix44& CurrentTransform
{
char* Token = Line;

/*** LPub3D Mod - true fade ***/
if (strstr(Token, "!COLOUR") != nullptr)
{
if (!lcLoadColorEntry(Line, Library->GetStudStyle()))
logError() << qPrintable(QString("Could not load colour meta %1.").arg(Line));
continue;
}
/*** LPub3D Mod end ***/

while (*Token && *Token <= 32)
Token++;

Expand Down
8 changes: 5 additions & 3 deletions lclib/common/lc_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,15 +585,14 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
else if (Token == QLatin1String("!COLOUR"))
{
if (!lcLoadColorEntry(OriginalLine.toLatin1().constData(), lcGetPiecesLibrary()->GetStudStyle()))
emit gui->messageSig(LOG_ERROR,QString("Could not load COLOUR command %1.")
emit gui->messageSig(LOG_WARNING,QString("Could not load COLOUR command %1.")
.arg(OriginalLine));
}
/*** LPub3D Mod end ***/
/*** LPub3D Mod - true fade ***/
else if (Token == QLatin1String("!FADE"))
{
QString FadeColor = LineStream.readAll().trimmed();
mLPubFade = FadeColor.isEmpty() ? false : true;
mLPubFade = !mLPubFade;
}
/*** LPub3D Mod end ***/
else if (Token == QLatin1String("FILE"))
Expand Down Expand Up @@ -627,6 +626,9 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
delete Piece;
Piece = nullptr;
CurrentStep++;
/*** LPub3D Mod - true fade ***/
mLPubFade = false;
/*** LPub3D Mod end ***/
mFileLines.append(OriginalLine);
continue;
}
Expand Down
31 changes: 11 additions & 20 deletions lclib/common/lc_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@
#include "lc_application.h"
#include "object.h"

/*** LPub3D Mod - true fade ***/
enum lcFadeArgs {
LC_NO_FADE,
LC_DISABLE_COLOR_WRITES,
LC_ENABLE_COLOR_WRITES,
LC_DISABLE_BFC
};
/*** LPub3D Mod end ***/

lcScene::lcScene()
: mRenderMeshes(0, 1024), mOpaqueMeshes(0, 1024), mTranslucentMeshes(0, 1024), mInterfaceObjects(0, 1024)
{
Expand Down Expand Up @@ -180,7 +171,7 @@ void lcScene::DrawOpaqueMeshes(lcContext* Context, bool DrawLit, int PrimitiveTy
const lcVector4 FocusedColor = lcVector4FromColor(Preferences.mObjectFocusedColor);
const lcVector4 SelectedColor = lcVector4FromColor(Preferences.mObjectSelectedColor);
/*** LPub3D Mod - Build mod object selected colour ***/
const lcVector4 BMSelectedColor = lcVector4FromColor(Preferences.mBMObjectSelectedColor);
const lcVector4 BMSelectedColor = lcVector4FromColor(Preferences.mBMObjectSelectedColor);
/*** LPub3D Mod end ***/

for (const int MeshIndex : mOpaqueMeshes)
Expand Down Expand Up @@ -344,7 +335,7 @@ void lcScene::DrawOpaqueMeshes(lcContext* Context, bool DrawLit, int PrimitiveTy
}

/*** LPub3D Mod - true fade ***/
void lcScene::DrawTranslucentMeshes(lcContext* Context, bool DrawLit, bool DrawFadePrepass, bool DrawFaded, bool DrawNonFaded, int LPubFade) const
void lcScene::DrawTranslucentMeshes(lcContext* Context, bool DrawLit, bool DrawFadePrepass, bool DrawFaded, bool DrawNonFaded, lcFadeArgs LPubFadeArg) const
/*** LPub3D Mod end ***/
{
if (mTranslucentMeshes.IsEmpty())
Expand All @@ -364,13 +355,13 @@ void lcScene::DrawTranslucentMeshes(lcContext* Context, bool DrawLit, bool DrawF
}

/*** LPub3D Mod - true fade ***/
if (LPubFade)
if (LPubFadeArg)
{
// Enable BFC
Context->EnableCullFace(true, true);

// Disable color writes
if (LPubFade == LC_DISABLE_COLOR_WRITES){
if (LPubFadeArg == LC_DISABLE_COLOR_WRITES){
Context->EnableColorBlend(false);
Context->EnableColorWrite(false);
}
Expand All @@ -381,7 +372,7 @@ void lcScene::DrawTranslucentMeshes(lcContext* Context, bool DrawLit, bool DrawF
Context->EnableColorWrite(true);
}

Context->SetDepthWrite(LPubFade == LC_DISABLE_COLOR_WRITES);
Context->SetDepthWrite(LPubFadeArg == LC_DISABLE_COLOR_WRITES);
}
else
/*** LPub3D Mod end ***/
Expand Down Expand Up @@ -421,7 +412,7 @@ void lcScene::DrawTranslucentMeshes(lcContext* Context, bool DrawLit, bool DrawF
ColorIndex = RenderMesh.ColorIndex;

/*** LPub3D Mod - true fade ***/
if (!LPubFade && DrawFadePrepass && lcIsColorTranslucent(ColorIndex))
if (!LPubFadeArg && DrawFadePrepass && lcIsColorTranslucent(ColorIndex))
continue;
/*** LPub3D Mod end ***/

Expand Down Expand Up @@ -476,7 +467,7 @@ void lcScene::DrawTranslucentMeshes(lcContext* Context, bool DrawLit, bool DrawF
Context->SetPolygonOffset(lcPolygonOffset::None);

/*** LPub3D Mod - true fade ***/
if (LPubFade)
if (LPubFadeArg)
{
Context->SetDepthWrite(true);
Context->EnableColorBlend(false);
Expand Down Expand Up @@ -507,10 +498,10 @@ void lcScene::Draw(lcContext* Context) const
const bool DrawConditional = Preferences.mDrawConditionalLines && Preferences.mLineWidth > 0.0f;
/*** LPub3D Mod - true fade ***/
// 03/22/2021 8039f5b Draw conditional lines on a separate pass.
const bool LPubTrueFade = gApplication->LPubFadeSteps() && // to turn off during HTML Steps export
Preferences.mLPubTrueFade &&
mHasLPubFadedParts &&
!mTranslucentMeshes.IsEmpty();
const bool LPubTrueFade = gApplication->LPubFadeSteps() && // turn off during HTML Steps export
gApplication->UseLPubTrueFade() &&
mHasLPubFadedParts &&
!mTranslucentMeshes.IsEmpty();
/*** LPub3D Mod end ***/

// lcShadingMode ShadingMode = Preferences.mShadingMode;
Expand Down
18 changes: 14 additions & 4 deletions lclib/common/lc_scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
#include "lc_mesh.h"
#include "lc_array.h"

/*** LPub3D Mod - true fade ***/
enum lcFadeArgs
{
LC_NO_FADE,
LC_DISABLE_COLOR_WRITES,
LC_ENABLE_COLOR_WRITES,
LC_DISABLE_BFC
};
/*** LPub3D Mod end ***/

enum class lcRenderMeshState : int
{
Default,
Expand Down Expand Up @@ -86,7 +96,7 @@ class lcScene

void Begin(const lcMatrix44& ViewMatrix);
void End();
/*** LPub3D Mod - true fade ***/
/*** LPub3D Mod - true fade ***/
void AddMesh(lcMesh* Mesh, const lcMatrix44& WorldMatrix, int ColorIndex, lcRenderMeshState State, bool LPubFade = false);
/*** LPub3D Mod end ***/

Expand All @@ -101,7 +111,7 @@ class lcScene
protected:
void DrawOpaqueMeshes(lcContext* Context, bool DrawLit, int PrimitiveTypes, bool DrawFaded, bool DrawNonFaded) const;
/*** LPub3D Mod - true fade ***/
void DrawTranslucentMeshes(lcContext* Context, bool DrawLit, bool DrawFadePrepass, bool DrawFaded, bool DrawNonFaded, int LPubFade = 0/*NoFade*/) const;
void DrawTranslucentMeshes(lcContext* Context, bool DrawLit, bool DrawFadePrepass, bool DrawFaded, bool DrawNonFaded, lcFadeArgs LPubFadeArg = LC_NO_FADE) const;
/*** LPub3D Mod end ***/
void DrawDebugNormals(lcContext* Context, const lcMesh* Mesh) const;

Expand All @@ -116,9 +126,9 @@ class lcScene
lcVector4 mFadeColor;
lcVector4 mHighlightColor;
bool mHasFadedParts;
/*** LPub3D Mod - true fade ***/
/*** LPub3D Mod - true fade ***/
bool mHasLPubFadedParts;
/*** LPub3D Mod end ***/
/*** LPub3D Mod end ***/
bool mTranslucentFade;

std::function<void()> mPreTranslucentCallback;
Expand Down
Loading

0 comments on commit ea21ecc

Please sign in to comment.