This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller Scene] Parse GLTF primitives #38064
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dce50b1
Bump buildroot
bdero 09bb019
[Impeller Scene] Parse GLTF geometry
bdero a9d668e
Add Divisor cast
bdero c34e192
Address comments
bdero ab0bb2f
Improve scalar conversion mechanism
bdero 8e807cb
Use source type for divisor
bdero c917e70
Better wording
bdero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "impeller/scene/importer/conversions.h" | ||
|
||
#include <cstring> | ||
|
||
#include "impeller/scene/importer/scene_flatbuffers.h" | ||
|
||
namespace impeller { | ||
namespace scene { | ||
namespace importer { | ||
|
||
Matrix ToMatrix(const std::vector<double>& m) { | ||
return Matrix(m[0], m[1], m[2], m[3], // | ||
m[4], m[5], m[6], m[7], // | ||
m[8], m[9], m[10], m[11], // | ||
m[12], m[13], m[14], m[15]); | ||
} | ||
|
||
//----------------------------------------------------------------------------- | ||
/// Flatbuffers -> Impeller | ||
/// | ||
|
||
Matrix ToMatrix(const fb::Matrix& m) { | ||
auto& a = *m.m(); | ||
return Matrix(a[0], a[1], a[2], a[3], // | ||
a[4], a[5], a[6], a[7], // | ||
a[8], a[9], a[10], a[11], // | ||
a[12], a[13], a[14], a[15]); | ||
} | ||
|
||
Vector2 ToVector2(const fb::Vec2& v) { | ||
return Vector2(v.x(), v.y()); | ||
} | ||
|
||
Vector3 ToVector3(const fb::Vec3& v) { | ||
return Vector3(v.x(), v.y(), v.z()); | ||
} | ||
|
||
Vector4 ToVector4(const fb::Vec4& v) { | ||
return Vector4(v.x(), v.y(), v.z(), v.w()); | ||
} | ||
|
||
Color ToColor(const fb::Color& c) { | ||
return Color(c.r(), c.g(), c.b(), c.a()); | ||
} | ||
|
||
//----------------------------------------------------------------------------- | ||
/// Impeller -> Flatbuffers | ||
/// | ||
|
||
std::unique_ptr<fb::Matrix> ToFBMatrix(const Matrix& m) { | ||
auto array = std::array<Scalar, 16>{m.m[0], m.m[1], m.m[2], m.m[3], // | ||
m.m[4], m.m[5], m.m[6], m.m[7], // | ||
m.m[8], m.m[9], m.m[10], m.m[11], // | ||
m.m[12], m.m[13], m.m[14], m.m[15]}; | ||
return std::make_unique<fb::Matrix>(array); | ||
} | ||
|
||
fb::Vec2 ToFBVec2(const Vector2 v) { | ||
return fb::Vec2(v.x, v.y); | ||
} | ||
|
||
fb::Vec3 ToFBVec3(const Vector3 v) { | ||
return fb::Vec3(v.x, v.y, v.z); | ||
} | ||
|
||
fb::Vec4 ToFBVec4(const Vector4 v) { | ||
return fb::Vec4(v.x, v.y, v.z, v.w); | ||
} | ||
|
||
fb::Color ToFBColor(const Color c) { | ||
return fb::Color(c.red, c.green, c.blue, c.alpha); | ||
} | ||
|
||
} // namespace importer | ||
} // namespace scene | ||
} // namespace impeller |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto question about include guards in this file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#pragma once | ||
|
||
#include <cstddef> | ||
#include <map> | ||
|
||
#include "impeller/geometry/matrix.h" | ||
#include "impeller/scene/importer/scene_flatbuffers.h" | ||
|
||
namespace impeller { | ||
namespace scene { | ||
namespace importer { | ||
|
||
Matrix ToMatrix(const std::vector<double>& m); | ||
|
||
//----------------------------------------------------------------------------- | ||
/// Flatbuffers -> Impeller | ||
/// | ||
|
||
Matrix ToMatrix(const fb::Matrix& m); | ||
|
||
Vector2 ToVector2(const fb::Vec2& c); | ||
|
||
Vector3 ToVector3(const fb::Vec3& c); | ||
|
||
Vector4 ToVector4(const fb::Vec4& c); | ||
|
||
Color ToColor(const fb::Color& c); | ||
|
||
//----------------------------------------------------------------------------- | ||
/// Impeller -> Flatbuffers | ||
/// | ||
|
||
std::unique_ptr<fb::Matrix> ToFBMatrix(const Matrix& m); | ||
|
||
fb::Vec2 ToFBVec2(const Vector2 v); | ||
|
||
fb::Vec3 ToFBVec3(const Vector3 v); | ||
|
||
fb::Vec4 ToFBVec4(const Vector4 v); | ||
|
||
fb::Color ToFBColor(const Color c); | ||
|
||
} // namespace importer | ||
} // namespace scene | ||
} // namespace impeller |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,19 @@ | |
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#pragma once | ||
|
||
#include <array> | ||
#include <memory> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto question about include guards in this file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
|
||
#include "flutter/fml/mapping.h" | ||
#include "impeller/scene/importer/mesh_flatbuffers.h" | ||
#include "impeller/scene/importer/scene_flatbuffers.h" | ||
|
||
namespace impeller { | ||
namespace scene { | ||
namespace importer { | ||
|
||
bool ParseGLTF(const fml::Mapping& source_mapping, fb::MeshT& out_mesh); | ||
bool ParseGLTF(const fml::Mapping& source_mapping, fb::SceneT& out_scene); | ||
|
||
} | ||
} // namespace scene | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this based off of an old commit? I thought scenec was the name we settled on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured it would make sense to call the frontend/executable name "scenec" and the namespace/library with the importing utilities "importer", similar to how "impellerc" is the frontend for the "compiler" lib. Perhaps I should use the
scenec
name all around?