| Flutter Impeller |

mesh.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 "impeller/scene/mesh.h"
6
7 #include <memory>
8 #include <optional>
9
10 #include "impeller/base/validation.h"
11 #include "impeller/scene/material.h"
12 #include "impeller/scene/pipeline_key.h"
13 #include "impeller/scene/scene_encoder.h"
14
15 namespace impeller {
16 namespace scene {
17
18 Mesh::Mesh() = default;
19 Mesh::~Mesh() = default;
20
21 void Mesh::AddPrimitive(Primitive mesh) {
22 if (mesh.geometry == nullptr) {
23 VALIDATION_LOG << "Mesh geometry cannot be null.";
24 }
25 if (mesh.material == nullptr) {
26 VALIDATION_LOG << "Mesh material cannot be null.";
27 }
28
29 primitives_.push_back(std::move(mesh));
30 }
31
32 std::vector<Mesh::Primitive>& Mesh::GetPrimitives() {
33 return primitives_;
34 }
35
36 bool Mesh::Render(SceneEncoder& encoder,
37 const Matrix& transform,
38 const std::shared_ptr<Texture>& joints) const {
39 for (const auto& mesh : primitives_) {
40 mesh.geometry->SetJointsTexture(joints);
41 SceneCommand command = {
42 .label = "Mesh Primitive",
43 .transform = transform,
44 .geometry = mesh.geometry.get(),
45 .material = mesh.material.get(),
46 };
47 encoder.Add(command);
48 }
49 return true;
50 }
51
52 } // namespace scene
53 } // namespace impeller
pipeline_key.h
impeller::scene::Mesh::GetPrimitives
std::vector< Primitive > & GetPrimitives()
Definition: mesh.cc:32
impeller::scene::Mesh::Mesh
Mesh()
impeller::scene::Mesh::Primitive
Definition: mesh.h:23
validation.h
scene_encoder.h
impeller::scene::SceneEncoder::Add
void Add(const SceneCommand &command)
Definition: scene_encoder.cc:18
impeller::scene::Mesh::Render
bool Render(SceneEncoder &encoder, const Matrix &transform, const std::shared_ptr< Texture > &joints) const
Definition: mesh.cc:36
material.h
impeller::scene::Mesh::AddPrimitive
void AddPrimitive(Primitive mesh_)
Definition: mesh.cc:21
impeller::scene::Mesh::~Mesh
~Mesh()
mesh.h
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:67
impeller::scene::Mesh::Primitive::material
std::shared_ptr< Material > material
Definition: mesh.h:25
impeller::scene::SceneCommand
Definition: scene_encoder.h:23
impeller::scene::SceneEncoder
Definition: scene_encoder.h:30
impeller::scene::SceneCommand::label
std::string label
Definition: scene_encoder.h:24
impeller
Definition: aiks_context.cc:10
impeller::scene::Mesh::Primitive::geometry
std::shared_ptr< Geometry > geometry
Definition: mesh.h:24
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37