@galacean/engine-core 2.0.0-alpha.18 → 2.0.0-alpha.19
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 +98 -106
- package/dist/main.js.map +1 -1
- package/dist/module.js +98 -106
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/physics/PhysicsScene.d.ts +2 -6
package/dist/main.js
CHANGED
|
@@ -13061,118 +13061,13 @@ __decorate([
|
|
|
13061
13061
|
this._fixedTimeStep = 1 / 60;
|
|
13062
13062
|
this._colliders = new DisorderedArray();
|
|
13063
13063
|
this._gravity = new engineMath.Vector3(0, -9.81, 0);
|
|
13064
|
-
this._onContactEnter = function(nativeCollision) {
|
|
13065
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
13066
|
-
var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
|
|
13067
|
-
var shape1 = physicalObjectsMap[shape0Id];
|
|
13068
|
-
var shape2 = physicalObjectsMap[shape1Id];
|
|
13069
|
-
var collision = PhysicsScene._collision;
|
|
13070
|
-
collision._nativeCollision = nativeCollision;
|
|
13071
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13072
|
-
collision.shape = shape2;
|
|
13073
|
-
element.onCollisionEnter(collision);
|
|
13074
|
-
}, function(element, index) {
|
|
13075
|
-
element._entityScriptsIndex = index;
|
|
13076
|
-
});
|
|
13077
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13078
|
-
collision.shape = shape1;
|
|
13079
|
-
element.onCollisionEnter(collision);
|
|
13080
|
-
}, function(element, index) {
|
|
13081
|
-
element._entityScriptsIndex = index;
|
|
13082
|
-
});
|
|
13083
|
-
};
|
|
13084
|
-
this._onContactExit = function(nativeCollision) {
|
|
13085
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
13086
|
-
var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
|
|
13087
|
-
var shape1 = physicalObjectsMap[shape0Id];
|
|
13088
|
-
var shape2 = physicalObjectsMap[shape1Id];
|
|
13089
|
-
var collision = PhysicsScene._collision;
|
|
13090
|
-
collision._nativeCollision = nativeCollision;
|
|
13091
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13092
|
-
collision.shape = shape2;
|
|
13093
|
-
element.onCollisionExit(collision);
|
|
13094
|
-
}, function(element, index) {
|
|
13095
|
-
element._entityScriptsIndex = index;
|
|
13096
|
-
});
|
|
13097
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13098
|
-
collision.shape = shape1;
|
|
13099
|
-
element.onCollisionExit(collision);
|
|
13100
|
-
}, function(element, index) {
|
|
13101
|
-
element._entityScriptsIndex = index;
|
|
13102
|
-
});
|
|
13103
|
-
};
|
|
13104
|
-
this._onContactStay = function(nativeCollision) {
|
|
13105
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
13106
|
-
var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
|
|
13107
|
-
var shape1 = physicalObjectsMap[shape0Id];
|
|
13108
|
-
var shape2 = physicalObjectsMap[shape1Id];
|
|
13109
|
-
var collision = PhysicsScene._collision;
|
|
13110
|
-
collision._nativeCollision = nativeCollision;
|
|
13111
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13112
|
-
collision.shape = shape2;
|
|
13113
|
-
element.onCollisionStay(collision);
|
|
13114
|
-
}, function(element, index) {
|
|
13115
|
-
element._entityScriptsIndex = index;
|
|
13116
|
-
});
|
|
13117
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13118
|
-
collision.shape = shape1;
|
|
13119
|
-
element.onCollisionStay(collision);
|
|
13120
|
-
}, function(element, index) {
|
|
13121
|
-
element._entityScriptsIndex = index;
|
|
13122
|
-
});
|
|
13123
|
-
};
|
|
13124
|
-
this._onTriggerEnter = function(obj1, obj2) {
|
|
13125
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
13126
|
-
var shape1 = physicalObjectsMap[obj1];
|
|
13127
|
-
var shape2 = physicalObjectsMap[obj2];
|
|
13128
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13129
|
-
element.onTriggerEnter(shape2);
|
|
13130
|
-
}, function(element, index) {
|
|
13131
|
-
element._entityScriptsIndex = index;
|
|
13132
|
-
});
|
|
13133
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13134
|
-
element.onTriggerEnter(shape1);
|
|
13135
|
-
}, function(element, index) {
|
|
13136
|
-
element._entityScriptsIndex = index;
|
|
13137
|
-
});
|
|
13138
|
-
};
|
|
13139
|
-
this._onTriggerExit = function(obj1, obj2) {
|
|
13140
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
13141
|
-
var shape1 = physicalObjectsMap[obj1];
|
|
13142
|
-
var shape2 = physicalObjectsMap[obj2];
|
|
13143
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13144
|
-
element.onTriggerExit(shape2);
|
|
13145
|
-
}, function(element, index) {
|
|
13146
|
-
element._entityScriptsIndex = index;
|
|
13147
|
-
});
|
|
13148
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13149
|
-
element.onTriggerExit(shape1);
|
|
13150
|
-
}, function(element, index) {
|
|
13151
|
-
element._entityScriptsIndex = index;
|
|
13152
|
-
});
|
|
13153
|
-
};
|
|
13154
|
-
this._onTriggerStay = function(obj1, obj2) {
|
|
13155
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
13156
|
-
var shape1 = physicalObjectsMap[obj1];
|
|
13157
|
-
var shape2 = physicalObjectsMap[obj2];
|
|
13158
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13159
|
-
element.onTriggerStay(shape2);
|
|
13160
|
-
}, function(element, index) {
|
|
13161
|
-
element._entityScriptsIndex = index;
|
|
13162
|
-
});
|
|
13163
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13164
|
-
element.onTriggerStay(shape1);
|
|
13165
|
-
}, function(element, index) {
|
|
13166
|
-
element._entityScriptsIndex = index;
|
|
13167
|
-
});
|
|
13168
|
-
};
|
|
13169
13064
|
this._scene = scene;
|
|
13170
13065
|
this._setGravity = this._setGravity.bind(this);
|
|
13171
13066
|
//@ts-ignore
|
|
13172
13067
|
this._gravity._onValueChanged = this._setGravity;
|
|
13173
13068
|
var engine = scene.engine;
|
|
13174
13069
|
if (engine._physicsInitialized) {
|
|
13175
|
-
this._nativePhysicsScene = Engine._nativePhysics.createPhysicsScene(engine._nativePhysicsManager
|
|
13070
|
+
this._nativePhysicsScene = Engine._nativePhysics.createPhysicsScene(engine._nativePhysicsManager);
|
|
13176
13071
|
}
|
|
13177
13072
|
}
|
|
13178
13073
|
var _proto = PhysicsScene.prototype;
|
|
@@ -13384,6 +13279,7 @@ __decorate([
|
|
|
13384
13279
|
this._callColliderOnUpdate();
|
|
13385
13280
|
nativePhysicsManager.update(fixedTimeStep);
|
|
13386
13281
|
this._callColliderOnLateUpdate();
|
|
13282
|
+
this._dispatchEvents(nativePhysicsManager.updateEvents());
|
|
13387
13283
|
}
|
|
13388
13284
|
};
|
|
13389
13285
|
/**
|
|
@@ -13447,7 +13343,9 @@ __decorate([
|
|
|
13447
13343
|
/**
|
|
13448
13344
|
* @internal
|
|
13449
13345
|
*/ _proto._gc = function _gc() {
|
|
13346
|
+
var _this__nativePhysicsScene;
|
|
13450
13347
|
this._colliders.garbageCollection();
|
|
13348
|
+
(_this__nativePhysicsScene = this._nativePhysicsScene) == null ? void 0 : _this__nativePhysicsScene.gc();
|
|
13451
13349
|
};
|
|
13452
13350
|
/**
|
|
13453
13351
|
* @internal
|
|
@@ -13455,6 +13353,92 @@ __decorate([
|
|
|
13455
13353
|
var _this__nativePhysicsScene;
|
|
13456
13354
|
(_this__nativePhysicsScene = this._nativePhysicsScene) == null ? void 0 : _this__nativePhysicsScene.destroy();
|
|
13457
13355
|
};
|
|
13356
|
+
_proto._dispatchEvents = function _dispatchEvents(events) {
|
|
13357
|
+
var _loop = function(i, n) {
|
|
13358
|
+
var _shape1_collider, _shape2_collider;
|
|
13359
|
+
var event = contactEvents[i];
|
|
13360
|
+
var shape1 = physicalObjectsMap[event.shape0Id];
|
|
13361
|
+
var shape2 = physicalObjectsMap[event.shape1Id];
|
|
13362
|
+
// entity.destroy() is deferred, so shapes/colliders stay valid through the dispatch loop
|
|
13363
|
+
// This guard covers synchronous removeShape()/clearShapes() which sets shape._collider = null
|
|
13364
|
+
if (!(shape1 == null ? void 0 : (_shape1_collider = shape1.collider) == null ? void 0 : _shape1_collider.entity) || !(shape2 == null ? void 0 : (_shape2_collider = shape2.collider) == null ? void 0 : _shape2_collider.entity)) return "continue";
|
|
13365
|
+
collision._nativeCollision = event;
|
|
13366
|
+
switch(event.state){
|
|
13367
|
+
case 0:
|
|
13368
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13369
|
+
collision.shape = shape2;
|
|
13370
|
+
element.onCollisionEnter(collision);
|
|
13371
|
+
}, scriptIndexSetter);
|
|
13372
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13373
|
+
collision.shape = shape1;
|
|
13374
|
+
element.onCollisionEnter(collision);
|
|
13375
|
+
}, scriptIndexSetter);
|
|
13376
|
+
break;
|
|
13377
|
+
case 1:
|
|
13378
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13379
|
+
collision.shape = shape2;
|
|
13380
|
+
element.onCollisionStay(collision);
|
|
13381
|
+
}, scriptIndexSetter);
|
|
13382
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13383
|
+
collision.shape = shape1;
|
|
13384
|
+
element.onCollisionStay(collision);
|
|
13385
|
+
}, scriptIndexSetter);
|
|
13386
|
+
break;
|
|
13387
|
+
case 2:
|
|
13388
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13389
|
+
collision.shape = shape2;
|
|
13390
|
+
element.onCollisionExit(collision);
|
|
13391
|
+
}, scriptIndexSetter);
|
|
13392
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13393
|
+
collision.shape = shape1;
|
|
13394
|
+
element.onCollisionExit(collision);
|
|
13395
|
+
}, scriptIndexSetter);
|
|
13396
|
+
break;
|
|
13397
|
+
}
|
|
13398
|
+
}, _loop1 = function(i1, n1) {
|
|
13399
|
+
var _shape1_collider, _shape2_collider;
|
|
13400
|
+
var event = triggerEvents[i1];
|
|
13401
|
+
var shape1 = physicalObjectsMap[event.index1];
|
|
13402
|
+
var shape2 = physicalObjectsMap[event.index2];
|
|
13403
|
+
// entity.destroy() is deferred, so shapes/colliders stay valid through the dispatch loop
|
|
13404
|
+
// This guard covers synchronous removeShape()/clearShapes() which sets shape._collider = null
|
|
13405
|
+
if (!(shape1 == null ? void 0 : (_shape1_collider = shape1.collider) == null ? void 0 : _shape1_collider.entity) || !(shape2 == null ? void 0 : (_shape2_collider = shape2.collider) == null ? void 0 : _shape2_collider.entity)) return "continue";
|
|
13406
|
+
switch(event.dispatchState){
|
|
13407
|
+
case 0:
|
|
13408
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13409
|
+
element.onTriggerEnter(shape2);
|
|
13410
|
+
}, scriptIndexSetter);
|
|
13411
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13412
|
+
element.onTriggerEnter(shape1);
|
|
13413
|
+
}, scriptIndexSetter);
|
|
13414
|
+
break;
|
|
13415
|
+
case 1:
|
|
13416
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13417
|
+
element.onTriggerStay(shape2);
|
|
13418
|
+
}, scriptIndexSetter);
|
|
13419
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13420
|
+
element.onTriggerStay(shape1);
|
|
13421
|
+
}, scriptIndexSetter);
|
|
13422
|
+
break;
|
|
13423
|
+
case 2:
|
|
13424
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13425
|
+
element.onTriggerExit(shape2);
|
|
13426
|
+
}, scriptIndexSetter);
|
|
13427
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13428
|
+
element.onTriggerExit(shape1);
|
|
13429
|
+
}, scriptIndexSetter);
|
|
13430
|
+
break;
|
|
13431
|
+
}
|
|
13432
|
+
};
|
|
13433
|
+
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
13434
|
+
var collision = PhysicsScene._collision;
|
|
13435
|
+
var scriptIndexSetter = PhysicsScene._scriptIndexSetter;
|
|
13436
|
+
var contactEvents = events.contactEvents, contactEventCount = events.contactEventCount, triggerEvents = events.triggerEvents;
|
|
13437
|
+
// Dispatch contact events
|
|
13438
|
+
for(var i = 0, n = contactEventCount; i < n; i++)_loop(i);
|
|
13439
|
+
// Dispatch trigger events
|
|
13440
|
+
for(var i1 = 0, n1 = triggerEvents.length; i1 < n1; i1++)_loop1(i1);
|
|
13441
|
+
};
|
|
13458
13442
|
_proto._setGravity = function _setGravity() {
|
|
13459
13443
|
this._nativePhysicsScene.setGravity(this._gravity);
|
|
13460
13444
|
};
|
|
@@ -13514,6 +13498,9 @@ __decorate([
|
|
|
13514
13498
|
}();
|
|
13515
13499
|
PhysicsScene._collision = new Collision();
|
|
13516
13500
|
PhysicsScene._identityQuaternion = new engineMath.Quaternion(0, 0, 0, 1);
|
|
13501
|
+
PhysicsScene._scriptIndexSetter = function(element, index) {
|
|
13502
|
+
element._entityScriptsIndex = index;
|
|
13503
|
+
};
|
|
13517
13504
|
|
|
13518
13505
|
/**
|
|
13519
13506
|
* A static collider component that will not move.
|
|
@@ -27106,6 +27093,11 @@ ShaderPool.init();
|
|
|
27106
27093
|
this._textSubRenderElementPool.garbageCollection();
|
|
27107
27094
|
this._renderElementPool.garbageCollection();
|
|
27108
27095
|
this._renderContext.garbageCollection();
|
|
27096
|
+
var scenes = this._sceneManager._scenes.getLoopArray();
|
|
27097
|
+
for(var i = 0, n = scenes.length; i < n; i++){
|
|
27098
|
+
var _scenes_i_physics, _scenes_i;
|
|
27099
|
+
(_scenes_i = scenes[i]) == null ? void 0 : (_scenes_i_physics = _scenes_i.physics) == null ? void 0 : _scenes_i_physics._gc();
|
|
27100
|
+
}
|
|
27109
27101
|
};
|
|
27110
27102
|
_create_class(Engine, [
|
|
27111
27103
|
{
|