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