-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from aras-p/more-edit-tools
Editing: merge, move splats, bake transform when exporting
- Loading branch information
Showing
31 changed files
with
2,516 additions
and
518 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
using GaussianSplatting.Runtime; | ||
using UnityEditor; | ||
using UnityEditor.EditorTools; | ||
using UnityEngine; | ||
|
||
namespace GaussianSplatting.Editor | ||
{ | ||
[EditorTool("Gaussian Move Tool", typeof(GaussianSplatRenderer), typeof(GaussianToolContext))] | ||
class GaussianMoveTool : GaussianTool | ||
{ | ||
public override void OnToolGUI(EditorWindow window) | ||
{ | ||
var gs = GetRenderer(); | ||
if (!gs || !CanBeEdited() || !HasSelection()) | ||
return; | ||
var tr = gs.transform; | ||
|
||
EditorGUI.BeginChangeCheck(); | ||
var selCenterLocal = GetSelectionCenterLocal(); | ||
var selCenterWorld = tr.TransformPoint(selCenterLocal); | ||
var newPosWorld = Handles.DoPositionHandle(selCenterWorld, Tools.handleRotation); | ||
if (EditorGUI.EndChangeCheck()) | ||
{ | ||
var newPosLocal = tr.InverseTransformPoint(newPosWorld); | ||
var wasModified = gs.editModified; | ||
gs.EditTranslateSelection(newPosLocal - selCenterLocal); | ||
if (!wasModified) | ||
GaussianSplatRendererEditor.RepaintAll(); | ||
Event.current.Use(); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
using GaussianSplatting.Runtime; | ||
using UnityEditor; | ||
using UnityEditor.EditorTools; | ||
using UnityEngine; | ||
|
||
namespace GaussianSplatting.Editor | ||
{ | ||
/* not working correctly yet | ||
[EditorTool("Gaussian Rotate Tool", typeof(GaussianSplatRenderer), typeof(GaussianToolContext))] | ||
class GaussianRotateTool : GaussianTool | ||
{ | ||
Quaternion m_CurrentRotation = Quaternion.identity; | ||
Vector3 m_FrozenSelCenterLocal = Vector3.zero; | ||
bool m_FreezePivot = false; | ||
public override void OnActivated() | ||
{ | ||
m_FreezePivot = false; | ||
} | ||
public override void OnToolGUI(EditorWindow window) | ||
{ | ||
var gs = GetRenderer(); | ||
if (!gs || !CanBeEdited() || !HasSelection()) | ||
return; | ||
var tr = gs.transform; | ||
var evt = Event.current; | ||
var selCenterLocal = GetSelectionCenterLocal(); | ||
if (evt.type == EventType.MouseDown) | ||
{ | ||
gs.EditStorePosMouseDown(); | ||
gs.EditStoreOtherMouseDown(); | ||
m_FrozenSelCenterLocal = selCenterLocal; | ||
m_FreezePivot = true; | ||
} | ||
if (evt.type == EventType.MouseUp) | ||
{ | ||
m_CurrentRotation = Quaternion.identity; | ||
m_FreezePivot = false; | ||
} | ||
if (m_FreezePivot) | ||
selCenterLocal = m_FrozenSelCenterLocal; | ||
EditorGUI.BeginChangeCheck(); | ||
var selCenterWorld = tr.TransformPoint(selCenterLocal); | ||
var newRotation = Handles.DoRotationHandle(m_CurrentRotation, selCenterWorld); | ||
if (EditorGUI.EndChangeCheck()) | ||
{ | ||
Matrix4x4 localToWorld = gs.transform.localToWorldMatrix; | ||
Matrix4x4 worldToLocal = gs.transform.worldToLocalMatrix; | ||
var wasModified = gs.editModified; | ||
var rotToApply = newRotation; | ||
gs.EditRotateSelection(selCenterLocal, localToWorld, worldToLocal, rotToApply); | ||
m_CurrentRotation = newRotation; | ||
if (!wasModified) | ||
GaussianSplatRendererEditor.RepaintAll(); | ||
if(GUIUtility.hotControl == 0) | ||
{ | ||
m_CurrentRotation = Tools.handleRotation; | ||
} | ||
} | ||
} | ||
} | ||
*/ | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
using GaussianSplatting.Runtime; | ||
using UnityEditor; | ||
using UnityEditor.EditorTools; | ||
using UnityEngine; | ||
|
||
namespace GaussianSplatting.Editor | ||
{ | ||
/* // not working correctly yet when the GS itself has scale | ||
[EditorTool("Gaussian Scale Tool", typeof(GaussianSplatRenderer), typeof(GaussianToolContext))] | ||
class GaussianScaleTool : GaussianTool | ||
{ | ||
Vector3 m_CurrentScale = Vector3.one; | ||
Vector3 m_FrozenSelCenterLocal = Vector3.zero; | ||
bool m_FreezePivot = false; | ||
public override void OnActivated() | ||
{ | ||
m_FreezePivot = false; | ||
} | ||
public override void OnToolGUI(EditorWindow window) | ||
{ | ||
var gs = GetRenderer(); | ||
if (!gs || !CanBeEdited() || !HasSelection()) | ||
return; | ||
var tr = gs.transform; | ||
var evt = Event.current; | ||
var selCenterLocal = GetSelectionCenterLocal(); | ||
if (evt.type == EventType.MouseDown) | ||
{ | ||
gs.EditStorePosMouseDown(); | ||
m_FrozenSelCenterLocal = selCenterLocal; | ||
m_FreezePivot = true; | ||
} | ||
if (evt.type == EventType.MouseUp) | ||
{ | ||
m_CurrentScale = Vector3.one; | ||
m_FreezePivot = false; | ||
} | ||
if (m_FreezePivot) | ||
selCenterLocal = m_FrozenSelCenterLocal; | ||
EditorGUI.BeginChangeCheck(); | ||
var selCenterWorld = tr.TransformPoint(selCenterLocal); | ||
m_CurrentScale = Handles.DoScaleHandle(m_CurrentScale, selCenterWorld, Tools.handleRotation, HandleUtility.GetHandleSize(selCenterWorld)); | ||
if (EditorGUI.EndChangeCheck()) | ||
{ | ||
Matrix4x4 localToWorld = Matrix4x4.identity; | ||
Matrix4x4 worldToLocal = Matrix4x4.identity; | ||
if (Tools.pivotRotation == PivotRotation.Global) | ||
{ | ||
localToWorld = gs.transform.localToWorldMatrix; | ||
worldToLocal = gs.transform.worldToLocalMatrix; | ||
} | ||
var wasModified = gs.editModified; | ||
gs.EditScaleSelection(selCenterLocal, localToWorld, worldToLocal, m_CurrentScale); | ||
if (!wasModified) | ||
GaussianSplatRendererEditor.RepaintAll(); | ||
evt.Use(); | ||
} | ||
} | ||
} | ||
*/ | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.