Merge remote-tracking branch 'origin/Physics' into LevelSystemAndSuch

This commit is contained in:
PlatinumSkink
2015-10-06 18:33:49 +02:00
22 changed files with 7961 additions and 560 deletions
+12
View File
@@ -0,0 +1,12 @@
# Blender MTL File: 'Bricks.blend'
# Material Count: 1
newmtl Material.002
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2
map_Kd IceBrick_Diffuse.png
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

+12
View File
@@ -0,0 +1,12 @@
# Blender MTL File: 'Bricks.blend'
# Material Count: 1
newmtl Material.004
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2
map_Kd turquoise.png
+513
View File
@@ -0,0 +1,513 @@
# Blender v2.75 (sub 0) OBJ File: 'Bricks.blend'
# www.blender.org
mtllib TurquoiseBrick.mtl
o OriginalBrick_Cube.002
v 0.416882 0.151013 0.189181
v 0.383459 0.157800 0.197587
v 0.427922 0.161606 0.161784
v 0.383459 0.180000 0.161784
v 0.432779 0.125616 0.202365
v 0.383459 0.126000 0.215784
v 0.450000 0.126000 0.161784
v -0.416882 0.151013 0.189181
v 0.000000 0.157800 0.197587
v -0.383459 0.157800 0.197587
v -0.427922 0.161606 0.161784
v 0.000000 0.180000 0.161784
v -0.383459 0.180000 0.161784
v -0.432779 0.125616 0.202365
v 0.000000 0.126000 0.215784
v -0.383459 0.126000 0.215784
v -0.450000 0.126000 0.161784
v 0.427922 0.161606 0.000000
v 0.416882 0.151013 -0.189181
v 0.383459 0.180000 0.000000
v 0.383459 0.157800 -0.197587
v 0.427922 0.161606 -0.161784
v 0.383459 0.180000 -0.161784
v 0.450000 0.126000 0.000000
v 0.432779 0.125616 -0.202365
v 0.383459 0.126000 -0.215784
v 0.450000 0.126000 -0.161784
v 0.000000 0.180000 0.000000
v -0.427922 0.161606 0.000000
v -0.416882 0.151013 -0.189181
v 0.000000 0.157800 -0.197587
v -0.383459 0.180000 0.000000
v -0.383459 0.157800 -0.197587
v -0.427922 0.161606 -0.161784
v 0.000000 0.180000 -0.161784
v -0.383459 0.180000 -0.161784
v -0.450000 0.126000 0.000000
v -0.432779 0.125616 -0.202365
v 0.000000 0.126000 -0.215784
v -0.383459 0.126000 -0.215784
v -0.450000 0.126000 -0.161784
v 0.416882 -0.151013 0.189181
v 0.383459 -0.157800 0.197587
v 0.427922 -0.161606 0.161784
v 0.383459 -0.180000 0.161784
v 0.432779 -0.125616 0.202365
v 0.383459 -0.126000 0.215784
v 0.450000 -0.126000 0.161784
v 0.432723 0.000000 0.202132
v 0.383459 0.000000 0.215784
v 0.450000 0.000000 0.161784
v -0.416882 -0.151013 0.189181
v 0.000000 -0.157800 0.197587
v -0.383459 -0.157800 0.197587
v -0.427922 -0.161606 0.161784
v 0.000000 -0.180000 0.161784
v -0.383459 -0.180000 0.161784
v -0.432779 -0.125616 0.202365
v 0.000000 -0.126000 0.215784
v -0.383459 -0.126000 0.215784
v -0.450000 -0.126000 0.161784
v -0.432723 0.000000 0.202132
v 0.000000 0.000000 0.215784
v -0.383459 0.000000 0.215784
v -0.450000 0.000000 0.161784
v 0.427922 -0.161606 0.000000
v 0.416882 -0.151013 -0.189181
v 0.383459 -0.180000 0.000000
v 0.383459 -0.157800 -0.197587
v 0.427922 -0.161606 -0.161784
v 0.383459 -0.180000 -0.161784
v 0.450000 -0.126000 0.000000
v 0.432779 -0.125616 -0.202365
v 0.383459 -0.126000 -0.215784
v 0.450000 -0.126000 -0.161784
v 0.450000 0.000000 0.000000
v 0.432723 0.000000 -0.202132
v 0.383459 0.000000 -0.215784
v 0.450000 0.000000 -0.161784
v 0.000000 -0.180000 0.000000
v -0.427922 -0.161606 0.000000
v -0.416882 -0.151013 -0.189181
v 0.000000 -0.157800 -0.197587
v -0.383459 -0.180000 0.000000
v -0.383459 -0.157800 -0.197587
v -0.427922 -0.161606 -0.161784
v 0.000000 -0.180000 -0.161784
v -0.383459 -0.180000 -0.161784
v -0.450000 -0.126000 0.000000
v -0.432779 -0.125616 -0.202365
v 0.000000 -0.126000 -0.215784
v -0.383459 -0.126000 -0.215784
v -0.450000 -0.126000 -0.161784
v -0.450000 0.000000 0.000000
v -0.432723 0.000000 -0.202132
v 0.000000 0.000000 -0.215784
v -0.383459 0.000000 -0.215784
v -0.450000 0.000000 -0.161784
vt 0.732824 0.651596
vt 0.497063 0.656145
vt 0.498352 0.561696
vt 0.835737 0.544092
vt 0.832410 0.574334
vt 0.728776 0.549797
vt 0.733409 0.516110
vt 0.747921 0.523504
vt 0.498691 0.536867
vt 0.754013 0.503366
vt 0.838288 0.518944
vt 0.716137 0.523643
vt 0.711494 0.504530
vt 0.498984 0.515399
vt 0.734485 0.500579
vt 0.734742 0.443967
vt 0.756687 0.444264
vt 0.500002 0.440769
vt 0.708811 0.443615
vt 0.842574 0.445423
vt 0.261516 0.645162
vt 0.268342 0.543511
vt 0.164088 0.565217
vt 0.161584 0.534899
vt 0.264629 0.509713
vt 0.281689 0.517713
vt 0.159717 0.509691
vt 0.244381 0.496413
vt 0.249922 0.516708
vt 0.263977 0.494158
vt 0.286851 0.498734
vt 0.243317 0.437260
vt 0.265263 0.437561
vt 0.291193 0.437916
vt 0.157430 0.436083
vt 0.495722 0.754363
vt 0.939579 0.572784
vt 0.950008 0.538976
vt 0.966270 0.556108
vt 0.495366 0.780443
vt 0.733578 0.753608
vt 0.929866 0.518425
vt 0.931317 0.541897
vt 0.953950 0.520177
vt 0.983612 0.534778
vt 0.733699 0.802691
vt 0.495056 0.803167
vt 0.935351 0.446668
vt 0.962999 0.447038
vt 0.733787 0.881463
vt 0.493987 0.881463
vt 0.999906 0.447531
vt 0.057009 0.560761
vt 0.047501 0.526686
vt 0.066106 0.530111
vt 0.257977 0.747114
vt 0.068193 0.506688
vt 0.030782 0.543370
vt 0.014024 0.521580
vt 0.256516 0.796175
vt 0.044070 0.507787
vt 0.037002 0.434429
vt 0.064650 0.434809
vt 0.254277 0.874915
vt 0.000094 0.433923
vt 0.501652 0.319843
vt 0.502941 0.225399
vt 0.738475 0.236380
vt 0.731650 0.338024
vt 0.835884 0.316299
vt 0.838396 0.346613
vt 0.735366 0.371817
vt 0.718307 0.363820
vt 0.501313 0.344671
vt 0.840268 0.371818
vt 0.755614 0.385114
vt 0.750071 0.364821
vt 0.736021 0.387371
vt 0.713148 0.382798
vt 0.501020 0.366139
vt 0.267194 0.229946
vt 0.164293 0.337419
vt 0.167628 0.307183
vt 0.271241 0.331739
vt 0.266605 0.365420
vt 0.252095 0.358025
vt 0.246001 0.378160
vt 0.161736 0.362565
vt 0.283877 0.357890
vt 0.288517 0.377003
vt 0.265527 0.380951
vt 0.504282 0.127186
vt 0.942953 0.320724
vt 0.952471 0.354792
vt 0.933866 0.351373
vt 0.742013 0.134433
vt 0.504638 0.101108
vt 0.931787 0.374794
vt 0.969182 0.338104
vt 0.985946 0.359886
vt 0.504948 0.078385
vt 0.743473 0.085376
vt 0.955907 0.373688
vt 0.506017 0.000095
vt 0.745712 0.006641
vt 0.060470 0.308697
vt 0.050030 0.342497
vt 0.033776 0.325361
vt 0.266441 0.127940
vt 0.070165 0.363055
vt 0.068721 0.339584
vt 0.046081 0.361294
vt 0.016425 0.346681
vt 0.266320 0.078861
vt 0.266232 0.000094
vt 0.733646 0.779865
vt 0.257192 0.773359
vt 0.742798 0.108190
vt 0.266373 0.101685
vn 0.194900 0.980800 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 0.961700 0.273900
vn 0.647300 0.762200 0.000000
vn 0.178700 0.949500 0.257800
vn 0.457300 0.661600 0.594300
vn 0.631200 0.737600 0.239800
vn 0.000000 0.694500 0.719500
vn 0.939500 0.276000 0.202600
vn 0.961700 0.274000 0.000000
vn 0.151600 0.685100 0.712500
vn 0.135500 0.258500 0.956400
vn 0.000000 0.256900 0.966400
vn 0.632300 0.305000 0.712100
vn 0.658300 0.000000 0.752800
vn 0.979700 0.000000 0.200600
vn 0.000000 0.000000 1.000000
vn 0.134200 0.000000 0.990900
vn 1.000000 0.000000 0.000000
vn -0.194900 0.980800 0.000000
vn -0.178700 0.949500 0.257800
vn -0.647300 0.762200 0.000000
vn -0.457300 0.661600 0.594300
vn -0.151600 0.685100 0.712500
vn -0.961700 0.274000 0.000000
vn -0.939500 0.276000 0.202600
vn -0.631200 0.737600 0.239800
vn -0.632300 0.305000 0.712100
vn -0.135500 0.258500 0.956400
vn -0.979700 0.000000 0.200600
vn -0.658300 0.000000 0.752800
vn -0.134200 0.000000 0.990900
vn -1.000000 0.000000 0.000000
vn 0.000000 0.961700 -0.273900
vn 0.178700 0.949500 -0.257800
vn 0.457300 0.661600 -0.594300
vn 0.151600 0.685100 -0.712500
vn 0.000000 0.694500 -0.719500
vn 0.939500 0.276000 -0.202600
vn 0.631200 0.737600 -0.239800
vn 0.632300 0.305000 -0.712100
vn 0.135500 0.258500 -0.956400
vn 0.000000 0.256900 -0.966400
vn 0.979700 0.000000 -0.200600
vn 0.658300 0.000000 -0.752800
vn 0.134200 0.000000 -0.990900
vn 0.000000 0.000000 -1.000000
vn -0.178700 0.949500 -0.257800
vn -0.457300 0.661600 -0.594300
vn -0.631200 0.737600 -0.239800
vn -0.939500 0.276000 -0.202600
vn -0.151600 0.685100 -0.712500
vn -0.135500 0.258500 -0.956400
vn -0.632300 0.305000 -0.712100
vn -0.658300 0.000000 -0.752800
vn -0.979700 0.000000 -0.200600
vn -0.134200 0.000000 -0.990900
vn 0.000000 -0.961700 0.273900
vn 0.000000 -1.000000 0.000000
vn 0.194900 -0.980800 0.000000
vn 0.178700 -0.949500 0.257800
vn 0.647300 -0.762200 0.000000
vn 0.457300 -0.661600 0.594300
vn 0.151600 -0.685100 0.712500
vn 0.000000 -0.694500 0.719500
vn 0.961700 -0.274000 0.000000
vn 0.939500 -0.276000 0.202600
vn 0.631200 -0.737600 0.239800
vn 0.632300 -0.305000 0.712100
vn 0.135500 -0.258500 0.956400
vn 0.000000 -0.256900 0.966400
vn -0.194900 -0.980800 0.000000
vn -0.647300 -0.762200 0.000000
vn -0.178700 -0.949500 0.257800
vn -0.457300 -0.661600 0.594300
vn -0.631200 -0.737600 0.239800
vn -0.939500 -0.276000 0.202600
vn -0.961700 -0.274000 0.000000
vn -0.151600 -0.685100 0.712500
vn -0.135500 -0.258500 0.956400
vn -0.632300 -0.305000 0.712100
vn 0.000000 -0.961700 -0.273900
vn 0.178700 -0.949500 -0.257800
vn 0.457300 -0.661600 -0.594300
vn 0.631200 -0.737600 -0.239800
vn 0.000000 -0.694500 -0.719500
vn 0.939500 -0.276000 -0.202600
vn 0.151600 -0.685100 -0.712500
vn 0.135500 -0.258500 -0.956400
vn 0.000000 -0.256900 -0.966400
vn 0.632300 -0.305000 -0.712100
vn -0.178700 -0.949500 -0.257800
vn -0.457300 -0.661600 -0.594300
vn -0.151600 -0.685100 -0.712500
vn -0.939500 -0.276000 -0.202600
vn -0.631200 -0.737600 -0.239800
vn -0.632300 -0.305000 -0.712100
vn -0.135500 -0.258500 -0.956400
usemtl Material.004
s 1
f 20/1/1 28/2/2 12/3/3
f 18/4/4 20/5/1 4/6/5
f 1/7/6 3/8/7 4/6/5
f 4/6/5 12/3/3 9/9/8
f 3/8/7 7/10/9 24/11/10
f 1/7/6 2/12/11 6/13/12
f 9/9/8 15/14/13 6/13/12
f 1/7/6 5/15/14 7/10/9
f 5/15/14 49/16/15 51/17/16
f 15/14/13 63/18/17 50/19/18
f 5/15/14 6/13/12 50/19/18
f 7/10/9 51/17/16 76/20/19
f 12/3/3 28/2/2 32/21/20
f 13/22/21 32/23/20 29/24/22
f 8/25/23 10/26/24 13/22/21
f 9/9/8 12/3/3 13/22/21
f 37/27/25 17/28/26 11/29/27
f 8/25/23 14/30/28 16/31/29
f 16/31/29 15/14/13 9/9/8
f 17/28/26 14/30/28 8/25/23
f 65/32/30 62/33/31 14/30/28
f 64/34/32 63/18/17 15/14/13
f 14/30/28 62/33/31 64/34/32
f 94/35/33 65/32/30 17/28/26
f 35/36/34 28/2/2 20/1/1
f 23/37/35 20/5/1 18/4/4
f 19/38/36 21/39/37 23/37/35
f 31/40/38 35/36/34 23/41/35
f 24/11/10 27/42/39 22/43/40
f 19/38/36 25/44/41 26/45/42
f 26/46/42 39/47/43 31/40/38
f 27/42/39 25/44/41 19/38/36
f 79/48/44 77/49/45 25/44/41
f 78/50/46 96/51/47 39/47/43
f 25/44/41 77/49/45 78/52/46
f 76/20/19 79/48/44 27/42/39
f 32/21/20 28/2/2 35/36/34
f 29/24/22 32/23/20 36/53/48
f 30/54/49 34/55/50 36/53/48
f 36/56/48 35/36/34 31/40/38
f 34/55/50 41/57/51 37/27/25
f 30/54/49 33/58/52 40/59/53
f 31/40/38 39/47/43 40/60/53
f 30/54/49 38/61/54 41/57/51
f 38/61/54 95/62/55 98/63/56
f 39/47/43 96/51/47 97/64/57
f 38/61/54 40/59/53 97/65/57
f 41/57/51 98/63/56 94/35/33
f 56/66/58 80/67/59 68/68/60
f 45/69/61 68/70/60 66/71/62
f 42/72/63 43/73/64 45/69/61
f 53/74/65 56/66/58 45/69/61
f 72/75/66 48/76/67 44/77/68
f 42/72/63 46/78/69 47/79/70
f 47/79/70 59/80/71 53/74/65
f 48/76/67 46/78/69 42/72/63
f 51/17/16 49/16/15 46/78/69
f 50/19/18 63/18/17 59/80/71
f 46/78/69 49/16/15 50/19/18
f 76/20/19 51/17/16 48/76/67
f 84/81/72 80/67/59 56/66/58
f 81/82/73 84/83/72 57/84/74
f 52/85/75 55/86/76 57/84/74
f 57/84/74 56/66/58 53/74/65
f 55/86/76 61/87/77 89/88/78
f 52/85/75 54/89/79 60/90/80
f 53/74/65 59/80/71 60/90/80
f 52/85/75 58/91/81 61/87/77
f 58/91/81 62/33/31 65/32/30
f 59/80/71 63/18/17 64/34/32
f 58/91/81 60/90/80 64/34/32
f 61/87/77 65/32/30 94/35/33
f 68/68/60 80/67/59 87/92/82
f 66/71/62 68/70/60 71/93/83
f 67/94/84 70/95/85 71/93/83
f 71/96/83 87/92/82 83/97/86
f 70/95/85 75/98/87 72/75/66
f 67/94/84 69/99/88 74/100/89
f 83/97/86 91/101/90 74/102/89
f 67/94/84 73/103/91 75/98/87
f 73/103/91 77/49/45 79/48/44
f 91/101/90 96/104/47 78/105/46
f 73/103/91 74/100/89 78/52/46
f 75/98/87 79/48/44 76/20/19
f 87/92/82 80/67/59 84/81/72
f 88/106/92 84/83/72 81/82/73
f 82/107/93 85/108/94 88/106/92
f 83/97/86 87/92/82 88/109/92
f 89/88/78 93/110/95 86/111/96
f 82/107/93 90/112/97 92/113/98
f 92/114/98 91/101/90 83/97/86
f 93/110/95 90/112/97 82/107/93
f 98/63/56 95/62/55 90/112/97
f 97/115/57 96/104/47 91/101/90
f 90/112/97 95/62/55 97/65/57
f 94/35/33 98/63/56 93/110/95
f 4/6/5 20/1/1 12/3/3
f 3/8/7 18/4/4 4/6/5
f 2/12/11 1/7/6 4/6/5
f 2/12/11 4/6/5 9/9/8
f 18/4/4 3/8/7 24/11/10
f 5/15/14 1/7/6 6/13/12
f 2/12/11 9/9/8 6/13/12
f 3/8/7 1/7/6 7/10/9
f 7/10/9 5/15/14 51/17/16
f 6/13/12 15/14/13 50/19/18
f 49/16/15 5/15/14 50/19/18
f 24/11/10 7/10/9 76/20/19
f 13/22/21 12/3/3 32/21/20
f 11/29/27 13/22/21 29/24/22
f 11/29/27 8/25/23 13/22/21
f 10/26/24 9/9/8 13/22/21
f 29/24/22 37/27/25 11/29/27
f 10/26/24 8/25/23 16/31/29
f 10/26/24 16/31/29 9/9/8
f 11/29/27 17/28/26 8/25/23
f 17/28/26 65/32/30 14/30/28
f 16/31/29 64/34/32 15/14/13
f 16/31/29 14/30/28 64/34/32
f 37/27/25 94/35/33 17/28/26
f 23/41/35 35/36/34 20/1/1
f 22/43/40 23/37/35 18/4/4
f 22/43/40 19/38/36 23/37/35
f 21/116/37 31/40/38 23/41/35
f 18/4/4 24/11/10 22/43/40
f 21/39/37 19/38/36 26/45/42
f 21/116/37 26/46/42 31/40/38
f 22/43/40 27/42/39 19/38/36
f 27/42/39 79/48/44 25/44/41
f 26/46/42 78/50/46 39/47/43
f 26/45/42 25/44/41 78/52/46
f 24/11/10 76/20/19 27/42/39
f 36/56/48 32/21/20 35/36/34
f 34/55/50 29/24/22 36/53/48
f 33/58/52 30/54/49 36/53/48
f 33/117/52 36/56/48 31/40/38
f 29/24/22 34/55/50 37/27/25
f 38/61/54 30/54/49 40/59/53
f 33/117/52 31/40/38 40/60/53
f 34/55/50 30/54/49 41/57/51
f 41/57/51 38/61/54 98/63/56
f 40/60/53 39/47/43 97/64/57
f 95/62/55 38/61/54 97/65/57
f 37/27/25 41/57/51 94/35/33
f 45/69/61 56/66/58 68/68/60
f 44/77/68 45/69/61 66/71/62
f 44/77/68 42/72/63 45/69/61
f 43/73/64 53/74/65 45/69/61
f 66/71/62 72/75/66 44/77/68
f 43/73/64 42/72/63 47/79/70
f 43/73/64 47/79/70 53/74/65
f 44/77/68 48/76/67 42/72/63
f 48/76/67 51/17/16 46/78/69
f 47/79/70 50/19/18 59/80/71
f 47/79/70 46/78/69 50/19/18
f 72/75/66 76/20/19 48/76/67
f 57/84/74 84/81/72 56/66/58
f 55/86/76 81/82/73 57/84/74
f 54/89/79 52/85/75 57/84/74
f 54/89/79 57/84/74 53/74/65
f 81/82/73 55/86/76 89/88/78
f 58/91/81 52/85/75 60/90/80
f 54/89/79 53/74/65 60/90/80
f 55/86/76 52/85/75 61/87/77
f 61/87/77 58/91/81 65/32/30
f 60/90/80 59/80/71 64/34/32
f 62/33/31 58/91/81 64/34/32
f 89/88/78 61/87/77 94/35/33
f 71/96/83 68/68/60 87/92/82
f 70/95/85 66/71/62 71/93/83
f 69/99/88 67/94/84 71/93/83
f 69/118/88 71/96/83 83/97/86
f 66/71/62 70/95/85 72/75/66
f 73/103/91 67/94/84 74/100/89
f 69/118/88 83/97/86 74/102/89
f 70/95/85 67/94/84 75/98/87
f 75/98/87 73/103/91 79/48/44
f 74/102/89 91/101/90 78/105/46
f 77/49/45 73/103/91 78/52/46
f 72/75/66 75/98/87 76/20/19
f 88/109/92 87/92/82 84/81/72
f 86/111/96 88/106/92 81/82/73
f 86/111/96 82/107/93 88/106/92
f 85/119/94 83/97/86 88/109/92
f 81/82/73 89/88/78 86/111/96
f 85/108/94 82/107/93 92/113/98
f 85/119/94 92/114/98 83/97/86
f 86/111/96 93/110/95 82/107/93
f 93/110/95 98/63/56 90/112/97
f 92/114/98 97/115/57 91/101/90
f 92/113/98 90/112/97 97/65/57
f 89/88/78 94/35/33 93/110/95
Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

