Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Side by Side Diff: chrome/browser/android/vr_shell/gltf_asset.cc

Issue 2757213003: Implementing glTF 1.0 parser (Closed)
Patch Set: Removing CHECKs when parsing fails. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/vr_shell/gltf_asset.h"
6
7 #include <unordered_map>
8
9 #include "base/logging.h"
10
11 namespace vr_shell {
12
13 namespace gltf {
14
15 const std::unordered_map<std::string, Type> kTypeMap = {
16 {"SCALAR", SCALAR}, {"VEC2", VEC2}, {"VEC3", VEC3}, {"VEC4", VEC4},
17 {"MAT2", MAT2}, {"MAT3", MAT3}, {"MAT4", MAT4},
18 };
19
20 Type GetType(const std::string& type) {
21 auto it = kTypeMap.find(type);
22 if (it == kTypeMap.end())
23 return UNKNOWN;
24 return it->second;
25 }
26
27 Mesh::Primitive::Primitive() : indices(nullptr), mode(4) {}
28
29 Mesh::Primitive::~Primitive() = default;
30
31 Mesh::Mesh() {}
32
33 Mesh::~Mesh() = default;
34
35 Node::Node() {}
36
37 Node::~Node() = default;
38
39 Scene::Scene() {}
40
41 Scene::~Scene() = default;
42
43 Asset::Asset() : scene_(nullptr) {}
44
45 Asset::~Asset() = default;
46
47 std::size_t Asset::AddBuffer(std::unique_ptr<Buffer> buffer) {
48 auto index = buffers_.size();
49 buffers_.push_back(std::move(buffer));
50 return index;
51 }
52
53 std::size_t Asset::AddBufferView(std::unique_ptr<BufferView> buffer_view) {
54 auto index = buffer_views_.size();
55 buffer_views_.push_back(std::move(buffer_view));
56 return index;
57 }
58
59 std::size_t Asset::AddAccessor(std::unique_ptr<Accessor> accessor) {
60 auto index = accessors_.size();
61 accessors_.push_back(std::move(accessor));
62 return index;
63 }
64
65 std::size_t Asset::AddMesh(std::unique_ptr<Mesh> mesh) {
66 auto index = meshes_.size();
67 meshes_.push_back(std::move(mesh));
68 return index;
69 }
70
71 std::size_t Asset::AddNode(std::unique_ptr<Node> node) {
72 auto index = nodes_.size();
73 nodes_.push_back(std::move(node));
74 return index;
75 }
76
77 std::size_t Asset::AddScene(std::unique_ptr<Scene> scene) {
78 auto index = scenes_.size();
79 scenes_.push_back(std::move(scene));
80 return index;
81 }
82
83 const Buffer* Asset::GetBuffer(std::size_t id) const {
84 return id < buffers_.size() ? buffers_[id].get() : nullptr;
85 }
86
87 const BufferView* Asset::GetBufferView(std::size_t id) const {
88 return id < buffer_views_.size() ? buffer_views_[id].get() : nullptr;
89 }
90
91 const Accessor* Asset::GetAccessor(std::size_t id) const {
92 return id < accessors_.size() ? accessors_[id].get() : nullptr;
93 }
94
95 const Mesh* Asset::GetMesh(std::size_t id) const {
96 return id < meshes_.size() ? meshes_[id].get() : nullptr;
97 }
98
99 const Node* Asset::GetNode(std::size_t id) const {
100 return id < nodes_.size() ? nodes_[id].get() : nullptr;
101 }
102
103 const Scene* Asset::GetScene(std::size_t id) const {
104 return id < scenes_.size() ? scenes_[id].get() : nullptr;
105 }
106
107 } // namespace gltf
108
109 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698