Blender  V3.3
eevee_velocity.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2021 Blender Foundation.
3  */
4 
14 #pragma once
15 
16 #include "BLI_map.hh"
17 
18 #include "eevee_shader_shared.hh"
19 #include "eevee_sync.hh"
20 
21 namespace blender::eevee {
22 
23 /* -------------------------------------------------------------------- */
30  public:
33  ID *id;
34  };
37  GPUVertBuf *pos_buf = nullptr;
38  /* Offset in the #VelocityGeometryBuf to the start of the data. In vertex. */
39  int ofs;
40  /* Length of the vertex buffer. In vertex. */
41  int len;
42  };
52  std::array<VelocityObjectBuf *, 3> object_steps;
54  std::array<VelocityGeometryBuf *, 3> geometry_steps;
58  VelocityIndexBuf indirection_buf;
59 
63  std::array<CameraDataBuf *, 3> camera_steps;
64 
65  private:
66  Instance &inst_;
67 
68  eVelocityStep step_ = STEP_CURRENT;
69 
70  public:
71  VelocityModule(Instance &inst) : inst_(inst)
72  {
73  for (VelocityObjectBuf *&step_buf : object_steps) {
74  step_buf = new VelocityObjectBuf();
75  }
76  for (VelocityGeometryBuf *&step_buf : geometry_steps) {
77  step_buf = new VelocityGeometryBuf();
78  }
79  for (CameraDataBuf *&step_buf : camera_steps) {
80  step_buf = new CameraDataBuf();
81  /* */
82  }
83  };
84 
86  {
87  for (VelocityObjectBuf *step_buf : object_steps) {
88  delete step_buf;
89  }
90  for (VelocityGeometryBuf *step_buf : geometry_steps) {
91  delete step_buf;
92  }
93  for (CameraDataBuf *step_buf : camera_steps) {
94  delete step_buf;
95  }
96  }
97 
98  void init();
99 
100  void step_camera_sync();
101  void step_sync(eVelocityStep step, float time);
102 
103  /* Gather motion data. Returns true if the object **can** have motion. */
104  bool step_object_sync(Object *ob, ObjectKey &object_key, int recalc = 0);
105 
106  /* Moves next frame data to previous frame data. Nullify next frame data. */
107  void step_swap();
108 
109  void begin_sync();
110  void end_sync();
111 
112  void bind_resources(DRWShadingGroup *grp);
113 
114  bool camera_has_motion() const;
115 
116  private:
117  bool object_has_velocity(const Object *ob);
118  bool object_is_deform(const Object *ob);
119 };
120 
123 } // namespace blender::eevee
struct GPUVertBuf GPUVertBuf
A running instance of the engine.
Map< ID *, VelocityGeometryData > geometry_map
Map< ObjectKey, VelocityObjectData > velocity_map
std::array< CameraDataBuf *, 3 > camera_steps
std::array< VelocityObjectBuf *, 3 > object_steps
std::array< VelocityGeometryBuf *, 3 > geometry_steps
void bind_resources(DRWShadingGroup *grp)
void step_sync(eVelocityStep step, float time)
bool step_object_sync(Object *ob, ObjectKey &object_key, int recalc=0)
double time
Frequency::PASS Frequency::PASS VelocityIndex
vec_base< int32_t, 3 > int3
Definition: DNA_ID.h:368