Mesh Edit Selection: Use last_update for update detection
Rel #134690 Pull Request: https://projects.blender.org/blender/blender/pulls/134881
This commit is contained in:
committed by
Clément Foucault
parent
e0829f9e55
commit
c3eba77c2d
@@ -11,6 +11,7 @@
|
||||
#include "DNA_ID.h"
|
||||
|
||||
#include "BLI_array.hh"
|
||||
#include "BLI_math_matrix_types.hh"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_sys_types.h" /* for bool and uint */
|
||||
|
||||
@@ -62,8 +63,10 @@ struct SELECTID_Context {
|
||||
short select_mode;
|
||||
|
||||
/* To check for updates. */
|
||||
float persmat[4][4];
|
||||
bool is_dirty(RegionView3D *rv3d);
|
||||
blender::float4x4 persmat;
|
||||
uint64_t depsgraph_last_update = 0;
|
||||
|
||||
bool is_dirty(Depsgraph *depsgraph, RegionView3D *rv3d);
|
||||
};
|
||||
|
||||
/* `draw_select_buffer.cc` */
|
||||
|
||||
@@ -205,14 +205,12 @@ static void select_cache_init(void *vedata)
|
||||
DrawData *data = DRW_drawdata_ensure(
|
||||
&obj_eval->id, &draw_engine_select_type, sizeof(SELECTID_ObjectData), nullptr, nullptr);
|
||||
SELECTID_ObjectData *sel_data = reinterpret_cast<SELECTID_ObjectData *>(data);
|
||||
|
||||
data->recalc = 0;
|
||||
sel_data->drawn_index = sel_id;
|
||||
sel_data->in_pass = false;
|
||||
sel_data->is_drawn = false;
|
||||
}
|
||||
|
||||
copy_m4_m4(e_data.context.persmat, draw_ctx->rv3d->persmat);
|
||||
e_data.context.persmat = float4x4(draw_ctx->rv3d->persmat);
|
||||
e_data.context.index_drawn_len = 1;
|
||||
select_engine_framebuffer_setup();
|
||||
GPU_framebuffer_bind(e_data.framebuffer_select_id);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
#include "BLI_math_matrix.hh"
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_array_utils.h"
|
||||
@@ -37,24 +38,26 @@
|
||||
using blender::int2;
|
||||
using blender::Span;
|
||||
|
||||
bool SELECTID_Context::is_dirty(RegionView3D *rv3d)
|
||||
bool SELECTID_Context::is_dirty(Depsgraph *depsgraph, RegionView3D *rv3d)
|
||||
{
|
||||
/* Check if the viewport has changed. */
|
||||
float(*persmat)[4] = rv3d->persmat;
|
||||
bool is_dirty = !compare_m4m4(this->persmat, persmat, FLT_EPSILON);
|
||||
uint64_t last_update = this->depsgraph_last_update;
|
||||
this->depsgraph_last_update = DEG_get_update_count(depsgraph);
|
||||
|
||||
if (!is_dirty) {
|
||||
/* Check if any of the drawn objects have been transformed. */
|
||||
for (Object *obj_eval : this->objects) {
|
||||
DrawData *data = DRW_drawdata_get(&obj_eval->id, &draw_engine_select_type);
|
||||
if (!data || (data->recalc & ID_RECALC_TRANSFORM)) {
|
||||
is_dirty = true;
|
||||
break;
|
||||
}
|
||||
/* Check if the viewport has changed.
|
||||
* This can happen when triggering the selection operator *while* playing back animation and
|
||||
* looking through an animated camera. */
|
||||
if (!blender::math::is_equal(this->persmat, blender::float4x4(rv3d->persmat), FLT_EPSILON)) {
|
||||
return true;
|
||||
}
|
||||
/* Check if any of the drawn objects have been transformed.
|
||||
* This can happen when triggering the selection operator *while* playing back animation on an
|
||||
* edited mesh. */
|
||||
for (Object *obj_eval : this->objects) {
|
||||
if (obj_eval->runtime->last_update_transform > last_update) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return is_dirty;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -83,7 +86,7 @@ uint *DRW_select_buffer_read(
|
||||
|
||||
DRW_gpu_context_enable();
|
||||
|
||||
if (select_ctx->is_dirty(rv3d)) {
|
||||
if (select_ctx->is_dirty(depsgraph, rv3d)) {
|
||||
/* Update drawing. */
|
||||
DRW_draw_select_id(depsgraph, region, v3d);
|
||||
}
|
||||
@@ -493,7 +496,7 @@ void DRW_select_buffer_context_create(Depsgraph *depsgraph,
|
||||
}
|
||||
|
||||
select_ctx->select_mode = select_mode;
|
||||
memset(select_ctx->persmat, 0, sizeof(select_ctx->persmat));
|
||||
select_ctx->persmat = blender::float4x4::zero();
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
Reference in New Issue
Block a user