"""
Draw X-ray overlay tools for retopology workflows.
Provides clean retopology overlay rendering over high-poly geometry.
"""
from typing import Dict, Any
from mcp.server.fastmcp import Context
import logging
logger = logging.getLogger("BlenderMCPServer")
# ============================================================================
# DRAW XRAY ENABLE
# ============================================================================
def draw_xray_enable(
ctx: Context,
blender_connection,
opacity: float = 0.35,
color: str = "#00FFD0",
strokes: bool = False,
snap_engine: str = "NONE"
) -> str:
"""
Enable Draw X-ray overlay for clean retopology visualization.
Creates a clean retopology overlay rendered over high-poly geometry
that remains visible across Object, Edit, Sculpt, and Weight Paint modes
without standard X-Ray artifacts.
Parameters:
- opacity: Overlay opacity 0.0-1.0 (default: 0.35)
- color: Overlay color in hex format (default: "#00FFD0")
- strokes: Enable stroke visualization (default: False)
- snap_engine: Snapping engine - 'NONE', 'DRAWXRAY' (default: 'NONE')
Returns status message with overlay configuration.
"""
try:
# Validate opacity
if not 0.0 <= opacity <= 1.0:
return f"Error: Invalid opacity '{opacity}'. Must be between 0.0 and 1.0."
# Validate snap_engine
valid_snap_engines = ['NONE', 'DRAWXRAY']
if snap_engine not in valid_snap_engines:
return f"Error: Invalid snap_engine '{snap_engine}'. Must be one of {valid_snap_engines}."
# Validate color format
if not color.startswith('#') or len(color) not in [7, 9]:
return f"Error: Invalid color format '{color}'. Must be hex format like '#00FFD0'."
result = blender_connection.send_command("draw_xray_enable", {
"opacity": opacity,
"color": color,
"strokes": strokes,
"snap_engine": snap_engine
})
if "error" in result:
return f"Error: {result['error']}"
output = "Draw X-ray Overlay Enabled!\n\n"
output += f"Opacity: {opacity}\n"
output += f"Color: {color}\n"
output += f"Strokes: {'Enabled' if strokes else 'Disabled'}\n"
output += f"Snap Engine: {snap_engine}\n"
output += "\nℹ The retopo overlay is now visible across Object, Edit, Sculpt, and Weight Paint modes.\n"
output += "No X-Ray artifacts will obscure selection or stroke feedback.\n"
return output
except Exception as e:
logger.error(f"Error enabling draw x-ray: {str(e)}")
return f"Error enabling draw x-ray: {str(e)}"