Skip to content

Commit

Permalink
Derived command crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Sep 5, 2018
1 parent 3a3d059 commit 34663f4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 17 deletions.
15 changes: 15 additions & 0 deletions Source/Renderer/DrawCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ define([
this._castShadows = defaultValue(options.castShadows, false);
this._receiveShadows = defaultValue(options.receiveShadows, false);
this._pickId = options.pickId;
this._pickOnly = defaultValue(options.pickOnly, false);

this.dirty = true;
this.lastDirtyTime = 0;
Expand Down Expand Up @@ -471,6 +472,19 @@ define([
this.dirty = true;
}
}
},
/**
* Whether this command should be executed in the pick pass only.
*
* @memberof DrawCommand.prototype
* @type {Boolean}
* @default false
* @readonly
*/
pickOnly : {
get : function() {
return this._pickOnly;
}
}
});

Expand Down Expand Up @@ -506,6 +520,7 @@ define([
result._castShadows = command._castShadows;
result._receiveShadows = command._receiveShadows;
result._pickId = command._pickId;
result._pickOnly = command._pickOnly;

result.dirty = true;
result.lastDirtyTime = 0;
Expand Down
9 changes: 6 additions & 3 deletions Source/Scene/ClassificationPrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,8 @@ define([
if (!defined(command)) {
command = pickCommands[j] = new DrawCommand({
owner : classificationPrimitive,
primitiveType : primitive._primitiveType
primitiveType : primitive._primitiveType,
pickOnly : true
});
}

Expand All @@ -820,7 +821,8 @@ define([
if (!defined(command)) {
command = pickCommands[j + 1] = new DrawCommand({
owner : classificationPrimitive,
primitiveType : primitive._primitiveType
primitiveType : primitive._primitiveType,
pickOnly : true
});
}

Expand All @@ -838,7 +840,8 @@ define([
if (!defined(command)) {
command = pickCommands[j + 2] = new DrawCommand({
owner : classificationPrimitive,
primitiveType : primitive._primitiveType
primitiveType : primitive._primitiveType,
pickOnly : true
});
}

Expand Down
3 changes: 2 additions & 1 deletion Source/Scene/EllipsoidPrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ define([
owner : defaultValue(options._owner, this)
});
this._pickCommand = new DrawCommand({
owner : defaultValue(options._owner, this)
owner : defaultValue(options._owner, this),
pickOnly : true
});

var that = this;
Expand Down
12 changes: 2 additions & 10 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -1475,12 +1475,6 @@ define([
var useLogDepth = frameState.useLogDepth;
var derivedCommands = command.derivedCommands;

if (frameState.useLogDepthDirty && !command.dirty) {
var needsLogDepthDerivedCommands = useLogDepth && !defined(derivedCommands.logDepth);
var needsDerivedCommands = !useLogDepth && !defined(derivedCommands.depth);
command.dirty = needsLogDepthDerivedCommands || needsDerivedCommands;
}

if (command.dirty) {
command.dirty = false;

Expand Down Expand Up @@ -1518,11 +1512,9 @@ define([
}
}

if (frameState.passes.pick && !defined(command.pickId)) {
return;
if (!command.pickOnly) {
derivedCommands.depth = DerivedCommand.createDepthOnlyDerivedCommand(this, command, context, derivedCommands.depth);
}

derivedCommands.depth = DerivedCommand.createDepthOnlyDerivedCommand(this, command, context, derivedCommands.depth);
}
};

Expand Down
9 changes: 6 additions & 3 deletions Source/Scene/Vector3DTilePrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,8 @@ define([
var stencilPreloadCommand = pickCommands[j * 3];
if (!defined(stencilPreloadCommand)) {
stencilPreloadCommand = pickCommands[j * 3] = new DrawCommand({
owner : primitive
owner : primitive,
pickOnly : true
});
}

Expand All @@ -835,7 +836,8 @@ define([
var stencilDepthCommand = pickCommands[j * 3 + 1];
if (!defined(stencilDepthCommand)) {
stencilDepthCommand = pickCommands[j * 3 + 1] = new DrawCommand({
owner : primitive
owner : primitive,
pickOnly : true
});
}

Expand All @@ -851,7 +853,8 @@ define([
var colorCommand = pickCommands[j * 3 + 2];
if (!defined(colorCommand)) {
colorCommand = pickCommands[j * 3 + 2] = new DrawCommand({
owner : primitive
owner : primitive,
pickOnly : true
});
}

Expand Down

0 comments on commit 34663f4

Please sign in to comment.