public ShadowTexture GetOptimalTexture(float size) { int indexLow = 0; int indexUp = Textures.Count - 1; int indexDiff = indexUp - indexLow; int indexMiddle; while (indexDiff >= 0) { indexMiddle = (indexDiff / 2) + indexLow; ShadowTexture texture = Textures[indexMiddle]; float minSizeMiddle = texture.MinWidth; if (size == minSizeMiddle || indexDiff == 0 && size > minSizeMiddle) { return(texture); } else if (minSizeMiddle > size) { indexUp = indexMiddle - 1; } else { indexLow = indexMiddle + 1; } indexDiff = indexUp - indexLow; } ; return(indexUp > 0 ? Textures[indexUp] : Textures[indexLow]); }
private static Vector2 GetShadowSize(ref Vector2 size, string textureSet, out ShadowTexture texture) { Vector2 shadowSize = size; ShadowTextureSet set; bool found = m_textureSets.TryGetValue(textureSet, out set); if (!found) { found = m_textureSets.TryGetValue(TEXT_SHADOW_DEFAULT, out set); if (!found) throw new Exception("Missing Default shadow texture. Check ShadowTextureSets.sbc"); } texture = set.GetOptimalTexture(size.X); shadowSize.X *= texture.GrowFactorWidth; shadowSize.Y *= texture.GrowFactorHeight; return shadowSize; }
private static Vector2 GetShadowSize(ref Vector2 size, string textureSet, out ShadowTexture texture) { Vector2 shadowSize = size; ShadowTextureSet set; bool found = m_textureSets.TryGetValue(textureSet, out set); if (!found) { found = m_textureSets.TryGetValue(TEXT_SHADOW_DEFAULT, out set); if (!found) { throw new Exception("Missing Default shadow texture. Check ShadowTextureSets.sbc"); } } texture = set.GetOptimalTexture(size.X); shadowSize.X *= texture.GrowFactorWidth; shadowSize.Y *= texture.GrowFactorHeight; return(shadowSize); }