Showing the changes to libraries/render-utils/src/Model.cpp (1 of 30 files). Show all
Unified · Split
| @@ -104,6 +104,7 @@ Model::Model(QObject* parent, SpatiallyNestable* spatiallyNestableOverride) : · 103 unmodified lines | |||
| 104 | _snappedToRegistrationPoint(false), | 104 | _snappedToRegistrationPoint(false), |
| 105 | _url(HTTP_INVALID_COM), | 105 | _url(HTTP_INVALID_COM), |
| 106 | _isVisible(true), | 106 | _isVisible(true), |
| 107 | _canCastShadow(false), | ||
| 107 | _blendNumber(0), | 108 | _blendNumber(0), |
| 108 | _appliedBlendNumber(0), | 109 | _appliedBlendNumber(0), |
| 109 | _isWireframe(false) | 110 | _isWireframe(false) |
| @@ -270,6 +271,7 @@ void Model::updateRenderItems() { · 160 unmodified lines | |||
| 270 | 271 | ||
| 271 | bool isWireframe = self->isWireframe(); | 272 | bool isWireframe = self->isWireframe(); |
| 272 | bool isVisible = self->isVisible(); | 273 | bool isVisible = self->isVisible(); |
| 274 | bool canCastShadow = self->canCastShadow(); | ||
| 273 | uint8_t viewTagBits = self->getViewTagBits(); | 275 | uint8_t viewTagBits = self->getViewTagBits(); |
| 274 | bool isLayeredInFront = self->isLayeredInFront(); | 276 | bool isLayeredInFront = self->isLayeredInFront(); |
| 275 | bool isLayeredInHUD = self->isLayeredInHUD(); | 277 | bool isLayeredInHUD = self->isLayeredInHUD(); |
| @@ -288,7 +290,7 @@ void Model::updateRenderItems() { · 12 unmodified lines | |||
| 288 | 290 | ||
| 289 | transaction.updateItem<ModelMeshPartPayload>(itemID, [modelTransform, meshState, useDualQuaternionSkinning, | 291 | transaction.updateItem<ModelMeshPartPayload>(itemID, [modelTransform, meshState, useDualQuaternionSkinning, |
| 290 | invalidatePayloadShapeKey, isWireframe, isVisible, | 292 | invalidatePayloadShapeKey, isWireframe, isVisible, |
| 291 | viewTagBits, isLayeredInFront, | 293 | canCastShadow, viewTagBits, isLayeredInFront, |
| 292 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { | 294 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { |
| 293 | if (useDualQuaternionSkinning) { | 295 | if (useDualQuaternionSkinning) { |
| 294 | data.updateClusterBuffer(meshState.clusterDualQuaternions); | 296 | data.updateClusterBuffer(meshState.clusterDualQuaternions); |
| @@ -313,7 +315,7 @@ void Model::updateRenderItems() { · 18 unmodified lines | |||
| 313 | } | 315 | } |
| 314 | data.updateTransformForSkinnedMesh(renderTransform, modelTransform); | 316 | data.updateTransformForSkinnedMesh(renderTransform, modelTransform); |
| 315 | 317 | ||
| 316 | data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, viewTagBits, isGroupCulled); | 318 | data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, canCastShadow, viewTagBits, isGroupCulled); |
| 317 | data.setLayer(isLayeredInFront, isLayeredInHUD); | 319 | data.setLayer(isLayeredInFront, isLayeredInHUD); |
| 318 | data.setShapeKey(invalidatePayloadShapeKey, isWireframe, useDualQuaternionSkinning); | 320 | data.setShapeKey(invalidatePayloadShapeKey, isWireframe, useDualQuaternionSkinning); |
| 319 | }); | 321 | }); |
| @@ -773,46 +775,66 @@ void Model::setVisibleInScene(bool isVisible, const render::ScenePointer& scene, · 453 unmodified lines | |||
| 773 | 775 | ||
| 774 | bool isLayeredInFront = _isLayeredInFront; | 776 | bool isLayeredInFront = _isLayeredInFront; |
| 775 | bool isLayeredInHUD = _isLayeredInHUD; | 777 | bool isLayeredInHUD = _isLayeredInHUD; |
| 776 | 778 | bool canCastShadow = _canCastShadow; | |
| 777 | render::Transaction transaction; | 779 | render::Transaction transaction; |
| 778 | foreach (auto item, _modelMeshRenderItemsMap.keys()) { | 780 | foreach (auto item, _modelMeshRenderItemsMap.keys()) { |
| 779 | transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, | 781 | transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, canCastShadow, |
| 780 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { | 782 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { |
| 781 | data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, viewTagBits, isGroupCulled); | 783 | data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, canCastShadow, viewTagBits, isGroupCulled); |
| 782 | }); | 784 | }); |
| 783 | } | 785 | } |
| 784 | foreach(auto item, _collisionRenderItemsMap.keys()) { | 786 | foreach(auto item, _collisionRenderItemsMap.keys()) { |
| 785 | transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, | 787 | transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, canCastShadow, |
| 786 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { | 788 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { |
| 787 | data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, viewTagBits, isGroupCulled); | 789 | data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, canCastShadow, viewTagBits, isGroupCulled); |
| 788 | }); | 790 | }); |
| 789 | } | 791 | } |
| 790 | scene->enqueueTransaction(transaction); | 792 | scene->enqueueTransaction(transaction); |
| 791 | } | 793 | } |
| 792 | } | 794 | } |
| 793 | 795 | ||
| 796 | void Model::setCanCastShadow(bool canCastShadow, const render::ScenePointer& scene, uint8_t viewTagBits, bool isGroupCulled) { | ||
| 797 | if (_canCastShadow != canCastShadow) { | ||
| 798 | _canCastShadow = canCastShadow; | ||
| 799 | |||
| 800 | bool isVisible = _isVisible; | ||
| 801 | bool isLayeredInFront = _isLayeredInFront; | ||
| 802 | bool isLayeredInHUD = _isLayeredInHUD; | ||
| 803 | |||
| 804 | render::Transaction transaction; | ||
| 805 | foreach (auto item, _modelMeshRenderItemsMap.keys()) { | ||
| 806 | transaction.updateItem<ModelMeshPartPayload>(item, | ||
| 807 | [isVisible, viewTagBits, canCastShadow, isLayeredInFront, isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { | ||
| 808 | data.updateKey(isVisible, viewTagBits, canCastShadow, isLayeredInFront || isLayeredInHUD, isGroupCulled); | ||
| 809 | }); | ||
| 810 | } | ||
| 811 | |||
| 812 | scene->enqueueTransaction(transaction); | ||
| 813 | } | ||
| 814 | } | ||
| 794 | 815 | ||
| 795 | void Model::setLayeredInFront(bool isLayeredInFront, const render::ScenePointer& scene) { | 816 | void Model::setLayeredInFront(bool isLayeredInFront, const render::ScenePointer& scene) { |
| 796 | if (_isLayeredInFront != isLayeredInFront) { | 817 | if (_isLayeredInFront != isLayeredInFront) { |
| 797 | _isLayeredInFront = isLayeredInFront; | 818 | _isLayeredInFront = isLayeredInFront; |
| 798 | 819 | ||
| 799 | bool isVisible = _isVisible; | 820 | bool isVisible = _isVisible; |
| 821 | bool canCastShadow = _canCastShadow; | ||
| 800 | uint8_t viewTagBits = _viewTagBits; | 822 | uint8_t viewTagBits = _viewTagBits; |
| 801 | bool isLayeredInHUD = _isLayeredInHUD; | 823 | bool isLayeredInHUD = _isLayeredInHUD; |
| 802 | bool isGroupCulled = _isGroupCulled; | 824 | bool isGroupCulled = _isGroupCulled; |
| 803 | 825 | ||
| 804 | render::Transaction transaction; | 826 | render::Transaction transaction; |
| 805 | foreach(auto item, _modelMeshRenderItemsMap.keys()) { | 827 | foreach(auto item, _modelMeshRenderItemsMap.keys()) { |
| 806 | transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, | 828 | transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, canCastShadow, |
| 807 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { | 829 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { |
| 808 | data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, viewTagBits, isGroupCulled); | 830 | data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, canCastShadow, viewTagBits, isGroupCulled); |
| 809 | data.setLayer(isLayeredInFront, isLayeredInHUD); | 831 | data.setLayer(isLayeredInFront, isLayeredInHUD); |
| 810 | }); | 832 | }); |
| 811 | } | 833 | } |
| 812 | foreach(auto item, _collisionRenderItemsMap.keys()) { | 834 | foreach(auto item, _collisionRenderItemsMap.keys()) { |
| 813 | transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, | 835 | transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, canCastShadow, |
| 814 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { | 836 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { |
| 815 | data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, viewTagBits, isGroupCulled); | 837 | data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, canCastShadow, viewTagBits, isGroupCulled); |
| 816 | data.setLayer(isLayeredInFront, isLayeredInHUD); | 838 | data.setLayer(isLayeredInFront, isLayeredInHUD); |
| 817 | }); | 839 | }); |
| 818 | } | 840 | } |
| @@ -825,22 +847,23 @@ void Model::setLayeredInHUD(bool isLayeredInHUD, const render::ScenePointer& sce · 6 unmodified lines | |||
| 825 | _isLayeredInHUD = isLayeredInHUD; | 847 | _isLayeredInHUD = isLayeredInHUD; |
| 826 | 848 | ||
| 827 | bool isVisible = _isVisible; | 849 | bool isVisible = _isVisible; |
| 850 | bool canCastShadow = _canCastShadow; | ||
| 828 | uint8_t viewTagBits = _viewTagBits; | 851 | uint8_t viewTagBits = _viewTagBits; |
| 829 | bool isLayeredInFront = _isLayeredInFront; | 852 | bool isLayeredInFront = _isLayeredInFront; |
| 830 | bool isGroupCulled = _isGroupCulled; | 853 | bool isGroupCulled = _isGroupCulled; |
| 831 | 854 | ||
| 832 | render::Transaction transaction; | 855 | render::Transaction transaction; |
| 833 | foreach(auto item, _modelMeshRenderItemsMap.keys()) { | 856 | foreach(auto item, _modelMeshRenderItemsMap.keys()) { |
| 834 | transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, | 857 | transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, canCastShadow, |
| 835 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { | 858 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { |
| 836 | data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, viewTagBits, isGroupCulled); | 859 | data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, canCastShadow, viewTagBits, isGroupCulled); |
| 837 | data.setLayer(isLayeredInFront, isLayeredInHUD); | 860 | data.setLayer(isLayeredInFront, isLayeredInHUD); |
| 838 | }); | 861 | }); |
| 839 | } | 862 | } |
| 840 | foreach(auto item, _collisionRenderItemsMap.keys()) { | 863 | foreach(auto item, _collisionRenderItemsMap.keys()) { |
| 841 | transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, | 864 | transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, canCastShadow, |
| 842 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { | 865 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { |
| 843 | data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, viewTagBits, isGroupCulled); | 866 | data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, canCastShadow, viewTagBits, isGroupCulled); |
| 844 | data.setLayer(isLayeredInFront, isLayeredInHUD); | 867 | data.setLayer(isLayeredInFront, isLayeredInHUD); |
| 845 | }); | 868 | }); |
| 846 | } | 869 | } |
| @@ -1650,15 +1673,16 @@ void Model::addMaterial(graphics::MaterialLayer material, const std::string& par · 803 unmodified lines | |||
| 1650 | uint8_t viewTagBits = getViewTagBits(); | 1673 | uint8_t viewTagBits = getViewTagBits(); |
| 1651 | bool layeredInFront = isLayeredInFront(); | 1674 | bool layeredInFront = isLayeredInFront(); |
| 1652 | bool layeredInHUD = isLayeredInHUD(); | 1675 | bool layeredInHUD = isLayeredInHUD(); |
| 1676 | bool canCastShadow = _canCastShadow; | ||
| 1653 | bool wireframe = isWireframe(); | 1677 | bool wireframe = isWireframe(); |
| 1654 | auto meshIndex = _modelMeshRenderItemShapes[shapeID].meshIndex; | 1678 | auto meshIndex = _modelMeshRenderItemShapes[shapeID].meshIndex; |
| 1655 | bool invalidatePayloadShapeKey = shouldInvalidatePayloadShapeKey(meshIndex); | 1679 | bool invalidatePayloadShapeKey = shouldInvalidatePayloadShapeKey(meshIndex); |
| 1656 | bool useDualQuaternionSkinning = _useDualQuaternionSkinning; | 1680 | bool useDualQuaternionSkinning = _useDualQuaternionSkinning; |
| 1657 | transaction.updateItem<ModelMeshPartPayload>(itemID, [material, visible, layeredInFront, layeredInHUD, viewTagBits, | 1681 | transaction.updateItem<ModelMeshPartPayload>(itemID, [material, visible, layeredInFront, layeredInHUD, viewTagBits, canCastShadow, |
| 1658 | invalidatePayloadShapeKey, wireframe, useDualQuaternionSkinning](ModelMeshPartPayload& data) { | 1682 | invalidatePayloadShapeKey, wireframe, useDualQuaternionSkinning](ModelMeshPartPayload& data) { |
| 1659 | data.addMaterial(material); | 1683 | data.addMaterial(material); |
| 1660 | // if the material changed, we might need to update our item key or shape key | 1684 | // if the material changed, we might need to update our item key or shape key |
| 1661 | data.updateKey(visible, layeredInFront || layeredInHUD, viewTagBits); | 1685 | data.updateKey(visible, layeredInFront || layeredInHUD, canCastShadow, viewTagBits); |
| 1662 | data.setShapeKey(invalidatePayloadShapeKey, wireframe, useDualQuaternionSkinning); | 1686 | data.setShapeKey(invalidatePayloadShapeKey, wireframe, useDualQuaternionSkinning); |
| 1663 | }); | 1687 | }); |
| 1664 | } | 1688 | } |
| @@ -1676,15 +1700,16 @@ void Model::removeMaterial(graphics::MaterialPointer material, const std::string · 11 unmodified lines | |||
| 1676 | uint8_t viewTagBits = getViewTagBits(); | 1700 | uint8_t viewTagBits = getViewTagBits(); |
| 1677 | bool layeredInFront = isLayeredInFront(); | 1701 | bool layeredInFront = isLayeredInFront(); |
| 1678 | bool layeredInHUD = isLayeredInHUD(); | 1702 | bool layeredInHUD = isLayeredInHUD(); |
| 1703 | bool canCastShadow = _canCastShadow; | ||
| 1679 | bool wireframe = isWireframe(); | 1704 | bool wireframe = isWireframe(); |
| 1680 | auto meshIndex = _modelMeshRenderItemShapes[shapeID].meshIndex; | 1705 | auto meshIndex = _modelMeshRenderItemShapes[shapeID].meshIndex; |
| 1681 | bool invalidatePayloadShapeKey = shouldInvalidatePayloadShapeKey(meshIndex); | 1706 | bool invalidatePayloadShapeKey = shouldInvalidatePayloadShapeKey(meshIndex); |
| 1682 | bool useDualQuaternionSkinning = _useDualQuaternionSkinning; | 1707 | bool useDualQuaternionSkinning = _useDualQuaternionSkinning; |
| 1683 | transaction.updateItem<ModelMeshPartPayload>(itemID, [material, visible, layeredInFront, layeredInHUD, viewTagBits, | 1708 | transaction.updateItem<ModelMeshPartPayload>(itemID, [material, visible, layeredInFront, layeredInHUD, viewTagBits, canCastShadow, |
| 1684 | invalidatePayloadShapeKey, wireframe, useDualQuaternionSkinning](ModelMeshPartPayload& data) { | 1709 | invalidatePayloadShapeKey, wireframe, useDualQuaternionSkinning](ModelMeshPartPayload& data) { |
| 1685 | data.removeMaterial(material); | 1710 | data.removeMaterial(material); |
| 1686 | // if the material changed, we might need to update our item key or shape key | 1711 | // if the material changed, we might need to update our item key or shape key |
| 1687 | data.updateKey(visible, layeredInFront || layeredInHUD, viewTagBits); | 1712 | data.updateKey(visible, layeredInFront || layeredInHUD, canCastShadow, viewTagBits); |
| 1688 | data.setShapeKey(invalidatePayloadShapeKey, wireframe, useDualQuaternionSkinning); | 1713 | data.setShapeKey(invalidatePayloadShapeKey, wireframe, useDualQuaternionSkinning); |
| 1689 | }); | 1714 | }); |
| 1690 | } | 1715 | } |