#include <msp/core/maputils.h>
#include <msp/geometry/box.h>
#include <msp/geometry/transformedshape.h>
+#include <msp/strings/regex.h>
#include <msp/strings/format.h>
#include "vehicletype.h"
{
MirrorParametersLoader params;
load_sub_with(params);
+ Regex r_filter(params.filter);
+
+ vector<unsigned> mirror_indices(obj.rods.size(), 0);
+ for(TagMap::const_iterator i=rod_tags.begin(); i!=rod_tags.end(); ++i)
+ if(i->second<0x10000 && r_filter.match(i->first))
+ mirror_indices[i->second] = 1;
+
+ for(unsigned i=0, j=obj.rods.size(); i<mirror_indices.size(); ++i)
+ if(mirror_indices[i])
+ mirror_indices[i] = j++;
Transform axle_trans = Transform::rotation(params.phase_offset, Vector(0, 1, 0));
- unsigned index_offset = obj.rods.size();
- for(unsigned i=0; i<index_offset; ++i)
+ for(unsigned i=0; i<mirror_indices.size(); ++i)
{
+ if(!mirror_indices[i])
+ continue;
+
Rod mr = obj.rods[i];
mr.initial_position.y = -mr.initial_position.y;
mr.mirror_object = !mr.mirror_object;
j->target_position.y = -j->target_position.y;
j->local_position.y = -j->local_position.y;
j->axis.y = -j->axis.y;
- if(j->target==RodConstraint::ROD)
- j->target_index += index_offset;
+ if(j->target==RodConstraint::ROD && mirror_indices[j->target_index])
+ j->target_index = mirror_indices[j->target_index];
else if(j->target==RodConstraint::AXLE)
j->target_position = axle_trans.transform(j->target_position);
}
VehicleType::MirrorParametersLoader::MirrorParametersLoader()
{
+ add("filter", &MirrorParametersLoader::filt);
add("phase_offset", &MirrorParametersLoader::phase_offs);
}
+void VehicleType::MirrorParametersLoader::filt(const string &f)
+{
+ filter = f;
+}
+
void VehicleType::MirrorParametersLoader::phase_offs(float o)
{
phase_offset = Angle::from_degrees(o);