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 | 104 | _snappedToRegistrationPoint(false), |
| 105 | 105 | _url(HTTP_INVALID_COM), |
| 106 | 106 | _isVisible(true), |
| 107 | + _canCastShadow(false), | |
| 107 | 108 | _blendNumber(0), |
| 108 | 109 | _appliedBlendNumber(0), |
| 109 | 110 | _isWireframe(false) |
| @@ -270,6 +271,7 @@ void Model::updateRenderItems() { · 160 unmodified lines | ||
| 270 | 271 | |
| 271 | 272 | bool isWireframe = self->isWireframe(); |
| 272 | 273 | bool isVisible = self->isVisible(); |
| 274 | + bool canCastShadow = self->canCastShadow(); | |
| 273 | 275 | uint8_t viewTagBits = self->getViewTagBits(); |
| 274 | 276 | bool isLayeredInFront = self->isLayeredInFront(); |
| 275 | 277 | bool isLayeredInHUD = self->isLayeredInHUD(); |
| @@ -288,7 +290,7 @@ void Model::updateRenderItems() { · 12 unmodified lines | ||
| 288 | 290 | |
| 289 | 291 | transaction.updateItem<ModelMeshPartPayload>(itemID, [modelTransform, meshState, useDualQuaternionSkinning, |
| 290 | 292 | invalidatePayloadShapeKey, isWireframe, isVisible, |
| 291 | − viewTagBits, isLayeredInFront, | |
| 293 | + canCastShadow, viewTagBits, isLayeredInFront, | |
| 292 | 294 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { |
| 293 | 295 | if (useDualQuaternionSkinning) { |
| 294 | 296 | data.updateClusterBuffer(meshState.clusterDualQuaternions); |
| @@ -313,7 +315,7 @@ void Model::updateRenderItems() { · 18 unmodified lines | ||
| 313 | 315 | } |
| 314 | 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 | 319 | data.setLayer(isLayeredInFront, isLayeredInHUD); |
| 318 | 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 | 776 | bool isLayeredInFront = _isLayeredInFront; |
| 775 | 777 | bool isLayeredInHUD = _isLayeredInHUD; |
| 776 | − | |
| 778 | + bool canCastShadow = _canCastShadow; | |
| 777 | 779 | render::Transaction transaction; |
| 778 | 780 | foreach (auto item, _modelMeshRenderItemsMap.keys()) { |
| 779 | − transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, | |
| 781 | + transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, canCastShadow, | |
| 780 | 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 | 786 | foreach(auto item, _collisionRenderItemsMap.keys()) { |
| 785 | − transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, | |
| 787 | + transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, canCastShadow, | |
| 786 | 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 | 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 | 816 | void Model::setLayeredInFront(bool isLayeredInFront, const render::ScenePointer& scene) { |
| 796 | 817 | if (_isLayeredInFront != isLayeredInFront) { |
| 797 | 818 | _isLayeredInFront = isLayeredInFront; |
| 798 | 819 | |
| 799 | 820 | bool isVisible = _isVisible; |
| 821 | + bool canCastShadow = _canCastShadow; | |
| 800 | 822 | uint8_t viewTagBits = _viewTagBits; |
| 801 | 823 | bool isLayeredInHUD = _isLayeredInHUD; |
| 802 | 824 | bool isGroupCulled = _isGroupCulled; |
| 803 | 825 | |
| 804 | 826 | render::Transaction transaction; |
| 805 | 827 | foreach(auto item, _modelMeshRenderItemsMap.keys()) { |
| 806 | − transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, | |
| 828 | + transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, canCastShadow, | |
| 807 | 829 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { |
| 808 | − data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, viewTagBits, isGroupCulled); | |
| 830 | + data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, canCastShadow, viewTagBits, isGroupCulled); | |
| 809 | 831 | data.setLayer(isLayeredInFront, isLayeredInHUD); |
| 810 | 832 | }); |
| 811 | 833 | } |
| 812 | 834 | foreach(auto item, _collisionRenderItemsMap.keys()) { |
| 813 | − transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, | |
| 835 | + transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, canCastShadow, | |
| 814 | 836 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { |
| 815 | − data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, viewTagBits, isGroupCulled); | |
| 837 | + data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, canCastShadow, viewTagBits, isGroupCulled); | |
| 816 | 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 | 847 | _isLayeredInHUD = isLayeredInHUD; |
| 826 | 848 | |
| 827 | 849 | bool isVisible = _isVisible; |
| 850 | + bool canCastShadow = _canCastShadow; | |
| 828 | 851 | uint8_t viewTagBits = _viewTagBits; |
| 829 | 852 | bool isLayeredInFront = _isLayeredInFront; |
| 830 | 853 | bool isGroupCulled = _isGroupCulled; |
| 831 | 854 | |
| 832 | 855 | render::Transaction transaction; |
| 833 | 856 | foreach(auto item, _modelMeshRenderItemsMap.keys()) { |
| 834 | − transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, | |
| 857 | + transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, canCastShadow, | |
| 835 | 858 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { |
| 836 | − data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, viewTagBits, isGroupCulled); | |
| 859 | + data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, canCastShadow, viewTagBits, isGroupCulled); | |
| 837 | 860 | data.setLayer(isLayeredInFront, isLayeredInHUD); |
| 838 | 861 | }); |
| 839 | 862 | } |
| 840 | 863 | foreach(auto item, _collisionRenderItemsMap.keys()) { |
| 841 | − transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, | |
| 864 | + transaction.updateItem<ModelMeshPartPayload>(item, [isVisible, viewTagBits, isLayeredInFront, canCastShadow, | |
| 842 | 865 | isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) { |
| 843 | − data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, viewTagBits, isGroupCulled); | |
| 866 | + data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, canCastShadow, viewTagBits, isGroupCulled); | |
| 844 | 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 | 1673 | uint8_t viewTagBits = getViewTagBits(); |
| 1651 | 1674 | bool layeredInFront = isLayeredInFront(); |
| 1652 | 1675 | bool layeredInHUD = isLayeredInHUD(); |
| 1676 | + bool canCastShadow = _canCastShadow; | |
| 1653 | 1677 | bool wireframe = isWireframe(); |
| 1654 | 1678 | auto meshIndex = _modelMeshRenderItemShapes[shapeID].meshIndex; |
| 1655 | 1679 | bool invalidatePayloadShapeKey = shouldInvalidatePayloadShapeKey(meshIndex); |
| 1656 | 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 | 1682 | invalidatePayloadShapeKey, wireframe, useDualQuaternionSkinning](ModelMeshPartPayload& data) { |
| 1659 | 1683 | data.addMaterial(material); |
| 1660 | 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 | 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 | 1700 | uint8_t viewTagBits = getViewTagBits(); |
| 1677 | 1701 | bool layeredInFront = isLayeredInFront(); |
| 1678 | 1702 | bool layeredInHUD = isLayeredInHUD(); |
| 1703 | + bool canCastShadow = _canCastShadow; | |
| 1679 | 1704 | bool wireframe = isWireframe(); |
| 1680 | 1705 | auto meshIndex = _modelMeshRenderItemShapes[shapeID].meshIndex; |
| 1681 | 1706 | bool invalidatePayloadShapeKey = shouldInvalidatePayloadShapeKey(meshIndex); |
| 1682 | 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 | 1709 | invalidatePayloadShapeKey, wireframe, useDualQuaternionSkinning](ModelMeshPartPayload& data) { |
| 1685 | 1710 | data.removeMaterial(material); |
| 1686 | 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 | 1713 | data.setShapeKey(invalidatePayloadShapeKey, wireframe, useDualQuaternionSkinning); |
| 1689 | 1714 | }); |
| 1690 | 1715 | } |