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

Light picker has option to be enabled and disabled #702

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/away3d/materials/MaterialBase.as
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ package away3d.materials
*/
arcane function renderPass(index:uint, renderable:IRenderable, stage3DProxy:Stage3DProxy, entityCollector:EntityCollector, viewProjection:Matrix3D):void
{
if (_lightPicker)
if (_lightPicker && _lightPicker.enabled)
_lightPicker.collectLights(renderable, entityCollector);

var pass:MaterialPassBase = _passes[index];
Expand Down
4 changes: 2 additions & 2 deletions src/away3d/materials/MultiPassMaterialBase.as
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@
*/
protected function get numLights():int
{
return _lightPicker? _lightPicker.numLightProbes + _lightPicker.numDirectionalLights + _lightPicker.numPointLights +
return _lightPicker && _lightPicker.enabled ? _lightPicker.numLightProbes + _lightPicker.numDirectionalLights + _lightPicker.numPointLights +
_lightPicker.numCastingDirectionalLights + _lightPicker.numCastingPointLights : 0;
}

Expand All @@ -740,7 +740,7 @@
*/
private function get numNonCasters():int
{
return _lightPicker? _lightPicker.numLightProbes + _lightPicker.numDirectionalLights + _lightPicker.numPointLights : 0;
return _lightPicker && _lightPicker.enabled? _lightPicker.numLightProbes + _lightPicker.numDirectionalLights + _lightPicker.numPointLights : 0;
}

/**
Expand Down
23 changes: 19 additions & 4 deletions src/away3d/materials/lightpickers/LightPickerBase.as
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ package away3d.materials.lightpickers
import away3d.core.traverse.*;
import away3d.library.assets.*;
import away3d.lights.*;

import flash.geom.*;

import flash.events.Event;
import flash.geom.*;

use namespace arcane;

Expand All @@ -31,6 +32,7 @@ package away3d.materials.lightpickers
protected var _castingDirectionalLights:Vector.<DirectionalLight>;
protected var _lightProbes:Vector.<LightProbe>;
protected var _lightProbeWeights:Vector.<Number>;
protected var _enabled:Boolean=true;

/**
* Creates a new LightPickerBase object.
Expand Down Expand Up @@ -193,6 +195,19 @@ package away3d.materials.lightpickers
for (i = 0; i < _numLightProbes; ++i)
_lightProbeWeights[i] *= total;
}

}

/**
* Flag indicating whether to consider this light picker during pass
*/
public function get enabled():Boolean {
return _enabled;
}

public function set enabled(value:Boolean):void {
if(_enabled!=value) {
_enabled = value;
dispatchEvent(new Event(Event.CHANGE));
}
}
}
}
2 changes: 1 addition & 1 deletion src/away3d/materials/passes/LightingPass.as
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ package away3d.materials.passes
var numPointLights:int = _numPointLights;
var numLightProbes:int = _numLightProbes;

if (_lightPicker) {
if (_lightPicker && _lightPicker.enabled) {
_numDirectionalLights = calculateNumDirectionalLights(_lightPicker.numDirectionalLights);
_numPointLights = calculateNumPointLights(_lightPicker.numPointLights);
_numLightProbes = calculateNumProbes(_lightPicker.numLightProbes);
Expand Down
2 changes: 1 addition & 1 deletion src/away3d/materials/passes/MaterialPassBase.as
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ package away3d.materials.passes
*/
protected function updateLights():void
{

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore this

}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/away3d/materials/passes/ShadowCasterPass.as
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ package away3d.materials.passes
var numPointLights:int;
var numDirectionalLights:int;

if (_lightPicker) {
if (_lightPicker && _lightPicker.enabled) {
numPointLights = _lightPicker.numCastingPointLights > 0? 1 : 0;
numDirectionalLights = _lightPicker.numCastingDirectionalLights > 0? 1 : 0;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/away3d/materials/passes/SuperShaderPass.as
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ package away3d.materials.passes
override protected function updateLights():void
{
// super.updateLights();
if (_lightPicker && !_ignoreLights) {
if (_lightPicker && _lightPicker.enabled && !_ignoreLights ) {
_numPointLights = _lightPicker.numPointLights;
_numDirectionalLights = _lightPicker.numDirectionalLights;
_numLightProbes = _lightPicker.numLightProbes;
Expand Down