Blender V4.5
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_types.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
22
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_;
64
65 public:
66 GreasePencilExporter(const IOContext &context, const ExportParams &params);
67
68 void prepare_render_params(Scene &scene, int frame_number);
69
71 const Span<ColorGeometry4f> vertex_colors);
72 static float compute_average_stroke_opacity(const Span<float> opacities);
73
74 /* Returns a value if point sizes are all equal. */
75 static std::optional<float> try_get_uniform_point_width(const RegionView3D &rv3d,
76 const Span<float3> world_positions,
77 const Span<float> radii);
78
80
81 using WriteStrokeFn = FunctionRef<void(const Span<float3> positions,
82 bool cyclic,
84 float opacity,
85 std::optional<float> width,
86 bool round_cap,
87 bool is_outline)>;
88
89 void foreach_stroke_in_layer(const Object &object,
90 const bke::greasepencil::Layer &layer,
91 const bke::greasepencil::Drawing &drawing,
92 WriteStrokeFn stroke_fn);
93
94 float2 project_to_screen(const float4x4 &transform, const float3 &position) const;
95
96 bool is_selected_frame(const GreasePencil &grease_pencil, int frame_number) const;
97
98 private:
99 std::optional<Bounds<float2>> compute_screen_space_drawing_bounds(
100 const RegionView3D &rv3d,
101 Object &object,
102 int layer_index,
103 const bke::greasepencil::Drawing &drawing);
104 std::optional<Bounds<float2>> compute_objects_bounds(
105 const RegionView3D &rv3d,
106 const Depsgraph &depsgraph,
108 int frame_number);
109};
110
111} // namespace blender::io::grease_pencil
BPy_StructRNA * depsgraph
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
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)
bool is_selected_frame(const GreasePencil &grease_pencil, int frame_number) const
static float compute_average_stroke_opacity(const Span< float > opacities)
float2 project_to_screen(const float4x4 &transform, const float3 &position) const
FunctionRef< void(const Span< float3 > positions, bool cyclic, const ColorGeometry4f &color, float opacity, std::optional< float > width, bool round_cap, bool is_outline)> WriteStrokeFn
GreasePencilImporter(const IOContext &context, const ImportParams &params)
int32_t create_material(StringRefNull name, bool stroke, bool fill)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
MatBase< float, 4, 4 > float4x4
VecBase< float, 2 > float2
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
Definition BLI_color.hh:342
VecBase< float, 3 > float3