Merge pull request #91846 from rburing/multimesh_cache_me_if_you_can
Fix MultiMesh buffer cache in transforms-only case
This commit is contained in:
commit
d532bc529a
|
@ -1936,6 +1936,11 @@ void MeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_b
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
// If we have a data cache, just update it.
|
||||||
|
if (multimesh->data_cache.size()) {
|
||||||
|
multimesh->data_cache = p_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
// Only Transform is being used, so we can upload directly.
|
// Only Transform is being used, so we can upload directly.
|
||||||
ERR_FAIL_COND(p_buffer.size() != (multimesh->instances * (int)multimesh->stride_cache));
|
ERR_FAIL_COND(p_buffer.size() != (multimesh->instances * (int)multimesh->stride_cache));
|
||||||
const float *r = p_buffer.ptr();
|
const float *r = p_buffer.ptr();
|
||||||
|
@ -1947,16 +1952,12 @@ void MeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_b
|
||||||
multimesh->buffer_set = true;
|
multimesh->buffer_set = true;
|
||||||
|
|
||||||
if (multimesh->data_cache.size() || multimesh->uses_colors || multimesh->uses_custom_data) {
|
if (multimesh->data_cache.size() || multimesh->uses_colors || multimesh->uses_custom_data) {
|
||||||
//if we have a data cache, just update it
|
// Clear dirty since nothing will be dirty anymore.
|
||||||
multimesh->data_cache = multimesh->data_cache;
|
uint32_t data_cache_dirty_region_count = Math::division_round_up(multimesh->instances, MULTIMESH_DIRTY_REGION_SIZE);
|
||||||
{
|
for (uint32_t i = 0; i < data_cache_dirty_region_count; i++) {
|
||||||
//clear dirty since nothing will be dirty anymore
|
multimesh->data_cache_dirty_regions[i] = false;
|
||||||
uint32_t data_cache_dirty_region_count = Math::division_round_up(multimesh->instances, MULTIMESH_DIRTY_REGION_SIZE);
|
|
||||||
for (uint32_t i = 0; i < data_cache_dirty_region_count; i++) {
|
|
||||||
multimesh->data_cache_dirty_regions[i] = false;
|
|
||||||
}
|
|
||||||
multimesh->data_cache_used_dirty_regions = 0;
|
|
||||||
}
|
}
|
||||||
|
multimesh->data_cache_used_dirty_regions = 0;
|
||||||
|
|
||||||
_multimesh_mark_all_dirty(multimesh, false, true); //update AABB
|
_multimesh_mark_all_dirty(multimesh, false, true); //update AABB
|
||||||
} else if (multimesh->mesh.is_valid()) {
|
} else if (multimesh->mesh.is_valid()) {
|
||||||
|
|
Loading…
Reference in New Issue