Merge branch 'master' into AnimationSampleNode-AnimationAssetReferencePort
This commit is contained in:
@@ -171,6 +171,8 @@ int32 FindVertex(const MeshData& mesh, int32 vertexIndex, int32 startIndex, int3
|
||||
const Float3 vNormal = mesh.Normals.HasItems() ? mesh.Normals[vertexIndex] : Float3::Zero;
|
||||
const Float3 vTangent = mesh.Tangents.HasItems() ? mesh.Tangents[vertexIndex] : Float3::Zero;
|
||||
const Float2 vLightmapUV = mesh.LightmapUVs.HasItems() ? mesh.LightmapUVs[vertexIndex] : Float2::Zero;
|
||||
const Color vColor = mesh.Colors.HasItems() ? mesh.Colors[vertexIndex] : Color::Black; // Assuming Color::Black as a default color
|
||||
|
||||
const int32 end = startIndex + searchRange;
|
||||
|
||||
for (size_t i = 0; i < sparialSortCache.size(); i++)
|
||||
@@ -184,6 +186,8 @@ int32 FindVertex(const MeshData& mesh, int32 vertexIndex, int32 startIndex, int3
|
||||
const Float3 vNormal = mesh.Normals.HasItems() ? mesh.Normals[vertexIndex] : Float3::Zero;
|
||||
const Float3 vTangent = mesh.Tangents.HasItems() ? mesh.Tangents[vertexIndex] : Float3::Zero;
|
||||
const Float2 vLightmapUV = mesh.LightmapUVs.HasItems() ? mesh.LightmapUVs[vertexIndex] : Float2::Zero;
|
||||
const Color vColor = mesh.Colors.HasItems() ? mesh.Colors[vertexIndex] : Color::Black; // Assuming Color::Black as a default color
|
||||
|
||||
const int32 end = startIndex + searchRange;
|
||||
|
||||
for (int32 v = startIndex; v < end; v++)
|
||||
@@ -201,6 +205,8 @@ int32 FindVertex(const MeshData& mesh, int32 vertexIndex, int32 startIndex, int3
|
||||
continue;
|
||||
if (mesh.LightmapUVs.HasItems() && (vLightmapUV - mesh.LightmapUVs[v]).LengthSquared() > uvEpsSqr)
|
||||
continue;
|
||||
if (mesh.Colors.HasItems() && vColor != mesh.Colors[v])
|
||||
continue;
|
||||
// TODO: check more components?
|
||||
|
||||
return v;
|
||||
|
||||
@@ -39,5 +39,19 @@ namespace FlaxEngine
|
||||
View = view;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The rendering mask for layers. Used to exclude objects from rendering (via <see cref="View"/> property).
|
||||
/// </summary>
|
||||
public LayersMask ViewLayersMask
|
||||
{
|
||||
get => View.RenderLayersMask;
|
||||
set
|
||||
{
|
||||
var view = View;
|
||||
view.RenderLayersMask = value;
|
||||
View = view;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ void RenderView::SetProjector(float nearPlane, float farPlane, const Float3& pos
|
||||
CullingFrustum = Frustum;
|
||||
}
|
||||
|
||||
void RenderView::CopyFrom(Camera* camera, Viewport* viewport)
|
||||
void RenderView::CopyFrom(const Camera* camera, const Viewport* viewport)
|
||||
{
|
||||
const Vector3 cameraPos = camera->GetPosition();
|
||||
LargeWorlds::UpdateOrigin(Origin, cameraPos);
|
||||
@@ -192,6 +192,8 @@ void RenderView::CopyFrom(Camera* camera, Viewport* viewport)
|
||||
Frustum.GetInvMatrix(IVP);
|
||||
CullingFrustum = Frustum;
|
||||
RenderLayersMask = camera->RenderLayersMask;
|
||||
Flags = camera->RenderFlags;
|
||||
Mode = camera->RenderMode;
|
||||
}
|
||||
|
||||
void RenderView::GetWorldMatrix(const Transform& transform, Matrix& world) const
|
||||
|
||||
@@ -102,6 +102,8 @@ namespace FlaxEngine
|
||||
NonJitteredProjection = Projection;
|
||||
TemporalAAJitter = Float4.Zero;
|
||||
RenderLayersMask = camera.RenderLayersMask;
|
||||
Flags = camera.RenderFlags;
|
||||
Mode = camera.RenderMode;
|
||||
|
||||
UpdateCachedData();
|
||||
}
|
||||
|
||||
@@ -295,10 +295,12 @@ public:
|
||||
/// <param name="angle">Camera's FOV angle (in degrees)</param>
|
||||
void SetProjector(float nearPlane, float farPlane, const Float3& position, const Float3& direction, const Float3& up, float angle);
|
||||
|
||||
// Copy view data from camera
|
||||
// @param camera Camera to copy its data
|
||||
// @param camera The custom viewport to use for view/projection matrices override.
|
||||
void CopyFrom(Camera* camera, Viewport* viewport = nullptr);
|
||||
/// <summary>
|
||||
/// Copies view data from camera to the view.
|
||||
/// </summary>
|
||||
/// <param name="camera">The camera to copy its data.</param>
|
||||
/// <param name="viewport">The custom viewport to use for view/projection matrices override.</param>
|
||||
void CopyFrom(const Camera* camera, const Viewport* viewport = nullptr);
|
||||
|
||||
public:
|
||||
FORCE_INLINE DrawPass GetShadowsDrawPassMask(ShadowsCastingMode shadowsMode) const
|
||||
|
||||
@@ -415,6 +415,8 @@ void Camera::Serialize(SerializeStream& stream, const void* otherObj)
|
||||
SERIALIZE_MEMBER(Far, _far);
|
||||
SERIALIZE_MEMBER(OrthoScale, _orthoScale);
|
||||
SERIALIZE(RenderLayersMask);
|
||||
SERIALIZE(RenderFlags);
|
||||
SERIALIZE(RenderMode);
|
||||
}
|
||||
|
||||
void Camera::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
|
||||
@@ -429,6 +431,8 @@ void Camera::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier
|
||||
DESERIALIZE_MEMBER(Far, _far);
|
||||
DESERIALIZE_MEMBER(OrthoScale, _orthoScale);
|
||||
DESERIALIZE(RenderLayersMask);
|
||||
DESERIALIZE(RenderFlags);
|
||||
DESERIALIZE(RenderMode);
|
||||
}
|
||||
|
||||
void Camera::OnEnable()
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "Engine/Core/Math/Viewport.h"
|
||||
#include "Engine/Core/Math/Ray.h"
|
||||
#include "Engine/Core/Types/LayersMask.h"
|
||||
#include "Engine/Graphics/Enums.h"
|
||||
#include "Engine/Scripting/ScriptingObjectReference.h"
|
||||
#if USE_EDITOR
|
||||
#include "Engine/Content/AssetReference.h"
|
||||
@@ -134,6 +135,18 @@ public:
|
||||
API_FIELD(Attributes="EditorOrder(100), EditorDisplay(\"Camera\")")
|
||||
LayersMask RenderLayersMask;
|
||||
|
||||
/// <summary>
|
||||
/// Frame rendering flags used to switch between graphics features for this camera.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes = "EditorOrder(110), EditorDisplay(\"Camera\")")
|
||||
ViewFlags RenderFlags = ViewFlags::DefaultGame;
|
||||
|
||||
/// <summary>
|
||||
/// Describes frame rendering modes for this camera.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes = "EditorOrder(120), EditorDisplay(\"Camera\")")
|
||||
ViewMode RenderMode = ViewMode::Default;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Projects the point from 3D world-space to game window coordinates (in screen pixels for default viewport calculated from <see cref="Viewport"/>).
|
||||
|
||||
@@ -79,6 +79,7 @@ public:
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
};
|
||||
#endif
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
@@ -127,7 +128,6 @@ public:
|
||||
{
|
||||
return (input[2] << 24) | (input[1] << 16) | (input[0] << 8);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -314,6 +314,28 @@ namespace FlaxEngine.GUI
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseDoubleClick(location, button))
|
||||
return true;
|
||||
|
||||
if (button == MouseButton.Left && _isPressed)
|
||||
{
|
||||
OnPressEnd();
|
||||
OnClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (button == MouseButton.Left && !_isPressed)
|
||||
{
|
||||
OnPressBegin();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnTouchDown(Float2 location, int pointerId)
|
||||
{
|
||||
|
||||
@@ -277,6 +277,27 @@ namespace FlaxEngine.GUI
|
||||
return base.OnMouseDown(location, button);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
|
||||
{
|
||||
if (button == MouseButton.Left && !_isPressed)
|
||||
{
|
||||
OnPressBegin();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (button == MouseButton.Left && _isPressed)
|
||||
{
|
||||
OnPressEnd();
|
||||
if (_box.Contains(ref location))
|
||||
{
|
||||
OnClick();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return base.OnMouseDoubleClick(location, button);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseUp(Float2 location, MouseButton button)
|
||||
{
|
||||
|
||||
@@ -666,6 +666,30 @@ namespace FlaxEngine.GUI
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseDoubleClick(location, button))
|
||||
return true;
|
||||
|
||||
if (_touchDown && button == MouseButton.Left)
|
||||
{
|
||||
_touchDown = false;
|
||||
ShowPopup();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (button == MouseButton.Left)
|
||||
{
|
||||
_touchDown = true;
|
||||
if (!IsPopupOpened)
|
||||
Focus();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnTouchDown(Float2 location, int pointerId)
|
||||
{
|
||||
|
||||
@@ -501,6 +501,29 @@ namespace FlaxEngine.GUI
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseDoubleClick(location, button))
|
||||
return true;
|
||||
|
||||
_mouseOverHeader = HeaderRectangle.Contains(location);
|
||||
if (button == MouseButton.Left && _mouseOverHeader)
|
||||
{
|
||||
_mouseButtonLeftDown = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (button == MouseButton.Left && _mouseButtonLeftDown)
|
||||
{
|
||||
_mouseButtonLeftDown = false;
|
||||
if (_mouseOverHeader)
|
||||
Toggle();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseLeave()
|
||||
{
|
||||
|
||||
@@ -23,9 +23,9 @@ namespace FlaxEngine.GUI
|
||||
|
||||
// Scrolling
|
||||
|
||||
private float _clickChange = 20, _scrollChange = 100;
|
||||
private float _clickChange = 20, _scrollChange = 50;
|
||||
private float _minimum, _maximum = 100;
|
||||
private float _value, _targetValue;
|
||||
private float _startValue, _value, _targetValue;
|
||||
private readonly Orientation _orientation;
|
||||
private RootControl.UpdateDelegate _update;
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace FlaxEngine.GUI
|
||||
// Smoothing
|
||||
|
||||
private float _thumbOpacity = DefaultMinimumOpacity;
|
||||
private float _scrollAnimationProgress = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the orientation.
|
||||
@@ -59,14 +60,19 @@ namespace FlaxEngine.GUI
|
||||
public float TrackThickness { get; set; } = 2.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value smoothing scale (0 to not use it).
|
||||
/// The maximum time it takes to animate from current to target scroll position
|
||||
/// </summary>
|
||||
public float SmoothingScale { get; set; } = 0.6f;
|
||||
public float ScrollAnimationDuration { get; set; } = 0.18f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether use scroll value smoothing.
|
||||
/// </summary>
|
||||
public bool UseSmoothing => !Mathf.IsZero(SmoothingScale);
|
||||
public bool UseSmoothing => EnableSmoothing && !Mathf.IsZero(ScrollAnimationDuration);
|
||||
|
||||
/// <summary>
|
||||
/// Enables scroll smoothing
|
||||
/// </summary>
|
||||
public bool EnableSmoothing { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum value.
|
||||
@@ -112,11 +118,15 @@ namespace FlaxEngine.GUI
|
||||
if (!Mathf.NearEqual(value, _targetValue))
|
||||
{
|
||||
_targetValue = value;
|
||||
_startValue = _value;
|
||||
_scrollAnimationProgress = 0f;
|
||||
|
||||
// Check if skip smoothing
|
||||
if (!UseSmoothing)
|
||||
{
|
||||
_value = value;
|
||||
_startValue = value;
|
||||
_scrollAnimationProgress = 1f;
|
||||
OnValueChanged();
|
||||
}
|
||||
else
|
||||
@@ -208,7 +218,8 @@ namespace FlaxEngine.GUI
|
||||
{
|
||||
if (!Mathf.NearEqual(_value, _targetValue))
|
||||
{
|
||||
_value = _targetValue;
|
||||
_value = _targetValue = _startValue;
|
||||
_scrollAnimationProgress = 0f;
|
||||
SetUpdate(ref _update, null);
|
||||
OnValueChanged();
|
||||
}
|
||||
@@ -274,7 +285,8 @@ namespace FlaxEngine.GUI
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
_value = _targetValue = 0;
|
||||
_value = _targetValue = _startValue = 0;
|
||||
_scrollAnimationProgress = 0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -296,22 +308,39 @@ namespace FlaxEngine.GUI
|
||||
_thumbOpacity = isDeltaSlow ? targetOpacity : Mathf.Lerp(_thumbOpacity, targetOpacity, deltaTime * 10.0f);
|
||||
bool needUpdate = Mathf.Abs(_thumbOpacity - targetOpacity) > 0.001f;
|
||||
|
||||
// Ensure scroll bar is visible
|
||||
if (Visible)
|
||||
// Ensure scroll bar is visible and smoothing is required
|
||||
if (Visible && Mathf.Abs(_targetValue - _value) > 0.01f)
|
||||
{
|
||||
// Value smoothing
|
||||
if (Mathf.Abs(_targetValue - _value) > 0.01f)
|
||||
// Interpolate or not if running slow
|
||||
float value;
|
||||
if (!isDeltaSlow && UseSmoothing)
|
||||
{
|
||||
// Interpolate or not if running slow
|
||||
float value;
|
||||
if (!isDeltaSlow && UseSmoothing)
|
||||
value = Mathf.Lerp(_value, _targetValue, deltaTime * 20.0f * SmoothingScale);
|
||||
else
|
||||
value = _targetValue;
|
||||
_value = value;
|
||||
OnValueChanged();
|
||||
needUpdate = true;
|
||||
// percentage of scroll from 0 to _scrollChange, ex. 0.5 at _scrollChange / 2
|
||||
var minScrollChangeRatio = Mathf.Clamp(Mathf.Abs(_targetValue - _startValue) / _scrollChange, 0, 1);
|
||||
|
||||
// shorten the duration if we scrolled less than _scrollChange
|
||||
var actualDuration = ScrollAnimationDuration * minScrollChangeRatio;
|
||||
var step = deltaTime / actualDuration;
|
||||
|
||||
var progress = _scrollAnimationProgress;
|
||||
progress = Mathf.Clamp(progress + step, 0, 1);
|
||||
|
||||
// https://easings.net/#easeOutSine
|
||||
var easedProgress = Mathf.Sin((progress * Mathf.Pi) / 2);
|
||||
value = Mathf.Lerp(_startValue, _targetValue, easedProgress);
|
||||
|
||||
_scrollAnimationProgress = progress;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = _targetValue;
|
||||
_startValue = _targetValue;
|
||||
_scrollAnimationProgress = 0f;
|
||||
}
|
||||
|
||||
_value = value;
|
||||
OnValueChanged();
|
||||
needUpdate = true;
|
||||
}
|
||||
|
||||
// End updating if all animations are done
|
||||
@@ -371,7 +400,7 @@ namespace FlaxEngine.GUI
|
||||
float mousePosition = _orientation == Orientation.Vertical ? slidePosition.Y : slidePosition.X;
|
||||
|
||||
float percentage = (mousePosition - _mouseOffset - _thumbSize / 2) / (TrackSize - _thumbSize);
|
||||
Value = _minimum + percentage * (_maximum - _minimum);
|
||||
TargetValue = _minimum + percentage * (_maximum - _minimum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,7 +410,7 @@ namespace FlaxEngine.GUI
|
||||
if (ThumbEnabled)
|
||||
{
|
||||
// Scroll
|
||||
Value = _value - delta * _scrollChange;
|
||||
Value = _targetValue - delta * _scrollChange;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user