Showing the changes to libraries/render-utils/src/Model.cpp (1 of 8 files). Show all
Unified · Split
| @@ -1285,7 +1285,9 @@ void Model::simulateInternal(float deltaTime) { · 1284 unmodified lines | |||
| 1285 | const FBXGeometry& geometry = _geometry->getFBXGeometry(); | 1285 | const FBXGeometry& geometry = _geometry->getFBXGeometry(); |
| 1286 | glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset; | 1286 | glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset; |
| 1287 | updateRig(deltaTime, parentTransform); | 1287 | updateRig(deltaTime, parentTransform); |
| 1288 | 1288 | } | |
| 1289 | void Model::updateClusterMatrices() { | ||
| 1290 | const FBXGeometry& geometry = _geometry->getFBXGeometry(); | ||
| 1289 | glm::mat4 zeroScale(glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), | 1291 | glm::mat4 zeroScale(glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), |
| 1290 | glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), | 1292 | glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), |
| 1291 | glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), | 1293 | glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), |
| @@ -1419,15 +1421,17 @@ AABox Model::getPartBounds(int meshIndex, int partIndex) { · 127 unmodified lines | |||
| 1419 | return AABox(); | 1421 | return AABox(); |
| 1420 | } | 1422 | } |
| 1421 | 1423 | ||
| 1424 | avatarLockForWriteIfApplicable(); | ||
| 1422 | if (meshIndex < _meshStates.size()) { | 1425 | if (meshIndex < _meshStates.size()) { |
| 1423 | const MeshState& state = _meshStates.at(meshIndex); | 1426 | const MeshState& state = _meshStates.at(meshIndex); |
| 1424 | bool isSkinned = state.clusterMatrices.size() > 1; | 1427 | bool isSkinned = state.clusterMatrices.size() > 1; |
| 1425 | if (isSkinned) { | 1428 | if (isSkinned) { |
| 1426 | // if we're skinned return the entire mesh extents because we can't know for sure our clusters don't move us | 1429 | // if we're skinned return the entire mesh extents because we can't know for sure our clusters don't move us |
| 1427 | return calculateScaledOffsetAABox(_geometry->getFBXGeometry().meshExtents); | 1430 | AABox box = calculateScaledOffsetAABox(_geometry->getFBXGeometry().meshExtents); |
| 1431 | avatarLockReleaseIfApplicable(); | ||
| 1432 | return box; | ||
| 1428 | } | 1433 | } |
| 1429 | } | 1434 | } |
| 1430 | |||
| 1431 | if (_geometry->getFBXGeometry().meshes.size() > meshIndex) { | 1435 | if (_geometry->getFBXGeometry().meshes.size() > meshIndex) { |
| 1432 | 1436 | ||
| 1433 | // FIX ME! - This is currently a hack because for some mesh parts our efforts to calculate the bounding | 1437 | // FIX ME! - This is currently a hack because for some mesh parts our efforts to calculate the bounding |
| @@ -1443,8 +1447,11 @@ AABox Model::getPartBounds(int meshIndex, int partIndex) { · 9 unmodified lines | |||
| 1443 | // | 1447 | // |
| 1444 | // If we not skinned use the bounds of the subMesh for all it's parts | 1448 | // If we not skinned use the bounds of the subMesh for all it's parts |
| 1445 | const FBXMesh& mesh = _geometry->getFBXGeometry().meshes.at(meshIndex); | 1449 | const FBXMesh& mesh = _geometry->getFBXGeometry().meshes.at(meshIndex); |
| 1446 | return calculateScaledOffsetExtents(mesh.meshExtents); | 1450 | AABox box = calculateScaledOffsetExtents(mesh.meshExtents); |
| 1451 | avatarLockReleaseIfApplicable(); | ||
| 1452 | return box; | ||
| 1447 | } | 1453 | } |
| 1454 | avatarLockReleaseIfApplicable(); | ||
| 1448 | return AABox(); | 1455 | return AABox(); |
| 1449 | } | 1456 | } |
| 1450 | 1457 | ||
| @@ -1482,6 +1489,9 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, bool tran · 31 unmodified lines | |||
| 1482 | return; | 1489 | return; |
| 1483 | } | 1490 | } |
| 1484 | 1491 | ||
| 1492 | avatarLockForWriteIfApplicable(); | ||
| 1493 | updateClusterMatrices(); | ||
| 1494 | |||
| 1485 | const NetworkMesh& networkMesh = *(networkMeshes.at(meshIndex).get()); | 1495 | const NetworkMesh& networkMesh = *(networkMeshes.at(meshIndex).get()); |
| 1486 | const FBXMesh& mesh = geometry.meshes.at(meshIndex); | 1496 | const FBXMesh& mesh = geometry.meshes.at(meshIndex); |
| 1487 | const MeshState& state = _meshStates.at(meshIndex); | 1497 | const MeshState& state = _meshStates.at(meshIndex); |
| @@ -1536,6 +1546,7 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, bool tran · 48 unmodified lines | |||
| 1536 | _meshGroupsKnown = false; // regenerate these lists next time around. | 1546 | _meshGroupsKnown = false; // regenerate these lists next time around. |
| 1537 | _readyWhenAdded = false; // in case any of our users are using scenes | 1547 | _readyWhenAdded = false; // in case any of our users are using scenes |
| 1538 | invalidCalculatedMeshBoxes(); // if we have to reload, we need to assume our mesh boxes are all invalid | 1548 | invalidCalculatedMeshBoxes(); // if we have to reload, we need to assume our mesh boxes are all invalid |
| 1549 | avatarLockReleaseIfApplicable(); | ||
| 1539 | return; // FIXME! | 1550 | return; // FIXME! |
| 1540 | } | 1551 | } |
| 1541 | 1552 | ||
| @@ -1543,6 +1554,7 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, bool tran · 1 unmodified line | |||
| 1543 | int vertexCount = mesh.vertices.size(); | 1554 | int vertexCount = mesh.vertices.size(); |
| 1544 | if (vertexCount == 0) { | 1555 | if (vertexCount == 0) { |
| 1545 | // sanity check | 1556 | // sanity check |
| 1557 | avatarLockReleaseIfApplicable(); | ||
| 1546 | return; // FIXME! | 1558 | return; // FIXME! |
| 1547 | } | 1559 | } |
| 1548 | 1560 | ||
| @@ -1587,6 +1599,7 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, bool tran · 38 unmodified lines | |||
| 1587 | 1599 | ||
| 1588 | // guard against partially loaded meshes | 1600 | // guard against partially loaded meshes |
| 1589 | if (partIndex >= (int)networkMesh._parts.size() || partIndex >= mesh.parts.size()) { | 1601 | if (partIndex >= (int)networkMesh._parts.size() || partIndex >= mesh.parts.size()) { |
| 1602 | avatarLockReleaseIfApplicable(); | ||
| 1590 | return; | 1603 | return; |
| 1591 | } | 1604 | } |
| 1592 | 1605 | ||
| @@ -1703,6 +1716,7 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, bool tran · 110 unmodified lines | |||
| 1703 | args->_details._trianglesRendered += part.triangleIndices.size() / INDICES_PER_TRIANGLE; | 1716 | args->_details._trianglesRendered += part.triangleIndices.size() / INDICES_PER_TRIANGLE; |
| 1704 | args->_details._quadsRendered += part.quadIndices.size() / INDICES_PER_QUAD; | 1717 | args->_details._quadsRendered += part.quadIndices.size() / INDICES_PER_QUAD; |
| 1705 | } | 1718 | } |
| 1719 | avatarLockReleaseIfApplicable(); | ||
| 1706 | } | 1720 | } |
| 1707 | 1721 | ||
| 1708 | void Model::segregateMeshGroups() { | 1722 | void Model::segregateMeshGroups() { |