Ignore:
Timestamp:
06/22/23 04:00:45 (10 months ago)
Author:
Maciej Komosinski
Message:

Cosmetic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/geneprops.cpp

    r1248 r1260  
    5151}
    5252
    53 int GeneProps::executeModifier_Legacy(char modif)
    54 {
    55         switch (modif)
    56         {
    57 #ifdef v1f1COMPATIBLE
    58         case 'L': length += (3.0 - length) * 0.3;
    59                 length = std::min(length, Model::getMaxJoint().d.x); break;
    60 #else
    61         case 'L': length += (2.0 - length) * 0.3; //2.0 is currently Model::getMaxJoint().d.x so min() does not limit the range
    62                 length = std::min(length, Model::getMaxJoint().d.x); break;
    63 #endif
    64         case 'l': length += (0.33 - length) * 0.3;
    65                 length = std::max(length, Model::getMinJoint().d.x); break;
    66 
    67         case 'W': weight += (2.0 - weight) * 0.3; break;
    68         case 'w': weight += (0.5 - weight) * 0.3; break;
    69         case 'F': friction += (4 - friction) * 0.2; break;
    70         case 'f': friction -= friction * 0.2; break;
    71         case 'C': curvedness += (2.0 - curvedness) * 0.25; break;
    72         case 'c': curvedness += (-2.0 - curvedness) * 0.25; break;
    73         case 'Q': twist += (M_PI_2 - twist) * 0.3; break;
    74         case 'q': twist += (-M_PI_2 - twist) * 0.3; break;
    75         case 'E': energy += (10.0 - energy) * 0.1; break;
    76         case 'e': energy -= energy * 0.1;  break;
    77 
    78         case 'A': assimilation += (1 - assimilation) * 0.8; normalizeBiol4(); break;
    79         case 'a': assimilation -= assimilation * 0.4; normalizeBiol4(); break;
    80         case 'I': ingestion += (1 - ingestion) * 0.8; normalizeBiol4(); break;
    81         case 'i': ingestion -= ingestion * 0.4; normalizeBiol4(); break;
    82         case 'S': stamina += (1 - stamina) * 0.8; normalizeBiol4(); break;
    83         case 's': stamina -= stamina * 0.4; normalizeBiol4(); break;
    84         case 'M': muscle_power += (1 - muscle_power) * 0.8; normalizeBiol4(); break;
    85         case 'm': muscle_power -= muscle_power * 0.4; normalizeBiol4(); break;
    86 
    87         case 'D': cred += (1.0 - cred) * 0.25; break;
    88         case 'd': cred += (0.0 - cred) * 0.25; break;
    89         case 'G': cgreen += (1.0 - cgreen) * 0.25; break;
    90         case 'g': cgreen += (0.0 - cgreen) * 0.25; break;
    91         case 'B': cblue += (1.0 - cblue) * 0.25; break;
    92         case 'b': cblue += (0.0 - cblue) * 0.25; break;
    93 
    94         default: return -1;
    95         }
    96         return 0;
    97 }
    98 
    9953int GeneProps::executeModifier(char modif, GenePropsOps* ops)
    10054{
    10155        if (ops == NULL)
    102                 ops = getStandardOps();
     56                ops = getDefaultOps();
    10357
    10458#define APPLY(name) ops->name->apply(name, modif)
     
    152106
    153107        if (ops == NULL)
    154                 ops = getStandardOps();
     108                ops = getDefaultOps();
    155109        if (ops->use_normalizebiol4) normalizeBiol4();
    156110
     
    171125}
    172126
    173 double GenePropsOp_Old::increase(double value) const
     127double GenePropsOp_Legacy::increase(double value) const
    174128{
    175129        return value + (maxvalue - value) * change;
    176130}
    177131
    178 double GenePropsOp_Old::decrease(double value) const
     132double GenePropsOp_Legacy::decrease(double value) const
    179133{
    180134        return value + (minvalue - value) * revchange;
    181135}
    182136
    183 GenePropsOp_Old::GenePropsOp_Old(double minvalue, double maxvalue, double defvalue, double change, double revchange)
     137GenePropsOp_Legacy::GenePropsOp_Legacy(double minvalue, double maxvalue, double defvalue, double change, double revchange)
    184138{
    185139        this->minvalue = minvalue;
     
    246200}
    247201
    248 GenePropsOps_Old::GenePropsOps_Old()
     202GenePropsOps_Legacy::GenePropsOps_Legacy()
    249203{
    250204        use_normalizebiol4 = true;
    251205
    252         length = new GenePropsOp_Old(0.33, 2.0, GeneProps::standard_values.length, 0.3);
    253         weight = new GenePropsOp_Old(0.5, 2.0, GeneProps::standard_values.weight, 0.3);
    254         friction = new GenePropsOp_Old(0, 4.0, GeneProps::standard_values.friction, 0.2);
    255         curvedness = new GenePropsOp_Old(-2, 2, GeneProps::standard_values.curvedness, 0.25);
    256         twist = new GenePropsOp_Old(-M_PI_2, M_PI_2, GeneProps::standard_values.twist, 0.3);
    257         energy = new GenePropsOp_Old(0, 10, GeneProps::standard_values.energy, 0.1);
    258 
    259         assimilation = new GenePropsOp_Old(0, 1, GeneProps::standard_values.assimilation, 0.8, 0.4);
    260         ingestion = new GenePropsOp_Old(0, 1, GeneProps::standard_values.ingestion, 0.8, 0.4);
    261         stamina = new GenePropsOp_Old(0, 1, GeneProps::standard_values.stamina, 0.8, 0.4);
    262         muscle_power = new GenePropsOp_Old(0, 1, GeneProps::standard_values.muscle_power, 0.8, 0.4);
    263 
    264         cred = new GenePropsOp_Old(0, 1, GeneProps::standard_values.cred, 0.25);
    265         cgreen = new GenePropsOp_Old(0, 1, GeneProps::standard_values.cgreen, 0.25);
    266         cblue = new GenePropsOp_Old(0, 1, GeneProps::standard_values.cblue, 0.25);
    267 }
    268 
    269 GenePropsOps_New05::GenePropsOps_New05()
     206        length = new GenePropsOp_Legacy(0.33, 2.0, GeneProps::standard_values.length, 0.3);
     207        weight = new GenePropsOp_Legacy(0.5, 2.0, GeneProps::standard_values.weight, 0.3);
     208        friction = new GenePropsOp_Legacy(0, 4.0, GeneProps::standard_values.friction, 0.2);
     209        curvedness = new GenePropsOp_Legacy(-2, 2, GeneProps::standard_values.curvedness, 0.25);
     210        twist = new GenePropsOp_Legacy(-M_PI_2, M_PI_2, GeneProps::standard_values.twist, 0.3);
     211        energy = new GenePropsOp_Legacy(0, 10, GeneProps::standard_values.energy, 0.1);
     212
     213        assimilation = new GenePropsOp_Legacy(0, 1, GeneProps::standard_values.assimilation, 0.8, 0.4);
     214        ingestion = new GenePropsOp_Legacy(0, 1, GeneProps::standard_values.ingestion, 0.8, 0.4);
     215        stamina = new GenePropsOp_Legacy(0, 1, GeneProps::standard_values.stamina, 0.8, 0.4);
     216        muscle_power = new GenePropsOp_Legacy(0, 1, GeneProps::standard_values.muscle_power, 0.8, 0.4);
     217
     218        cred = new GenePropsOp_Legacy(0, 1, GeneProps::standard_values.cred, 0.25);
     219        cgreen = new GenePropsOp_Legacy(0, 1, GeneProps::standard_values.cgreen, 0.25);
     220        cblue = new GenePropsOp_Legacy(0, 1, GeneProps::standard_values.cblue, 0.25);
     221}
     222
     223GenePropsOps_AllChange05::GenePropsOps_AllChange05()
    270224{
    271225        use_normalizebiol4 = false;
     226
     227        constexpr float CHANGE = 0.5;
    272228        auto fields = { length,curvedness,weight,friction,muscle_power,assimilation,stamina,ingestion,twist,energy,cred,cgreen,cblue };
    273229        for (auto f : fields)
    274230        {
    275                 auto f_gpo = dynamic_cast<GenePropsOp_Old*>(f);
     231                auto f_gpo = dynamic_cast<GenePropsOp_Legacy*>(f);
    276232                if (f_gpo)
    277                         f_gpo->change = f_gpo->revchange = 0.5;
    278         }
     233                        f_gpo->change = f_gpo->revchange = CHANGE;
     234        }
     235
     236        delete curvedness;
     237        curvedness = new GenePropsOp_Legacy(-M_PI_2, M_PI_2, GeneProps::standard_values.curvedness, CHANGE);
    279238}
    280239
     
    298257}
    299258
    300 
    301 GenePropsOps* GeneProps::standard_ops = NULL;
    302 GenePropsOps* GeneProps::getStandardOps()
    303 {
    304         if (!standard_ops)
    305                 standard_ops = new GenePropsOps_New05();
    306         return standard_ops;
    307 }
     259GenePropsOps* GeneProps::getAllChange05Ops()
     260{
     261        static GenePropsOps_AllChange05 ops;
     262        return &ops;
     263}
     264
     265GenePropsOps* GeneProps::getLegacyOps()
     266{
     267        static GenePropsOps_Legacy ops;
     268        return &ops;
     269}
     270
     271static GenePropsOps* default_ops = NULL;
     272
     273GenePropsOps* GeneProps::getDefaultOps()
     274{
     275        if (!default_ops)
     276                default_ops = getAllChange05Ops();
     277        return default_ops;
     278}
     279
     280void GeneProps::setDefaultOps(GenePropsOps* ops)
     281{
     282        default_ops = ops;
     283}
Note: See TracChangeset for help on using the changeset viewer.