From: Mikko Rasa Date: Wed, 14 Aug 2013 14:08:20 +0000 (+0300) Subject: Support mirroring only a subset of rods based on a tag filter X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=b1936d09d6f37f941e594493e8a7e18fca88cc55;p=r2c2.git Support mirroring only a subset of rods based on a tag filter --- diff --git a/source/libr2c2/vehicletype.cpp b/source/libr2c2/vehicletype.cpp index 786d18a..7200b99 100644 --- a/source/libr2c2/vehicletype.cpp +++ b/source/libr2c2/vehicletype.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include "vehicletype.h" @@ -179,12 +180,24 @@ void VehicleType::Loader::mirror_rods() { MirrorParametersLoader params; load_sub_with(params); + Regex r_filter(params.filter); + + vector 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(); itarget_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); } @@ -360,9 +373,15 @@ void VehicleType::Rod::Loader::initial_position(float x, float y, float z) 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); diff --git a/source/libr2c2/vehicletype.h b/source/libr2c2/vehicletype.h index 1305a19..a027915 100644 --- a/source/libr2c2/vehicletype.h +++ b/source/libr2c2/vehicletype.h @@ -148,10 +148,12 @@ public: class MirrorParametersLoader: public Msp::DataFile::Loader { public: + std::string filter; Angle phase_offset; MirrorParametersLoader(); private: + void filt(const std::string &); void phase_offs(float); };