Change dali-scene-loader to dali-scene3d
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / loader / matrix-stack.cpp
1 /*
2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17 #include "dali-scene3d/public-api/loader/matrix-stack.h"
18 #include "dali-scene3d/public-api/loader/utils.h"
19
20 namespace Dali
21 {
22 namespace Scene3D
23 {
24 namespace Loader
25 {
26 MatrixStack::MatrixStack()
27 {
28   mStack.reserve(16);
29 }
30
31 bool MatrixStack::IsEmpty() const
32 {
33   return mStack.empty();
34 }
35
36 void MatrixStack::Push(const Matrix& model)
37 {
38   if(mStack.empty())
39   {
40     mStack.push_back(model);
41   }
42   else
43   {
44     Matrix m{false};
45     Matrix::Multiply(m, model, mStack.back());
46     mStack.push_back(m);
47   }
48 }
49
50 const Matrix& MatrixStack::Top() const
51 {
52   return mStack.back();
53 }
54
55 void MatrixStack::Pop()
56 {
57   DALI_ASSERT_ALWAYS(mStack.size() > 0);
58   mStack.pop_back();
59 }
60
61 void MatrixStack::PopAll()
62 {
63   mStack.clear();
64 }
65
66 } // namespace Loader
67 } // namespace Scene3D
68 } // namespace Dali