mirror of
https://github.com/leozide/leocad
synced 2025-01-29 20:34:50 +01:00
Fixed interface draw location in active submodels.
This commit is contained in:
parent
760d14c6e4
commit
752ae54788
13 changed files with 31 additions and 21 deletions
|
@ -488,8 +488,9 @@ void lcCamera::CopyPosition(const lcCamera* camera)
|
|||
mState |= (camera->mState&LC_CAMERA_ORTHO);
|
||||
}
|
||||
|
||||
void lcCamera::DrawInterface(lcContext* Context) const
|
||||
void lcCamera::DrawInterface(lcContext* Context, const lcScene& Scene) const
|
||||
{
|
||||
Q_UNUSED(Scene);
|
||||
Context->SetMaterial(LC_MATERIAL_UNLIT_COLOR);
|
||||
|
||||
lcMatrix44 ViewWorldMatrix = lcMatrix44AffineInverse(mWorldView);
|
||||
|
|
|
@ -261,7 +261,7 @@ public:
|
|||
public:
|
||||
virtual void RayTest(lcObjectRayTest& ObjectRayTest) const override;
|
||||
virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const override;
|
||||
virtual void DrawInterface(lcContext* Context) const override;
|
||||
virtual void DrawInterface(lcContext* Context, const lcScene& Scene) const override;
|
||||
virtual void RemoveKeyFrames() override;
|
||||
|
||||
void InsertTime(lcStep Start, lcStep Time);
|
||||
|
|
|
@ -1251,10 +1251,10 @@ void lcModel::DuplicateSelectedPieces()
|
|||
SaveCheckpoint(tr("Duplicating Pieces"));
|
||||
}
|
||||
|
||||
void lcModel::GetScene(lcScene& Scene, lcCamera* ViewCamera, bool DrawInterface, bool Highlight, lcPiece* ActiveSubmodelInstance) const
|
||||
void lcModel::GetScene(lcScene& Scene, lcCamera* ViewCamera, bool DrawInterface, bool Highlight, lcPiece* ActiveSubmodelInstance, const lcMatrix44& ActiveSubmodelTransform) const
|
||||
{
|
||||
Scene.Begin(ViewCamera->mWorldView);
|
||||
Scene.SetActiveSubmodelInstance(ActiveSubmodelInstance);
|
||||
Scene.SetActiveSubmodelInstance(ActiveSubmodelInstance, ActiveSubmodelTransform);
|
||||
Scene.SetDrawInterface(DrawInterface);
|
||||
|
||||
mPieceInfo->AddRenderMesh(Scene);
|
||||
|
|
|
@ -233,7 +233,7 @@ public:
|
|||
void Paste();
|
||||
void DuplicateSelectedPieces();
|
||||
|
||||
void GetScene(lcScene& Scene, lcCamera* ViewCamera, bool DrawInterface, bool Highlight, lcPiece* ActiveSubmodelInstance) const;
|
||||
void GetScene(lcScene& Scene, lcCamera* ViewCamera, bool DrawInterface, bool Highlight, lcPiece* ActiveSubmodelInstance, const lcMatrix44& ActiveSubmodelTransform) const;
|
||||
void AddSubModelRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcRenderMeshState RenderMeshState, bool ParentActive) const;
|
||||
void DrawBackground(lcGLWidget* Widget);
|
||||
void SaveStepImages(const QString& BaseName, bool AddStepSuffix, bool Zoom, bool Highlight, int Width, int Height, lcStep Start, lcStep End);
|
||||
|
|
|
@ -378,5 +378,5 @@ void lcScene::Draw(lcContext* Context) const
|
|||
void lcScene::DrawInterfaceObjects(lcContext* Context) const
|
||||
{
|
||||
for (const lcObject* Object : mInterfaceObjects)
|
||||
Object->DrawInterface(Context);
|
||||
Object->DrawInterface(Context, *this);
|
||||
}
|
||||
|
|
|
@ -8,9 +8,10 @@ class lcScene
|
|||
public:
|
||||
lcScene();
|
||||
|
||||
void SetActiveSubmodelInstance(lcPiece* ActiveSubmodelInstance)
|
||||
void SetActiveSubmodelInstance(lcPiece* ActiveSubmodelInstance, const lcMatrix44& ActiveSubmodelTransform)
|
||||
{
|
||||
mActiveSubmodelInstance = ActiveSubmodelInstance;
|
||||
mActiveSubmodelTransform = ActiveSubmodelTransform;
|
||||
}
|
||||
|
||||
lcPiece* GetActiveSubmodelInstance() const
|
||||
|
@ -33,6 +34,11 @@ public:
|
|||
mAllowWireframe = AllowWireframe;
|
||||
}
|
||||
|
||||
lcMatrix44 ApplyActiveSubmodelTransform(const lcMatrix44& WorldMatrix) const
|
||||
{
|
||||
return !mActiveSubmodelInstance ? WorldMatrix : lcMul(WorldMatrix, mActiveSubmodelTransform);
|
||||
}
|
||||
|
||||
void Begin(const lcMatrix44& ViewMatrix);
|
||||
void End();
|
||||
void AddMesh(lcMesh* Mesh, const lcMatrix44& WorldMatrix, int ColorIndex, lcRenderMeshState State, int Flags);
|
||||
|
@ -49,6 +55,7 @@ protected:
|
|||
void DrawRenderMeshes(lcContext* Context, int PrimitiveTypes, bool EnableNormals, bool DrawTranslucent, bool DrawTextured) const;
|
||||
|
||||
lcMatrix44 mViewMatrix;
|
||||
lcMatrix44 mActiveSubmodelTransform;
|
||||
lcPiece* mActiveSubmodelInstance;
|
||||
bool mDrawInterface;
|
||||
bool mAllowWireframe;
|
||||
|
|
|
@ -282,8 +282,9 @@ void lcLight::UpdatePosition(lcStep Step)
|
|||
}
|
||||
}
|
||||
|
||||
void lcLight::DrawInterface(lcContext* Context) const
|
||||
void lcLight::DrawInterface(lcContext* Context, const lcScene& Scene) const
|
||||
{
|
||||
Q_UNUSED(Scene);
|
||||
Context->SetMaterial(LC_MATERIAL_UNLIT_COLOR);
|
||||
|
||||
if (IsPointLight())
|
||||
|
|
|
@ -177,7 +177,7 @@ public:
|
|||
public:
|
||||
virtual void RayTest(lcObjectRayTest& ObjectRayTest) const override;
|
||||
virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const override;
|
||||
virtual void DrawInterface(lcContext* Context) const override;
|
||||
virtual void DrawInterface(lcContext* Context, const lcScene& Scene) const override;
|
||||
virtual void RemoveKeyFrames() override;
|
||||
|
||||
void InsertTime(lcStep Start, lcStep Time);
|
||||
|
|
|
@ -94,7 +94,7 @@ public:
|
|||
virtual lcVector3 GetSectionPosition(quint32 Section) const = 0;
|
||||
virtual void RayTest(lcObjectRayTest& ObjectRayTest) const = 0;
|
||||
virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const = 0;
|
||||
virtual void DrawInterface(lcContext* Context) const = 0;
|
||||
virtual void DrawInterface(lcContext* Context, const lcScene& Scene) const = 0;
|
||||
virtual void RemoveKeyFrames() = 0;
|
||||
virtual const char* GetName() const = 0;
|
||||
|
||||
|
|
|
@ -509,7 +509,7 @@ void lcPiece::BoxTest(lcObjectBoxTest& ObjectBoxTest) const
|
|||
ObjectBoxTest.Objects.Add(const_cast<lcPiece*>(this));
|
||||
}
|
||||
|
||||
void lcPiece::DrawInterface(lcContext* Context) const
|
||||
void lcPiece::DrawInterface(lcContext* Context, const lcScene& Scene) const
|
||||
{
|
||||
float LineWidth = lcGetPreferences().mLineWidth;
|
||||
Context->SetLineWidth(2.0f * LineWidth);
|
||||
|
@ -554,8 +554,9 @@ void lcPiece::DrawInterface(lcContext* Context) const
|
|||
{ Min[0], Min[1], Min[2] }, { Min[0], Min[1], Min[2] + Edge[2] },
|
||||
};
|
||||
|
||||
lcMatrix44 WorldMatrix = Scene.ApplyActiveSubmodelTransform(mModelWorld);
|
||||
Context->SetMaterial(LC_MATERIAL_UNLIT_COLOR);
|
||||
Context->SetWorldMatrix(mModelWorld);
|
||||
Context->SetWorldMatrix(WorldMatrix);
|
||||
|
||||
if (IsFocused(LC_PIECE_SECTION_POSITION))
|
||||
Context->SetInterfaceColor(LC_COLOR_FOCUSED);
|
||||
|
@ -581,7 +582,7 @@ void lcPiece::DrawInterface(lcContext* Context) const
|
|||
0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7
|
||||
};
|
||||
|
||||
Context->SetWorldMatrix(lcMul(mPivotMatrix, mModelWorld));
|
||||
Context->SetWorldMatrix(lcMul(mPivotMatrix, WorldMatrix));
|
||||
|
||||
Context->SetVertexBufferPointer(Verts);
|
||||
Context->SetVertexFormatPosition(3);
|
||||
|
@ -618,7 +619,7 @@ void lcPiece::DrawInterface(lcContext* Context) const
|
|||
|
||||
for (int ControlPointIdx = 0; ControlPointIdx < mControlPoints.GetSize(); ControlPointIdx++)
|
||||
{
|
||||
Context->SetWorldMatrix(lcMul(mControlPoints[ControlPointIdx].Transform, mModelWorld));
|
||||
Context->SetWorldMatrix(lcMul(mControlPoints[ControlPointIdx].Transform, WorldMatrix));
|
||||
|
||||
Context->SetVertexBufferPointer(Verts);
|
||||
Context->SetVertexFormatPosition(3);
|
||||
|
|
|
@ -344,7 +344,7 @@ public:
|
|||
|
||||
virtual void RayTest(lcObjectRayTest& ObjectRayTest) const override;
|
||||
virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const override;
|
||||
virtual void DrawInterface(lcContext* Context) const override;
|
||||
virtual void DrawInterface(lcContext* Context, const lcScene& Scene) const override;
|
||||
virtual void RemoveKeyFrames() override;
|
||||
|
||||
void AddMainModelRenderMeshes(lcScene& Scene, bool Highlight) const;
|
||||
|
|
|
@ -66,8 +66,8 @@ void View::SetSelectedSubmodelActive()
|
|||
|
||||
if (Piece->mPieceInfo->IsModel())
|
||||
{
|
||||
mActiveSubmodelMatrix = lcMatrix44Identity();
|
||||
mModel->GetPieceWorldMatrix(Piece, mActiveSubmodelMatrix);
|
||||
mActiveSubmodelTransform = lcMatrix44Identity();
|
||||
mModel->GetPieceWorldMatrix(Piece, mActiveSubmodelTransform);
|
||||
mActiveSubmodelInstance = Piece;
|
||||
lcModel* Model = mActiveSubmodelInstance->mPieceInfo->GetModel();
|
||||
Model->SetActive(true);
|
||||
|
@ -606,7 +606,7 @@ lcObjectSection View::FindObjectUnderPointer(bool PiecesOnly, bool IgnoreSelecte
|
|||
|
||||
if (ActiveModel != mModel)
|
||||
{
|
||||
lcMatrix44 InverseMatrix = lcMatrix44AffineInverse(mActiveSubmodelMatrix);
|
||||
lcMatrix44 InverseMatrix = lcMatrix44AffineInverse(mActiveSubmodelTransform);
|
||||
|
||||
ObjectRayTest.Start = lcMul31(ObjectRayTest.Start, InverseMatrix);
|
||||
ObjectRayTest.End = lcMul31(ObjectRayTest.End, InverseMatrix);
|
||||
|
@ -712,7 +712,7 @@ void View::OnDraw()
|
|||
|
||||
bool DrawInterface = mWidget != nullptr;
|
||||
|
||||
mModel->GetScene(mScene, mCamera, DrawInterface, mHighlight, mActiveSubmodelInstance);
|
||||
mModel->GetScene(mScene, mCamera, DrawInterface, mHighlight, mActiveSubmodelInstance, mActiveSubmodelTransform);
|
||||
|
||||
if (DrawInterface && mTrackTool == LC_TRACKTOOL_INSERT)
|
||||
{
|
||||
|
@ -853,7 +853,7 @@ void View::DrawSelectMoveOverlay()
|
|||
lcMatrix44 WorldMatrix = lcMatrix44(RelativeRotation, OverlayCenter);
|
||||
|
||||
if (ActiveModel != mModel)
|
||||
WorldMatrix = lcMul(WorldMatrix, mActiveSubmodelMatrix);
|
||||
WorldMatrix = lcMul(WorldMatrix, mActiveSubmodelTransform);
|
||||
|
||||
const float OverlayScale = GetOverlayScale();
|
||||
WorldMatrix = lcMul(lcMatrix44Scale(lcVector3(OverlayScale, OverlayScale, OverlayScale)), WorldMatrix);
|
||||
|
|
|
@ -172,7 +172,7 @@ protected:
|
|||
|
||||
lcModel* mModel;
|
||||
lcPiece* mActiveSubmodelInstance;
|
||||
lcMatrix44 mActiveSubmodelMatrix;
|
||||
lcMatrix44 mActiveSubmodelTransform;
|
||||
|
||||
lcScene mScene;
|
||||
lcDragState mDragState;
|
||||
|
|
Loading…
Add table
Reference in a new issue