Modifications around addLight from Inc
* Removed redundant checks at the start of the function. * changed the return value to void because the "return false" were redundant, and simply made it so the lightInAtlas is set at the end of the function. * Removed unused variable
This commit is contained in:
parent
614385ea7b
commit
63716eea17
|
@ -115,7 +115,7 @@ class Inc {
|
|||
for (light in iron.Scene.active.lights) {
|
||||
if (!light.lightInAtlas && !light.culledLight && light.visible && light.shadowMapScale > 0.0
|
||||
&& light.data.raw.strength > 0.0 && light.data.raw.cast_shadow) {
|
||||
light.lightInAtlas = ShadowMapAtlas.addLight(light);
|
||||
ShadowMapAtlas.addLight(light);
|
||||
}
|
||||
}
|
||||
// update point light data before rendering
|
||||
|
@ -564,11 +564,7 @@ class ShadowMapAtlas {
|
|||
* @param light of type LightObject to be added to an yatlas
|
||||
* @return if the light was added succesfully
|
||||
*/
|
||||
public static function addLight(light: LightObject): Bool {
|
||||
// check if light can be added based on culling
|
||||
if (light.culledLight || light.shadowMapScale == 0.0)
|
||||
return false;
|
||||
|
||||
public static function addLight(light: LightObject) {
|
||||
var atlasName = shadowMapAtlasName(light.data.raw.type);
|
||||
var atlas = shadowMapAtlases.get(atlasName);
|
||||
if (atlas == null) {
|
||||
|
@ -580,15 +576,15 @@ class ShadowMapAtlas {
|
|||
// find a free tile for this light
|
||||
var mainTile = ShadowMapTile.assignTiles(light, atlas, null);
|
||||
if (mainTile == null)
|
||||
return false;
|
||||
// push main tile to active tiles
|
||||
return;
|
||||
|
||||
atlas.activeTiles.push(mainTile);
|
||||
// notify the tile on light remove
|
||||
light.tileNotifyOnRemove = mainTile.notifyOnLightRemove;
|
||||
// notify atlas when this tile is freed
|
||||
mainTile.notifyOnFree = atlas.freeActiveTile;
|
||||
|
||||
return true;
|
||||
// "lock" light to make sure it's not eligible to be added again
|
||||
light.lightInAtlas = true;
|
||||
}
|
||||
|
||||
static inline function shadowMapAtlasSize(light:LightObject):Int {
|
||||
|
@ -805,7 +801,6 @@ class ShadowMapTile {
|
|||
static inline function findCreateTiles(light: LightObject, oldTile: ShadowMapTile, atlas: ShadowMapAtlas, tilesPerLightType: Int, tileSize: Int): Array<ShadowMapTile> {
|
||||
var tilesFound: Array<ShadowMapTile> = [];
|
||||
|
||||
var updateAtlas = false;
|
||||
while (tilesFound.length < tilesPerLightType) {
|
||||
findTiles(light, oldTile, atlas.tiles, tileSize, tilesPerLightType, tilesFound);
|
||||
|
||||
|
|
Loading…
Reference in a new issue