Skip to content

Commit

Permalink
New Modify Tool mode based on previously experimental "plane subdivid…
Browse files Browse the repository at this point in the history
…e" (#34)

* Initial WIP

* Add icon for subdivide plane

* Add code for the new mode in some more places

* And another

* Fix mode switching and UI feedback

* Remove the the guidance mesh plane

* Don't switch to loop subdivide if we're in plane mode

* Snapping
  • Loading branch information
andybak authored Sep 4, 2024
1 parent 8b04f03 commit ba81beb
Show file tree
Hide file tree
Showing 11 changed files with 211 additions and 79 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions Assets/Mogwai/Design/Icons/ic_modify_subdivide_plane.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Assets/Prefabs/ControllerGeometryLeftRift.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -3696,7 +3696,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!4 &4556842653616612
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -3750,15 +3750,15 @@ SpriteRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 0}
m_Sprite: {fileID: 21300000, guid: 65d6f3cd2f69efc4ba4dad3dc844733a, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_Size: {x: 1.92, y: 1.92}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &1149554040781548
Expand Down
8 changes: 4 additions & 4 deletions Assets/Prefabs/ControllerGeometryRightRift.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -5117,7 +5117,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!4 &4614152009913662
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -5171,15 +5171,15 @@ SpriteRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 0}
m_Sprite: {fileID: 21300000, guid: 65d6f3cd2f69efc4ba4dad3dc844733a, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_Size: {x: 1.92, y: 1.92}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &1252400099692316
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/model/controller/ChangeModeMenuItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ private void ToolHeadAnimationEnd()
case ControllerMode.reshape:
case ControllerMode.subdivideFace:
case ControllerMode.subdivideMesh:
case ControllerMode.subdividePlane:
GetComponent<ModifyToolheadAnimation>().Activate();
break;
case ControllerMode.move:
Expand Down
4 changes: 4 additions & 0 deletions Assets/Scripts/model/controller/ControllerMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,9 @@ public enum ControllerMode
/// Mode for deleting edges.
/// </summary>
deletePart,
/// <summary>
/// Mode for plane subdivision.
/// </summary>
subdividePlane,
}
}
1 change: 1 addition & 0 deletions Assets/Scripts/model/controller/PaletteController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ public GameObject GetToolheadForMode(ControllerMode mode)
case ControllerMode.move:
return grabToolhead;
case ControllerMode.subdivideFace:
case ControllerMode.subdividePlane:
case ControllerMode.reshape:
case ControllerMode.extrude:
return modifyToolhead;
Expand Down
42 changes: 29 additions & 13 deletions Assets/Scripts/model/controller/PeltzerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ public void CacheTooltips()
tooltips.Add(ControllerMode.reshape, controllerGeometry.modifyTooltips);
tooltips.Add(ControllerMode.subdivideMesh, controllerGeometry.modifyTooltips);
tooltips.Add(ControllerMode.subdivideFace, controllerGeometry.modifyTooltips);
tooltips.Add(ControllerMode.subdividePlane, controllerGeometry.modifyTooltips);
tooltips.Add(ControllerMode.paintFace, controllerGeometry.paintTooltips);
tooltips.Add(ControllerMode.paintMesh, controllerGeometry.paintTooltips);
tooltips.Add(ControllerMode.move, controllerGeometry.grabTooltips);
Expand Down Expand Up @@ -741,7 +742,7 @@ private void HandleMenuItemPoint()
return;
}

// At this point, we know something on the menu has been hit, so we update variables accordingly and
// At this point, we know something on the menu has been hit, so we update variables accordingly and
// hide the shapes menu.
menuIsInDefaultState = false;
isPointingAtMenu = true;
Expand Down Expand Up @@ -1192,6 +1193,10 @@ private void ControllerEventHandler(object sender, ControllerEventArgs args)
{
ChangeMode(ControllerMode.subdivideFace);
}
else if (location == TouchpadLocation.BOTTOM && mode != ControllerMode.subdividePlane)
{
ChangeMode(ControllerMode.subdividePlane);
}
else if (location == TouchpadLocation.RIGHT && mode != ControllerMode.extrude)
{
ChangeMode(ControllerMode.extrude);
Expand Down Expand Up @@ -1243,7 +1248,8 @@ private bool IsModifyMode(ControllerMode mode)
return mode == ControllerMode.reshape
|| mode == ControllerMode.extrude
|| mode == ControllerMode.subdivideFace
|| mode == ControllerMode.subdivideMesh;
|| mode == ControllerMode.subdivideMesh
|| mode == ControllerMode.subdividePlane;
}

