Skip to content

Commit a84a4a6

Browse files
committed
Don't mark instance meshes dirty every update. We can use the hash to only send them when needed and only send instance infos every udpate.
1 parent 930e0e9 commit a84a4a6

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

Plugins~/Src/MeshSyncClient/msInstancesManager.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,22 @@ namespace ms {
6565
void InstancesManager::add(InstanceInfoPtr info)
6666
{
6767
auto& rec = lockAndGet(info->path);
68-
69-
bool existed = false;
70-
68+
7169
for (int i = 0; i < rec.instancesPerParent[info->parent_path].size(); ++i)
7270
{
7371
const auto& instance = rec.instancesPerParent[info->parent_path][i];
7472

7573
if (instance->parent_path == info->parent_path)
7674
{
77-
existed = true;
78-
7975
// Remove instance from the list, the new one will be added below:
8076
rec.instancesPerParent[info->parent_path].erase(rec.instancesPerParent[info->parent_path].begin() + i);
8177

8278
break;
8379
}
8480
}
8581

86-
if (m_always_mark_dirty || !existed) {
87-
rec.dirtyInstances = true;
88-
}
82+
// instanceInfos need to be sent every update because it's how the server knows which instances are still alive:
83+
rec.dirtyInstances = true;
8984

9085
rec.instancesPerParent[info->parent_path].push_back(info);
9186
rec.updatedParents[info->parent_path] = true;

Plugins~/Src/MeshSyncClientBlender/msblenContextGeometryNodes.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ void msblenContext::exportInstances() {
3737
auto id = static_cast<ID*>(obj->data);
3838
scene_objects.insert(id->name + 2);
3939
});
40-
41-
// Assume everything is now dirty
42-
m_instances_state->manager.setAlwaysMarkDirty(true);
43-
40+
4441
std::unordered_map<std::string, ms::TransformPtr> exportedTransforms;
4542

4643
m_geometryNodeUtils.each_instanced_object(

0 commit comments

Comments
 (0)