Changeset 719 for cpp/frams/genetics/f1


Ignore:
Timestamp:
12/21/17 21:48:17 (7 years ago)
Author:
Maciej Komosinski
Message:

f1->f0 mapping maps ',' and ')' symbols to the branching Part (earlier they were not mapped at all)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/f1/conv_f1.cpp

    r716 r719  
    4343        double model_energy;
    4444        int model_energy_count;
    45         void grow(int part1, const char*g, Pt3D k, F1Props c);
     45        void grow(int part1, const char*g, Pt3D k, F1Props c, int branching_part);
    4646        void setPartMapping(int p, const char* g);
    4747        int growJoint(int part1, int part2, Pt3D &angle, F1Props &c, const char *g);
     
    111111        Builder builder(g, map ? 1 : 0);
    112112        builder.model.open();
    113         builder.grow(-1, g, Pt3D_0, stdprops); // uses Model::singleStepBuild to create model elements
     113        builder.grow(-1, g, Pt3D_0, stdprops, -1); // uses Model::singleStepBuild to create model elements
    114114        if (builder.invalid) return SString();
    115115        builder.addPendingInputs();
     
    133133}
    134134
    135 void Builder::grow(int part1, const char*g, Pt3D k, F1Props c)
     135void Builder::grow(int part1, const char*g, Pt3D k, F1Props c, int branching_part)
    136136{
    137137        int hasmuscles = 0;
     
    141141                switch (*g)
    142142                {
    143                 case 0: case ',': case ')': return;
     143                case 0: return;
     144                case ',': case ')': setPartMapping(branching_part, g); return;
    144145                case 'R': k.x += 0.7853; setPartMapping(part1, g); break;
    145146                case 'r': k.x -= 0.7853;        setPartMapping(part1, g); break;
     
    241242
    242243                        if (c.muscle_reset_range) c.muscle_bend_range = 1.0; else c.muscle_reset_range = true;
    243                         grow(part2, g + 1, Pt3D_0, c);
     244                        grow(part2, g + 1, Pt3D_0, c, branching_part);
    244245                        return;
    245246                }
     
    253254                        c.muscle_bend_range = 1.0 / count;
    254255                        for (i = 0; i < count; i++)
    255                                 grow(part1, (char*)ga(i), k + Pt3D(0, 0, -M_PI + (i + 1)*(2 * M_PI / (count + 1))), c);
     256                                grow(part1, (char*)ga(i), k + Pt3D(0, 0, -M_PI + (i + 1)*(2 * M_PI / (count + 1))), c, part1);
    256257                        return;
    257258                }
Note: See TracChangeset for help on using the changeset viewer.