Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 19, 2008, 2:18:55 AM (16 years ago)
Author:
landauf
Message:

changed the previously implemented assimilate function to take an optional default-value and to return false if the conversion failed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/util/MultiTypeMath.cc

    r1319 r1320  
    216216}
    217217
    218 void MultiTypeMath::assimilate(const MultiTypeMath& mtm)
    219 {
    220     if (this->type_ == MT_vector2)
    221         this->vector2_ = mtm.operator orxonox::Vector2();
    222     else if (this->type_ == MT_vector3)
    223         this->vector3_ = mtm.operator orxonox::Vector3();
    224     else if (this->type_ == MT_vector4)
    225         this->vector4_ = mtm.operator orxonox::Vector4();
    226     else if (this->type_ == MT_colourvalue)
    227         this->colourvalue_ = mtm;
    228     else if (this->type_ == MT_quaternion)
    229         this->quaternion_ = mtm;
    230     else if (this->type_ == MT_radian)
    231         this->radian_ = mtm.operator orxonox::Radian();
    232     else if (this->type_ == MT_degree)
    233         this->degree_ = mtm.operator orxonox::Degree();
    234     else
    235         MultiTypeString::assimilate(mtm);
     218bool MultiTypeMath::assimilate(const MultiTypeMath& mtm, const MultiTypeMath& defvalue)
     219{
     220    if (this->type_ == MT_vector2)
     221        return ConvertValue(&this->vector2_, mtm, defvalue.vector2_);
     222    else if (this->type_ == MT_vector3)
     223        return ConvertValue(&this->vector3_, mtm, defvalue.vector3_);
     224    else if (this->type_ == MT_vector4)
     225        return ConvertValue(&this->vector4_, mtm, defvalue.vector4_);
     226    else if (this->type_ == MT_colourvalue)
     227        return ConvertValue(&this->colourvalue_, mtm, defvalue.colourvalue_);
     228    else if (this->type_ == MT_quaternion)
     229        return ConvertValue(&this->quaternion_, mtm, defvalue.quaternion_);
     230    else if (this->type_ == MT_radian)
     231        return ConvertValue(&this->radian_, mtm, defvalue.radian_);
     232    else if (this->type_ == MT_degree)
     233        return ConvertValue(&this->degree_, mtm, defvalue.degree_);
     234    else
     235        return MultiTypeString::assimilate(mtm, defvalue);
    236236}
    237237
Note: See TracChangeset for help on using the changeset viewer.