BlueGit

timfa frameworkv3

optimize collider & fix sort of pendingRemoval array

timfa wsadhelios · pushed by timfa

Authored 2022-10-21 · 4 years ago

Hash
723e2a0ca3ae657a032e51085b8ba48364d79398
Parent
22c3ddfc
2 files changed +3 −5
framework/engine/objectComponents/collider.js +2 −4
@@ -110,11 +110,9 @@ class Collider
110 110 this.gameObject.transform.position.y + hh
111 111 ];
112 112
113 if (points[0] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw ||
114 points[1] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw)
113 if (points[1] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw)
115 114 {
116 if (points[2] > o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh ||
117 points[3] >= o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh)
115 if (points[3] >= o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh)
118 116 {
119 117 hit = true;
120 118 }
@@ -110,11 +110,9 @@ class Collider
110 this.gameObject.transform.position.y + hh
110 this.gameObject.transform.position.y + hh
111 ];
111 ];
112
112
113 if (points[0] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw ||
113 if (points[1] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw)
114 points[1] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw)
115 {
114 {
116 if (points[2] > o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh ||
115 if (points[3] >= o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh)
117 points[3] >= o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh)
118 {
116 {
119 hit = true;
117 hit = true;
120 }
118 }
framework/engine/scene.js +1 −1
@@ -125,7 +125,7 @@ class Scene
125 125
126 126 if (this.pendingRemoval.length)
127 127 {
128 this.pendingRemoval.sort();
128 this.pendingRemoval.sort((a, b) => a - b);
129 129
130 130 for (let i = this.pendingRemoval.length - 1; i >= 0; i--)
131 131 {
@@ -125,7 +125,7 @@ class Scene
125
125
126 if (this.pendingRemoval.length)
126 if (this.pendingRemoval.length)
127 {
127 {
128 this.pendingRemoval.sort();
128 this.pendingRemoval.sort((a, b) => a - b);
129
129
130 for (let i = this.pendingRemoval.length - 1; i >= 0; i--)
130 for (let i = this.pendingRemoval.length - 1; i >= 0; i--)
131 {
131 {