mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 02:14:26 +02:00
Fix warning and refactoring
This commit is contained in:
parent
beeeb74f17
commit
dfb434ea09
4 changed files with 40 additions and 52 deletions
|
@ -2323,24 +2323,25 @@ void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
|
|||
|
||||
std::shared_ptr<QMetaObject::Connection> skeletonConnection = std::make_shared<QMetaObject::Connection>();
|
||||
*skeletonConnection = QObject::connect(_skeletonModel.get(), &SkeletonModel::skeletonLoaded, [this, skeletonModelChangeCount, skeletonConnection]() {
|
||||
if (skeletonModelChangeCount == _skeletonModelChangeCount) {
|
||||
if (skeletonModelChangeCount == _skeletonModelChangeCount) {
|
||||
|
||||
if (_fullAvatarModelName.isEmpty()) {
|
||||
// Store the FST file name into preferences
|
||||
const auto& mapping = _skeletonModel->getGeometry()->getMapping();
|
||||
if (mapping.value("name").isValid()) {
|
||||
_fullAvatarModelName = mapping.value("name").toString();
|
||||
}
|
||||
}
|
||||
if (_fullAvatarModelName.isEmpty()) {
|
||||
// Store the FST file name into preferences
|
||||
const auto& mapping = _skeletonModel->getGeometry()->getMapping();
|
||||
if (mapping.value("name").isValid()) {
|
||||
_fullAvatarModelName = mapping.value("name").toString();
|
||||
}
|
||||
}
|
||||
|
||||
initHeadBones();
|
||||
_skeletonModel->setCauterizeBoneSet(_headBoneSet);
|
||||
_fstAnimGraphOverrideUrl = _skeletonModel->getGeometry()->getAnimGraphOverrideUrl();
|
||||
initAnimGraph();
|
||||
initFlow();
|
||||
_skeletonModelLoaded = true;
|
||||
}
|
||||
QObject::disconnect(*skeletonConnection);
|
||||
initHeadBones();
|
||||
_skeletonModel->setCauterizeBoneSet(_headBoneSet);
|
||||
_fstAnimGraphOverrideUrl = _skeletonModel->getGeometry()->getAnimGraphOverrideUrl();
|
||||
initAnimGraph();
|
||||
initFlowFromFST();
|
||||
|
||||
_skeletonModelLoaded = true;
|
||||
}
|
||||
QObject::disconnect(*skeletonConnection);
|
||||
});
|
||||
|
||||
saveAvatarUrl();
|
||||
|
@ -5384,33 +5385,11 @@ void MyAvatar::useFlow(bool isActive, bool isCollidable, const QVariantMap& phys
|
|||
}
|
||||
}
|
||||
|
||||
void MyAvatar::initFlow() {
|
||||
auto &flowData = _skeletonModel->getHFMModel().flowData;
|
||||
if (flowData._physicsData.size() > 0) {
|
||||
QVariantMap physicsConfig;
|
||||
QVariantMap collisionsConfig;
|
||||
for (auto &data : flowData._physicsData) {
|
||||
QJsonObject map = QJsonDocument::fromJson(data).object();
|
||||
if (!map.isEmpty() && map.keys().size() == 1) {
|
||||
QString group = map.keys()[0];
|
||||
if (map[group].isObject()) {
|
||||
physicsConfig.insert(group, map[group].toObject().toVariantMap());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto &data : flowData._collisionsData) {
|
||||
QJsonObject map = QJsonDocument::fromJson(data).object();
|
||||
if (!map.isEmpty() && map.keys().size() == 1) {
|
||||
QString jointName = map.keys()[0];
|
||||
if (map[jointName].isObject()) {
|
||||
collisionsConfig.insert(jointName, map[jointName].toObject().toVariantMap());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (collisionsConfig.size() > 0) {
|
||||
useFlow(true, true, physicsConfig, collisionsConfig);
|
||||
} else {
|
||||
useFlow(true, false, physicsConfig);
|
||||
void MyAvatar::initFlowFromFST() {
|
||||
if (_skeletonModel->isLoaded()) {
|
||||
auto &flowData = _skeletonModel->getHFMModel().flowData;
|
||||
if (flowData.shouldInitFlow()) {
|
||||
useFlow(true, flowData.shouldInitCollisions(), flowData._physicsConfig, flowData._collisionsConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1751,7 +1751,7 @@ private:
|
|||
void updateCollisionSound(const glm::vec3& penetration, float deltaTime, float frequency);
|
||||
void initHeadBones();
|
||||
void initAnimGraph();
|
||||
void initFlow();
|
||||
void initFlowFromFST();
|
||||
|
||||
// Avatar Preferences
|
||||
QUrl _fullAvatarURLFromPreferences;
|
||||
|
|
|
@ -276,8 +276,10 @@ public:
|
|||
class FlowData {
|
||||
public:
|
||||
FlowData() {};
|
||||
std::vector<QByteArray> _physicsData;
|
||||
std::vector<QByteArray> _collisionsData;
|
||||
QVariantMap _physicsConfig;
|
||||
QVariantMap _collisionsConfig;
|
||||
bool shouldInitFlow() const { return _physicsConfig.size() > 0; }
|
||||
bool shouldInitCollisions() const { return _collisionsConfig.size() > 0; }
|
||||
};
|
||||
|
||||
/// The runtime model format.
|
||||
|
|
|
@ -12,13 +12,20 @@ void ParseFlowDataTask::run(const baker::BakeContextPointer& context, const Inpu
|
|||
FlowData flowData;
|
||||
static const QString FLOW_PHYSICS_FIELD = "flowPhysicsData";
|
||||
static const QString FLOW_COLLISIONS_FIELD = "flowCollisionsData";
|
||||
for (auto &mappingIter = mapping.begin(); mappingIter != mapping.end(); mappingIter++) {
|
||||
for (auto mappingIter = mapping.begin(); mappingIter != mapping.end(); mappingIter++) {
|
||||
if (mappingIter.key() == FLOW_PHYSICS_FIELD || mappingIter.key() == FLOW_COLLISIONS_FIELD) {
|
||||
QByteArray flowDataValue = mappingIter.value().toByteArray();
|
||||
if (mappingIter.key() == FLOW_PHYSICS_FIELD) {
|
||||
flowData._physicsData.push_back(flowDataValue);
|
||||
} else {
|
||||
flowData._collisionsData.push_back(flowDataValue);
|
||||
QByteArray data = mappingIter.value().toByteArray();
|
||||
QJsonObject dataObject = QJsonDocument::fromJson(data).object();
|
||||
if (!dataObject.isEmpty() && dataObject.keys().size() == 1) {
|
||||
QString key = dataObject.keys()[0];
|
||||
if (dataObject[key].isObject()) {
|
||||
QVariantMap dataMap = dataObject[key].toObject().toVariantMap();
|
||||
if (mappingIter.key() == FLOW_PHYSICS_FIELD) {
|
||||
flowData._physicsConfig.insert(key, dataMap);
|
||||
} else {
|
||||
flowData._collisionsConfig.insert(key, dataMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue