/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
for(float z = 0.0f; z < 2.0f; z += 0.1f)
{
Vector3 vScale(x, y, z);
+ Vector2 vScaleXY(x, y);
for(float angle = 5.0f; angle <= 360.0f; angle += 15.0f)
{
Matrix m1(false);
m1.SetTransformComponents(vScale, rotation1, position1);
- Vector3 scale2 = m1.GetScale();
+ Vector3 scale2 = m1.GetScale();
+ Vector2 scale2XY = m1.GetScaleXY();
DALI_TEST_EQUALS(vScale, scale2, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(vScaleXY, scale2XY, 0.001, TEST_LOCATION);
}
}
}
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
END_TEST;
}
+int UtcDaliVector4Constructor06P(void)
+{
+ Vector3 vec3(1.f, 2.f, 3.f);
+ Vector4 v(vec3, 4.f);
+ DALI_TEST_EQUALS(v.x, 1.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(v.y, 2.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(v.z, 3.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(v.w, 4.0f, TEST_LOCATION);
+ END_TEST;
+}
+
int UtcDaliVector4CopyConstructor(void)
{
TestApplication application;
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Vec4 tempResult;
asm volatile(
- "VLD1.F32 {q0}, [%1] \n\t" //Load "temp" from memory to register q0
- "VLD1.F32 {q1}, [%0]! \n\t" //Load first row of the matrix from memory to register q1
- "VMUL.F32 q2, q1, d0[0] \n\t" //q2 = (m[0..3] * v.x)
- "VLD1.F32 {q1}, [%0]! \n\t" //Load second row of the matrix from memory
- "VMLA.F32 q2, q1, d0[1] \n\t" //q2 = (m[0..3] * v.x) + (m[4..7] * v.y)
- "VLD1.F32 {q1}, [%0]! \n\t" //Load third row of the matrix from memory
- "VMLA.F32 q2, q1, d1[0] \n\t" //q2 = (m[0..3] * v.x) + (m[4..7] * v.y) + (m[8...11] * v.z)
- "VST1.F32 {q2}, [%2] \n\t" //Write the result back to memory
+ "VLD1.F32 {q0}, [%1] \n\t" // Load "temp" from memory to register q0
+ "VLD1.F32 {q1}, [%0]! \n\t" // Load first row of the matrix from memory to register q1
+ "VMUL.F32 q2, q1, d0[0] \n\t" // q2 = (m[0..3] * v.x)
+ "VLD1.F32 {q1}, [%0]! \n\t" // Load second row of the matrix from memory
+ "VMLA.F32 q2, q1, d0[1] \n\t" // q2 = (m[0..3] * v.x) + (m[4..7] * v.y)
+ "VLD1.F32 {q1}, [%0]! \n\t" // Load third row of the matrix from memory
+ "VMLA.F32 q2, q1, d1[0] \n\t" // q2 = (m[0..3] * v.x) + (m[4..7] * v.y) + (m[8...11] * v.z)
+ "VST1.F32 {q2}, [%2] \n\t" // Write the result back to memory
:
: "r"(m), "r"(temp), "r"(tempResult)
: "q0", "q1", "q2", "memory");
{
return sqrtf(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
}
+
+float Dali::Internal::TransformFloat(const Mat4 m, const float x)
+{
+ return sqrtf(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]) * x;
+}
\ No newline at end of file
#define DALI_INTERNAL_MATH_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
float Length(const Vec3 v);
+/**
+ * @brief Applies a transformation matrix to a Vector3(x, 0, 0) and get the length of result matrix
+ *
+ * @param[in] m The transformation matrix
+ * @param[in] v The x components of vector to transform
+ * @return The length of transformed vector
+ */
+float TransformFloat(const Mat4 m, const float x);
+
} // namespace Internal
} // namespace Dali
node->UpdatePartialRenderingData(updateBufferIndex, isLayer3d);
const Vector4& nodeUpdateArea = nodePartialRenderingData.mNodeInfomations.updatedPositionSize;
- const Vector3& nodeScale = nodePartialRenderingData.mNodeInfomations.modelMatrix.GetScale();
+ const Vector2& nodeScaleXY = nodePartialRenderingData.mNodeInfomations.modelMatrix.GetScaleXY();
nodePartialRenderingDataUpdateChecked = true;
- const Vector3& size = Vector3(nodeUpdateArea.z, nodeUpdateArea.w, 0.0f) * nodeScale;
+ const Vector2& sizeXY = Vector2(nodeUpdateArea.z * nodeScaleXY.x, nodeUpdateArea.w * nodeScaleXY.y);
- if(size.LengthSquared() > Math::MACHINE_EPSILON_1000)
+ if(sizeXY.LengthSquared() > Math::MACHINE_EPSILON_1000)
{
MatrixUtils::MultiplyTransformMatrix(nodeModelViewMatrix, nodePartialRenderingData.mNodeInfomations.modelMatrix, viewMatrix);
nodeModelViewMatrixSet = true;
}
}
- // Update the bounding sphere
- Vec3 centerToEdge = {mSize[i].Length() * 0.5f, 0.0f, 0.0f};
- Vec3 centerToEdgeWorldSpace;
- TransformVector3(centerToEdgeWorldSpace, mWorld[i].AsFloat(), centerToEdge);
+ // TODO : We need to check mComponentDirty since we have to check the size changeness.
+ // Could we check size changeness only?
+ if(mComponentDirty[i] || mWorldMatrixDirty[i])
+ {
+ // Update the bounding sphere
+ float centerToEdge = mSize[i].Length() * 0.5f;
+ float centerToEdgeWorldSpace = TransformFloat(mWorld[i].AsFloat(), centerToEdge);
- mBoundingSpheres[i] = mWorld[i].GetTranslation();
- mBoundingSpheres[i].w = Length(centerToEdgeWorldSpace);
+ mBoundingSpheres[i] = std::move(Vector4(mWorld[i].GetTranslation3(), centerToEdgeWorldSpace));
+ }
mUpdated = mUpdated || mWorldMatrixDirty[i];
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/math/math-utils.h>
#include <dali/public-api/math/quaternion.h>
+#include <dali/public-api/math/vector2.h>
#include <dali/public-api/math/vector3.h>
#include <dali/public-api/math/vector4.h>
// e.g. q0 = d0 and d1
// load and stores interleaved as NEON can load and store while calculating
asm volatile(
- "VLD1.F32 {q0}, [%1] \n\t" //q0 = rhs
+ "VLD1.F32 {q0}, [%1] \n\t" // q0 = rhs
"VLD1.F32 {q9}, [%0]! \n\t"
"VMUL.F32 q10, q9, d0[0] \n\t"
"VLD1.F32 {q9}, [%0]! \n\t"
- "VMLA.F32 q10, q9, d0[1] \n\t" //q10 = mMatrix[0..3] * rhs + mMatrix[4..7] * rhs
+ "VMLA.F32 q10, q9, d0[1] \n\t" // q10 = mMatrix[0..3] * rhs + mMatrix[4..7] * rhs
"VLD1.F32 {q9}, [%0]! \n\t"
"VMUL.F32 q11, q9, d1[0] \n\t"
"VLD1.F32 {q9}, [%0]! \n\t"
- "VMLA.F32 q11, q9, d1[1] \n\t" //q11 = mMatrix[8..11] * rhs + mMatrix[12..15] * rhs
+ "VMLA.F32 q11, q9, d1[1] \n\t" // q11 = mMatrix[8..11] * rhs + mMatrix[12..15] * rhs
"VADD.F32 q10, q10, q11 \n\t"
- "VST1.F32 {q10},[%2] \n\t" //temp = q10 + q11
+ "VST1.F32 {q10},[%2] \n\t" // temp = q10 + q11
:
: "r"(mMatrix), "r"(&rhs), "r"(&temp)
: "q0", "q9", "q10", "q11", "memory");
Vector3 Matrix::GetScale() const
{
// Derive scale from axis lengths.
- return Vector3(GetXAxis().Length(), GetYAxis().Length(), GetZAxis().Length());
+ // Note : To avoid struct creation, let we access memory directoy, instead call GetXAxis(), GetYAxis() and GetZAxis().
+ return Vector3(reinterpret_cast<const Vector3&>(mMatrix[0]).Length(), reinterpret_cast<const Vector3&>(mMatrix[4]).Length(), reinterpret_cast<const Vector3&>(mMatrix[8]).Length());
+}
+
+Vector2 Matrix::GetScaleXY() const
+{
+ // Derive scale from axis lengths.
+ // Note : To avoid struct creation, let we access memory directoy, instead call GetXAxis() and GetYAxis().
+ return Vector2(reinterpret_cast<const Vector3&>(mMatrix[0]).Length(), reinterpret_cast<const Vector3&>(mMatrix[4]).Length());
}
void Matrix::GetTransformComponents(Vector3& position,
#define DALI_MATRIX_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
Vector3 GetScale() const;
+ /**
+ * @brief Gets the x,y components of the scale as a Vector2.
+ * Note that transform scale always has positive components.
+ *
+ * This assumes the matrix is a transform matrix.
+ * @SINCE_2_4.19
+ * @return The scale of xy components
+ */
+ Vector2 GetScaleXY() const;
+
/**
* @brief Sets the translation.
*
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
}
+Vector4::Vector4(const Vector3& vec3, float w)
+: x(vec3.x),
+ y(vec3.y),
+ z(vec3.z),
+ w(w)
+{
+}
+
Vector4& Vector4::operator=(const Vector2& vec2)
{
x = vec2.x;
#define DALI_VECTOR_4_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
explicit Vector4(const Vector3& vec3);
+ /**
+ * @brief Conversion constructor from Vector3 and float.
+ *
+ * @SINCE_2_4.19
+ * @param[in] vec3 Vector3 to copy from
+ * @param[in] w w (or a/q) component
+ */
+ explicit Vector4(const Vector3& vec3, float w);
+
// Constants
static const Vector4 ONE; ///< (1.0f,1.0f,1.0f,1.0f)
static const Vector4 XAXIS; ///< (1.0f,0.0f,0.0f,0.0f)
};
public:
- Vector4(const Vector4&) = default; ///< Default copy constructor
- Vector4(Vector4&&) noexcept = default; ///< Default move constructor
- Vector4& operator=(const Vector4&) = default; ///< Default copy assignment operator
+ Vector4(const Vector4&) = default; ///< Default copy constructor
+ Vector4(Vector4&&) noexcept = default; ///< Default move constructor
+ Vector4& operator=(const Vector4&) = default; ///< Default copy assignment operator
Vector4& operator=(Vector4&&) noexcept = default; ///< Default move assignment operator
};