39 step_sync(STEP_PREVIOUS, initial_time - 1.0f);
40 step_sync(STEP_NEXT, initial_time + 1.0f);
41 inst_.set_time(initial_time);
51 reinterpret_cast<VelocityModule *
>(velocity)->step_object_sync(ob, object_key);
83 if (!has_motion && !has_deform) {
97 vel.obj.resource_id = resource_id;
100 if (step_ == STEP_CURRENT) {
102 if (vel.obj.ofs[STEP_PREVIOUS] == -1) {
104 object_steps[STEP_PREVIOUS]->get_or_resize(vel.obj.ofs[STEP_PREVIOUS]) = ob->
obmat;
106 if (vel.obj.ofs[STEP_NEXT] == -1) {
114 auto add_cb = [&]() {
129 if (
data.pos_buf ==
nullptr) {
135 if (step_ == STEP_CURRENT && has_motion ==
true && has_deform ==
false) {
140 has_motion = (obmat_curr != obmat_prev);
143 has_motion = (obmat_curr != obmat_prev || obmat_curr != obmat_next);
148 if (!has_motion && !has_deform) {
149 std::cout <<
"Detected no motion on " << ob->
id.
name << std::endl;
152 std::cout <<
"Geometry Motion on " << ob->
id.
name << std::endl;
155 std::cout <<
"Object Motion on " << ob->
id.
name << std::endl;
159 if (!has_motion && !has_deform) {
193 geom.ofs *
sizeof(
float4),
195 geom.len *
sizeof(
float4));
202 vel.geo.len[step_] = geom.
len;
203 vel.geo.ofs[step_] = geom.
ofs;
211 auto swap_steps = [&](eVelocityStep step_a, eVelocityStep step_b) {
217 vel.obj.ofs[step_a] = vel.obj.ofs[step_b];
218 vel.obj.ofs[step_b] = (
uint)-1;
219 vel.geo.ofs[step_a] = vel.geo.ofs[step_b];
220 vel.geo.len[step_a] = vel.geo.len[step_b];
221 vel.geo.ofs[step_b] = (
uint)-1;
222 vel.geo.len[step_b] = (
uint)-1;
231 swap_steps(eVelocityStep::STEP_PREVIOUS, eVelocityStep::STEP_CURRENT);
235 swap_steps(eVelocityStep::STEP_PREVIOUS, eVelocityStep::STEP_NEXT);
243 step_ = STEP_CURRENT;
257 if (item.value.obj.resource_id == (
uint)-1) {
258 deleted_obj.
append(item.key);
261 max_resource_id_ =
max_uu(max_resource_id_, item.value.obj.resource_id);
265 if (deleted_obj.
size() > 0) {
273 for (
auto key : deleted_obj) {
288 vel.geo.do_deform = pos_buf !=
nullptr &&
292 vel.geo.do_deform = (vel.geo.len[STEP_PREVIOUS] == vel.geo.len[STEP_CURRENT]) &&
293 (vel.geo.len[STEP_NEXT] == vel.geo.len[STEP_CURRENT]);
297 vel.obj.resource_id = (
uint)-1;
308 bool VelocityModule::object_has_velocity(
const Object *ob)
321 const bool object_moves =
true;
326 bool VelocityModule::object_is_deform(
const Object *ob)
General operations, lookup, etc. for blender objects.
int BKE_object_is_deform_modified(struct Scene *scene, struct Object *ob)
bool BKE_object_moves_in_time(const struct Object *object, bool recurse_parent)
MINLINE unsigned int power_of_2_max_u(unsigned int x)
MINLINE uint max_uu(uint a, uint b)
MINLINE int max_ii(int a, int b)
struct Depsgraph Depsgraph
@ EEVEE_RENDER_PASS_VECTOR
Types and defines for representing Rigid Body entities.
#define DRW_shgroup_uniform_block_ref(shgroup, name, ubo)
#define DRW_shgroup_storage_block_ref(shgroup, name, ssbo)
void GPU_storagebuf_copy_sub_from_vertbuf(GPUStorageBuf *ssbo, GPUVertBuf *src, uint dst_offset, uint src_offset, uint copy_size)
Copy a part of a vertex buffer to a storage buffer.
uint GPU_vertbuf_get_vertex_len(const GPUVertBuf *verts)
struct GPUVertBuf GPUVertBuf
void append(const T &value)
const CameraData & data_get() const
eViewLayerEEVEEPassType enabled_passes_get() const
Map< ID *, VelocityGeometryData > geometry_map
Map< ObjectKey, VelocityObjectData > velocity_map
std::array< CameraDataBuf *, 3 > camera_steps
std::array< VelocityObjectBuf *, 3 > object_steps
VelocityIndexBuf indirection_buf
bool camera_has_motion() const
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)
const Depsgraph * depsgraph
GPUVertBuf * DRW_cache_object_pos_vertbuf_get(Object *ob)
struct GPUVertBuf * DRW_curves_pos_buffer_get(struct Object *object)
void DRW_render_object_iter(void *vedata, RenderEngine *engine, struct Depsgraph *depsgraph, void(*callback)(void *vedata, Object *ob, RenderEngine *engine, struct Depsgraph *depsgraph))
uint32_t DRW_object_resource_id_get(Object *UNUSED(ob))
smooth(Type::VEC3, "prev") .smooth(Type CameraData
static void step_object_sync_render(void *velocity, Object *ob, RenderEngine *UNUSED(engine), Depsgraph *UNUSED(depsgraph))
struct RigidBodyOb * rigidbody_object