Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layer.cullingMask and Camera.cullingMask has been removed as not needed #5506

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/scene/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class Camera {
this._clearDepthBuffer = true;
this._clearStencil = 0;
this._clearStencilBuffer = true;
this._cullingMask = 0xFFFFFFFF;
this._cullFaces = true;
this._farClip = 1000;
this._flipFaces = false;
Expand Down Expand Up @@ -177,14 +176,6 @@ class Camera {
return this._clearStencilBuffer;
}

set cullingMask(newValue) {
this._cullingMask = newValue;
}

get cullingMask() {
return this._cullingMask;
}

set cullFaces(newValue) {
this._cullFaces = newValue;
}
Expand Down Expand Up @@ -411,7 +402,6 @@ class Camera {
this.clearStencil = other.clearStencil;
this.clearStencilBuffer = other.clearStencilBuffer;
this.cullFaces = other.cullFaces;
this.cullingMask = other.cullingMask;
this.flipFaces = other.flipFaces;
this.frustumCulling = other.frustumCulling;
this.layers = other.layers;
Expand Down
9 changes: 0 additions & 9 deletions src/scene/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,6 @@ class Layer {
*/
this.instances = options.layerReference ? options.layerReference.instances : new InstanceList();

/**
* Visibility bit mask that interacts with {@link MeshInstance#mask}. Especially useful
* when combined with layerReference, allowing for the filtering of some objects, while
* sharing their list and culling.
*
* @type {number}
*/
this.cullingMask = options.cullingMask ? options.cullingMask : 0xFFFFFFFF;

/**
* @type {import('./mesh-instance.js').MeshInstance[]}
* @ignore
Expand Down
11 changes: 3 additions & 8 deletions src/scene/renderer/forward-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ class ForwardRenderer extends Renderer {
}

// execute first pass over draw calls, in order to update materials / shaders
renderForwardPrepareMaterials(camera, drawCalls, drawCallsCount, sortedLights, cullingMask, layer, pass) {
renderForwardPrepareMaterials(camera, drawCalls, drawCallsCount, sortedLights, layer, pass) {

const addCall = (drawCall, isNewMaterial, lightMaskChanged) => {
_drawCallList.drawCalls.push(drawCall);
Expand All @@ -482,10 +482,6 @@ class ForwardRenderer extends Renderer {
/** @type {import('../mesh-instance.js').MeshInstance} */
const drawCall = drawCalls[i];

// apply visibility override
if (cullingMask && drawCall.mask && !(cullingMask & drawCall.mask))
continue;

if (drawCall.command) {

addCall(drawCall, false, false);
Expand Down Expand Up @@ -697,14 +693,14 @@ class ForwardRenderer extends Renderer {
}
}

renderForward(camera, allDrawCalls, allDrawCallsCount, sortedLights, pass, cullingMask, drawCallback, layer, flipFaces) {
renderForward(camera, allDrawCalls, allDrawCallsCount, sortedLights, pass, drawCallback, layer, flipFaces) {

// #if _PROFILER
const forwardStartTime = now();
// #endif

// run first pass over draw calls and handle material / shader updates
const preparedCalls = this.renderForwardPrepareMaterials(camera, allDrawCalls, allDrawCallsCount, sortedLights, cullingMask, layer, pass);
const preparedCalls = this.renderForwardPrepareMaterials(camera, allDrawCalls, allDrawCallsCount, sortedLights, layer, pass);

// render mesh instances
this.renderForwardInternal(camera, preparedCalls, sortedLights, pass, drawCallback, flipFaces);
Expand Down Expand Up @@ -1143,7 +1139,6 @@ class ForwardRenderer extends Renderer {
visible.length,
layer._splitLights,
shaderPass,
layer.cullingMask,
layer.onDrawCall,
layer,
flipFaces);
Expand Down
13 changes: 3 additions & 10 deletions src/scene/renderer/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -786,16 +786,12 @@ class Renderer {
let visibleLength = 0;
const drawCallsCount = drawCalls.length;

const cullingMask = camera.cullingMask || 0xFFFFFFFF; // if missing assume camera's default value

if (!camera.frustumCulling) {
for (let i = 0; i < drawCallsCount; i++) {
// need to copy array anyway because sorting will happen and it'll break original draw call order assumption
const drawCall = drawCalls[i];
if (!drawCall.visible && !drawCall.command) continue;

// if the object's mask AND the camera's cullingMask is zero then the game object will be invisible from the camera
if (drawCall.mask && (drawCall.mask & cullingMask) === 0) continue;
if (!drawCall.visible && !drawCall.command)
continue;

visibleList[visibleLength] = drawCall;
visibleLength++;
Expand All @@ -810,9 +806,6 @@ class Renderer {
if (!drawCall.visible) continue; // use visible property to quickly hide/show meshInstances
let visible = true;

// if the object's mask AND the camera's cullingMask is zero then the game object will be invisible from the camera
if (drawCall.mask && (drawCall.mask & cullingMask) === 0) continue;

if (drawCall.cull) {
visible = drawCall._isVisible(camera);
// #if _PROFILER
Expand Down Expand Up @@ -924,7 +917,7 @@ class Renderer {

/**
* visibility culling of lights, meshInstances, shadows casters
* Also applies meshInstance.visible and camera.cullingMask
* Also applies meshInstance.visible
*
* @param {import('../composition/layer-composition.js').LayerComposition} comp - The layer
* composition.
Expand Down