refactor(z-values): removed redundant inline with contexpr, Updated doc, magic numbers removed from TableZone.

This commit is contained in:
DawnFire42 2026-03-04 14:31:02 -05:00
parent 652ca041b4
commit 5943ae3427
No known key found for this signature in database
GPG key ID: 24BB855EE2911B33
3 changed files with 36 additions and 11 deletions

View file

@ -39,17 +39,41 @@ constexpr qreal DRAG_ITEM = ZValueLayerManager::overlayZValue(5.0);
constexpr qreal DRAG_ITEM_CHILD = ZValueLayerManager::overlayZValue(6.0);
constexpr qreal TOP_UI = ZValueLayerManager::overlayZValue(7.0);
/// Compute Z-value for child drag items based on hotspot position.
/// When dragging multiple cards together, each child card needs a unique Z-value
/// to prevent Z-fighting (flickering/flashing). The Z-values are derived from
/// their position when grabbed to conserve original stacking. The formula encodes
/// 2D coordinates into a single value where X has higher weight, ensuring
/// deterministic visual stacking.
/**
* @brief Compute Z-value for child drag items based on hotspot position.
*
* When dragging multiple cards together, each child card needs a unique Z-value
* to prevent Z-fighting (flickering/flashing). The Z-values are derived from
* their position when grabbed to conserve original stacking. The formula encodes
* 2D coordinates into a single value where X has higher weight, ensuring
* deterministic visual stacking.
*
* @param hotSpotX The X coordinate of the grab position
* @param hotSpotY The Y coordinate of the grab position
* @return Unique Z-value for the child drag item
*/
[[nodiscard]] constexpr qreal childDragZValue(qreal hotSpotX, qreal hotSpotY)
{
return DRAG_ITEM_CHILD + hotSpotX * 1000000 + hotSpotY * 1000 + 1000;
}
/**
* @brief Compute Z-value for cards on the table zone based on position.
*
* Cards lower on the table (higher Y) render above cards higher up,
* and cards to the right (higher X) render above cards to the left.
* This creates natural visual stacking for overlapping cards.
*
* @param x The X coordinate of the card position
* @param y The Y coordinate of the card position
* @return Z-value for the card's table position
*/
[[nodiscard]] constexpr qreal tableCardZValue(qreal x, qreal y)
{
constexpr qreal CARD_HEIGHT_FOR_Z = 102.0;
return (y + CARD_HEIGHT_FOR_Z) * 100000.0 + (x + 1) * 100.0;
}
// Card layering (general architecture, not command-zone specific)
constexpr qreal CARD_BASE = 1.0;
constexpr qreal CARD_MAX = ZValueLayerManager::CARD_Z_VALUE_MAX;