public void _CacheWorldBounds() { if (!_t) { _t = this.transform; } _worldBounds = SFRenderer._TransformRect(_t.localToWorldMatrix, _bounds); }
public void OnDisable() { // OnDisable for editor scripts is essentially used when you change focus. inEditMode = false; if (Camera.main) { SFRenderer sfRen = Camera.main.GetComponent <SFRenderer>(); if (sfRen) { sfRen._shadows = preserveShadowSetting | sfRen._shadows; } } }
public Rect _CalcCullBounds(Matrix4x4 vpMatrix) { var lightMatrix = _ModelMatrix(true); var mvp = vpMatrix*lightMatrix; var area = new Rect(-_radius, -_radius, 2.0f*_radius, 2.0f*_radius); var bounds = _rt.rect; var cull = area; cull = QuadrantCull(cull, mvp, Rect.MinMaxRect(bounds.xMin, bounds.yMin, area.xMax, area.yMax)); cull = QuadrantCull(cull, mvp, Rect.MinMaxRect(area.xMin, bounds.yMin, bounds.xMax, area.yMax)); cull = QuadrantCull(cull, mvp, Rect.MinMaxRect(bounds.xMin, area.yMin, area.xMax, bounds.yMax)); cull = QuadrantCull(cull, mvp, Rect.MinMaxRect(area.xMin, area.yMin, bounds.xMax, bounds.yMax)); return (_cullBounds = SFRenderer._TransformRect(lightMatrix, cull)); }
public void _CacheWorldBounds() { var matrix = this._lightMatrix; _worldBounds = SFRenderer._TransformRect(_rt.localToWorldMatrix * matrix, new Rect(-1, -1, 2, 2)); }
private static Rect QuadrantCull(Rect cull, Matrix4x4 mvp, Rect r) { return(SFRenderer._FastCull(mvp, r) ? Union(cull, r) : cull); }
public override void OnInspectorGUI() { this.serializedObject.Update(); SFPolygon poly = this.target as SFPolygon; EditorGUILayout.HelpBox("When editing the shadow geometry, shift+click to add new points. Command+click or control+click to remove point.", MessageType.Info); GUILayout.BeginHorizontal("box"); if (GUILayout.Button(SFPolygonEditor.inEditMode ? "Stop Editing" : "Edit Shadow Geometry")) { SFPolygonEditor.inEditMode = !SFPolygonEditor.inEditMode; if (Camera.main) { SFRenderer sfRen = Camera.main.GetComponent <SFRenderer>(); if (sfRen) { if (inEditMode) { preserveShadowSetting = sfRen._shadows; sfRen._shadows = false; } else { sfRen._shadows = preserveShadowSetting; } } } EditorUtility.SetDirty(target); } if (GUILayout.Button("Flip Inside-Out")) { Undo.RecordObjects(this.targets, "Flip Inside-Out"); foreach (SFPolygon t in this.targets) { t._FlipInsideOut(); EditorUtility.SetDirty(t); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); if (poly.GetComponent <Collider2D> () != null) { Undo.RecordObjects(this.targets, "Copy from Collider"); if (GUILayout.Button("Copy from Collider")) { foreach (SFPolygon t in this.targets) { t._CopyVertsFromCollider(); EditorUtility.SetDirty(t); } } } if (poly.GetComponent <SpriteRenderer>() != null) { Undo.RecordObjects(this.targets, "Copy from Sprite"); if (GUILayout.Button("Copy from Sprite")) { foreach (SFPolygon t in this.targets) { t._CopyVertsFromSprite(); EditorUtility.SetDirty(t); } } } GUILayout.EndHorizontal(); PropertyField("_looped"); if (poly.GetComponent <CircleCollider2D>() != null) { PropertyField("circleVertCount"); } //PropertyField("_shadowLayers"); serializedObject.FindProperty("_shadowLayers").intValue = EditorGUILayout.LayerField("shadowLayers", serializedObject.FindProperty("_shadowLayers").intValue); PropertyField("_lightPenetration", (p) => p.floatValue = Math.Max(0.0f, p.floatValue)); PropertyField("_opacity", (p) => p.floatValue = Mathf.Clamp01(p.floatValue)); this.serializedObject.ApplyModifiedProperties(); }