diff -Nru leocad-17.02/appveyor.yml leocad-17.07/appveyor.yml --- leocad-17.02/appveyor.yml 1970-01-01 00:00:00.000000000 +0000 +++ leocad-17.07/appveyor.yml 2017-07-03 03:12:17.000000000 +0000 @@ -0,0 +1,16 @@ + version: 17.02.{build} + + environment: + matrix: + - name: win32 + platform: x86 + qt: 5.7\msvc2015 + + init: + - set PATH=C:\Qt\%qt%\bin;%PATH% + - call "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" + + install: + - qmake -v + - qmake -tp vc + - msbuild /t:Rebuild /p:Configuration=Release diff -Nru leocad-17.02/common/camera.cpp leocad-17.07/common/camera.cpp --- leocad-17.02/common/camera.cpp 2017-02-12 01:51:57.000000000 +0000 +++ leocad-17.07/common/camera.cpp 2017-07-03 03:12:17.000000000 +0000 @@ -67,11 +67,11 @@ { m_fovy = 30.0f; m_zNear = 25.0f; - m_zFar = 12500.0f; + m_zFar = 50000.0f; mState = 0; - m_pTR = NULL; + m_pTR = nullptr; memset(m_strName, 0, sizeof(m_strName)); } @@ -155,11 +155,20 @@ else if (Token == QLatin1String("ZFAR")) Stream >> m_zFar; else if (Token == QLatin1String("POSITION")) + { Stream >> mPosition[0] >> mPosition[1] >> mPosition[2]; + ChangeKey(mPositionKeys, mPosition, 1, true); + } else if (Token == QLatin1String("TARGET_POSITION")) + { Stream >> mTargetPosition[0] >> mTargetPosition[1] >> mTargetPosition[2]; + ChangeKey(mTargetPositionKeys, mTargetPosition, 1, true); + } else if (Token == QLatin1String("UP_VECTOR")) + { Stream >> mUpVector[0] >> mUpVector[1] >> mUpVector[2]; + ChangeKey(mUpVectorKeys, mUpVector, 1, true); + } else if (Token == QLatin1String("POSITION_KEY")) LoadKeysLDraw(Stream, mPositionKeys); else if (Token == QLatin1String("TARGET_POSITION_KEY")) @@ -464,11 +473,12 @@ mPosition = camera->mPosition; mTargetPosition = camera->mTargetPosition; mUpVector = camera->mUpVector; + mState |= (camera->mState&LC_CAMERA_ORTHO); } void lcCamera::DrawInterface(lcContext* Context) const { - Context->SetProgram(LC_PROGRAM_SIMPLE); + Context->SetMaterial(LC_MATERIAL_UNLIT_COLOR); lcMatrix44 ViewWorldMatrix = lcMatrix44AffineInverse(mWorldView); ViewWorldMatrix.SetTranslation(lcVector3(0, 0, 0)); @@ -535,7 +545,7 @@ }; Context->SetVertexBufferPointer(Verts); - Context->SetVertexFormat(0, 3, 0, 0); + Context->SetVertexFormatPosition(3); Context->SetIndexBufferPointer(Indices); float LineWidth = lcGetPreferences().mLineWidth; @@ -621,7 +631,7 @@ lcVector3 End = lcMul31(ObjectRayTest.End, mWorldView); float Distance; - if (lcBoundingBoxRayIntersectDistance(Min, Max, Start, End, &Distance, NULL) && (Distance < ObjectRayTest.Distance)) + if (lcBoundingBoxRayIntersectDistance(Min, Max, Start, End, &Distance, nullptr) && (Distance < ObjectRayTest.Distance)) { ObjectRayTest.ObjectSection.Object = const_cast(this); ObjectRayTest.ObjectSection.Section = LC_CAMERA_SECTION_POSITION; @@ -637,7 +647,7 @@ Start = lcMul31(ObjectRayTest.Start, WorldView); End = lcMul31(ObjectRayTest.End, WorldView); - if (lcBoundingBoxRayIntersectDistance(Min, Max, Start, End, &Distance, NULL) && (Distance < ObjectRayTest.Distance)) + if (lcBoundingBoxRayIntersectDistance(Min, Max, Start, End, &Distance, nullptr) && (Distance < ObjectRayTest.Distance)) { ObjectRayTest.ObjectSection.Object = const_cast(this); ObjectRayTest.ObjectSection.Section = LC_CAMERA_SECTION_TARGET; @@ -653,7 +663,7 @@ Start = lcMul31(ObjectRayTest.Start, WorldView); End = lcMul31(ObjectRayTest.End, WorldView); - if (lcBoundingBoxRayIntersectDistance(Min, Max, Start, End, &Distance, NULL) && (Distance < ObjectRayTest.Distance)) + if (lcBoundingBoxRayIntersectDistance(Min, Max, Start, End, &Distance, nullptr) && (Distance < ObjectRayTest.Distance)) { ObjectRayTest.ObjectSection.Object = const_cast(this); ObjectRayTest.ObjectSection.Section = LC_CAMERA_SECTION_UPVECTOR; @@ -980,7 +990,7 @@ void lcCamera::GetTileInfo(int* row, int* col, int* width, int* height) { - if (m_pTR != NULL) + if (m_pTR != nullptr) { *row = m_pTR->mRows - m_pTR->mCurrentRow - 1; *col = m_pTR->mCurrentColumn; @@ -991,13 +1001,13 @@ bool lcCamera::EndTile() { - if (m_pTR != NULL) + if (m_pTR != nullptr) { if (m_pTR->EndTile()) return true; delete m_pTR; - m_pTR = NULL; + m_pTR = nullptr; } return false; diff -Nru leocad-17.02/common/camera.h leocad-17.07/common/camera.h --- leocad-17.02/common/camera.h 2017-02-12 01:51:57.000000000 +0000 +++ leocad-17.07/common/camera.h 2017-07-03 03:12:17.000000000 +0000 @@ -45,7 +45,7 @@ lcCamera(float ex, float ey, float ez, float tx, float ty, float tz); virtual ~lcCamera(); - const char* GetName() const + const char* GetName() const override { return m_strName; } @@ -70,12 +70,12 @@ mState &= ~LC_CAMERA_ORTHO; } - virtual bool IsSelected() const + virtual bool IsSelected() const override { return (mState & LC_CAMERA_SELECTION_MASK) != 0; } - virtual bool IsSelected(lcuint32 Section) const + virtual bool IsSelected(lcuint32 Section) const override { switch (Section) { @@ -94,7 +94,7 @@ return false; } - virtual void SetSelected(bool Selected) + virtual void SetSelected(bool Selected) override { if (Selected) mState |= LC_CAMERA_SELECTION_MASK; @@ -102,7 +102,7 @@ mState &= ~(LC_CAMERA_SELECTION_MASK | LC_CAMERA_FOCUS_MASK); } - virtual void SetSelected(lcuint32 Section, bool Selected) + virtual void SetSelected(lcuint32 Section, bool Selected) override { switch (Section) { @@ -129,12 +129,12 @@ } } - virtual bool IsFocused() const + virtual bool IsFocused() const override { return (mState & LC_CAMERA_FOCUS_MASK) != 0; } - virtual bool IsFocused(lcuint32 Section) const + virtual bool IsFocused(lcuint32 Section) const override { switch (Section) { @@ -153,7 +153,7 @@ return false; } - virtual void SetFocused(lcuint32 Section, bool Focus) + virtual void SetFocused(lcuint32 Section, bool Focus) override { switch (Section) { @@ -180,7 +180,7 @@ } } - virtual lcuint32 GetFocusSection() const + virtual lcuint32 GetFocusSection() const override { if (mState & LC_CAMERA_POSITION_FOCUSED) return LC_CAMERA_SECTION_POSITION; @@ -194,12 +194,12 @@ return ~0; } - virtual lcuint32 GetAllowedTransforms() const + virtual lcuint32 GetAllowedTransforms() const override { return LC_OBJECT_TRANSFORM_MOVE_X | LC_OBJECT_TRANSFORM_MOVE_Y | LC_OBJECT_TRANSFORM_MOVE_Z; } - virtual lcVector3 GetSectionPosition(lcuint32 Section) const + virtual lcVector3 GetSectionPosition(lcuint32 Section) const override { switch (Section) { @@ -262,9 +262,9 @@ } public: - virtual void RayTest(lcObjectRayTest& ObjectRayTest) const; - virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const; - virtual void DrawInterface(lcContext* Context) const; + virtual void RayTest(lcObjectRayTest& ObjectRayTest) const override; + virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const override; + virtual void DrawInterface(lcContext* Context) const override; void InsertTime(lcStep Start, lcStep Time); void RemoveTime(lcStep Start, lcStep Time); diff -Nru leocad-17.02/common/debug.cpp leocad-17.07/common/debug.cpp --- leocad-17.02/common/debug.cpp 2017-02-12 01:51:57.000000000 +0000 +++ leocad-17.07/common/debug.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ -#include "lc_global.h" -#include "debug.h" - -#ifdef LC_DEBUG - -#define LC_MAX_DEBUG_LINES 100 - -struct LC_DEBUG_LINE -{ - lcVector3 pt1; - lcVector3 pt2; - lcVector3 color; -}; - -static LC_DEBUG_LINE DebugLines[LC_MAX_DEBUG_LINES]; -static int NumDebugLines; - -void ClearDebugLines() -{ - NumDebugLines = 0; -} - -void AddDebugLine(const lcVector3& pt1, const lcVector3& pt2, const lcVector3& Color) -{ - if (NumDebugLines == LC_MAX_DEBUG_LINES-1) - return; - - DebugLines[NumDebugLines].pt1 = pt1; - DebugLines[NumDebugLines].pt2 = pt2; - DebugLines[NumDebugLines].color = Color; - NumDebugLines++; -} - -#define LC_MAX_DEBUG_QUADS 100 - -struct LC_DEBUG_QUAD -{ - lcVector3 pt1; - lcVector3 pt2; - lcVector3 pt3; - lcVector3 pt4; - lcVector4 color; -}; - -static LC_DEBUG_QUAD DebugQuads[LC_MAX_DEBUG_QUADS]; -static int NumDebugQuads; - -void ClearDebugQuads() -{ - NumDebugQuads = 0; -} - -void AddDebugQuad(const lcVector3& pt1, const lcVector3& pt2, const lcVector3& pt3, const lcVector3& pt4, const lcVector4& Color) -{ - if (NumDebugQuads == LC_MAX_DEBUG_QUADS-1) - return; - - DebugQuads[NumDebugQuads].pt1 = pt1; - DebugQuads[NumDebugQuads].pt2 = pt2; - DebugQuads[NumDebugQuads].pt3 = pt3; - DebugQuads[NumDebugQuads].pt4 = pt4; - DebugQuads[NumDebugQuads].color = Color; - NumDebugQuads++; -} - -void RenderDebugPrimitives() -{ - for (int i = 0; i < NumDebugLines; i++) - { - glVertexPointer(3, GL_FLOAT, 0, &DebugLines[i].pt1); - glColor3fv((float*)&DebugLines[i].color); - glDrawArrays(GL_LINES, 0, 2); - } - - glDepthMask(GL_FALSE); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - for (int i = 0; i < NumDebugQuads; i++) - { - glVertexPointer(3, GL_FLOAT, 0, &DebugQuads[i].pt1); - glColor4fv((float*)&DebugQuads[i].color); - glDrawArrays(GL_QUADS, 0, 4); - } - - glDisable(GL_BLEND); - glDepthMask(GL_TRUE); -} - -#endif // LC_DEBUG diff -Nru leocad-17.02/common/debug.h leocad-17.07/common/debug.h --- leocad-17.02/common/debug.h 2017-02-12 01:51:57.000000000 +0000 +++ leocad-17.07/common/debug.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -#ifndef _DEBUG_H_ -#define _DEBUG_H_ - -#ifdef LC_DEBUG - -#include "lc_math.h" - -void RenderDebugPrimitives(); - -void AddDebugLine(const lcVector3& pt1, const lcVector3& pt2, const lcVector3& Color); -void ClearDebugLines(); - -void AddDebugQuad(const lcVector3& pt1, const lcVector3& pt2, const lcVector3& pt3, const lcVector3& pt4, const lcVector4& Color); -void ClearDebugQuads(); - -#endif // LC_DEBUG - -#endif // _DEBUG_H_ diff -Nru leocad-17.02/common/group.cpp leocad-17.07/common/group.cpp --- leocad-17.02/common/group.cpp 2017-02-12 01:51:57.000000000 +0000 +++ leocad-17.07/common/group.cpp 2017-07-03 03:12:17.000000000 +0000 @@ -5,7 +5,7 @@ lcGroup::lcGroup() { - mGroup = NULL; + mGroup = nullptr; } lcGroup::~lcGroup() diff -Nru leocad-17.02/common/image.cpp leocad-17.07/common/image.cpp --- leocad-17.02/common/image.cpp 2017-02-12 01:51:57.000000000 +0000 +++ leocad-17.07/common/image.cpp 2017-07-03 03:12:17.000000000 +0000 @@ -27,7 +27,7 @@ Image::Image() { - mData = NULL; + mData = nullptr; mWidth = 0; mHeight = 0; mFormat = LC_PIXEL_FORMAT_INVALID; @@ -79,7 +79,7 @@ void Image::FreeData() { free(mData); - mData = NULL; + mData = nullptr; mWidth = 0; mHeight = 0; mFormat = LC_PIXEL_FORMAT_INVALID; @@ -117,24 +117,31 @@ { int i, j, k, components, stx, sty; float accumx, accumy; - unsigned char* bits; + unsigned char* bits = nullptr; components = GetBPP(); + int BufferSize = width * height * components; - bits = (unsigned char*)malloc(width * height * components); - - for (j = 0; j < mHeight; j++) + if (BufferSize) { - accumy = (float)height*j/(float)mHeight; - sty = (int)floor(accumy); + bits = (unsigned char*)malloc(BufferSize); - for (i = 0; i < mWidth; i++) + if (bits) { - accumx = (float)width*i/(float)mWidth; - stx = (int)floor(accumx); - - for (k = 0; k < components; k++) - bits[(stx+sty*width)*components+k] = mData[(i+j*mWidth)*components+k]; + for (j = 0; j < mHeight; j++) + { + accumy = (float)height*j / (float)mHeight; + sty = (int)floor(accumy); + + for (i = 0; i < mWidth; i++) + { + accumx = (float)width*i / (float)mWidth; + stx = (int)floor(accumx); + + for (k = 0; k < components; k++) + bits[(stx + sty*width)*components + k] = mData[(i + j * mWidth) * components + k]; + } + } } } @@ -159,7 +166,7 @@ return true; } -bool Image::FileLoad(const char* FileName) +bool Image::FileLoad(const QString& FileName) { QImage Image; diff -Nru leocad-17.02/common/image.h leocad-17.07/common/image.h --- leocad-17.02/common/image.h 2017-02-12 01:51:57.000000000 +0000 +++ leocad-17.07/common/image.h 2017-07-03 03:12:17.000000000 +0000 @@ -5,13 +5,6 @@ #define LC_IMAGE_TRANSPARENT 0x2000 //#define LC_IMAGE_MASK 0x7000 -enum LC_IMAGE_FORMAT -{ - LC_IMAGE_BMP, - LC_IMAGE_JPG, - LC_IMAGE_PNG -}; - enum lcPixelFormat { LC_PIXEL_FORMAT_INVALID, @@ -31,7 +24,7 @@ bool HasAlpha() const; bool FileLoad(lcMemFile& File); - bool FileLoad(const char* FileName); + bool FileLoad(const QString& FileName); void Resize(int Width, int Height); void ResizePow2(); diff -Nru leocad-17.02/common/lc_application.cpp leocad-17.07/common/lc_application.cpp --- leocad-17.02/common/lc_application.cpp 2017-02-12 01:51:57.000000000 +0000 +++ leocad-17.07/common/lc_application.cpp 2017-07-03 03:12:17.000000000 +0000 @@ -6,6 +6,7 @@ #include "project.h" #include "lc_mainwindow.h" #include "lc_shortcuts.h" +#include "view.h" lcApplication* g_App; @@ -41,9 +42,9 @@ lcApplication::lcApplication() { - mProject = NULL; - mLibrary = NULL; - mClipboard = NULL; + mProject = nullptr; + mLibrary = nullptr; + mClipboard = nullptr; mPreferences.LoadDefaults(); } @@ -83,7 +84,7 @@ bool lcApplication::LoadPiecesLibrary(const char* LibPath, const char* LibraryInstallPath, const char* LDrawPath) { - if (mLibrary == NULL) + if (mLibrary == nullptr) mLibrary = new lcPiecesLibrary(); if (LibPath && LibPath[0]) @@ -99,7 +100,7 @@ QString CustomPath = lcGetProfileString(LC_PROFILE_PARTS_LIBRARY); if (!CustomPath.isEmpty()) - return mLibrary->Load(CustomPath.toLatin1().constData()); // todo: qstring + return mLibrary->Load(CustomPath); if (LibraryInstallPath && LibraryInstallPath[0]) { @@ -147,7 +148,10 @@ if ((sscanf(argv[(*CurArg)], "%d", &val) == 1) && (val > 0)) *Value = val; else + { + *Value = 0; printf("Invalid value specified for the %s argument.", argv[(*CurArg) - 1]); + } } else { @@ -171,21 +175,26 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstallPath, const char* LDrawPath, bool& ShowWindow) { - char* LibPath = NULL; + // todo: parse command line using Qt to handle multibyte strings. + char* LibPath = nullptr; // Image output options. bool SaveImage = false; bool SaveWavefront = false; bool Save3DS = false; -// bool ImageHighlight = false; + bool Orthographic = false; + bool ImageHighlight = false; int ImageWidth = lcGetProfileInt(LC_PROFILE_IMAGE_WIDTH); int ImageHeight = lcGetProfileInt(LC_PROFILE_IMAGE_HEIGHT); lcStep ImageStart = 0; lcStep ImageEnd = 0; - char* ImageName = NULL; - char* ProjectName = NULL; - char* SaveWavefrontName = NULL; - char* Save3DSName = NULL; + char* ImageName = nullptr; + char* ModelName = nullptr; + char* CameraName = nullptr; + char* Viewpoint = nullptr; + char* ProjectName = nullptr; + char* SaveWavefrontName = nullptr; + char* Save3DSName = nullptr; // Parse the command line arguments. for (int i = 1; i < argc; i++) @@ -228,8 +237,34 @@ ParseIntegerArgument(&i, argc, argv, &Step); ImageEnd = Step; } -// else if (strcmp(Param, "--highlight") == 0) -// ImageHighlight = true; + else if ((strcmp(Param, "-m") == 0) || (strcmp(Param, "--model") == 0)) + { + if ((argc > (i+1)) && (argv[i+1][0] != '-')) + { + i++; + ModelName = argv[i]; + } + } + else if ((strcmp(Param, "-c") == 0) || (strcmp(Param, "--camera") == 0)) + { + if ((argc > (i+1)) && (argv[i+1][0] != '-')) + { + i++; + CameraName = argv[i]; + } + } + else if (strcmp(Param, "--viewpoint") == 0) + { + if ((argc > (i+1)) && (argv[i+1][0] != '-')) + { + i++; + Viewpoint = argv[i]; + } + } + else if (strcmp(Param, "--orthographic") == 0) + Orthographic = true; + else if (strcmp(Param, "--highlight") == 0) + ImageHighlight = true; else if ((strcmp(Param, "-wf") == 0) || (strcmp(Param, "--export-wavefront") == 0)) { SaveWavefront = true; @@ -268,9 +303,15 @@ printf(" -h, --height : Sets the picture height.\n"); printf(" -f, --from