diff options
214 files changed, 1074 insertions, 290 deletions
diff --git a/LICENSE.md b/LICENSE.md index 122736f5f1..ca0a9702f7 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -21,3 +21,7 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +********************************************************************** + diff --git a/demos/2d/isometric_light/character_shder.res b/demos/2d/isometric_light/character_shder.res Binary files differnew file mode 100644 index 0000000000..ca221f766c --- /dev/null +++ b/demos/2d/isometric_light/character_shder.res diff --git a/demos/2d/isometric_light/column.scn b/demos/2d/isometric_light/column.scn Binary files differnew file mode 100644 index 0000000000..f0b7683885 --- /dev/null +++ b/demos/2d/isometric_light/column.scn diff --git a/demos/2d/isometric_light/cubio.gd b/demos/2d/isometric_light/cubio.gd new file mode 100644 index 0000000000..30c766936c --- /dev/null +++ b/demos/2d/isometric_light/cubio.gd @@ -0,0 +1,96 @@ + +extends KinematicBody2D + +# member variables here, example: +# var a=2 +# var b="textvar" + +const MAX_SPEED = 300.0 +const IDLE_SPEED = 10.0 +const ACCEL=5.0 +const VSCALE=0.5 +const SHOOT_INTERVAL=0.3 + +var speed=Vector2() +var current_anim="" +var current_mirror=false + +var shoot_countdown=0 + +func _input(ev): + if (ev.type==InputEvent.MOUSE_BUTTON and ev.button_index==1 and ev.pressed and shoot_countdown<=0): + var pos = get_canvas_transform().affine_inverse() * ev.pos + var dir = (pos-get_global_pos()).normalized() + var bullet = preload("res://shoot.scn").instance() + bullet.advance_dir=dir + bullet.set_pos( get_global_pos() + dir * 60 ) + get_parent().add_child(bullet) + shoot_countdown=SHOOT_INTERVAL + + + + +func _fixed_process(delta): + + shoot_countdown-=delta + var dir = Vector2() + if (Input.is_action_pressed("up")): + dir+=Vector2(0,-1) + if (Input.is_action_pressed("down")): + dir+=Vector2(0,1) + if (Input.is_action_pressed("left")): + dir+=Vector2(-1,0) + if (Input.is_action_pressed("right")): + dir+=Vector2(1,0) + + if (dir!=Vector2()): + dir=dir.normalized() + speed = speed.linear_interpolate(dir*MAX_SPEED,delta*ACCEL) + var motion = speed * delta + motion.y*=VSCALE + motion=move(motion) + + if (is_colliding()): + var n = get_collision_normal() + motion=n.slide(motion) + move(motion) + + var next_anim="" + var next_mirror=false + + if (dir==Vector2() and speed.length()<IDLE_SPEED): + next_anim="idle" + next_mirror=false + elif (speed.length()>IDLE_SPEED*0.1): + var angle = atan2(abs(speed.x),speed.y) + + next_mirror = speed.x>0 + if (angle<PI/8): + next_anim="bottom" + next_mirror=false + elif (angle<PI/4+PI/8): + next_anim="bottom_left" + elif (angle<PI*2/4+PI/8): + next_anim="left" + elif (angle<PI*3/4+PI/8): + next_anim="top_left" + else: + next_anim="top" + next_mirror=false + + + if (next_anim!=current_anim or next_mirror!=current_mirror): + get_node("frames").set_flip_h(next_mirror) + get_node("anim").play(next_anim) + current_anim=next_anim + current_mirror=next_mirror + + + +func _ready(): + # Initialization here + set_fixed_process(true) + set_process_input(true) + pass + + diff --git a/demos/2d/isometric_light/cubio.scn b/demos/2d/isometric_light/cubio.scn Binary files differnew file mode 100644 index 0000000000..29fa077389 --- /dev/null +++ b/demos/2d/isometric_light/cubio.scn diff --git a/demos/2d/isometric_light/cubio/idle0001.png b/demos/2d/isometric_light/cubio/idle0001.png Binary files differnew file mode 100644 index 0000000000..837dd38f9c --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0001.png diff --git a/demos/2d/isometric_light/cubio/idle0002.png b/demos/2d/isometric_light/cubio/idle0002.png Binary files differnew file mode 100644 index 0000000000..6137a37a9d --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0002.png diff --git a/demos/2d/isometric_light/cubio/idle0003.png b/demos/2d/isometric_light/cubio/idle0003.png Binary files differnew file mode 100644 index 0000000000..7f3e3e0e31 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0003.png diff --git a/demos/2d/isometric_light/cubio/idle0004.png b/demos/2d/isometric_light/cubio/idle0004.png Binary files differnew file mode 100644 index 0000000000..0a697dadf9 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0004.png diff --git a/demos/2d/isometric_light/cubio/idle0005.png b/demos/2d/isometric_light/cubio/idle0005.png Binary files differnew file mode 100644 index 0000000000..9c47197247 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0005.png diff --git a/demos/2d/isometric_light/cubio/idle0006.png b/demos/2d/isometric_light/cubio/idle0006.png Binary files differnew file mode 100644 index 0000000000..717a7be5b1 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0006.png diff --git a/demos/2d/isometric_light/cubio/idle0007.png b/demos/2d/isometric_light/cubio/idle0007.png Binary files differnew file mode 100644 index 0000000000..dde18399f3 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0007.png diff --git a/demos/2d/isometric_light/cubio/idle0008.png b/demos/2d/isometric_light/cubio/idle0008.png Binary files differnew file mode 100644 index 0000000000..0f716a5d84 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0008.png diff --git a/demos/2d/isometric_light/cubio/idle0009.png b/demos/2d/isometric_light/cubio/idle0009.png Binary files differnew file mode 100644 index 0000000000..d271373f9d --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0009.png diff --git a/demos/2d/isometric_light/cubio/idle0010.png b/demos/2d/isometric_light/cubio/idle0010.png Binary files differnew file mode 100644 index 0000000000..61311be0eb --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0010.png diff --git a/demos/2d/isometric_light/cubio/idle0011.png b/demos/2d/isometric_light/cubio/idle0011.png Binary files differnew file mode 100644 index 0000000000..0b7d32d138 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0011.png diff --git a/demos/2d/isometric_light/cubio/idle0012.png b/demos/2d/isometric_light/cubio/idle0012.png Binary files differnew file mode 100644 index 0000000000..c176034cfa --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0012.png diff --git a/demos/2d/isometric_light/cubio/idle0013.png b/demos/2d/isometric_light/cubio/idle0013.png Binary files differnew file mode 100644 index 0000000000..c37018154b --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0013.png diff --git a/demos/2d/isometric_light/cubio/idle0014.png b/demos/2d/isometric_light/cubio/idle0014.png Binary files differnew file mode 100644 index 0000000000..a4613e4269 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0014.png diff --git a/demos/2d/isometric_light/cubio/idle0015.png b/demos/2d/isometric_light/cubio/idle0015.png Binary files differnew file mode 100644 index 0000000000..8354588b72 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0015.png diff --git a/demos/2d/isometric_light/cubio/idle0016.png b/demos/2d/isometric_light/cubio/idle0016.png Binary files differnew file mode 100644 index 0000000000..4e5796fb89 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0016.png diff --git a/demos/2d/isometric_light/cubio/idle0017.png b/demos/2d/isometric_light/cubio/idle0017.png Binary files differnew file mode 100644 index 0000000000..a4ac7e8c43 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0017.png diff --git a/demos/2d/isometric_light/cubio/idle0018.png b/demos/2d/isometric_light/cubio/idle0018.png Binary files differnew file mode 100644 index 0000000000..aa7cc8fe6c --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0018.png diff --git a/demos/2d/isometric_light/cubio/idle0019.png b/demos/2d/isometric_light/cubio/idle0019.png Binary files differnew file mode 100644 index 0000000000..3ab603ceda --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0019.png diff --git a/demos/2d/isometric_light/cubio/idle0020.png b/demos/2d/isometric_light/cubio/idle0020.png Binary files differnew file mode 100644 index 0000000000..9f02648f1a --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0020.png diff --git a/demos/2d/isometric_light/cubio/idle0021.png b/demos/2d/isometric_light/cubio/idle0021.png Binary files differnew file mode 100644 index 0000000000..ec37fc331f --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0021.png diff --git a/demos/2d/isometric_light/cubio/idle0022.png b/demos/2d/isometric_light/cubio/idle0022.png Binary files differnew file mode 100644 index 0000000000..34bf331af0 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0022.png diff --git a/demos/2d/isometric_light/cubio/idle0023.png b/demos/2d/isometric_light/cubio/idle0023.png Binary files differnew file mode 100644 index 0000000000..80a458146e --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0023.png diff --git a/demos/2d/isometric_light/cubio/idle0024.png b/demos/2d/isometric_light/cubio/idle0024.png Binary files differnew file mode 100644 index 0000000000..cd08c6d14a --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0024.png diff --git a/demos/2d/isometric_light/cubio/idle0025.png b/demos/2d/isometric_light/cubio/idle0025.png Binary files differnew file mode 100644 index 0000000000..de500512d4 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0025.png diff --git a/demos/2d/isometric_light/cubio/idle0026.png b/demos/2d/isometric_light/cubio/idle0026.png Binary files differnew file mode 100644 index 0000000000..4a8335a248 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0026.png diff --git a/demos/2d/isometric_light/cubio/idle0027.png b/demos/2d/isometric_light/cubio/idle0027.png Binary files differnew file mode 100644 index 0000000000..c3d1609a03 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0027.png diff --git a/demos/2d/isometric_light/cubio/idle0028.png b/demos/2d/isometric_light/cubio/idle0028.png Binary files differnew file mode 100644 index 0000000000..96c1f32223 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0028.png diff --git a/demos/2d/isometric_light/cubio/idle0029.png b/demos/2d/isometric_light/cubio/idle0029.png Binary files differnew file mode 100644 index 0000000000..5b72d02300 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0029.png diff --git a/demos/2d/isometric_light/cubio/idle0030.png b/demos/2d/isometric_light/cubio/idle0030.png Binary files differnew file mode 100644 index 0000000000..a84787bf0a --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0030.png diff --git a/demos/2d/isometric_light/cubio/idle0031.png b/demos/2d/isometric_light/cubio/idle0031.png Binary files differnew file mode 100644 index 0000000000..dc9cd7ddc5 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0031.png diff --git a/demos/2d/isometric_light/cubio/idle0032.png b/demos/2d/isometric_light/cubio/idle0032.png Binary files differnew file mode 100644 index 0000000000..c99f2e52bc --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0032.png diff --git a/demos/2d/isometric_light/cubio/idle0033.png b/demos/2d/isometric_light/cubio/idle0033.png Binary files differnew file mode 100644 index 0000000000..cf5c648f9e --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0033.png diff --git a/demos/2d/isometric_light/cubio/idle0034.png b/demos/2d/isometric_light/cubio/idle0034.png Binary files differnew file mode 100644 index 0000000000..8e18e12d8d --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0034.png diff --git a/demos/2d/isometric_light/cubio/idle0035.png b/demos/2d/isometric_light/cubio/idle0035.png Binary files differnew file mode 100644 index 0000000000..ee2c25ee96 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0035.png diff --git a/demos/2d/isometric_light/cubio/idle0036.png b/demos/2d/isometric_light/cubio/idle0036.png Binary files differnew file mode 100644 index 0000000000..f452b5db33 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0036.png diff --git a/demos/2d/isometric_light/cubio/idle0037.png b/demos/2d/isometric_light/cubio/idle0037.png Binary files differnew file mode 100644 index 0000000000..7768c712e3 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0037.png diff --git a/demos/2d/isometric_light/cubio/idle0038.png b/demos/2d/isometric_light/cubio/idle0038.png Binary files differnew file mode 100644 index 0000000000..1200127116 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0038.png diff --git a/demos/2d/isometric_light/cubio/idle0039.png b/demos/2d/isometric_light/cubio/idle0039.png Binary files differnew file mode 100644 index 0000000000..25219f0582 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0039.png diff --git a/demos/2d/isometric_light/cubio/idle0040.png b/demos/2d/isometric_light/cubio/idle0040.png Binary files differnew file mode 100644 index 0000000000..8da0a81050 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0040.png diff --git a/demos/2d/isometric_light/cubio/idle0041.png b/demos/2d/isometric_light/cubio/idle0041.png Binary files differnew file mode 100644 index 0000000000..fa102aec8a --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0041.png diff --git a/demos/2d/isometric_light/cubio/idle0042.png b/demos/2d/isometric_light/cubio/idle0042.png Binary files differnew file mode 100644 index 0000000000..0d19c32572 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0042.png diff --git a/demos/2d/isometric_light/cubio/idle0043.png b/demos/2d/isometric_light/cubio/idle0043.png Binary files differnew file mode 100644 index 0000000000..bf284c62d0 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0043.png diff --git a/demos/2d/isometric_light/cubio/idle0044.png b/demos/2d/isometric_light/cubio/idle0044.png Binary files differnew file mode 100644 index 0000000000..3daa1be0b8 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0044.png diff --git a/demos/2d/isometric_light/cubio/idle0045.png b/demos/2d/isometric_light/cubio/idle0045.png Binary files differnew file mode 100644 index 0000000000..92abe74295 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0045.png diff --git a/demos/2d/isometric_light/cubio/idle0046.png b/demos/2d/isometric_light/cubio/idle0046.png Binary files differnew file mode 100644 index 0000000000..2a1ab0f036 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0046.png diff --git a/demos/2d/isometric_light/cubio/idle0047.png b/demos/2d/isometric_light/cubio/idle0047.png Binary files differnew file mode 100644 index 0000000000..da38b835ef --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0047.png diff --git a/demos/2d/isometric_light/cubio/idle0048.png b/demos/2d/isometric_light/cubio/idle0048.png Binary files differnew file mode 100644 index 0000000000..35fac1b602 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0048.png diff --git a/demos/2d/isometric_light/cubio/idle0049.png b/demos/2d/isometric_light/cubio/idle0049.png Binary files differnew file mode 100644 index 0000000000..7ebd79b8d7 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0049.png diff --git a/demos/2d/isometric_light/cubio/idle0050.png b/demos/2d/isometric_light/cubio/idle0050.png Binary files differnew file mode 100644 index 0000000000..ba0678ba87 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0050.png diff --git a/demos/2d/isometric_light/cubio/idle0051.png b/demos/2d/isometric_light/cubio/idle0051.png Binary files differnew file mode 100644 index 0000000000..03c54f1232 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0051.png diff --git a/demos/2d/isometric_light/cubio/idle0052.png b/demos/2d/isometric_light/cubio/idle0052.png Binary files differnew file mode 100644 index 0000000000..0e2c8b5d9f --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0052.png diff --git a/demos/2d/isometric_light/cubio/idle0053.png b/demos/2d/isometric_light/cubio/idle0053.png Binary files differnew file mode 100644 index 0000000000..d95095937f --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0053.png diff --git a/demos/2d/isometric_light/cubio/idle0054.png b/demos/2d/isometric_light/cubio/idle0054.png Binary files differnew file mode 100644 index 0000000000..5a09fce69e --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0054.png diff --git a/demos/2d/isometric_light/cubio/idle0055.png b/demos/2d/isometric_light/cubio/idle0055.png Binary files differnew file mode 100644 index 0000000000..6e2aad9d70 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0055.png diff --git a/demos/2d/isometric_light/cubio/idle0056.png b/demos/2d/isometric_light/cubio/idle0056.png Binary files differnew file mode 100644 index 0000000000..45813e953f --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0056.png diff --git a/demos/2d/isometric_light/cubio/idle0057.png b/demos/2d/isometric_light/cubio/idle0057.png Binary files differnew file mode 100644 index 0000000000..579b4e1647 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0057.png diff --git a/demos/2d/isometric_light/cubio/idle0058.png b/demos/2d/isometric_light/cubio/idle0058.png Binary files differnew file mode 100644 index 0000000000..236f290651 --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0058.png diff --git a/demos/2d/isometric_light/cubio/idle0059.png b/demos/2d/isometric_light/cubio/idle0059.png Binary files differnew file mode 100644 index 0000000000..837dd38f9c --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0059.png diff --git a/demos/2d/isometric_light/cubio/idle0060.png b/demos/2d/isometric_light/cubio/idle0060.png Binary files differnew file mode 100644 index 0000000000..837dd38f9c --- /dev/null +++ b/demos/2d/isometric_light/cubio/idle0060.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0001.png b/demos/2d/isometric_light/cubio/norm-b-0001.png Binary files differnew file mode 100644 index 0000000000..cda17e21cc --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0001.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0002.png b/demos/2d/isometric_light/cubio/norm-b-0002.png Binary files differnew file mode 100644 index 0000000000..fb36728cdf --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0002.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0003.png b/demos/2d/isometric_light/cubio/norm-b-0003.png Binary files differnew file mode 100644 index 0000000000..c8bfecb100 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0003.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0004.png b/demos/2d/isometric_light/cubio/norm-b-0004.png Binary files differnew file mode 100644 index 0000000000..e91213434f --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0004.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0005.png b/demos/2d/isometric_light/cubio/norm-b-0005.png Binary files differnew file mode 100644 index 0000000000..a823fe9a92 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0005.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0006.png b/demos/2d/isometric_light/cubio/norm-b-0006.png Binary files differnew file mode 100644 index 0000000000..d9de12baad --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0006.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0007.png b/demos/2d/isometric_light/cubio/norm-b-0007.png Binary files differnew file mode 100644 index 0000000000..f042eed408 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0007.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0008.png b/demos/2d/isometric_light/cubio/norm-b-0008.png Binary files differnew file mode 100644 index 0000000000..e18ca607dd --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0008.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0009.png b/demos/2d/isometric_light/cubio/norm-b-0009.png Binary files differnew file mode 100644 index 0000000000..7e7ddd4c63 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0009.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0010.png b/demos/2d/isometric_light/cubio/norm-b-0010.png Binary files differnew file mode 100644 index 0000000000..fddb956099 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0010.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0011.png b/demos/2d/isometric_light/cubio/norm-b-0011.png Binary files differnew file mode 100644 index 0000000000..240a50a9ec --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0011.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0012.png b/demos/2d/isometric_light/cubio/norm-b-0012.png Binary files differnew file mode 100644 index 0000000000..3e38628e98 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0012.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0013.png b/demos/2d/isometric_light/cubio/norm-b-0013.png Binary files differnew file mode 100644 index 0000000000..2380e76909 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0013.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0014.png b/demos/2d/isometric_light/cubio/norm-b-0014.png Binary files differnew file mode 100644 index 0000000000..db374927c6 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0014.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0015.png b/demos/2d/isometric_light/cubio/norm-b-0015.png Binary files differnew file mode 100644 index 0000000000..1cd0e762c5 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0015.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0016.png b/demos/2d/isometric_light/cubio/norm-b-0016.png Binary files differnew file mode 100644 index 0000000000..0d894db3f4 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0016.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0017.png b/demos/2d/isometric_light/cubio/norm-b-0017.png Binary files differnew file mode 100644 index 0000000000..c184af8e85 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0017.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0018.png b/demos/2d/isometric_light/cubio/norm-b-0018.png Binary files differnew file mode 100644 index 0000000000..1db06014b7 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0018.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0019.png b/demos/2d/isometric_light/cubio/norm-b-0019.png Binary files differnew file mode 100644 index 0000000000..e74c9c7954 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0019.png diff --git a/demos/2d/isometric_light/cubio/norm-b-0020.png b/demos/2d/isometric_light/cubio/norm-b-0020.png Binary files differnew file mode 100644 index 0000000000..326e60c64a --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-b-0020.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0001.png b/demos/2d/isometric_light/cubio/norm-bl-0001.png Binary files differnew file mode 100644 index 0000000000..0b36e8caa3 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0001.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0002.png b/demos/2d/isometric_light/cubio/norm-bl-0002.png Binary files differnew file mode 100644 index 0000000000..f00166d140 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0002.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0003.png b/demos/2d/isometric_light/cubio/norm-bl-0003.png Binary files differnew file mode 100644 index 0000000000..d84993e097 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0003.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0004.png b/demos/2d/isometric_light/cubio/norm-bl-0004.png Binary files differnew file mode 100644 index 0000000000..8e4c7f278b --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0004.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0005.png b/demos/2d/isometric_light/cubio/norm-bl-0005.png Binary files differnew file mode 100644 index 0000000000..5009f2a514 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0005.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0006.png b/demos/2d/isometric_light/cubio/norm-bl-0006.png Binary files differnew file mode 100644 index 0000000000..d0d654de6e --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0006.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0007.png b/demos/2d/isometric_light/cubio/norm-bl-0007.png Binary files differnew file mode 100644 index 0000000000..2df2437a0d --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0007.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0008.png b/demos/2d/isometric_light/cubio/norm-bl-0008.png Binary files differnew file mode 100644 index 0000000000..4bb8e91ecc --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0008.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0009.png b/demos/2d/isometric_light/cubio/norm-bl-0009.png Binary files differnew file mode 100644 index 0000000000..e4ab80ab72 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0009.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0010.png b/demos/2d/isometric_light/cubio/norm-bl-0010.png Binary files differnew file mode 100644 index 0000000000..7ead89343f --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0010.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0011.png b/demos/2d/isometric_light/cubio/norm-bl-0011.png Binary files differnew file mode 100644 index 0000000000..9714999645 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0011.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0012.png b/demos/2d/isometric_light/cubio/norm-bl-0012.png Binary files differnew file mode 100644 index 0000000000..95e0117df8 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0012.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0013.png b/demos/2d/isometric_light/cubio/norm-bl-0013.png Binary files differnew file mode 100644 index 0000000000..85d4f25e7e --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0013.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0014.png b/demos/2d/isometric_light/cubio/norm-bl-0014.png Binary files differnew file mode 100644 index 0000000000..3c9cc526d0 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0014.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0015.png b/demos/2d/isometric_light/cubio/norm-bl-0015.png Binary files differnew file mode 100644 index 0000000000..3e30649ce1 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0015.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0016.png b/demos/2d/isometric_light/cubio/norm-bl-0016.png Binary files differnew file mode 100644 index 0000000000..f39399c369 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0016.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0017.png b/demos/2d/isometric_light/cubio/norm-bl-0017.png Binary files differnew file mode 100644 index 0000000000..47f79741a1 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0017.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0018.png b/demos/2d/isometric_light/cubio/norm-bl-0018.png Binary files differnew file mode 100644 index 0000000000..8f4ccdcf33 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0018.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0019.png b/demos/2d/isometric_light/cubio/norm-bl-0019.png Binary files differnew file mode 100644 index 0000000000..a278ec0f05 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0019.png diff --git a/demos/2d/isometric_light/cubio/norm-bl-0020.png b/demos/2d/isometric_light/cubio/norm-bl-0020.png Binary files differnew file mode 100644 index 0000000000..db5fd0b73c --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-bl-0020.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0001.png b/demos/2d/isometric_light/cubio/norm-l-0001.png Binary files differnew file mode 100644 index 0000000000..7a989e79dd --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0001.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0002.png b/demos/2d/isometric_light/cubio/norm-l-0002.png Binary files differnew file mode 100644 index 0000000000..2257923ee6 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0002.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0003.png b/demos/2d/isometric_light/cubio/norm-l-0003.png Binary files differnew file mode 100644 index 0000000000..2e264e49a4 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0003.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0004.png b/demos/2d/isometric_light/cubio/norm-l-0004.png Binary files differnew file mode 100644 index 0000000000..e0061451d6 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0004.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0005.png b/demos/2d/isometric_light/cubio/norm-l-0005.png Binary files differnew file mode 100644 index 0000000000..e16cca081c --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0005.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0006.png b/demos/2d/isometric_light/cubio/norm-l-0006.png Binary files differnew file mode 100644 index 0000000000..694c2163eb --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0006.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0007.png b/demos/2d/isometric_light/cubio/norm-l-0007.png Binary files differnew file mode 100644 index 0000000000..ed2ae64cad --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0007.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0008.png b/demos/2d/isometric_light/cubio/norm-l-0008.png Binary files differnew file mode 100644 index 0000000000..4bbaeb8006 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0008.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0009.png b/demos/2d/isometric_light/cubio/norm-l-0009.png Binary files differnew file mode 100644 index 0000000000..1f53a1067b --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0009.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0010.png b/demos/2d/isometric_light/cubio/norm-l-0010.png Binary files differnew file mode 100644 index 0000000000..2007942a2a --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0010.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0011.png b/demos/2d/isometric_light/cubio/norm-l-0011.png Binary files differnew file mode 100644 index 0000000000..0c27288646 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0011.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0012.png b/demos/2d/isometric_light/cubio/norm-l-0012.png Binary files differnew file mode 100644 index 0000000000..8b885bcee8 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0012.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0013.png b/demos/2d/isometric_light/cubio/norm-l-0013.png Binary files differnew file mode 100644 index 0000000000..ed08c9a470 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0013.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0014.png b/demos/2d/isometric_light/cubio/norm-l-0014.png Binary files differnew file mode 100644 index 0000000000..3b6088c9a0 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0014.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0015.png b/demos/2d/isometric_light/cubio/norm-l-0015.png Binary files differnew file mode 100644 index 0000000000..1ffa2b8cda --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0015.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0016.png b/demos/2d/isometric_light/cubio/norm-l-0016.png Binary files differnew file mode 100644 index 0000000000..00279dc052 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0016.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0017.png b/demos/2d/isometric_light/cubio/norm-l-0017.png Binary files differnew file mode 100644 index 0000000000..1805000a78 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0017.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0018.png b/demos/2d/isometric_light/cubio/norm-l-0018.png Binary files differnew file mode 100644 index 0000000000..1ff123533f --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0018.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0019.png b/demos/2d/isometric_light/cubio/norm-l-0019.png Binary files differnew file mode 100644 index 0000000000..2faf043a2b --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0019.png diff --git a/demos/2d/isometric_light/cubio/norm-l-0020.png b/demos/2d/isometric_light/cubio/norm-l-0020.png Binary files differnew file mode 100644 index 0000000000..7948d2d79d --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-l-0020.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0001.png b/demos/2d/isometric_light/cubio/norm-u-0001.png Binary files differnew file mode 100644 index 0000000000..6c702ba7c3 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0001.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0002.png b/demos/2d/isometric_light/cubio/norm-u-0002.png Binary files differnew file mode 100644 index 0000000000..9a151e049b --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0002.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0003.png b/demos/2d/isometric_light/cubio/norm-u-0003.png Binary files differnew file mode 100644 index 0000000000..0b7464260a --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0003.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0004.png b/demos/2d/isometric_light/cubio/norm-u-0004.png Binary files differnew file mode 100644 index 0000000000..89061fdbcf --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0004.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0005.png b/demos/2d/isometric_light/cubio/norm-u-0005.png Binary files differnew file mode 100644 index 0000000000..efc8ab0157 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0005.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0006.png b/demos/2d/isometric_light/cubio/norm-u-0006.png Binary files differnew file mode 100644 index 0000000000..a89ef58f46 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0006.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0007.png b/demos/2d/isometric_light/cubio/norm-u-0007.png Binary files differnew file mode 100644 index 0000000000..b069591200 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0007.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0008.png b/demos/2d/isometric_light/cubio/norm-u-0008.png Binary files differnew file mode 100644 index 0000000000..8f0dbe8016 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0008.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0009.png b/demos/2d/isometric_light/cubio/norm-u-0009.png Binary files differnew file mode 100644 index 0000000000..d4698f2584 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0009.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0010.png b/demos/2d/isometric_light/cubio/norm-u-0010.png Binary files differnew file mode 100644 index 0000000000..cc3d442d4a --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0010.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0011.png b/demos/2d/isometric_light/cubio/norm-u-0011.png Binary files differnew file mode 100644 index 0000000000..43c505d7e4 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0011.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0012.png b/demos/2d/isometric_light/cubio/norm-u-0012.png Binary files differnew file mode 100644 index 0000000000..d4f955fd0c --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0012.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0013.png b/demos/2d/isometric_light/cubio/norm-u-0013.png Binary files differnew file mode 100644 index 0000000000..08dd875a54 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0013.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0014.png b/demos/2d/isometric_light/cubio/norm-u-0014.png Binary files differnew file mode 100644 index 0000000000..4bea108a46 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0014.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0015.png b/demos/2d/isometric_light/cubio/norm-u-0015.png Binary files differnew file mode 100644 index 0000000000..943c556706 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0015.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0016.png b/demos/2d/isometric_light/cubio/norm-u-0016.png Binary files differnew file mode 100644 index 0000000000..d71a69c5a6 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0016.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0017.png b/demos/2d/isometric_light/cubio/norm-u-0017.png Binary files differnew file mode 100644 index 0000000000..2d74e4472c --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0017.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0018.png b/demos/2d/isometric_light/cubio/norm-u-0018.png Binary files differnew file mode 100644 index 0000000000..17a5b10acb --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0018.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0019.png b/demos/2d/isometric_light/cubio/norm-u-0019.png Binary files differnew file mode 100644 index 0000000000..e376c843e1 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0019.png diff --git a/demos/2d/isometric_light/cubio/norm-u-0020.png b/demos/2d/isometric_light/cubio/norm-u-0020.png Binary files differnew file mode 100644 index 0000000000..fa1d3521ca --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-u-0020.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0001.png b/demos/2d/isometric_light/cubio/norm-ul-0001.png Binary files differnew file mode 100644 index 0000000000..3e75621260 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0001.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0002.png b/demos/2d/isometric_light/cubio/norm-ul-0002.png Binary files differnew file mode 100644 index 0000000000..d48d902936 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0002.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0003.png b/demos/2d/isometric_light/cubio/norm-ul-0003.png Binary files differnew file mode 100644 index 0000000000..703cef6715 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0003.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0004.png b/demos/2d/isometric_light/cubio/norm-ul-0004.png Binary files differnew file mode 100644 index 0000000000..7dd3e2884e --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0004.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0005.png b/demos/2d/isometric_light/cubio/norm-ul-0005.png Binary files differnew file mode 100644 index 0000000000..1281b9ceb8 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0005.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0006.png b/demos/2d/isometric_light/cubio/norm-ul-0006.png Binary files differnew file mode 100644 index 0000000000..e3c58752e9 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0006.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0007.png b/demos/2d/isometric_light/cubio/norm-ul-0007.png Binary files differnew file mode 100644 index 0000000000..ccec10c83c --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0007.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0008.png b/demos/2d/isometric_light/cubio/norm-ul-0008.png Binary files differnew file mode 100644 index 0000000000..1243c7dfe8 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0008.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0009.png b/demos/2d/isometric_light/cubio/norm-ul-0009.png Binary files differnew file mode 100644 index 0000000000..77ea3ca8e9 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0009.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0010.png b/demos/2d/isometric_light/cubio/norm-ul-0010.png Binary files differnew file mode 100644 index 0000000000..cf1cb7d0e3 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0010.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0011.png b/demos/2d/isometric_light/cubio/norm-ul-0011.png Binary files differnew file mode 100644 index 0000000000..1063ee29a8 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0011.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0012.png b/demos/2d/isometric_light/cubio/norm-ul-0012.png Binary files differnew file mode 100644 index 0000000000..a896237161 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0012.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0013.png b/demos/2d/isometric_light/cubio/norm-ul-0013.png Binary files differnew file mode 100644 index 0000000000..cc289b18a0 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0013.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0014.png b/demos/2d/isometric_light/cubio/norm-ul-0014.png Binary files differnew file mode 100644 index 0000000000..faf36e82b6 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0014.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0015.png b/demos/2d/isometric_light/cubio/norm-ul-0015.png Binary files differnew file mode 100644 index 0000000000..925be82a2e --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0015.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0016.png b/demos/2d/isometric_light/cubio/norm-ul-0016.png Binary files differnew file mode 100644 index 0000000000..1cb2300b9d --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0016.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0017.png b/demos/2d/isometric_light/cubio/norm-ul-0017.png Binary files differnew file mode 100644 index 0000000000..5a841b57af --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0017.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0018.png b/demos/2d/isometric_light/cubio/norm-ul-0018.png Binary files differnew file mode 100644 index 0000000000..2b30df8988 --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0018.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0019.png b/demos/2d/isometric_light/cubio/norm-ul-0019.png Binary files differnew file mode 100644 index 0000000000..12c0a72d6d --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0019.png diff --git a/demos/2d/isometric_light/cubio/norm-ul-0020.png b/demos/2d/isometric_light/cubio/norm-ul-0020.png Binary files differnew file mode 100644 index 0000000000..3cffda17ca --- /dev/null +++ b/demos/2d/isometric_light/cubio/norm-ul-0020.png diff --git a/demos/2d/isometric_light/energy.png b/demos/2d/isometric_light/energy.png Binary files differnew file mode 100644 index 0000000000..237e3ea4f0 --- /dev/null +++ b/demos/2d/isometric_light/energy.png diff --git a/demos/2d/isometric_light/engine.cfg b/demos/2d/isometric_light/engine.cfg new file mode 100644 index 0000000000..bd65a38921 --- /dev/null +++ b/demos/2d/isometric_light/engine.cfg @@ -0,0 +1,14 @@ +[application] + +main_scene="res://map.scn" + +[input] + +up=[key(Up), key(W)] +down=[key(S), key(Down)] +left=[key(Left), key(A)] +right=[key(Right), key(D)] + +[render] + +default_clear_color=#ff000000 diff --git a/demos/2d/isometric_light/faceColor.png b/demos/2d/isometric_light/faceColor.png Binary files differnew file mode 100644 index 0000000000..b7e3839a78 --- /dev/null +++ b/demos/2d/isometric_light/faceColor.png diff --git a/demos/2d/isometric_light/faceMask.png b/demos/2d/isometric_light/faceMask.png Binary files differnew file mode 100644 index 0000000000..d91e968c8e --- /dev/null +++ b/demos/2d/isometric_light/faceMask.png diff --git a/demos/2d/isometric_light/faceNormal.png b/demos/2d/isometric_light/faceNormal.png Binary files differnew file mode 100644 index 0000000000..c6498dd1df --- /dev/null +++ b/demos/2d/isometric_light/faceNormal.png diff --git a/demos/2d/isometric_light/fire.png b/demos/2d/isometric_light/fire.png Binary files differnew file mode 100644 index 0000000000..746e4f9f4b --- /dev/null +++ b/demos/2d/isometric_light/fire.png diff --git a/demos/2d/isometric_light/floor_shader.res b/demos/2d/isometric_light/floor_shader.res Binary files differnew file mode 100644 index 0000000000..d4fac5b933 --- /dev/null +++ b/demos/2d/isometric_light/floor_shader.res diff --git a/demos/2d/isometric_light/light2.png b/demos/2d/isometric_light/light2.png Binary files differnew file mode 100644 index 0000000000..dd035e9911 --- /dev/null +++ b/demos/2d/isometric_light/light2.png diff --git a/demos/2d/isometric_light/map.gd b/demos/2d/isometric_light/map.gd new file mode 100644 index 0000000000..f712aeeaec --- /dev/null +++ b/demos/2d/isometric_light/map.gd @@ -0,0 +1,18 @@ + +extends Node2D + +# member variables here, example: +# var a=2 +# var b="textvar" + +func _ready(): + # Initialization here + pass + + + + +func _on_prince_area_body_enter( body ): + if (body.get_name()=="cubio"): + get_node("message").show() + pass # replace with function body diff --git a/demos/2d/isometric_light/map.scn b/demos/2d/isometric_light/map.scn Binary files differnew file mode 100644 index 0000000000..10de40d4ac --- /dev/null +++ b/demos/2d/isometric_light/map.scn diff --git a/demos/2d/isometric_light/shadow_blob.png b/demos/2d/isometric_light/shadow_blob.png Binary files differnew file mode 100644 index 0000000000..e97fd2a826 --- /dev/null +++ b/demos/2d/isometric_light/shadow_blob.png diff --git a/demos/2d/isometric_light/shoot.gd b/demos/2d/isometric_light/shoot.gd new file mode 100644 index 0000000000..0486bbb658 --- /dev/null +++ b/demos/2d/isometric_light/shoot.gd @@ -0,0 +1,27 @@ + +extends KinematicBody2D + +# member variables here, example: +# var a=2 +# var b="textvar" + +var advance_dir=Vector2(1,0) +const ADVANCE_SPEED = 500.0 + +var hit=false + +func _fixed_process(delta): + + if (hit): + return + move(advance_dir*delta*ADVANCE_SPEED) + if (is_colliding()): + get_node("anim").play("explode") + hit=true + +func _ready(): + # Initialization here + set_fixed_process(true) + pass + + diff --git a/demos/2d/isometric_light/shoot.scn b/demos/2d/isometric_light/shoot.scn Binary files differnew file mode 100644 index 0000000000..672608810f --- /dev/null +++ b/demos/2d/isometric_light/shoot.scn diff --git a/demos/2d/isometric_light/shoot_halo.png b/demos/2d/isometric_light/shoot_halo.png Binary files differnew file mode 100644 index 0000000000..5ba954b32b --- /dev/null +++ b/demos/2d/isometric_light/shoot_halo.png diff --git a/demos/2d/isometric_light/tileset.res b/demos/2d/isometric_light/tileset.res Binary files differnew file mode 100644 index 0000000000..633bdada38 --- /dev/null +++ b/demos/2d/isometric_light/tileset.res diff --git a/demos/2d/isometric_light/tileset_scene.scn b/demos/2d/isometric_light/tileset_scene.scn Binary files differnew file mode 100644 index 0000000000..e76a22c892 --- /dev/null +++ b/demos/2d/isometric_light/tileset_scene.scn diff --git a/demos/2d/isometric_light/torch.scn b/demos/2d/isometric_light/torch.scn Binary files differnew file mode 100644 index 0000000000..2daa199e92 --- /dev/null +++ b/demos/2d/isometric_light/torch.scn diff --git a/demos/2d/isometric_light/torch_light.png b/demos/2d/isometric_light/torch_light.png Binary files differnew file mode 100644 index 0000000000..60e5838043 --- /dev/null +++ b/demos/2d/isometric_light/torch_light.png diff --git a/demos/2d/isometric_light/torch_shader.res b/demos/2d/isometric_light/torch_shader.res Binary files differnew file mode 100644 index 0000000000..ad70d5260d --- /dev/null +++ b/demos/2d/isometric_light/torch_shader.res diff --git a/demos/2d/isometric_light/wall_shader.res b/demos/2d/isometric_light/wall_shader.res Binary files differnew file mode 100644 index 0000000000..a1318746a5 --- /dev/null +++ b/demos/2d/isometric_light/wall_shader.res diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index e167b647e7..b6444b2978 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -9276,7 +9276,10 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const normal_flip=Vector2(1,1); } - canvas_shader.set_conditional(CanvasShaderGLES2::USE_SHADOWS,light->shadow_buffer.is_valid()); + + bool has_shadow = light->shadow_buffer.is_valid() && ci->light_mask&light->item_shadow_mask; + + canvas_shader.set_conditional(CanvasShaderGLES2::USE_SHADOWS,has_shadow); bool light_rebind = canvas_shader.bind(); @@ -9302,7 +9305,9 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_POS,light->light_shader_pos); canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_COLOR,light->color); canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_HEIGHT,light->height); - if (light->shadow_buffer.is_valid()) { + canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_LOCAL_MATRIX,light->xform_cache.affine_inverse()); + + if (has_shadow) { CanvasLightShadow *cls = canvas_light_shadow_owner.get(light->shadow_buffer); glActiveTexture(GL_TEXTURE0+max_texture_units-3); @@ -9313,7 +9318,6 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const canvas_shader.set_uniform(CanvasShaderGLES2::SHADOW_TEXTURE,max_texture_units-3); canvas_shader.set_uniform(CanvasShaderGLES2::SHADOW_MATRIX,light->shadow_matrix_cache); - canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_LOCAL_MATRIX,light->xform_cache.affine_inverse()); canvas_shader.set_uniform(CanvasShaderGLES2::SHADOW_ESM_MULTIPLIER,light->shadow_esm_mult); } diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index b2052c7cbb..be40043573 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -808,12 +808,19 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { mode_replace_table[4]["POINT_COORD"]="gl_PointCoord"; mode_replace_table[4]["TIME"]="time"; - mode_replace_table[5]["SRC_COLOR"]="color"; - mode_replace_table[5]["COLOR"]="color"; + mode_replace_table[5]["POSITION"]="gl_Position"; mode_replace_table[5]["NORMAL"]="normal"; - mode_replace_table[5]["LIGHT_DIR"]="light_dir"; - mode_replace_table[5]["LIGHT_DISTANCE"]="light_distance"; - mode_replace_table[5]["LIGHT"]="light"; + mode_replace_table[5]["UV"]="uv_interp"; + mode_replace_table[5]["COLOR"]="color"; + mode_replace_table[5]["TEXTURE"]="texture"; + mode_replace_table[5]["TEXTURE_PIXEL_SIZE"]="texpixel_size"; + mode_replace_table[5]["VAR1"]="var1_interp"; + mode_replace_table[5]["VAR2"]="var2_interp"; + mode_replace_table[5]["LIGHT_VEC"]="light_vec"; + mode_replace_table[5]["LIGHT_HEIGHT"]="light_height"; + mode_replace_table[5]["LIGHT_COLOR"]="light"; + mode_replace_table[5]["LIGHT"]="light_out"; + mode_replace_table[5]["SCREEN_UV"]="screen_uv"; mode_replace_table[5]["POINT_COORD"]="gl_PointCoord"; mode_replace_table[5]["TIME"]="time"; diff --git a/drivers/gles2/shaders/canvas.glsl b/drivers/gles2/shaders/canvas.glsl index 9022f30d7f..0e19736fd5 100644 --- a/drivers/gles2/shaders/canvas.glsl +++ b/drivers/gles2/shaders/canvas.glsl @@ -26,6 +26,7 @@ uniform float time; #ifdef USE_LIGHTING uniform highp mat4 light_matrix; +uniform highp mat4 light_local_matrix; uniform vec2 light_pos; varying vec4 light_uv_interp; @@ -80,7 +81,7 @@ VERTEX_SHADER_CODE #ifdef USE_LIGHTING light_uv_interp.xy = (light_matrix * outvec).xy; - light_uv_interp.zw = outvec.xy-light_pos; + light_uv_interp.zw =(light_local_matrix * outvec).xy; #ifdef USE_SHADOWS pos=outvec.xy; #endif @@ -164,7 +165,6 @@ uniform sampler2D shadow_texture; uniform float shadow_attenuation; uniform highp mat4 shadow_matrix; -uniform highp mat4 light_local_matrix; highp varying vec2 pos; uniform float shadowpixel_size; @@ -188,7 +188,7 @@ void main() { vec4 color = color_interp; #if defined(NORMAL_USED) - vec3 normal = vec3(0,0,1); + vec3 normal = vec3(0.0,0.0,1.0); #endif @@ -197,6 +197,7 @@ void main() { vec2 screen_uv = gl_FragCoord.xy*screen_uv_mult; #endif + { FRAGMENT_SHADER_CODE } @@ -213,79 +214,110 @@ FRAGMENT_SHADER_CODE #ifdef USE_LIGHTING + vec2 light_vec = light_uv_interp.zw;; //for shadow and normal mapping + #if defined(NORMAL_USED) normal.xy = mat2(local_rot.xy,local_rot.zw) * normal.xy; #endif float att=1.0; - vec4 light = texture2D(light_texture,light_uv_interp.xy) * light_color; -#ifdef USE_SHADOWS + vec4 light = texture2D(light_texture,light_uv_interp.xy) * light_color; + +#if defined(USE_LIGHT_SHADER_CODE) +//light is written by the light shader +{ + vec4 light_out=vec4(0.0,0.0,0.0,0.0); +LIGHT_SHADER_CODE + color=light_out; +} +#else - vec2 lpos = (light_local_matrix * vec4(pos,0.0,1.0)).xy; - float angle_to_light = -atan(lpos.x,lpos.y); - float PI = 3.14159265358979323846264; - /*int i = int(mod(floor((angle_to_light+7.0*PI/6.0)/(4.0*PI/6.0))+1.0, 3.0)); // +1 pq os indices estao em ordem 2,0,1 nos arrays - float ang*/ +#if defined(NORMAL_USED) + vec3 light_normal = normalize(vec3(light_vec,-light_height)); + light*=max(dot(-light_normal,normal),0.0); +#endif - float su,sz; + color*=light; +/* +#ifdef USE_NORMAL + color.xy=local_rot.xy;//normal.xy; + color.zw=vec2(0.0,1.0); +#endif +*/ - float abs_angle = abs(angle_to_light); - vec2 point; - float sh; - if (abs_angle<45.0*PI/180.0) { - point = lpos; - sh=0+(1.0/8.0); - } else if (abs_angle>135.0*PI/180.0) { - point = -lpos; - sh = 0.5+(1.0/8.0); - } else if (angle_to_light>0) { +//light shader code +#endif - point = vec2(lpos.y,-lpos.x); - sh = 0.25+(1.0/8.0); + if (any(lessThan(light_uv_interp.xy,vec2(0.0,0.0))) || any(greaterThanEqual(light_uv_interp.xy,vec2(1.0,1.0)))) { + color.a=0.0; //invisible } else { - point = vec2(-lpos.y,lpos.x); - sh = 0.75+(1.0/8.0); +#ifdef USE_SHADOWS - } + float angle_to_light = -atan(light_vec.x,light_vec.y); + float PI = 3.14159265358979323846264; + /*int i = int(mod(floor((angle_to_light+7.0*PI/6.0)/(4.0*PI/6.0))+1.0, 3.0)); // +1 pq os indices estao em ordem 2,0,1 nos arrays + float ang*/ + + float su,sz; + float abs_angle = abs(angle_to_light); + vec2 point; + float sh; + if (abs_angle<45.0*PI/180.0) { + point = light_vec; + sh=0.0+(1.0/8.0); + } else if (abs_angle>135.0*PI/180.0) { + point = -light_vec; + sh = 0.5+(1.0/8.0); + } else if (angle_to_light>0.0) { - vec4 s = shadow_matrix * vec4(point,0.0,1.0); - s.xyz/=s.w; - su=s.x*0.5+0.5; - sz=s.z*0.5+0.5; + point = vec2(light_vec.y,-light_vec.x); + sh = 0.25+(1.0/8.0); + } else { - float shadow_attenuation; + point = vec2(-light_vec.y,light_vec.x); + sh = 0.75+(1.0/8.0); + + } + + + vec4 s = shadow_matrix * vec4(point,0.0,1.0); + s.xyz/=s.w; + su=s.x*0.5+0.5; + sz=s.z*0.5+0.5; + + float shadow_attenuation; #ifdef SHADOW_PCF5 - shadow_attenuation=0.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*2.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*2.0,sh)).z<sz?0.0:1.0; - shadow_attenuation/=5.0; + shadow_attenuation=0.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su,sh)).z<sz?0.0:1.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size,sh)).z<sz?0.0:1.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*2.0,sh)).z<sz?0.0:1.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size,sh)).z<sz?0.0:1.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*2.0,sh)).z<sz?0.0:1.0; + shadow_attenuation/=5.0; #endif #ifdef SHADOW_PCF13 - shadow_attenuation += texture2D(shadow_texture,vec2(su,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*2.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*3.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*4.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*5.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*6.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*2.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*3.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*4.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*5.0,sh)).z<sz?0.0:1.0; - shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*6.0,sh)).z<sz?0.0:1.0; - shadow_attenuation/=13.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su,sh)).z<sz?0.0:1.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size,sh)).z<sz?0.0:1.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*2.0,sh)).z<sz?0.0:1.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*3.0,sh)).z<sz?0.0:1.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*4.0,sh)).z<sz?0.0:1.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*5.0,sh)).z<sz?0.0:1.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su+shadowpixel_size*6.0,sh)).z<sz?0.0:1.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*2.0,sh)).z<sz?0.0:1.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*3.0,sh)).z<sz?0.0:1.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*4.0,sh)).z<sz?0.0:1.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*5.0,sh)).z<sz?0.0:1.0; + shadow_attenuation += texture2D(shadow_texture,vec2(su-shadowpixel_size*6.0,sh)).z<sz?0.0:1.0; + shadow_attenuation/=13.0; #endif @@ -293,56 +325,28 @@ FRAGMENT_SHADER_CODE { - float unnormalized = su/shadowpixel_size; - float fractional = fract(unnormalized); - unnormalized = floor(unnormalized); - float zc = texture2D(shadow_texture,vec2((unnormalized-0.5)*shadowpixel_size,sh)).z; - float zn = texture2D(shadow_texture,vec2((unnormalized+0.5)*shadowpixel_size,sh)).z; - float z = mix(zc,zn,fractional); - shadow_attenuation=clamp(exp(shadow_esm_multiplier* ( z - sz )),0.0,1.0); + float unnormalized = su/shadowpixel_size; + float fractional = fract(unnormalized); + unnormalized = floor(unnormalized); + float zc = texture2D(shadow_texture,vec2((unnormalized-0.5)*shadowpixel_size,sh)).z; + float zn = texture2D(shadow_texture,vec2((unnormalized+0.5)*shadowpixel_size,sh)).z; + float z = mix(zc,zn,fractional); + shadow_attenuation=clamp(exp(shadow_esm_multiplier* ( z - sz )),0.0,1.0); } #endif #if !defined(SHADOW_PCF5) && !defined(SHADOW_PCF13) && !defined(SHADOW_ESM) - shadow_attenuation = texture2D(shadow_texture,vec2(su+shadowpixel_size,sh)).z<sz?0.0:1.0; + shadow_attenuation = texture2D(shadow_texture,vec2(su+shadowpixel_size,sh)).z<sz?0.0:1.0; #endif - light*=shadow_attenuation; + color.rgb*=shadow_attenuation; //use shadows #endif - -#if defined(USE_LIGHT_SHADER_CODE) -//light is written by the light shader -{ - vec2 light_dir = normalize(light_uv_interp.zw); - float light_distance = length(light_uv_interp.zw); -LIGHT_SHADER_CODE -} - -#else - -#if defined(NORMAL_USED) - vec3 light_normal = normalize(vec3(light_uv_interp.zw,-light_height)); - light*=max(dot(-light_normal,normal),0); -#endif - - color*=light; -/* -#ifdef USE_NORMAL - color.xy=local_rot.xy;//normal.xy; - color.zw=vec2(0.0,1.0); -#endif -*/ - if (any(lessThan(light_uv_interp.xy,vec2(0.0,0.0))) || any(greaterThanEqual(light_uv_interp.xy,vec2(1.0,1.0)))) { - color.a=0.0; //invisible } -//light shader code -#endif - //use lighting #endif // color.rgb*=color.a; diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 4a1842100a..1002713740 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -1011,6 +1011,7 @@ void CanvasItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_global_transform_with_canvas"),&CanvasItem::get_global_transform_with_canvas); ObjectTypeDB::bind_method(_MD("get_viewport_transform"),&CanvasItem::get_viewport_transform); ObjectTypeDB::bind_method(_MD("get_viewport_rect"),&CanvasItem::get_viewport_rect); + ObjectTypeDB::bind_method(_MD("get_canvas_transform"),&CanvasItem::get_canvas_transform); ObjectTypeDB::bind_method(_MD("get_canvas"),&CanvasItem::get_canvas); ObjectTypeDB::bind_method(_MD("get_world_2d"),&CanvasItem::get_world_2d); //ObjectTypeDB::bind_method(_MD("get_viewport"),&CanvasItem::get_viewport); diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index 93be0c397f..5472e0b00e 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -148,6 +148,18 @@ int Light2D::get_item_mask() const { return item_mask; } +void Light2D::set_item_shadow_mask( int p_mask) { + + item_shadow_mask=p_mask; + VS::get_singleton()->canvas_light_set_item_shadow_mask(canvas_light,item_shadow_mask); + +} + +int Light2D::get_item_shadow_mask() const { + + return item_shadow_mask; +} + void Light2D::set_subtract_mode( bool p_enable ) { subtract_mode=p_enable; @@ -246,6 +258,9 @@ void Light2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_item_mask","item_mask"),&Light2D::set_item_mask); ObjectTypeDB::bind_method(_MD("get_item_mask"),&Light2D::get_item_mask); + ObjectTypeDB::bind_method(_MD("set_item_shadow_mask","item_shadow_mask"),&Light2D::set_item_shadow_mask); + ObjectTypeDB::bind_method(_MD("get_item_shadow_mask"),&Light2D::get_item_shadow_mask); + ObjectTypeDB::bind_method(_MD("set_subtract_mode","enable"),&Light2D::set_subtract_mode); ObjectTypeDB::bind_method(_MD("get_subtract_mode"),&Light2D::get_subtract_mode); @@ -272,6 +287,7 @@ void Light2D::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::BOOL,"shadow/enabled"),_SCS("set_shadow_enabled"),_SCS("is_shadow_enabled")); ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow/buffer_size",PROPERTY_HINT_RANGE,"32,16384,1"),_SCS("set_shadow_buffer_size"),_SCS("get_shadow_buffer_size")); ADD_PROPERTY( PropertyInfo(Variant::REAL,"shadow/esm_multiplier",PROPERTY_HINT_RANGE,"1,4096,0.1"),_SCS("set_shadow_esm_multiplier"),_SCS("get_shadow_esm_multiplier")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow/item_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_item_shadow_mask"),_SCS("get_item_shadow_mask")); } @@ -288,6 +304,7 @@ Light2D::Light2D() { layer_min=0; layer_max=0; item_mask=1; + item_shadow_mask=1; subtract_mode=false; shadow_buffer_size=2048; shadow_esm_multiplier=80; diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h index 89f351c3cd..26dc1f4d44 100644 --- a/scene/2d/light_2d.h +++ b/scene/2d/light_2d.h @@ -17,6 +17,7 @@ private: int layer_min; int layer_max; int item_mask; + int item_shadow_mask; int shadow_buffer_size; float shadow_esm_multiplier; bool subtract_mode; @@ -64,6 +65,9 @@ public: void set_item_mask( int p_mask); int get_item_mask() const; + void set_item_shadow_mask( int p_mask); + int get_item_shadow_mask() const; + void set_subtract_mode( bool p_enable ); bool get_subtract_mode() const; diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp index 186ea2e248..6ebd499f71 100644 --- a/scene/2d/light_occluder_2d.cpp +++ b/scene/2d/light_occluder_2d.cpp @@ -18,7 +18,8 @@ void OccluderPolygon2D::set_closed(bool p_closed) { if (closed==p_closed) return; closed=p_closed; - VS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon,polygon,closed); + if (polygon.size()) + VS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon,polygon,closed); emit_changed(); } @@ -56,9 +57,9 @@ void OccluderPolygon2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_polygon","polygon"),&OccluderPolygon2D::set_polygon); ObjectTypeDB::bind_method(_MD("get_polygon"),&OccluderPolygon2D::get_polygon); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"closed"),_SCS("set_closed"),_SCS("is_closed")); ADD_PROPERTY( PropertyInfo(Variant::INT,"cull_mode",PROPERTY_HINT_ENUM,"Disabled,ClockWise,CounterClockWise"),_SCS("set_cull_mode"),_SCS("get_cull_mode")); + ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon")); BIND_CONSTANT(CULL_DISABLED); BIND_CONSTANT(CULL_CLOCKWISE); diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 75e7957cb8..b9d87c1224 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -30,12 +30,32 @@ #include "io/marshalls.h" #include "servers/physics_2d_server.h" #include "method_bind_ext.inc" + +int TileMap::_get_quadrant_size() const { + + if (y_sort_mode) + return 1; + else + return quadrant_size; +} + void TileMap::_notification(int p_what) { switch(p_what) { case NOTIFICATION_ENTER_TREE: { + Node2D *c=this; + while(c) { + + navigation=c->cast_to<Navigation2D>(); + if (navigation) { + break; + } + + c=c->get_parent()->cast_to<Node2D>(); + } + pending_update=true; _update_dirty_quadrants(); RID space = get_world_2d()->get_space(); @@ -47,6 +67,25 @@ void TileMap::_notification(int p_what) { case NOTIFICATION_EXIT_TREE: { _update_quadrant_space(RID()); + for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) { + + Quadrant &q=E->get(); + if (navigation) { + for(Map<PosKey,Quadrant::NavPoly>::Element *E=q.navpoly_ids.front();E;E=E->next()) { + + navigation->navpoly_remove(E->get().id); + } + q.navpoly_ids.clear(); + } + + for(Map<PosKey,Quadrant::Occluder>::Element *E=q.occluder_instances.front();E;E=E->next()) { + VS::get_singleton()->free(E->get().id); + } + q.occluder_instances.clear(); + } + + navigation=NULL; + } break; case NOTIFICATION_TRANSFORM_CHANGED: { @@ -74,6 +113,10 @@ void TileMap::_update_quadrant_transform() { Matrix32 global_transform = get_global_transform(); + Matrix32 nav_rel; + if (navigation) + nav_rel = get_relative_transform(navigation); + for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) { Quadrant &q=E->get(); @@ -81,6 +124,17 @@ void TileMap::_update_quadrant_transform() { xform.set_origin( q.pos ); xform = global_transform * xform; Physics2DServer::get_singleton()->body_set_state(q.body,Physics2DServer::BODY_STATE_TRANSFORM,xform); + + if (navigation) { + for(Map<PosKey,Quadrant::NavPoly>::Element *E=q.navpoly_ids.front();E;E=E->next()) { + + navigation->navpoly_set_transform(E->get().id,nav_rel * E->get().xform); + } + } + + for(Map<PosKey,Quadrant::Occluder>::Element *E=q.occluder_instances.front();E;E=E->next()) { + VS::get_singleton()->canvas_light_occluder_set_transform(E->get().id,global_transform * E->get().xform); + } } } @@ -161,6 +215,33 @@ bool TileMap::get_center_y() const { return center_y; } +void TileMap::_fix_cell_transform(Matrix32& xform,const Cell& c,Vector2& offset,const Size2 &sc) { + + Size2 s=sc; + + if (c.transpose) { + SWAP(xform.elements[0].x, xform.elements[0].y); + SWAP(xform.elements[1].x, xform.elements[1].y); + SWAP(offset.x, offset.y); + SWAP(s.x, s.y); + } + if (c.flip_h) { + xform.elements[0].x=-xform.elements[0].x; + xform.elements[1].x=-xform.elements[1].x; + if (tile_origin==TILE_ORIGIN_TOP_LEFT) + offset.x=s.x-offset.x; + } + if (c.flip_v) { + xform.elements[0].y=-xform.elements[0].y; + xform.elements[1].y=-xform.elements[1].y; + if (tile_origin==TILE_ORIGIN_TOP_LEFT) + offset.y=s.y-offset.y; + } + xform.elements[2].x+=offset.x; + xform.elements[2].y+=offset.y; + +} + void TileMap::_update_dirty_quadrants() { if (!pending_update) @@ -173,15 +254,42 @@ void TileMap::_update_dirty_quadrants() { VisualServer *vs = VisualServer::get_singleton(); Physics2DServer *ps = Physics2DServer::get_singleton(); Vector2 tofs = get_cell_draw_offset(); + Vector2 tcenter = cell_size/2; + Matrix32 nav_rel; + if (navigation) + nav_rel = get_relative_transform(navigation); + + Vector2 qofs; while (dirty_quadrant_list.first()) { Quadrant &q = *dirty_quadrant_list.first()->self(); - vs->canvas_item_clear(q.canvas_item); + for (List<RID>::Element *E=q.canvas_items.front();E;E=E->next()) { + + vs->free(E->get()); + } + + q.canvas_items.clear(); + ps->body_clear_shapes(q.body); int shape_idx=0; + if (navigation) { + for(Map<PosKey,Quadrant::NavPoly>::Element *E=q.navpoly_ids.front();E;E=E->next()) { + + navigation->navpoly_remove(E->get().id); + } + q.navpoly_ids.clear(); + } + + for(Map<PosKey,Quadrant::Occluder>::Element *E=q.occluder_instances.front();E;E=E->next()) { + VS::get_singleton()->free(E->get().id); + } + q.occluder_instances.clear(); + Ref<CanvasItemMaterial> prev_material; + RID prev_canvas_item; + for(int i=0;i<q.cells.size();i++) { Map<PosKey,Cell>::Element *E=tile_map.find( q.cells[i] ); @@ -192,11 +300,35 @@ void TileMap::_update_dirty_quadrants() { Ref<Texture> tex = tile_set->tile_get_texture(c.id); Vector2 tile_ofs = tile_set->tile_get_texture_offset(c.id); - Vector2 offset = _map_to_world(E->key().x, E->key().y) - q.pos + tofs; + Vector2 wofs = _map_to_world(E->key().x, E->key().y); + Vector2 offset = wofs - q.pos + tofs; if (!tex.is_valid()) continue; + Ref<CanvasItemMaterial> mat = tile_set->tile_get_material(c.id); + + RID canvas_item; + + if (prev_canvas_item==RID() || prev_material!=mat) { + + canvas_item=vs->canvas_item_create(); + if (mat.is_valid()) + vs->canvas_item_set_material(canvas_item,mat->get_rid()); + vs->canvas_item_set_parent( canvas_item, get_canvas_item() ); + Matrix32 xform; + xform.set_origin( q.pos ); + vs->canvas_item_set_transform( canvas_item, xform ); + q.canvas_items.push_back(canvas_item); + + prev_canvas_item=canvas_item; + prev_material=mat; + + } else { + canvas_item=prev_canvas_item; + } + + Rect2 r = tile_set->tile_get_region(c.id); Size2 s = tex->get_size(); @@ -223,12 +355,32 @@ void TileMap::_update_dirty_quadrants() { if (c.flip_v) rect.size.y=-rect.size.y; + Vector2 center_ofs; + + if (tile_origin==TILE_ORIGIN_TOP_LEFT) { + rect.pos+=tile_ofs; + } else if (tile_origin==TILE_ORIGIN_CENTER) { + rect.pos+=tcenter; + + Vector2 center = (s/2) - tile_ofs; + center_ofs=tcenter-(s/2); + + if (c.flip_h) + rect.pos.x-=s.x-center.x; + else + rect.pos.x-=center.x; + + if (c.flip_v) + rect.pos.y-=s.y-center.y; + else + rect.pos.y-=center.y; + } + - rect.pos+=tile_ofs; if (r==Rect2()) { - tex->draw_rect(q.canvas_item,rect,false,Color(1,1,1),c.transpose); + tex->draw_rect(canvas_item,rect,false,Color(1,1,1),c.transpose); } else { - tex->draw_rect_region(q.canvas_item,rect,r,Color(1,1,1),c.transpose); + tex->draw_rect_region(canvas_item,rect,r,Color(1,1,1),c.transpose); } Vector< Ref<Shape2D> > shapes = tile_set->tile_get_shapes(c.id); @@ -242,32 +394,48 @@ void TileMap::_update_dirty_quadrants() { Vector2 shape_ofs = tile_set->tile_get_shape_offset(c.id); Matrix32 xform; xform.set_origin(offset.floor()); - if (c.transpose) { - SWAP(xform.elements[0].x, xform.elements[0].y); - SWAP(xform.elements[1].x, xform.elements[1].y); - SWAP(shape_ofs.x, shape_ofs.y); - SWAP(s.x, s.y); - } - if (c.flip_h) { - xform.elements[0].x=-xform.elements[0].x; - xform.elements[1].x=-xform.elements[1].x; - shape_ofs.x=s.x-shape_ofs.x; - } - if (c.flip_v) { - xform.elements[0].y=-xform.elements[0].y; - xform.elements[1].y=-xform.elements[1].y; - shape_ofs.y=s.y-shape_ofs.y; - } - xform.elements[2].x+=shape_ofs.x; - xform.elements[2].y+=shape_ofs.y; - + _fix_cell_transform(xform,c,shape_ofs+center_ofs,s); ps->body_add_shape(q.body,shape->get_rid(),xform); ps->body_set_shape_metadata(q.body,shape_idx++,Vector2(E->key().x,E->key().y)); } } + + if (navigation) { + Ref<NavigationPolygon> navpoly = tile_set->tile_get_navigation_polygon(c.id); + Vector2 npoly_ofs = tile_set->tile_get_navigation_polygon_offset(c.id); + Matrix32 xform; + xform.set_origin(offset.floor()+q.pos); + _fix_cell_transform(xform,c,npoly_ofs+center_ofs,s); + + int pid = navigation->navpoly_create(navpoly,nav_rel * xform); + + Quadrant::NavPoly np; + np.id=pid; + np.xform=xform; + q.navpoly_ids[E->key()]=np; + } + + + Ref<OccluderPolygon2D> occluder=tile_set->tile_get_light_occluder(c.id); + if (occluder.is_valid()) { + + Vector2 occluder_ofs = tile_set->tile_get_occluder_offset(c.id); + Matrix32 xform; + xform.set_origin(offset.floor()+q.pos); + _fix_cell_transform(xform,c,occluder_ofs+center_ofs,s); + + RID orid = VS::get_singleton()->canvas_light_occluder_create(); + VS::get_singleton()->canvas_light_occluder_set_transform(orid,get_global_transform() * xform); + VS::get_singleton()->canvas_light_occluder_set_polygon(orid,occluder->get_rid()); + VS::get_singleton()->canvas_light_occluder_attach_to_canvas(orid,get_canvas()); + Quadrant::Occluder oc; + oc.xform=xform; + oc.id=orid; + q.occluder_instances[E->key()]=oc; + } } dirty_quadrant_list.remove( dirty_quadrant_list.first() ); @@ -282,10 +450,10 @@ void TileMap::_update_dirty_quadrants() { for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) { Quadrant &q=E->get(); - if (q.canvas_item.is_valid()) { - VS::get_singleton()->canvas_item_raise(q.canvas_item); - } + for (List<RID>::Element *E=q.canvas_items.front();E;E=E->next()) { + VS::get_singleton()->canvas_item_raise(E->get()); + } } quadrant_order_dirty=false; @@ -308,10 +476,10 @@ void TileMap::_recompute_rect_cache() { Rect2 r; - r.pos=_map_to_world(E->key().x*quadrant_size, E->key().y*quadrant_size); - r.expand_to( _map_to_world(E->key().x*quadrant_size+quadrant_size, E->key().y*quadrant_size) ); - r.expand_to( _map_to_world(E->key().x*quadrant_size+quadrant_size, E->key().y*quadrant_size+quadrant_size) ); - r.expand_to( _map_to_world(E->key().x*quadrant_size, E->key().y*quadrant_size+quadrant_size) ); + r.pos=_map_to_world(E->key().x*_get_quadrant_size(), E->key().y*_get_quadrant_size()); + r.expand_to( _map_to_world(E->key().x*_get_quadrant_size()+_get_quadrant_size(), E->key().y*_get_quadrant_size()) ); + r.expand_to( _map_to_world(E->key().x*_get_quadrant_size()+_get_quadrant_size(), E->key().y*_get_quadrant_size()+_get_quadrant_size()) ); + r.expand_to( _map_to_world(E->key().x*_get_quadrant_size(), E->key().y*_get_quadrant_size()+_get_quadrant_size()) ); if (E==quadrant_map.front()) r_total=r; else @@ -322,7 +490,7 @@ void TileMap::_recompute_rect_cache() { if (r_total==Rect2()) { rect_cache=Rect2(-10,-10,20,20); } else { - rect_cache=r_total.grow(MAX(cell_size.x,cell_size.y)*quadrant_size); + rect_cache=r_total.grow(MAX(cell_size.x,cell_size.y)*_get_quadrant_size()); } item_rect_changed(); @@ -338,11 +506,13 @@ Map<TileMap::PosKey,TileMap::Quadrant>::Element *TileMap::_create_quadrant(const Matrix32 xform; //xform.set_origin(Point2(p_qk.x,p_qk.y)*cell_size*quadrant_size); Quadrant q; - q.pos = _map_to_world(p_qk.x*quadrant_size,p_qk.y*quadrant_size); + q.pos = _map_to_world(p_qk.x*_get_quadrant_size(),p_qk.y*_get_quadrant_size()); + q.pos+=get_cell_draw_offset(); + if (tile_origin==TILE_ORIGIN_CENTER) + q.pos+=cell_size/2; + xform.set_origin( q.pos ); - q.canvas_item = VisualServer::get_singleton()->canvas_item_create(); - VisualServer::get_singleton()->canvas_item_set_parent( q.canvas_item, get_canvas_item() ); - VisualServer::get_singleton()->canvas_item_set_transform( q.canvas_item, xform ); +// q.canvas_item = VisualServer::get_singleton()->canvas_item_create(); q.body=Physics2DServer::get_singleton()->body_create(use_kinematic?Physics2DServer::BODY_MODE_KINEMATIC:Physics2DServer::BODY_MODE_STATIC); Physics2DServer::get_singleton()->body_attach_object_instance_ID(q.body,get_instance_ID()); Physics2DServer::get_singleton()->body_set_layer_mask(q.body,collision_layer); @@ -366,10 +536,27 @@ void TileMap::_erase_quadrant(Map<PosKey,Quadrant>::Element *Q) { Quadrant &q=Q->get(); Physics2DServer::get_singleton()->free(q.body); - VisualServer::get_singleton()->free(q.canvas_item); + for (List<RID>::Element *E=q.canvas_items.front();E;E=E->next()) { + + VisualServer::get_singleton()->free(E->get()); + } + q.canvas_items.clear(); if (q.dirty_list.in_list()) dirty_quadrant_list.remove(&q.dirty_list); + if (navigation) { + for(Map<PosKey,Quadrant::NavPoly>::Element *E=q.navpoly_ids.front();E;E=E->next()) { + + navigation->navpoly_remove(E->get().id); + } + q.navpoly_ids.clear(); + } + + for(Map<PosKey,Quadrant::Occluder>::Element *E=q.occluder_instances.front();E;E=E->next()) { + VS::get_singleton()->free(E->get().id); + } + q.occluder_instances.clear(); + quadrant_map.erase(Q); rect_cache_dirty=true; } @@ -397,7 +584,7 @@ void TileMap::set_cell(int p_x,int p_y,int p_tile,bool p_flip_x,bool p_flip_y,bo if (!E && p_tile==INVALID_CELL) return; //nothing to do - PosKey qk(p_x/quadrant_size,p_y/quadrant_size); + PosKey qk(p_x/_get_quadrant_size(),p_y/_get_quadrant_size()); if (p_tile==INVALID_CELL) { //erase existing tile_map.erase(pk); @@ -495,7 +682,7 @@ void TileMap::_recreate_quadrants() { for (Map<PosKey,Cell>::Element *E=tile_map.front();E;E=E->next()) { - PosKey qk(E->key().x/quadrant_size,E->key().y/quadrant_size); + PosKey qk(E->key().x/_get_quadrant_size(),E->key().y/_get_quadrant_size()); Map<PosKey,Quadrant>::Element *Q=quadrant_map.find(qk); if (!Q) { @@ -511,6 +698,7 @@ void TileMap::_recreate_quadrants() { } + void TileMap::_clear_quadrants() { while (quadrant_map.size()) { @@ -678,6 +866,20 @@ void TileMap::set_half_offset(HalfOffset p_half_offset) { emit_signal("settings_changed"); } +void TileMap::set_tile_origin(TileOrigin p_tile_origin) { + + _clear_quadrants(); + tile_origin=p_tile_origin; + _recreate_quadrants(); + emit_signal("settings_changed"); +} + +TileMap::TileOrigin TileMap::get_tile_origin() const{ + + return tile_origin; +} + + Vector2 TileMap::get_cell_draw_offset() const { switch(mode) { @@ -804,6 +1006,21 @@ Vector2 TileMap::world_to_map(const Vector2& p_pos) const{ return ret.floor(); } +void TileMap::set_y_sort_mode(bool p_enable) { + + _clear_quadrants(); + y_sort_mode=p_enable; + VS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(),y_sort_mode); + _recreate_quadrants(); + emit_signal("settings_changed"); + +} + +bool TileMap::is_y_sort_mode_enabled() const { + + return y_sort_mode; +} + void TileMap::_bind_methods() { @@ -829,12 +1046,18 @@ void TileMap::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_quadrant_size","size"),&TileMap::set_quadrant_size); ObjectTypeDB::bind_method(_MD("get_quadrant_size"),&TileMap::get_quadrant_size); + ObjectTypeDB::bind_method(_MD("set_tile_origin","origin"),&TileMap::set_tile_origin); + ObjectTypeDB::bind_method(_MD("get_tile_origin"),&TileMap::get_tile_origin); + ObjectTypeDB::bind_method(_MD("set_center_x","enable"),&TileMap::set_center_x); ObjectTypeDB::bind_method(_MD("get_center_x"),&TileMap::get_center_x); ObjectTypeDB::bind_method(_MD("set_center_y","enable"),&TileMap::set_center_y); ObjectTypeDB::bind_method(_MD("get_center_y"),&TileMap::get_center_y); + ObjectTypeDB::bind_method(_MD("set_y_sort_mode","enable"),&TileMap::set_y_sort_mode); + ObjectTypeDB::bind_method(_MD("is_y_sort_mode_enabled"),&TileMap::is_y_sort_mode_enabled); + ObjectTypeDB::bind_method(_MD("set_collision_use_kinematic","use_kinematic"),&TileMap::set_collision_use_kinematic); ObjectTypeDB::bind_method(_MD("get_collision_use_kinematic"),&TileMap::get_collision_use_kinematic); @@ -871,6 +1094,8 @@ void TileMap::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/quadrant_size",PROPERTY_HINT_RANGE,"1,128,1"),_SCS("set_quadrant_size"),_SCS("get_quadrant_size")); ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"cell/custom_transform"),_SCS("set_custom_transform"),_SCS("get_custom_transform")); ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/half_offset",PROPERTY_HINT_ENUM,"Offset X,Offset Y,Disabled"),_SCS("set_half_offset"),_SCS("get_half_offset")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/tile_origin",PROPERTY_HINT_ENUM,"Top Left,Center"),_SCS("set_tile_origin"),_SCS("get_tile_origin")); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"cell/y_sort"),_SCS("set_y_sort_mode"),_SCS("is_y_sort_mode_enabled")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collision/use_kinematic",PROPERTY_HINT_NONE,""),_SCS("set_collision_use_kinematic"),_SCS("get_collision_use_kinematic")); ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_friction"),_SCS("get_collision_friction")); ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_bounce"),_SCS("get_collision_bounce")); @@ -886,6 +1111,8 @@ void TileMap::_bind_methods() { BIND_CONSTANT( HALF_OFFSET_X ); BIND_CONSTANT( HALF_OFFSET_Y ); BIND_CONSTANT( HALF_OFFSET_DISABLED ); + BIND_CONSTANT( TILE_ORIGIN_TOP_LEFT ); + BIND_CONSTANT( TILE_ORIGIN_CENTER ); } @@ -906,9 +1133,12 @@ TileMap::TileMap() { mode=MODE_SQUARE; half_offset=HALF_OFFSET_DISABLED; use_kinematic=false; + navigation=NULL; + y_sort_mode=false; fp_adjust=0.01; fp_adjust=0.01; + tile_origin=TILE_ORIGIN_TOP_LEFT; } TileMap::~TileMap() { diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index fe1067fc1d..3facc9e8b7 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -30,6 +30,7 @@ #define TILE_MAP_H #include "scene/2d/node_2d.h" +#include "scene/2d/navigation2d.h" #include "scene/resources/tile_set.h" #include "self_list.h" #include "vset.h" @@ -51,6 +52,12 @@ public: HALF_OFFSET_DISABLED, }; + enum TileOrigin { + TILE_ORIGIN_TOP_LEFT, + TILE_ORIGIN_CENTER + }; + + private: Ref<TileSet> tile_set; @@ -61,6 +68,7 @@ private: Matrix32 custom_transform; HalfOffset half_offset; bool use_kinematic; + Navigation2D *navigation; union PosKey { @@ -98,15 +106,29 @@ private: struct Quadrant { Vector2 pos; - RID canvas_item; + List<RID> canvas_items; RID body; SelfList<Quadrant> dirty_list; + struct NavPoly { + int id; + Matrix32 xform; + }; + + struct Occluder { + RID id; + Matrix32 xform; + }; + + + Map<PosKey,NavPoly> navpoly_ids; + Map<PosKey,Occluder> occluder_instances; + VSet<PosKey> cells; - void operator=(const Quadrant& q) { pos=q.pos; canvas_item=q.canvas_item; body=q.body; cells=q.cells; } - Quadrant(const Quadrant& q) : dirty_list(this) { pos=q.pos; canvas_item=q.canvas_item; body=q.body; cells=q.cells;} + void operator=(const Quadrant& q) { pos=q.pos; canvas_items=q.canvas_items; body=q.body; cells=q.cells; navpoly_ids=q.navpoly_ids; occluder_instances=q.occluder_instances; } + Quadrant(const Quadrant& q) : dirty_list(this) { pos=q.pos; canvas_items=q.canvas_items; body=q.body; cells=q.cells; occluder_instances=q.occluder_instances; navpoly_ids=q.navpoly_ids;} Quadrant() : dirty_list(this) {} }; @@ -119,11 +141,14 @@ private: Rect2 rect_cache; bool rect_cache_dirty; bool quadrant_order_dirty; + bool y_sort_mode; float fp_adjust; float friction; float bounce; uint32_t collision_layer; + TileOrigin tile_origin; + void _fix_cell_transform(Matrix32& xform, const Cell& c, Vector2 &offset, const Size2 &s); Map<PosKey,Quadrant>::Element *_create_quadrant(const PosKey& p_qk); void _erase_quadrant(Map<PosKey,Quadrant>::Element *Q); @@ -135,6 +160,9 @@ private: void _update_quadrant_transform(); void _recompute_rect_cache(); + _FORCE_INLINE_ int _get_quadrant_size() const; + + void _set_tile_data(const DVector<int>& p_data); DVector<int> _get_tile_data() const; @@ -195,6 +223,9 @@ public: void set_half_offset(HalfOffset p_half_offset); HalfOffset get_half_offset() const; + void set_tile_origin(TileOrigin p_tile_origin); + TileOrigin get_tile_origin() const; + void set_custom_transform(const Matrix32& p_xform); Matrix32 get_custom_transform() const; @@ -204,6 +235,9 @@ public: Vector2 map_to_world(const Vector2& p_pos, bool p_ignore_ofs=false) const; Vector2 world_to_map(const Vector2& p_pos) const; + void set_y_sort_mode(bool p_enable); + bool is_y_sort_mode_enabled() const; + void clear(); TileMap(); @@ -212,5 +246,6 @@ public: VARIANT_ENUM_CAST(TileMap::Mode); VARIANT_ENUM_CAST(TileMap::HalfOffset); +VARIANT_ENUM_CAST(TileMap::TileOrigin); #endif // TILE_MAP_H diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp index 22534eeb0e..cd3c788b65 100644 --- a/scene/2d/visibility_notifier_2d.cpp +++ b/scene/2d/visibility_notifier_2d.cpp @@ -32,6 +32,7 @@ #include "scene/2d/physics_body_2d.h" #include "scene/animation/animation_player.h" #include "scene/scene_string_names.h" +#include "particles_2d.h" void VisibilityNotifier2D::_enter_viewport(Viewport* p_viewport) { @@ -188,6 +189,15 @@ void VisibilityEnabler2D::_find_nodes(Node* p_node) { } + if (enabler[ENABLER_PAUSE_PARTICLES]) { + + Particles2D *ps = p_node->cast_to<Particles2D>(); + if (ps) { + add=true; + } + + } + if (add) { p_node->connect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed",varray(p_node),CONNECT_ONESHOT); @@ -271,6 +281,15 @@ void VisibilityEnabler2D::_change_node_state(Node* p_node,bool p_enabled) { } } + { + Particles2D *ps=p_node->cast_to<Particles2D>(); + + if (ps) { + + ps->set_emitting(p_enabled); + } + } + } @@ -292,9 +311,11 @@ void VisibilityEnabler2D::_bind_methods(){ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/pause_animations"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATIONS ); ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/freeze_bodies"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_FREEZE_BODIES); + ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/pause_particles"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_PARTICLES); BIND_CONSTANT( ENABLER_FREEZE_BODIES ); BIND_CONSTANT( ENABLER_PAUSE_ANIMATIONS ); + BIND_CONSTANT( ENABLER_PAUSE_PARTICLES ); BIND_CONSTANT( ENABLER_MAX); } @@ -320,3 +341,4 @@ VisibilityEnabler2D::VisibilityEnabler2D() { } + diff --git a/scene/2d/visibility_notifier_2d.h b/scene/2d/visibility_notifier_2d.h index cdf52ecb27..621c470d5d 100644 --- a/scene/2d/visibility_notifier_2d.h +++ b/scene/2d/visibility_notifier_2d.h @@ -73,6 +73,7 @@ public: enum Enabler { ENABLER_PAUSE_ANIMATIONS, ENABLER_FREEZE_BODIES, + ENABLER_PAUSE_PARTICLES, ENABLER_MAX }; diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index a8070be91d..86f442fd8c 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -940,67 +940,67 @@ void Control::_window_input_event(InputEvent p_event) { case InputEvent::MOUSE_BUTTON: { - window->key_event_accepted=false; + window->key_event_accepted=false; - Point2 mpos =(get_canvas_transform()).affine_inverse().xform(Point2(p_event.mouse_button.x,p_event.mouse_button.y)); - if (p_event.mouse_button.pressed) { + Point2 mpos =(get_canvas_transform()).affine_inverse().xform(Point2(p_event.mouse_button.x,p_event.mouse_button.y)); + if (p_event.mouse_button.pressed) { - Size2 pos = mpos; - if (window->mouse_focus && p_event.mouse_button.button_index!=window->mouse_focus_button) { + Size2 pos = mpos; + if (window->mouse_focus && p_event.mouse_button.button_index!=window->mouse_focus_button) { - //do not steal mouse focus and stuff + //do not steal mouse focus and stuff - } else { + } else { - _window_sort_modal_stack(); - while (!window->modal_stack.empty()) { + _window_sort_modal_stack(); + while (!window->modal_stack.empty()) { - Control *top = window->modal_stack.back()->get(); - if (!top->has_point(top->get_global_transform().affine_inverse().xform(pos))) { + Control *top = window->modal_stack.back()->get(); + if (!top->has_point(top->get_global_transform().affine_inverse().xform(pos))) { - if (top->data.modal_exclusive) { - //cancel event, sorry, modal exclusive EATS UP ALL - get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID); - get_tree()->set_input_as_handled(); - return; // no one gets the event if exclusive NO ONE - } + if (top->data.modal_exclusive) { + //cancel event, sorry, modal exclusive EATS UP ALL + get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID); + get_tree()->set_input_as_handled(); + return; // no one gets the event if exclusive NO ONE + } - top->notification(NOTIFICATION_MODAL_CLOSE); - top->_modal_stack_remove(); - top->hide(); - } else { - break; + top->notification(NOTIFICATION_MODAL_CLOSE); + top->_modal_stack_remove(); + top->hide(); + } else { + break; + } } - } - Matrix32 parent_xform; + Matrix32 parent_xform; - if (data.parent_canvas_item) - parent_xform=data.parent_canvas_item->get_global_transform(); + if (data.parent_canvas_item) + parent_xform=data.parent_canvas_item->get_global_transform(); - window->mouse_focus = _find_control_at_pos(this,pos,parent_xform,window->focus_inv_xform); - //print_line("has mf "+itos(window->mouse_focus!=NULL)); - window->mouse_focus_button=p_event.mouse_button.button_index; + window->mouse_focus = _find_control_at_pos(this,pos,parent_xform,window->focus_inv_xform); + //print_line("has mf "+itos(window->mouse_focus!=NULL)); + window->mouse_focus_button=p_event.mouse_button.button_index; - if (!window->mouse_focus) { - break; - } + if (!window->mouse_focus) { + break; + } - if (p_event.mouse_button.button_index==BUTTON_LEFT) { - window->drag_accum=Vector2(); - window->drag_attempted=false; - window->drag_data=Variant(); - } + if (p_event.mouse_button.button_index==BUTTON_LEFT) { + window->drag_accum=Vector2(); + window->drag_attempted=false; + window->drag_data=Variant(); + } - } + } p_event.mouse_button.global_x = pos.x; p_event.mouse_button.global_y = pos.y; @@ -1020,8 +1020,8 @@ void Control::_window_input_event(InputEvent p_event) { /*if (bool(GLOBAL_DEF("debug/print_clicked_control",false))) { - print_line(String(window->mouse_focus->get_path())+" - "+pos); - }*/ + print_line(String(window->mouse_focus->get_path())+" - "+pos); + }*/ #endif if (window->mouse_focus->get_focus_mode()!=FOCUS_NONE && window->mouse_focus!=window->key_focus && p_event.mouse_button.button_index==BUTTON_LEFT) { @@ -1033,10 +1033,12 @@ void Control::_window_input_event(InputEvent p_event) { if (window->mouse_focus->can_process()) { _window_call_input(window->mouse_focus,p_event); } - + get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID); get_tree()->set_input_as_handled(); + window->tooltip_popup->hide(); + } else { if (window->drag_preview && p_event.mouse_button.button_index==BUTTON_LEFT) { diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index 208ba5bb66..338804e0e1 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -46,6 +46,8 @@ bool TileSet::_set(const StringName& p_name, const Variant& p_value) { tile_set_texture(id,p_value); else if (what=="tex_offset") tile_set_texture_offset(id,p_value); + else if (what=="material") + tile_set_material(id,p_value); else if (what=="shape_offset") tile_set_shape_offset(id,p_value); else if (what=="region") @@ -54,6 +56,14 @@ bool TileSet::_set(const StringName& p_name, const Variant& p_value) { tile_set_shape(id,p_value); else if (what=="shapes") _tile_set_shapes(id,p_value); + else if (what=="occluder") + tile_set_light_occluder(id,p_value); + else if (what=="occluder_offset") + tile_set_occluder_offset(id,p_value); + else if (what=="navigation") + tile_set_navigation_polygon(id,p_value); + else if (what=="navigation_offset") + tile_set_navigation_polygon_offset(id,p_value); else return false; @@ -79,6 +89,8 @@ bool TileSet::_get(const StringName& p_name,Variant &r_ret) const{ r_ret=tile_get_texture(id); else if (what=="tex_offset") r_ret=tile_get_texture_offset(id); + else if (what=="material") + r_ret=tile_get_material(id); else if (what=="shape_offset") r_ret=tile_get_shape_offset(id); else if (what=="region") @@ -87,6 +99,14 @@ bool TileSet::_get(const StringName& p_name,Variant &r_ret) const{ r_ret=tile_get_shape(id); else if (what=="shapes") r_ret=_tile_get_shapes(id); + else if (what=="occluder") + r_ret=tile_get_light_occluder(id); + else if (what=="occluder_offset") + r_ret=tile_get_occluder_offset(id); + else if (what=="navigation") + r_ret=tile_get_navigation_polygon(id); + else if (what=="navigation_offset") + r_ret=tile_get_navigation_polygon_offset(id); else return false; @@ -103,8 +123,13 @@ void TileSet::_get_property_list( List<PropertyInfo> *p_list) const{ p_list->push_back(PropertyInfo(Variant::STRING,pre+"name")); p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture")); p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"tex_offset")); - p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"shape_offset")); + p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"material",PROPERTY_HINT_RESOURCE_TYPE,"CanvasItemMaterial")); p_list->push_back(PropertyInfo(Variant::RECT2,pre+"region")); + p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"occluder_offset")); + p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"occluder",PROPERTY_HINT_RESOURCE_TYPE,"OccluderPolygon2D")); + p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"navigation_offset")); + p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"navigation",PROPERTY_HINT_RESOURCE_TYPE,"NavigationPolygon")); + p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"shape_offset")); p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"shape",PROPERTY_HINT_RESOURCE_TYPE,"Shape2D",PROPERTY_USAGE_EDITOR)); p_list->push_back(PropertyInfo(Variant::ARRAY,pre+"shapes",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR)); } @@ -134,6 +159,22 @@ Ref<Texture> TileSet::tile_get_texture(int p_id) const { } + +void TileSet::tile_set_material(int p_id,const Ref<CanvasItemMaterial> &p_material) { + + ERR_FAIL_COND(!tile_map.has(p_id)); + tile_map[p_id].material=p_material; + emit_changed(); + +} + +Ref<CanvasItemMaterial> TileSet::tile_get_material(int p_id) const{ + + ERR_FAIL_COND_V(!tile_map.has(p_id),Ref<CanvasItemMaterial>()); + return tile_map[p_id].material; +} + + void TileSet::tile_set_texture_offset(int p_id,const Vector2 &p_offset) { ERR_FAIL_COND(!tile_map.has(p_id)); @@ -210,6 +251,58 @@ Ref<Shape2D> TileSet::tile_get_shape(int p_id) const { } +void TileSet::tile_set_light_occluder(int p_id,const Ref<OccluderPolygon2D> &p_light_occluder) { + + ERR_FAIL_COND(!tile_map.has(p_id)); + tile_map[p_id].occluder=p_light_occluder; + +} + +Ref<OccluderPolygon2D> TileSet::tile_get_light_occluder(int p_id) const{ + + ERR_FAIL_COND_V(!tile_map.has(p_id),Ref<OccluderPolygon2D>()); + return tile_map[p_id].occluder; + +} + +void TileSet::tile_set_navigation_polygon_offset(int p_id,const Vector2& p_offset) { + + ERR_FAIL_COND(!tile_map.has(p_id)); + tile_map[p_id].navigation_polygon_offset=p_offset; + +} + +Vector2 TileSet::tile_get_navigation_polygon_offset(int p_id) const{ + ERR_FAIL_COND_V(!tile_map.has(p_id),Vector2()); + return tile_map[p_id].navigation_polygon_offset; +} + +void TileSet::tile_set_navigation_polygon(int p_id,const Ref<NavigationPolygon> &p_navigation_polygon) { + + ERR_FAIL_COND(!tile_map.has(p_id)); + tile_map[p_id].navigation_polygon=p_navigation_polygon; + +} + +Ref<NavigationPolygon> TileSet::tile_get_navigation_polygon(int p_id) const { + + ERR_FAIL_COND_V(!tile_map.has(p_id),Ref<NavigationPolygon>()); + return tile_map[p_id].navigation_polygon; + +} + +void TileSet::tile_set_occluder_offset(int p_id,const Vector2& p_offset) { + + ERR_FAIL_COND(!tile_map.has(p_id)); + tile_map[p_id].occluder_offset=p_offset; + +} + +Vector2 TileSet::tile_get_occluder_offset(int p_id) const{ + ERR_FAIL_COND_V(!tile_map.has(p_id),Vector2()); + return tile_map[p_id].occluder_offset; +} + void TileSet::tile_set_shapes(int p_id,const Vector<Ref<Shape2D> > &p_shapes) { ERR_FAIL_COND(!tile_map.has(p_id)); @@ -319,6 +412,8 @@ void TileSet::_bind_methods() { ObjectTypeDB::bind_method(_MD("tile_get_name","id"),&TileSet::tile_get_name); ObjectTypeDB::bind_method(_MD("tile_set_texture","id","texture:Texture"),&TileSet::tile_set_texture); ObjectTypeDB::bind_method(_MD("tile_get_texture:Texture","id"),&TileSet::tile_get_texture); + ObjectTypeDB::bind_method(_MD("tile_set_material","id","material:CanvasItemMaterial"),&TileSet::tile_set_material); + ObjectTypeDB::bind_method(_MD("tile_get_material:CanvasItemMaterial","id"),&TileSet::tile_get_material); ObjectTypeDB::bind_method(_MD("tile_set_texture_offset","id","texture_offset"),&TileSet::tile_set_texture_offset); ObjectTypeDB::bind_method(_MD("tile_get_texture_offset","id"),&TileSet::tile_get_texture_offset); ObjectTypeDB::bind_method(_MD("tile_set_shape_offset","id","shape_offset"),&TileSet::tile_set_shape_offset); @@ -329,6 +424,15 @@ void TileSet::_bind_methods() { ObjectTypeDB::bind_method(_MD("tile_get_shape:Shape2D","id"),&TileSet::tile_get_shape); ObjectTypeDB::bind_method(_MD("tile_set_shapes","id","shapes"),&TileSet::_tile_set_shapes); ObjectTypeDB::bind_method(_MD("tile_get_shapes","id"),&TileSet::_tile_get_shapes); + ObjectTypeDB::bind_method(_MD("tile_set_navigation_polygon","id","navigation_polygon:NavigationPolygon"),&TileSet::tile_set_navigation_polygon); + ObjectTypeDB::bind_method(_MD("tile_get_navigation_polygon:NavigationPolygon","id"),&TileSet::tile_get_navigation_polygon); + ObjectTypeDB::bind_method(_MD("tile_set_navigation_polygon_offset","id","navigation_polygon_offset"),&TileSet::tile_set_navigation_polygon_offset); + ObjectTypeDB::bind_method(_MD("tile_get_navigation_polygon_offset","id"),&TileSet::tile_get_navigation_polygon_offset); + ObjectTypeDB::bind_method(_MD("tile_set_light_occluder","id","light_occluder:OccluderPolygon2D"),&TileSet::tile_set_light_occluder); + ObjectTypeDB::bind_method(_MD("tile_get_light_occluder:OccluderPolygon2D","id"),&TileSet::tile_get_light_occluder); + ObjectTypeDB::bind_method(_MD("tile_set_occluder_offset","id","occluder_offset"),&TileSet::tile_set_occluder_offset); + ObjectTypeDB::bind_method(_MD("tile_get_occluder_offset","id"),&TileSet::tile_get_occluder_offset); + ObjectTypeDB::bind_method(_MD("remove_tile","id"),&TileSet::remove_tile); ObjectTypeDB::bind_method(_MD("clear"),&TileSet::clear); ObjectTypeDB::bind_method(_MD("get_last_unused_tile_id"),&TileSet::get_last_unused_tile_id); diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h index ddbb1b59a6..0234755a53 100644 --- a/scene/resources/tile_set.h +++ b/scene/resources/tile_set.h @@ -32,6 +32,8 @@ #include "resource.h" #include "scene/resources/shape_2d.h" #include "scene/resources/texture.h" +#include "scene/2d/light_occluder_2d.h" +#include "scene/2d/navigation_polygon.h" class TileSet : public Resource { @@ -45,6 +47,11 @@ class TileSet : public Resource { Vector2 shape_offset; Rect2i region; Vector<Ref<Shape2D> > shapes; + Vector2 occluder_offset; + Ref<OccluderPolygon2D> occluder; + Vector2 navigation_polygon_offset; + Ref<NavigationPolygon> navigation_polygon; + Ref<CanvasItemMaterial> material; }; Map<int,Data> tile_map; @@ -84,6 +91,21 @@ public: void tile_set_shape(int p_id,const Ref<Shape2D> &p_shape); Ref<Shape2D> tile_get_shape(int p_id) const; + void tile_set_material(int p_id,const Ref<CanvasItemMaterial> &p_material); + Ref<CanvasItemMaterial> tile_get_material(int p_id) const; + + void tile_set_occluder_offset(int p_id,const Vector2& p_offset); + Vector2 tile_get_occluder_offset(int p_id) const; + + void tile_set_light_occluder(int p_id,const Ref<OccluderPolygon2D> &p_light_occluder); + Ref<OccluderPolygon2D> tile_get_light_occluder(int p_id) const; + + void tile_set_navigation_polygon_offset(int p_id,const Vector2& p_offset); + Vector2 tile_get_navigation_polygon_offset(int p_id) const; + + void tile_set_navigation_polygon(int p_id,const Ref<NavigationPolygon> &p_navigation_polygon); + Ref<NavigationPolygon> tile_get_navigation_polygon(int p_id) const; + void tile_set_shapes(int p_id,const Vector<Ref<Shape2D> > &p_shapes); Vector<Ref<Shape2D> > tile_get_shapes(int p_id) const; diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 62ab8b3c56..d2a1c48c46 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -582,6 +582,7 @@ public: int layer_min; int layer_max; int item_mask; + int item_shadow_mask; bool subtract; RID texture; Vector2 texture_offset; @@ -613,6 +614,7 @@ public: layer_min=0; layer_max=0; item_mask=1; + item_shadow_mask=-1; subtract=false; texture_cache=NULL; next_ptr=NULL; diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index f178c27ed0..e53fe8f82d 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -1149,11 +1149,19 @@ const ShaderLanguage::BuiltinsDef ShaderLanguage::ci_fragment_builtins_defs[]={ const ShaderLanguage::BuiltinsDef ShaderLanguage::ci_light_builtins_defs[]={ - { "COLOR", TYPE_VEC4}, + { "POSITION", TYPE_VEC4}, { "NORMAL", TYPE_VEC3}, - { "LIGHT_DIR", TYPE_VEC2}, - { "LIGHT_DISTANCE", TYPE_FLOAT}, - { "LIGHT", TYPE_VEC3}, + { "UV", TYPE_VEC2}, + { "COLOR", TYPE_VEC4}, + { "TEXTURE", TYPE_TEXTURE}, + { "TEXTURE_PIXEL_SIZE", TYPE_VEC2}, + { "VAR1", TYPE_VEC4}, + { "VAR2", TYPE_VEC4}, + { "SCREEN_UV", TYPE_VEC2}, + { "LIGHT_VEC", TYPE_VEC2}, + { "LIGHT_HEIGHT", TYPE_FLOAT}, + { "LIGHT_COLOR", TYPE_VEC4}, + { "LIGHT", TYPE_VEC4}, { "POINT_COORD", TYPE_VEC2}, // { "SCREEN_POS", TYPE_VEC2}, // { "SCREEN_TEXEL_SIZE", TYPE_VEC2}, diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 3bcf0b8a3e..1c16f51e89 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -3954,6 +3954,15 @@ void VisualServerRaster::canvas_light_set_item_mask(RID p_light, int p_mask){ } +void VisualServerRaster::canvas_light_set_item_shadow_mask(RID p_light, int p_mask){ + + Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); + ERR_FAIL_COND(!clight); + clight->item_shadow_mask=p_mask; + +} + + void VisualServerRaster::canvas_light_set_subtract_mode(RID p_light, bool p_enable) { @@ -4559,6 +4568,13 @@ void VisualServerRaster::free( RID p_rid ) { } + if (occluder->canvas.is_valid() && canvas_owner.owns(occluder->canvas)) { + + Canvas *canvas = canvas_owner.get(occluder->canvas); + canvas->occluders.erase(occluder); + + } + canvas_light_occluder_owner.free( p_rid ); memdelete(occluder); @@ -6906,6 +6922,8 @@ void VisualServerRaster::_draw_viewport(Viewport *p_viewport,int p_ofs_x, int p_ Rasterizer::CanvasLight *lights_with_shadow=NULL; Rect2 shadow_rect; + int light_count=0; + for (Map<RID,Viewport::CanvasData>::Element *E=p_viewport->canvas_map.front();E;E=E->next()) { Matrix32 xf = p_viewport->global_transform * E->get().transform; @@ -6944,10 +6962,13 @@ void VisualServerRaster::_draw_viewport(Viewport *p_viewport,int p_ofs_x, int p_ cl->radius_cache=cl->rect_cache.size.length(); } + + light_count++; } } } + //print_line("lights: "+itos(light_count)); canvas_map[ Viewport::CanvasKey( E->key(), E->get().layer) ]=&E->get(); } @@ -7007,7 +7028,7 @@ void VisualServerRaster::_draw_viewport(Viewport *p_viewport,int p_ofs_x, int p_ } - rasterizer->canvas_debug_viewport_shadows(lights_with_shadow); + //rasterizer->canvas_debug_viewport_shadows(lights_with_shadow); } //capture diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index b9a3f83364..7d7bbe1d71 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -1164,6 +1164,7 @@ public: virtual void canvas_light_set_z_range(RID p_light, int p_min_z,int p_max_z); virtual void canvas_light_set_layer_range(RID p_light, int p_min_layer,int p_max_layer); virtual void canvas_light_set_item_mask(RID p_light, int p_mask); + virtual void canvas_light_set_item_shadow_mask(RID p_light, int p_mask); virtual void canvas_light_set_subtract_mode(RID p_light, bool p_enable); virtual void canvas_light_set_shadow_enabled(RID p_light, bool p_enabled); diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 1890f7b760..bccb096e1b 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -1158,6 +1158,7 @@ public: FUNC3(canvas_light_set_layer_range,RID,int,int); FUNC3(canvas_light_set_z_range,RID,int,int); FUNC2(canvas_light_set_item_mask,RID,int); + FUNC2(canvas_light_set_item_shadow_mask,RID,int); FUNC2(canvas_light_set_subtract_mode,RID,bool); FUNC2(canvas_light_set_shadow_enabled,RID,bool); diff --git a/servers/visual_server.h b/servers/visual_server.h index ccf6978ae3..9404ea040c 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -1013,6 +1013,7 @@ public: virtual void canvas_light_set_z_range(RID p_light, int p_min_z,int p_max_z)=0; virtual void canvas_light_set_layer_range(RID p_light, int p_min_layer,int p_max_layer)=0; virtual void canvas_light_set_item_mask(RID p_light, int p_mask)=0; + virtual void canvas_light_set_item_shadow_mask(RID p_light, int p_mask)=0; virtual void canvas_light_set_subtract_mode(RID p_light, bool p_enable)=0; virtual void canvas_light_set_shadow_enabled(RID p_light, bool p_enabled)=0; diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 514f4b6525..fdec72332e 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -87,7 +87,7 @@ Dictionary CanvasItemEditor::get_state() const { state["ofs"]=Point2(h_scroll->get_val(),v_scroll->get_val()); // state["ofs"]=-transform.get_origin(); state["use_snap"]=is_snap_active(); - state["snap"]=snap; + state["snap_vec"]=Vector2(get_snap()); state["pixel_snap"]=pixel_snap; return state; } @@ -111,7 +111,15 @@ void CanvasItemEditor::set_state(const Dictionary& p_state){ } if (state.has("snap")) { - snap=state["snap"]; + snap_x->set_val(state["snap"]); + snap_y->set_val(state["snap"]); + } + + if (state.has("snap_vec")) { + Vector2 sv = state["snap_vec"]; + snap_x->set_val(sv.x); + snap_y->set_val(sv.y); + viewport->update(); } if (state.has("pixel_snap")) { @@ -300,7 +308,7 @@ void CanvasItemEditor::_key_move(const Vector2& p_dir, bool p_snap, KeyMoveMODE Vector2 drag = p_dir; if (p_snap) - drag*=snap; + drag*=get_snap(); undo_redo->add_undo_method(canvas_item,"edit_set_state",canvas_item->edit_get_state()); @@ -554,6 +562,13 @@ void CanvasItemEditor::_append_canvas_item(CanvasItem *c) { } +void CanvasItemEditor::_snap_changed(double) { + + viewport->update(); +} + + + void CanvasItemEditor::_dialog_value_changed(double) { if (updating_value_dialog) @@ -563,7 +578,7 @@ void CanvasItemEditor::_dialog_value_changed(double) { case SNAP_CONFIGURE: { - snap=dialog_val->get_val(); + // snap=dialog_val->get_val(); viewport->update(); } break; case ZOOM_SET: { @@ -1165,7 +1180,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { continue; } - if (pixel_snap || (is_snap_active() && snap>0)) { + if (pixel_snap || (is_snap_active() && get_snap().x>0 && get_snap().y>0)) { if (drag!=DRAG_ALL) { dfrom=drag_point_from; @@ -1174,14 +1189,14 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { Vector2 newpos = drag_point_from + (dto-dfrom); Vector2 disp; - if (!is_snap_active() || snap<1) { + if (!is_snap_active() || get_snap().x<1 || get_snap().y<1) { disp.x = Math::fposmod(newpos.x,1); disp.y = Math::fposmod(newpos.y,1); } else { - disp.x = Math::fposmod(newpos.x,snap); - disp.y = Math::fposmod(newpos.y,snap); + disp.x = Math::fposmod(newpos.x,get_snap().x); + disp.y = Math::fposmod(newpos.y,get_snap().y); } dto-=disp; } @@ -1477,7 +1492,7 @@ void CanvasItemEditor::_viewport_draw() { _update_scrollbars(); RID ci=viewport->get_canvas_item(); - if (snap>0 && is_snap_active() && true ) { + if (get_snap().x>0 && get_snap().y>0 && is_snap_active() && true ) { Size2 s = viewport->get_size(); @@ -1485,7 +1500,7 @@ void CanvasItemEditor::_viewport_draw() { Matrix32 xform = transform.affine_inverse(); for(int i=0;i<s.width;i++) { - int cell = Math::fast_ftoi(Math::floor(xform.xform(Vector2(i,0)).x/snap)); + int cell = Math::fast_ftoi(Math::floor(xform.xform(Vector2(i,0)).x/get_snap().x)); if (i==0) last_cell=cell; if (last_cell!=cell) @@ -1495,7 +1510,7 @@ void CanvasItemEditor::_viewport_draw() { for(int i=0;i<s.height;i++) { - int cell = Math::fast_ftoi(Math::floor(xform.xform(Vector2(0,i)).y/snap)); + int cell = Math::fast_ftoi(Math::floor(xform.xform(Vector2(0,i)).y/get_snap().y)); if (i==0) last_cell=cell; if (last_cell!=cell) @@ -1809,6 +1824,8 @@ void CanvasItemEditor::_notification(int p_what) { group_button->set_icon(get_icon("Group","EditorIcons")); ungroup_button->set_icon(get_icon("Ungroup","EditorIcons")); key_insert_button->set_icon(get_icon("Key","EditorIcons")); + snap_x->connect("value_changed",this,"_snap_changed"); + snap_y->connect("value_changed",this,"_snap_changed"); } @@ -2002,7 +2019,7 @@ Point2 CanvasItemEditor::snapify(const Point2& p_pos) const { Vector2 pos = p_pos; - if (!active || snap<1) { + if (!active || get_snap().x<1 || get_snap().y<1) { if (pixel_snap) { @@ -2014,8 +2031,8 @@ Point2 CanvasItemEditor::snapify(const Point2& p_pos) const { } - pos.x=Math::stepify(pos.x,snap); - pos.y=Math::stepify(pos.y,snap); + pos.x=Math::stepify(pos.x,get_snap().x); + pos.y=Math::stepify(pos.y,get_snap().y); return pos; @@ -2038,15 +2055,46 @@ void CanvasItemEditor::_popup_callback(int p_op) { int idx = edit_menu->get_popup()->get_item_index(SNAP_USE_PIXEL); edit_menu->get_popup()->set_item_checked(idx,pixel_snap); } break; + case SNAP_OBJECT_CENTERS: { + + List<Node*> &selection = editor_selection->get_selected_node_list(); + + undo_redo->create_action("Snap Object Centers"); + for(List<Node*>::Element *E=selection.front();E;E=E->next()) { + + CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>(); + if (!canvas_item) + continue; + if (!canvas_item->is_visible()) + continue; + Node2D* node = canvas_item->cast_to<Node2D>(); + if (!node) + continue; + + Matrix32 gtrans = node->get_global_transform(); + gtrans.elements[2]=snapify(gtrans.elements[2]); + + undo_redo->add_do_method(node,"set_global_transform",gtrans); + undo_redo->add_undo_method(node,"set_global_transform",node->get_global_transform()); + } + + undo_redo->add_do_method(viewport,"update"); + undo_redo->add_undo_method(viewport,"update"); + undo_redo->commit_action(); + + } break; case SNAP_CONFIGURE: { updating_value_dialog=true; + snap_dialog->popup_centered_minsize(); +/* dialog_label->set_text("Snap (Pixels):"); dialog_val->set_min(1); dialog_val->set_step(1); dialog_val->set_max(4096); dialog_val->set_val(snap); value_dialog->popup_centered(Size2(200,85)); + */ updating_value_dialog=false; } break; @@ -2604,6 +2652,7 @@ void CanvasItemEditor::_bind_methods() { ObjectTypeDB::bind_method("_unhandled_key_input",&CanvasItemEditor::_unhandled_key_input); ObjectTypeDB::bind_method("_viewport_draw",&CanvasItemEditor::_viewport_draw); ObjectTypeDB::bind_method("_viewport_input_event",&CanvasItemEditor::_viewport_input_event); + ObjectTypeDB::bind_method("_snap_changed",&CanvasItemEditor::_snap_changed); ADD_SIGNAL( MethodInfo("item_lock_status_changed") ); ADD_SIGNAL( MethodInfo("item_group_status_changed") ); @@ -2812,6 +2861,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { p->add_item("Configure Snap..",SNAP_CONFIGURE); p->add_separator(); p->add_check_item("Use Pixel Snap",SNAP_USE_PIXEL); + p->add_item("Snap Selected Object Centers",SNAP_OBJECT_CENTERS); p->add_separator(); p->add_item("Expand to Parent",EXPAND_TO_PARENT,KEY_MASK_CMD|KEY_P); p->add_separator(); @@ -2918,12 +2968,33 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { dialog_val->connect("value_changed",this,"_dialog_value_changed"); select_sb = Ref<StyleBoxTexture>( memnew( StyleBoxTexture) ); + snap_dialog = memnew( AcceptDialog ); + VBoxContainer *snap_vb = memnew( VBoxContainer ); + snap_dialog->add_child(snap_vb); + snap_dialog->set_child_rect(snap_vb); + snap_dialog->set_title("Snap Configuration"); + snap_x = memnew( SpinBox ); + snap_x->set_custom_minimum_size(Size2(250,0)); + snap_y = memnew( SpinBox ); + snap_x->set_min(1); + snap_x->set_max(4096); + snap_x->set_step(1); + snap_x->set_val(10); + snap_y->set_min(1); + snap_y->set_max(4096); + snap_y->set_step(1); + snap_y->set_val(10); + snap_vb->add_margin_child("Snap X",snap_x); + snap_vb->add_margin_child("Snap Y",snap_y); + add_child(snap_dialog); + + key_pos=true; key_rot=true; key_scale=false; zoom=1; - snap=10; + //snap=10; updating_value_dialog=false; box_selecting=false; //zoom=0.5; diff --git a/tools/editor/plugins/canvas_item_editor_plugin.h b/tools/editor/plugins/canvas_item_editor_plugin.h index 6648d486e8..9160742826 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.h +++ b/tools/editor/plugins/canvas_item_editor_plugin.h @@ -77,6 +77,7 @@ class CanvasItemEditor : public VBoxContainer { SNAP_USE, SNAP_CONFIGURE, SNAP_USE_PIXEL, + SNAP_OBJECT_CENTERS, ZOOM_IN, ZOOM_OUT, ZOOM_RESET, @@ -143,7 +144,6 @@ class CanvasItemEditor : public VBoxContainer { Matrix32 transform; float zoom; - int snap; bool pixel_snap; bool box_selecting; Point2 box_selecting_to; @@ -250,7 +250,11 @@ class CanvasItemEditor : public VBoxContainer { AcceptDialog *value_dialog; Label *dialog_label; SpinBox *dialog_val; - + + AcceptDialog *snap_dialog; + SpinBox *snap_x; + SpinBox *snap_y; + CanvasItem *ref_item; void _add_canvas_item(CanvasItem *p_canvas_item); @@ -289,6 +293,7 @@ class CanvasItemEditor : public VBoxContainer { void _viewport_input_event(const InputEvent& p_event); void _viewport_draw(); + void _snap_changed(double); HSplitContainer *palette_split; VSplitContainer *bottom_split; @@ -335,7 +340,7 @@ protected: public: bool is_snap_active() const; - int get_snap() const { return snap; } + Size2i get_snap() const { return Size2i(snap_x->get_val(),snap_y->get_val()); } Matrix32 get_canvas_transform() const { return transform; } diff --git a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp index dab6df9a39..9a0d5b4066 100644 --- a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp +++ b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp @@ -369,6 +369,7 @@ void CollisionPolygon2DEditor::edit(Node *p_collision_polygon) { wip.clear(); wip_active=false; edited_point=-1; + canvas_item_editor->get_viewport_control()->update(); } else { node=NULL; diff --git a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp index c1fb81b66a..5fa3d8ac8f 100644 --- a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp +++ b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp @@ -96,7 +96,7 @@ bool LightOccluder2DEditor::forward_input_event(const InputEvent& p_event) { create_poly->set_text("No OccluderPolygon2D resource on this node.\nCreate and assign one?"); create_poly->popup_centered_minsize(); } - return false; + return (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1); } switch(p_event.type) { @@ -389,7 +389,7 @@ void LightOccluder2DEditor::edit(Node *p_collision_polygon) { wip.clear(); wip_active=false; edited_point=-1; - + canvas_item_editor->get_viewport_control()->update(); } else { node=NULL; @@ -402,6 +402,8 @@ void LightOccluder2DEditor::edit(Node *p_collision_polygon) { void LightOccluder2DEditor::_create_poly() { + if (!node) + return; undo_redo->create_action("Create Occluder Polygon"); undo_redo->add_do_method(node,"set_occluder_polygon",Ref<OccluderPolygon2D>(memnew( OccluderPolygon2D))); undo_redo->add_undo_method(node,"set_occluder_polygon",Variant(REF())); diff --git a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp index 599d18c8bb..163accfdd3 100644 --- a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp +++ b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp @@ -36,6 +36,9 @@ void NavigationPolygonEditor::_node_removed(Node *p_node) { void NavigationPolygonEditor::_create_nav() { + if (!node) + return; + undo_redo->create_action("Create Navigation Polygon"); undo_redo->add_do_method(node,"set_navigation_polygon",Ref<NavigationPolygon>(memnew( NavigationPolygon))); undo_redo->add_undo_method(node,"set_navigation_polygon",Variant(REF())); @@ -107,7 +110,7 @@ bool NavigationPolygonEditor::forward_input_event(const InputEvent& p_event) { create_nav->set_text("No NavigationPolygon resource on this node.\nCreate and assign one?"); create_nav->popup_centered_minsize(); } - return false; + return (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1);; } @@ -445,6 +448,7 @@ void NavigationPolygonEditor::edit(Node *p_collision_polygon) { wip.clear(); wip_active=false; edited_point=-1; + canvas_item_editor->get_viewport_control()->update(); } else { node=NULL; diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index 47727a00c2..79e43f9012 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.cpp +++ b/tools/editor/plugins/tile_map_editor_plugin.cpp @@ -640,19 +640,53 @@ void TileMapEditor::_canvas_draw() { Ref<Texture> t = ts->tile_get_texture(st); if (t.is_valid()) { - Vector2 from = xform.xform(ts->tile_get_texture_offset(st)+node->map_to_world(over_tile)+node->get_cell_draw_offset()); + Vector2 from = node->map_to_world(over_tile)+node->get_cell_draw_offset(); Rect2 r = ts->tile_get_region(st); Size2 sc = xform.get_scale(); if (mirror_x->is_pressed()) sc.x*=-1.0; if (mirror_y->is_pressed()) sc.y*=-1.0; + + Rect2 rect; + if (r==Rect2()) { + rect=Rect2(from,t->get_size()); + } else { + + rect=Rect2(from,r.get_size()); + } + + + if (node->get_tile_origin()==TileMap::TILE_ORIGIN_TOP_LEFT) { + rect.pos+=ts->tile_get_texture_offset(st); + + } else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_CENTER) { + rect.pos+=node->get_cell_size()/2; + Vector2 s = r.size; + + Vector2 center = (s/2) - ts->tile_get_texture_offset(st); + + + if (mirror_x->is_pressed()) + rect.pos.x-=s.x-center.x; + else + rect.pos.x-=center.x; + + if (mirror_y->is_pressed()) + rect.pos.y-=s.y-center.y; + else + rect.pos.y-=center.y; + } + + rect.pos=xform.xform(rect.pos); + rect.size*=sc; + if (r==Rect2()) { - canvas_item_editor->draw_texture_rect(t,Rect2(from,t->get_size()*sc),false,Color(1,1,1,0.5),transpose->is_pressed()); + canvas_item_editor->draw_texture_rect(t,rect,false,Color(1,1,1,0.5),transpose->is_pressed()); } else { - canvas_item_editor->draw_texture_rect_region(t,Rect2(from,r.get_size()*sc),r,Color(1,1,1,0.5),transpose->is_pressed()); + canvas_item_editor->draw_texture_rect_region(t,rect,r,Color(1,1,1,0.5),transpose->is_pressed()); } } } diff --git a/tools/editor/plugins/tile_set_editor_plugin.cpp b/tools/editor/plugins/tile_set_editor_plugin.cpp index a51caf7d54..8ff7720934 100644 --- a/tools/editor/plugins/tile_set_editor_plugin.cpp +++ b/tools/editor/plugins/tile_set_editor_plugin.cpp @@ -37,83 +37,103 @@ void TileSetEditor::edit(const Ref<TileSet>& p_tileset) { void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_merge) { if (!p_merge) - p_library->clear(); + p_library->clear(); for(int i=0;i<scene->get_child_count();i++) { - Node *child = scene->get_child(i); + Node *child = scene->get_child(i); - if (!child->cast_to<Sprite>()) { - if (child->get_child_count()>0) { - child=child->get_child(0); - if (!child->cast_to<Sprite>()) { - continue; - } + if (!child->cast_to<Sprite>()) { + if (child->get_child_count()>0) { + child=child->get_child(0); + if (!child->cast_to<Sprite>()) { + continue; + } - } else - continue; + } else + continue; - } + } - Sprite *mi = child->cast_to<Sprite>(); - Ref<Texture> texture=mi->get_texture(); - if (texture.is_null()) + Sprite *mi = child->cast_to<Sprite>(); + Ref<Texture> texture=mi->get_texture(); + Ref<CanvasItemMaterial> material=mi->get_material(); + + if (texture.is_null()) continue; - int id = p_library->find_tile_by_name(mi->get_name()); - if (id<0) { - - id=p_library->get_last_unused_tile_id(); - p_library->create_tile(id); - p_library->tile_set_name(id,mi->get_name()); - } - - - p_library->tile_set_texture(id,texture); - Vector2 phys_offset; - - if (mi->is_centered()) { - Size2 s; - if (mi->is_region()) { - s=mi->get_region_rect().size; - } else { - s=texture->get_size(); - } - phys_offset+=-s/2; - } - if (mi->is_region()) { - p_library->tile_set_region(id,mi->get_region_rect()); - } - - Vector<Ref<Shape2D> >collisions; - - for(int j=0;j<mi->get_child_count();j++) { - - Node *child2 = mi->get_child(j); - if (!child2->cast_to<StaticBody2D>()) - continue; - StaticBody2D *sb = child2->cast_to<StaticBody2D>(); - if (sb->get_shape_count()==0) - continue; - Ref<Shape2D> collision=sb->get_shape(0); - if (collision.is_valid()) { - collisions.push_back(collision); + int id = p_library->find_tile_by_name(mi->get_name()); + if (id<0) { + + id=p_library->get_last_unused_tile_id(); + p_library->create_tile(id); + p_library->tile_set_name(id,mi->get_name()); + } + + + + p_library->tile_set_texture(id,texture); + p_library->tile_set_material(id,material); + + Vector2 phys_offset; + + if (mi->is_centered()) { + Size2 s; + if (mi->is_region()) { + s=mi->get_region_rect().size; + } else { + s=texture->get_size(); + } + phys_offset+=-s/2; + } + if (mi->is_region()) { + p_library->tile_set_region(id,mi->get_region_rect()); + } + + Vector<Ref<Shape2D> >collisions; + Ref<NavigationPolygon> nav_poly; + Ref<OccluderPolygon2D> occluder; + + for(int j=0;j<mi->get_child_count();j++) { + + Node *child2 = mi->get_child(j); + + if (child2->cast_to<NavigationPolygonInstance>()) + nav_poly=child2->cast_to<NavigationPolygonInstance>()->get_navigation_polygon(); + + if (child2->cast_to<LightOccluder2D>()) + occluder=child2->cast_to<LightOccluder2D>()->get_occluder_polygon(); + + if (!child2->cast_to<StaticBody2D>()) + continue; + StaticBody2D *sb = child2->cast_to<StaticBody2D>(); + if (sb->get_shape_count()==0) + continue; + Ref<Shape2D> collision=sb->get_shape(0); + if (collision.is_valid()) { + collisions.push_back(collision); } - } + } - if (collisions.size()) { + if (collisions.size()) { - p_library->tile_set_shapes(id,collisions); - p_library->tile_set_shape_offset(id,-phys_offset); - } else { - p_library->tile_set_shape_offset(id,Vector2()); + p_library->tile_set_shapes(id,collisions); + p_library->tile_set_shape_offset(id,-phys_offset); + } else { + p_library->tile_set_shape_offset(id,Vector2()); + + } + + p_library->tile_set_texture_offset(id,mi->get_offset()); + p_library->tile_set_navigation_polygon(id,nav_poly); + p_library->tile_set_light_occluder(id,occluder); + p_library->tile_set_occluder_offset(id,-phys_offset); + p_library->tile_set_navigation_polygon_offset(id,-phys_offset); - } - p_library->tile_set_texture_offset(id,mi->get_offset()); } } @@ -121,23 +141,23 @@ void TileSetEditor::_menu_confirm() { switch(option) { - case MENU_OPTION_REMOVE_ITEM: { + case MENU_OPTION_REMOVE_ITEM: { - tileset->remove_tile(to_erase); - } break; - case MENU_OPTION_MERGE_FROM_SCENE: - case MENU_OPTION_CREATE_FROM_SCENE: { + tileset->remove_tile(to_erase); + } break; + case MENU_OPTION_MERGE_FROM_SCENE: + case MENU_OPTION_CREATE_FROM_SCENE: { - EditorNode *en = editor; - Node * scene = en->get_edited_scene(); - if (!scene) - break; + EditorNode *en = editor; + Node * scene = en->get_edited_scene(); + if (!scene) + break; - _import_scene(scene,tileset,option==MENU_OPTION_MERGE_FROM_SCENE); + _import_scene(scene,tileset,option==MENU_OPTION_MERGE_FROM_SCENE); - } break; + } break; } } @@ -165,11 +185,11 @@ void TileSetEditor::_menu_cbk(int p_option) { cd->set_text("Create from scene?"); cd->popup_centered(Size2(300,60)); } break; - case MENU_OPTION_MERGE_FROM_SCENE: { + case MENU_OPTION_MERGE_FROM_SCENE: { - cd->set_text("Merge from scene?"); - cd->popup_centered(Size2(300,60)); - } break; + cd->set_text("Merge from scene?"); + cd->popup_centered(Size2(300,60)); + } break; } } diff --git a/tools/editor/plugins/tile_set_editor_plugin.h b/tools/editor/plugins/tile_set_editor_plugin.h index 2531ec55bf..1248b4e007 100644 --- a/tools/editor/plugins/tile_set_editor_plugin.h +++ b/tools/editor/plugins/tile_set_editor_plugin.h @@ -56,7 +56,7 @@ class TileSetEditor : public Control { int option; void _menu_cbk(int p_option); - void _menu_confirm(); + void _menu_confirm(); static void _import_scene(Node *p_scene, Ref<TileSet> p_library, bool p_merge); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 25c39b3173..fb4c134263 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -1860,7 +1860,7 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p if (has_icon(res->get_type(),"EditorIcons")) { - p_item->set_icon(1,get_icon(res->get_type(),"EditorIcons")); + p_item->set_icon(0,get_icon(res->get_type(),"EditorIcons")); } else { Dictionary d = p_item->get_metadata(0); @@ -1870,10 +1870,10 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p if (has_icon(hint_text,"EditorIcons")) { - p_item->set_icon(1,get_icon(hint_text,"EditorIcons")); + p_item->set_icon(0,get_icon(hint_text,"EditorIcons")); } else { - p_item->set_icon(1,get_icon("Object","EditorIcons")); + p_item->set_icon(0,get_icon("Object","EditorIcons")); } } |