|
@@ -31,15 +31,15 @@
|
|
|
#include "Header.h"
|
|
#include "Header.h"
|
|
|
#include "Types.h"
|
|
#include "Types.h"
|
|
|
#include "Property.h"
|
|
#include "Property.h"
|
|
|
-#include <variant>
|
|
|
|
|
#include <array>
|
|
#include <array>
|
|
|
|
|
|
|
|
|
|
+
|
|
|
namespace Rocket {
|
|
namespace Rocket {
|
|
|
namespace Core {
|
|
namespace Core {
|
|
|
namespace Transforms {
|
|
namespace Transforms {
|
|
|
|
|
|
|
|
|
|
|
|
|
-struct NumericValue
|
|
|
|
|
|
|
+struct ROCKETCORE_API NumericValue
|
|
|
{
|
|
{
|
|
|
/// Non-initializing constructor.
|
|
/// Non-initializing constructor.
|
|
|
NumericValue() noexcept;
|
|
NumericValue() noexcept;
|
|
@@ -91,8 +91,6 @@ struct ResolvedPrimitive
|
|
|
ResolvedPrimitive(std::array<float, N> values) noexcept : values(values) { }
|
|
ResolvedPrimitive(std::array<float, N> values) noexcept : values(values) { }
|
|
|
|
|
|
|
|
std::array<float, N> values;
|
|
std::array<float, N> values;
|
|
|
-
|
|
|
|
|
- String ToString(String unit, bool rad_to_deg = false, bool only_unit_on_last_value = false) const noexcept;
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
template< size_t N >
|
|
template< size_t N >
|
|
@@ -106,162 +104,139 @@ struct UnresolvedPrimitive
|
|
|
UnresolvedPrimitive(std::array<NumericValue, N> values) noexcept : values(values) { }
|
|
UnresolvedPrimitive(std::array<NumericValue, N> values) noexcept : values(values) { }
|
|
|
|
|
|
|
|
std::array<NumericValue, N> values;
|
|
std::array<NumericValue, N> values;
|
|
|
-
|
|
|
|
|
- String ToString() const noexcept;
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-struct Matrix2D : public ResolvedPrimitive< 6 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API Matrix2D : public ResolvedPrimitive< 6 >
|
|
|
{
|
|
{
|
|
|
Matrix2D(const NumericValue* values) noexcept : ResolvedPrimitive(values) { }
|
|
Matrix2D(const NumericValue* values) noexcept : ResolvedPrimitive(values) { }
|
|
|
- String ToString() const noexcept { return "matrix" + ResolvedPrimitive< 6 >::ToString(""); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct Matrix3D : public ResolvedPrimitive< 16 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API Matrix3D : public ResolvedPrimitive< 16 >
|
|
|
{
|
|
{
|
|
|
- Matrix3D(const Matrix4f& matrix) noexcept : ResolvedPrimitive(matrix.data()) { }
|
|
|
|
|
Matrix3D(const NumericValue* values) noexcept : ResolvedPrimitive(values) { }
|
|
Matrix3D(const NumericValue* values) noexcept : ResolvedPrimitive(values) { }
|
|
|
- String ToString() const noexcept { return "matrix3d" + ResolvedPrimitive< 16 >::ToString(""); }
|
|
|
|
|
|
|
+ Matrix3D(const Matrix4f& matrix) noexcept : ResolvedPrimitive(matrix.data()) { }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct TranslateX : public UnresolvedPrimitive< 1 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API TranslateX : public UnresolvedPrimitive< 1 >
|
|
|
{
|
|
{
|
|
|
TranslateX(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
|
|
TranslateX(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
|
|
|
TranslateX(float x, Property::Unit unit = Property::PX) noexcept : UnresolvedPrimitive({ NumericValue(x, unit) }) { }
|
|
TranslateX(float x, Property::Unit unit = Property::PX) noexcept : UnresolvedPrimitive({ NumericValue(x, unit) }) { }
|
|
|
- String ToString() const noexcept { return "translateX" + UnresolvedPrimitive< 1 >::ToString(); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct TranslateY : public UnresolvedPrimitive< 1 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API TranslateY : public UnresolvedPrimitive< 1 >
|
|
|
{
|
|
{
|
|
|
TranslateY(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
|
|
TranslateY(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
|
|
|
TranslateY(float y, Property::Unit unit = Property::PX) noexcept : UnresolvedPrimitive({ NumericValue(y, unit) }) { }
|
|
TranslateY(float y, Property::Unit unit = Property::PX) noexcept : UnresolvedPrimitive({ NumericValue(y, unit) }) { }
|
|
|
- String ToString() const noexcept { return "translateY" + UnresolvedPrimitive< 1 >::ToString(); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct TranslateZ : public UnresolvedPrimitive< 1 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API TranslateZ : public UnresolvedPrimitive< 1 >
|
|
|
{
|
|
{
|
|
|
TranslateZ(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
|
|
TranslateZ(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
|
|
|
TranslateZ(float z, Property::Unit unit = Property::PX) noexcept : UnresolvedPrimitive({ NumericValue(z, unit) }) { }
|
|
TranslateZ(float z, Property::Unit unit = Property::PX) noexcept : UnresolvedPrimitive({ NumericValue(z, unit) }) { }
|
|
|
- String ToString() const noexcept { return "translateZ" + UnresolvedPrimitive< 1 >::ToString(); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct Translate2D : public UnresolvedPrimitive< 2 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API Translate2D : public UnresolvedPrimitive< 2 >
|
|
|
{
|
|
{
|
|
|
Translate2D(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
|
|
Translate2D(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
|
|
|
Translate2D(float x, float y, Property::Unit units = Property::PX) noexcept : UnresolvedPrimitive({ NumericValue(x, units), NumericValue(y, units) }) { }
|
|
Translate2D(float x, float y, Property::Unit units = Property::PX) noexcept : UnresolvedPrimitive({ NumericValue(x, units), NumericValue(y, units) }) { }
|
|
|
- String ToString() const noexcept { return "translate" + UnresolvedPrimitive< 2 >::ToString(); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct Translate3D : public UnresolvedPrimitive< 3 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API Translate3D : public UnresolvedPrimitive< 3 >
|
|
|
{
|
|
{
|
|
|
Translate3D(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
|
|
Translate3D(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
|
|
|
Translate3D(NumericValue x, NumericValue y, NumericValue z) noexcept : UnresolvedPrimitive({ x, y, z }) { }
|
|
Translate3D(NumericValue x, NumericValue y, NumericValue z) noexcept : UnresolvedPrimitive({ x, y, z }) { }
|
|
|
Translate3D(float x, float y, float z, Property::Unit units = Property::PX) noexcept : UnresolvedPrimitive({ NumericValue(x, units), NumericValue(y, units), NumericValue(z, units) }) { }
|
|
Translate3D(float x, float y, float z, Property::Unit units = Property::PX) noexcept : UnresolvedPrimitive({ NumericValue(x, units), NumericValue(y, units), NumericValue(z, units) }) { }
|
|
|
- String ToString() const noexcept { return "translate3d" + UnresolvedPrimitive< 3 >::ToString(); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct ScaleX : public ResolvedPrimitive< 1 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API ScaleX : public ResolvedPrimitive< 1 >
|
|
|
{
|
|
{
|
|
|
ScaleX(const NumericValue* values) noexcept : ResolvedPrimitive(values) { }
|
|
ScaleX(const NumericValue* values) noexcept : ResolvedPrimitive(values) { }
|
|
|
ScaleX(float value) noexcept : ResolvedPrimitive({ value }) { }
|
|
ScaleX(float value) noexcept : ResolvedPrimitive({ value }) { }
|
|
|
- String ToString() const noexcept { return "scaleX" + ResolvedPrimitive< 1 >::ToString(""); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct ScaleY : public ResolvedPrimitive< 1 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API ScaleY : public ResolvedPrimitive< 1 >
|
|
|
{
|
|
{
|
|
|
ScaleY(const NumericValue* values) noexcept : ResolvedPrimitive(values) { }
|
|
ScaleY(const NumericValue* values) noexcept : ResolvedPrimitive(values) { }
|
|
|
ScaleY(float value) noexcept : ResolvedPrimitive({ value }) { }
|
|
ScaleY(float value) noexcept : ResolvedPrimitive({ value }) { }
|
|
|
- String ToString() const noexcept { return "scaleY" + ResolvedPrimitive< 1 >::ToString(""); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct ScaleZ : public ResolvedPrimitive< 1 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API ScaleZ : public ResolvedPrimitive< 1 >
|
|
|
{
|
|
{
|
|
|
ScaleZ(const NumericValue* values) noexcept : ResolvedPrimitive(values) { }
|
|
ScaleZ(const NumericValue* values) noexcept : ResolvedPrimitive(values) { }
|
|
|
ScaleZ(float value) noexcept : ResolvedPrimitive({ value }) { }
|
|
ScaleZ(float value) noexcept : ResolvedPrimitive({ value }) { }
|
|
|
- String ToString() const noexcept { return "scaleZ" + ResolvedPrimitive< 1 >::ToString(""); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct Scale2D : public ResolvedPrimitive< 2 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API Scale2D : public ResolvedPrimitive< 2 >
|
|
|
{
|
|
{
|
|
|
Scale2D(const NumericValue* values) noexcept : ResolvedPrimitive(values) { }
|
|
Scale2D(const NumericValue* values) noexcept : ResolvedPrimitive(values) { }
|
|
|
Scale2D(float xy) noexcept : ResolvedPrimitive({ xy, xy }) { }
|
|
Scale2D(float xy) noexcept : ResolvedPrimitive({ xy, xy }) { }
|
|
|
Scale2D(float x, float y) noexcept : ResolvedPrimitive({ x, y }) { }
|
|
Scale2D(float x, float y) noexcept : ResolvedPrimitive({ x, y }) { }
|
|
|
- String ToString() const noexcept { return "scale" + ResolvedPrimitive< 2 >::ToString(""); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct Scale3D : public ResolvedPrimitive< 3 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API Scale3D : public ResolvedPrimitive< 3 >
|
|
|
{
|
|
{
|
|
|
Scale3D(const NumericValue* values) noexcept : ResolvedPrimitive(values) { }
|
|
Scale3D(const NumericValue* values) noexcept : ResolvedPrimitive(values) { }
|
|
|
Scale3D(float xyz) noexcept : ResolvedPrimitive({ xyz, xyz, xyz }) { }
|
|
Scale3D(float xyz) noexcept : ResolvedPrimitive({ xyz, xyz, xyz }) { }
|
|
|
Scale3D(float x, float y, float z) noexcept : ResolvedPrimitive({ x, y, z }) { }
|
|
Scale3D(float x, float y, float z) noexcept : ResolvedPrimitive({ x, y, z }) { }
|
|
|
- String ToString() const noexcept { return "scale3d" + ResolvedPrimitive< 3 >::ToString(""); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct RotateX : public ResolvedPrimitive< 1 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API RotateX : public ResolvedPrimitive< 1 >
|
|
|
{
|
|
{
|
|
|
RotateX(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::RAD }) { }
|
|
RotateX(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::RAD }) { }
|
|
|
RotateX(float angle, Property::Unit unit = Property::DEG) noexcept : ResolvedPrimitive({ NumericValue{ angle, unit } }, { Property::RAD }) { }
|
|
RotateX(float angle, Property::Unit unit = Property::DEG) noexcept : ResolvedPrimitive({ NumericValue{ angle, unit } }, { Property::RAD }) { }
|
|
|
- String ToString() const noexcept { return "rotateX" + ResolvedPrimitive< 1 >::ToString("deg", true); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct RotateY : public ResolvedPrimitive< 1 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API RotateY : public ResolvedPrimitive< 1 >
|
|
|
{
|
|
{
|
|
|
RotateY(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::RAD }) {}
|
|
RotateY(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::RAD }) {}
|
|
|
RotateY(float angle, Property::Unit unit = Property::DEG) noexcept : ResolvedPrimitive({ NumericValue{ angle, unit } }, { Property::RAD }) { }
|
|
RotateY(float angle, Property::Unit unit = Property::DEG) noexcept : ResolvedPrimitive({ NumericValue{ angle, unit } }, { Property::RAD }) { }
|
|
|
- String ToString() const noexcept { return "rotateY" + ResolvedPrimitive< 1 >::ToString("deg", true); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct RotateZ : public ResolvedPrimitive< 1 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API RotateZ : public ResolvedPrimitive< 1 >
|
|
|
{
|
|
{
|
|
|
RotateZ(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::RAD }) { }
|
|
RotateZ(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::RAD }) { }
|
|
|
RotateZ(float angle, Property::Unit unit = Property::DEG) noexcept : ResolvedPrimitive({ NumericValue{ angle, unit } }, { Property::RAD }) { }
|
|
RotateZ(float angle, Property::Unit unit = Property::DEG) noexcept : ResolvedPrimitive({ NumericValue{ angle, unit } }, { Property::RAD }) { }
|
|
|
- String ToString() const noexcept { return "rotateZ" + ResolvedPrimitive< 1 >::ToString("deg", true); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct Rotate2D : public ResolvedPrimitive< 1 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API Rotate2D : public ResolvedPrimitive< 1 >
|
|
|
{
|
|
{
|
|
|
Rotate2D(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::RAD }) { }
|
|
Rotate2D(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::RAD }) { }
|
|
|
Rotate2D(float angle, Property::Unit unit = Property::DEG) noexcept : ResolvedPrimitive({ NumericValue{ angle, unit } }, { Property::RAD }) { }
|
|
Rotate2D(float angle, Property::Unit unit = Property::DEG) noexcept : ResolvedPrimitive({ NumericValue{ angle, unit } }, { Property::RAD }) { }
|
|
|
- String ToString() const noexcept { return "rotate" + ResolvedPrimitive< 1 >::ToString("deg", true); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct Rotate3D : public ResolvedPrimitive< 4 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API Rotate3D : public ResolvedPrimitive< 4 >
|
|
|
{
|
|
{
|
|
|
Rotate3D(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::NUMBER, Property::NUMBER, Property::NUMBER, Property::RAD }) { }
|
|
Rotate3D(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::NUMBER, Property::NUMBER, Property::NUMBER, Property::RAD }) { }
|
|
|
Rotate3D(float x, float y, float z, float angle, Property::Unit angle_unit = Property::DEG) noexcept
|
|
Rotate3D(float x, float y, float z, float angle, Property::Unit angle_unit = Property::DEG) noexcept
|
|
|
: ResolvedPrimitive({ NumericValue{x, Property::NUMBER}, NumericValue{y, Property::NUMBER}, NumericValue{z, Property::NUMBER}, NumericValue{angle, angle_unit} },
|
|
: ResolvedPrimitive({ NumericValue{x, Property::NUMBER}, NumericValue{y, Property::NUMBER}, NumericValue{z, Property::NUMBER}, NumericValue{angle, angle_unit} },
|
|
|
{ Property::NUMBER, Property::NUMBER, Property::NUMBER, Property::RAD }) { }
|
|
{ Property::NUMBER, Property::NUMBER, Property::NUMBER, Property::RAD }) { }
|
|
|
- String ToString() const noexcept { return "rotate3d" + ResolvedPrimitive< 4 >::ToString("deg", true, true); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct SkewX : public ResolvedPrimitive< 1 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API SkewX : public ResolvedPrimitive< 1 >
|
|
|
{
|
|
{
|
|
|
SkewX(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::RAD }) { }
|
|
SkewX(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::RAD }) { }
|
|
|
SkewX(float angle, Property::Unit unit = Property::DEG) noexcept : ResolvedPrimitive({ NumericValue{ angle, unit } }, { Property::RAD }) { }
|
|
SkewX(float angle, Property::Unit unit = Property::DEG) noexcept : ResolvedPrimitive({ NumericValue{ angle, unit } }, { Property::RAD }) { }
|
|
|
- String ToString() const noexcept { return "skewX" + ResolvedPrimitive< 1 >::ToString("deg", true); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct SkewY : public ResolvedPrimitive< 1 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API SkewY : public ResolvedPrimitive< 1 >
|
|
|
{
|
|
{
|
|
|
SkewY(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::RAD }) { }
|
|
SkewY(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::RAD }) { }
|
|
|
SkewY(float angle, Property::Unit unit = Property::DEG) noexcept : ResolvedPrimitive({ NumericValue{ angle, unit } }, { Property::RAD }) { }
|
|
SkewY(float angle, Property::Unit unit = Property::DEG) noexcept : ResolvedPrimitive({ NumericValue{ angle, unit } }, { Property::RAD }) { }
|
|
|
- String ToString() const noexcept { return "skewY" + ResolvedPrimitive< 1 >::ToString("deg", true); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct Skew2D : public ResolvedPrimitive< 2 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API Skew2D : public ResolvedPrimitive< 2 >
|
|
|
{
|
|
{
|
|
|
Skew2D(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::RAD, Property::RAD }) { }
|
|
Skew2D(const NumericValue* values) noexcept : ResolvedPrimitive(values, { Property::RAD, Property::RAD }) { }
|
|
|
Skew2D(float x, float y, Property::Unit unit = Property::DEG) noexcept : ResolvedPrimitive({NumericValue{ x, unit }, { NumericValue{ y, unit }}}, {Property::RAD, Property::RAD}) { }
|
|
Skew2D(float x, float y, Property::Unit unit = Property::DEG) noexcept : ResolvedPrimitive({NumericValue{ x, unit }, { NumericValue{ y, unit }}}, {Property::RAD, Property::RAD}) { }
|
|
|
- String ToString() const noexcept { return "skew" + ResolvedPrimitive< 2 >::ToString("deg", true); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct Perspective : public UnresolvedPrimitive< 1 >
|
|
|
|
|
|
|
+struct ROCKETCORE_API Perspective : public UnresolvedPrimitive< 1 >
|
|
|
{
|
|
{
|
|
|
Perspective(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
|
|
Perspective(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
|
|
|
- String ToString() const noexcept { return "perspective" + UnresolvedPrimitive< 1 >::ToString(); }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
struct DecomposedMatrix4
|
|
struct DecomposedMatrix4
|
|
@@ -273,17 +248,49 @@ struct DecomposedMatrix4
|
|
|
Vector3f skew;
|
|
Vector3f skew;
|
|
|
|
|
|
|
|
bool Decompose(const Matrix4f& m);
|
|
bool Decompose(const Matrix4f& m);
|
|
|
- String ToString() const noexcept { return "decomposedMatrix3d"; }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
-using PrimitiveVariant = std::variant<
|
|
|
|
|
- Matrix2D, Matrix3D,
|
|
|
|
|
- TranslateX, TranslateY, TranslateZ, Translate2D, Translate3D,
|
|
|
|
|
- ScaleX, ScaleY, ScaleZ, Scale2D, Scale3D,
|
|
|
|
|
- RotateX, RotateY, RotateZ, Rotate2D, Rotate3D,
|
|
|
|
|
- SkewX, SkewY, Skew2D,
|
|
|
|
|
- Perspective, DecomposedMatrix4>;
|
|
|
|
|
|
|
+struct ROCKETCORE_API PrimitiveVariant {
|
|
|
|
|
+
|
|
|
|
|
+ enum Type {
|
|
|
|
|
+ MATRIX2D, MATRIX3D,
|
|
|
|
|
+ TRANSLATEX, TRANSLATEY, TRANSLATEZ, TRANSLATE2D, TRANSLATE3D,
|
|
|
|
|
+ SCALEX, SCALEY, SCALEZ, SCALE2D, SCALE3D,
|
|
|
|
|
+ ROTATEX, ROTATEY, ROTATEZ, ROTATE2D, ROTATE3D,
|
|
|
|
|
+ SKEWX, SKEWY, SKEW2D,
|
|
|
|
|
+ PERSPECTIVE, DECOMPOSEDMATRIX4
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ PrimitiveVariant(Type type) : type(type) {}
|
|
|
|
|
+
|
|
|
|
|
+ Type type;
|
|
|
|
|
+
|
|
|
|
|
+ union {
|
|
|
|
|
+ Matrix2D matrix_2d;
|
|
|
|
|
+ Matrix3D matrix_3d;
|
|
|
|
|
+ TranslateX translate_x;
|
|
|
|
|
+ TranslateY translate_y;
|
|
|
|
|
+ TranslateZ translate_z;
|
|
|
|
|
+ Translate2D translate_2d;
|
|
|
|
|
+ Translate3D translate_3d;
|
|
|
|
|
+ ScaleX scale_x;
|
|
|
|
|
+ ScaleY scale_y;
|
|
|
|
|
+ ScaleZ scale_z;
|
|
|
|
|
+ Scale2D scale_2d;
|
|
|
|
|
+ Scale3D scale_3d;
|
|
|
|
|
+ RotateX rotate_x;
|
|
|
|
|
+ RotateY rotate_y;
|
|
|
|
|
+ RotateZ rotate_z;
|
|
|
|
|
+ Rotate2D rotate_2d;
|
|
|
|
|
+ Rotate3D rotate_3d;
|
|
|
|
|
+ SkewX skew_x;
|
|
|
|
|
+ SkewY skew_y;
|
|
|
|
|
+ Skew2D skew_2d;
|
|
|
|
|
+ Perspective perspective;
|
|
|
|
|
+ DecomposedMatrix4 decomposed_matrix_4;
|
|
|
|
|
+ };
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -296,12 +303,32 @@ using PrimitiveVariant = std::variant<
|
|
|
@see Rocket::Core::Transform
|
|
@see Rocket::Core::Transform
|
|
|
@see Rocket::Core::PropertyParserTransform
|
|
@see Rocket::Core::PropertyParserTransform
|
|
|
*/
|
|
*/
|
|
|
-struct Primitive
|
|
|
|
|
|
|
+struct ROCKETCORE_API Primitive
|
|
|
{
|
|
{
|
|
|
PrimitiveVariant primitive;
|
|
PrimitiveVariant primitive;
|
|
|
|
|
|
|
|
- template<typename PrimitiveType>
|
|
|
|
|
- Primitive(PrimitiveType primitive) : primitive(primitive) {}
|
|
|
|
|
|
|
+ Primitive(Matrix2D p) : primitive(PrimitiveVariant::MATRIX2D) { primitive.matrix_2d = p; }
|
|
|
|
|
+ Primitive(Matrix3D p) : primitive(PrimitiveVariant::MATRIX3D) { primitive.matrix_3d = p; }
|
|
|
|
|
+ Primitive(TranslateX p) : primitive(PrimitiveVariant::TRANSLATEX) { primitive.translate_x = p; }
|
|
|
|
|
+ Primitive(TranslateY p) : primitive(PrimitiveVariant::TRANSLATEY) { primitive.translate_y = p; }
|
|
|
|
|
+ Primitive(TranslateZ p) : primitive(PrimitiveVariant::TRANSLATEZ) { primitive.translate_z = p; }
|
|
|
|
|
+ Primitive(Translate2D p) : primitive(PrimitiveVariant::TRANSLATE2D) { primitive.translate_2d = p; }
|
|
|
|
|
+ Primitive(Translate3D p) : primitive(PrimitiveVariant::TRANSLATE3D) { primitive.translate_3d = p; }
|
|
|
|
|
+ Primitive(ScaleX p) : primitive(PrimitiveVariant::SCALEX) { primitive.scale_x = p; }
|
|
|
|
|
+ Primitive(ScaleY p) : primitive(PrimitiveVariant::SCALEY) { primitive.scale_y = p; }
|
|
|
|
|
+ Primitive(ScaleZ p) : primitive(PrimitiveVariant::SCALEZ) { primitive.scale_z = p; }
|
|
|
|
|
+ Primitive(Scale2D p) : primitive(PrimitiveVariant::SCALE2D) { primitive.scale_2d = p; }
|
|
|
|
|
+ Primitive(Scale3D p) : primitive(PrimitiveVariant::SCALE3D) { primitive.scale_3d = p; }
|
|
|
|
|
+ Primitive(RotateX p) : primitive(PrimitiveVariant::ROTATEX) { primitive.rotate_x = p; }
|
|
|
|
|
+ Primitive(RotateY p) : primitive(PrimitiveVariant::ROTATEY) { primitive.rotate_y = p; }
|
|
|
|
|
+ Primitive(RotateZ p) : primitive(PrimitiveVariant::ROTATEZ) { primitive.rotate_z = p; }
|
|
|
|
|
+ Primitive(Rotate2D p) : primitive(PrimitiveVariant::ROTATE2D) { primitive.rotate_2d = p; }
|
|
|
|
|
+ Primitive(Rotate3D p) : primitive(PrimitiveVariant::ROTATE3D) { primitive.rotate_3d = p; }
|
|
|
|
|
+ Primitive(SkewX p) : primitive(PrimitiveVariant::SKEWX) { primitive.skew_x = p; }
|
|
|
|
|
+ Primitive(SkewY p) : primitive(PrimitiveVariant::SKEWY) { primitive.skew_y = p; }
|
|
|
|
|
+ Primitive(Skew2D p) : primitive(PrimitiveVariant::SKEW2D) { primitive.skew_2d = p; }
|
|
|
|
|
+ Primitive(Perspective p) : primitive(PrimitiveVariant::PERSPECTIVE) { primitive.perspective = p; }
|
|
|
|
|
+ Primitive(DecomposedMatrix4 p) : primitive(PrimitiveVariant::DECOMPOSEDMATRIX4) { primitive.decomposed_matrix_4 = p; }
|
|
|
|
|
|
|
|
void SetIdentity() noexcept;
|
|
void SetIdentity() noexcept;
|
|
|
|
|
|
|
@@ -326,33 +353,6 @@ struct Primitive
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
-template<size_t N>
|
|
|
|
|
-inline String ResolvedPrimitive<N>::ToString(String unit, bool rad_to_deg, bool only_unit_on_last_value) const noexcept {
|
|
|
|
|
- float multiplier = 1.0f;
|
|
|
|
|
- if (rad_to_deg) multiplier = 180.f / Math::ROCKET_PI;
|
|
|
|
|
- String tmp;
|
|
|
|
|
- String result = "(";
|
|
|
|
|
- for (size_t i = 0; i < N; i++) {
|
|
|
|
|
- if (TypeConverter<float, String>::Convert(values[i] * multiplier, tmp))
|
|
|
|
|
- result += tmp;
|
|
|
|
|
- if (!unit.empty() && (!only_unit_on_last_value || (i == N - 1)))
|
|
|
|
|
- result += unit;
|
|
|
|
|
- if (i != N - 1) result += ", ";
|
|
|
|
|
- }
|
|
|
|
|
- result += ")";
|
|
|
|
|
- return result;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template<size_t N>
|
|
|
|
|
-inline String UnresolvedPrimitive<N>::ToString() const noexcept {
|
|
|
|
|
- String result = "(";
|
|
|
|
|
- for (size_t i = 0; i < N; i++) {
|
|
|
|
|
- result += values[i].ToString();
|
|
|
|
|
- if (i != N - 1) result += ", ";
|
|
|
|
|
- }
|
|
|
|
|
- result += ")";
|
|
|
|
|
- return result;
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|