Skip to content

Commit 9d82f13

Browse files
Add Editor Setting for "Keep gizmo in view", Added documentation note on all datatypes for table key equality/hash consing
1 parent 6a450bd commit 9d82f13

5 files changed

Lines changed: 27 additions & 16 deletions

File tree

lsp/api-docs.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@
501501
"documentation": "* An RGB color"
502502
},
503503
"@phoenix/global/Color.new": {
504-
"documentation": "* Returns a Color with the provided R, G, and B values\n* Values are expected to be in the range 0 to 1"
504+
"documentation": "* Returns a Color with the provided R, G, and B values\n* Values are expected to be in the range 0 to 1\n* This datatype is not hash consed! Two separate value-identical colors are not `rawequal` and will not behave as expected when used as table keys"
505505
},
506506
"@phoenix/global/Enum": {
507507
"documentation": "* Contains enumerations"
@@ -721,10 +721,10 @@
721721
"documentation": "* A connection to an Event"
722722
},
723723
"@phoenix/global/EventSignal": {
724-
"documentation": "* An Event that can be connected to"
724+
"documentation": "* An Event that can be connected to\n* This datatype is not hash consed! Two separate value-identical signals are not `rawequal` and will not behave as expected when used as table keys (e.g. `rawequal(game.OnFrameBegin, game.OnFrameBegin) == false`)"
725725
},
726726
"@phoenix/global/GameObject": {
727-
"documentation": "* A Game Object\n* Game Objects have a \"base\" API (properties, methods, and events) that can be extended by giving them Components\n* The base API will be documented on the Component APIs page"
727+
"documentation": "* A Game Object\n* Game Objects have a \"base\" API (properties, methods, and events) that can be extended by giving them Components\n* The base API will be documented on the Component APIs page\n* This datatype is hash consed, `t[game]` and `t[workspace.Parent]` are guaranteed to access the same value as `game` and `workspace.Parent` are `rawequal`"
728728
},
729729
"@phoenix/global/GameObject.fromId": {
730730
"documentation": "* Finds an Object by it's internal ID. Do not rely on the ID"
@@ -736,7 +736,7 @@
736736
"documentation": "* A list of all valid component names which can be passed into `.new`"
737737
},
738738
"@phoenix/global/Matrix": {
739-
"documentation": "* A 4x4 transformation matrix"
739+
"documentation": "* A 4x4 transformation matrix\n* This datatype is not hash consed! Two separate value-identical matrices are not `rawequal` and will not behave as expected when used as table keys"
740740
},
741741
"@phoenix/global/Matrix.fromAngles": {
742742
"documentation": "* Alias of `.fromEulerAnglesYXZ`"

resources/scripts/ed/CoreTools.luau

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ local function findDxDyToKeepOnScreen(Point: vector, ViewportRenderPosition: vec
138138
return dx, dy
139139
end
140140

141-
local function _keepGizmoInView(target: GameObject & Transform, ViewportRenderPosition: vector, ViewportRenderSize: vector)
141+
local function keepGizmoInView(target: GameObject & Transform, ViewportRenderPosition: vector, ViewportRenderSize: vector, DeltaTime: number)
142142
assert(GizmoDragHandle)
143143

144144
local cam = workspace.SceneCamera
@@ -157,7 +157,7 @@ local function _keepGizmoInView(target: GameObject & Transform, ViewportRenderPo
157157
end
158158
end
159159

160-
cam.Transform *= Matrix.fromAngles(-dy * orbitSpeed * 1/60, -dx * orbitSpeed * 1/60, 0)
160+
cam.Transform *= Matrix.fromAngles(-dy * orbitSpeed * DeltaTime, -dx * orbitSpeed * DeltaTime, 0)
161161
cam.Transform *= Matrix.fromAngles(0, 0, -cam.Transform:ExtractAngles().z)
162162

163163
if dx ~= 0 or dy ~= 0 then
@@ -170,7 +170,7 @@ local function _keepGizmoInView(target: GameObject & Transform, ViewportRenderPo
170170
GizmoDragPlaneNormal = vector.normalize(vector.cross(axisWorld, cam.Transform.Forward))
171171
end
172172

173-
function CoreTools.Update(Project: Types.Project, ViewportRenderPosition: vector, ViewportRenderSize: vector)
173+
function CoreTools.Update(Project: Types.Project, EditorPreferences, ViewportRenderPosition: vector, ViewportRenderSize: vector, DeltaTime: number)
174174
if not Project.Workspace then
175175
return
176176
end
@@ -313,7 +313,9 @@ function CoreTools.Update(Project: Types.Project, ViewportRenderPosition: vector
313313
target.Transform = Matrix.fromTranslation(move) * GizmoDragStartTransform
314314
PrevDragMousePos = cpos
315315

316-
--keepGizmoInView(target, ViewportRenderPosition, ViewportRenderSize)
316+
if EditorPreferences.KeepGizmoInView then
317+
keepGizmoInView(target, ViewportRenderPosition, ViewportRenderSize, DeltaTime)
318+
end
317319
end
318320
end
319321

resources/scripts/ed/ed.luau

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ local EditorPreferences = {
4040
UseLightTheme = false,
4141
Gamma = 2.2,
4242
ClosingProjectSaveRequiresConfirmation = false,
43-
AutosaveInterval = 10
43+
AutosaveInterval = 10,
44+
KeepGizmoInView = false
4445
}
4546

4647
EditorPreferences = EditorPreferences :: { [keyof<typeof(EditorPreferences)>]: index<typeof(EditorPreferences), keyof<typeof(EditorPreferences)>> } & typeof(EditorPreferences)
@@ -202,7 +203,7 @@ local function editorFrame(DeltaTime)
202203

203204
WasHoldingF5 = f5
204205

205-
CoreTools.Update(Project, ViewportRenderPosition, ViewportRenderSize)
206+
CoreTools.Update(Project, EditorPreferences, ViewportRenderPosition, ViewportRenderSize, DeltaTime)
206207
Stages[CurrentStage](DeltaTime)
207208

208209
WasHoldingDownM1 = PlayerInput:IsMouseButtonPressed(Enum.MouseButton.Left)
@@ -1192,6 +1193,7 @@ local function renderMainMenuBar(dt: number)
11921193
)
11931194

11941195
EditorPreferences.AutosaveInterval = imgui.inputnumber("Autosave interval (in minutes)", EditorPreferences.AutosaveInterval)
1196+
EditorPreferences.KeepGizmoInView = imgui.checkbox("Turn the camera to keep the gizmo handles in view while moving an object", EditorPreferences.KeepGizmoInView)
11951197

11961198
imgui.urllink("https://youtu.be/YCjNT9qGjh4?t=7193")
11971199

@@ -1407,7 +1409,7 @@ local function renderViewport(DeltaTime: number)
14071409
end
14081410

14091411
PluginManager.OnUpdate(DeltaTime, CurrentStage)
1410-
CoreTools.Update(Project, ViewportRenderPosition, ViewportRenderSize)
1412+
CoreTools.Update(Project, EditorPreferences, ViewportRenderPosition, ViewportRenderSize, DeltaTime)
14111413
HistoryView.Render()
14121414
TagViewer.Render()
14131415

src/impl/script/lib/lhxmatrix.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ static void createmetatable(lua_State* L)
304304
lua_pushcfunction(L, mtx_newindex, "Matrix.__newindex");
305305
lua_setfield(L, -2, "__newindex");
306306

307-
// TODO table key hashes?
308307
lua_pushcfunction(L, mtx_eq, "Matrix.__eq");
309308
lua_setfield(L, -2, "__eq");
310309

wikigen/doc-comments.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,8 @@
654654
"new": {
655655
"Description": [
656656
"Returns a Color with the provided R, G, and B values",
657-
"Values are expected to be in the range 0 to 1"
657+
"Values are expected to be in the range 0 to 1",
658+
"This datatype is not hash consed! Two separate value-identical colors are not `rawequal` and will not behave as expected when used as table keys"
658659
],
659660
"In": "R: number, G: number, B: number",
660661
"Out": "Color",
@@ -693,7 +694,10 @@
693694
}
694695
},
695696
"EventSignal": {
696-
"Description": "An Event that can be connected to",
697+
"Description": [
698+
"An Event that can be connected to",
699+
"This datatype is not hash consed! Two separate value-identical signals are not `rawequal` and will not behave as expected when used as table keys (e.g. `rawequal(game.OnFrameBegin, game.OnFrameBegin) == false`)"
700+
],
697701
"Members": {
698702
":Connect": {
699703
"Description": "Connect a callback to the Event",
@@ -710,7 +714,8 @@
710714
"Description": [
711715
"A Game Object",
712716
"Game Objects have a \"base\" API (properties, methods, and events) that can be extended by giving them Components",
713-
"The base API will be documented on the Component APIs page"
717+
"The base API will be documented on the Component APIs page",
718+
"This datatype is hash consed, `t[game]` and `t[workspace.Parent]` are guaranteed to access the same value as `game` and `workspace.Parent` are `rawequal`"
714719
],
715720
"Library": {
716721
"fromId": {
@@ -730,7 +735,10 @@
730735
}
731736
},
732737
"Matrix": {
733-
"Description": "A 4x4 transformation matrix",
738+
"Description": [
739+
"A 4x4 transformation matrix",
740+
"This datatype is not hash consed! Two separate value-identical matrices are not `rawequal` and will not behave as expected when used as table keys"
741+
],
734742
"Library": {
735743
"fromAngles": {
736744
"Description": "Alias of `.fromEulerAnglesYXZ`",

0 commit comments

Comments
 (0)