Mass: fix data ordering issue with joint sliders.

This commit is contained in:
Guillaume Jacquemin 2021-11-01 11:19:34 +01:00
parent 83fa5822bf
commit bd8ff47f1e
2 changed files with 77 additions and 66 deletions

View File

@ -290,94 +290,94 @@ auto Mass::writeJointSliders() -> bool {
return false; return false;
} }
auto length = frame_prop->at<FloatProperty>("NeckLength_6_ED6AF79849C27CD1A9D523A09E2BFE58"); Containers::Array<UnrealPropertyBase::ptr> temp;
if(!length && _frame.joints.neck != 0.0f) {
length = new FloatProperty; auto length = frame_prop->atMove<FloatProperty>("NeckLength_6_ED6AF79849C27CD1A9D523A09E2BFE58");
auto length_prop = FloatProperty::ptr{length}; if(_frame.joints.neck != 0.0f) {
length_prop->name.emplace("NeckLength_6_ED6AF79849C27CD1A9D523A09E2BFE58"); if(!length) {
arrayAppend(frame_prop->properties, std::move(length_prop)); length.emplace();
} length->name.emplace("NeckLength_6_ED6AF79849C27CD1A9D523A09E2BFE58");
if(length) { }
length->value = _frame.joints.neck; length->value = _frame.joints.neck;
arrayAppend(temp, std::move(length));
} }
length = frame_prop->at<FloatProperty>("BodyLength_7_C16287754CBA96C93BAE36A5C154996A"); length = frame_prop->atMove<FloatProperty>("BodyLength_7_C16287754CBA96C93BAE36A5C154996A");
if(!length && _frame.joints.body != 0.0f) { if(_frame.joints.body != 0.0f) {
length = new FloatProperty; if(!length) {
auto length_prop = FloatProperty::ptr{length}; length.emplace();
length_prop->name.emplace("BodyLength_7_C16287754CBA96C93BAE36A5C154996A"); length->name.emplace("BodyLength_7_C16287754CBA96C93BAE36A5C154996A");
arrayAppend(frame_prop->properties, std::move(length_prop)); }
}
if(length) {
length->value = _frame.joints.body; length->value = _frame.joints.body;
arrayAppend(temp, std::move(length));
} }
length = frame_prop->at<FloatProperty>("ShoulderLength_8_220EDF304F1C1226F0D8D39117FB3883"); length = frame_prop->atMove<FloatProperty>("ShoulderLength_8_220EDF304F1C1226F0D8D39117FB3883");
if(!length && _frame.joints.shoulders != 0.0f) { if(_frame.joints.shoulders != 0.0f) {
length = new FloatProperty; if(!length) {
auto length_prop = FloatProperty::ptr{length}; length.emplace();
length_prop->name.emplace("ShoulderLength_8_220EDF304F1C1226F0D8D39117FB3883"); length->name.emplace("ShoulderLength_8_220EDF304F1C1226F0D8D39117FB3883");
arrayAppend(frame_prop->properties, std::move(length_prop)); }
}
if(length) {
length->value = _frame.joints.shoulders; length->value = _frame.joints.shoulders;
arrayAppend(temp, std::move(length));
} }
length = frame_prop->at<FloatProperty>("HipLength_14_02AEEEAC4376087B9C51F0AA7CC92818"); length = frame_prop->atMove<FloatProperty>("ArmUpperLength_10_249FDA3E4F3B399E7B9E5C9B7C765EAE");
if(!length && _frame.joints.hips != 0.0f) { if(_frame.joints.upperArms != 0.0f) {
length = new FloatProperty; if(!length) {
auto length_prop = FloatProperty::ptr{length}; length.emplace();
length_prop->name.emplace("HipLength_14_02AEEEAC4376087B9C51F0AA7CC92818"); length->name.emplace("ArmUpperLength_10_249FDA3E4F3B399E7B9E5C9B7C765EAE");
arrayAppend(frame_prop->properties, std::move(length_prop)); }
}
if(length) {
length->value = _frame.joints.hips;
}
length = frame_prop->at<FloatProperty>("ArmUpperLength_10_249FDA3E4F3B399E7B9E5C9B7C765EAE");
if(!length && _frame.joints.upperArms != 0.0f) {
length = new FloatProperty;
auto length_prop = FloatProperty::ptr{length};
length_prop->name.emplace("ArmUpperLength_10_249FDA3E4F3B399E7B9E5C9B7C765EAE");
arrayAppend(frame_prop->properties, std::move(length_prop));
}
if(length) {
length->value = _frame.joints.upperArms; length->value = _frame.joints.upperArms;
arrayAppend(temp, std::move(length));
} }
length = frame_prop->at<FloatProperty>("ArmLowerLength_12_ACD0F02745C28882619376926292FB36"); length = frame_prop->atMove<FloatProperty>("ArmLowerLength_12_ACD0F02745C28882619376926292FB36");
if(!length && _frame.joints.lowerArms != 0.0f) { if(_frame.joints.lowerArms != 0.0f) {
length = new FloatProperty; if(!length) {
auto length_prop = FloatProperty::ptr{length}; length.emplace();
length_prop->name.emplace("ArmLowerLength_12_ACD0F02745C28882619376926292FB36"); length->name.emplace("ArmLowerLength_12_ACD0F02745C28882619376926292FB36");
arrayAppend(frame_prop->properties, std::move(length_prop)); }
}
if(length) {
length->value = _frame.joints.lowerArms; length->value = _frame.joints.lowerArms;
arrayAppend(temp, std::move(length));
} }
length = frame_prop->at<FloatProperty>("LegUpperLength_16_A7C4C71249A3776F7A543D96819C0C61"); length = frame_prop->atMove<FloatProperty>("HipLength_14_02AEEEAC4376087B9C51F0AA7CC92818");
if(!length && _frame.joints.upperLegs != 0.0f) { if(_frame.joints.hips != 0.0f) {
length = new FloatProperty; if(!length) {
auto length_prop = FloatProperty::ptr{length}; length.emplace();
length_prop->name.emplace("LegUpperLength_16_A7C4C71249A3776F7A543D96819C0C61"); length->name.emplace("HipLength_14_02AEEEAC4376087B9C51F0AA7CC92818");
arrayAppend(frame_prop->properties, std::move(length_prop)); }
length->value = _frame.joints.hips;
arrayAppend(temp, std::move(length));
} }
if(length) {
length = frame_prop->atMove<FloatProperty>("LegUpperLength_16_A7C4C71249A3776F7A543D96819C0C61");
if(_frame.joints.upperLegs != 0.0f) {
if(!length) {
length.emplace();
length->name.emplace("LegUpperLength_16_A7C4C71249A3776F7A543D96819C0C61");
}
length->value = _frame.joints.upperLegs; length->value = _frame.joints.upperLegs;
arrayAppend(temp, std::move(length));
} }
length = frame_prop->at<FloatProperty>("LegLowerLength_18_D2DF39964EA0F2A2129D0491B08A032F"); length = frame_prop->atMove<FloatProperty>("LegLowerLength_18_D2DF39964EA0F2A2129D0491B08A032F");
if(!length && _frame.joints.lowerLegs != 0.0f) { if(_frame.joints.lowerLegs != 0.0f) {
length = new FloatProperty; if(!length) {
auto length_prop = FloatProperty::ptr{length}; length.emplace();
length_prop->name.emplace("LegLowerLength_18_D2DF39964EA0F2A2129D0491B08A032F"); length->name.emplace("LegLowerLength_18_D2DF39964EA0F2A2129D0491B08A032F");
arrayAppend(frame_prop->properties, std::move(length_prop)); }
}
if(length) {
length->value = _frame.joints.lowerLegs; length->value = _frame.joints.lowerLegs;
arrayAppend(temp, std::move(length));
} }
arrayAppend(temp, std::move(frame_prop->properties[frame_prop->properties.size() - 3]));
arrayAppend(temp, std::move(frame_prop->properties[frame_prop->properties.size() - 2]));
arrayAppend(temp, std::move(frame_prop->properties[frame_prop->properties.size() - 1]));
frame_prop->properties = std::move(temp);
if(!_mass->saveToFile()) { if(!_mass->saveToFile()) {
_lastError = "Couldn't write data to " + _filename; _lastError = "Couldn't write data to " + _filename;
return false; return false;

View File

@ -36,5 +36,16 @@ struct GenericStructProperty : public StructProperty {
return nullptr; return nullptr;
} }
template<typename T>
std::enable_if_t<std::is_base_of<UnrealPropertyBase, T>::value, typename T::ptr>
atMove(const std::string& name) {
for(auto& item : properties) {
if(item && item->name == name) {
return Containers::Pointer<T>{static_cast<T*>(item.release())};
}
}
return nullptr;
}
Containers::Array<UnrealPropertyBase::ptr> properties; Containers::Array<UnrealPropertyBase::ptr> properties;
}; };