@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.
package/dist/main.js CHANGED
@@ -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 engine.BoundingSphere();
891
845
  this._box = new engine.BoundingBox();
892
- this._currentEvents = new DisorderedArray();
846
+ this._currentEvents = new engine.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;