diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml
index 3238ce5c2..3d99537ba 100644
--- a/.github/workflows/build_linux.yml
+++ b/.github/workflows/build_linux.yml
@@ -10,7 +10,7 @@ jobs:
steps:
- name: Install dependencies
run: |
- sudo apt-get install libx11-dev libxcursor-dev libxinerama-dev build-essential gettext curl libtool libtool-bin libpulse-dev libasound2-dev libjack-dev portaudio19-dev libcurl4-gnutls-dev
+ sudo apt-get install libx11-dev libxcursor-dev libxinerama-dev build-essential gettext libtool libtool-bin libpulse-dev libasound2-dev libjack-dev portaudio19-dev
- name: Checkout repo
uses: actions/checkout@v2
- name: Checkout LFS
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 236fa6d67..ada5e5fa5 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -32,3 +32,19 @@ Go check out our [Trello](https://trello.com/b/NQjLXRCP/flax-roadmap).
Thank you for taking interest in contributing to Flax!
+
+## **Common issues**
+
+Below are some common issues that someone working with the FlaxEngine source code might run into. Hopefully some of those issues will get fixed in the future. If you know how, please contribute!
+
+* Missing MSVC toolset
+ * Install it through the Visual Studio Installer
+* Building or attaching fails
+ * Run `GenerateProjectFiles.bat`
+ * Rebuild `Flax.Build`
+ * Make sure that there isn't a stray FlaxEngine process running in the background
+ * First start Flax and then attach the C# debugger
+ * Configure the C# FlaxEngine project by going into the project properties, then the debug tab and selecting "Start external program" `Flax\FlaxEngine\Binaries\Editor\Win64\Debug\FlaxEditor.exe`
+ * Then you can also set command line arguments such as `-project "C:\Users\PROFILE\Documents\Flax Projects\FlaxSamples\BasicTemplate"`
+* Git LFS
+ * Push with `git push --no-verify`
diff --git a/README.md b/README.md
index 7d836ed55..be785107d 100644
--- a/README.md
+++ b/README.md
@@ -47,7 +47,7 @@ Flax Visual Studio extension provides better programming workflow, C# scripts de
* Install Visual Studio Code
* Install Mono ([https://www.mono-project.com/download/stable](https://www.mono-project.com/download/stable))
* Install Git with LFS
-* Install requried packages: `sudo apt-get install libx11-dev libxcursor-dev libxinerama-dev nuget autoconf libogg-dev automake build-essential gettext cmake python curl libtool libtool-bin libpulse-dev libasound2-dev libjack-dev portaudio19-dev libcurl4-gnutls-dev`
+* Install requried packages: `sudo apt-get install libx11-dev libxcursor-dev libxinerama-dev nuget autoconf libogg-dev automake build-essential gettext cmake python libtool libtool-bin libpulse-dev libasound2-dev libjack-dev portaudio19-dev`
* Install compiler `sudo apt-get install clang lldb lld` (Clang 6 or newer)
* Clone repo (with LFS)
* Run `./GenerateProjectFiles.sh`
diff --git a/Source/Editor/GUI/Docking/DockWindow.cs b/Source/Editor/GUI/Docking/DockWindow.cs
index 5e94ef547..1a28b1307 100644
--- a/Source/Editor/GUI/Docking/DockWindow.cs
+++ b/Source/Editor/GUI/Docking/DockWindow.cs
@@ -59,7 +59,10 @@ namespace FlaxEditor.GUI.Docking
///
/// Gets the default window size.
///
- public virtual Vector2 DefaultSize => new Vector2(900, 580);
+ ///
+ /// Scaled by the DPI, because the window should be large enough for its content on every monitor
+ ///
+ public virtual Vector2 DefaultSize => new Vector2(900, 580) * DpiScale;
///
/// Gets the serialization typename.
diff --git a/Source/Editor/Modules/SceneModule.cs b/Source/Editor/Modules/SceneModule.cs
index 6334225fd..86479b696 100644
--- a/Source/Editor/Modules/SceneModule.cs
+++ b/Source/Editor/Modules/SceneModule.cs
@@ -22,14 +22,25 @@ namespace FlaxEditor.Modules
///
public class ScenesRootNode : RootNode
{
+ private readonly Editor _editor;
+
+ ///
+ public ScenesRootNode()
+ {
+ _editor = Editor.Instance;
+ }
+
///
public override void Spawn(Actor actor, Actor parent)
{
- Editor.Instance.SceneEditing.Spawn(actor, parent);
+ _editor.SceneEditing.Spawn(actor, parent);
}
///
public override Undo Undo => Editor.Instance.Undo;
+
+ ///
+ public override List Selection => _editor.SceneEditing.Selection;
}
///
diff --git a/Source/Editor/SceneGraph/Actors/SplineNode.cs b/Source/Editor/SceneGraph/Actors/SplineNode.cs
index 293e7d030..7f9e4ca70 100644
--- a/Source/Editor/SceneGraph/Actors/SplineNode.cs
+++ b/Source/Editor/SceneGraph/Actors/SplineNode.cs
@@ -29,7 +29,7 @@ namespace FlaxEditor.SceneGraph.Actors
public override bool CanBeSelectedDirectly => true;
- public override bool CanDuplicate => true;
+ public override bool CanDuplicate => !Root?.Selection.Contains(ParentNode) ?? true;
public override bool CanDelete => true;
@@ -367,6 +367,15 @@ namespace FlaxEditor.SceneGraph.Actors
}
}
+ ///
+ public override bool RayCastSelf(ref RayCastData ray, out float distance, out Vector3 normal)
+ {
+ // Select only spline points
+ normal = Vector3.Up;
+ distance = float.MaxValue;
+ return false;
+ }
+
///
public override void OnDispose()
{
diff --git a/Source/Editor/SceneGraph/RootNode.cs b/Source/Editor/SceneGraph/RootNode.cs
index 10af88489..485c656b1 100644
--- a/Source/Editor/SceneGraph/RootNode.cs
+++ b/Source/Editor/SceneGraph/RootNode.cs
@@ -1,6 +1,7 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using System;
+using System.Collections.Generic;
using FlaxEditor.SceneGraph.Actors;
using FlaxEngine;
@@ -146,5 +147,10 @@ namespace FlaxEditor.SceneGraph
/// Gets the undo.
///
public abstract Undo Undo { get; }
+
+ ///
+ /// Gets the list of selected scene graph nodes in the editor context.
+ ///
+ public abstract List Selection { get; }
}
}
diff --git a/Source/Editor/SceneGraph/SceneGraphNode.cs b/Source/Editor/SceneGraph/SceneGraphNode.cs
index 11c3b7709..76327918d 100644
--- a/Source/Editor/SceneGraph/SceneGraphNode.cs
+++ b/Source/Editor/SceneGraph/SceneGraphNode.cs
@@ -57,7 +57,9 @@ namespace FlaxEditor.SceneGraph
///
public virtual RootNode Root => ParentNode?.Root;
- ///
+ ///
+ /// Gets or sets the transform of the node.
+ ///
public abstract Transform Transform { get; set; }
///
diff --git a/Source/Editor/Windows/Assets/PrefabWindow.Hierarchy.cs b/Source/Editor/Windows/Assets/PrefabWindow.Hierarchy.cs
index e671ba1de..afba74fbc 100644
--- a/Source/Editor/Windows/Assets/PrefabWindow.Hierarchy.cs
+++ b/Source/Editor/Windows/Assets/PrefabWindow.Hierarchy.cs
@@ -36,6 +36,9 @@ namespace FlaxEditor.Windows.Assets
///
public override Undo Undo => _window.Undo;
+
+ ///
+ public override List Selection => _window.Selection;
}
///
diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs
index 5f6ab1613..e33d658e6 100644
--- a/Source/Editor/Windows/SceneTreeWindow.cs
+++ b/Source/Editor/Windows/SceneTreeWindow.cs
@@ -209,9 +209,11 @@ namespace FlaxEditor.Windows
public override void Draw()
{
var style = Style.Current;
+
// Draw overlay
string overlayText = null;
var state = Editor.StateMachine.CurrentState;
+ var textWrap = TextWrapping.NoWrap;
if (state is LoadingState)
{
overlayText = "Loading...";
@@ -223,10 +225,11 @@ namespace FlaxEditor.Windows
else if (((ContainerControl)_tree.GetChild(0)).ChildrenCount == 0)
{
overlayText = "No scene\nOpen one from the content window";
+ textWrap = TextWrapping.WrapWords;
}
if (overlayText != null)
{
- Render2D.DrawText(Style.Current.FontLarge, overlayText, GetClientArea(), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontLarge, overlayText, GetClientArea(), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center, textWrap);
}
base.Draw();
diff --git a/Source/Engine/Audio/OpenAL/AudioBackendOAL.cpp b/Source/Engine/Audio/OpenAL/AudioBackendOAL.cpp
index 89c8f3d02..374ab646f 100644
--- a/Source/Engine/Audio/OpenAL/AudioBackendOAL.cpp
+++ b/Source/Engine/Audio/OpenAL/AudioBackendOAL.cpp
@@ -18,7 +18,7 @@
#include
#include
-#define FLAX_POS_TO_OAL(vec) -vec.X * 0.01f, vec.Y * 0.01f, vec.Z * 0.01f
+#define FLAX_POS_TO_OAL(vec) -vec.X * 0.01f, vec.Y * 0.01f, -vec.Z * 0.01f
namespace ALC
{
diff --git a/Source/Engine/Audio/XAudio2/AudioBackendXAudio2.cpp b/Source/Engine/Audio/XAudio2/AudioBackendXAudio2.cpp
index aac3979ce..a287f40f2 100644
--- a/Source/Engine/Audio/XAudio2/AudioBackendXAudio2.cpp
+++ b/Source/Engine/Audio/XAudio2/AudioBackendXAudio2.cpp
@@ -26,7 +26,7 @@
#define MAX_OUTPUT_CHANNELS 8
#define MAX_CHANNELS_MATRIX_SIZE (MAX_INPUT_CHANNELS*MAX_OUTPUT_CHANNELS)
-#define FLAX_POS_TO_XAUDIO(vec) X3DAUDIO_VECTOR(-vec.X * 0.01f, vec.Y * 0.01f, vec.Z * 0.01f)
+#define FLAX_POS_TO_XAUDIO(vec) X3DAUDIO_VECTOR(vec.X * 0.01f, vec.Y * 0.01f, vec.Z * 0.01f)
#define FLAX_VEC_TO_XAUDIO(vec) (*((X3DAUDIO_VECTOR*)&vec))
namespace XAudio2
diff --git a/Source/Engine/Core/Collections/BitArray.h b/Source/Engine/Core/Collections/BitArray.h
index c3051c678..dc20d1cd7 100644
--- a/Source/Engine/Core/Collections/BitArray.h
+++ b/Source/Engine/Core/Collections/BitArray.h
@@ -236,7 +236,7 @@ public:
return;
ASSERT(capacity >= 0);
const int32 count = preserveContents ? (_count < capacity ? _count : capacity) : 0;
- _allocation.Relocate(Math::Max(capacity / sizeof(ItemType), 1), _count, count);
+ _allocation.Relocate(Math::Max(capacity / sizeof(ItemType), 1), _count / sizeof(ItemType), count / sizeof(ItemType));
_capacity = capacity;
_count = count;
}
diff --git a/Source/Engine/Core/Collections/Sorting.h b/Source/Engine/Core/Collections/Sorting.h
index 4fd26f794..6aa584ace 100644
--- a/Source/Engine/Core/Collections/Sorting.h
+++ b/Source/Engine/Core/Collections/Sorting.h
@@ -17,7 +17,7 @@ public:
///
/// Helper collection used by the sorting algorithms. Implements stack using single linear allocation with variable capacity.
///
- class SortingStack
+ class FLAXENGINE_API SortingStack
{
public:
diff --git a/Source/Engine/Core/ISerializable.h b/Source/Engine/Core/ISerializable.h
index cfc5e1976..aaa2c241b 100644
--- a/Source/Engine/Core/ISerializable.h
+++ b/Source/Engine/Core/ISerializable.h
@@ -37,21 +37,21 @@ public:
virtual ~ISerializable() = default;
///
- /// Serialize object to the output stream compared to the values of the other object instance (eg. default class object). If other object is null then serialize all properties.
+ /// Serializes object to the output stream compared to the values of the other object instance (eg. default class object). If other object is null then serialize all properties.
///
/// The output stream.
/// The instance of the object to compare with and serialize only the modified properties. If null, then serialize all properties.
virtual void Serialize(SerializeStream& stream, const void* otherObj) = 0;
///
- /// Deserialize object from the input stream
+ /// Deserializes object from the input stream.
///
/// The input stream.
/// The deserialization modifier object. Always valid.
virtual void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) = 0;
///
- /// Deserialize object from the input stream child member. Won't deserialize it if member is missing.
+ /// Deserializes object from the input stream child member. Won't deserialize it if member is missing.
///
/// The input stream.
/// The input stream member to lookup.
diff --git a/Source/Engine/Core/Types/Version.h b/Source/Engine/Core/Types/Version.h
index 6d0bac6b1..323c894a5 100644
--- a/Source/Engine/Core/Types/Version.h
+++ b/Source/Engine/Core/Types/Version.h
@@ -4,11 +4,10 @@
#include "BaseTypes.h"
#include "Engine/Core/Math/Math.h"
-#include "Engine/Core/Formatting.h"
#include "Engine/Core/Templates.h"
///
-/// Represents the version number made of major, minor, patch and build numbers.
+/// Represents the version number made of major, minor, build and revision numbers.
///
struct FLAXENGINE_API Version
{
diff --git a/Source/Engine/Engine/GameplayGlobals.cpp b/Source/Engine/Engine/GameplayGlobals.cpp
index 944253b4a..f945832cc 100644
--- a/Source/Engine/Engine/GameplayGlobals.cpp
+++ b/Source/Engine/Engine/GameplayGlobals.cpp
@@ -59,6 +59,7 @@ GameplayGlobals::GameplayGlobals(const SpawnParams& params, const AssetInfo* inf
Dictionary GameplayGlobals::GetValues() const
{
+ ScopeLock lock(Locker);
Dictionary result;
for (auto& e : Variables)
result.Add(e.Key, e.Value.Value);
@@ -67,6 +68,7 @@ Dictionary GameplayGlobals::GetValues() const
void GameplayGlobals::SetValues(const Dictionary& values)
{
+ ScopeLock lock(Locker);
for (auto& e : values)
{
bool hasKey = false;
@@ -97,6 +99,7 @@ void GameplayGlobals::SetValues(const Dictionary& values)
Dictionary GameplayGlobals::GetDefaultValues() const
{
+ ScopeLock lock(Locker);
Dictionary result;
for (auto& e : Variables)
result.Add(e.Key, e.Value.DefaultValue);
@@ -105,6 +108,7 @@ Dictionary GameplayGlobals::GetDefaultValues() const
void GameplayGlobals::SetDefaultValues(const Dictionary& values)
{
+ ScopeLock lock(Locker);
for (auto& e : values)
{
bool hasKey = false;
@@ -135,12 +139,14 @@ void GameplayGlobals::SetDefaultValues(const Dictionary& values
Variant GameplayGlobals::GetValue(const StringView& name) const
{
+ ScopeLock lock(Locker);
auto e = Variables.TryGet(name);
return e ? e->Value : Variant::Zero;
}
void GameplayGlobals::SetValue(const StringView& name, const Variant& value)
{
+ ScopeLock lock(Locker);
auto e = Variables.TryGet(name);
if (e)
{
@@ -150,6 +156,7 @@ void GameplayGlobals::SetValue(const StringView& name, const Variant& value)
void GameplayGlobals::ResetValues()
{
+ ScopeLock lock(Locker);
for (auto& e : Variables)
{
e.Value.Value = e.Value.DefaultValue;
diff --git a/Source/Engine/Engine/Time.h b/Source/Engine/Engine/Time.h
index eb176ae7c..af0545184 100644
--- a/Source/Engine/Engine/Time.h
+++ b/Source/Engine/Engine/Time.h
@@ -22,7 +22,7 @@ public:
/// Engine subsystem updating data.
/// Used to invoke game logic updates, physics updates and rendering with possibly different frequencies.
///
- class TickData
+ class FLAXENGINE_API TickData
{
public:
diff --git a/Source/Engine/Graphics/RenderTask.h b/Source/Engine/Graphics/RenderTask.h
index 5d6a47861..96048bcc2 100644
--- a/Source/Engine/Graphics/RenderTask.h
+++ b/Source/Engine/Graphics/RenderTask.h
@@ -251,7 +251,7 @@ public:
///
/// The scene rendering camera. Can be used to override the rendering view properties based on the current camera setup.
///
- API_FIELD() Camera* Camera = nullptr;
+ API_FIELD() ScriptingObjectReference Camera;
///
/// The render view description.
diff --git a/Source/Engine/Level/Actors/BoxBrush.cpp b/Source/Engine/Level/Actors/BoxBrush.cpp
index f02dd5bd3..4330424c7 100644
--- a/Source/Engine/Level/Actors/BoxBrush.cpp
+++ b/Source/Engine/Level/Actors/BoxBrush.cpp
@@ -128,6 +128,13 @@ void BoxBrush::GetSurfaces(CSG::Surface surfaces[6])
}
}
+void BoxBrush::SetMaterial(int32 surfaceIndex, MaterialBase* material)
+{
+ CHECK(Math::IsInRange(surfaceIndex, 0, 5));
+ Surfaces[surfaceIndex].Material = material;
+ OnBrushModified();
+}
+
bool BoxBrush::Intersects(int32 surfaceIndex, const Ray& ray, float& distance, Vector3& normal) const
{
distance = MAX_float;
@@ -232,6 +239,26 @@ void BoxBrush::OnDebugDrawSelected()
#endif
+Scene* BoxBrush::GetBrushScene() const
+{
+ return GetScene();
+}
+
+Guid BoxBrush::GetBrushID() const
+{
+ return GetID();
+}
+
+bool BoxBrush::CanUseCSG() const
+{
+ return IsActiveInHierarchy();
+}
+
+CSG::Mode BoxBrush::GetBrushMode() const
+{
+ return _mode;
+}
+
void BoxBrush::GetSurfaces(Array& surfaces)
{
surfaces.Clear();
@@ -240,6 +267,11 @@ void BoxBrush::GetSurfaces(Array& surfaces)
GetSurfaces(surfaces.Get());
}
+int32 BoxBrush::GetSurfacesCount()
+{
+ return 6;
+}
+
void BoxBrush::OnTransformChanged()
{
// Base
@@ -272,7 +304,7 @@ void BoxBrush::OnParentChanged()
{
// Base
Actor::OnParentChanged();
-
+
if (!IsDuringPlay())
return;
diff --git a/Source/Engine/Level/Actors/BoxBrush.h b/Source/Engine/Level/Actors/BoxBrush.h
index e8fc63e3f..ae9be5b83 100644
--- a/Source/Engine/Level/Actors/BoxBrush.h
+++ b/Source/Engine/Level/Actors/BoxBrush.h
@@ -153,6 +153,13 @@ public:
/// Surfaces
void GetSurfaces(CSG::Surface surfaces[6]);
+ ///
+ /// Sets the brush surface material.
+ ///
+ /// The brush surface index.
+ /// The material.
+ API_FUNCTION() void SetMaterial(int32 surfaceIndex, MaterialBase* material);
+
public:
///
@@ -169,7 +176,7 @@ public:
/// Otherwise performs simple vs test.
/// For more efficient collisions detection and ray casting use physics.
///
- /// The brush surface index..
+ /// The brush surface index.
/// The ray to test.
/// When the method completes and returns true, contains the distance of the intersection (if any valid).
/// When the method completes, contains the intersection surface normal vector (if any valid).
@@ -179,7 +186,7 @@ public:
///
/// Gets the brush surface triangles array (group by 3 vertices).
///
- /// The brush surface index..
+ /// The brush surface index.
/// The output vertices buffer with triangles or empty if no data loaded.
API_FUNCTION() void GetVertices(int32 surfaceIndex, API_PARAM(Out) Array& outputData) const;
@@ -204,32 +211,12 @@ public:
#endif
// [CSG::Brush]
- Scene* GetBrushScene() const override
- {
- return GetScene();
- }
-
- Guid GetBrushID() const override
- {
- return GetID();
- }
-
- bool CanUseCSG() const override
- {
- return IsActiveInHierarchy();
- }
-
- CSG::Mode GetBrushMode() const override
- {
- return _mode;
- }
-
+ Scene* GetBrushScene() const override;
+ Guid GetBrushID() const override;
+ bool CanUseCSG() const override;
+ CSG::Mode GetBrushMode() const override;
void GetSurfaces(Array& surfaces) override;
-
- int32 GetSurfacesCount() override
- {
- return 6;
- }
+ int32 GetSurfacesCount() override;
protected:
diff --git a/Source/Engine/Level/Actors/Camera.cpp b/Source/Engine/Level/Actors/Camera.cpp
index 1f9de6d41..c37e30607 100644
--- a/Source/Engine/Level/Actors/Camera.cpp
+++ b/Source/Engine/Level/Actors/Camera.cpp
@@ -17,12 +17,13 @@
Array Camera::Cameras;
Camera* Camera::CutSceneCamera = nullptr;
-Camera* Camera::OverrideMainCamera = nullptr;
+ScriptingObjectReference Camera::OverrideMainCamera;
Camera* Camera::GetMainCamera()
{
- if (OverrideMainCamera)
- return OverrideMainCamera;
+ Camera* overrideMainCamera = OverrideMainCamera.Get();
+ if (overrideMainCamera)
+ return overrideMainCamera;
if (CutSceneCamera)
return CutSceneCamera;
return Cameras.HasItems() ? Cameras.First() : nullptr;
diff --git a/Source/Engine/Level/Actors/Camera.h b/Source/Engine/Level/Actors/Camera.h
index 4bf277279..505479e98 100644
--- a/Source/Engine/Level/Actors/Camera.h
+++ b/Source/Engine/Level/Actors/Camera.h
@@ -8,6 +8,7 @@
#include "Engine/Core/Math/Viewport.h"
#include "Engine/Core/Math/Ray.h"
#include "Engine/Core/Types/LayersMask.h"
+#include "Engine/Scripting/ScriptingObjectReference.h"
#if USE_EDITOR
#include "Engine/Content/AssetReference.h"
#include "Engine/Graphics/Models/ModelInstanceEntry.h"
@@ -28,7 +29,7 @@ DECLARE_SCENE_OBJECT(Camera);
static Camera* CutSceneCamera;
// The overriden main camera.
- API_FIELD() static Camera* OverrideMainCamera;
+ API_FIELD() static ScriptingObjectReference OverrideMainCamera;
// Gets the main camera.
API_PROPERTY() static Camera* GetMainCamera();
diff --git a/Source/Engine/Level/Actors/SplineModel.cpp b/Source/Engine/Level/Actors/SplineModel.cpp
index 794658afb..ffa995f58 100644
--- a/Source/Engine/Level/Actors/SplineModel.cpp
+++ b/Source/Engine/Level/Actors/SplineModel.cpp
@@ -138,11 +138,10 @@ void SplineModel::OnSplineUpdated()
Vector3 tmp = corners[i] * _preTransform.Scale;
double rotation[4] = { (double)_preTransform.Orientation.X, (double)_preTransform.Orientation.Y, (double)_preTransform.Orientation.Z, (double)_preTransform.Orientation.W };
const double length = sqrt(rotation[0] * rotation[0] + rotation[1] * rotation[1] + rotation[2] * rotation[2] + rotation[3] * rotation[3]);
- const double inv = 1.0 / length;
- rotation[0] *= inv;
- rotation[1] *= inv;
- rotation[2] *= inv;
- rotation[3] *= inv;
+ rotation[0] /= length;
+ rotation[1] /= length;
+ rotation[2] /= length;
+ rotation[3] /= length;
double pos[3] = { (double)tmp.X, (double)tmp.Y, (double)tmp.Z };
const double x = rotation[0] + rotation[0];
const double y = rotation[1] + rotation[1];
@@ -251,7 +250,7 @@ void SplineModel::UpdateDeformationBuffer()
AnimationUtils::GetTangent(end.Value, end.TangentIn, length, rightTangent);
for (int32 chunk = 0; chunk < chunksPerSegment; chunk++)
{
- const float alpha = (float)chunk * chunksPerSegmentInv;
+ const float alpha = (chunk == chunksPerSegment - 1)? 1.0f : ((float)chunk * chunksPerSegmentInv);
// Evaluate transformation at the curve
AnimationUtils::Bezier(start.Value, leftTangent, rightTangent, end.Value, alpha, transform);
diff --git a/Source/Engine/Physics/Colliders/CharacterController.cpp b/Source/Engine/Physics/Colliders/CharacterController.cpp
index 4315ce8ba..419b6b052 100644
--- a/Source/Engine/Physics/Colliders/CharacterController.cpp
+++ b/Source/Engine/Physics/Colliders/CharacterController.cpp
@@ -22,6 +22,7 @@ CharacterController::CharacterController(const SpawnParams& params)
, _radius(50.0f)
, _height(150.0f)
, _minMoveDistance(0.0f)
+ , _upDirection(Vector3::Up)
, _isUpdatingTransform(false)
, _nonWalkableMode(CharacterController::NonWalkableModes::PreventClimbing)
, _lastFlags(CollisionFlags::None)
@@ -82,6 +83,18 @@ void CharacterController::SetStepOffset(float value)
_controller->setStepOffset(value);
}
+void CharacterController::SetUpDirection(const Vector3& up)
+{
+ if (_controller)
+ _controller->setUpDirection(C2P(up));
+ _upDirection = up;
+}
+
+Vector3 CharacterController::GetUpDirection() const
+{
+ return _controller ? P2C(_controller->getUpDirection()) : _upDirection;
+}
+
void CharacterController::SetMinMoveDistance(float value)
{
_minMoveDistance = Math::Max(value, 0.0f);
@@ -180,6 +193,7 @@ void CharacterController::CreateActor()
// Create controller
_controller = (PxCapsuleController*)Physics::GetControllerManager()->createController(desc);
ASSERT(_controller);
+ _controller->setUpDirection(C2P(_upDirection));
const auto actor = _controller->getActor();
ASSERT(actor && actor->getNbShapes() == 1);
actor->getShapes(&_shape, 1);
@@ -363,6 +377,7 @@ void CharacterController::Serialize(SerializeStream& stream, const void* otherOb
SERIALIZE_MEMBER(Radius, _radius);
SERIALIZE_MEMBER(Height, _height);
SERIALIZE_MEMBER(MinMoveDistance, _minMoveDistance);
+ SERIALIZE_MEMBER(UpDirection, _upDirection);
}
void CharacterController::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
@@ -376,4 +391,5 @@ void CharacterController::Deserialize(DeserializeStream& stream, ISerializeModif
DESERIALIZE_MEMBER(Radius, _radius);
DESERIALIZE_MEMBER(Height, _height);
DESERIALIZE_MEMBER(MinMoveDistance, _minMoveDistance);
+ DESERIALIZE_MEMBER(UpDirection, _upDirection);
}
diff --git a/Source/Engine/Physics/Colliders/CharacterController.h b/Source/Engine/Physics/Colliders/CharacterController.h
index f850b9124..e3f690f8c 100644
--- a/Source/Engine/Physics/Colliders/CharacterController.h
+++ b/Source/Engine/Physics/Colliders/CharacterController.h
@@ -65,6 +65,7 @@ private:
float _height;
float _minMoveDistance;
bool _isUpdatingTransform;
+ Vector3 _upDirection;
NonWalkableModes _nonWalkableMode;
CollisionFlags _lastFlags;
uint32 _filterData[4];
@@ -141,6 +142,17 @@ public:
///
API_PROPERTY() void SetStepOffset(float value);
+ ///
+ /// Gets the character up vector.
+ ///
+ API_PROPERTY(Attributes="EditorOrder(240), DefaultValue(true), EditorDisplay(\"Character Controller\")")
+ Vector3 GetUpDirection() const;
+
+ ///
+ /// Sets the character up vector.
+ ///
+ API_PROPERTY() void SetUpDirection(const Vector3& up);
+
///
/// Gets the minimum move distance of the character controller. The minimum traveled distance to consider. If traveled distance is smaller, the character doesn't move. This is used to stop the recursive motion algorithm when remaining distance to travel is small.
///
diff --git a/Source/Engine/Physics/Physics.Queries.cpp b/Source/Engine/Physics/Physics.Queries.cpp
index 15630e7ff..6cf3c786d 100644
--- a/Source/Engine/Physics/Physics.Queries.cpp
+++ b/Source/Engine/Physics/Physics.Queries.cpp
@@ -358,6 +358,51 @@ bool Physics::SphereCastAll(const Vector3& center, const float radius, const Vec
return true;
}
+bool Physics::CapsuleCast(const Vector3& center, const float radius, const float height, const Vector3& direction, const Quaternion& rotation, const float maxDistance, uint32 layerMask, bool hitTriggers)
+{
+ // Prepare data
+ SCENE_QUERY_SETUP_SWEEP_1();
+ const PxTransform pose(C2P(center), C2P(rotation));
+ const PxCapsuleGeometry geometry(radius, height * 0.5f);
+
+ // Perform sweep test
+ return GetScene()->sweep(geometry, pose, C2P(direction), maxDistance, buffer, hitFlags, filterData, GetQueryFilterCallback());
+}
+
+bool Physics::CapsuleCast(const Vector3& center, const float radius, const float height, const Vector3& direction, RayCastHit& hitInfo, const Quaternion& rotation, const float maxDistance, uint32 layerMask, bool hitTriggers)
+{
+ // Prepare data
+ SCENE_QUERY_SETUP_SWEEP_1();
+ const PxTransform pose(C2P(center), C2P(rotation));
+ const PxCapsuleGeometry geometry(radius, height * 0.5f);
+
+ // Perform sweep test
+ if (!GetScene()->sweep(geometry, pose, C2P(direction), maxDistance, buffer, hitFlags, filterData, GetQueryFilterCallback()))
+ return false;
+
+ // Collect results
+ SCENE_QUERY_COLLECT_SINGLE();
+
+ return true;
+}
+
+bool Physics::CapsuleCastAll(const Vector3& center, const float radius, const float height, const Vector3& direction, Array& results, const Quaternion& rotation, const float maxDistance, uint32 layerMask, bool hitTriggers)
+{
+ // Prepare data
+ SCENE_QUERY_SETUP_SWEEP();
+ const PxTransform pose(C2P(center), C2P(rotation));
+ const PxCapsuleGeometry geometry(radius, height * 0.5f);
+
+ // Perform sweep test
+ if (!GetScene()->sweep(geometry, pose, C2P(direction), maxDistance, buffer, hitFlags, filterData, GetQueryFilterCallback()))
+ return false;
+
+ // Collect results
+ SCENE_QUERY_COLLECT_ALL();
+
+ return true;
+}
+
bool Physics::CheckBox(const Vector3& center, const Vector3& halfExtents, const Quaternion& rotation, uint32 layerMask, bool hitTriggers)
{
// Prepare data
@@ -380,6 +425,17 @@ bool Physics::CheckSphere(const Vector3& center, const float radius, uint32 laye
return GetScene()->overlap(geometry, pose, buffer, filterData, GetQueryFilterCallback());
}
+bool Physics::CheckCapsule(const Vector3& center, const float radius, const float height, uint32 layerMask, bool hitTriggers)
+{
+ // Prepare data
+ SCENE_QUERY_SETUP_OVERLAP_1();
+ const PxTransform pose(C2P(center));
+ const PxCapsuleGeometry geometry(radius, height * 0.5f);
+
+ // Perform overlap test
+ return GetScene()->overlap(geometry, pose, buffer, filterData, GetQueryFilterCallback());
+}
+
bool Physics::OverlapBox(const Vector3& center, const Vector3& halfExtents, Array& results, const Quaternion& rotation, uint32 layerMask, bool hitTriggers)
{
// Prepare data
@@ -414,6 +470,23 @@ bool Physics::OverlapSphere(const Vector3& center, const float radius, Array& results, uint32 layerMask, bool hitTriggers)
+{
+ // Prepare data
+ SCENE_QUERY_SETUP_OVERLAP();
+ const PxTransform pose(C2P(center));
+ const PxCapsuleGeometry geometry(radius, height * 0.5f);
+
+ // Perform overlap test
+ if (!GetScene()->overlap(geometry, pose, buffer, filterData, GetQueryFilterCallback()))
+ return false;
+
+ // Collect results
+ SCENE_QUERY_COLLECT_OVERLAP_COLLIDER();
+
+ return true;
+}
+
bool Physics::OverlapBox(const Vector3& center, const Vector3& halfExtents, Array& results, const Quaternion& rotation, uint32 layerMask, bool hitTriggers)
{
// Prepare data
@@ -447,3 +520,20 @@ bool Physics::OverlapSphere(const Vector3& center, const float radius, Array& results, uint32 layerMask, bool hitTriggers)
+{
+ // Prepare data
+ SCENE_QUERY_SETUP_OVERLAP();
+ const PxTransform pose(C2P(center));
+ const PxCapsuleGeometry geometry(radius, height * 0.5f);
+
+ // Perform overlap test
+ if (!GetScene()->overlap(geometry, pose, buffer, filterData, GetQueryFilterCallback()))
+ return false;
+
+ // Collect results
+ SCENE_QUERY_COLLECT_OVERLAP();
+
+ return true;
+}
diff --git a/Source/Engine/Physics/Physics.h b/Source/Engine/Physics/Physics.h
index dfff1d51a..0a5dfefd0 100644
--- a/Source/Engine/Physics/Physics.h
+++ b/Source/Engine/Physics/Physics.h
@@ -268,6 +268,50 @@ public:
/// True if sphere hits an matching object, otherwise false.
API_FUNCTION() static bool SphereCastAll(const Vector3& center, float radius, const Vector3& direction, API_PARAM(Out) Array& results, float maxDistance = MAX_float, uint32 layerMask = MAX_uint32, bool hitTriggers = true);
+ ///
+ /// Performs a sweep test against objects in the scene using a capsule geometry.
+ ///
+ /// The box center.
+ /// The radius of the capsule.
+ /// The height of the capsule, excluding the top and bottom spheres.
+ /// The normalized direction in which cast a box.
+ /// The capsule rotation.
+ /// The maximum distance the ray should check for collisions.
+ /// The layer mask used to filter the results.
+ /// If set to true triggers will be hit, otherwise will skip them.
+ /// True if capsule hits an matching object, otherwise false.
+ API_FUNCTION() static bool CapsuleCast(const Vector3& center, float radius, float height, const Vector3& direction, const Quaternion& rotation = Quaternion::Identity, float maxDistance = MAX_float, uint32 layerMask = MAX_uint32, bool hitTriggers = true);
+
+ ///
+ /// Performs a sweep test against objects in the scene using a capsule geometry.
+ ///
+ /// The box center.
+ /// The radius of the capsule.
+ /// The height of the capsule, excluding the top and bottom spheres.
+ /// The normalized direction in which cast a box.
+ /// The result hit information. Valid only when method returns true.
+ /// The capsule rotation.
+ /// The maximum distance the ray should check for collisions.
+ /// The layer mask used to filter the results.
+ /// If set to true triggers will be hit, otherwise will skip them.
+ /// True if capsule hits an matching object, otherwise false.
+ API_FUNCTION() static bool CapsuleCast(const Vector3& center, float radius, float height, const Vector3& direction, API_PARAM(Out) RayCastHit& hitInfo, const Quaternion& rotation = Quaternion::Identity, float maxDistance = MAX_float, uint32 layerMask = MAX_uint32, bool hitTriggers = true);
+
+ ///
+ /// Performs a sweep test against objects in the scene using a capsule geometry.
+ ///
+ /// The box center.
+ /// The radius of the capsule.
+ /// The height of the capsule, excluding the top and bottom spheres.
+ /// The normalized direction in which cast a box.
+ /// The result hits. Valid only when method returns true.
+ /// The capsule rotation.
+ /// The maximum distance the ray should check for collisions.
+ /// The layer mask used to filter the results.
+ /// If set to true triggers will be hit, otherwise will skip them.
+ /// True if capsule hits an matching object, otherwise false.
+ API_FUNCTION() static bool CapsuleCastAll(const Vector3& center, float radius, float height, const Vector3& direction, API_PARAM(Out) Array& results, const Quaternion& rotation = Quaternion::Identity, float maxDistance = MAX_float, uint32 layerMask = MAX_uint32, bool hitTriggers = true);
+
///
/// Checks whether the given box overlaps with other colliders or not.
///
@@ -289,6 +333,17 @@ public:
/// True if sphere overlaps any matching object, otherwise false.
API_FUNCTION() static bool CheckSphere(const Vector3& center, float radius, uint32 layerMask = MAX_uint32, bool hitTriggers = true);
+ ///
+ /// Checks whether the given capsule overlaps with other colliders or not.
+ ///
+ /// The capsule center.
+ /// The radius of the capsule.
+ /// The height of the capsule, excluding the top and bottom spheres.
+ /// The layer mask used to filter the results.
+ /// If set to true triggers will be hit, otherwise will skip them.
+ /// True if capsule overlaps any matching object, otherwise false.
+ API_FUNCTION() static bool CheckCapsule(const Vector3& center, float radius, float height, uint32 layerMask = MAX_uint32, bool hitTriggers = true);
+
///
/// Finds all colliders touching or inside of the given box.
///
@@ -312,6 +367,18 @@ public:
/// True if sphere overlaps any matching object, otherwise false.
API_FUNCTION() static bool OverlapSphere(const Vector3& center, float radius, API_PARAM(Out) Array& results, uint32 layerMask = MAX_uint32, bool hitTriggers = true);
+ ///
+ /// Finds all colliders touching or inside of the given sphere.
+ ///
+ /// The sphere center.
+ /// The radius of the capsule.
+ /// The height of the capsule, excluding the top and bottom spheres.
+ /// The result colliders that overlap with the given sphere. Valid only when method returns true.
+ /// The layer mask used to filter the results.
+ /// If set to true triggers will be hit, otherwise will skip them.
+ /// True if capsule overlaps any matching object, otherwise false.
+ API_FUNCTION() static bool OverlapCapsule(const Vector3& center, float radius, float height, API_PARAM(Out) Array& results, uint32 layerMask = MAX_uint32, bool hitTriggers = true);
+
///
/// Finds all colliders touching or inside of the given box.
///
@@ -335,6 +402,18 @@ public:
/// True if sphere overlaps any matching object, otherwise false.
API_FUNCTION() static bool OverlapSphere(const Vector3& center, float radius, API_PARAM(Out) Array& results, uint32 layerMask = MAX_uint32, bool hitTriggers = true);
+ ///
+ /// Finds all colliders touching or inside of the given sphere.
+ ///
+ /// The capsule center.
+ /// The radius of the capsule.
+ /// The height of the capsule, excluding the top and bottom spheres.
+ /// The result colliders that overlap with the given sphere. Valid only when method returns true.
+ /// The layer mask used to filter the results.
+ /// If set to true triggers will be hit, otherwise will skip them.
+ /// True if capsule overlaps any matching object, otherwise false.
+ API_FUNCTION() static bool OverlapCapsule(const Vector3& center, float radius, float height, API_PARAM(Out) Array& results, uint32 layerMask = MAX_uint32, bool hitTriggers = true);
+
public:
///
diff --git a/Source/Engine/Platform/Windows/WindowsFileSystem.cpp b/Source/Engine/Platform/Windows/WindowsFileSystem.cpp
index 1816c9552..6cf467976 100644
--- a/Source/Engine/Platform/Windows/WindowsFileSystem.cpp
+++ b/Source/Engine/Platform/Windows/WindowsFileSystem.cpp
@@ -260,7 +260,7 @@ bool WindowsFileSystem::ShowSaveFileDialog(Window* parentWindow, const StringVie
of.lpstrFilter = filter.HasChars() ? filter.Get() : nullptr;
of.lpstrFile = fileNamesBuffer.Get();
of.nMaxFile = maxFilenamesSize;
- of.Flags = OFN_EXPLORER | OFN_ENABLESIZING;
+ of.Flags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_OVERWRITEPROMPT;
of.lpstrTitle = title.HasChars() ? title.Get() : nullptr;
of.lpstrInitialDir = initialDirectory.HasChars() ? initialDirectory.Get() : nullptr;
if (parentWindow)
diff --git a/Source/Engine/Renderer/ShadowsPass.cpp b/Source/Engine/Renderer/ShadowsPass.cpp
index 0552fc598..7e1504e42 100644
--- a/Source/Engine/Renderer/ShadowsPass.cpp
+++ b/Source/Engine/Renderer/ShadowsPass.cpp
@@ -251,6 +251,7 @@ void ShadowsPass::Prepare(RenderContext& renderContext, GPUContext* context)
auto& shadowView = _shadowContext.View;
shadowView.Flags = view.Flags;
shadowView.StaticFlagsMask = view.StaticFlagsMask;
+ shadowView.RenderLayersMask = view.RenderLayersMask;
shadowView.IsOfflinePass = view.IsOfflinePass;
shadowView.ModelLODBias = view.ModelLODBias + view.ShadowModelLODBias;
shadowView.ModelLODDistanceFactor = view.ModelLODDistanceFactor * view.ShadowModelLODDistanceFactor;
diff --git a/Source/Engine/UI/GUI/Common/Dropdown.cs b/Source/Engine/UI/GUI/Common/Dropdown.cs
index 917e51f6e..3bb00990f 100644
--- a/Source/Engine/UI/GUI/Common/Dropdown.cs
+++ b/Source/Engine/UI/GUI/Common/Dropdown.cs
@@ -8,8 +8,8 @@ namespace FlaxEngine.GUI
///
/// Dropdown menu control allows to choose one item from the provided collection of options.
///
- ///
- public class Dropdown : Control
+ ///
+ public class Dropdown : ContainerControl
{
///
/// The root control used by the to show the items collections and track item selecting event.
@@ -18,7 +18,7 @@ namespace FlaxEngine.GUI
[HideInEditor]
protected class DropdownRoot : Panel
{
- private bool isMouseDown;
+ private bool _isMouseDown;
///
/// Occurs when item gets clicked. Argument is item index.
@@ -38,9 +38,9 @@ namespace FlaxEngine.GUI
///
public override bool OnMouseDown(Vector2 location, MouseButton button)
{
- isMouseDown = true;
+ _isMouseDown = true;
var result = base.OnMouseDown(location, button);
- isMouseDown = false;
+ _isMouseDown = false;
if (!result)
return false;
@@ -57,8 +57,10 @@ namespace FlaxEngine.GUI
{
base.OnLostFocus();
- if (!isMouseDown)
- LostFocus();
+ if (!_isMouseDown)
+ {
+ LostFocus?.Invoke();
+ }
}
///
@@ -82,7 +84,7 @@ namespace FlaxEngine.GUI
///
protected DropdownRoot _popup;
- private bool _mouseDown;
+ private bool _touchDown;
///
/// The selected index of the item (-1 for no selection).
@@ -118,13 +120,9 @@ namespace FlaxEngine.GUI
get => _selectedIndex;
set
{
- // Clamp index
value = Mathf.Min(value, _items.Count - 1);
-
- // Check if index will change
if (value != _selectedIndex)
{
- // Select
_selectedIndex = value;
OnSelectedIndexChanged();
}
@@ -225,6 +223,8 @@ namespace FlaxEngine.GUI
public Dropdown()
: base(0, 0, 120, 18.0f)
{
+ AutoFocus = false;
+
var style = Style.Current;
Font = new FontReference(style.FontMedium);
TextColor = style.Foreground;
@@ -334,6 +334,7 @@ namespace FlaxEngine.GUI
}
*/
var itemsWidth = Width;
+ var height = container.Margin.Height;
for (int i = 0; i < _items.Count; i++)
{
@@ -347,35 +348,51 @@ namespace FlaxEngine.GUI
var label = new Label
{
X = itemsMargin,
- Width = itemsWidth - itemsMargin,
+ Size = new Vector2(itemsWidth - itemsMargin, itemsHeight),
Font = Font,
TextColor = Color.White * 0.9f,
TextColorHighlighted = Color.White,
HorizontalAlignment = TextAlignment.Near,
- AnchorPreset = AnchorPresets.VerticalStretchRight,
Text = _items[i],
Parent = item,
};
+ height += itemsHeight;
+ if (i != 0)
+ height += container.Spacing;
if (_selectedIndex == i)
{
var icon = new Image
{
Brush = CheckedImage,
- Width = itemsMargin,
+ Size = new Vector2(itemsMargin, itemsHeight),
Margin = new Margin(4.0f, 6.0f, 4.0f, 4.0f),
- AnchorPreset = AnchorPresets.VerticalStretchLeft,
+ //AnchorPreset = AnchorPresets.VerticalStretchLeft,
Parent = item,
};
}
}
- popup.Size = new Vector2(itemsWidth, (itemsHeight + container.Spacing) * _items.Count + container.Margin.Height);
+ popup.Size = new Vector2(itemsWidth, height);
popup.ItemsContainer = container;
return popup;
}
+ ///
+ /// Called when popup menu gets shown.
+ ///
+ protected virtual void OnPopupShow()
+ {
+ }
+
+ ///
+ /// Called when popup menu gets hidden.
+ ///
+ protected virtual void OnPopupHide()
+ {
+ }
+
///
/// Destroys the popup.
///
@@ -383,11 +400,59 @@ namespace FlaxEngine.GUI
{
if (_popup != null)
{
+ OnPopupHide();
_popup.Dispose();
_popup = null;
}
}
+ ///
+ /// Shows the popup.
+ ///
+ public void ShowPopup()
+ {
+ var root = Root;
+ if (_items.Count == 0 || root == null)
+ return;
+
+ // Setup popup
+ DestroyPopup();
+ _popup = CreatePopup();
+
+ // Update layout
+ _popup.UnlockChildrenRecursive();
+ _popup.PerformLayout();
+
+ // Bind events
+ _popup.ItemClicked += index =>
+ {
+ OnItemClicked(index);
+ DestroyPopup();
+ };
+ _popup.LostFocus += DestroyPopup;
+
+ // Show dropdown popup
+ Vector2 locationRootSpace = Location + new Vector2(0, Height);
+ var parent = Parent;
+ while (parent != null && parent != Root)
+ {
+ locationRootSpace = parent.PointToParent(ref locationRootSpace);
+ parent = parent.Parent;
+ }
+ _popup.Location = locationRootSpace;
+ _popup.Parent = root;
+ _popup.Focus();
+ OnPopupShow();
+ }
+
+ ///
+ /// Hides the popup.
+ ///
+ public void HidePopup()
+ {
+ DestroyPopup();
+ }
+
///
public override void OnDestroy()
{
@@ -397,7 +462,7 @@ namespace FlaxEngine.GUI
}
///
- public override void Draw()
+ public override void DrawSelf()
{
// Cache data
var clientRect = new Rectangle(Vector2.Zero, Size);
@@ -413,7 +478,7 @@ namespace FlaxEngine.GUI
backgroundColor *= 0.5f;
arrowColor *= 0.7f;
}
- else if (isOpened || _mouseDown)
+ else if (isOpened || _touchDown)
{
backgroundColor = BackgroundColorSelected;
borderColor = BorderColorSelected;
@@ -448,17 +513,15 @@ namespace FlaxEngine.GUI
///
public override void OnLostFocus()
{
- base.OnLostFocus();
+ _touchDown = false;
- // Clear flags
- _mouseDown = false;
+ base.OnLostFocus();
}
///
public override void OnMouseLeave()
{
- // Clear flags
- _mouseDown = false;
+ _touchDown = false;
base.OnMouseLeave();
}
@@ -466,59 +529,60 @@ namespace FlaxEngine.GUI
///
public override bool OnMouseDown(Vector2 location, MouseButton button)
{
- // Check mouse buttons
+ if (base.OnMouseDown(location, button))
+ return true;
+
if (button == MouseButton.Left)
{
- // Set flag
- _mouseDown = true;
+ _touchDown = true;
+ return true;
}
- return base.OnMouseDown(location, button);
+ return false;
}
///
public override bool OnMouseUp(Vector2 location, MouseButton button)
{
- // Check flags
- if (_mouseDown)
+ if (_touchDown && button == MouseButton.Left)
{
- // Clear flag
- _mouseDown = false;
-
- var root = Root;
- if (_items.Count > 0 && root != null)
- {
- // Setup popup
- DestroyPopup();
- _popup = CreatePopup();
-
- // Update layout
- _popup.UnlockChildrenRecursive();
- _popup.PerformLayout();
-
- // Bind events
- _popup.ItemClicked += (index) =>
- {
- OnItemClicked(index);
- DestroyPopup();
- };
- _popup.LostFocus += DestroyPopup;
-
- // Show dropdown popup
- Vector2 locationRootSpace = Location + new Vector2(0, Height);
- var parent = Parent;
- while (parent != null && parent != Root)
- {
- locationRootSpace = parent.PointToParent(ref location);
- parent = parent.Parent;
- }
- _popup.Location = locationRootSpace;
- _popup.Parent = root;
- _popup.Focus();
- }
+ _touchDown = false;
+ ShowPopup();
+ return true;
}
+ return base.OnMouseUp(location, button);
+ }
+
+ ///
+ public override bool OnTouchDown(Vector2 location, int pointerId)
+ {
+ if (base.OnTouchDown(location, pointerId))
+ return true;
+
+ _touchDown = true;
return true;
}
+
+ ///
+ public override bool OnTouchUp(Vector2 location, int pointerId)
+ {
+ if (base.OnTouchUp(location, pointerId))
+ return true;
+
+ if (_touchDown)
+ {
+ ShowPopup();
+ }
+ return true;
+ }
+
+ ///
+ public override void OnTouchLeave(int pointerId)
+ {
+ _touchDown = false;
+
+ base.OnTouchLeave(pointerId);
+ }
}
}
diff --git a/Source/Engine/UI/GUI/Control.cs b/Source/Engine/UI/GUI/Control.cs
index 96b7bf22b..afdd86bcb 100644
--- a/Source/Engine/UI/GUI/Control.cs
+++ b/Source/Engine/UI/GUI/Control.cs
@@ -313,7 +313,7 @@ namespace FlaxEngine.GUI
///
/// Gets the control DPI scale factor (1 is default). Includes custom DPI scale.
///
- public float DpiScale => _root?.RootWindow?.Window.DpiScale ?? Platform.DpiScale;
+ public float DpiScale => RootWindow?.Window.DpiScale ?? Platform.DpiScale;
///
/// Gets screen position of the control (upper left corner).
@@ -456,9 +456,9 @@ namespace FlaxEngine.GUI
#region Focus
///
- /// Gets a value indicating whether the control can receive automatic focus on user events (eg. mouse down.
+ /// Gets a value indicating whether the control can receive automatic focus on user events (eg. mouse down).
///
- [HideInEditor]
+ [HideInEditor, NoSerialize]
public bool AutoFocus
{
get => _autoFocus;
diff --git a/Source/Engine/Utilities/Extensions.cs b/Source/Engine/Utilities/Extensions.cs
index b3f6d2053..3eb31e1d2 100644
--- a/Source/Engine/Utilities/Extensions.cs
+++ b/Source/Engine/Utilities/Extensions.cs
@@ -211,6 +211,17 @@ namespace FlaxEngine.Utilities
/// A thats either true or false.
public static bool NextBool(this Random random, float weight = 0.5f) => random.NextDouble() < weight;
+ ///
+ /// Generates a random value up until an exclusive maximum.
+ ///
+ /// An instance of .
+ /// The maximum value. If it's zero, a maximum of 256 is used
+ /// A random between min and max.
+ public static byte NextByte(this Random random, byte max = 0)
+ {
+ return max == 0 ? (byte)(random.Next() % 256) : (byte)random.Next(max);
+ }
+
///
/// Generates a random value between min and max.
///
@@ -218,9 +229,9 @@ namespace FlaxEngine.Utilities
/// The minimum value.
/// The maximum value.
/// A random between min and max.
- public static byte NextByte(this Random random, byte min = 0, byte max = byte.MaxValue)
+ public static byte NextByte(this Random random, byte min, byte max)
{
- return (byte)random.Next(min, max == byte.MaxValue ? byte.MaxValue + 1 : max);
+ return (byte)random.Next(min, max);
}
///
diff --git a/Source/Platforms/Linux/Binaries/ThirdParty/x64/libcurl.a b/Source/Platforms/Linux/Binaries/ThirdParty/x64/libcurl.a
new file mode 100644
index 000000000..f722e3a16
--- /dev/null
+++ b/Source/Platforms/Linux/Binaries/ThirdParty/x64/libcurl.a
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7b7f66f58d5e7dabe0a0ec7e01ae5dd3683c2ae474ac6dbc133393b2be715bbf
+size 574086
diff --git a/Source/ThirdParty/OpenFBX/ofbx.cpp b/Source/ThirdParty/OpenFBX/ofbx.cpp
index 36f942cf8..94fc6684b 100644
--- a/Source/ThirdParty/OpenFBX/ofbx.cpp
+++ b/Source/ThirdParty/OpenFBX/ofbx.cpp
@@ -3172,6 +3172,8 @@ static bool parseObjects(const Element& root, Scene* scene, u64 flags, Allocator
node->bone_link_property = con.property;
}
break;
+ default:
+ break;
}
switch (parent->getType())
@@ -3190,6 +3192,8 @@ static bool parseObjects(const Element& root, Scene* scene, u64 flags, Allocator
mesh->geometry = (Geometry*)child;
break;
case Object::Type::MATERIAL: mesh->materials.push_back((Material*)child); break;
+ default:
+ break;
}
break;
}
@@ -3323,6 +3327,8 @@ static bool parseObjects(const Element& root, Scene* scene, u64 flags, Allocator
}
break;
}
+ default:
+ break;
}
}
@@ -3350,6 +3356,8 @@ static bool parseObjects(const Element& root, Scene* scene, u64 flags, Allocator
return false;
}
break;
+ default:
+ break;
}
}
}
diff --git a/Source/ThirdParty/curl/curl.Build.cs b/Source/ThirdParty/curl/curl.Build.cs
index 35943d9f1..ac77162a1 100644
--- a/Source/ThirdParty/curl/curl.Build.cs
+++ b/Source/ThirdParty/curl/curl.Build.cs
@@ -38,7 +38,7 @@ public class curl : DepsModule
options.OutputFiles.Add("crypt32.lib");
break;
case TargetPlatform.Linux:
- options.Libraries.Add("curl");
+ options.OutputFiles.Add(Path.Combine(depsRoot, "libcurl.a"));
break;
default: throw new InvalidPlatformException(options.Platform.Target);
}
diff --git a/Source/Tools/Flax.Build/Build/Builder.Projects.cs b/Source/Tools/Flax.Build/Build/Builder.Projects.cs
index 9337881ad..c91fd9f9c 100644
--- a/Source/Tools/Flax.Build/Build/Builder.Projects.cs
+++ b/Source/Tools/Flax.Build/Build/Builder.Projects.cs
@@ -248,7 +248,7 @@ namespace Flax.Build
// Get all modules aggregated into all binary modules used in all configurations of this target
foreach (var configurationData in mainProject.Configurations)
{
- var configurationBinaryModules = GetBinaryModules(rootProject, configurationData.Target, configurationData.Modules);
+ var configurationBinaryModules = GetBinaryModules(projectInfo, configurationData.Target, configurationData.Modules);
foreach (var configurationBinaryModule in configurationBinaryModules)
{
// Skip if none of the included binary modules is inside the project workspace (eg. merged external binary modules from engine to game project)
@@ -274,7 +274,7 @@ namespace Flax.Build
{
var referenceBuildOptions = GetBuildOptions(referenceTarget, configurationData.TargetBuildOptions.Platform, configurationData.TargetBuildOptions.Toolchain, configurationData.Architecture, configurationData.Configuration, reference.Project.ProjectFolderPath);
var referenceModules = CollectModules(rules, referenceBuildOptions.Platform, referenceTarget, referenceBuildOptions, referenceBuildOptions.Toolchain, referenceBuildOptions.Architecture, referenceBuildOptions.Configuration);
- var referenceBinaryModules = GetBinaryModules(rootProject, referenceTarget, referenceModules);
+ var referenceBinaryModules = GetBinaryModules(projectInfo, referenceTarget, referenceModules);
foreach (var binaryModule in referenceBinaryModules)
{
project.Defines.Add(binaryModule.Key.ToUpperInvariant() + "_API=");
diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs b/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs
index 4fdc68067..6461706df 100644
--- a/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs
+++ b/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs
@@ -1,5 +1,6 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
+using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
@@ -25,6 +26,11 @@ namespace Flax.Deps.Dependencies
{
TargetPlatform.Windows,
};
+ case TargetPlatform.Linux:
+ return new[]
+ {
+ TargetPlatform.Linux,
+ };
default: return new TargetPlatform[0];
}
}
@@ -76,7 +82,37 @@ namespace Flax.Deps.Dependencies
foreach (var filename in binariesToCopyWin)
Utilities.FileCopy(Path.Combine(root, "build", "Win64", vcVersion, configuration, filename), Path.Combine(depsFolder, Path.GetFileName(filename)));
}
-
+ break;
+ }
+ case TargetPlatform.Linux:
+ {
+ // Build for Linux
+ var settings = new []
+ {
+ "-without-librtmp",
+ "--without-ssl",
+ "--with-gnutls",
+ "--disable-ipv6",
+ "--disable-manual",
+ "--disable-verbose",
+ "--disable-shared",
+ "--enable-static",
+ "-disable-ldap --disable-sspi --disable-ftp --disable-file --disable-dict --disable-telnet --disable-tftp --disable-rtsp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-smb",
+ };
+ var envVars = new Dictionary
+ {
+ { "CC", "clang-7" },
+ { "CC_FOR_BUILD", "clang-7" }
+ };
+ var buildDir = Path.Combine(root, "build");
+ SetupDirectory(buildDir, true);
+ Utilities.Run("chmod", "+x configure", null, root, Utilities.RunOptions.None);
+ Utilities.Run(Path.Combine(root, "configure"), string.Join(" ", settings) + " --prefix=\"" + buildDir + "\"", null, root, Utilities.RunOptions.None, envVars);
+ Utilities.Run("make", null, null, root, Utilities.RunOptions.None);
+ Utilities.Run("make", "install", null, root, Utilities.RunOptions.None);
+ var depsFolder = GetThirdPartyFolder(options, TargetPlatform.Linux, TargetArchitecture.x64);
+ var filename = "libcurl.a";
+ Utilities.FileCopy(Path.Combine(buildDir, "lib", filename), Path.Combine(depsFolder, filename));
break;
}
}
diff --git a/Source/flax.natvis b/Source/flax.natvis
index 550d8a4d4..774badad3 100644
--- a/Source/flax.natvis
+++ b/Source/flax.natvis
@@ -143,9 +143,9 @@
- {_data_allocation.._data,su}
+ {_data._allocation._data,su}
- - _data._data
+ - _data._allocation._data
- _data._count
_data._count