History

Merge branch 'master' into tony/ik-and-controllers

Anthony J. Thibault committed 11 years ago

Commit 663e37d2 parents 3149bae e8ede3a2 files · +28 −28Browse files

Showing the changes to libraries/animation/src/AnimNodeLoader.cpp (1 of 2 files). Show all

Unified · Split

libraries/animation/src/AnimNodeLoader.cpp+26−26
@@ -82,13 +82,13 @@ static NodeProcessFunc animNodeTypeToProcessFunc(AnimNode::Type type) { · 81 unmodified lines
8282 return nullptr;
8383 }
8484
85−#define READ_STRING(NAME, JSON_OBJ, ID, URL) \
85+#define READ_STRING(NAME, JSON_OBJ, ID, URL, ERROR_RETURN) \
8686 auto NAME##_VAL = JSON_OBJ.value(#NAME); \
8787 if (!NAME##_VAL.isString()) { \
8888 qCCritical(animation) << "AnimNodeLoader, error reading string" \
8989 << #NAME << ", id =" << ID \
9090 << ", url =" << URL.toDisplayString(); \
91− return nullptr; \
91+ return ERROR_RETURN; \
9292 } \
9393 QString NAME = NAME##_VAL.toString()
9494
@@ -99,23 +99,23 @@ static NodeProcessFunc animNodeTypeToProcessFunc(AnimNode::Type type) { · 4 unmodified lines
9999 NAME = NAME##_VAL.toString(); \
100100 }
101101
102−#define READ_BOOL(NAME, JSON_OBJ, ID, URL) \
102+#define READ_BOOL(NAME, JSON_OBJ, ID, URL, ERROR_RETURN) \
103103 auto NAME##_VAL = JSON_OBJ.value(#NAME); \
104104 if (!NAME##_VAL.isBool()) { \
105105 qCCritical(animation) << "AnimNodeLoader, error reading bool" \
106106 << #NAME << ", id =" << ID \
107107 << ", url =" << URL.toDisplayString(); \
108− return nullptr; \
108+ return ERROR_RETURN; \
109109 } \
110110 bool NAME = NAME##_VAL.toBool()
111111
112−#define READ_FLOAT(NAME, JSON_OBJ, ID, URL) \
112+#define READ_FLOAT(NAME, JSON_OBJ, ID, URL, ERROR_RETURN) \
113113 auto NAME##_VAL = JSON_OBJ.value(#NAME); \
114114 if (!NAME##_VAL.isDouble()) { \
115115 qCCritical(animation) << "AnimNodeLoader, error reading double" \
116116 << #NAME << "id =" << ID \
117117 << ", url =" << URL.toDisplayString(); \
118− return nullptr; \
118+ return ERROR_RETURN; \
119119 } \
120120 float NAME = (float)NAME##_VAL.toDouble()
121121
@@ -184,11 +184,11 @@ static AnimNode::Pointer loadNode(const QJsonObject& jsonObj, const QUrl& jsonUr · 62 unmodified lines
184184
185185 static AnimNode::Pointer loadClipNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) {
186186
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);
192192
193193 READ_OPTIONAL_STRING(startFrameVar, jsonObj);
194194 READ_OPTIONAL_STRING(endFrameVar, jsonObj);
@@ -215,7 +215,7 @@ static AnimNode::Pointer loadClipNode(const QJsonObject& jsonObj, const QString& · 20 unmodified lines
215215
216216 static AnimNode::Pointer loadBlendLinearNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) {
217217
218− READ_FLOAT(alpha, jsonObj, id, jsonUrl);
218+ READ_FLOAT(alpha, jsonObj, id, jsonUrl, nullptr);
219219
220220 READ_OPTIONAL_STRING(alphaVar, jsonObj);
221221
@@ -252,8 +252,8 @@ static AnimOverlay::BoneSet stringToBoneSetEnum(const QString& str) { · 30 unmodified lines
252252
253253 static AnimNode::Pointer loadOverlayNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) {
254254
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);
257257
258258 auto boneSetEnum = stringToBoneSetEnum(boneSet);
259259 if (boneSetEnum == AnimOverlay::NumBoneSets) {
@@ -352,12 +352,12 @@ AnimNode::Pointer processStateMachineNode(AnimNode::Pointer node, const QJsonObj · 92 unmodified lines
352352 auto smNode = std::static_pointer_cast<AnimStateMachine>(node);
353353 assert(smNode);
354354
355− READ_STRING(currentState, jsonObj, nodeId, jsonUrl);
355+ READ_STRING(currentState, jsonObj, nodeId, jsonUrl, false);
356356
357357 auto statesValue = jsonObj.value("states");
358358 if (!statesValue.isArray()) {
359359 qCCritical(animation) << "AnimNodeLoader, bad array \"states\" in stateMachine node, id =" << nodeId << ", url =" << jsonUrl.toDisplayString();
360− return nullptr;
360+ return false;
361361 }
362362
363363 // build a map for all children by name.
@@ -376,13 +376,13 @@ AnimNode::Pointer processStateMachineNode(AnimNode::Pointer node, const QJsonObj · 12 unmodified lines
376376 for (const auto& stateValue : statesArray) {
377377 if (!stateValue.isObject()) {
378378 qCCritical(animation) << "AnimNodeLoader, bad state object in \"states\", id =" << nodeId << ", url =" << jsonUrl.toDisplayString();
379− return nullptr;
379+ return false;
380380 }
381381 auto stateObj = stateValue.toObject();
382382
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);
386386
387387 READ_OPTIONAL_STRING(interpTargetVar, stateObj);
388388 READ_OPTIONAL_STRING(interpDurationVar, stateObj);
@@ -392,7 +392,7 @@ AnimNode::Pointer processStateMachineNode(AnimNode::Pointer node, const QJsonObj · 3 unmodified lines
392392 auto iter = childMap.find(stdId);
393393 if (iter == childMap.end()) {
394394 qCCritical(animation) << "AnimNodeLoader, could not find stateMachine child (state) with nodeId =" << nodeId << "stateId =" << id << "url =" << jsonUrl.toDisplayString();
395− return nullptr;
395+ return false;
396396 }
397397
398398 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
411411 auto transitionsValue = stateObj.value("transitions");
412412 if (!transitionsValue.isArray()) {
413413 qCritical(animation) << "AnimNodeLoader, bad array \"transitions\" in stateMachine node, stateId =" << id << "nodeId =" << nodeId << "url =" << jsonUrl.toDisplayString();
414− return nullptr;
414+ return false;
415415 }
416416
417417 auto transitionsArray = transitionsValue.toArray();
418418 for (const auto& transitionValue : transitionsArray) {
419419 if (!transitionValue.isObject()) {
420420 qCritical(animation) << "AnimNodeLoader, bad transition object in \"transtions\", stateId =" << id << "nodeId =" << nodeId << "url =" << jsonUrl.toDisplayString();
421− return nullptr;
421+ return false;
422422 }
423423 auto transitionObj = transitionValue.toObject();
424424
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);
427427
428428 transitionMap.insert(TransitionMap::value_type(statePtr, StringPair(var.toStdString(), state.toStdString())));
429429 }
@@ -437,7 +437,7 @@ AnimNode::Pointer processStateMachineNode(AnimNode::Pointer node, const QJsonObj · 7 unmodified lines
437437 srcState->addTransition(AnimStateMachine::State::Transition(transition.second.first, iter->second));
438438 } else {
439439 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;
441441 }
442442 }
443443

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t