From 4251873f49d0e08df6e189bad7c660d003b38ae7 Mon Sep 17 00:00:00 2001 From: immibis Date: Sat, 18 Nov 2023 14:53:58 +0100 Subject: [PATCH] Very similar thing with DrawFront flag --- colobot-base/graphics/engine/engine.cpp | 16 +++++++--------- colobot-base/graphics/engine/engine.h | 6 ++---- colobot-base/level/robotmain.cpp | 2 +- colobot-base/object/object.h | 2 ++ colobot-base/object/old_object.cpp | 15 --------------- colobot-base/object/old_object.h | 2 -- colobot-base/object/old_object_interface.cpp | 5 ----- colobot-base/object/old_object_interface.h | 2 -- colobot-base/ui/displayinfo.cpp | 2 +- 9 files changed, 13 insertions(+), 39 deletions(-) diff --git a/colobot-base/graphics/engine/engine.cpp b/colobot-base/graphics/engine/engine.cpp index 40e460e3..162cdc64 100644 --- a/colobot-base/graphics/engine/engine.cpp +++ b/colobot-base/graphics/engine/engine.cpp @@ -826,7 +826,6 @@ void CEngine::DebugObject(int objRank) l->Debug(" baseObjRank = %d\n", m_objects[objRank].baseObjRank); l->Debug(" visible = %s\n", m_objects[objRank].visible ? "true" : "false"); l->Debug(" drawWorld = %s\n", m_objects[objRank].drawWorld ? "true" : "false"); - l->Debug(" drawFront = %s\n", m_objects[objRank].drawFront ? "true" : "false"); l->Debug(" type = %d\n", m_objects[objRank].type); l->Debug(" distance = %f\n", m_objects[objRank].distance); l->Debug(" shadowRank = %d\n", m_objects[objRank].shadowRank); @@ -980,13 +979,6 @@ void CEngine::SetObjectDrawWorld(int objRank, bool draw) m_objects[objRank].drawWorld = draw; } -void CEngine::SetObjectDrawFront(int objRank, bool draw) -{ - assert(objRank >= 0 && objRank < static_cast( m_objects.size() )); - - m_objects[objRank].drawFront = draw; -} - void CEngine::GetObjectBBox(int objRank, glm::vec3& min, glm::vec3& max) { assert(objRank >= 0 && objRank < static_cast( m_objects.size() )); @@ -2803,6 +2795,12 @@ bool CEngine::IsGhostObject(int objRank) return gameObject->m_bCameraGhost; } +bool CEngine::IsDrawFrontObject(int objRank) +{ + CObject *gameObject = m_objects[objRank].gameObject; + return gameObject && gameObject->m_bDrawFront; +} + void CEngine::Draw3DScene() { if (!m_worldCaptured) @@ -3709,7 +3707,7 @@ void CEngine::DrawInterface() if (m_objects[objRank].type == ENG_OBJTYPE_TERRAIN) continue; - if (! m_objects[objRank].drawFront) + if (! IsDrawFrontObject(objRank)) continue; auto combinedMatrix = projectionViewMatrix * m_objects[objRank].transform; diff --git a/colobot-base/graphics/engine/engine.h b/colobot-base/graphics/engine/engine.h index c8949acc..39c79abc 100644 --- a/colobot-base/graphics/engine/engine.h +++ b/colobot-base/graphics/engine/engine.h @@ -127,8 +127,6 @@ struct EngineObject bool visible = false; //! If true, object is behind the 2D interface bool drawWorld = false; - //! If true, the shape is before the 2D interface - bool drawFront = false; //! Type of object EngineObjectType type = ENG_OBJTYPE_NULL; //! Transformation matrix @@ -593,11 +591,11 @@ public: //! Sets drawWorld for given object void SetObjectDrawWorld(int objRank, bool draw); - //! Sets drawFront for given object - void SetObjectDrawFront(int objRank, bool draw); //! Check if object is transparent to prevent blocking the camera view bool IsGhostObject(int objRank); + //! Check if object draws in front of the user interface + bool IsDrawFrontObject(int objRank); //! Returns the bounding box for an object void GetObjectBBox(int objRank, glm::vec3& min, glm::vec3& max); diff --git a/colobot-base/level/robotmain.cpp b/colobot-base/level/robotmain.cpp index eb785286..81d50adb 100644 --- a/colobot-base/level/robotmain.cpp +++ b/colobot-base/level/robotmain.cpp @@ -2728,7 +2728,7 @@ void CRobotMain::ScenePerso() CObject* obj = SearchHuman(); if (obj != nullptr) { - obj->SetDrawFront(true); // draws the interface + obj->m_bDrawFront = true; // draws the interface assert(obj->Implements(ObjectInterfaceType::Movable)); CMotionHuman* mh = static_cast(dynamic_cast(*obj).GetMotion()); diff --git a/colobot-base/object/object.h b/colobot-base/object/object.h index ad7ffe8a..26823dac 100644 --- a/colobot-base/object/object.h +++ b/colobot-base/object/object.h @@ -164,6 +164,8 @@ public: //! Is the object translucent to prevent blocking the camera view? bool m_bCameraGhost = false; + //! Does the object draw in front of the user interface? + bool m_bDrawFront = false; //! Sets flag controlling animation effect on level reset void SetAnimateOnReset(bool animateOnReset); diff --git a/colobot-base/object/old_object.cpp b/colobot-base/object/old_object.cpp index eafbf869..f3b2485a 100644 --- a/colobot-base/object/old_object.cpp +++ b/colobot-base/object/old_object.cpp @@ -1855,21 +1855,6 @@ glm::mat4 COldObject::GetWorldMatrix(int part) } -// Indicates whether the object should be drawn over the interface. - -void COldObject::SetDrawFront(bool bDraw) -{ - int i; - - for ( i=0 ; iSetObjectDrawFront(m_objectPart[i].object, bDraw); - } - } -} - // Creates shade under a vehicle as a negative light. bool COldObject::CreateShadowLight(float height, Gfx::Color color) diff --git a/colobot-base/object/old_object.h b/colobot-base/object/old_object.h index 57d39312..fe27103e 100644 --- a/colobot-base/object/old_object.h +++ b/colobot-base/object/old_object.h @@ -130,8 +130,6 @@ public: void Write(CLevelParserLine* line) override; void Read(CLevelParserLine* line) override; - void SetDrawFront(bool bDraw) override; - int GetShadowLight(); void SetFloorHeight(float height); diff --git a/colobot-base/object/old_object_interface.cpp b/colobot-base/object/old_object_interface.cpp index 73aa82ec..7471b1f5 100644 --- a/colobot-base/object/old_object_interface.cpp +++ b/colobot-base/object/old_object_interface.cpp @@ -46,11 +46,6 @@ int COldObjectInterface::GetOption() throw std::logic_error("GetOption: not implemented!"); } -void COldObjectInterface::SetDrawFront(bool bDraw) -{ - throw std::logic_error("SetDrawFront: not implemented!"); -} - void COldObjectInterface::FloorAdjust() { diff --git a/colobot-base/object/old_object_interface.h b/colobot-base/object/old_object_interface.h index 72c7ec27..38be4dcd 100644 --- a/colobot-base/object/old_object_interface.h +++ b/colobot-base/object/old_object_interface.h @@ -53,8 +53,6 @@ public: virtual int GetOption(); - virtual void SetDrawFront(bool bDraw); - virtual void FloorAdjust(); diff --git a/colobot-base/ui/displayinfo.cpp b/colobot-base/ui/displayinfo.cpp index 1e74974e..0d83aafc 100644 --- a/colobot-base/ui/displayinfo.cpp +++ b/colobot-base/ui/displayinfo.cpp @@ -446,7 +446,7 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc m_toto = SearchToto(); if ( m_toto != nullptr ) { - m_toto->SetDrawFront(true); + m_toto->m_bDrawFront = true; assert(m_toto->Implements(ObjectInterfaceType::Movable)); CMotionToto* toto = static_cast(dynamic_cast(*m_toto).GetMotion());