Showing the changes to libraries/animation/src/AnimNodeLoader.cpp (1 of 2 files). Show all
Unified · Split
| @@ -82,13 +82,13 @@ static NodeProcessFunc animNodeTypeToProcessFunc(AnimNode::Type type) { · 81 unmodified lines | ||
| 82 | 82 | return nullptr; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | −#define READ_STRING(NAME, JSON_OBJ, ID, URL) \ | |
| 85 | +#define READ_STRING(NAME, JSON_OBJ, ID, URL, ERROR_RETURN) \ | |
| 86 | 86 | auto NAME##_VAL = JSON_OBJ.value(#NAME); \ |
| 87 | 87 | if (!NAME##_VAL.isString()) { \ |
| 88 | 88 | qCCritical(animation) << "AnimNodeLoader, error reading string" \ |
| 89 | 89 | << #NAME << ", id =" << ID \ |
| 90 | 90 | << ", url =" << URL.toDisplayString(); \ |
| 91 | − return nullptr; \ | |
| 91 | + return ERROR_RETURN; \ | |
| 92 | 92 | } \ |
| 93 | 93 | QString NAME = NAME##_VAL.toString() |
| 94 | 94 | |
| @@ -99,23 +99,23 @@ static NodeProcessFunc animNodeTypeToProcessFunc(AnimNode::Type type) { · 4 unmodified lines | ||
| 99 | 99 | NAME = NAME##_VAL.toString(); \ |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | −#define READ_BOOL(NAME, JSON_OBJ, ID, URL) \ | |
| 102 | +#define READ_BOOL(NAME, JSON_OBJ, ID, URL, ERROR_RETURN) \ | |
| 103 | 103 | auto NAME##_VAL = JSON_OBJ.value(#NAME); \ |
| 104 | 104 | if (!NAME##_VAL.isBool()) { \ |
| 105 | 105 | qCCritical(animation) << "AnimNodeLoader, error reading bool" \ |
| 106 | 106 | << #NAME << ", id =" << ID \ |
| 107 | 107 | << ", url =" << URL.toDisplayString(); \ |
| 108 | − return nullptr; \ | |
| 108 | + return ERROR_RETURN; \ | |
| 109 | 109 | } \ |
| 110 | 110 | bool NAME = NAME##_VAL.toBool() |
| 111 | 111 | |
| 112 | −#define READ_FLOAT(NAME, JSON_OBJ, ID, URL) \ | |
| 112 | +#define READ_FLOAT(NAME, JSON_OBJ, ID, URL, ERROR_RETURN) \ | |
| 113 | 113 | auto NAME##_VAL = JSON_OBJ.value(#NAME); \ |
| 114 | 114 | if (!NAME##_VAL.isDouble()) { \ |
| 115 | 115 | qCCritical(animation) << "AnimNodeLoader, error reading double" \ |
| 116 | 116 | << #NAME << "id =" << ID \ |
| 117 | 117 | << ", url =" << URL.toDisplayString(); \ |
| 118 | − return nullptr; \ | |
| 118 | + return ERROR_RETURN; \ | |
| 119 | 119 | } \ |
| 120 | 120 | float NAME = (float)NAME##_VAL.toDouble() |
| 121 | 121 | |
| @@ -184,11 +184,11 @@ static AnimNode::Pointer loadNode(const QJsonObject& jsonObj, const QUrl& jsonUr · 62 unmodified lines | ||
| 184 | 184 | |
| 185 | 185 | static AnimNode::Pointer loadClipNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { |
| 186 | 186 | |
| 187 | − READ_STRING(url, jsonObj, id, jsonUrl); | |
| 188 | − READ_FLOAT(startFrame, jsonObj, id, jsonUrl); | |
| 189 | − READ_FLOAT(endFrame, jsonObj, id, jsonUrl); | |
| 190 | − READ_FLOAT(timeScale, jsonObj, id, jsonUrl); | |
| 191 | − READ_BOOL(loopFlag, jsonObj, id, jsonUrl); | |
| 187 | + READ_STRING(url, jsonObj, id, jsonUrl, nullptr); | |
| 188 | + READ_FLOAT(startFrame, jsonObj, id, jsonUrl, nullptr); | |
| 189 | + READ_FLOAT(endFrame, jsonObj, id, jsonUrl, nullptr); | |
| 190 | + READ_FLOAT(timeScale, jsonObj, id, jsonUrl, nullptr); | |
| 191 | + READ_BOOL(loopFlag, jsonObj, id, jsonUrl, nullptr); | |
| 192 | 192 | |
| 193 | 193 | READ_OPTIONAL_STRING(startFrameVar, jsonObj); |
| 194 | 194 | READ_OPTIONAL_STRING(endFrameVar, jsonObj); |
| @@ -215,7 +215,7 @@ static AnimNode::Pointer loadClipNode(const QJsonObject& jsonObj, const QString& · 20 unmodified lines | ||
| 215 | 215 | |
| 216 | 216 | static AnimNode::Pointer loadBlendLinearNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { |
| 217 | 217 | |
| 218 | − READ_FLOAT(alpha, jsonObj, id, jsonUrl); | |
| 218 | + READ_FLOAT(alpha, jsonObj, id, jsonUrl, nullptr); | |
| 219 | 219 | |
| 220 | 220 | READ_OPTIONAL_STRING(alphaVar, jsonObj); |
| 221 | 221 | |
| @@ -252,8 +252,8 @@ static AnimOverlay::BoneSet stringToBoneSetEnum(const QString& str) { · 30 unmodified lines | ||
| 252 | 252 | |
| 253 | 253 | static AnimNode::Pointer loadOverlayNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { |
| 254 | 254 | |
| 255 | − READ_STRING(boneSet, jsonObj, id, jsonUrl); | |
| 256 | − READ_FLOAT(alpha, jsonObj, id, jsonUrl); | |
| 255 | + READ_STRING(boneSet, jsonObj, id, jsonUrl, nullptr); | |
| 256 | + READ_FLOAT(alpha, jsonObj, id, jsonUrl, nullptr); | |
| 257 | 257 | |
| 258 | 258 | auto boneSetEnum = stringToBoneSetEnum(boneSet); |
| 259 | 259 | if (boneSetEnum == AnimOverlay::NumBoneSets) { |
| @@ -352,12 +352,12 @@ AnimNode::Pointer processStateMachineNode(AnimNode::Pointer node, const QJsonObj · 92 unmodified lines | ||
| 352 | 352 | auto smNode = std::static_pointer_cast<AnimStateMachine>(node); |
| 353 | 353 | assert(smNode); |
| 354 | 354 | |
| 355 | − READ_STRING(currentState, jsonObj, nodeId, jsonUrl); | |
| 355 | + READ_STRING(currentState, jsonObj, nodeId, jsonUrl, false); | |
| 356 | 356 | |
| 357 | 357 | auto statesValue = jsonObj.value("states"); |
| 358 | 358 | if (!statesValue.isArray()) { |
| 359 | 359 | qCCritical(animation) << "AnimNodeLoader, bad array \"states\" in stateMachine node, id =" << nodeId << ", url =" << jsonUrl.toDisplayString(); |
| 360 | − return nullptr; | |
| 360 | + return false; | |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | // build a map for all children by name. |
| @@ -376,13 +376,13 @@ AnimNode::Pointer processStateMachineNode(AnimNode::Pointer node, const QJsonObj · 12 unmodified lines | ||
| 376 | 376 | for (const auto& stateValue : statesArray) { |
| 377 | 377 | if (!stateValue.isObject()) { |
| 378 | 378 | qCCritical(animation) << "AnimNodeLoader, bad state object in \"states\", id =" << nodeId << ", url =" << jsonUrl.toDisplayString(); |
| 379 | − return nullptr; | |
| 379 | + return false; | |
| 380 | 380 | } |
| 381 | 381 | auto stateObj = stateValue.toObject(); |
| 382 | 382 | |
| 383 | − READ_STRING(id, stateObj, nodeId, jsonUrl); | |
| 384 | − READ_FLOAT(interpTarget, stateObj, nodeId, jsonUrl); | |
| 385 | − READ_FLOAT(interpDuration, stateObj, nodeId, jsonUrl); | |
| 383 | + READ_STRING(id, stateObj, nodeId, jsonUrl, false); | |
| 384 | + READ_FLOAT(interpTarget, stateObj, nodeId, jsonUrl, false); | |
| 385 | + READ_FLOAT(interpDuration, stateObj, nodeId, jsonUrl, false); | |
| 386 | 386 | |
| 387 | 387 | READ_OPTIONAL_STRING(interpTargetVar, stateObj); |
| 388 | 388 | READ_OPTIONAL_STRING(interpDurationVar, stateObj); |
| @@ -392,7 +392,7 @@ AnimNode::Pointer processStateMachineNode(AnimNode::Pointer node, const QJsonObj · 3 unmodified lines | ||
| 392 | 392 | auto iter = childMap.find(stdId); |
| 393 | 393 | if (iter == childMap.end()) { |
| 394 | 394 | qCCritical(animation) << "AnimNodeLoader, could not find stateMachine child (state) with nodeId =" << nodeId << "stateId =" << id << "url =" << jsonUrl.toDisplayString(); |
| 395 | − return nullptr; | |
| 395 | + return false; | |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | auto statePtr = std::make_shared<AnimStateMachine::State>(stdId, iter->second, interpTarget, interpDuration); |
| @@ -411,19 +411,19 @@ AnimNode::Pointer processStateMachineNode(AnimNode::Pointer node, const QJsonObj · 12 unmodified lines | ||
| 411 | 411 | auto transitionsValue = stateObj.value("transitions"); |
| 412 | 412 | if (!transitionsValue.isArray()) { |
| 413 | 413 | qCritical(animation) << "AnimNodeLoader, bad array \"transitions\" in stateMachine node, stateId =" << id << "nodeId =" << nodeId << "url =" << jsonUrl.toDisplayString(); |
| 414 | − return nullptr; | |
| 414 | + return false; | |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | auto transitionsArray = transitionsValue.toArray(); |
| 418 | 418 | for (const auto& transitionValue : transitionsArray) { |
| 419 | 419 | if (!transitionValue.isObject()) { |
| 420 | 420 | qCritical(animation) << "AnimNodeLoader, bad transition object in \"transtions\", stateId =" << id << "nodeId =" << nodeId << "url =" << jsonUrl.toDisplayString(); |
| 421 | − return nullptr; | |
| 421 | + return false; | |
| 422 | 422 | } |
| 423 | 423 | auto transitionObj = transitionValue.toObject(); |
| 424 | 424 | |
| 425 | − READ_STRING(var, transitionObj, nodeId, jsonUrl); | |
| 426 | − READ_STRING(state, transitionObj, nodeId, jsonUrl); | |
| 425 | + READ_STRING(var, transitionObj, nodeId, jsonUrl, false); | |
| 426 | + READ_STRING(state, transitionObj, nodeId, jsonUrl, false); | |
| 427 | 427 | |
| 428 | 428 | transitionMap.insert(TransitionMap::value_type(statePtr, StringPair(var.toStdString(), state.toStdString()))); |
| 429 | 429 | } |
| @@ -437,7 +437,7 @@ AnimNode::Pointer processStateMachineNode(AnimNode::Pointer node, const QJsonObj · 7 unmodified lines | ||
| 437 | 437 | srcState->addTransition(AnimStateMachine::State::Transition(transition.second.first, iter->second)); |
| 438 | 438 | } else { |
| 439 | 439 | qCCritical(animation) << "AnimNodeLoader, bad state machine transtion from srcState =" << srcState->_id.c_str() << "dstState =" << transition.second.second.c_str() << "nodeId =" << nodeId << "url = " << jsonUrl.toDisplayString(); |
| 440 | − return nullptr; | |
| 440 | + return false; | |
| 441 | 441 | } |
| 442 | 442 | } |
| 443 | 443 | |