END_TEST;
}
+int UtcDaliPropertyNotificationStepQuaternion(void)
+{
+ TestApplication application;
+ tet_infoline(" UtcDaliPropertyNotificationStepQuaternion");
+
+ tet_printf("Note : Current implement is kind of POC. Should be complete in future.");
+
+ Actor actor = Actor::New();
+ application.GetScene().Add(actor);
+
+ // TODO : Need to be meanful value in future.
+ const float tinyStep = 0.01f;
+
+ PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::ORIENTATION, StepCondition(tinyStep));
+ notification.NotifySignal().Connect(&TestCallback);
+
+ // Rotate big angles for current case.
+ actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Radian(Degree(0.0f)), Vector3::YAXIS));
+ Wait(application, DEFAULT_WAIT_PERIOD);
+
+ for(int i = 1; i <= 10; ++i)
+ {
+ // Move x to negative position
+ gCallBackCalled = false;
+ actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Radian(Degree(i * 36.0f)), Vector3::YAXIS));
+ Wait(application, DEFAULT_WAIT_PERIOD);
+ DALI_TEST_CHECK(gCallBackCalled);
+ }
+
+ tet_printf("Test for length of EulerAngle is same, but each componets are difference.");
+ actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Radian(Degree(90.0f)), Vector3::YAXIS));
+ Wait(application, DEFAULT_WAIT_PERIOD);
+
+ gCallBackCalled = false;
+ actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Radian(Degree(90.0f)), Vector3::XAXIS));
+ Wait(application, DEFAULT_WAIT_PERIOD);
+ DALI_TEST_CHECK(gCallBackCalled);
+
+ tet_printf("Test notify should not be called");
+ gCallBackCalled = false;
+ Animation animation = Animation::New(RENDER_FRAME_INTERVAL);
+ animation.AnimateTo(Property(actor, Actor::Property::ORIENTATION), Quaternion(Radian(Degree(90.0f)), Vector3::XAXIS));
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(RENDER_FRAME_INTERVAL);
+ application.SendNotification();
+ application.Render(RENDER_FRAME_INTERVAL);
+
+ DALI_TEST_CHECK(!gCallBackCalled);
+ END_TEST;
+}
+
int UtcDaliPropertyNotificationVariableStep(void)
{
TestApplication application;
}
// To cover swapping components, previous and current components should be compared.
- if(mObject->GetPropertyType(mObjectPropertyIndex) == Property::VECTOR3)
+ if(mObject->GetPropertyType(mObjectPropertyIndex) == Property::VECTOR3 ||
+ mObject->GetPropertyType(mObjectPropertyIndex) == Property::ROTATION)
{
mCompare = true;
for(int i = 0; i < 3; ++i)
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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/internal/update/common/property-condition-step-functions.h>
#include <dali/public-api/common/dali-common.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>
const int32_t ARGINDEX_SECOND_VALUE = 4;
const int32_t ARGINDEX_THIRD_VALUE = 5;
+inline float AngleDifference(float a1, float a2, const float angleRangeHalf)
+{
+ float diff = fabs(a1 - a2);
+ return diff < angleRangeHalf ? diff : angleRangeHalf * 2.0f - diff;
+}
+
} // namespace
ConditionFunction Step::GetFunction(Property::Type valueType)
{
function = EvalAndCompareVector3;
}
+ else if(valueType == Property::ROTATION)
+ {
+ function = EvalAndCompareQuaternion;
+ }
else
{
function = GetFunction(valueType);
return Evaluate(propertyValue, arg);
}
+bool Step::EvalAndCompareQuaternion(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
+{
+ // TODO : Make some meaningfule calculation here
+
+ Quaternion propertyValue = value.GetQuaternion();
+
+ Vector4 v = propertyValue.EulerAngles();
+ const float checkValue = v.LengthSquared();
+ bool result = Evaluate(checkValue, arg);
+
+ if(result == false)
+ {
+ const float step = 1.0f / arg[ARGINDEX_STEP_SIZE];
+ if((AngleDifference(arg[ARGINDEX_FIRST_VALUE], v.x, Dali::Math::PI) > step) ||
+ (AngleDifference(arg[ARGINDEX_SECOND_VALUE], v.y, Dali::Math::PI_2) > step) ||
+ (AngleDifference(arg[ARGINDEX_THIRD_VALUE], v.z, Dali::Math::PI) > step))
+ {
+ result = true;
+ }
+ }
+ arg[ARGINDEX_FIRST_VALUE] = v.x;
+ arg[ARGINDEX_SECOND_VALUE] = v.y;
+ arg[ARGINDEX_THIRD_VALUE] = v.z;
+ return result;
+}
+
bool Step::EvalDefault(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
return false;
* Vector2 => 2 dimensional length of vector has stepped arg1 amount from arg0.
* Vector3 => 3 dimensional length of vector has stepped arg1 amount from arg0.
* Vector4 => 4 dimensional length of vector has stepped arg1 amount from arg0.
+ * Quaternion => 3 dimensional lenght of eular angle stepped arg1 amount from arg0
* Default => return false.
*/
class Step
static bool EvalVector4(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
+ * Checks if Quaternion is Outside
+ *
+ * If previous Quaternion and current examined value are same, the raw datas are checked with comparing these values.
+ *
+ * @param[in] value The value being examined.
+ * @param[in] arg The supplied arguments for the condition.
+ * @return Condition result (true if condition met, false if not)
+ */
+ static bool EvalAndCompareQuaternion(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
+
+ /**
* Default check for other types.
* @param[in] value The value being examined.
* @param[in] arg The supplied arguments for the condition.
* vector2 (the 2D length)
* vector3 (the 3D length)
* vector4 (the 4D length)
+ * quaternion (the 3D length of eular angle)
* @SINCE_1_0.0
* @param[in] stepAmount The step size required to trigger condition
* @param[in] initialValue The initial value to step from