Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions core/PhysiCell_standard_models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,8 @@ void dynamic_attachments( Cell* pCell , Phenotype& phenotype, double dt )
{
// check for detachments
double detachment_probability = phenotype.mechanics.detachment_rate * dt;
for( int j=0; j < pCell->state.attached_cells.size(); j++ )
// detach_cells swaps the detached cell with the last cell in the vector, so we need to iterate backwards
for( int j=pCell->state.attached_cells.size()-1; j >= 0; j-- )
{
Cell* pTest = pCell->state.attached_cells[j];
if( UniformRandom() <= detachment_probability )
Expand All @@ -1441,8 +1442,6 @@ void dynamic_attachments( Cell* pCell , Phenotype& phenotype, double dt )
while( done == false && j < pCell->state.neighbors.size() )
{
Cell* pTest = pCell->state.neighbors[j];
if (phenotype.cell_interactions.pAttackTarget==pTest || pTest->phenotype.cell_interactions.pAttackTarget==pCell) // do not let attackers detach randomly
{ continue; }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the right check, but in the wrong place

if( pTest->state.number_of_attached_cells() < pTest->phenotype.mechanics.maximum_number_of_attachments )
{
// std::string search_string = "adhesive affinity to " + pTest->type_name;
Expand All @@ -1467,9 +1466,12 @@ void dynamic_spring_attachments( Cell* pCell , Phenotype& phenotype, double dt )
{
// check for detachments
double detachment_probability = phenotype.mechanics.detachment_rate * dt;
for( int j=0; j < pCell->state.spring_attachments.size(); j++ )
// detach_cells_as_spring swaps the detached cell with the last cell in the vector, so we need to iterate backwards
for( int j=pCell->state.spring_attachments.size()-1; j >= 0; j-- )
{
Cell* pTest = pCell->state.spring_attachments[j];
Cell* pTest = pCell->state.spring_attachments[j];
if (phenotype.cell_interactions.pAttackTarget==pTest || pTest->phenotype.cell_interactions.pAttackTarget==pCell) // do not let attackers detach randomly
{ continue; }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the check in the correct place

if( UniformRandom() <= detachment_probability )
{ detach_cells_as_spring( pCell , pTest ); }
}
Expand Down
Loading