Merge remote-tracking branch 'origin/master' into 1.5

This commit is contained in:
Wojciech Figat
2022-12-01 12:10:41 +01:00
5 changed files with 60 additions and 27 deletions

View File

@@ -225,7 +225,8 @@ namespace FlaxEditor.CustomEditors.Editors
}
private static HashSet<PropertiesList> _visibleIfPropertiesListsCache;
private static Dictionary<string, GroupElement> _groups;
private static Stack<Dictionary<string, GroupElement>> _groups;
private static List<Dictionary<string, GroupElement>> _groupsPool;
private VisibleIfCache[] _visibleIfCaches;
private bool _isNull;
@@ -514,17 +515,38 @@ namespace FlaxEditor.CustomEditors.Editors
menu.Show(groupPanel, location);
}
internal static void OnGroupUsage()
internal static void OnGroupsBegin()
{
if (_groups != null)
_groups.Clear();
if (_groups == null)
_groups = new Stack<Dictionary<string, GroupElement>>();
if (_groupsPool == null)
_groupsPool = new List<Dictionary<string, GroupElement>>();
Dictionary<string, GroupElement> group;
if (_groupsPool.Count != 0)
{
group = _groupsPool[0];
_groupsPool.RemoveAt(0);
}
else
{
group = new Dictionary<string, GroupElement>();
}
_groups.Push(group);
}
internal static void OnGroupsEnd()
{
var groups = _groups.Pop();
groups.Clear();
_groupsPool.Add(groups);
}
internal static LayoutElementsContainer OnGroup(LayoutElementsContainer layout, EditorDisplayAttribute display)
{
if (display?.Group != null)
{
if (_groups != null && _groups.TryGetValue(display.Group, out var group))
var groups = _groups.Peek();
if (groups.TryGetValue(display.Group, out var group))
{
// Reuse group
layout = group;
@@ -532,12 +554,10 @@ namespace FlaxEditor.CustomEditors.Editors
else
{
// Add new group
if (_groups == null)
_groups = new Dictionary<string, GroupElement>();
group = layout.Group(display.Group);
group.Panel.Tag = group;
group.Panel.MouseButtonRightClicked += OnGroupPanelMouseButtonRightClicked;
_groups.Add(display.Group, group);
groups.Add(display.Group, group);
layout = group;
}
}
@@ -713,7 +733,7 @@ namespace FlaxEditor.CustomEditors.Editors
items.Sort();
// Add items
OnGroupUsage();
OnGroupsBegin();
for (int i = 0; i < items.Count; i++)
{
var item = items[i];
@@ -759,7 +779,7 @@ namespace FlaxEditor.CustomEditors.Editors
} while (c != null);
}
}
OnGroupUsage();
OnGroupsEnd();
}
/// <inheritdoc />

View File

@@ -285,7 +285,7 @@ namespace FlaxEditor.Surface
internal static void DisplayGraphParameters(LayoutElementsContainer layout, GraphParameterData[] data, GetGraphParameterDelegate getter, SetGraphParameterDelegate setter, ValueContainer values, GetGraphParameterDelegate defaultValueGetter = null, CustomPropertySpawnDelegate propertySpawn = null)
{
CustomEditors.Editors.GenericEditor.OnGroupUsage();
CustomEditors.Editors.GenericEditor.OnGroupsBegin();
for (int i = 0; i < data.Length; i++)
{
ref var e = ref data[i];
@@ -332,7 +332,7 @@ namespace FlaxEditor.Surface
else
propertySpawn(itemLayout, valueContainer, ref e);
}
CustomEditors.Editors.GenericEditor.OnGroupUsage();
CustomEditors.Editors.GenericEditor.OnGroupsEnd();
}
internal static string GetMethodDisplayName(string methodName)

View File

@@ -372,7 +372,7 @@ namespace FlaxEditor.Surface
return;
}
var parameters = window.VisjectSurface.Parameters;
CustomEditors.Editors.GenericEditor.OnGroupUsage();
CustomEditors.Editors.GenericEditor.OnGroupsBegin();
for (int i = 0; i < parameters.Count; i++)
{
var p = parameters[i];
@@ -429,7 +429,7 @@ namespace FlaxEditor.Surface
var property = itemLayout.AddPropertyItem(propertyLabel, tooltipText);
property.Property("Value", propertyValue);
}
CustomEditors.Editors.GenericEditor.OnGroupUsage();
CustomEditors.Editors.GenericEditor.OnGroupsEnd();
// Parameters creating
var newParameterTypes = window.NewParameterTypes;

View File

@@ -621,7 +621,11 @@ DragDropEffect WindowsWindow::DoDragDrop(const StringView& data)
// Fix hanging mouse state (Windows doesn't send WM_LBUTTONUP when we end the drag and drop)
if (Input::GetMouseButton(MouseButton::Left))
Input::Mouse->OnMouseUp(Input::Mouse->GetPosition(), MouseButton::Left, this);
{
::POINT point;
::GetCursorPos(&point);
Input::Mouse->OnMouseUp(Float2((float)point.x, (float)point.y), MouseButton::Left, this);
}
return SUCCEEDED(result) ? dropEffectFromOleEnum(dwEffect) : DragDropEffect::None;
}

View File

@@ -248,18 +248,6 @@ bool ProcessMesh(ImportedModelData& result, AssimpImporterData& data, const aiMe
}
}
// Normals
if (aMesh->mNormals)
{
mesh.Normals.Set((const Float3*)aMesh->mNormals, aMesh->mNumVertices);
}
// Tangents
if (aMesh->mTangents)
{
mesh.Tangents.Set((const Float3*)aMesh->mTangents, aMesh->mNumVertices);
}
// Indices
const int32 indicesCount = aMesh->mNumFaces * 3;
mesh.Indices.Resize(indicesCount, false);
@@ -277,6 +265,27 @@ bool ProcessMesh(ImportedModelData& result, AssimpImporterData& data, const aiMe
mesh.Indices[i++] = face->mIndices[2];
}
// Normals
if (data.Options.CalculateNormals || !aMesh->mNormals)
{
// Support generation of normals when using assimp.
if (mesh.GenerateNormals(data.Options.SmoothingNormalsAngle))
{
errorMsg = TEXT("Failed to generate normals.");
return true;
}
}
else if (aMesh->mNormals)
{
mesh.Normals.Set((const Float3*)aMesh->mNormals, aMesh->mNumVertices);
}
// Tangents
if (aMesh->mTangents)
{
mesh.Tangents.Set((const Float3*)aMesh->mTangents, aMesh->mNumVertices);
}
// Lightmap UVs
if (data.Options.LightmapUVsSource == ModelLightmapUVsSource::Disable)
{