Permalink
Browse files

Change the list of commands to a list of objects with lists of comman…

…ds per pass.
  • Loading branch information...
1 parent 99ab7e8 commit 4cb880ef9c810ce74c448d85aaa80912cd27920b @bagnell bagnell committed Sep 14, 2012
@@ -99,6 +99,8 @@
this._colorCommand.primitiveType = this._pickCommand.primitiveType = Cesium.PrimitiveType.LINES;
this._colorCommand.boundingVolume = this._pickCommand.boundingVolume = new Cesium.BoundingSphere();
this._colorCommand.modelMatrix = this._pickCommand.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(position);
+
+ this._commandLists = new Cesium.CommandLists();
var that = this;
this._colorCommand.uniformMap = {
@@ -176,12 +178,15 @@
}
var pass = frameState.passes;
+ this._commandLists.removeAll();
if (pass.color) {
- commandList.push(colorCommand);
+ this._commandLists.colorList.push(colorCommand);
}
if (pass.pick) {
- commandList.push(pickCommand);
+ this._commandLists.pickList.push(pickCommand);
}
+
+ commandList.push(this._commandLists);
};
Box.prototype.isDestroyed = function() {
@@ -214,6 +219,8 @@
this._colorCommand.primitiveType = this._pickCommand.primitiveType = Cesium.PrimitiveType.LINES;
this._colorCommand.boundingVolume = this._pickCommand.boundingVolume = new Cesium.BoundingSphere();
+ this._commandLists = new Cesium.CommandLists();
+
this._mode = undefined;
this._projection = undefined;
@@ -381,14 +388,17 @@
modelMatrix = this._modelMatrix;
}
+ this._commandLists.removeAll();
if (pass.color) {
colorCommand.modelMatrix = modelMatrix;
- commandList.push(colorCommand);
+ this._commandLists.colorList.push(colorCommand);
}
if (pass.pick) {
pickCommand.modelMatrix = modelMatrix;
- commandList.push(pickCommand);
+ this._commandLists.pickList.push(pickCommand);
}
+
+ commandList.push(this._commandLists);
};
// These functions are the same as before.
@@ -16,6 +16,7 @@ define([
'../Renderer/BufferUsage',
'../Renderer/VertexArrayFacade',
'./Command',
+ './CommandLists',
'./SceneMode',
'./Billboard',
'./HorizontalOrigin',
@@ -38,6 +39,7 @@ define([
BufferUsage,
VertexArrayFacade,
Command,
+ CommandLists,
SceneMode,
Billboard,
HorizontalOrigin,
@@ -138,7 +140,7 @@ define([
this._baseVolume = new BoundingSphere();
this._baseVolume2D = new BoundingSphere();
- this._commandList = [];
+ this._commandLists = new CommandLists();
/**
* The 4x4 transformation matrix that transforms each billboard in this collection from model to world coordinates.
@@ -1034,9 +1036,10 @@ define([
var pass = frameState.passes;
var va = this._vaf.va;
var vaLength = va.length;
- var commands = this._commandList;
+ var commands;
var command;
var j;
+ this._commandLists.removeAll();
if (pass.color) {
if (typeof this._sp === 'undefined') {
this._rs = context.createRenderState({
@@ -1049,6 +1052,7 @@ define([
this._sp = context.getShaderCache().getShaderProgram(BillboardCollectionVS, BillboardCollectionFS, attributeIndices);
}
+ commands = this._commandLists.colorList;
commands.length = vaLength;
for (j = 0; j < vaLength; ++j) {
command = commands[j];
@@ -1064,7 +1068,6 @@ define([
command.uniformMap = this._uniforms;
command.vertexArray = va[j].va;
command.renderState = this._rs;
- commandList.push(command);
}
}
if (pass.pick) {
@@ -1081,6 +1084,7 @@ define([
attributeIndices);
}
+ commands = this._commandLists.pickList;
commands.length = vaLength;
for (j = 0; j < vaLength; ++j) {
command = commands[j];
@@ -1096,9 +1100,12 @@ define([
command.uniformMap = this._uniforms;
command.vertexArray = va[j].va;
command.renderState = this._rsPick;
- commandList.push(command);
}
}
+
+ if (!this._commandLists.empty()) {
+ commandList.push(this._commandLists);
+ }
};
/**
@@ -37,6 +37,7 @@ define([
'../Renderer/TextureMinificationFilter',
'../Renderer/TextureWrap',
'./Command',
+ './CommandLists',
'./Projections',
'./Tile',
'./TileState',
@@ -93,6 +94,7 @@ define([
TextureMinificationFilter,
TextureWrap,
Command,
+ CommandLists,
Projections,
Tile,
TileState,
@@ -285,6 +287,8 @@ define([
this._drawNorthPole = false;
this._drawSouthPole = false;
+ this._commandLists = new CommandLists();
+
/**
* Determines the color of the north pole. If the day tile provider imagery does not
* extend over the north pole, it will be filled with this color before applying lighting.
@@ -1562,6 +1566,7 @@ define([
color : new Color(0.0, 0.0, 0.0, 0.0)
};
+ var scratchQuadCommands = [];
/**
* @private
*/
@@ -2039,9 +2044,13 @@ define([
this._projection = projection;
var pass = frameState.passes;
+ var commands;
+ this._commandLists.removeAll();
if (pass.color) {
+ commands = this._commandLists.colorList;
+
if (this.showSkyAtmosphere) {
- commandList.push(this._skyCommand);
+ commands.push(this._skyCommand);
}
if (this._renderQueue.length !== 0) {
@@ -2053,8 +2062,8 @@ define([
});
// render tiles to FBO
- var commands = this._tileCommandList;
- commands.length = this._renderQueue.length;
+ var tileCommands = this._tileCommandList;
+ tileCommands.length = this._renderQueue.length;
var j = 0;
while (this._renderQueue.length > 0) {
var curTile = this._renderQueue.dequeue();
@@ -2074,9 +2083,9 @@ define([
var centerEye = mv.multiplyByVector(new Cartesian4(rtc.x, rtc.y, rtc.z, 1.0));
curTile.modelView = mv.setColumn(3, centerEye, curTile.modelView);
- var command = commands[j++];
+ var command = tileCommands[j++];
if (typeof command === 'undefined') {
- command = commands[j - 1] = new Command();
+ command = tileCommands[j - 1] = new Command();
}
command.framebuffer = this._fb;
@@ -2086,36 +2095,48 @@ define([
command.vertexArray = curTile._extentVA;
command.uniformMap = curTile._drawUniforms;
- commandList.push(command);
+ commands.push(command);
}
// render quad with vertical and horizontal gaussian blur
- this._quadV.update(context, frameState, commandList);
- this._quadH.update(context, frameState, commandList);
+ scratchQuadCommands.length = 0;
+ this._quadV.update(context, frameState, scratchQuadCommands);
+ commands.push.apply(commands, scratchQuadCommands[0].colorList);
+ scratchQuadCommands.length = 0;
+ this._quadH.update(context, frameState, scratchQuadCommands);
+ commands.push.apply(commands, scratchQuadCommands[0].colorList);
+ scratchQuadCommands.length = 0;
// render quads to fill the poles
if (this._mode === SceneMode.SCENE3D) {
if (this._drawNorthPole) {
- commandList.push(this._northPoleCommand);
+ commands.push(this._northPoleCommand);
}
if (this._drawSouthPole) {
- commandList.push(this._southPoleCommand);
+ commands.push(this._southPoleCommand);
}
}
// render depth plane
if (this._mode === SceneMode.SCENE3D) {
- commandList.push(this._depthCommand);
+ commands.push(this._depthCommand);
}
if (typeof this._quadLogo !== 'undefined' && !this._quadLogo.isDestroyed()) {
- this._quadLogo.update(context, frameState, commandList);
+ this._quadLogo.update(context, frameState, scratchQuadCommands);
+ commands.push.apply(commands, scratchQuadCommands[0].colorList);
}
}
- } else if (pass.pick) {
+ }
+ if (pass.pick) {
// Not actually pickable, but render depth-only so primitives on the backface
// of the globe are not picked.
- commandList.push(this._depthCommand);
+ commands = this._commandLists.pickList;
+ commands.push(this._depthCommand);
+ }
+
+ if (!this._commandLists.empty()) {
+ commandList.push(this._commandLists);
}
};
Oops, something went wrong.

0 comments on commit 4cb880e

Please sign in to comment.