diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp index 0678f3e4..7198bf70 100644 --- a/src/graphics/engine/camera.cpp +++ b/src/graphics/engine/camera.cpp @@ -54,22 +54,22 @@ namespace Gfx const float MOUSE_EDGE_MARGIN = 0.01f; //! Changes the level of transparency of an object and objects transported (battery & cargo) -static void SetTransparency(CObject* obj, float value) +static void SetGhostMode(CObject* obj, bool enabled) { - obj->SetTransparency(value); + obj->SetGhostMode(enabled); if (obj->Implements(ObjectInterfaceType::Carrier)) { CObject* cargo = dynamic_cast(*obj).GetCargo(); if (cargo != nullptr) - cargo->SetTransparency(value); + cargo->SetGhostMode(enabled); } if (obj->Implements(ObjectInterfaceType::Powered)) { CObject* power = dynamic_cast(*obj).GetPower(); if (power != nullptr) - power->SetTransparency(value); + power->SetGhostMode(enabled); } } @@ -262,7 +262,7 @@ void CCamera::SetType(CameraType type) if (IsObjectBeingTransported(obj)) continue; - SetTransparency(obj, 0.0f); // opaque object + SetGhostMode(obj, false); // opaque object } } @@ -839,7 +839,7 @@ void CCamera::IsCollisionBack() if (IsObjectBeingTransported(obj)) continue; - SetTransparency(obj, 0.0f); // opaque object + SetGhostMode(obj, false); // opaque object if (obj == m_cameraObj) continue; @@ -899,7 +899,7 @@ void CCamera::IsCollisionBack() float len = glm::distance(m_actualEye, proj); if (len > del) continue; - SetTransparency(obj, 1.0f); // transparent object + SetGhostMode(obj, true); // ghost mode } } diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index cb54cd83..ae6095db 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -830,7 +830,7 @@ void CEngine::DebugObject(int objRank) 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); - l->Debug(" transparency = %f\n", m_objects[objRank].transparency); + l->Debug(" ghost = %s\n", m_objects[objRank].ghost ? "true" : "false"); l->Debug(" baseObj:\n"); int baseObjRank = m_objects[objRank].baseObjRank; @@ -984,11 +984,11 @@ void CEngine::SetObjectDrawFront(int objRank, bool draw) m_objects[objRank].drawFront = draw; } -void CEngine::SetObjectTransparency(int objRank, float value) +void CEngine::SetObjectGhostMode(int objRank, bool enabled) { assert(objRank >= 0 && objRank < static_cast( m_objects.size() )); - m_objects[objRank].transparency = value; + m_objects[objRank].ghost = enabled; } void CEngine::GetObjectBBox(int objRank, glm::vec3& min, glm::vec3& max) @@ -3544,7 +3544,7 @@ void CEngine::Draw3DScene() { EngineBaseObjDataTier& p3 = p2.next[l3]; - if (m_objects[objRank].transparency != 0.0f) // transparent ? + if (m_objects[objRank].ghost) // transparent ? { transparent = true; continue; @@ -3629,7 +3629,7 @@ void CEngine::Draw3DScene() { EngineBaseObjDataTier& p3 = p2.next[l3]; - if (m_objects[objRank].transparency == 0.0f) + if (!m_objects[objRank].ghost) continue; float dirty = (p3.state & ENG_RSTATE_DUAL_BLACK) && m_dirty ? 1.0 : 0.0; @@ -5646,10 +5646,10 @@ const glm::mat4& CEngine::GetStaticMeshWorldMatrix(int meshHandle) return m_objects[objRank].transform; } -void CEngine::SetStaticMeshTransparency(int meshHandle, float value) +void CEngine::SetStaticMeshGhostMode(int meshHandle, bool enabled) { int objRank = meshHandle; - SetObjectTransparency(objRank, value); + SetObjectGhostMode(objRank, enabled); } void CEngine::SetDebugLights(bool debugLights) diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h index 9306e151..86db73be 100644 --- a/src/graphics/engine/engine.h +++ b/src/graphics/engine/engine.h @@ -274,8 +274,8 @@ struct EngineObject float distance = 0.0f; //! Rank of the associated shadow int shadowRank = -1; - //! Transparency of the object [0, 1] - float transparency = 0.0f; + //! Ghost mode + bool ghost = false; //! Loads default values inline void LoadDefault() @@ -706,7 +706,7 @@ public: const glm::mat4& GetStaticMeshWorldMatrix(int meshHandle); //! Sets transparency for static mesh - void SetStaticMeshTransparency(int meshHandle, float value); + void SetStaticMeshGhostMode(int meshHandle, bool enabled); /* *************** Object management *************** */ @@ -767,7 +767,7 @@ public: void SetObjectDrawFront(int objRank, bool draw); //! Sets the transparency level for given object - void SetObjectTransparency(int objRank, float value); + void SetObjectGhostMode(int objRank, bool enabled); //! Returns the bounding box for an object void GetObjectBBox(int objRank, glm::vec3& min, glm::vec3& max); diff --git a/src/object/object.h b/src/object/object.h index e7bfc127..efa5422d 100644 --- a/src/object/object.h +++ b/src/object/object.h @@ -162,8 +162,8 @@ public: // TODO: remove from here once no longer necessary void SetCameraCollisionSphere(const Math::Sphere& sphere); - //! Sets the transparency of object - virtual void SetTransparency(float value) = 0; + //! Sets object's ghost mode + virtual void SetGhostMode(bool enabled) = 0; //! Sets flag controlling animation effect on level reset void SetAnimateOnReset(bool animateOnReset); diff --git a/src/object/old_object.cpp b/src/object/old_object.cpp index f48ed362..113488bf 100644 --- a/src/object/old_object.cpp +++ b/src/object/old_object.cpp @@ -2547,7 +2547,7 @@ float COldObject::GetReactorRange() // Management of transparency of the object. -void COldObject::SetTransparency(float value) +void COldObject::SetGhostMode(bool enabled) { int i; @@ -2560,7 +2560,7 @@ void COldObject::SetTransparency(float value) if ( i != 9 ) continue; // no central pillar? } - m_engine->SetObjectTransparency(m_objectPart[i].object, value); + m_engine->SetObjectGhostMode(m_objectPart[i].object, enabled); } } } diff --git a/src/object/old_object.h b/src/object/old_object.h index 445a3e5b..3c7bce54 100644 --- a/src/object/old_object.h +++ b/src/object/old_object.h @@ -209,7 +209,7 @@ public: void SetReactorRange(float reactorRange) override; float GetReactorRange() override; - void SetTransparency(float value) override; + void SetGhostMode(bool enabled) override; Math::Sphere GetJostlingSphere() const override; bool JostleObject(float force) override; diff --git a/src/object/subclass/static_object.cpp b/src/object/subclass/static_object.cpp index da297a51..3403e593 100644 --- a/src/object/subclass/static_object.cpp +++ b/src/object/subclass/static_object.cpp @@ -105,9 +105,9 @@ void CStaticObject::TransformCameraCollisionSphere(Math::Sphere& collisionSphere Math::Transform(worldMatrix, collisionSphere.pos); } -void CStaticObject::SetTransparency(float value) +void CStaticObject::SetGhostMode(bool enabled) { - m_engine->SetStaticMeshTransparency(m_meshHandle, value); + m_engine->SetStaticMeshGhostMode(m_meshHandle, enabled); } bool CStaticObject::IsStaticObject(ObjectType type) diff --git a/src/object/subclass/static_object.h b/src/object/subclass/static_object.h index 4d7a174e..78181b2a 100644 --- a/src/object/subclass/static_object.h +++ b/src/object/subclass/static_object.h @@ -53,7 +53,7 @@ public: void Read(CLevelParserLine* line) override; void Write(CLevelParserLine* line) override; - void SetTransparency(float value) override; + void SetGhostMode(bool enabled) override; public: static bool IsStaticObject(ObjectType type);