Add support for Large Worlds in more engine systems

This commit is contained in:
Wojtek Figat
2022-07-02 20:07:04 +02:00
parent 85fe22d7a7
commit 33513834df
18 changed files with 398 additions and 188 deletions

View File

@@ -151,6 +151,16 @@ namespace FlaxEngine
corners.AddRange(GetCorners());
}
/// <summary>
/// Transforms this box using a transformation.
/// </summary>
/// <param name="transform">The transformation.</param>
/// <remarks>While any kind of transformation can be applied, it is recommended to apply scaling using scale method instead, which scales the Extents and keeps the Transformation for rotation only, and that preserves collision detection accuracy.</remarks>
public void Transform(ref Transform transform)
{
Transformation = transform.LocalToWorld(Transformation);
}
/// <summary>
/// Transforms this box using a transformation matrix.
/// </summary>
@@ -425,6 +435,20 @@ namespace FlaxEngine
return result;
}
/// <summary>
/// Transforms bounding box using the given transformation.
/// </summary>
/// <param name="box">The bounding box to transform.</param>
/// <param name="transform">The transformation.</param>
/// <returns>The result of the transformation.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static OrientedBoundingBox operator *(OrientedBoundingBox box, Transform transform)
{
OrientedBoundingBox result = box;
result.Transformation = transform.LocalToWorld(result.Transformation);
return result;
}
/// <summary>
/// Tests for equality between two objects.
/// </summary>

View File

@@ -7,6 +7,7 @@
#include "Quaternion.h"
#include "Matrix.h"
#include "Matrix3x3.h"
#include "Transform.h"
#include "../Types/String.h"
// Float
@@ -214,6 +215,14 @@ Float3 Float3::Transform(const Float3& vector, const Matrix& transform)
vector.X * transform.M13 + vector.Y * transform.M23 + vector.Z * transform.M33 + transform.M43);
}
template<>
Float3 Float3::Transform(const Float3& vector, const ::Transform& transform)
{
Vector3 result;
transform.LocalToWorld(vector, result);
return result;
}
template<>
void Float3::TransformCoordinate(const Float3& coordinate, const Matrix& transform, Float3& result)
{
@@ -508,6 +517,14 @@ Double3 Double3::Transform(const Double3& vector, const Matrix& transform)
vector.X * transform.M13 + vector.Y * transform.M23 + vector.Z * transform.M33 + transform.M43);
}
template<>
Double3 Double3::Transform(const Double3& vector, const ::Transform& transform)
{
Vector3 result;
transform.LocalToWorld(vector, result);
return result;
}
template<>
void Double3::TransformCoordinate(const Double3& coordinate, const Matrix& transform, Double3& result)
{
@@ -748,6 +765,12 @@ Int3 Int3::Transform(const Int3& vector, const Matrix& transform)
return vector;
}
template<>
Int3 Int3::Transform(const Int3& vector, const ::Transform& transform)
{
return vector;
}
template<>
void Int3::TransformCoordinate(const Int3& coordinate, const Matrix& transform, Int3& result)
{

View File

@@ -1432,6 +1432,17 @@ namespace FlaxEngine
vector.X * transform.M14 + vector.Y * transform.M24 + vector.Z * transform.M34 + transform.M44);
}
/// <summary>
/// Transforms a 3D vector by the given <see cref="FlaxEngine.Transform" />.
/// </summary>
/// <param name="vector">The source vector.</param>
/// <param name="transform">The transformation <see cref="FlaxEngine.Transform" />.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Vector3" />.</param>
public static void Transform(ref Vector3 vector, ref Transform transform, out Vector3 result)
{
transform.LocalToWorld(ref vector, out result);
}
/// <summary>
/// Transforms a 3D vector by the given <see cref="Matrix" />.
/// </summary>
@@ -1444,6 +1455,18 @@ namespace FlaxEngine
return result;
}
/// <summary>
/// Transforms a 3D vector by the given <see cref="FlaxEngine.Transform" />.
/// </summary>
/// <param name="vector">The source vector.</param>
/// <param name="transform">The transformation <see cref="FlaxEngine.Transform" />.</param>
/// <returns>The transformed <see cref="Vector4" />.</returns>
public static Vector3 Transform(Vector3 vector, Transform transform)
{
Transform(ref vector, ref transform, out Vector3 result);
return result;
}
/// <summary>
/// Performs a coordinate transformation using the given <see cref="Matrix" />.
/// </summary>

View File

@@ -712,12 +712,24 @@ public:
// @param result When the method completes, contains the transformed Vector3
static FLAXENGINE_API void Transform(const Vector3Base& vector, const Matrix3x3& transform, Vector3Base& result);
// Transforms a 3D vector by the given transformation
// @param vector The source vector
// @param transform The transformation
// @param result When the method completes, contains the transformed Vector3
static FLAXENGINE_API void Transform(const Vector3Base& vector, const ::Transform& transform, Vector3Base& result);
// Transforms a 3D vector by the given matrix
// @param vector The source vector
// @param transform The transformation matrix
// @returns Transformed Vector3
static FLAXENGINE_API Vector3Base Transform(const Vector3Base& vector, const Matrix& transform);
// Transforms a 3D vector by the given transformation
// @param vector The source vector
// @param transform The transformation
// @returns Transformed Vector3
static FLAXENGINE_API Vector3Base Transform(const Vector3Base& vector, const ::Transform& transform);
// Transforms a 3D vector by the given matrix
// @param vector The source vector
// @param transform The transformation matrix