Fix MultiMesh visible_instance_count being ignored after the first frame
Co-authored-by: Clay John <claynjohn@gmail.com>
This commit is contained in:
parent
604493eb6e
commit
497f5576c1
3 changed files with 12 additions and 6 deletions
|
@ -1835,8 +1835,12 @@ void MeshStorage::multimesh_set_visible_instances(RID p_multimesh, int p_visible
|
||||||
}
|
}
|
||||||
|
|
||||||
if (multimesh->data_cache.size()) {
|
if (multimesh->data_cache.size()) {
|
||||||
//there is a data cache..
|
// There is a data cache, but we may need to update some sections.
|
||||||
_multimesh_mark_all_dirty(multimesh, false, true);
|
_multimesh_mark_all_dirty(multimesh, false, true);
|
||||||
|
int start = multimesh->visible_instances >= 0 ? multimesh->visible_instances : multimesh->instances;
|
||||||
|
for (int i = start; i < p_visible; i++) {
|
||||||
|
_multimesh_mark_dirty(multimesh, i, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
multimesh->visible_instances = p_visible;
|
multimesh->visible_instances = p_visible;
|
||||||
|
@ -1868,7 +1872,7 @@ void MeshStorage::_update_dirty_multimeshes() {
|
||||||
if (multimesh->data_cache_used_dirty_regions > 32 || multimesh->data_cache_used_dirty_regions > visible_region_count / 2) {
|
if (multimesh->data_cache_used_dirty_regions > 32 || multimesh->data_cache_used_dirty_regions > visible_region_count / 2) {
|
||||||
// If there too many dirty regions, or represent the majority of regions, just copy all, else transfer cost piles up too much
|
// If there too many dirty regions, or represent the majority of regions, just copy all, else transfer cost piles up too much
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, multimesh->buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, multimesh->buffer);
|
||||||
glBufferData(GL_ARRAY_BUFFER, MIN(visible_region_count * region_size, multimesh->instances * multimesh->stride_cache * sizeof(float)), data, GL_STATIC_DRAW);
|
glBufferSubData(GL_ARRAY_BUFFER, 0, MIN(visible_region_count * region_size, multimesh->instances * multimesh->stride_cache * sizeof(float)), data);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
} else {
|
} else {
|
||||||
// Not that many regions? update them all
|
// Not that many regions? update them all
|
||||||
|
|
|
@ -1805,8 +1805,12 @@ void MeshStorage::multimesh_set_visible_instances(RID p_multimesh, int p_visible
|
||||||
}
|
}
|
||||||
|
|
||||||
if (multimesh->data_cache.size()) {
|
if (multimesh->data_cache.size()) {
|
||||||
//there is a data cache..
|
// There is a data cache, but we may need to update some sections.
|
||||||
_multimesh_mark_all_dirty(multimesh, false, true);
|
_multimesh_mark_all_dirty(multimesh, false, true);
|
||||||
|
int start = multimesh->visible_instances >= 0 ? multimesh->visible_instances : multimesh->instances;
|
||||||
|
for (int i = start; i < p_visible; i++) {
|
||||||
|
_multimesh_mark_dirty(multimesh, i, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
multimesh->visible_instances = p_visible;
|
multimesh->visible_instances = p_visible;
|
||||||
|
|
|
@ -485,6 +485,7 @@ public:
|
||||||
singleton->_instance_queue_update(instance, true, false);
|
singleton->_instance_queue_update(instance, true, false);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
case Dependency::DEPENDENCY_CHANGED_MULTIMESH_VISIBLE_INSTANCES:
|
||||||
case Dependency::DEPENDENCY_CHANGED_MATERIAL: {
|
case Dependency::DEPENDENCY_CHANGED_MATERIAL: {
|
||||||
singleton->_instance_queue_update(instance, false, true);
|
singleton->_instance_queue_update(instance, false, true);
|
||||||
} break;
|
} break;
|
||||||
|
@ -496,9 +497,6 @@ public:
|
||||||
case Dependency::DEPENDENCY_CHANGED_REFLECTION_PROBE: {
|
case Dependency::DEPENDENCY_CHANGED_REFLECTION_PROBE: {
|
||||||
singleton->_instance_queue_update(instance, true, true);
|
singleton->_instance_queue_update(instance, true, true);
|
||||||
} break;
|
} break;
|
||||||
case Dependency::DEPENDENCY_CHANGED_MULTIMESH_VISIBLE_INSTANCES: {
|
|
||||||
//ignored
|
|
||||||
} break;
|
|
||||||
case Dependency::DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR: {
|
case Dependency::DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR: {
|
||||||
//requires repairing
|
//requires repairing
|
||||||
if (instance->indexer_id.is_valid()) {
|
if (instance->indexer_id.is_valid()) {
|
||||||
|
|
Loading…
Reference in a new issue