Optimized further the building of rotated rules.
This brings the speed up of the previous commits up to 90%.
This commit is contained in:
parent
b069193054
commit
52eebbefa1
2 changed files with 9 additions and 15 deletions
|
@ -502,19 +502,14 @@ void terrain_builder::replace_token(terrain_builder::building_rule &rule, const
|
|||
//replace_token(rule.images, token, replacement);
|
||||
}
|
||||
|
||||
terrain_builder::building_rule terrain_builder::rotate_rule(const terrain_builder::building_rule &rule,
|
||||
int angle, const std::vector<std::string>& rot)
|
||||
void terrain_builder::rotate_rule(building_rule &ret, int angle,
|
||||
const std::vector<std::string> &rot)
|
||||
{
|
||||
building_rule ret;
|
||||
if(rot.size() != 6) {
|
||||
if (rot.size() != 6) {
|
||||
ERR_NG << "invalid rotations\n";
|
||||
return ret;
|
||||
return;
|
||||
}
|
||||
ret.location_constraints = rule.location_constraints;
|
||||
ret.probability = rule.probability;
|
||||
ret.local = rule.local;
|
||||
|
||||
ret.constraints = rule.constraints;
|
||||
foreach (terrain_constraint &cons, ret.constraints) {
|
||||
rotate(cons, angle);
|
||||
}
|
||||
|
@ -543,8 +538,6 @@ terrain_builder::building_rule terrain_builder::rotate_rule(const terrain_builde
|
|||
token.push_back('0' + i);
|
||||
replace_token(ret, token, rot[a]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
terrain_builder::rule_image_variant::rule_image_variant(const std::string &image_string, const std::string& tod, int prob) :
|
||||
|
@ -731,7 +724,8 @@ void terrain_builder::add_rotated_rules(building_ruleset& rules, building_rule&
|
|||
const std::vector<std::string>& rot = utils::split(rotations, ',');
|
||||
|
||||
for(size_t angle = 0; angle < rot.size(); ++angle) {
|
||||
building_rule rule = rotate_rule(tpl, angle, rot);
|
||||
building_rule rule = tpl;
|
||||
rotate_rule(rule, angle, rot);
|
||||
add_rule(rules, rule, precedence);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -545,7 +545,7 @@ private:
|
|||
const std::string& replacement);
|
||||
|
||||
/**
|
||||
* Rotates a template rule to a given angle, and returns the rotated rule.
|
||||
* Rotates a template rule to a given angle.
|
||||
*
|
||||
* Template rules are defined like normal rules, except that:
|
||||
* * Flags and image filenames may contain template strings of the form
|
||||
|
@ -580,8 +580,8 @@ private:
|
|||
* r2, r3, r4, r5, r0, r1 and so on.
|
||||
*
|
||||
*/
|
||||
building_rule rotate_rule(const building_rule &rule, int angle,
|
||||
const std::vector<std::string>& angle_name);
|
||||
void rotate_rule(building_rule &rule, int angle,
|
||||
const std::vector<std::string> &angle_name);
|
||||
|
||||
/**
|
||||
* Parses a "config" object, which should contains [image] children,
|
||||
|
|
Loading…
Add table
Reference in a new issue