Blender V4.3
grease_pencil_io_intern.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BLI_bounds.hh"
6#include "BLI_color.hh"
7#include "BLI_function_ref.hh"
9#include "BLI_string_ref.hh"
10#include "BLI_vector.hh"
11
12#include "grease_pencil_io.hh"
13
14#include <cstdint>
15#include <optional>
16
17#pragma once
18
23struct Scene;
24struct Object;
25struct Material;
26struct RegionView3D;
28class Layer;
29class Drawing;
30} // namespace blender::bke::greasepencil
31
33
35 protected:
38
39 Object *object_ = nullptr;
40
41 public:
42 GreasePencilImporter(const IOContext &context, const ImportParams &params);
43
45 int32_t create_material(StringRefNull name, bool stroke, bool fill);
46};
47
49 public:
50 struct ObjectInfo {
52 float depth;
53 };
54
55 protected:
58
59 /* Camera projection matrix, only available with an active camera. */
60 std::optional<float4x4> camera_persmat_;
62
63 public:
64 GreasePencilExporter(const IOContext &context, const ExportParams &params);
65
66 void prepare_render_params(Scene &scene, int frame_number);
67
69 const Span<ColorGeometry4f> vertex_colors);
70 static float compute_average_stroke_opacity(const Span<float> opacities);
71
72 /* Returns a value if point sizes are all equal. */
73 static std::optional<float> try_get_uniform_point_width(const RegionView3D &rv3d,
74 const Span<float3> world_positions,
75 const Span<float> radii);
76
78
79 using WriteStrokeFn = FunctionRef<void(const Span<float3> positions,
80 bool cyclic,
81 const ColorGeometry4f &color,
82 float opacity,
83 std::optional<float> width,
84 bool round_cap,
85 bool is_outline)>;
86
87 void foreach_stroke_in_layer(const Object &object,
88 const bke::greasepencil::Layer &layer,
89 const bke::greasepencil::Drawing &drawing,
90 WriteStrokeFn stroke_fn);
91
92 float2 project_to_screen(const float4x4 &transform, const float3 &position) const;
93};
94
95} // namespace blender::io::grease_pencil
GreasePencilExporter(const IOContext &context, const ExportParams &params)
static std::optional< float > try_get_uniform_point_width(const RegionView3D &rv3d, const Span< float3 > world_positions, const Span< float > radii)
static ColorGeometry4f compute_average_stroke_color(const Material &material, const Span< ColorGeometry4f > vertex_colors)
void prepare_render_params(Scene &scene, int frame_number)
void foreach_stroke_in_layer(const Object &object, const bke::greasepencil::Layer &layer, const bke::greasepencil::Drawing &drawing, WriteStrokeFn stroke_fn)
static float compute_average_stroke_opacity(const Span< float > opacities)
float2 project_to_screen(const float4x4 &transform, const float3 &position) const
GreasePencilImporter(const IOContext &context, const ImportParams &params)
int32_t create_material(StringRefNull name, bool stroke, bool fill)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
signed int int32_t
Definition stdint.h:77