/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
namespace
{
-const int ARGINDEX_REF_VALUE = 0;
-const int ARGINDEX_STEP_SIZE = 1;
-const int ARGINDEX_CURRENT_STEP = 2;
+const int32_t ARGINDEX_REF_VALUE = 0;
+const int32_t ARGINDEX_STEP_SIZE = 1;
+const int32_t ARGINDEX_CURRENT_STEP = 2;
+const int32_t ARGINDEX_FIRST_VALUE = 3;
+const int32_t ARGINDEX_SECOND_VALUE = 4;
+const int32_t ARGINDEX_THIRD_VALUE = 5;
} // namespace
switch(valueType)
{
- case Property::FLOAT:
+ case Property::INTEGER:
{
- function = EvalFloat;
+ function = EvalInteger;
break;
}
- case Property::INTEGER:
+ case Property::FLOAT:
{
- function = EvalInteger;
+ function = EvalFloat;
break;
}
case Property::VECTOR2:
return function;
}
+ConditionFunction Step::GetCompareFunction( Property::Type valueType )
+{
+ ConditionFunction function = NULL;
+ if( valueType == Property::VECTOR3 )
+ {
+ function = EvalAndCompareVector3;
+ }
+ else
+ {
+ function = GetFunction( valueType );
+ }
+
+ return function;
+}
+
bool Step::Evaluate( const float propertyValue, PropertyNotification::RawArgumentContainer& arg )
{
const float refValue = arg[ARGINDEX_REF_VALUE];
const float step = arg[ARGINDEX_STEP_SIZE];
- const int currentStep = static_cast<int>(arg[ARGINDEX_CURRENT_STEP]);
+ const int32_t currentStep = static_cast<int32_t>(arg[ARGINDEX_CURRENT_STEP]);
const float distance = (propertyValue - refValue);
// step is actual 1.0f / step so can multiply instead of dividing
- const int newStep = static_cast<int>(floorf(distance * step));
+ const int32_t newStep = static_cast<int32_t>(floorf(distance * step));
if( newStep != currentStep )
{
return false;
}
-bool Step::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+
+bool Step::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
- const float propertyValue = value.GetFloat();
+ const float propertyValue = static_cast<float>( value.GetInteger() );
return Evaluate( propertyValue, arg );
}
-bool Step::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Step::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
- const float propertyValue = static_cast<float>( value.GetInteger() );
+ const float propertyValue = value.GetFloat();
return Evaluate( propertyValue, arg );
}
bool Step::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
- const float propertyValue = value.GetVector2().LengthSquared();
+ const float propertyValue = value.GetVector2().Length();
return Evaluate( propertyValue, arg );
}
bool Step::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
- float propertyValue = value.GetVector3().LengthSquared();
+ float propertyValue = value.GetVector3().Length();
return Evaluate( propertyValue, arg );
}
-bool Step::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Step::EvalAndCompareVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+{
+ float propertyValue = value.GetVector3().Length();
+ bool result = Evaluate( propertyValue, arg );
+ if( result == false )
+ {
+ const float step = 1.0f / arg[ARGINDEX_STEP_SIZE];
+ if( ( fabsf( arg[ARGINDEX_FIRST_VALUE] - value.GetVector3().x ) > step )
+ || ( fabsf( arg[ARGINDEX_SECOND_VALUE] - value.GetVector3().y ) > step )
+ || ( fabsf( arg[ARGINDEX_THIRD_VALUE] - value.GetVector3().z ) > step ) )
+ {
+ result = true;
+ }
+ }
+ arg[ARGINDEX_FIRST_VALUE] = value.GetVector3().x;
+ arg[ARGINDEX_SECOND_VALUE] = value.GetVector3().y;
+ arg[ARGINDEX_THIRD_VALUE] = value.GetVector3().z;
+ return result;
+}
+
+bool Step::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
- const float propertyValue = value.GetVector4().LengthSquared();
+ const float propertyValue = value.GetVector4().Length();
return Evaluate( propertyValue, arg );
}