diff --git a/src/flamegpu/runtime/agent/DeviceAgentVector_impl.cu b/src/flamegpu/runtime/agent/DeviceAgentVector_impl.cu index 7b3ac21a5..c1a530ad6 100644 --- a/src/flamegpu/runtime/agent/DeviceAgentVector_impl.cu +++ b/src/flamegpu/runtime/agent/DeviceAgentVector_impl.cu @@ -190,12 +190,15 @@ void DeviceAgentVector_impl::_insert(size_type pos, size_type count) { h_ptr[i] = cuda_agent.nextID(); } } - _changedAfter(ID_VARIABLE_NAME, pos); } else { THROW exception::InvalidOperation("Internal agent ID variable was not found, " "in DeviceAgentVector_impl._insert()."); } } + // Update change detail for all variables + for (const auto& [v, _] : agent->variables) { + _changedAfter(v, pos); + } // No unbound buffers, return if (unbound_buffers.empty()) return; @@ -239,19 +242,6 @@ void DeviceAgentVector_impl::_insert(size_type pos, size_type count) { if (unbound_host_buffer_size != _size) { THROW exception::InvalidOperation("Unbound buffers have gone out of sync, in DeviceAgentVector::_insert().\n"); } - // Update change detail for all variables - for (const auto& v : agent->variables) { - // Does it exist in change map - auto change = change_detail.find(v.first); - if (change == change_detail.end()) { - change_detail.emplace(v.first, std::pair{pos, _size}); - } else { - // Inclusive min bound - change->second.first = change->second.first > pos ? pos : change->second.first; - // Exclusive max bound - change->second.second = _size; - } - } } void DeviceAgentVector_impl::_erase(size_type pos, size_type count) { // No unbound buffers, return diff --git a/tests/test_cases/runtime/agent/test_host_agent_creation.cu b/tests/test_cases/runtime/agent/test_host_agent_creation.cu index e34edd07c..75aed5ab0 100644 --- a/tests/test_cases/runtime/agent/test_host_agent_creation.cu +++ b/tests/test_cases/runtime/agent/test_host_agent_creation.cu @@ -860,7 +860,7 @@ TEST(HostAgentCreationTest, AgentID_Consistent_Combined) { } FLAMEGPU_AGENT_FUNCTION(AgentID_Consistent_Agent, flamegpu::MessageNone, flamegpu::MessageNone) { FLAMEGPU->setVariable("id_copy_from_device", FLAMEGPU->getID()); - FLAMEGPU->setVariable("id_copy_copy_from_device", FLAMEGPU->getVariable("id_copy_copy_from_device")); + FLAMEGPU->setVariable("id_copy_copy_from_device", FLAMEGPU->getVariable("id_copy")); return flamegpu::ALIVE; } FLAMEGPU_STEP_FUNCTION(AgentID_Consistent_Step_Agent) {