private bool IsDeleteMode(ControllerMode mode)
Expand Down Expand Up @@ -1335,6 +1341,7 @@ public void ChangeMode(ControllerMode newMode, GameObject toolHead = null)
case ControllerMode.reshape:
case ControllerMode.subdivideFace:
case ControllerMode.subdivideMesh:
case ControllerMode.subdividePlane:
attachedToolHead.GetComponent<ModifyToolheadAnimation>().Deactivate();
switch (newMode)
{
Expand All @@ -1343,6 +1350,7 @@ public void ChangeMode(ControllerMode newMode, GameObject toolHead = null)
break;
case ControllerMode.subdivideFace:
case ControllerMode.subdivideMesh:
case ControllerMode.subdividePlane:
PeltzerMain.Instance.GetSelector().UpdateInactive(Selector.EDGES_ONLY);
break;
default:
Expand Down Expand Up @@ -1609,6 +1617,18 @@ public void ChangeTouchpadOverlay(TouchpadOverlay newOverlay)
controllerGeometry.modifyOverlay.GetComponent<Overlay>().upIcon.color = halfWhite;
// Extrude.
controllerGeometry.modifyOverlay.GetComponent<Overlay>().rightIcon.color = halfWhite;
// Plane.
controllerGeometry.modifyOverlay.GetComponent<Overlay>().downIcon.color = halfWhite;
break;
case ControllerMode.subdividePlane:
// Subdivide.
controllerGeometry.modifyOverlay.GetComponent<Overlay>().leftIcon.color = halfWhite;
// Reshape.
controllerGeometry.modifyOverlay.GetComponent<Overlay>().upIcon.color = halfWhite;
// Extrude.
controllerGeometry.modifyOverlay.GetComponent<Overlay>().rightIcon.color = halfWhite;
// Plane.
controllerGeometry.modifyOverlay.GetComponent<Overlay>().downIcon.color = fullWhite;
break;
case ControllerMode.reshape:
// Subdivide.
Expand All @@ -1617,6 +1637,8 @@ public void ChangeTouchpadOverlay(TouchpadOverlay newOverlay)
controllerGeometry.modifyOverlay.GetComponent<Overlay>().upIcon.color = fullWhite;
// Extrude.
controllerGeometry.modifyOverlay.GetComponent<Overlay>().rightIcon.color = halfWhite;
// Plane.
controllerGeometry.modifyOverlay.GetComponent<Overlay>().downIcon.color = halfWhite;
break;
case ControllerMode.extrude:
// Subdivide.
Expand All @@ -1625,6 +1647,8 @@ public void ChangeTouchpadOverlay(TouchpadOverlay newOverlay)
controllerGeometry.modifyOverlay.GetComponent<Overlay>().upIcon.color = halfWhite;
// Extrude.
controllerGeometry.modifyOverlay.GetComponent<Overlay>().rightIcon.color = fullWhite;
// Plane.
controllerGeometry.modifyOverlay.GetComponent<Overlay>().downIcon.color = halfWhite;
break;
case ControllerMode.delete:
controllerGeometry.deleteOverlay.GetComponent<Overlay>().leftIcon.gameObject
Expand Down Expand Up @@ -1689,6 +1713,7 @@ public void ChangeTouchpadOverlay(TouchpadOverlay newOverlay)
case ControllerMode.extrude:
case ControllerMode.subdivideFace:
case ControllerMode.subdivideMesh:
case ControllerMode.subdividePlane:
currentOverlayGO = controllerGeometry.modifyOverlay;
break;
case ControllerMode.delete:
Expand Down Expand Up @@ -1727,29 +1752,20 @@ public void ResetTouchpadOverlay()
ChangeTouchpadOverlay(TouchpadOverlay.FREEFORM);
break;
case ControllerMode.reshape:
ChangeTouchpadOverlay(TouchpadOverlay.MODIFY);
break;
case ControllerMode.extrude:
ChangeTouchpadOverlay(TouchpadOverlay.MODIFY);
break;
case ControllerMode.subdivideFace:
ChangeTouchpadOverlay(TouchpadOverlay.MODIFY);
break;
case ControllerMode.subdivideMesh:
case ControllerMode.subdividePlane:
ChangeTouchpadOverlay(TouchpadOverlay.MODIFY);
break;
case ControllerMode.deletePart:
ChangeTouchpadOverlay(TouchpadOverlay.DELETE);
break;
case ControllerMode.delete:
ChangeTouchpadOverlay(TouchpadOverlay.DELETE);
break;
case ControllerMode.move:
ChangeTouchpadOverlay(TouchpadOverlay.MOVE);
break;
case ControllerMode.paintMesh:
ChangeTouchpadOverlay(TouchpadOverlay.PAINT);
break;
case ControllerMode.paintFace:
ChangeTouchpadOverlay(TouchpadOverlay.PAINT);
break;
Expand Down Expand Up @@ -1849,7 +1865,7 @@ public void ControllerHandednessChanged()
/// <summary>
/// Determines which tooltip and where to show it when called. These are the grip tooltips to
/// advise a user how to move/zoom the world.
/// We only show these tooltips until the user has successfully moved or zoomed the world.
/// We only show these tooltips until the user has successfully moved or zoomed the world.
/// We do not show these tooltips until at least one object is in the scene.
/// We do not show these tooltips during tutorials.
/// </summary>
Expand Down
4 changes: 0 additions & 4 deletions Assets/Scripts/model/main/Features.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ public class Features
// Incompatible with planeSubdivideEnabled.
public static bool loopSubdivideEnabled = false;

// If true, the subdivide tool will turn into the experimental plane subdivide form.
// Incompatible with loopSubdivideEnabled.
public static bool planeSubdivideEnabled = false;

// If true, allow noncoplanar faces to remain during mesh fixing.
public static bool allowNoncoplanarFaces = false;

Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/model/main/PeltzerMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,8 @@ public bool OperationInProgress()
return reshaper.IsReshaping();
case ControllerMode.subdivideFace:
return false;
case ControllerMode.subdividePlane:
return false;
case ControllerMode.subtract:
return volumeInserter.IsFilling();
}
Expand Down
Loading

0 comments on commit ba81beb

Please sign in to comment.