@@ -2627,7 +2627,7 @@ void Individual::SetProperty(EidosGlobalStringID p_property_id, const EidosValue
26272627 Species &species = subpopulation_->species_ ;
26282628 Trait *trait = species.TraitFromStringID (p_property_id);
26292629
2630- if (trait)
2630+ if (trait) // ACCELERATED
26312631 {
26322632 trait_info_[trait->Index ()].value_ = (slim_effect_t )p_value.FloatAtIndex_NOCAST (0 , nullptr );
26332633 return ;
@@ -3039,7 +3039,7 @@ void Individual::SetProperty_Accelerated_age(EidosGlobalStringID p_property_id,
30393039
30403040void Individual::SetProperty_Accelerated_TRAIT_VALUE (EidosGlobalStringID p_property_id, EidosObject **p_values, size_t p_values_size, const EidosValue &p_source, size_t p_source_size)
30413041{
3042- #pragma unused (p_property_id, p_source_size )
3042+ #pragma unused (p_property_id)
30433043 const Individual **individuals_buffer = (const Individual **)p_values;
30443044 Species *species = Community::SpeciesForIndividualsVector (individuals_buffer, (int )p_values_size);
30453045 const double *source_data = p_source.FloatData ();
@@ -3049,23 +3049,53 @@ void Individual::SetProperty_Accelerated_TRAIT_VALUE(EidosGlobalStringID p_prope
30493049 Trait *trait = species->TraitFromStringID (p_property_id);
30503050 int64_t trait_index = trait->Index ();
30513051
3052- for ( size_t value_index = 0 ; value_index < p_values_size; ++value_index )
3052+ if (p_source_size == 1 )
30533053 {
3054- const Individual *value = individuals_buffer[value_index ];
3054+ slim_effect_t source_value = ( slim_effect_t )source_data[ 0 ];
30553055
3056- value->trait_info_ [trait_index].value_ = (slim_effect_t )source_data[value_index];
3056+ for (size_t value_index = 0 ; value_index < p_values_size; ++value_index)
3057+ {
3058+ const Individual *value = individuals_buffer[value_index];
3059+
3060+ value->trait_info_ [trait_index].value_ = source_value;
3061+ }
3062+ }
3063+ else
3064+ {
3065+ for (size_t value_index = 0 ; value_index < p_values_size; ++value_index)
3066+ {
3067+ const Individual *value = individuals_buffer[value_index];
3068+
3069+ value->trait_info_ [trait_index].value_ = (slim_effect_t )source_data[value_index];
3070+ }
30573071 }
30583072 }
30593073 else
30603074 {
30613075 // with a mixed-species target, the species and trait have to be looked up for each individual
3062- for ( size_t value_index = 0 ; value_index < p_values_size; ++value_index )
3076+ if (p_source_size == 1 )
30633077 {
3064- const Individual *value = individuals_buffer[value_index];
3065- Trait *trait = value->subpopulation_ ->species_ .TraitFromStringID (p_property_id);
3066- int64_t trait_index = trait->Index ();
3078+ slim_effect_t source_value = (slim_effect_t )source_data[0 ];
30673079
3068- value->trait_info_ [trait_index].value_ = (slim_effect_t )source_data[value_index];
3080+ for (size_t value_index = 0 ; value_index < p_values_size; ++value_index)
3081+ {
3082+ const Individual *value = individuals_buffer[value_index];
3083+ Trait *trait = value->subpopulation_ ->species_ .TraitFromStringID (p_property_id);
3084+ int64_t trait_index = trait->Index ();
3085+
3086+ value->trait_info_ [trait_index].value_ = source_value;
3087+ }
3088+ }
3089+ else
3090+ {
3091+ for (size_t value_index = 0 ; value_index < p_values_size; ++value_index)
3092+ {
3093+ const Individual *value = individuals_buffer[value_index];
3094+ Trait *trait = value->subpopulation_ ->species_ .TraitFromStringID (p_property_id);
3095+ int64_t trait_index = trait->Index ();
3096+
3097+ value->trait_info_ [trait_index].value_ = (slim_effect_t )source_data[value_index];
3098+ }
30693099 }
30703100 }
30713101}
0 commit comments