Code cleanup #765
This commit is contained in:
@@ -54,10 +54,8 @@ namespace FlaxEditor.Gizmo
|
|||||||
if (!_isActive || !IsActive)
|
if (!_isActive || !IsActive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//PE: As all axisMesh have the same pivot, add a little offset to the x axisMesh,
|
// As all axisMesh have the same pivot, add a little offset to the x axisMesh, this way SortDrawCalls is able to sort the draw order
|
||||||
//PE: This way SortDrawCalls is able to sort the draw order.
|
// https://github.com/FlaxEngine/FlaxEngine/issues/680
|
||||||
//PE: https://github.com/FlaxEngine/FlaxEngine/issues/680
|
|
||||||
//PE: @Artist To fix the rotate, add new "wider" circleMesh, so direction is visible.
|
|
||||||
|
|
||||||
Matrix m1, m2, m3 , mx1;
|
Matrix m1, m2, m3 , mx1;
|
||||||
bool isXAxis = _activeAxis == Axis.X || _activeAxis == Axis.XY || _activeAxis == Axis.ZX;
|
bool isXAxis = _activeAxis == Axis.X || _activeAxis == Axis.XY || _activeAxis == Axis.ZX;
|
||||||
|
|||||||
@@ -287,31 +287,29 @@ namespace FlaxEditor.Gizmo
|
|||||||
delta *= 0.5f;
|
delta *= 0.5f;
|
||||||
if ((isScaling ? ScaleSnapEnabled : TranslationSnapEnable) || Owner.UseSnapping)
|
if ((isScaling ? ScaleSnapEnabled : TranslationSnapEnable) || Owner.UseSnapping)
|
||||||
{
|
{
|
||||||
float snapValue = isScaling ? ScaleSnapValue : TranslationSnapValue;
|
var snapValue = new Vector3(isScaling ? ScaleSnapValue : TranslationSnapValue);
|
||||||
_translationScaleSnapDelta += delta;
|
_translationScaleSnapDelta += delta;
|
||||||
if (!isScaling && snapValue < 0.0f)
|
if (!isScaling && snapValue.X < 0.0f)
|
||||||
{
|
{
|
||||||
//PE: Snap to object bounding box
|
// Snap to object bounding box
|
||||||
GetSelectedObjectsBounds(out var b, out _);
|
GetSelectedObjectsBounds(out var b, out _);
|
||||||
float X, Y, Z;
|
if (b.Minimum.X < 0.0f)
|
||||||
if (b.Minimum.X < 0.0f) X = (float) Math.Abs(b.Minimum.X) + b.Maximum.X;
|
snapValue.X = (Real)Math.Abs(b.Minimum.X) + b.Maximum.X;
|
||||||
else X = (float) b.Minimum.X - b.Maximum.X;
|
else
|
||||||
if (b.Minimum.Y < 0.0f) Y = (float) Math.Abs(b.Minimum.Y) + b.Maximum.Y;
|
snapValue.X = (Real)b.Minimum.X - b.Maximum.X;
|
||||||
else Y = (float) b.Minimum.Y - b.Maximum.Y;
|
if (b.Minimum.Y < 0.0f)
|
||||||
if (b.Minimum.Z < 0.0f) Z = (float) Math.Abs(b.Minimum.Z) + b.Maximum.Z;
|
snapValue.Y = (Real)Math.Abs(b.Minimum.Y) + b.Maximum.Y;
|
||||||
else Z = (float) b.Minimum.Z - b.Maximum.Z;
|
else
|
||||||
delta = new Vector3(
|
snapValue.Y = (Real)b.Minimum.Y - b.Maximum.Y;
|
||||||
(int)(_translationScaleSnapDelta.X / X) * X,
|
if (b.Minimum.Z < 0.0f)
|
||||||
(int)(_translationScaleSnapDelta.Y / Y) * Y,
|
snapValue.Z = (Real)Math.Abs(b.Minimum.Z) + b.Maximum.Z;
|
||||||
(int)(_translationScaleSnapDelta.Z / Z) * Z);
|
else
|
||||||
}
|
snapValue.Z = (Real)b.Minimum.Z - b.Maximum.Z;
|
||||||
else
|
|
||||||
{
|
|
||||||
delta = new Vector3(
|
|
||||||
(int)(_translationScaleSnapDelta.X / snapValue) * snapValue,
|
|
||||||
(int)(_translationScaleSnapDelta.Y / snapValue) * snapValue,
|
|
||||||
(int)(_translationScaleSnapDelta.Z / snapValue) * snapValue);
|
|
||||||
}
|
}
|
||||||
|
delta = new Vector3(
|
||||||
|
(int)(_translationScaleSnapDelta.X / snapValue.X) * snapValue.X,
|
||||||
|
(int)(_translationScaleSnapDelta.Y / snapValue.Y) * snapValue.Y,
|
||||||
|
(int)(_translationScaleSnapDelta.Z / snapValue.Z) * snapValue.Z);
|
||||||
_translationScaleSnapDelta -= delta;
|
_translationScaleSnapDelta -= delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,10 +463,9 @@ namespace FlaxEditor.Gizmo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply transformation (but to the parents, not whole selection pool)
|
// Apply transformation (but to the parents, not whole selection pool)
|
||||||
if (anyValid || (!_isTransforming && Owner.UseDuplicate) )
|
if (anyValid || (!_isTransforming && Owner.UseDuplicate))
|
||||||
{
|
{
|
||||||
StartTransforming();
|
StartTransforming();
|
||||||
|
|
||||||
LastDelta = new Transform(translationDelta, rotationDelta, scaleDelta);
|
LastDelta = new Transform(translationDelta, rotationDelta, scaleDelta);
|
||||||
OnApplyTransformation(ref translationDelta, ref rotationDelta, ref scaleDelta);
|
OnApplyTransformation(ref translationDelta, ref rotationDelta, ref scaleDelta);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -319,6 +319,8 @@ namespace FlaxEditor.Viewport
|
|||||||
{
|
{
|
||||||
TooltipText = "Position snapping values"
|
TooltipText = "Position snapping values"
|
||||||
};
|
};
|
||||||
|
if (TransformGizmo.TranslationSnapValue < 0.0f)
|
||||||
|
_translateSnapping.Text = "Bounding Box";
|
||||||
|
|
||||||
for (int i = 0; i < EditorViewportTranslateSnapValues.Length; i++)
|
for (int i = 0; i < EditorViewportTranslateSnapValues.Length; i++)
|
||||||
{
|
{
|
||||||
@@ -326,7 +328,7 @@ namespace FlaxEditor.Viewport
|
|||||||
var button = translateSnappingCM.AddButton(v.ToString());
|
var button = translateSnappingCM.AddButton(v.ToString());
|
||||||
button.Tag = v;
|
button.Tag = v;
|
||||||
}
|
}
|
||||||
var buttonBB = translateSnappingCM.AddButton("Bounding Box");
|
var buttonBB = translateSnappingCM.AddButton("Bounding Box").LinkTooltip("Snaps the selection based on it's bounding volume");
|
||||||
buttonBB.Tag = -1.0f;
|
buttonBB.Tag = -1.0f;
|
||||||
|
|
||||||
translateSnappingCM.ButtonClicked += OnWidgetTranslateSnapClick;
|
translateSnappingCM.ButtonClicked += OnWidgetTranslateSnapClick;
|
||||||
@@ -543,28 +545,24 @@ namespace FlaxEditor.Viewport
|
|||||||
private void OnTranslateSnappingToggle(ViewportWidgetButton button)
|
private void OnTranslateSnappingToggle(ViewportWidgetButton button)
|
||||||
{
|
{
|
||||||
TransformGizmo.TranslationSnapEnable = !TransformGizmo.TranslationSnapEnable;
|
TransformGizmo.TranslationSnapEnable = !TransformGizmo.TranslationSnapEnable;
|
||||||
// cache value
|
|
||||||
_editor.ProjectCache.SetCustomData("TranslateSnapState", TransformGizmo.TranslationSnapEnable.ToString());
|
_editor.ProjectCache.SetCustomData("TranslateSnapState", TransformGizmo.TranslationSnapEnable.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRotateSnappingToggle(ViewportWidgetButton button)
|
private void OnRotateSnappingToggle(ViewportWidgetButton button)
|
||||||
{
|
{
|
||||||
TransformGizmo.RotationSnapEnabled = !TransformGizmo.RotationSnapEnabled;
|
TransformGizmo.RotationSnapEnabled = !TransformGizmo.RotationSnapEnabled;
|
||||||
// cache value
|
|
||||||
_editor.ProjectCache.SetCustomData("RotationSnapState", TransformGizmo.RotationSnapEnabled.ToString());
|
_editor.ProjectCache.SetCustomData("RotationSnapState", TransformGizmo.RotationSnapEnabled.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnScaleSnappingToggle(ViewportWidgetButton button)
|
private void OnScaleSnappingToggle(ViewportWidgetButton button)
|
||||||
{
|
{
|
||||||
TransformGizmo.ScaleSnapEnabled = !TransformGizmo.ScaleSnapEnabled;
|
TransformGizmo.ScaleSnapEnabled = !TransformGizmo.ScaleSnapEnabled;
|
||||||
// cache value
|
|
||||||
_editor.ProjectCache.SetCustomData("ScaleSnapState", TransformGizmo.ScaleSnapEnabled.ToString());
|
_editor.ProjectCache.SetCustomData("ScaleSnapState", TransformGizmo.ScaleSnapEnabled.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTransformSpaceToggle(ViewportWidgetButton button)
|
private void OnTransformSpaceToggle(ViewportWidgetButton button)
|
||||||
{
|
{
|
||||||
TransformGizmo.ToggleTransformSpace();
|
TransformGizmo.ToggleTransformSpace();
|
||||||
// cache value
|
|
||||||
_editor.ProjectCache.SetCustomData("TransformSpaceState", TransformGizmo.ActiveTransformSpace.ToString());
|
_editor.ProjectCache.SetCustomData("TransformSpaceState", TransformGizmo.ActiveTransformSpace.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -595,7 +593,6 @@ namespace FlaxEditor.Viewport
|
|||||||
var v = (float)button.Tag;
|
var v = (float)button.Tag;
|
||||||
TransformGizmo.ScaleSnapValue = v;
|
TransformGizmo.ScaleSnapValue = v;
|
||||||
_scaleSnapping.Text = v.ToString();
|
_scaleSnapping.Text = v.ToString();
|
||||||
// cache value
|
|
||||||
_editor.ProjectCache.SetCustomData("ScaleSnapValue", TransformGizmo.ScaleSnapValue.ToString("N"));
|
_editor.ProjectCache.SetCustomData("ScaleSnapValue", TransformGizmo.ScaleSnapValue.ToString("N"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,7 +631,6 @@ namespace FlaxEditor.Viewport
|
|||||||
var v = (float)button.Tag;
|
var v = (float)button.Tag;
|
||||||
TransformGizmo.RotationSnapValue = v;
|
TransformGizmo.RotationSnapValue = v;
|
||||||
_rotateSnapping.Text = v.ToString();
|
_rotateSnapping.Text = v.ToString();
|
||||||
// cache value
|
|
||||||
_editor.ProjectCache.SetCustomData("RotationSnapValue", TransformGizmo.RotationSnapValue.ToString("N"));
|
_editor.ProjectCache.SetCustomData("RotationSnapValue", TransformGizmo.RotationSnapValue.ToString("N"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -675,7 +671,6 @@ namespace FlaxEditor.Viewport
|
|||||||
_translateSnapping.Text = "Bounding Box";
|
_translateSnapping.Text = "Bounding Box";
|
||||||
else
|
else
|
||||||
_translateSnapping.Text = v.ToString();
|
_translateSnapping.Text = v.ToString();
|
||||||
// cache value
|
|
||||||
_editor.ProjectCache.SetCustomData("TranslateSnapValue", TransformGizmo.TranslationSnapValue.ToString("N"));
|
_editor.ProjectCache.SetCustomData("TranslateSnapValue", TransformGizmo.TranslationSnapValue.ToString("N"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ void AudioSource::Play()
|
|||||||
// Request faster streaming update
|
// Request faster streaming update
|
||||||
Clip->RequestStreamingUpdate();
|
Clip->RequestStreamingUpdate();
|
||||||
|
|
||||||
// PE: If we are looping and streaming also update streaming buffers.
|
// If we are looping and streaming also update streaming buffers
|
||||||
if(_loop)
|
if(_loop)
|
||||||
RequestStreamingBuffersUpdate();
|
RequestStreamingBuffersUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,7 +215,6 @@ bool String::IsANSI() const
|
|||||||
bool result = true;
|
bool result = true;
|
||||||
for (int32 i = 0; i < _length; i++)
|
for (int32 i = 0; i < _length; i++)
|
||||||
{
|
{
|
||||||
//PE: Ansi is max 7 bit so...
|
|
||||||
if (_data[i] > 127)
|
if (_data[i] > 127)
|
||||||
{
|
{
|
||||||
result = false;
|
result = false;
|
||||||
|
|||||||
@@ -872,17 +872,14 @@ ScriptingObject* Scripting::TryFindObject(MClass* mclass)
|
|||||||
{
|
{
|
||||||
if (mclass == nullptr)
|
if (mclass == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
ScopeLock lock(_objectsLocker);
|
ScopeLock lock(_objectsLocker);
|
||||||
|
|
||||||
for (auto i = _objectsDictionary.Begin(); i.IsNotEnd(); ++i)
|
for (auto i = _objectsDictionary.Begin(); i.IsNotEnd(); ++i)
|
||||||
{
|
{
|
||||||
const auto obj = i->Value;
|
const auto obj = i->Value;
|
||||||
if(obj->GetClass() == mclass)
|
if (obj->GetClass() == mclass)
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptingObject* Scripting::FindObject(const MObject* managedInstance)
|
ScriptingObject* Scripting::FindObject(const MObject* managedInstance)
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public:
|
|||||||
/// <param name="fullname">The full name of the type eg: System.Int64.</param>
|
/// <param name="fullname">The full name of the type eg: System.Int64.</param>
|
||||||
/// <returns>The MClass object or null if missing.</returns>
|
/// <returns>The MClass object or null if missing.</returns>
|
||||||
static MClass* FindClass(const StringAnsiView& fullname);
|
static MClass* FindClass(const StringAnsiView& fullname);
|
||||||
|
|
||||||
#if USE_MONO
|
#if USE_MONO
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds the class from the given Mono class object within whole assembly.
|
/// Finds the class from the given Mono class object within whole assembly.
|
||||||
@@ -144,13 +144,11 @@ public:
|
|||||||
/// <returns>The found object or null if missing.</returns>
|
/// <returns>The found object or null if missing.</returns>
|
||||||
static ScriptingObject* FindObject(Guid id, MClass* type = nullptr);
|
static ScriptingObject* FindObject(Guid id, MClass* type = nullptr);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tries to find the object by the given class.
|
/// Tries to find the object by the given class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The found object or null if missing.</returns>
|
/// <returns>The found object or null if missing.</returns>
|
||||||
static ScriptingObject* TryFindObject(MClass* type = nullptr);
|
static ScriptingObject* TryFindObject(MClass* type);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tries to find the object by the given identifier.
|
/// Tries to find the object by the given identifier.
|
||||||
|
|||||||
@@ -641,7 +641,7 @@ bool ModelTool::ImportDataAssimp(const char* path, ImportedModelData& data, Opti
|
|||||||
aiProcess_JoinIdenticalVertices |
|
aiProcess_JoinIdenticalVertices |
|
||||||
aiProcess_LimitBoneWeights |
|
aiProcess_LimitBoneWeights |
|
||||||
aiProcess_Triangulate |
|
aiProcess_Triangulate |
|
||||||
aiProcess_SortByPType | //PE: Added aiProcess_SortByPType so we can ignore meshes with non triangle faces.
|
aiProcess_SortByPType |
|
||||||
aiProcess_GenUVCoords |
|
aiProcess_GenUVCoords |
|
||||||
aiProcess_FindDegenerates |
|
aiProcess_FindDegenerates |
|
||||||
aiProcess_FindInvalidData |
|
aiProcess_FindInvalidData |
|
||||||
|
|||||||
Reference in New Issue
Block a user