+21
View File
@@ -0,0 +1,21 @@
# Blender MTL File: 'Sid.blend'
# Material Count: 2
newmtl Derp
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2
map_Kd SquidTexture.png
newmtl None
Ns 0
Ka 0.000000 0.000000 0.000000
Kd 0.8 0.8 0.8
Ks 0.8 0.8 0.8
d 1
illum 2
map_Kd SquidTexture.png
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Executable → Regular
+27 -58
View File
@@ -225,12 +225,10 @@ public:
//Water test
{
float amount = 1.5f;
auto t_waterBody = m_World->CreateEntity();
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
transform->Position = glm::vec3(0.f, -6.25f + (amount / 2), -10.f);
transform->Scale = glm::vec3(7.f, amount, 1.f);
transform->Position = glm::vec3(0.f, -5.5f, -10.f);
transform->Scale = glm::vec3(7.f, 1.5f, 1.f);
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
m_World->CommitEntity(t_waterBody);
@@ -239,83 +237,54 @@ public:
//TODO: Why does the ball not collide with these bricks?
//BottomBox
{
auto topWall = m_World->CreateEntity();
auto transform = m_World->AddComponent<Components::Transform>(topWall);
transform->Position = glm::vec3(0.f, -6.f, -9.9f);
transform->Scale = glm::vec3(10.f, 0.5f, 1.f);
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
auto BottomWall = m_World->CreateEntity();
auto transform = m_World->AddComponent<Components::Transform>(BottomWall);
transform->Position = glm::vec3(0.f, -6.f, -10.f);
transform->Scale = glm::vec3(20.f, 0.5f, 1.f);
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(BottomWall);
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
topWall);
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
physics->Static = true;
m_World->CommitEntity(topWall);
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(BottomWall);
rectangleShape->Dimensions = glm::vec2(20.f, 0.5f);
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(BottomWall);
physics->CollisionType = CollisionType::Type::Static;
m_World->CommitEntity(BottomWall);
}
//SideBox
// {
// auto topWall = m_World->CreateEntity();
// std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
// transform->Position = glm::vec3(3.f, -3.0f, -9.9f);
// transform->Scale = glm::vec3(0.5f, 3.f, 1.f);
// std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
// sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
// std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
// topWall);
// std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
// physics->Static = true;
// m_World->CommitEntity(topWall);
// }
// //OtherSideBox
// {
// auto topWall = m_World->CreateEntity();
// std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
// transform->Position = glm::vec3(-4.f, -3.0f, -9.9f);
// transform->Scale = glm::vec3(0.5f, 3.0f, 1.f);
// std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
// sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
// std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
// topWall);
// std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
// physics->Static = true;
// m_World->CommitEntity(topWall);
// }
/*{
{
auto topWall = m_World->CreateEntity();
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(
topWall);
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
transform->Position = glm::vec3(0.f, 6.f, -10.f);
transform->Scale = glm::vec3(20.f, 0.5f, 1.f);
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
topWall);
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(topWall);
rectangleShape->Dimensions = glm::vec2(20.f, 0.5f);
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
physics->Static = true;
physics->CollisionType = CollisionType::Type::Static;
physics->Category = CollisionLayer::Type::Wall;
physics->Mask = CollisionLayer::Type::Ball | CollisionLayer::Type::Brick;
m_World->CommitEntity(topWall);
}*/
}
{
auto leftWall = m_World->CreateEntity();
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(
leftWall);
transform->Position = glm::vec3(-4.f, 1.f, -10.f);
transform->Scale = glm::vec3(0.5f, 35.f, 1.f);
transform->Scale = glm::vec3(0.5f, 20.f, 1.f);
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(leftWall);
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
leftWall);
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(leftWall);
rectangleShape->Dimensions = glm::vec2(0.5f, 20.f);
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(leftWall);
physics->Static = true;
physics->CollisionType = CollisionType::Type::Static;
physics->Category = CollisionLayer::Type::Wall;
physics->Mask = CollisionLayer::Type::Ball | CollisionLayer::Type::Brick;
@@ -327,23 +296,23 @@ public:
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(
rightWall);
transform->Position = glm::vec3(4.f, 1.f, -10.f);
transform->Scale = glm::vec3(0.5f, 35.f, 1.f);
transform->Scale = glm::vec3(0.5f, 20.f, 1.f);
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(rightWall);
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
rightWall);
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(rightWall);
rectangleShape->Dimensions = glm::vec2(0.5f, 20.f);
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(rightWall);
physics->Static = true;
physics->CollisionType = CollisionType::Type::Static;
physics->Category = CollisionLayer::Type::Wall;
physics->Mask = CollisionLayer::Type::Ball | CollisionLayer::Type::Brick;
m_World->CommitEntity(rightWall);
}
//EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &Engine::OnGameStart);
m_EGameStart = decltype(m_EGameStart)(std::bind(&Engine::OnGameStart, this, std::placeholders::_1));
m_EventBroker->Subscribe(m_EGameStart);
+14
View File
@@ -60,6 +60,10 @@ protected:
virtual bool OnMouseMove(const Events::MouseMove& event)
{
if (Hidden()) {
return false;
}
bool isOver = Rectangle::Intersects(AbsoluteRectangle(), Rectangle(event.X, event.Y, 1, 1));
if (isOver && !m_MouseIsOver) { // Enter
if (!m_IsDown) {
@@ -88,6 +92,11 @@ protected:
}
virtual bool OnMousePress(const Events::MousePress& event)
{
if (Hidden()) {
LOG_DEBUG("Pressed hidden button");
return false;
}
if (!Rectangle::Intersects(AbsoluteRectangle(), Rectangle(event.X, event.Y, 1, 1))) {
return false;
}
@@ -107,6 +116,11 @@ protected:
}
virtual bool OnMouseRelease(const Events::MouseRelease& event)
{
if (Hidden()) {
LOG_DEBUG("Released hidden button");
return false;
}
bool isOver = Rectangle::Intersects(AbsoluteRectangle(), Rectangle(event.X, event.Y, 1, 1));
if (!isOver && !m_IsDown) {
return false;
+1 -1
View File
@@ -10,7 +10,7 @@ namespace Components
struct CircleShape : public Component
{
// Circles are circles
float Radius = 1.f;
};
}
+31 -16
View File
@@ -18,26 +18,41 @@ enum Type
Wall = 1 << 6
};
}
namespace Components
{
struct Physics: public Component
namespace CollisionType
{
bool Static = true;
bool Calculate = false;
float GravityScale = 0.f;
CollisionLayer::Type Category = CollisionLayer::Type::Other;
CollisionLayer::Type Mask =
CollisionLayer::Type::Pad |
CollisionLayer::Type::Ball |
CollisionLayer::Type::Brick |
CollisionLayer::Type::Water |
CollisionLayer::Type::PowerUp |
CollisionLayer::Type::Wall |
CollisionLayer::Type::Other;
enum Type
{
Static = 0,
Kinematic = 1,
Dynamic = 2,
};
}
namespace Components
{
struct Physics: public Component
{
CollisionType::Type CollisionType = CollisionType::Type::Static;
bool Calculate = false;
float GravityScale = 0.f;
CollisionLayer::Type Category = CollisionLayer::Type::Other;
CollisionLayer::Type Mask =
CollisionLayer::Type::Pad |
CollisionLayer::Type::Ball |
CollisionLayer::Type::Brick |
CollisionLayer::Type::Water |
CollisionLayer::Type::PowerUp |
CollisionLayer::Type::Wall |
CollisionLayer::Type::Other;
};
}
}
#endif //DAYDREAM_CPHYSICS_H
+1 -1
View File
@@ -10,7 +10,7 @@ namespace Components
struct RectangleShape : public Component
{
glm::vec2 Dimensions = glm::vec2(1.f, 1.f);
};
}
+94 -129
View File
@@ -3,167 +3,132 @@
#include <unordered_map>
#include "Core/CTransform.h"
#include <Box2D/Box2D.h>
#include "Core/System.h"
#include "Core/World.h"
#include "Core/EventBroker.h"
#include "Core/CTemplate.h"
#include "Box2D/Box2D.h"
#include "Physics/CRectangleShape.h"
#include "Physics/CCircleShape.h"
#include "Physics/CPhysics.h"
#include "Physics/CWaterVolume.h"
#include "Core/CTransform.h"
#include "Transform/TransformSystem.h"
#include "CRectangleShape.h"
#include "Physics/CPhysics.h"
#include "Physics/EContact.h"
#include "Physics/ESetImpulse.h"
#include "Physics/CParticle.h"
#include "Physics/CCircleShape.h"
#include "Physics/CParticleEmitter.h"
#include "Game/EPause.h"
#include "Game/CPad.h"
#include "Game/CPad.h"
#include "Game/CBall.h"
#include "Transform/TransformSystem.h"
#include "Rendering/CSprite.h"
#include "Core/CTemplate.h"
#include "Game/EPause.h"
namespace dd
{
namespace Systems
{
class PhysicsSystem : public System
{
friend class ContractListener;
public:
PhysicsSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
: System(world, eventBroker) {}
~PhysicsSystem();
EventRelay<PhysicsSystem, Events::SetImpulse> m_SetImpulse;
bool SetImpulse(const Events::SetImpulse &event);
void RegisterComponents(ComponentFactory* cf) override;
void Initialize() override;
// Called once per system every tick
void Update(double dt) override;
// Called once for every entity in the world every tick
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
// Called when components are committed to an entity
void OnEntityCommit(EntityID entity) override;
// Called when an entity is removed
void OnEntityRemoved(EntityID entity) override;
bool IsPaused() const { return m_Pause; }
void SetPause(const bool& pause) { m_Pause = pause; }
private:
b2Vec2 m_Gravity;
b2World* m_PhysicsWorld;
double m_TimeStep;
double m_Accumulator;
bool m_Pause = false;
dd::EventRelay<PhysicsSystem, dd::Events::Pause> m_EPause;
bool OnPause(const dd::Events::Pause &event);
int m_VelocityIterations, m_PositionIterations;
std::unordered_map<EntityID, b2Body*> m_EntitiesToBodies;
std::unordered_map<b2Body*, EntityID> m_BodiesToEntities;
void CreateBody(EntityID entity);
std::vector<b2ParticleSystem*> m_ParticleSystem;
std::vector<b2ParticleGroup*> t_ParticleGroup;
std::vector<std::unordered_map<EntityID, const b2ParticleHandle*>> m_EntitiesToParticleHandle;
std::vector<std::unordered_map<const b2ParticleHandle*, EntityID>> m_ParticleHandleToEntities;
b2ParticleSystem* CreateParticleSystem(float radius, float gravityScale);
void InitializeWater();
void CreateParticleGroup(EntityID entity);
void CreateParticleEmitter(EntityID entity);
void UpdateParticleEmitters(double dt); //TODO: Remove them and particles if needed.
//TODO: Fill struct with info needed.
struct ParticleEmitter
namespace Systems
{
std::vector<b2ParticleSystem*> ParticleSystem;
std::vector<EntityID> ParticleEmitter;
std::vector<EntityID> ParticleTemplate;
};
ParticleEmitter m_ParticleEmitters;
//TODO: Struct med listor är bättre än en lista med structs
struct Impulse
{
b2Body* Body;
b2Vec2 Impulse;
b2Vec2 Point;
};
std::list<Impulse> m_Impulses;
class ContactListener : public b2ContactListener
{
public:
ContactListener(PhysicsSystem* physicsSystem)
: m_PhysicsSystem(physicsSystem) { }
void BeginContact(b2Contact* contact)
class PhysicsSystem : public System
{
b2WorldManifold worldManifold;
friend class ContractListener;
contact->GetWorldManifold(&worldManifold);
public:
PhysicsSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
: System(world, eventBroker) { }
Events::Contact e;
e.Entity1 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureA()->GetBody()];
e.Entity2 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()];
e.Normal = glm::normalize(glm::vec2(contact->GetManifold()->localNormal.x, contact->GetManifold()->localNormal.y));
e.SignificantNormal = glm::normalize((glm::abs(e.Normal.x) > glm::abs(e.Normal.y)) ? glm::vec2(e.Normal.x, 0) : glm::vec2(0, e.Normal.y));
~PhysicsSystem();
m_PhysicsSystem->EventBroker->Publish(e);
}
void EndContact(b2Contact* contact)
{
void RegisterComponents(ComponentFactory* cf) override;
void Initialize() override;
void Update(double dt) override;
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
void OnEntityCommit(EntityID entity) override;
void OnEntityRemoved(EntityID entity) override;
}
void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
{
EntityID entityA = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureA()->GetBody()];
EntityID entityB = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()];
auto physicsComponentA = m_PhysicsSystem->m_World->GetComponent<Components::Physics>(entityA);
auto physicsComponentB = m_PhysicsSystem->m_World->GetComponent<Components::Physics>(entityB);
if (physicsComponentA != nullptr && physicsComponentB != nullptr) {
if (physicsComponentA->Calculate || physicsComponentB->Calculate) {
// Turn of collisions
contact->SetEnabled(false);
}
}
private:
struct Impulse
{
b2Body* Body;
b2Vec2 Impulse;
b2Vec2 Point;
};
bool m_Pause = false;
}
void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
{
b2Vec2 m_Gravity = b2Vec2(0.f, -9.82f);
b2World* m_PhysicsWorld = nullptr;
float m_TimeStep = 1.f/60.f;
float m_Accumulator = 0.f;
int m_VelocityIterations = 6;
int m_PositionIterations = 2;
}
std::vector<b2ParticleSystem*> m_ParticleSystem;
std::vector<b2ParticleGroup*> t_ParticleGroup;
private:
PhysicsSystem* m_PhysicsSystem;
};
std::vector<std::unordered_map<EntityID, const b2ParticleHandle*>> m_EntitiesToParticleHandle;
std::vector<std::unordered_map<const b2ParticleHandle*, EntityID>> m_ParticleHandleToEntities;
std::unordered_map<EntityID, b2Body*> m_EntitiesToBodies;
std::unordered_map<b2Body*, EntityID> m_BodiesToEntities;
ContactListener* m_ContactListener;
};
}
void CreateBody(EntityID entity);
void SyncEntitiesWithBodies();
void SyncBodiesWithEntities();
void InitializeWater();
void CreateParticleGroup(EntityID entity);
b2ParticleSystem* CreateParticleSystem(float radius, float gravityScale);
void CreateParticleEmitter(EntityID entity);
void UpdateParticleEmitters(double dt); //TODO: Remove them and particles if needed.
EventRelay<PhysicsSystem, Events::SetImpulse> m_SetImpulse;
bool SetImpulse(const Events::SetImpulse &event);
dd::EventRelay<PhysicsSystem, dd::Events::Pause> m_EPause;
bool OnPause(const dd::Events::Pause &event);
//TODO: Fill struct with info needed.
struct ParticleEmitter
{
std::vector<b2ParticleSystem*> ParticleSystem;
std::vector<EntityID> ParticleEmitter;
std::vector<EntityID> ParticleTemplate;
};
ParticleEmitter m_ParticleEmitters;
std::list<Impulse> m_Impulses;
class ContactListener : public b2ContactListener
{
public:
ContactListener(PhysicsSystem* physicsSystem)
: m_PhysicsSystem(physicsSystem) { }
void BeginContact(b2Contact* contact);
void EndContact(b2Contact* contact);
void PreSolve(b2Contact* contact, const b2Manifold* oldManifold);
void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse);
private:
PhysicsSystem* m_PhysicsSystem;
};
ContactListener* m_ContactListener;
};
}
}
#endif //DAYDREAM_PHYSICSSYSTEM_H
#endif
+11 -7
View File
@@ -30,11 +30,12 @@ void dd::Systems::BallSystem::Initialize()
auto model = m_World->AddComponent<Components::Model>(ent);
model->ModelFile = "Models/Test/Ball/Ballopus.obj";
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
circleShape->Radius = 0.5f;
std::shared_ptr<Components::Ball> ball = m_World->AddComponent<Components::Ball>(ent);
ball->Speed = 5.f;
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
std::shared_ptr<Components::Template> ballTemplate = m_World->AddComponent<Components::Template>(ent);
physics->Static = false;
physics->CollisionType = CollisionType::Type::Dynamic;
physics->Category = CollisionLayer::Type::Ball;
physics->Mask = CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall;
physics->Calculate = true;
@@ -71,6 +72,8 @@ void dd::Systems::BallSystem::Update(double dt)
void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
{
//TODO: When the ball collides with 2 bricks on the same frame it is reflected and then reflected again, make it reflect only once like a list or something?
auto ballComponent = m_World->GetComponent<Components::Ball>(entity);
if (IsPaused()) {
if (ballComponent != nullptr) {
@@ -127,7 +130,8 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
EventBroker->Publish(e);
return;
}
} else if (transformBall->Position.x > EdgeX()) {
} //Removing this made the wall collisions work again
/*else if (transformBall->Position.x > EdgeX()) {
if (transformBall->Velocity.x > 0) {
glm::vec2 reflectedVelocity = glm::reflect(glm::vec2(transformBall->Velocity.x, transformBall->Velocity.y), glm::vec2(1, 0));
transformBall->Velocity = glm::vec3(reflectedVelocity, 0.f);
@@ -142,7 +146,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
glm::vec2 reflectedVelocity = glm::reflect(glm::vec2(transformBall->Velocity.x, transformBall->Velocity.y), glm::vec2(0, 1));
transformBall->Velocity = glm::vec3(reflectedVelocity, 0.f);
}
}
}*/
}
if (Lives() != PastLives()) {
@@ -249,10 +253,10 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
if (m_World->GetProperty<std::string>(otherEntitiy, "Name") == "Pad"){
Events::HitPad e;
EventBroker->Publish(e);
Events::HitLag el;
el.Time = 0.1f;
el.Type = "All";
EventBroker->Publish(el);
// Events::HitLag el;
// el.Time = 0.1f;
//el.Type = "All";
// EventBroker->Publish(el);
auto padTransform = m_World->GetComponent<Components::Transform>(otherEntitiy);
float x = (ballTransform->Position.x - padTransform->Position.x) * XMovementMultiplier();
+8 -29
View File
@@ -24,19 +24,15 @@ void dd::Systems::LevelSystem::Initialize()
auto model = m_World->AddComponent<Components::Model>(m_BrickTemplate);
std::shared_ptr<Components::Brick> cBrick = m_World->AddComponent<Components::Brick>(m_BrickTemplate);
std::shared_ptr<Components::RectangleShape> cRec = m_World->AddComponent<Components::RectangleShape>(m_BrickTemplate);
cRec->Dimensions = glm::vec2(0.9f, 0.35f);
std::shared_ptr<Components::Physics> cPhys = m_World->AddComponent<Components::Physics>(m_BrickTemplate);
std::shared_ptr<Components::Template> cTemplate = m_World->AddComponent<Components::Template>(m_BrickTemplate);
cPhys->Static = false;
cPhys->CollisionType = CollisionType::Type::Dynamic;
cPhys->GravityScale = 0.f;
cPhys->Category = CollisionLayer::Type::Brick;
cPhys->Mask = CollisionLayer::Type::Ball;
model->ModelFile = "Models/Test/Brick/Brick.obj";
/*if ((line == 1 && row == 4) || (line == 3 && row == 2) || (line == 5 && row == 2)) {
std::shared_ptr<Components::PowerUpBrick> cPow = m_World->AddComponent<Components::PowerUpBrick>(brick);
}*/
transform->Scale = glm::vec3(0.8, 0.2, 0.2);
model->ModelFile = "Models/Brick/TurquoiseBrick.obj";
transform->Position = glm::vec3(50, 50, -10);
//sound
@@ -173,30 +169,13 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
auto cBrick = m_World->GetComponent<Components::Brick>(brick);
auto cPhys = m_World->GetComponent<Components::Physics>(brick);
/*auto brick = m_World->CreateEntity();
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(brick);
auto model = m_World->AddComponent<Components::Model>(brick);
std::shared_ptr<Components::Brick> cBrick = m_World->AddComponent<Components::Brick>(brick);
std::shared_ptr<Components::RectangleShape> cRec = m_World->AddComponent<Components::RectangleShape>(brick);
std::shared_ptr<Components::Physics> cPhys = m_World->AddComponent<Components::Physics>(brick);*/
//std::shared_ptr<Components::Template> cTemplate = m_World->AddComponent<Components::Template>(brick);
cPhys->Static = false;
cPhys->GravityScale = 0.f;
cPhys->Category = CollisionLayer::Type::Brick;
cPhys->Mask = CollisionLayer::Type::Ball;
//model->ModelFile = "Models/Test/Brick/Brick.obj";
/*if ((line == 1 && row == 4) || (line == 3 && row == 2) || (line == 5 && row == 2)) {
if (typeInt == 2) {
std::shared_ptr<Components::PowerUpBrick> cPow = m_World->AddComponent<Components::PowerUpBrick>(brick);
}*/
//transform->Scale = glm::vec3(0.8, 0.2, 0.2);
/*if (typeInt == 2) {
std::shared_ptr<Components::PowerUpBrick> cPow = m_World->AddComponent<Components::PowerUpBrick>(brick);
}*/
auto model = m_World->GetComponent<Components::Model>(brick);
model->ModelFile = "Models/Brick/IceBrick.obj";
}
float x = line * spacesBetweenBricks.x;
float y = row * spacesBetweenBricks.y;
transform->Scale = glm::vec3(0.8, 0.2, 0.2);
transform->Position = glm::vec3(x - 3, 5 - spaceToEdge - y , -10.f);
cBrick->Score = 10 * num;
@@ -320,7 +299,7 @@ bool dd::Systems::LevelSystem::OnCreatePowerUp(const dd::Events::CreatePowerUp &
auto model = m_World->AddComponent<Components::Model>(powerUp);
std::shared_ptr<Components::CircleShape> cRec = m_World->AddComponent<Components::CircleShape>(powerUp);
std::shared_ptr<Components::Physics> cPhys = m_World->AddComponent<Components::Physics>(powerUp);
cPhys->Static = false;
cPhys->CollisionType = CollisionType::Type::Dynamic;
cPhys->Category = CollisionLayer::Type::PowerUp;
cPhys->Mask = CollisionLayer::Type::Pad;
+3 -3
View File
@@ -34,10 +34,10 @@ void dd::Systems::PadSystem::Initialize()
m_World->SetProperty(ent, "Name", "Pad");
auto ctransform = m_World->AddComponent<Components::Transform>(ent);
ctransform->Position = glm::vec3(0.f, -3.5f, -10.f);
ctransform->Scale = glm::vec3(1.0f, 1.0f, 1.f);
auto rectangle = m_World->AddComponent<Components::RectangleShape>(ent);
auto rectangleShape = m_World->AddComponent<Components::RectangleShape>(ent);
rectangleShape->Dimensions = glm::vec2(1.f, 0.5f);
auto physics = m_World->AddComponent<Components::Physics>(ent);
physics->Static = false;
physics->CollisionType = CollisionType::Type::Dynamic;
physics->Category = CollisionLayer::Type::Pad;
physics->Mask = CollisionLayer::Type::Ball | CollisionLayer::Type::PowerUp;
physics->Calculate = true;
+47
View File
@@ -0,0 +1,47 @@
#include "PrecompiledHeader.h"
#include "Physics/PhysicsSystem.h"
void dd::Systems::PhysicsSystem::ContactListener::BeginContact(b2Contact* contact)
{
b2WorldManifold worldManifold;
contact->GetWorldManifold(&worldManifold);
Events::Contact e;
e.Entity1 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureA()->GetBody()];
e.Entity2 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()];
e.Normal = glm::normalize(glm::vec2(contact->GetManifold()->localNormal.x, contact->GetManifold()->localNormal.y));
e.SignificantNormal = glm::normalize((glm::abs(e.Normal.x) > glm::abs(e.Normal.y)) ? glm::vec2(e.Normal.x, 0) : glm::vec2(0, e.Normal.y));
m_PhysicsSystem->EventBroker->Publish(e);
}
void dd::Systems::PhysicsSystem::ContactListener::EndContact(b2Contact* contact)
{
}
void dd::Systems::PhysicsSystem::ContactListener::PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
{
EntityID entityA = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureA()->GetBody()];
EntityID entityB = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()];
auto physicsComponentA = m_PhysicsSystem->m_World->GetComponent<Components::Physics>(entityA);
auto physicsComponentB = m_PhysicsSystem->m_World->GetComponent<Components::Physics>(entityB);
if (physicsComponentA != nullptr && physicsComponentB != nullptr) {
if (physicsComponentA->Calculate || physicsComponentB->Calculate) {
// Turn of collisions
contact->SetEnabled(false);
}
}
}
void dd::Systems::PhysicsSystem::ContactListener::PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
{
}
+164 -133
View File
@@ -2,29 +2,19 @@
#include "Physics/PhysicsSystem.h"
void dd::Systems::PhysicsSystem::RegisterComponents(ComponentFactory* cf)
{
cf->Register<Components::CircleShape>();
//TODO: REGISTER PHYSICS COMPONENTS HERE
}
void dd::Systems::PhysicsSystem::Initialize()
{
m_ContactListener = new ContactListener(this);
m_Gravity = b2Vec2(0.f, -9.82f);
m_PhysicsWorld = new b2World(m_Gravity);
m_TimeStep = 1.0/60.0;
m_VelocityIterations = 6;
m_PositionIterations = 2;
m_Accumulator = 0.0;
m_PhysicsWorld->SetContactListener(m_ContactListener);
InitializeWater();
EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, &PhysicsSystem::SetImpulse);
EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, PhysicsSystem::SetImpulse);
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PhysicsSystem::OnPause);
}
@@ -37,7 +27,11 @@ void dd::Systems::PhysicsSystem::InitializeWater()
bool dd::Systems::PhysicsSystem::SetImpulse(const Events::SetImpulse &event)
{
b2Body* body = m_EntitiesToBodies[event.Entity];
auto it = m_EntitiesToBodies.find(event.Entity);
if(it == m_EntitiesToBodies.end()) {
LOG_ERROR("Entity: %i, Tried to set an impulse on a body that does not exsist", event.Entity);
return false;
}
b2Vec2 impulse;
impulse.x = event.Impulse.x;
@@ -47,112 +41,134 @@ bool dd::Systems::PhysicsSystem::SetImpulse(const Events::SetImpulse &event)
point.x = event.Point.x;
point.y = event.Point.y;
Impulse i;
i.Body = body;
i.Body = it->second;
i.Impulse = impulse;
i.Point = point;
m_Impulses.push_back(i);
return true;
}
void dd::Systems::PhysicsSystem::Update(double dt) {
if (IsPaused()) {
void dd::Systems::PhysicsSystem::SyncEntitiesWithBodies()
{
for (auto i : m_EntitiesToBodies) {
EntityID entity = i.first;
b2Body* body = i.second;
if (body == nullptr) {
LOG_ERROR("This body should not exist, please fix this");
continue;
}
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
if (! transformComponent) {
continue;
LOG_ERROR("RigidBody with no TransformComponent");
}
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
if (! physicsComponent) {
continue;
LOG_ERROR("RigidBody with no PhysicsComponent");
}
if (m_World->GetEntityParent(entity) == 0) { //TODO: Make this work with childs too
b2Vec2 position;
position.x = transformComponent->Position.x;
position.y = transformComponent->Position.y;
float angle = glm::eulerAngles(transformComponent->Orientation).z;
body->SetTransform(position, angle);
body->SetLinearVelocity(b2Vec2(transformComponent->Velocity.x, transformComponent->Velocity.y));
body->SetGravityScale(physicsComponent->GravityScale);
b2Filter filter;
filter.categoryBits = physicsComponent->Category;
filter.maskBits = physicsComponent->Mask;
body->GetFixtureList()->SetFilterData(filter);
}
}
}
void dd::Systems::PhysicsSystem::SyncBodiesWithEntities()
{
for (auto i : m_BodiesToEntities) {
b2Body* body = i.first;
EntityID entity = i.second;
if (body == nullptr) {
LOG_ERROR("This body should not exist, please fix this");
continue;
}
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
if (! transformComponent) {
continue;
LOG_ERROR("RigidBody with no TransformComponent");
}
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
if (! physicsComponent) {
continue;
LOG_ERROR("RigidBody with no PhysicsComponent");
}
auto parent = m_World->GetEntityParent(entity);
if (parent == 0) {
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
if (physicsComponent->Calculate) { //TODO: REPLACE THIS WITH PARTICLE COLLISION FILTERS
transformComponent->Position.x = transformComponent->Position.x + (transformComponent->Velocity.x * m_TimeStep);
transformComponent->Position.y = transformComponent->Position.y + (transformComponent->Velocity.y * m_TimeStep);
} else {
b2Vec2 position = body->GetPosition();
transformComponent->Position.x = position.x;
transformComponent->Position.y = position.y;
float angle = body->GetAngle();
transformComponent->Orientation = glm::quat(glm::vec3(0, 0, angle));
b2Vec2 velocity = body->GetLinearVelocity();
transformComponent->Velocity.x = velocity.x;
transformComponent->Velocity.y = velocity.y;
}
}
}
}
void dd::Systems::PhysicsSystem::Update(double dt)
{
if (m_Pause) {
return;
}
m_Accumulator += dt;
while (m_Accumulator >= m_TimeStep) {
for (auto i : m_EntitiesToBodies) {
EntityID entity = i.first;
b2Body *body = i.second;
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
if (!transformComponent) {
continue;
LOG_ERROR("RigidBody with no TransformComponent");
}
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
if (!physicsComponent) {
continue;
LOG_ERROR("RigidBody with no PhysicsComponent");
}
if (body == nullptr) {
LOG_ERROR("This body should not exist");
continue;
}
if (m_World->GetEntityParent(entity) == 0) { //TODO: Make this work with childs too
b2Vec2 position;
position.x = transformComponent->Position.x;
position.y = transformComponent->Position.y;
float angle = glm::eulerAngles(transformComponent->Orientation).z;
body->SetTransform(position, angle);
body->SetLinearVelocity(b2Vec2(transformComponent->Velocity.x, transformComponent->Velocity.y));
body->SetGravityScale(physicsComponent->GravityScale);
b2Filter filter;
filter.categoryBits = physicsComponent->Category;
filter.maskBits = physicsComponent->Mask;
body->GetFixtureList()->SetFilterData(filter);
}
}
while(m_Accumulator >= m_TimeStep)
{
UpdateParticleEmitters(dt);
SyncEntitiesWithBodies();
//Apply Impulses Must be done after SyncEntitiesWithBodies
for (auto i : m_Impulses) {
i.Body->ApplyLinearImpulse(i.Impulse, i.Point, true);
}
m_Impulses.clear();
//Update the PhysicsWorld
m_PhysicsWorld->Step(m_TimeStep, m_VelocityIterations, m_PositionIterations);
SyncBodiesWithEntities();
for (auto i : m_EntitiesToBodies) {
EntityID entity = i.first;
b2Body *body = i.second;
if (body == nullptr) {
LOG_ERROR("This body should not exist");
continue;
}
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
if (!transformComponent)
continue;
auto parent = m_World->GetEntityParent(entity);
if (parent == 0) {
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
if (physicsComponent->Calculate) { //TODO: REPLACE THIS WITH PARTICLE COLLISION FILTERS
transformComponent->Position.x =
transformComponent->Position.x + (transformComponent->Velocity.x * m_TimeStep);
transformComponent->Position.y =
transformComponent->Position.y + (transformComponent->Velocity.y * m_TimeStep);
}
else {
b2Vec2 position = body->GetPosition();
transformComponent->Position.x = position.x;
transformComponent->Position.y = position.y;
float angle = body->GetAngle();
transformComponent->Orientation = glm::quat(glm::vec3(0, 0, angle));
b2Vec2 velocity = body->GetLinearVelocity();
transformComponent->Velocity.x = velocity.x;
transformComponent->Velocity.y = velocity.y;
}
}
}
for ( int e = 0; e < m_EntitiesToParticleHandle.size(); e++) {
b2Vec2 *positionBuffer = m_ParticleSystem[e]->GetPositionBuffer();
for (auto i : m_EntitiesToParticleHandle[e]){
for (auto i : m_EntitiesToParticleHandle[e]) {
EntityID entity = i.first;
b2ParticleHandle *particleH = i.second;
@@ -161,7 +177,7 @@ void dd::Systems::PhysicsSystem::Update(double dt) {
EntityID entityParent = m_World->GetEntityParent(entity);
glm::vec3 parentTransform = glm::vec3(0.f);
if(entityParent) {
if (entityParent) {
auto tp = m_World->GetComponent<Components::Transform>(entityParent);
parentTransform = tp->Position;
}
@@ -176,7 +192,6 @@ void dd::Systems::PhysicsSystem::Update(double dt) {
}
}
void dd::Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
{
@@ -188,10 +203,10 @@ bool dd::Systems::PhysicsSystem::OnPause(const dd::Events::Pause &event)
return false;
}
if (IsPaused()) {
SetPause(false);
if (m_Pause) {
m_Pause = false;
} else {
SetPause(true);
m_Pause = true;
}
return true;
}
@@ -215,6 +230,8 @@ void dd::Systems::PhysicsSystem::OnEntityCommit(EntityID entity)
auto it = m_EntitiesToBodies.find(entity);
if(it == m_EntitiesToBodies.end()) {
CreateBody(entity);
} else {
LOG_ERROR("Tried to commit a body that already exists");
}
} else if (waterComponent) {
CreateParticleGroup(entity);
@@ -226,22 +243,25 @@ void dd::Systems::PhysicsSystem::OnEntityCommit(EntityID entity)
void dd::Systems::PhysicsSystem::OnEntityRemoved(EntityID entity)
{
auto physics = m_World->GetComponent<Components::Physics>(entity);
/* auto physics = m_World->GetComponent<Components::Physics>(entity);
if (physics == nullptr) {
return;
}*/
auto it = m_EntitiesToBodies.find(entity);
if(it == m_EntitiesToBodies.end()) {
LOG_ERROR("Trying to remove non-exsisting body, Entity: %i", entity);
return;
}
b2Body* body = m_EntitiesToBodies[entity];
if (body != nullptr) {
m_EntitiesToBodies.erase(entity);
m_BodiesToEntities.erase(body);
m_PhysicsWorld->DestroyBody(body);
}
LOG_INFO("Removing entity %i", entity);
it->second->GetWorld()->DestroyBody(it->second);
m_BodiesToEntities.erase(it->second);
m_EntitiesToBodies.erase(entity);
//delete body;
}
void dd::Systems::PhysicsSystem::CreateBody(EntityID entity)
{
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
@@ -250,7 +270,6 @@ void dd::Systems::PhysicsSystem::CreateBody(EntityID entity)
return;
}
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
if(!transformComponent) {
LOG_ERROR("No TransformComponent in CreateBody");
@@ -263,34 +282,28 @@ void dd::Systems::PhysicsSystem::CreateBody(EntityID entity)
bodyDef.position.Set(absoluteTransform.Position.x, absoluteTransform.Position.y);
bodyDef.angle = -glm::eulerAngles(absoluteTransform.Orientation).z;
if (physicsComponent->Static) {
if (physicsComponent->CollisionType == CollisionType::Type::Static) {
bodyDef.type = b2_staticBody;
} else {
} else if (physicsComponent->CollisionType == CollisionType::Type::Dynamic) {
bodyDef.type = b2_dynamicBody;
} else if (physicsComponent->CollisionType == CollisionType::Type::Kinematic) {
bodyDef.type = b2_dynamicBody;
}
b2Body* body = m_PhysicsWorld->CreateBody(&bodyDef);
b2Shape* pShape;
auto boxComponent = m_World->GetComponent<Components::RectangleShape>(entity);
if (boxComponent) {
auto rectangleComponent = m_World->GetComponent<Components::RectangleShape>(entity);
if (rectangleComponent) {
b2PolygonShape* bShape = new b2PolygonShape();
bShape->SetAsBox(absoluteTransform.Scale.x/2, absoluteTransform.Scale.y/2);
bShape->SetAsBox(rectangleComponent->Dimensions.x/2.f, rectangleComponent->Dimensions.y/2.f);
pShape = bShape;
} else {
auto circleComponent = m_World->GetComponent<Components::CircleShape>(entity);
if (circleComponent) {
pShape = new b2CircleShape();
pShape->m_radius = absoluteTransform.Scale.x;
if (absoluteTransform.Scale.x != absoluteTransform.Scale.y && absoluteTransform.Scale.y != absoluteTransform.Scale.z) {
LOG_WARNING("Circles has to be of uniform scale.");
}
pShape->m_radius = absoluteTransform.Scale.x/2;
pShape->m_radius = circleComponent->Radius;
}
}
@@ -300,26 +313,26 @@ void dd::Systems::PhysicsSystem::CreateBody(EntityID entity)
fixtureDef.filter.maskBits = physicsComponent->Mask;
if(physicsComponent->Static) {
body->CreateFixture(&fixtureDef); //Density kanske ska vara 0 p statiska kroppar
}
else {
fixtureDef.shape = pShape;
fixtureDef.density = 10.f;
fixtureDef.restitution = 1.0f;
fixtureDef.friction = 0.0f;
body->CreateFixture(&fixtureDef);
}
fixtureDef.shape = pShape;
fixtureDef.density = 10.f;
fixtureDef.restitution = 1.0f;
fixtureDef.friction = 0.0f;
body->CreateFixture(&fixtureDef);
delete pShape;
/* if(physicsComponent->Static) {
body->SetType(b2BodyType::b2_staticBody);
} else if (! physicsComponent->Static) {
body->SetType(b2BodyType::b2_dynamicBody);
}*/
body->SetGravityScale(physicsComponent->GravityScale);
m_EntitiesToBodies.insert(std::make_pair(entity, body));
m_BodiesToEntities.insert(std::make_pair(body, entity));
}
void dd::Systems::PhysicsSystem::CreateParticleGroup(EntityID e)
{
auto transform = m_World->GetComponent<Components::Transform>(e);
@@ -449,10 +462,28 @@ b2ParticleSystem* dd::Systems::PhysicsSystem::CreateParticleSystem(float radius,
return m_ParticleSystem.back();
}
dd::Systems::PhysicsSystem::~PhysicsSystem()
{
for (auto i = m_BodiesToEntities.begin(); i != m_BodiesToEntities.end(); i++) {
b2Body* body = i->first;
body->GetWorld()->DestroyBody(body);
//delete body;
}
m_BodiesToEntities.clear();
m_EntitiesToBodies.clear();
m_Impulses.clear();
//TODO:REMOVE PARTICLE SYSTEMS
if (m_ContactListener != nullptr) {
delete m_ContactListener;
m_ContactListener = nullptr;
}
if (m_PhysicsWorld != nullptr) {
delete m_PhysicsWorld;
m_PhysicsWorld = nullptr;
}
}
-183
View File
@@ -1,183 +0,0 @@
#include "PrecompiledHeader.h"
#include "Sound/SoundSystem.h"
dd::Systems::SoundSystem::~SoundSystem()
{
alcCloseDevice(m_Device);
};
void dd::Systems::SoundSystem::Initialize()
{
//initialize OpenAL
m_Device = alcOpenDevice(NULL);
ALCcontext* context;
if (m_Device) {
context = alcCreateContext(m_Device, NULL);
alcMakeContextCurrent(context);
}
else {
LOG_ERROR("OpenAL failed to initialize.");
}
alGetError();
//Subscribe to events
EVENT_SUBSCRIBE_MEMBER(m_EContact, &SoundSystem::OnContact);
EVENT_SUBSCRIBE_MEMBER(m_EPlaySFX, &SoundSystem::OnPlaySound);
EVENT_SUBSCRIBE_MEMBER(m_EStopSound, &SoundSystem::OnStopSound);
EVENT_SUBSCRIBE_MEMBER(m_EMasterVolume, &SoundSystem::OnMasterVolume);
<<<<<<< HEAD
//Todo: Move this
{
dd::Events::PlaySound e;
e.FilePath = "Sounds/BGM/under-the-sea-instrumental.wav";
e.IsAmbient = true;
EventBroker->Publish(e);
}
{
dd::Events::PlaySound e;
e.FilePath = "Sounds/BGM/water-flowing.wav";
e.Gain = 0.3f;
e.IsAmbient = true;
EventBroker->Publish(e);
}
=======
>>>>>>> origin/master
}
void dd::Systems::SoundSystem::Update(double dt)
{
//Clean up none-active sources
//Only used for SFX's. BGM's are handled on stop sound.
std::vector<ALuint> deleteList;
for (auto& item : m_SFXSourcesToBuffers) {
ALint sourceState;
alGetSourcei(item.first, AL_SOURCE_STATE, &sourceState);
if (sourceState == AL_STOPPED) {
deleteList.push_back(item.first);
}
}
for (int i = 0; i < deleteList.size(); i++) {
alDeleteSources(1, &deleteList[i]);
//alDeleteBuffers(1, &m_SourcesToBuffers[deleteList[i]]);
m_SFXSourcesToBuffers.erase(deleteList[i]);
}
}
ALuint dd::Systems::SoundSystem::CreateSource()
{
ALuint source;
alGenSources((ALuint)1, &source);
return source;
}
bool dd::Systems::SoundSystem::OnPlaySound(const dd::Events::PlaySound &event)
{
//Loading and binding sound buffer to source
Sound *sound = ResourceManager::Load<Sound>(event.FilePath);
if (sound == nullptr) {
return false;
}
ALuint source = CreateSource();
ALuint buffer = sound->Buffer();
alSourcei(source, AL_BUFFER, buffer);
//Sound settings
float relativeVolume = 1.f;
if (event.IsAmbient) {
alSourcei(source, AL_LOOPING, AL_TRUE);
relativeVolume = m_BGMMasterVolume;
m_BGMSourcesToBuffers[source] = sound;
}
else if (!event.IsAmbient)
{
m_SFXSourcesToBuffers[source] = sound;
alSourcei(source, AL_LOOPING, AL_FALSE);
relativeVolume = m_SFXMasterVolume;
}
alSourcef(source, AL_GAIN, (event.Gain * relativeVolume));
alSourcef(source, AL_PITCH, event.Pitch);
//Play
alSourcePlay(source);
return true;
}
bool dd::Systems::SoundSystem::OnStopSound(const dd::Events::StopSound &event)
{
ALuint itemToDeleted;
for (auto& item : m_BGMSourcesToBuffers)
{
if (item.second->Path() == event.FilePath) {
itemToDeleted = item.first;
break;
}
}
alSourceStop(itemToDeleted);
alDeleteSources(1, &itemToDeleted);
m_BGMSourcesToBuffers.erase(itemToDeleted);
//Should not happen because SFX's should be very short.
for (auto item : m_SFXSourcesToBuffers)
{
if (item.second->Path() == event.FilePath) {
alSourceStop(item.first);
return true;
}
}
return false;
}
bool dd::Systems::SoundSystem::OnMasterVolume(const dd::Events::MasterVolume &event)
{
//TODO: Make the Gain depend on the value given when stored.
//TODO: .. now it ONLY uses the master Gain
if (event.IsAmbient) {
m_BGMMasterVolume = event.Gain;
for (auto& item : m_BGMSourcesToBuffers)
{
alSourcef(item.first, AL_GAIN, event.Gain);
}
return true;
}
else if (!event.IsAmbient) {
m_SFXMasterVolume = event.Gain;
for (auto& item : m_SFXSourcesToBuffers)
{
alSourcef(item.first, AL_GAIN, event.Gain);
}
return true;
}
return false;
}
bool dd::Systems::SoundSystem::OnContact(const dd::Events::Contact &event)
{
//Check which entity has the collisionSound component.
auto collisionSound = m_World->GetComponent<Components::CollisionSound>(event.Entity1);
if (collisionSound == nullptr) {
collisionSound = m_World->GetComponent<Components::CollisionSound>(event.Entity2);
if (collisionSound == nullptr) {
//None of the entities had a collisionSound component.
return false;
}
}
//Send play-sound event
dd::Events::PlaySound e;
e.FilePath = collisionSound->FilePath;
e.IsAmbient = false;
EventBroker->Publish(e);
return true;
}
+51
View File
@@ -0,0 +1,51 @@
#include "PrecompiledHeader.h"
#include <boost/test/unit_test.hpp>
#include "Core/World.h"
#include "Core/EventBroker.h"
#include "Physics/PhysicsSystem.h"
#include "Transform/TransformSystem.h"
#include "Physics/CPhysics.h"
#include "Physics/CRectangleShape.h"
using namespace dd;
BOOST_AUTO_TEST_CASE(RemovePhysicsSystemTest)
{
// Setup world
std::shared_ptr<EventBroker> eventBroker = std::make_shared<EventBroker>();
World world(eventBroker);
world.SystemFactory.Register<Systems::TransformSystem>(
[this]() { return new Systems::TransformSystem(&world, eventBroker); });
world.AddSystem<Systems::TransformSystem>();
world.SystemFactory.Register<Systems::PhysicsSystem>(
[this]() { return new Systems::PhysicsSystem(&world, eventBroker); });
world.AddSystem<Systems::PhysicsSystem>();
world.ComponentFactory.Register<Components::RectangleShape>();
world.ComponentFactory.Register<Components::Physics>();
//Create entity
EntityID ent = world.CreateEntity();
auto transform = world.AddComponent<Components::Transform>(ent);
transform->Position = glm::vec3(20.f, 0.f, -10.f);
transform->Velocity = glm::vec3(1.f, 3.f, 0.f);
transform->Scale = glm::vec3(2.f, 5.f, 1.f);
auto physics = world.AddComponent<Components::Physics>(ent);
physics->Static = false;
physics->Calculate = true;
physics->Category = CollisionLayer::Type::Ball;
physics->Mask = CollisionLayer::Type::Brick | CollisionLayer::Type::Pad | CollisionLayer::Wall;
physics->GravityScale = 0.f;
auto rectangle = world.AddComponent<Components::RectangleShape>(ent);
}