2
This commit is contained in:
@@ -59,17 +59,17 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
};
|
||||
const selectedData = getSelectedPartition();
|
||||
|
||||
// --- RAYCASTING (Надежный поиск коробки) ---
|
||||
// Находит ближайшие стенки во всех 4 направлениях
|
||||
// --- RAYCASTING (Поиск коробки для НОВОЙ стенки) ---
|
||||
// Мы ищем ближайшие препятствия, чтобы определить границы новой стенки
|
||||
const getCursorBox = (lx: number, ly: number, parts: Partition[]) => {
|
||||
let minX = 0, maxX = 1;
|
||||
let minY = 0, maxY = 1;
|
||||
|
||||
parts.forEach(p => {
|
||||
// Используем сохраненные границы (они теперь достоверны)
|
||||
// Используем сохраненные границы (честные)
|
||||
const pMin = p.min ?? 0;
|
||||
const pMax = p.max ?? 1;
|
||||
const EPS = 0.005; // Допуск на попадание
|
||||
const EPS = 0.005; // Допуск
|
||||
|
||||
if (p.axis === 'x') {
|
||||
// Вертикальная стенка. Перекрывает ли она наш Y?
|
||||
@@ -90,7 +90,7 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
return { minX, maxX, minY, maxY };
|
||||
};
|
||||
|
||||
// Поиск соседей для размеров (Та же логика, что Raycasting)
|
||||
// Поиск соседей для размеров (Используем сохраненные данные)
|
||||
const getNeighborOffsets = (offset: number, crossPos: number, axis: Axis, parts: Partition[]) => {
|
||||
let min = 0;
|
||||
let max = 1;
|
||||
@@ -232,7 +232,7 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
if (found) {
|
||||
setHoveredPartition({ id: found.id, cellKey: key });
|
||||
} else {
|
||||
// --- FIND BOX ---
|
||||
// --- FIND BOX USING RAYCASTING ---
|
||||
const box = getCursorBox(lx, ly, parts);
|
||||
|
||||
const boxW = (box.maxX - box.minX) * realCellW;
|
||||
@@ -244,11 +244,12 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
// Override if near edges
|
||||
const relL = (lx - box.minX) / (box.maxX - box.minX);
|
||||
const relT = (ly - box.minY) / (box.maxY - box.minY);
|
||||
const THRESHOLD = 0.2;
|
||||
const THRESHOLD = 0.2; // 20% zone near edges
|
||||
|
||||
if (relL < THRESHOLD || relL > 1 - THRESHOLD) newAxis = 'x'; // Near vertical edge -> vertical wall
|
||||
else if (relT < THRESHOLD || relT > 1 - THRESHOLD) newAxis = 'y'; // Near horiz edge -> horizontal wall
|
||||
if (relL < THRESHOLD || relL > 1 - THRESHOLD) newAxis = 'x';
|
||||
else if (relT < THRESHOLD || relT > 1 - THRESHOLD) newAxis = 'y';
|
||||
|
||||
// Validate space
|
||||
const valid = (newAxis === 'x' && (box.maxX - box.minX) > 0.05) || (newAxis === 'y' && (box.maxY - box.minY) > 0.05);
|
||||
|
||||
if (valid) {
|
||||
@@ -298,7 +299,7 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
}
|
||||
};
|
||||
|
||||
// --- ДОБАВЛЕНО: Очистка при выходе мыши ---
|
||||
// --- HANDLER: Clear Phantom on Leave ---
|
||||
const handleMouseLeave = () => {
|
||||
setDragging(null);
|
||||
setPhantomMainAxis(null);
|
||||
@@ -444,8 +445,9 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
onMouseMove={handleMouseMove}
|
||||
onMouseDown={handleMouseDown}
|
||||
onMouseUp={() => setDragging(null)}
|
||||
onMouseLeave={handleMouseLeave} // ДОБАВЛЕН ОБРАБОТЧИК
|
||||
onContextMenu={(e) => e.preventDefault()}>
|
||||
onMouseLeave={handleMouseLeave} // ДОБАВЛЕНО СЮДА
|
||||
onContextMenu={(e) => e.preventDefault()}
|
||||
>
|
||||
<defs><pattern id="grid" width="50" height="50" patternUnits="userSpaceOnUse"><path d="M 50 0 L 0 0 0 50" fill="none" stroke="rgba(255,255,255,0.03)" strokeWidth="1"/></pattern></defs>
|
||||
<rect width="100%" height="100%" fill="url(#grid)" />
|
||||
{renderCellsAndPartitions()}
|
||||
|
||||
Reference in New Issue
Block a user