修改水

This commit is contained in:
2026-01-01 22:00:33 +08:00
parent 040a222bd6
commit 9ceffccd39
1800 changed files with 103929 additions and 139495 deletions

View File

@@ -28,9 +28,27 @@ namespace Obi
// select vertex on mouse click:
switch (Event.current.GetTypeForControl(controlID))
{
case EventType.Layout:
case EventType.MouseMove:
case EventType.MouseDown:
{
if ((Event.current.modifiers & EventModifiers.Control) == 0 &&
(HandleUtility.nearestControl != controlID || Event.current.button != 0)) break;
startPos = Event.current.mousePosition;
marquee.Set(0, 0, 0, 0);
// If the user is pressing shift, accumulate selection.
if ((Event.current.modifiers & EventModifiers.Shift) == 0 && (Event.current.modifiers & EventModifiers.Alt) == 0)
{
for (int i = 0; i < selectionStatus.Length; i++)
selectionStatus[i] = false;
}
// If the user is holding down control, dont allow selection of other objects and use marquee tool.
if ((Event.current.modifiers & EventModifiers.Control) != 0)
GUIUtility.hotControl = controlID;
float minSqrDistance = System.Single.MaxValue;
float sqrMinSelectionDistance = minSelectionDistance * minSelectionDistance;
@@ -41,94 +59,50 @@ namespace Obi
Vector2 pos = HandleUtility.WorldToGUIPoint(path.points[i].position);
// get distance from mouse position to particle position:
float sqrDistance = Vector2.SqrMagnitude(Event.current.mousePosition - pos);
float sqrDistance = Vector2.SqrMagnitude(startPos - pos);
// check if this control point is closer to the cursor that any previously considered point.
if (sqrDistance < sqrMinSelectionDistance && sqrDistance < minSqrDistance)
{
{
minSqrDistance = sqrDistance;
selectedCPIndex = i;
}
}
HandleUtility.AddControl(controlID, Mathf.Sqrt(minSqrDistance));
break;
case EventType.MouseDown:
marquee.Set(0, 0, 0, 0);
startPos = Event.current.mousePosition;
if (selectedCPIndex >= 0)
{ // toggle particle selection status.
if (Event.current.button == 0)
{
selectionStatus[selectedCPIndex] = !selectionStatus[selectedCPIndex];
selectionStatusChanged = true;
if (HandleUtility.nearestControl == controlID)
{
GUIUtility.hotControl = controlID;
// Prevent spline deselection if we have selected a particle:
GUIUtility.hotControl = controlID;
Event.current.Use();
// If the user is pressing shift or ctrl, accumulate selection.
if ((Event.current.modifiers & (EventModifiers.Shift | EventModifiers.Control)) == 0 && (Event.current.modifiers & EventModifiers.Alt) == 0)
{
for (int i = 0; i < selectionStatus.Length; i++)
selectionStatus[i] = false;
selectionStatusChanged = true;
}
minSqrDistance = System.Single.MaxValue;
sqrMinSelectionDistance = minSelectionDistance * minSelectionDistance;
for (int i = 0; i < path.ControlPointCount; i++)
{
// get particle position in gui space:
Vector2 pos = HandleUtility.WorldToGUIPoint(path.points[i].position);
// get distance from mouse position to particle position:
float sqrDistance = Vector2.SqrMagnitude(startPos - pos);
// check if this control point is closer to the cursor that any previously considered point.
if (sqrDistance < sqrMinSelectionDistance && sqrDistance < minSqrDistance)
{
minSqrDistance = sqrDistance;
selectedCPIndex = i;
}
}
if (selectedCPIndex >= 0)
{ // toggle particle selection status.
selectionStatus[selectedCPIndex] = !selectionStatus[selectedCPIndex];
selectionStatusChanged = true;
// Prevent spline deselection if we have selected a particle:
Event.current.Use();
}
}
else if ((Event.current.modifiers & (EventModifiers.Shift | EventModifiers.Control)) == 0 && (Event.current.modifiers & EventModifiers.Alt) == 0)
{
for (int i = 0; i < selectionStatus.Length; i++)
selectionStatus[i] = false;
selectionStatusChanged = true;
}
}
else if (Event.current.modifiers == EventModifiers.None)
{ // deselect all particles:
for (int i = 0; i < selectionStatus.Length; i++)
selectionStatus[i] = false;
selectionStatusChanged = true;
}
}
break;
case EventType.MouseDrag:
if (Event.current.button == 0 && (Event.current.modifiers & EventModifiers.Alt) == 0)
if (GUIUtility.hotControl == controlID)
{
currentPos = Event.current.mousePosition;
if (!dragging && Vector2.Distance(startPos, currentPos) > 5)
{
dragging = true;
}
if (dragging)
else
{
GUIUtility.hotControl = controlID;
Event.current.Use();
@@ -187,6 +161,34 @@ namespace Obi
break;
case EventType.Layout:
{
float minSqrDistance = System.Single.MaxValue;
float sqrMinSelectionDistance = minSelectionDistance * minSelectionDistance;
for (int i = 0; i < path.ControlPointCount; i++)
{
// get particle position in gui space:
Vector2 pos = HandleUtility.WorldToGUIPoint(path.points[i].position);
// get distance from mouse position to particle position:
float sqrDistance = Vector2.SqrMagnitude(Event.current.mousePosition - pos);
// check if this control point is closer to the cursor that any previously considered point.
if (sqrDistance < sqrMinSelectionDistance && sqrDistance < minSqrDistance)
{ //magic number 900 = 30*30, where 30 is min distance in pixels to select a particle.
minSqrDistance = sqrDistance;
}
}
HandleUtility.AddControl(controlID, Mathf.Sqrt(minSqrDistance));
}
break;
}
return selectionStatusChanged;