1 #ifndef DALI_INTERNAL_PATH_H
2 #define DALI_INTERNAL_PATH_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/internal/event/common/object-impl.h>
23 #include <dali/public-api/animation/path.h>
24 #include <dali/public-api/common/dali-vector.h>
25 #include <dali/public-api/math/matrix.h>
26 #include <dali/public-api/object/base-object.h>
32 using PathPtr = IntrusivePtr<Path>;
37 class Path : public Object
41 * Construct a new path
58 * @copydoc Dali::Internal::Object::SetDefaultProperty()
60 void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) override;
63 * @copydoc Dali::Internal::Object::GetDefaultProperty()
65 Property::Value GetDefaultProperty(Property::Index index) const override;
69 * Returns a clone to the given path
71 static Path* Clone(const Path& path);
74 * @copydoc Dali::Path::AddPoint
76 void AddPoint(const Vector3& point);
79 * @copydoc Dali::Path::AddControlPoint
81 void AddControlPoint(const Vector3& point);
84 * @copydoc Dali::Path::GenerateControlPoints
86 void GenerateControlPoints(float curvature);
89 * @copydoc Dali::Path::Sample
91 void Sample(float t, Vector3& position, Vector3& tangent) const;
94 * @brief Sample path at a given progress. Calculates position and tangent at that point of the curve
96 * @param[in] progress A floating point value between 0.0 and 1.0.
97 * @param[out] position The interpolated position at that progress.
98 * @param[out] tangent The interpolated tangent at that progress.
99 * @return true if Sample could be calculated
101 bool SampleAt(float t, Vector3& position, Vector3& tangent) const;
104 * Sample position at point t.
106 * @param[in] progress A floating point value between 0.0 and 1.0.
107 * @param[out] position The interpolated position at that progress.
108 * @return true if sample could be calculated
110 bool SamplePosition(float t, Vector3& position) const;
113 * @brief Sample tangent at point t.
115 * @param[in] progress A floating point value between 0.0 and 1.0.
116 * @param[out] tangent The interpolated tangent at that progress.
117 * @return true if sample could be calculated
119 bool SampleTangent(float t, Vector3& tangent) const;
122 * @copydoc Dali::Path::GetPoint
124 Vector3& GetPoint(uint32_t index);
127 * @copydoc Dali::Path::GetControlPoint
129 Vector3& GetControlPoint(uint32_t index);
132 * @copydoc Dali::Path::GetPointCount
134 uint32_t GetPointCount() const;
137 * Clears the points of the path
142 * Clears the control points of the path
144 void ClearControlPoints();
147 * @brief Get mPoint property
149 * @return A const reference to mPoint vector
151 const Dali::Vector<Vector3>& GetPoints() const
159 * @param[in] p New value for mPoint property
161 void SetPoints(const Dali::Vector<Vector3>& p)
167 * @brief Get mCotrolPoint property
169 * @return A const reference to mControlPoint vector
171 const Dali::Vector<Vector3>& GetControlPoints() const
173 return mControlPoint;
177 * @brief Set mControlPoint property
179 * @param[in] p New value for mControlPoint property
181 void SetControlPoints(const Dali::Vector<Vector3>& p)
195 Path& operator=(const Path& rhs);
198 * Helper function to calculate the segment and local progress in that segment
201 * @param[in] t Progress
202 * @param[out] segment Segment for t
203 * @param[out] tLocal Local progress in the segment
206 void FindSegmentAndProgress(float t, uint32_t& segment, float& tLocal) const;
209 * Helper function to calculate to number of segments in the path
211 uint32_t GetNumberOfSegments() const;
213 Dali::Vector<Vector3> mPoint; ///< Interpolation points
214 Dali::Vector<Vector3> mControlPoint; ///< Control points
217 } // namespace Internal
219 // Get impl of handle
220 inline Internal::Path& GetImplementation(Dali::Path& path)
222 DALI_ASSERT_ALWAYS(path && "Path handle is empty");
223 Dali::RefObject& object = path.GetBaseObject();
224 return static_cast<Internal::Path&>(object);
227 inline const Internal::Path& GetImplementation(const Dali::Path& path)
229 DALI_ASSERT_ALWAYS(path && "Path handle is empty");
230 const Dali::RefObject& object = path.GetBaseObject();
231 return static_cast<const Internal::Path&>(object);
236 #endif // DALI_INTERNAL_PATH_H