@galacean/engine-physics-lite 1.3.9 → 1.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -706,52 +706,6 @@ var /**
706
706
  return LitePhysicsMaterial;
707
707
  }();
708
708
 
709
- /**
710
- * High-performance unordered array, delete uses exchange method to improve performance, internal capacity only increases.
711
- */ var DisorderedArray = /*#__PURE__*/ function() {
712
- function DisorderedArray(count) {
713
- if (count === void 0) count = 0;
714
- this.length = 0;
715
- this._elements = new Array(count);
716
- }
717
- var _proto = DisorderedArray.prototype;
718
- _proto.add = function add(element) {
719
- if (this.length === this._elements.length) this._elements.push(element);
720
- else this._elements[this.length] = element;
721
- this.length++;
722
- };
723
- _proto.delete = function _delete(element) {
724
- //TODO: It can be optimized for custom binary search and other algorithms, currently this._elements>=this.length wastes performance.
725
- var index = this._elements.indexOf(element);
726
- this.deleteByIndex(index);
727
- };
728
- _proto.get = function get(index) {
729
- if (index >= this.length) {
730
- throw "Index is out of range.";
731
- }
732
- return this._elements[index];
733
- };
734
- /**
735
- *
736
- * @param index
737
- * @returns The replaced item is used to reset its index.
738
- */ _proto.deleteByIndex = function deleteByIndex(index) {
739
- var elements = this._elements;
740
- var end = null;
741
- var lastIndex = this.length - 1;
742
- if (index !== lastIndex) {
743
- end = elements[lastIndex];
744
- elements[index] = end;
745
- }
746
- this.length--;
747
- return end;
748
- };
749
- _proto.garbageCollection = function garbageCollection() {
750
- this._elements.length = this.length;
751
- };
752
- return DisorderedArray;
753
- }();
754
-
755
709
  /**
756
710
  * Structure used to get information back from a raycast or a sweep.
757
711
  * @internal
@@ -889,7 +843,7 @@ var /**
889
843
  this._dynamicColliders = [];
890
844
  this._sphere = new miniprogram.BoundingSphere();
891
845
  this._box = new miniprogram.BoundingBox();
892
- this._currentEvents = new DisorderedArray();
846
+ this._currentEvents = new miniprogram.DisorderedArray();
893
847
  this._eventMap = {};
894
848
  this._eventPool = [];
895
849
  this._onContactEnter = onContactEnter;
@@ -915,8 +869,7 @@ var /**
915
869
  */ _proto.removeColliderShape = function removeColliderShape(colliderShape) {
916
870
  var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents, eventMap = _this._eventMap;
917
871
  var id = colliderShape._id;
918
- for(var i = currentEvents.length - 1; i >= 0; i--){
919
- var event = currentEvents.get(i);
872
+ currentEvents.forEach(function(event, i) {
920
873
  if (event.index1 == id) {
921
874
  currentEvents.deleteByIndex(i);
922
875
  eventPool.push(event);
@@ -926,7 +879,7 @@ var /**
926
879
  // If the shape is big index, should clear from the small index shape subMap
927
880
  eventMap[event.index1][id] = undefined;
928
881
  }
929
- }
882
+ });
930
883
  delete eventMap[id];
931
884
  };
932
885
  /**
@@ -1063,25 +1016,25 @@ var /**
1063
1016
  }
1064
1017
  };
1065
1018
  _proto._fireEvent = function _fireEvent() {
1066
- var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents;
1067
- for(var i = currentEvents.length - 1; i >= 0; i--){
1068
- var event = currentEvents.get(i);
1019
+ var _this = this;
1020
+ var _this1 = this, eventPool = _this1._eventPool, currentEvents = _this1._currentEvents;
1021
+ currentEvents.forEach(function(event, i) {
1069
1022
  if (!event.alreadyInvoked) {
1070
1023
  if (event.state == 0) {
1071
- this._onTriggerEnter(event.index1, event.index2);
1024
+ _this._onTriggerEnter(event.index1, event.index2);
1072
1025
  event.alreadyInvoked = true;
1073
1026
  } else if (event.state == 1) {
1074
- this._onTriggerStay(event.index1, event.index2);
1027
+ _this._onTriggerStay(event.index1, event.index2);
1075
1028
  event.alreadyInvoked = true;
1076
1029
  }
1077
1030
  } else {
1078
1031
  event.state = 2;
1079
- this._eventMap[event.index1][event.index2] = undefined;
1080
- this._onTriggerExit(event.index1, event.index2);
1032
+ _this._eventMap[event.index1][event.index2] = undefined;
1081
1033
  currentEvents.deleteByIndex(i);
1034
+ _this._onTriggerExit(event.index1, event.index2);
1082
1035
  eventPool.push(event);
1083
1036
  }
1084
- }
1037
+ });
1085
1038
  };
1086
1039
  _proto._boxCollision = function _boxCollision(other) {
1087
1040
  if (_instanceof(other, LiteBoxColliderShape)) {
@@ -1267,7 +1220,7 @@ var LitePhysics = /*#__PURE__*/ function() {
1267
1220
  }();
1268
1221
 
1269
1222
  //@ts-ignore
1270
- var version = "1.3.9";
1223
+ var version = "1.3.11";
1271
1224
  console.log("Galacean PhysicsLite version: " + version);
1272
1225
 
1273
1226
  exports.LitePhysics = LitePhysics;
package/dist/module.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Utils, Ray, Vector3, Matrix, Quaternion, MathUtil, BoundingBox, BoundingSphere, CollisionUtil } from '@galacean/engine';
1
+ import { Utils, Ray, Vector3, Matrix, Quaternion, MathUtil, BoundingBox, BoundingSphere, DisorderedArray, CollisionUtil } from '@galacean/engine';
2
2
 
3
3
  function _set_prototype_of(o, p) {
4
4
  _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
@@ -702,52 +702,6 @@ var /**
702
702
  return LitePhysicsMaterial;
703
703
  }();
704
704
 
705
- /**
706
- * High-performance unordered array, delete uses exchange method to improve performance, internal capacity only increases.
707
- */ var DisorderedArray = /*#__PURE__*/ function() {
708
- function DisorderedArray(count) {
709
- if (count === void 0) count = 0;
710
- this.length = 0;
711
- this._elements = new Array(count);
712
- }
713
- var _proto = DisorderedArray.prototype;
714
- _proto.add = function add(element) {
715
- if (this.length === this._elements.length) this._elements.push(element);
716
- else this._elements[this.length] = element;
717
- this.length++;
718
- };
719
- _proto.delete = function _delete(element) {
720
- //TODO: It can be optimized for custom binary search and other algorithms, currently this._elements>=this.length wastes performance.
721
- var index = this._elements.indexOf(element);
722
- this.deleteByIndex(index);
723
- };
724
- _proto.get = function get(index) {
725
- if (index >= this.length) {
726
- throw "Index is out of range.";
727
- }
728
- return this._elements[index];
729
- };
730
- /**
731
- *
732
- * @param index
733
- * @returns The replaced item is used to reset its index.
734
- */ _proto.deleteByIndex = function deleteByIndex(index) {
735
- var elements = this._elements;
736
- var end = null;
737
- var lastIndex = this.length - 1;
738
- if (index !== lastIndex) {
739
- end = elements[lastIndex];
740
- elements[index] = end;
741
- }
742
- this.length--;
743
- return end;
744
- };
745
- _proto.garbageCollection = function garbageCollection() {
746
- this._elements.length = this.length;
747
- };
748
- return DisorderedArray;
749
- }();
750
-
751
705
  /**
752
706
  * Structure used to get information back from a raycast or a sweep.
753
707
  * @internal
@@ -911,8 +865,7 @@ var /**
911
865
  */ _proto.removeColliderShape = function removeColliderShape(colliderShape) {
912
866
  var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents, eventMap = _this._eventMap;
913
867
  var id = colliderShape._id;
914
- for(var i = currentEvents.length - 1; i >= 0; i--){
915
- var event = currentEvents.get(i);
868
+ currentEvents.forEach(function(event, i) {
916
869
  if (event.index1 == id) {
917
870
  currentEvents.deleteByIndex(i);
918
871
  eventPool.push(event);
@@ -922,7 +875,7 @@ var /**
922
875
  // If the shape is big index, should clear from the small index shape subMap
923
876
  eventMap[event.index1][id] = undefined;
924
877
  }
925
- }
878
+ });
926
879
  delete eventMap[id];
927
880
  };
928
881
  /**
@@ -1059,25 +1012,25 @@ var /**
1059
1012
  }
1060
1013
  };
1061
1014
  _proto._fireEvent = function _fireEvent() {
1062
- var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents;
1063
- for(var i = currentEvents.length - 1; i >= 0; i--){
1064
- var event = currentEvents.get(i);
1015
+ var _this = this;
1016
+ var _this1 = this, eventPool = _this1._eventPool, currentEvents = _this1._currentEvents;
1017
+ currentEvents.forEach(function(event, i) {
1065
1018
  if (!event.alreadyInvoked) {
1066
1019
  if (event.state == 0) {
1067
- this._onTriggerEnter(event.index1, event.index2);
1020
+ _this._onTriggerEnter(event.index1, event.index2);
1068
1021
  event.alreadyInvoked = true;
1069
1022
  } else if (event.state == 1) {
1070
- this._onTriggerStay(event.index1, event.index2);
1023
+ _this._onTriggerStay(event.index1, event.index2);
1071
1024
  event.alreadyInvoked = true;
1072
1025
  }
1073
1026
  } else {
1074
1027
  event.state = 2;
1075
- this._eventMap[event.index1][event.index2] = undefined;
1076
- this._onTriggerExit(event.index1, event.index2);
1028
+ _this._eventMap[event.index1][event.index2] = undefined;
1077
1029
  currentEvents.deleteByIndex(i);
1030
+ _this._onTriggerExit(event.index1, event.index2);
1078
1031
  eventPool.push(event);
1079
1032
  }
1080
- }
1033
+ });
1081
1034
  };
1082
1035
  _proto._boxCollision = function _boxCollision(other) {
1083
1036
  if (_instanceof(other, LiteBoxColliderShape)) {
@@ -1263,7 +1216,7 @@ var LitePhysics = /*#__PURE__*/ function() {
1263
1216
  }();
1264
1217
 
1265
1218
  //@ts-ignore
1266
- var version = "1.3.9";
1219
+ var version = "1.3.11";
1267
1220
  console.log("Galacean PhysicsLite version: " + version);
1268
1221
 
1269
1222
  export { LitePhysics, version };