| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010, Google Inc. | 2 * Copyright 2010, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 o3d.Shape.prototype.writeToDrawLists = | 108 o3d.Shape.prototype.writeToDrawLists = |
| 109 function(drawListInfos, world, transform) { | 109 function(drawListInfos, world, transform) { |
| 110 var elements = this.elements; | 110 var elements = this.elements; |
| 111 | 111 |
| 112 // Iterate through elements of this shape. | 112 // Iterate through elements of this shape. |
| 113 for (var i = 0; i < elements.length; ++i) { | 113 for (var i = 0; i < elements.length; ++i) { |
| 114 var element = elements[i]; | 114 var element = elements[i]; |
| 115 | 115 |
| 116 // For each element look at the DrawElements for that element. | 116 // For each element look at the DrawElements for that element. |
| 117 for (var j = 0; j < element.drawElements.length; ++j) { | 117 for (var j = 0; j < element.drawElements.length; ++j) { |
| 118 this.gl.client.render_stats_['drawElementsProcessed']++; |
| 118 var drawElement = element.drawElements[j]; | 119 var drawElement = element.drawElements[j]; |
| 119 var material = drawElement.material || drawElement.owner.material; | 120 var material = drawElement.material || drawElement.owner.material; |
| 120 var materialDrawList = material.drawList; | 121 var materialDrawList = material.drawList; |
| 122 var rendered = false; |
| 121 | 123 |
| 122 // Iterate through the drawlists we might write to. | 124 // Iterate through the drawlists we might write to. |
| 123 for (var k = 0; k < drawListInfos.length; ++k) { | 125 for (var k = 0; k < drawListInfos.length; ++k) { |
| 124 var drawListInfo = drawListInfos[k]; | 126 var drawListInfo = drawListInfos[k]; |
| 125 var list = drawListInfo.list; | 127 var list = drawListInfo.list; |
| 126 var context = drawListInfo.context; | |
| 127 | 128 |
| 128 // If any of those drawlists matches the material on the drawElement, | 129 // If any of those drawlists matches the material on the drawElement, |
| 129 // add the drawElement to the list. | 130 // add the drawElement to the list. |
| 130 if (materialDrawList == list) { | 131 if (materialDrawList == list) { |
| 132 var context = drawListInfo.context; |
| 133 var view = context.view; |
| 134 var projection = context.projection; |
| 135 |
| 136 var worldViewProjection = [[], [], [], []]; |
| 137 var viewProjection = [[], [], [], []]; |
| 138 o3d.Transform.compose(projection, view, viewProjection); |
| 139 o3d.Transform.compose(viewProjection, world, worldViewProjection); |
| 140 |
| 141 if (element.cull && element.boundingBox) { |
| 142 if (!element.boundingBox.inFrustum(worldViewProjection)) { |
| 143 continue; |
| 144 } |
| 145 } |
| 146 |
| 147 rendered = true; |
| 131 list.list_.push({ | 148 list.list_.push({ |
| 132 view: context.view, | 149 view: view, |
| 133 projection: context.projection, | 150 projection: projection, |
| 134 world: world, | 151 world: world, |
| 152 viewProjection: viewProjection, |
| 153 worldViewProjection: worldViewProjection, |
| 135 transform: transform, | 154 transform: transform, |
| 136 drawElement: drawElement | 155 drawElement: drawElement |
| 137 }); | 156 }); |
| 138 } | 157 } |
| 139 } | 158 } |
| 159 |
| 160 if (rendered) { |
| 161 this.gl.client.render_stats_['drawElementsRendered']++; |
| 162 } else { |
| 163 this.gl.client.render_stats_['drawElementsCulled']++; |
| 164 } |
| 140 } | 165 } |
| 141 } | 166 } |
| 142 }; | 167 }; |
| 143 | 168 |
| 144 | 169 |
| OLD | NEW |