@galacean/engine-physics-physx 0.0.0-experimental-renderSort.3 → 0.0.0-experimental-shaderlab.2

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
@@ -196,8 +196,10 @@ var ShapeFlag;
196
196
  var _this;
197
197
  _this = PhysXColliderShape1.call(this, physXPhysics) || this;
198
198
  /** @internal */ _this._halfSize = new engine.Vector3();
199
- _this._halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
200
- _this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(_this._halfSize.x * _this._worldScale.x, _this._halfSize.y * _this._worldScale.y, _this._halfSize.z * _this._worldScale.z);
199
+ _this._sizeScale = new engine.Vector3(1, 1, 1);
200
+ var halfSize = _this._halfSize;
201
+ halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
202
+ _this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(halfSize.x, halfSize.y, halfSize.z);
201
203
  _this._initialize(material, uniqueID);
202
204
  _this._setLocalPose();
203
205
  return _this;
@@ -206,9 +208,10 @@ var ShapeFlag;
206
208
  /**
207
209
  * {@inheritDoc IBoxColliderShape.setSize }
208
210
  */ _proto.setSize = function setSize(value) {
211
+ var halfSize = this._halfSize;
209
212
  var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
210
- this._halfSize.set(value.x * 0.5, value.y * 0.5, value.z * 0.5);
211
- engine.Vector3.multiply(this._halfSize, this._worldScale, tempExtents);
213
+ halfSize.set(value.x * 0.5, value.y * 0.5, value.z * 0.5);
214
+ engine.Vector3.multiply(halfSize, this._sizeScale, tempExtents);
212
215
  this._pxGeometry.halfExtents = tempExtents;
213
216
  this._pxShape.setGeometry(this._pxGeometry);
214
217
  this._updateController(tempExtents);
@@ -217,8 +220,9 @@ var ShapeFlag;
217
220
  * {@inheritDoc IColliderShape.setWorldScale }
218
221
  */ _proto.setWorldScale = function setWorldScale(scale) {
219
222
  PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
223
+ this._sizeScale.set(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
220
224
  var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
221
- engine.Vector3.multiply(this._halfSize, this._worldScale, tempExtents);
225
+ engine.Vector3.multiply(this._halfSize, this._sizeScale, tempExtents);
222
226
  this._pxGeometry.halfExtents = tempExtents;
223
227
  this._pxShape.setGeometry(this._pxGeometry);
224
228
  this._updateController(tempExtents);
@@ -246,6 +250,7 @@ var ShapeFlag;
246
250
  var _this;
247
251
  _this = PhysXColliderShape1.call(this, physXPhysics) || this;
248
252
  _this._upAxis = /** Up axis is Y. */ 1;
253
+ _this._sizeScale = new engine.Vector3(1, 1, 1);
249
254
  _this._radius = radius;
250
255
  _this._halfHeight = height * 0.5;
251
256
  _this._axis = new engine.Quaternion(0, 0, PhysXColliderShape.halfSqrt, PhysXColliderShape.halfSqrt);
@@ -260,15 +265,16 @@ var ShapeFlag;
260
265
  * {@inheritDoc ICapsuleColliderShape.setRadius }
261
266
  */ _proto.setRadius = function setRadius(value) {
262
267
  this._radius = value;
268
+ var sizeScale = this._sizeScale;
263
269
  switch(this._upAxis){
264
270
  case /** Up axis is X. */ 0:
265
- this._pxGeometry.radius = this._radius * Math.max(this._worldScale.y, this._worldScale.z);
271
+ this._pxGeometry.radius = this._radius * Math.max(sizeScale.y, sizeScale.z);
266
272
  break;
267
273
  case 1:
268
- this._pxGeometry.radius = this._radius * Math.max(this._worldScale.x, this._worldScale.z);
274
+ this._pxGeometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.z);
269
275
  break;
270
276
  case /** Up axis is Z. */ 2:
271
- this._pxGeometry.radius = this._radius * Math.max(this._worldScale.x, this._worldScale.y);
277
+ this._pxGeometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.y);
272
278
  break;
273
279
  }
274
280
  this._pxShape.setGeometry(this._pxGeometry);
@@ -282,15 +288,16 @@ var ShapeFlag;
282
288
  * {@inheritDoc ICapsuleColliderShape.setHeight }
283
289
  */ _proto.setHeight = function setHeight(value) {
284
290
  this._halfHeight = value * 0.5;
291
+ var sizeScale = this._sizeScale;
285
292
  switch(this._upAxis){
286
293
  case 0:
287
- this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.x;
294
+ this._pxGeometry.halfHeight = this._halfHeight * sizeScale.x;
288
295
  break;
289
296
  case 1:
290
- this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.y;
297
+ this._pxGeometry.halfHeight = this._halfHeight * sizeScale.y;
291
298
  break;
292
299
  case 2:
293
- this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.z;
300
+ this._pxGeometry.halfHeight = this._halfHeight * sizeScale.z;
294
301
  break;
295
302
  }
296
303
  this._pxShape.setGeometry(this._pxGeometry);
@@ -328,19 +335,20 @@ var ShapeFlag;
328
335
  * {@inheritDoc IColliderShape.setWorldScale }
329
336
  */ _proto.setWorldScale = function setWorldScale(scale) {
330
337
  PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
338
+ var sizeScale = this._sizeScale.set(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
331
339
  var geometry = this._pxGeometry;
332
340
  switch(this._upAxis){
333
341
  case 0:
334
- geometry.radius = this._radius * Math.max(scale.y, scale.z);
335
- geometry.halfHeight = this._halfHeight * scale.x;
342
+ geometry.radius = this._radius * Math.max(sizeScale.y, sizeScale.z);
343
+ geometry.halfHeight = this._halfHeight * sizeScale.x;
336
344
  break;
337
345
  case 1:
338
- geometry.radius = this._radius * Math.max(scale.x, scale.z);
339
- geometry.halfHeight = this._halfHeight * scale.y;
346
+ geometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.z);
347
+ geometry.halfHeight = this._halfHeight * sizeScale.y;
340
348
  break;
341
349
  case 2:
342
- geometry.radius = this._radius * Math.max(scale.x, scale.y);
343
- geometry.halfHeight = this._halfHeight * scale.z;
350
+ geometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.y);
351
+ geometry.halfHeight = this._halfHeight * sizeScale.z;
344
352
  break;
345
353
  }
346
354
  this._pxShape.setGeometry(geometry);
@@ -825,15 +833,21 @@ var /**
825
833
  * {@inheritDoc IPhysicsManager.removeColliderShape }
826
834
  */ _proto.removeColliderShape = function removeColliderShape(colliderShape) {
827
835
  var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents;
828
- var shapeID = colliderShape._id;
836
+ var id = colliderShape._id;
837
+ var _this__physXManager = this._physXManager, eventMap = _this__physXManager._eventMap;
829
838
  for(var i = currentEvents.length - 1; i >= 0; i--){
830
839
  var event = currentEvents.get(i);
831
- if (event.index1 == shapeID || event.index2 == shapeID) {
840
+ if (event.index1 == id) {
832
841
  currentEvents.deleteByIndex(i);
833
842
  eventPool.push(event);
843
+ } else if (event.index2 == id) {
844
+ currentEvents.deleteByIndex(i);
845
+ eventPool.push(event);
846
+ // If the shape is big index, should clear from the small index shape subMap
847
+ eventMap[event.index1][id] = undefined;
834
848
  }
835
849
  }
836
- delete this._physXManager._eventMap[shapeID];
850
+ delete eventMap[id];
837
851
  };
838
852
  /**
839
853
  * {@inheritDoc IPhysicsManager.addCollider }
@@ -1256,7 +1270,7 @@ var /**
1256
1270
  * {@inheritDoc IColliderShape.setWorldScale }
1257
1271
  */ _proto.setWorldScale = function setWorldScale(scale) {
1258
1272
  PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
1259
- this._maxScale = Math.max(scale.x, scale.y, scale.z);
1273
+ this._maxScale = Math.max(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
1260
1274
  this._pxGeometry.radius = this._radius * this._maxScale;
1261
1275
  this._pxShape.setGeometry(this._pxGeometry);
1262
1276
  };
@@ -1423,7 +1437,7 @@ var InitializeState;
1423
1437
  })(InitializeState || (InitializeState = {}));
1424
1438
 
1425
1439
  //@ts-ignore
1426
- var version = "0.0.0-experimental-renderSort.3";
1440
+ var version = "0.0.0-experimental-shaderlab.2";
1427
1441
  console.log("Galacean PhysX version: " + version);
1428
1442
 
1429
1443
  exports.PhysXPhysics = PhysXPhysics;