Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 50 files). Show all
Unified · Split
| @@ -722,42 +722,12 @@ gpu::ShaderPointer GeometryCache::_forwardUnlitShader; · 721 unmodified lines | ||
| 722 | 722 | gpu::ShaderPointer GeometryCache::_forwardSimpleFadeShader; |
| 723 | 723 | gpu::ShaderPointer GeometryCache::_forwardUnlitFadeShader; |
| 724 | 724 | |
| 725 | −render::ShapePipelinePointer GeometryCache::_simpleOpaquePipeline; | |
| 726 | −render::ShapePipelinePointer GeometryCache::_simpleTransparentPipeline; | |
| 727 | −render::ShapePipelinePointer GeometryCache::_forwardSimpleOpaquePipeline; | |
| 728 | −render::ShapePipelinePointer GeometryCache::_forwardSimpleTransparentPipeline; | |
| 729 | −render::ShapePipelinePointer GeometryCache::_simpleOpaqueFadePipeline; | |
| 730 | −render::ShapePipelinePointer GeometryCache::_simpleTransparentFadePipeline; | |
| 731 | −render::ShapePipelinePointer GeometryCache::_simpleWirePipeline; | |
| 732 | − | |
| 733 | −uint8_t GeometryCache::CUSTOM_PIPELINE_NUMBER = 0; | |
| 734 | − | |
| 735 | −render::ShapePipelinePointer GeometryCache::shapePipelineFactory(const render::ShapePlumber& plumber, const render::ShapeKey& key, gpu::Batch& batch) { | |
| 736 | − initializeShapePipelines(); | |
| 737 | − | |
| 738 | − if (key.isWireframe()) { | |
| 739 | − return _simpleWirePipeline; | |
| 740 | − } | |
| 741 | − | |
| 742 | − if (key.isFaded()) { | |
| 743 | − if (key.isTranslucent()) { | |
| 744 | − return _simpleTransparentFadePipeline; | |
| 745 | − } else { | |
| 746 | − return _simpleOpaqueFadePipeline; | |
| 747 | − } | |
| 748 | − } else { | |
| 749 | − if (key.isTranslucent()) { | |
| 750 | − return _simpleTransparentPipeline; | |
| 751 | − } else { | |
| 752 | − return _simpleOpaquePipeline; | |
| 753 | − } | |
| 754 | − } | |
| 755 | −} | |
| 725 | +std::map<std::tuple<bool, bool, bool>, render::ShapePipelinePointer> GeometryCache::_shapePipelines; | |
| 756 | 726 | |
| 757 | 727 | GeometryCache::GeometryCache() : |
| 758 | 728 | _nextID(0) { |
| 759 | 729 | // Let's register its special shapePipeline factory: |
| 760 | − registerShapePipeline(); | |
| 730 | + initializeShapePipelines(); | |
| 761 | 731 | buildShapes(); |
| 762 | 732 | } |
| 763 | 733 | |
| @@ -799,16 +769,14 @@ void GeometryCache::releaseID(int id) { · 35 unmodified lines | ||
| 799 | 769 | } |
| 800 | 770 | |
| 801 | 771 | void GeometryCache::initializeShapePipelines() { |
| 802 | − if (!_simpleOpaquePipeline) { | |
| 803 | − _simpleOpaquePipeline = getShapePipeline(false, false, true, false); | |
| 804 | − _simpleTransparentPipeline = getShapePipeline(false, true, true, false); | |
| 805 | − _forwardSimpleOpaquePipeline = getShapePipeline(false, false, true, false, false, true); | |
| 806 | − _forwardSimpleTransparentPipeline = getShapePipeline(false, true, true, false, false, true); | |
| 807 | − | |
| 808 | − // FIXME: these need forward pipelines | |
| 809 | − _simpleOpaqueFadePipeline = getFadingShapePipeline(false, false, false, false, false); | |
| 810 | − _simpleTransparentFadePipeline = getFadingShapePipeline(false, true, false, false, false); | |
| 811 | − _simpleWirePipeline = getShapePipeline(false, false, true, true); | |
| 772 | + if (_shapePipelines.empty()) { | |
| 773 | + const int NUM_PIPELINES = 8; | |
| 774 | + for (int i = 0; i < NUM_PIPELINES; ++i) { | |
| 775 | + bool transparent = i & 1; | |
| 776 | + bool unlit = i & 2; | |
| 777 | + bool forward = i & 4; | |
| 778 | + _shapePipelines[std::make_tuple(transparent, unlit, forward)] = getShapePipeline(false, transparent, true, unlit, false, forward); | |
| 779 | + } | |
| 812 | 780 | } |
| 813 | 781 | } |
| 814 | 782 | |
| @@ -1027,7 +995,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, con · 212 unmodified lines | ||
| 1027 | 995 | int* colorData = new int[details.vertices]; |
| 1028 | 996 | int* colorDataAt = colorData; |
| 1029 | 997 | |
| 1030 | − const glm::vec3 NORMAL(0.0f, 1.0f, 0.0f); | |
| 998 | + const glm::vec3 NORMAL(0.0f, -1.0f, 0.0f); | |
| 1031 | 999 | auto pointCount = points.size(); |
| 1032 | 1000 | auto colorCount = colors.size(); |
| 1033 | 1001 | int compactColor = 0; |
| @@ -1105,7 +1073,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con · 71 unmodified lines | ||
| 1105 | 1073 | int* colorData = new int[details.vertices]; |
| 1106 | 1074 | int* colorDataAt = colorData; |
| 1107 | 1075 | |
| 1108 | − const glm::vec3 NORMAL(0.0f, 1.0f, 0.0f); | |
| 1076 | + const glm::vec3 NORMAL(0.0f, -1.0f, 0.0f); | |
| 1109 | 1077 | auto pointCount = points.size(); |
| 1110 | 1078 | auto colorCount = colors.size(); |
| 1111 | 1079 | for (auto i = 0; i < pointCount; i++) { |
| @@ -1193,7 +1161,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con · 81 unmodified lines | ||
| 1193 | 1161 | int* colorData = new int[details.vertices]; |
| 1194 | 1162 | int* colorDataAt = colorData; |
| 1195 | 1163 | |
| 1196 | − const glm::vec3 NORMAL(0.0f, 1.0f, 0.0f); | |
| 1164 | + const glm::vec3 NORMAL(0.0f, -1.0f, 0.0f); | |
| 1197 | 1165 | for (int i = 0; i < points.size(); i++) { |
| 1198 | 1166 | glm::vec3 point = points[i]; |
| 1199 | 1167 | glm::vec2 texCoord = texCoords[i]; |
| @@ -2281,8 +2249,7 @@ void renderInstances(RenderArgs* args, gpu::Batch& batch, const glm::vec4& color · 1081 unmodified lines | ||
| 2281 | 2249 | |
| 2282 | 2250 | if (isWire) { |
| 2283 | 2251 | DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, shape, data.count(), data.buffers[INSTANCE_COLOR_BUFFER]); |
| 2284 | − } | |
| 2285 | − else { | |
| 2252 | + } else { | |
| 2286 | 2253 | DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, shape, data.count(), data.buffers[INSTANCE_COLOR_BUFFER]); |
| 2287 | 2254 | } |
| 2288 | 2255 | }); |