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

overlay_instance.hh « overlay « engines « draw « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 09029963c9a7f3ee3fa8ccb967e977500e856208 (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
/* SPDX-License-Identifier: GPL-2.0-or-later */

/** \file
 * \ingroup overlay
 */

#pragma once

#include "draw_manager.hh"

#include "overlay_background.hh"
#include "overlay_grid.hh"

namespace blender::draw::overlay {

class ShaderCache {
  Map<StringRefNull, std::array<GPUShader *, 2>> cache;

  int clipping_enabled = 0;
};

class SceneResources {
  ShaderCache shaders;

  // UniformBuffer<ThemeColorData> theme_colors;
  // Texture color_ramp = {"color_ramp"};

  void weight_ramp_init()
  {
    /* Weight Painting color ramp texture */
    // bool user_weight_ramp = (U.flag & USER_CUSTOM_RANGE) != 0;

    // if (weight_ramp_custom != user_weight_ramp ||
    //     (user_weight_ramp && memcmp(&weight_ramp_copy, &U.coba_weight, sizeof(ColorBand)) != 0))
    //     {
    //   DRW_TEXTURE_FREE_SAFE(G_draw.weight_ramp);
    // }

    // if (G_draw.weight_ramp == NULL) {
    //   weight_ramp_custom = user_weight_ramp;
    //   memcpy(&weight_ramp_copy, &U.coba_weight, sizeof(ColorBand));

    //   G_draw.weight_ramp = DRW_create_weight_colorramp_texture();
    // }
  }
};

class Instance {
 public:
  ShaderCache shaders;

  /* WORKAROUND: Legacy. Move to grid pass. */
  GPUUniformBuf *grid_ubo = nullptr;

  /** Global types. */
  Resources resources;
  State state;

  /** Overlay types. */
  Background background;
  Grid grid;

  ~Instance()
  {
    DRW_UBO_FREE_SAFE(grid_ubo);
  }

  void init();
  void begin_sync();
  void object_sync(ObjectRef &ob_ref);
  void end_sync();
  void draw(Manager &manager);
};

}  // namespace blender::draw::overlay