Add utility ctors to Half vectors
This commit is contained in:
@@ -12,9 +12,9 @@ static_assert(sizeof(Half2) == 4, "Invalid Half2 type size.");
|
|||||||
static_assert(sizeof(Half3) == 6, "Invalid Half3 type size.");
|
static_assert(sizeof(Half3) == 6, "Invalid Half3 type size.");
|
||||||
static_assert(sizeof(Half4) == 8, "Invalid Half4 type size.");
|
static_assert(sizeof(Half4) == 8, "Invalid Half4 type size.");
|
||||||
|
|
||||||
Half2 Half2::Zero(0, 0);
|
Half2 Half2::Zero(0.0f, 0.0f);
|
||||||
Half3 Half3::Zero(0, 0, 0);
|
Half3 Half3::Zero(0.0f, 0.0f, 0.0f);
|
||||||
Half4 Half4::Zero(0, 0, 0, 0);
|
Half4 Half4::Zero(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
Half2::Half2(const Vector2& v)
|
Half2::Half2(const Vector2& v)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ class FLAXENGINE_API Float16Compressor
|
|||||||
static const int32 minD = minC - subC - 1;
|
static const int32 minD = minC - subC - 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static Half Compress(const float value)
|
static Half Compress(const float value)
|
||||||
{
|
{
|
||||||
#if USE_SSE_HALF_CONVERSION
|
#if USE_SSE_HALF_CONVERSION
|
||||||
@@ -102,14 +101,12 @@ public:
|
|||||||
struct FLAXENGINE_API Half2
|
struct FLAXENGINE_API Half2
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Zero vector
|
/// Zero vector
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static Half2 Zero;
|
static Half2 Zero;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the X component of the vector.
|
/// Gets or sets the X component of the vector.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -121,7 +118,6 @@ public:
|
|||||||
Half Y;
|
Half Y;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default constructor
|
/// Default constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -129,6 +125,17 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Init
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x">X component</param>
|
||||||
|
/// <param name="y">Y component</param>
|
||||||
|
Half2(Half x, Half y)
|
||||||
|
: X(x)
|
||||||
|
, Y(y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Init
|
/// Init
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -147,7 +154,6 @@ public:
|
|||||||
Half2(const Vector2& v);
|
Half2(const Vector2& v);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert to Vector2
|
/// Convert to Vector2
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -161,14 +167,12 @@ public:
|
|||||||
struct FLAXENGINE_API Half3
|
struct FLAXENGINE_API Half3
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Zero vector
|
/// Zero vector
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static Half3 Zero;
|
static Half3 Zero;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the X component of the vector.
|
/// Gets or sets the X component of the vector.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -185,11 +189,17 @@ public:
|
|||||||
Half Z;
|
Half Z;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Half3()
|
Half3()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Half3(Half x, Half y, Half z)
|
||||||
|
: X(x)
|
||||||
|
, Y(y)
|
||||||
|
, Z(z)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Half3(const float x, const float y, const float z)
|
Half3(const float x, const float y, const float z)
|
||||||
{
|
{
|
||||||
X = Float16Compressor::Compress(x);
|
X = Float16Compressor::Compress(x);
|
||||||
@@ -200,7 +210,6 @@ public:
|
|||||||
Half3(const Vector3& v);
|
Half3(const Vector3& v);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Vector3 ToVector3() const;
|
Vector3 ToVector3() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -210,14 +219,12 @@ public:
|
|||||||
struct FLAXENGINE_API Half4
|
struct FLAXENGINE_API Half4
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Zero vector
|
/// Zero vector
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static Half4 Zero;
|
static Half4 Zero;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the X component of the vector.
|
/// Gets or sets the X component of the vector.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -239,11 +246,18 @@ public:
|
|||||||
Half W;
|
Half W;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Half4()
|
Half4()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Half4(Half x, Half y, Half z, Half w)
|
||||||
|
: X(x)
|
||||||
|
, Y(y)
|
||||||
|
, Z(z)
|
||||||
|
, W(w)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Half4(const float x, const float y, const float z)
|
Half4(const float x, const float y, const float z)
|
||||||
{
|
{
|
||||||
X = Float16Compressor::Compress(x);
|
X = Float16Compressor::Compress(x);
|
||||||
@@ -265,7 +279,6 @@ public:
|
|||||||
explicit Half4(const Rectangle& rect);
|
explicit Half4(const Rectangle& rect);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Vector2 ToVector2() const;
|
Vector2 ToVector2() const;
|
||||||
Vector3 ToVector3() const;
|
Vector3 ToVector3() const;
|
||||||
Vector4 ToVector4() const;
|
Vector4 ToVector4() const;
|
||||||
|
|||||||
@@ -89,12 +89,12 @@ namespace
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto v = Half2(0, 0);
|
auto v = Half2::Zero;
|
||||||
for (uint32 i = 0; i < vertexCount; i++)
|
for (uint32 i = 0; i < vertexCount; i++)
|
||||||
vb1[i].TexCoord = v;
|
vb1[i].TexCoord = v;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto v = Half2(0, 0);
|
auto v = Half2::Zero;
|
||||||
for (uint32 i = 0; i < vertexCount; i++)
|
for (uint32 i = 0; i < vertexCount; i++)
|
||||||
vb1[i].LightmapUVs = v;
|
vb1[i].LightmapUVs = v;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ bool UpdateMesh(SkinnedMesh* mesh, MonoArray* verticesObj, MonoArray* trianglesO
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto v = Half2(0, 0);
|
auto v = Half2::Zero;
|
||||||
for (uint32 i = 0; i < vertexCount; i++)
|
for (uint32 i = 0; i < vertexCount; i++)
|
||||||
vb[i].TexCoord = v;
|
vb[i].TexCoord = v;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user