Showing the changes to libraries/render-utils/src/Model.cpp (1 of 427 files). Show all
Unified · Split
| @@ -60,6 +60,8 @@ float Model::FAKE_DIMENSION_PLACEHOLDER = -1.0f; · 59 unmodified lines | ||
| 60 | 60 | |
| 61 | 61 | Model::Model(RigPointer rig, QObject* parent) : |
| 62 | 62 | QObject(parent), |
| 63 | + _translation(0.0f), | |
| 64 | + _rotation(), | |
| 63 | 65 | _scale(1.0f, 1.0f, 1.0f), |
| 64 | 66 | _scaleToFit(false), |
| 65 | 67 | _scaleToFitDimensions(0.0f), |
| @@ -70,7 +72,6 @@ Model::Model(RigPointer rig, QObject* parent) : · 4 unmodified lines | ||
| 70 | 72 | _cauterizeBones(false), |
| 71 | 73 | _pupilDilation(0.0f), |
| 72 | 74 | _url(HTTP_INVALID_COM), |
| 73 | − _urlAsString(HTTP_INVALID_COM), | |
| 74 | 75 | _isVisible(true), |
| 75 | 76 | _blendNumber(0), |
| 76 | 77 | _appliedBlendNumber(0), |
| @@ -195,6 +196,13 @@ void Model::RenderPipelineLib::initLocations(gpu::ShaderPointer& program, Model: · 118 unmodified lines | ||
| 195 | 196 | |
| 196 | 197 | AbstractViewStateInterface* Model::_viewState = NULL; |
| 197 | 198 | |
| 199 | +void Model::setTranslation(const glm::vec3& translation) { | |
| 200 | + _translation = translation; | |
| 201 | +} | |
| 202 | + | |
| 203 | +void Model::setRotation(const glm::quat& rotation) { | |
| 204 | + _rotation = rotation; | |
| 205 | +} | |
| 198 | 206 | |
| 199 | 207 | void Model::setScale(const glm::vec3& scale) { |
| 200 | 208 | setScaleInternal(scale); |
| @@ -433,14 +441,14 @@ void Model::initJointStates(QVector<JointState> states) { · 232 unmodified lines | ||
| 433 | 441 | int rightElbowJointIndex = rightHandJointIndex >= 0 ? geometry.joints.at(rightHandJointIndex).parentIndex : -1; |
| 434 | 442 | int rightShoulderJointIndex = rightElbowJointIndex >= 0 ? geometry.joints.at(rightElbowJointIndex).parentIndex : -1; |
| 435 | 443 | |
| 436 | − _boundingRadius = _rig->initJointStates(states, parentTransform, | |
| 437 | − rootJointIndex, | |
| 438 | − leftHandJointIndex, | |
| 439 | − leftElbowJointIndex, | |
| 440 | − leftShoulderJointIndex, | |
| 441 | − rightHandJointIndex, | |
| 442 | − rightElbowJointIndex, | |
| 443 | − rightShoulderJointIndex); | |
| 444 | + _rig->initJointStates(states, parentTransform, | |
| 445 | + rootJointIndex, | |
| 446 | + leftHandJointIndex, | |
| 447 | + leftElbowJointIndex, | |
| 448 | + leftShoulderJointIndex, | |
| 449 | + rightHandJointIndex, | |
| 450 | + rightElbowJointIndex, | |
| 451 | + rightShoulderJointIndex); | |
| 444 | 452 | } |
| 445 | 453 | |
| 446 | 454 | bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const glm::vec3& direction, float& distance, |
| @@ -1023,14 +1031,12 @@ int Model::getLastFreeJointIndex(int jointIndex) const { · 576 unmodified lines | ||
| 1023 | 1031 | } |
| 1024 | 1032 | |
| 1025 | 1033 | void Model::setURL(const QUrl& url) { |
| 1026 | − | |
| 1027 | 1034 | // don't recreate the geometry if it's the same URL |
| 1028 | 1035 | if (_url == url && _geometry && _geometry->getURL() == url) { |
| 1029 | 1036 | return; |
| 1030 | 1037 | } |
| 1031 | 1038 | |
| 1032 | 1039 | _url = url; |
| 1033 | − _urlAsString = _url.toString(); | |
| 1034 | 1040 | |
| 1035 | 1041 | { |
| 1036 | 1042 | render::PendingChanges pendingChanges; |
| @@ -1280,7 +1286,9 @@ void Model::simulateInternal(float deltaTime) { · 243 unmodified lines | ||
| 1280 | 1286 | const FBXGeometry& geometry = _geometry->getFBXGeometry(); |
| 1281 | 1287 | glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset; |
| 1282 | 1288 | updateRig(deltaTime, parentTransform); |
| 1283 | − | |
| 1289 | +} | |
| 1290 | +void Model::updateClusterMatrices() { | |
| 1291 | + const FBXGeometry& geometry = _geometry->getFBXGeometry(); | |
| 1284 | 1292 | glm::mat4 zeroScale(glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), |
| 1285 | 1293 | glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), |
| 1286 | 1294 | glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), |
| @@ -1294,7 +1302,7 @@ void Model::simulateInternal(float deltaTime) { · 7 unmodified lines | ||
| 1294 | 1302 | if (_showTrueJointTransforms) { |
| 1295 | 1303 | for (int j = 0; j < mesh.clusters.size(); j++) { |
| 1296 | 1304 | const FBXCluster& cluster = mesh.clusters.at(j); |
| 1297 | − auto jointMatrix =_rig->getJointTransform(cluster.jointIndex); | |
| 1305 | + auto jointMatrix = _rig->getJointTransform(cluster.jointIndex); | |
| 1298 | 1306 | state.clusterMatrices[j] = modelToWorld * jointMatrix * cluster.inverseBindMatrix; |
| 1299 | 1307 | |
| 1300 | 1308 | // as an optimization, don't build cautrizedClusterMatrices if the boneSet is empty. |
| @@ -1308,7 +1316,7 @@ void Model::simulateInternal(float deltaTime) { · 7 unmodified lines | ||
| 1308 | 1316 | } else { |
| 1309 | 1317 | for (int j = 0; j < mesh.clusters.size(); j++) { |
| 1310 | 1318 | const FBXCluster& cluster = mesh.clusters.at(j); |
| 1311 | − auto jointMatrix = _rig->getJointVisibleTransform(cluster.jointIndex); | |
| 1319 | + auto jointMatrix = _rig->getJointVisibleTransform(cluster.jointIndex); // differs from above only in using get...VisibleTransform | |
| 1312 | 1320 | state.clusterMatrices[j] = modelToWorld * jointMatrix * cluster.inverseBindMatrix; |
| 1313 | 1321 | |
| 1314 | 1322 | // as an optimization, don't build cautrizedClusterMatrices if the boneSet is empty. |
| @@ -1405,6 +1413,7 @@ void Model::deleteGeometry() { · 90 unmodified lines | ||
| 1405 | 1413 | _rig->clearJointStates(); |
| 1406 | 1414 | _meshStates.clear(); |
| 1407 | 1415 | _rig->deleteAnimations(); |
| 1416 | + _rig->destroyAnimGraph(); | |
| 1408 | 1417 | _blendedBlendshapeCoefficients.clear(); |
| 1409 | 1418 | } |
| 1410 | 1419 | |
| @@ -1422,7 +1431,6 @@ AABox Model::getPartBounds(int meshIndex, int partIndex) { · 11 unmodified lines | ||
| 1422 | 1431 | return calculateScaledOffsetAABox(_geometry->getFBXGeometry().meshExtents); |
| 1423 | 1432 | } |
| 1424 | 1433 | } |
| 1425 | − | |
| 1426 | 1434 | if (_geometry->getFBXGeometry().meshes.size() > meshIndex) { |
| 1427 | 1435 | |
| 1428 | 1436 | // FIX ME! - This is currently a hack because for some mesh parts our efforts to calculate the bounding |
| @@ -1486,6 +1494,8 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, int shape · 57 unmodified lines | ||
| 1486 | 1494 | return; |
| 1487 | 1495 | } |
| 1488 | 1496 | |
| 1497 | + updateClusterMatrices(); | |
| 1498 | + | |
| 1489 | 1499 | const NetworkMesh& networkMesh = *(networkMeshes.at(meshIndex).get()); |
| 1490 | 1500 | const FBXMesh& mesh = geometry.meshes.at(meshIndex); |
| 1491 | 1501 | const MeshState& state = _meshStates.at(meshIndex); |