Merge remote-tracking branch 'origin/master' into 1.9
# Conflicts: # Source/Editor/Modules/ContentDatabaseModule.cs # Source/Editor/Surface/SurfaceUtils.cs # Source/Editor/Windows/Assets/MaterialInstanceWindow.cs # Source/Engine/Foliage/Foliage.cpp # Source/Engine/Graphics/Models/MeshBase.h # Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Textures.cpp
This commit is contained in:
@@ -237,7 +237,10 @@ Ray Camera::ConvertMouseToRay(const Float2& mousePosition, const Viewport& viewp
|
||||
viewport.Unproject(nearPoint, ivp, nearPoint);
|
||||
viewport.Unproject(farPoint, ivp, farPoint);
|
||||
|
||||
return Ray(nearPoint, Vector3::Normalize(farPoint - nearPoint));
|
||||
Vector3 dir = Vector3::Normalize(farPoint - nearPoint);
|
||||
if (dir.IsZero())
|
||||
return Ray::Identity;
|
||||
return Ray(nearPoint, dir);
|
||||
}
|
||||
|
||||
Viewport Camera::GetViewport() const
|
||||
@@ -303,6 +306,8 @@ void Camera::GetMatrices(Matrix& view, Matrix& projection, const Viewport& viewp
|
||||
void Camera::OnPreviewModelLoaded()
|
||||
{
|
||||
_previewModelBuffer.Setup(_previewModel.Get());
|
||||
if (_previewModelBuffer.Count() > 0)
|
||||
_previewModelBuffer.At(0).ReceiveDecals = false;
|
||||
|
||||
UpdateCache();
|
||||
}
|
||||
|
||||
@@ -150,35 +150,30 @@ float Spline::GetSplineLength() const
|
||||
{
|
||||
float sum = 0.0f;
|
||||
constexpr int32 slices = 20;
|
||||
constexpr float step = 1.0f / (float)slices;
|
||||
Vector3 prevPoint = Vector3::Zero;
|
||||
if (Curve.GetKeyframes().Count() != 0)
|
||||
{
|
||||
const auto& a = Curve[0];
|
||||
prevPoint = a.Value.Translation * _transform.Scale;
|
||||
}
|
||||
constexpr float step = 1.0f / (float)(slices - 1);
|
||||
const Vector3 scale = _transform.Scale;
|
||||
for (int32 i = 1; i < Curve.GetKeyframes().Count(); i++)
|
||||
{
|
||||
const auto& a = Curve[i - 1];
|
||||
const auto& b = Curve[i];
|
||||
Vector3 prevPoint = a.Value.Translation * scale;
|
||||
|
||||
const float length = Math::Abs(b.Time - a.Time);
|
||||
Vector3 leftTangent, rightTangent;
|
||||
AnimationUtils::GetTangent(a.Value.Translation, a.TangentOut.Translation, length, leftTangent);
|
||||
AnimationUtils::GetTangent(b.Value.Translation, b.TangentIn.Translation, length, rightTangent);
|
||||
|
||||
// TODO: implement sth more analytical than brute-force solution
|
||||
for (int32 slice = 0; slice < slices; slice++)
|
||||
for (int32 slice = 1; slice < slices; slice++)
|
||||
{
|
||||
const float t = (float)slice * step;
|
||||
Vector3 pos;
|
||||
AnimationUtils::Bezier(a.Value.Translation, leftTangent, rightTangent, b.Value.Translation, t, pos);
|
||||
pos *= _transform.Scale;
|
||||
sum += (float)Vector3::DistanceSquared(pos, prevPoint);
|
||||
pos *= scale;
|
||||
sum += (float)Vector3::Distance(pos, prevPoint);
|
||||
prevPoint = pos;
|
||||
}
|
||||
}
|
||||
return Math::Sqrt(sum);
|
||||
return sum;
|
||||
}
|
||||
|
||||
float Spline::GetSplineSegmentLength(int32 index) const
|
||||
@@ -188,28 +183,28 @@ float Spline::GetSplineSegmentLength(int32 index) const
|
||||
CHECK_RETURN(index > 0 && index < GetSplinePointsCount(), 0.0f);
|
||||
float sum = 0.0f;
|
||||
constexpr int32 slices = 20;
|
||||
constexpr float step = 1.0f / (float)slices;
|
||||
constexpr float step = 1.0f / (float)(slices - 1);
|
||||
const auto& a = Curve[index - 1];
|
||||
const auto& b = Curve[index];
|
||||
Vector3 startPoint = a.Value.Translation * _transform.Scale;
|
||||
const Vector3 scale = _transform.Scale;
|
||||
Vector3 prevPoint = a.Value.Translation * scale;
|
||||
{
|
||||
const float length = Math::Abs(b.Time - a.Time);
|
||||
Vector3 leftTangent, rightTangent;
|
||||
AnimationUtils::GetTangent(a.Value.Translation, a.TangentOut.Translation, length, leftTangent);
|
||||
AnimationUtils::GetTangent(b.Value.Translation, b.TangentIn.Translation, length, rightTangent);
|
||||
|
||||
// TODO: implement sth more analytical than brute-force solution
|
||||
for (int32 slice = 0; slice < slices; slice++)
|
||||
for (int32 slice = 1; slice < slices; slice++)
|
||||
{
|
||||
const float t = (float)slice * step;
|
||||
Vector3 pos;
|
||||
AnimationUtils::Bezier(a.Value.Translation, leftTangent, rightTangent, b.Value.Translation, t, pos);
|
||||
pos *= _transform.Scale;
|
||||
sum += (float)Vector3::DistanceSquared(pos, startPoint);
|
||||
startPoint = pos;
|
||||
pos *= scale;
|
||||
sum += (float)Vector3::Distance(pos, prevPoint);
|
||||
prevPoint = pos;
|
||||
}
|
||||
}
|
||||
return Math::Sqrt(sum);
|
||||
return sum;
|
||||
}
|
||||
|
||||
float Spline::GetSplineTime(int32 index) const
|
||||
|
||||
@@ -357,6 +357,10 @@ void StaticModel::Draw(RenderContext& renderContext)
|
||||
draw.ForcedLOD = _forcedLod;
|
||||
draw.SortOrder = _sortOrder;
|
||||
draw.VertexColors = _vertexColorsCount ? _vertexColorsBuffer : nullptr;
|
||||
#if USE_EDITOR
|
||||
if (HasStaticFlag(StaticFlags::Lightmap))
|
||||
draw.LightmapScale = _scaleInLightmap;
|
||||
#endif
|
||||
|
||||
Model->Draw(renderContext, draw);
|
||||
|
||||
@@ -391,6 +395,10 @@ void StaticModel::Draw(RenderContextBatch& renderContextBatch)
|
||||
draw.ForcedLOD = _forcedLod;
|
||||
draw.SortOrder = _sortOrder;
|
||||
draw.VertexColors = _vertexColorsCount ? _vertexColorsBuffer : nullptr;
|
||||
#if USE_EDITOR
|
||||
if (HasStaticFlag(StaticFlags::Lightmap))
|
||||
draw.LightmapScale = _scaleInLightmap;
|
||||
#endif
|
||||
|
||||
Model->Draw(renderContextBatch, draw);
|
||||
|
||||
|
||||
@@ -7,9 +7,7 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace FlaxEngine
|
||||
{
|
||||
#if FLAX_EDITOR
|
||||
[TypeConverter(typeof(TypeConverters.TagConverter))]
|
||||
#endif
|
||||
partial struct Tag : IEquatable<Tag>, IEquatable<string>, IComparable, IComparable<Tag>, IComparable<string>
|
||||
{
|
||||
/// <summary>
|
||||
@@ -254,7 +252,6 @@ namespace FlaxEngine
|
||||
}
|
||||
}
|
||||
|
||||
#if FLAX_EDITOR
|
||||
namespace FlaxEngine.TypeConverters
|
||||
{
|
||||
internal class TagConverter : TypeConverter
|
||||
@@ -291,4 +288,3 @@ namespace FlaxEngine.TypeConverters
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user