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

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