Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gpencil_io_base.hh « intern « gpencil « io « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a89b723ed6cffad46268c956bfe3e539f0cee561 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* SPDX-License-Identifier: GPL-2.0-or-later
 * Copyright 2020 Blender Foundation. All rights reserved. */
#pragma once

/** \file
 * \ingroup bgpencil
 */

#include "BLI_float4x4.hh"
#include "BLI_math_vec_types.hh"
#include "BLI_vector.hh"

#include "DNA_space_types.h" /* for FILE_MAX */

#include "gpencil_io.h"

struct Depsgraph;
struct Main;
struct Object;
struct RegionView3D;
struct Scene;

struct bGPDlayer;
struct bGPDstroke;
struct bGPdata;

using blender::Vector;

namespace blender::io::gpencil {

class GpencilIO {
 public:
  GpencilIO(const GpencilIOParams *iparams);

  void frame_number_set(int value);
  void prepare_camera_params(Scene *scene, const GpencilIOParams *iparams);

 protected:
  GpencilIOParams params_;

  bool invert_axis_[2];
  float4x4 diff_mat_;
  char filepath_[FILE_MAX];

  /* Used for sorting objects. */
  struct ObjectZ {
    float zdepth;
    struct Object *ob;
  };

  /** List of included objects. */
  blender::Vector<ObjectZ> ob_list_;

  /* Data for easy access. */
  struct Depsgraph *depsgraph_;
  struct bGPdata *gpd_;
  struct Main *bmain_;
  struct Scene *scene_;
  struct RegionView3D *rv3d_;

  int16_t winx_, winy_;
  int16_t render_x_, render_y_;
  float camera_ratio_;
  rctf camera_rect_;

  float2 offset_;

  int cfra_;

  float stroke_color_[4], fill_color_[4];

  /* Geometry functions. */
  /** Convert to screenspace. */
  bool gpencil_3D_point_to_screen_space(const float3 co, float2 &r_co);
  /** Convert to render space. */
  float2 gpencil_3D_point_to_render_space(const float3 co);
  /** Convert to 2D. */
  float2 gpencil_3D_point_to_2D(const float3 co);

  /** Get radius of point. */
  float stroke_point_radius_get(struct bGPDlayer *gpl, struct bGPDstroke *gps);
  /** Create a list of selected objects sorted from back to front */
  void create_object_list();

  bool is_camera_mode();

  float stroke_average_opacity_get();

  void prepare_layer_export_matrix(struct Object *ob, struct bGPDlayer *gpl);
  void prepare_stroke_export_colors(struct Object *ob, struct bGPDstroke *gps);

  /* Calculate selected strokes boundbox. */
  void selected_objects_boundbox_calc();
  void selected_objects_boundbox_get(rctf *boundbox);
  /**
   * Set file input_text full path.
   * \param filepath: Path of the file provided by save dialog.
   */
  void filepath_set(const char *filepath);

 private:
  float avg_opacity_;
  bool is_camera_;
  rctf select_boundbox_;

  /* Camera matrix. */
  float persmat_[4][4];
};

}  // namespace blender::io::gpencil