Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] Fix build failures for Impeller Scene #40635

Merged
merged 1 commit into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions impeller/scene/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class Camera {
Vector3 position_ = Vector3();
Vector3 target_ = Vector3(0, 0, -1);
Vector3 up_ = Vector3(0, -1, 0);
Scalar z_near_ = 0.1;
Scalar z_far_ = 1000;
Scalar z_near_ = 0.1f;
Scalar z_far_ = 1000.0f;

mutable std::optional<Matrix> transform_;
};
Expand Down
20 changes: 16 additions & 4 deletions lib/ui/painting/scene/scene_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,22 @@ std::string SceneNode::initFromAsset(const std::string& asset_name,
}

static impeller::Matrix ToMatrix(const tonic::Float64List& matrix4) {
return impeller::Matrix(matrix4[0], matrix4[1], matrix4[2], matrix4[3], //
matrix4[4], matrix4[5], matrix4[6], matrix4[7], //
matrix4[8], matrix4[9], matrix4[10], matrix4[11], //
matrix4[12], matrix4[13], matrix4[14], matrix4[15]);
return impeller::Matrix(static_cast<impeller::Scalar>(matrix4[0]),
static_cast<impeller::Scalar>(matrix4[1]),
static_cast<impeller::Scalar>(matrix4[2]),
static_cast<impeller::Scalar>(matrix4[3]),
static_cast<impeller::Scalar>(matrix4[4]),
static_cast<impeller::Scalar>(matrix4[5]),
static_cast<impeller::Scalar>(matrix4[6]),
static_cast<impeller::Scalar>(matrix4[7]),
static_cast<impeller::Scalar>(matrix4[8]),
static_cast<impeller::Scalar>(matrix4[9]),
static_cast<impeller::Scalar>(matrix4[10]),
static_cast<impeller::Scalar>(matrix4[11]),
static_cast<impeller::Scalar>(matrix4[12]),
static_cast<impeller::Scalar>(matrix4[13]),
static_cast<impeller::Scalar>(matrix4[14]),
static_cast<impeller::Scalar>(matrix4[15]));
}

void SceneNode::initFromTransform(const tonic::Float64List& matrix4) {
Expand Down
22 changes: 17 additions & 5 deletions lib/ui/painting/scene/scene_shader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,30 @@ void SceneShader::Create(Dart_Handle wrapper, Dart_Handle scene_node_handle) {

void SceneShader::SetCameraTransform(const tonic::Float64List& matrix4) {
camera_transform_ =
impeller::Matrix(matrix4[0], matrix4[1], matrix4[2], matrix4[3], //
matrix4[4], matrix4[5], matrix4[6], matrix4[7], //
matrix4[8], matrix4[9], matrix4[10], matrix4[11], //
matrix4[12], matrix4[13], matrix4[14], matrix4[15]);
impeller::Matrix(static_cast<impeller::Scalar>(matrix4[0]),
static_cast<impeller::Scalar>(matrix4[1]),
static_cast<impeller::Scalar>(matrix4[2]),
static_cast<impeller::Scalar>(matrix4[3]),
static_cast<impeller::Scalar>(matrix4[4]),
static_cast<impeller::Scalar>(matrix4[5]),
static_cast<impeller::Scalar>(matrix4[6]),
static_cast<impeller::Scalar>(matrix4[7]),
static_cast<impeller::Scalar>(matrix4[8]),
static_cast<impeller::Scalar>(matrix4[9]),
static_cast<impeller::Scalar>(matrix4[10]),
static_cast<impeller::Scalar>(matrix4[11]),
static_cast<impeller::Scalar>(matrix4[12]),
static_cast<impeller::Scalar>(matrix4[13]),
static_cast<impeller::Scalar>(matrix4[14]),
static_cast<impeller::Scalar>(matrix4[15]));
}

static impeller::Matrix DefaultCameraTransform() {
// TODO(bdero): There's no way to know what the draw area will be yet, so
// make the DlSceneColorSource camera transform optional and
// defer this default (or parameterize the camera instead).
return impeller::Matrix::MakePerspective(
impeller::Degrees(45), impeller::ISize{800, 600}, 0.1, 1000) *
impeller::Degrees(45), impeller::ISize{800, 600}, 0.1f, 1000) *
impeller::Matrix::MakeLookAt({0, 0, -5}, {0, 0, 0}, {0, 1, 0});
}

Expand Down