From bf73033c97852380f62895f9aafc41f6689e95d4 Mon Sep 17 00:00:00 2001 From: Heber Lima da Rocha Date: Mon, 16 Feb 2026 11:51:40 -0500 Subject: [PATCH 1/3] Update max cell interactive distance in voxel during position update --- core/PhysiCell_cell.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/PhysiCell_cell.cpp b/core/PhysiCell_cell.cpp index 2755d7d5d..da7cd5a50 100644 --- a/core/PhysiCell_cell.cpp +++ b/core/PhysiCell_cell.cpp @@ -895,6 +895,13 @@ void Cell::update_position( double dt ) if(get_container()->underlying_mesh.is_position_valid(position[0],position[1],position[2])) { updated_current_mechanics_voxel_index=get_container()->underlying_mesh.nearest_voxel_index( position ); + // Update max_cell_interactive_distance_in_voxel if needed + if( get_container()->max_cell_interactive_distance_in_voxel[get_current_mechanics_voxel_index()] < + phenotype.geometry.radius * phenotype.mechanics.relative_maximum_adhesion_distance ) + { + get_container()->max_cell_interactive_distance_in_voxel[get_current_mechanics_voxel_index()] = phenotype.geometry.radius + * phenotype.mechanics.relative_maximum_adhesion_distance; + } } else { From 3b809aedfae0455ee8b07cc2c6204456bf77b3e5 Mon Sep 17 00:00:00 2001 From: Heber Lima da Rocha Date: Mon, 16 Feb 2026 15:25:04 -0500 Subject: [PATCH 2/3] Refactor max cell interactive distance update to occur after voxel index assignment --- core/PhysiCell_cell.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/PhysiCell_cell.cpp b/core/PhysiCell_cell.cpp index da7cd5a50..f5a36d40d 100644 --- a/core/PhysiCell_cell.cpp +++ b/core/PhysiCell_cell.cpp @@ -895,13 +895,6 @@ void Cell::update_position( double dt ) if(get_container()->underlying_mesh.is_position_valid(position[0],position[1],position[2])) { updated_current_mechanics_voxel_index=get_container()->underlying_mesh.nearest_voxel_index( position ); - // Update max_cell_interactive_distance_in_voxel if needed - if( get_container()->max_cell_interactive_distance_in_voxel[get_current_mechanics_voxel_index()] < - phenotype.geometry.radius * phenotype.mechanics.relative_maximum_adhesion_distance ) - { - get_container()->max_cell_interactive_distance_in_voxel[get_current_mechanics_voxel_index()] = phenotype.geometry.radius - * phenotype.mechanics.relative_maximum_adhesion_distance; - } } else { @@ -954,6 +947,14 @@ void Cell::update_voxel_in_container() } current_mechanics_voxel_index=updated_current_mechanics_voxel_index; } + + // Update max_cell_interactive_distance_in_voxel if needed + if( get_container()->max_cell_interactive_distance_in_voxel[current_mechanics_voxel_index] < + phenotype.geometry.radius * phenotype.mechanics.relative_maximum_adhesion_distance ) + { + get_container()->max_cell_interactive_distance_in_voxel[current_mechanics_voxel_index] = phenotype.geometry.radius + * phenotype.mechanics.relative_maximum_adhesion_distance; + } return; } From 7bce9409dbf2c8a059367f9ec4cef959c5c32813 Mon Sep 17 00:00:00 2001 From: Heber Lima da Rocha Date: Mon, 16 Feb 2026 15:31:18 -0500 Subject: [PATCH 3/3] update max_cell_interactive_distance_in_voxel if cell changed voxel --- core/PhysiCell_cell.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/PhysiCell_cell.cpp b/core/PhysiCell_cell.cpp index f5a36d40d..16f0ac8f4 100644 --- a/core/PhysiCell_cell.cpp +++ b/core/PhysiCell_cell.cpp @@ -946,15 +946,17 @@ void Cell::update_voxel_in_container() container->add_agent_to_voxel(this, updated_current_mechanics_voxel_index); } current_mechanics_voxel_index=updated_current_mechanics_voxel_index; - } - // Update max_cell_interactive_distance_in_voxel if needed - if( get_container()->max_cell_interactive_distance_in_voxel[current_mechanics_voxel_index] < - phenotype.geometry.radius * phenotype.mechanics.relative_maximum_adhesion_distance ) - { - get_container()->max_cell_interactive_distance_in_voxel[current_mechanics_voxel_index] = phenotype.geometry.radius - * phenotype.mechanics.relative_maximum_adhesion_distance; + // Update max_cell_interactive_distance_in_voxel if needed + if( get_container()->max_cell_interactive_distance_in_voxel[current_mechanics_voxel_index] < + phenotype.geometry.radius * phenotype.mechanics.relative_maximum_adhesion_distance ) + { + get_container()->max_cell_interactive_distance_in_voxel[current_mechanics_voxel_index] = phenotype.geometry.radius + * phenotype.mechanics.relative_maximum_adhesion_distance; + } } + + return; }