From b537f4c9a1c99ce86458a222cf9a90d833796fc0 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 2 Jan 2015 16:21:07 +0000 Subject: [PATCH] Fixed crash dragging models from the parts tree. --- common/pieceinf.cpp | 5 ----- common/pieceinf.h | 2 -- common/view.cpp | 27 ++++++++++++--------------- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/common/pieceinf.cpp b/common/pieceinf.cpp index 9761af8e..e79a0153 100644 --- a/common/pieceinf.cpp +++ b/common/pieceinf.cpp @@ -220,11 +220,6 @@ void PieceInfo::ZoomExtents(const lcMatrix44& ProjectionMatrix, lcMatrix44& View } } -void PieceInfo::RenderPiece(int nColor) -{ - mMesh->Render(nColor, false, false); -} - void PieceInfo::AddRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMatrix, int ColorIndex, bool Focused, bool Selected) { if (mFlags & LC_PIECE_MODEL) diff --git a/common/pieceinf.h b/common/pieceinf.h index c95fa994..4bf1c431 100644 --- a/common/pieceinf.h +++ b/common/pieceinf.h @@ -90,9 +90,7 @@ public: (m_fDimensions[2] + m_fDimensions[5]) * 0.5f); } - // Operations void ZoomExtents(const lcMatrix44& ProjectionMatrix, lcMatrix44& ViewMatrix, float* EyePos = NULL) const; - void RenderPiece(int nColor); void AddRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMatrix, int ColorIndex, bool Focused, bool Selected); void AddRenderMeshes(const lcMatrix44& ViewMatrix, const lcMatrix44& WorldMatrix, int ColorIndex, bool Focused, bool Selected, lcArray& OpaqueMeshes, lcArray& TranslucentMeshes); diff --git a/common/view.cpp b/common/view.cpp index 18462352..80514bd4 100644 --- a/common/view.cpp +++ b/common/view.cpp @@ -355,6 +355,18 @@ void View::OnDraw() lcScene Scene; mModel->GetScene(Scene, mCamera, DrawInterface); + if (DrawInterface && mTrackTool == LC_TRACKTOOL_INSERT) + { + lcVector3 Position; + lcVector4 Rotation; + GetPieceInsertPosition(Position, Rotation); + + lcMatrix44 WorldMatrix = lcMatrix44FromAxisAngle(lcVector3(Rotation[0], Rotation[1], Rotation[2]), Rotation[3] * LC_DTOR); + WorldMatrix.SetTranslation(Position); + + gMainWindow->mPreviewWidget->GetCurrentPiece()->AddRenderMeshes(Scene, WorldMatrix, gMainWindow->mColorIndex, true, true); + } + mContext->SetDefaultState(); mContext->SetViewport(0, 0, mWidth, mHeight); @@ -416,21 +428,6 @@ void View::OnDraw() if (DrawInterface) { - if (mTrackTool == LC_TRACKTOOL_INSERT) - { - lcVector3 Position; - lcVector4 Rotation; - GetPieceInsertPosition(Position, Rotation); - - lcMatrix44 WorldMatrix = lcMatrix44FromAxisAngle(lcVector3(Rotation[0], Rotation[1], Rotation[2]), Rotation[3] * LC_DTOR); - WorldMatrix.SetTranslation(Position); - - mContext->SetWorldViewMatrix(lcMul(WorldMatrix, ViewMatrix)); - - mContext->SetLineWidth(2.0f * Preferences.mLineWidth); - gMainWindow->mPreviewWidget->GetCurrentPiece()->RenderPiece(gMainWindow->mColorIndex); - } - mContext->DrawInterfaceObjects(ViewMatrix, Scene.InterfaceObjects); mContext->SetLineWidth(Preferences.mLineWidth); // context remove