Debian Codegraph @

libs/gltfio/src/FilamentInstance.cpp

raw
1 /*
2 * Copyright (C) 2020 The Android Open Source Project
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 "FFilamentInstance.h"
18 #include "FFilamentAsset.h"
19
20 #include <gltfio/Animator.h>
21
22 #include <utils/Log.h>
23
24 using namespace filament;
25 using namespace utils;
26
27 namespace gltfio {
28
29 Animator* FFilamentInstance::getAnimator() noexcept {
30 if (!animator) {
31 if (!owner->mResourcesLoaded) {
32 slog.e << "Cannot create animator before resource loading." << io::endl;
33 return nullptr;
34 }
35 if (!owner->mSourceAsset) {
36 slog.e << "Cannot create animator from frozen asset." << io::endl;
37 return nullptr;
38 }
39 animator = new Animator(owner, this);
40 }
41 return animator;
42 }
43
44 size_t FilamentInstance::getEntityCount() const noexcept {
45 return upcast(this)->entities.size();
46 }
47
48 const Entity* FilamentInstance::getEntities() const noexcept {
49 const auto& entities = upcast(this)->entities;
50 return entities.empty() ? nullptr : entities.data();
51 }
52
53 Entity FilamentInstance::getRoot() const noexcept {
54 return upcast(this)->root;
55 }
56
57 Animator* FilamentInstance::getAnimator() noexcept {
58 return upcast(this)->getAnimator();
59 }
60
61 } // namespace gltfio