@galacean/engine-physics-physx 1.2.0-beta.2 → 1.2.0-beta.4

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.
@@ -197,8 +197,10 @@ var ShapeFlag;
197
197
  var _this;
198
198
  _this = PhysXColliderShape1.call(this, physXPhysics) || this;
199
199
  /** @internal */ _this._halfSize = new miniprogram.Vector3();
200
- _this._halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
201
- _this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(_this._halfSize.x * _this._worldScale.x, _this._halfSize.y * _this._worldScale.y, _this._halfSize.z * _this._worldScale.z);
200
+ _this._sizeScale = new miniprogram.Vector3(1, 1, 1);
201
+ var halfSize = _this._halfSize;
202
+ halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
203
+ _this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(halfSize.x, halfSize.y, halfSize.z);
202
204
  _this._initialize(material, uniqueID);
203
205
  _this._setLocalPose();
204
206
  return _this;
@@ -207,9 +209,10 @@ var ShapeFlag;
207
209
  /**
208
210
  * {@inheritDoc IBoxColliderShape.setSize }
209
211
  */ _proto.setSize = function setSize(value) {
212
+ var halfSize = this._halfSize;
210
213
  var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
211
- this._halfSize.set(value.x * 0.5, value.y * 0.5, value.z * 0.5);
212
- miniprogram.Vector3.multiply(this._halfSize, this._worldScale, tempExtents);
214
+ halfSize.set(value.x * 0.5, value.y * 0.5, value.z * 0.5);
215
+ miniprogram.Vector3.multiply(halfSize, this._sizeScale, tempExtents);
213
216
  this._pxGeometry.halfExtents = tempExtents;
214
217
  this._pxShape.setGeometry(this._pxGeometry);
215
218
  this._updateController(tempExtents);
@@ -218,8 +221,9 @@ var ShapeFlag;
218
221
  * {@inheritDoc IColliderShape.setWorldScale }
219
222
  */ _proto.setWorldScale = function setWorldScale(scale) {
220
223
  PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
224
+ this._sizeScale.set(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
221
225
  var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
222
- miniprogram.Vector3.multiply(this._halfSize, this._worldScale, tempExtents);
226
+ miniprogram.Vector3.multiply(this._halfSize, this._sizeScale, tempExtents);
223
227
  this._pxGeometry.halfExtents = tempExtents;
224
228
  this._pxShape.setGeometry(this._pxGeometry);
225
229
  this._updateController(tempExtents);
@@ -247,6 +251,7 @@ var ShapeFlag;
247
251
  var _this;
248
252
  _this = PhysXColliderShape1.call(this, physXPhysics) || this;
249
253
  _this._upAxis = /** Up axis is Y. */ 1;
254
+ _this._sizeScale = new miniprogram.Vector3(1, 1, 1);
250
255
  _this._radius = radius;
251
256
  _this._halfHeight = height * 0.5;
252
257
  _this._axis = new miniprogram.Quaternion(0, 0, PhysXColliderShape.halfSqrt, PhysXColliderShape.halfSqrt);
@@ -261,15 +266,16 @@ var ShapeFlag;
261
266
  * {@inheritDoc ICapsuleColliderShape.setRadius }
262
267
  */ _proto.setRadius = function setRadius(value) {
263
268
  this._radius = value;
269
+ var sizeScale = this._sizeScale;
264
270
  switch(this._upAxis){
265
271
  case /** Up axis is X. */ 0:
266
- this._pxGeometry.radius = this._radius * Math.max(this._worldScale.y, this._worldScale.z);
272
+ this._pxGeometry.radius = this._radius * Math.max(sizeScale.y, sizeScale.z);
267
273
  break;
268
274
  case 1:
269
- this._pxGeometry.radius = this._radius * Math.max(this._worldScale.x, this._worldScale.z);
275
+ this._pxGeometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.z);
270
276
  break;
271
277
  case /** Up axis is Z. */ 2:
272
- this._pxGeometry.radius = this._radius * Math.max(this._worldScale.x, this._worldScale.y);
278
+ this._pxGeometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.y);
273
279
  break;
274
280
  }
275
281
  this._pxShape.setGeometry(this._pxGeometry);
@@ -283,15 +289,16 @@ var ShapeFlag;
283
289
  * {@inheritDoc ICapsuleColliderShape.setHeight }
284
290
  */ _proto.setHeight = function setHeight(value) {
285
291
  this._halfHeight = value * 0.5;
292
+ var sizeScale = this._sizeScale;
286
293
  switch(this._upAxis){
287
294
  case 0:
288
- this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.x;
295
+ this._pxGeometry.halfHeight = this._halfHeight * sizeScale.x;
289
296
  break;
290
297
  case 1:
291
- this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.y;
298
+ this._pxGeometry.halfHeight = this._halfHeight * sizeScale.y;
292
299
  break;
293
300
  case 2:
294
- this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.z;
301
+ this._pxGeometry.halfHeight = this._halfHeight * sizeScale.z;
295
302
  break;
296
303
  }
297
304
  this._pxShape.setGeometry(this._pxGeometry);
@@ -329,19 +336,20 @@ var ShapeFlag;
329
336
  * {@inheritDoc IColliderShape.setWorldScale }
330
337
  */ _proto.setWorldScale = function setWorldScale(scale) {
331
338
  PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
339
+ var sizeScale = this._sizeScale.set(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
332
340
  var geometry = this._pxGeometry;
333
341
  switch(this._upAxis){
334
342
  case 0:
335
- geometry.radius = this._radius * Math.max(scale.y, scale.z);
336
- geometry.halfHeight = this._halfHeight * scale.x;
343
+ geometry.radius = this._radius * Math.max(sizeScale.y, sizeScale.z);
344
+ geometry.halfHeight = this._halfHeight * sizeScale.x;
337
345
  break;
338
346
  case 1:
339
- geometry.radius = this._radius * Math.max(scale.x, scale.z);
340
- geometry.halfHeight = this._halfHeight * scale.y;
347
+ geometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.z);
348
+ geometry.halfHeight = this._halfHeight * sizeScale.y;
341
349
  break;
342
350
  case 2:
343
- geometry.radius = this._radius * Math.max(scale.x, scale.y);
344
- geometry.halfHeight = this._halfHeight * scale.z;
351
+ geometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.y);
352
+ geometry.halfHeight = this._halfHeight * sizeScale.z;
345
353
  break;
346
354
  }
347
355
  this._pxShape.setGeometry(geometry);
@@ -1263,7 +1271,7 @@ var /**
1263
1271
  * {@inheritDoc IColliderShape.setWorldScale }
1264
1272
  */ _proto.setWorldScale = function setWorldScale(scale) {
1265
1273
  PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
1266
- this._maxScale = Math.max(scale.x, scale.y, scale.z);
1274
+ this._maxScale = Math.max(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
1267
1275
  this._pxGeometry.radius = this._radius * this._maxScale;
1268
1276
  this._pxShape.setGeometry(this._pxGeometry);
1269
1277
  };
@@ -1430,7 +1438,7 @@ var InitializeState;
1430
1438
  })(InitializeState || (InitializeState = {}));
1431
1439
 
1432
1440
  //@ts-ignore
1433
- var version = "1.2.0-beta.2";
1441
+ var version = "1.2.0-beta.4";
1434
1442
  console.log("Galacean PhysX version: " + version);
1435
1443
 
1436
1444
  exports.PhysXPhysics = PhysXPhysics;
package/dist/module.js CHANGED
@@ -192,8 +192,10 @@ var ShapeFlag;
192
192
  var _this;
193
193
  _this = PhysXColliderShape1.call(this, physXPhysics) || this;
194
194
  /** @internal */ _this._halfSize = new Vector3();
195
- _this._halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
196
- _this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(_this._halfSize.x * _this._worldScale.x, _this._halfSize.y * _this._worldScale.y, _this._halfSize.z * _this._worldScale.z);
195
+ _this._sizeScale = new Vector3(1, 1, 1);
196
+ var halfSize = _this._halfSize;
197
+ halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
198
+ _this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(halfSize.x, halfSize.y, halfSize.z);
197
199
  _this._initialize(material, uniqueID);
198
200
  _this._setLocalPose();
199
201
  return _this;
@@ -202,9 +204,10 @@ var ShapeFlag;
202
204
  /**
203
205
  * {@inheritDoc IBoxColliderShape.setSize }
204
206
  */ _proto.setSize = function setSize(value) {
207
+ var halfSize = this._halfSize;
205
208
  var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
206
- this._halfSize.set(value.x * 0.5, value.y * 0.5, value.z * 0.5);
207
- Vector3.multiply(this._halfSize, this._worldScale, tempExtents);
209
+ halfSize.set(value.x * 0.5, value.y * 0.5, value.z * 0.5);
210
+ Vector3.multiply(halfSize, this._sizeScale, tempExtents);
208
211
  this._pxGeometry.halfExtents = tempExtents;
209
212
  this._pxShape.setGeometry(this._pxGeometry);
210
213
  this._updateController(tempExtents);
@@ -213,8 +216,9 @@ var ShapeFlag;
213
216
  * {@inheritDoc IColliderShape.setWorldScale }
214
217
  */ _proto.setWorldScale = function setWorldScale(scale) {
215
218
  PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
219
+ this._sizeScale.set(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
216
220
  var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
217
- Vector3.multiply(this._halfSize, this._worldScale, tempExtents);
221
+ Vector3.multiply(this._halfSize, this._sizeScale, tempExtents);
218
222
  this._pxGeometry.halfExtents = tempExtents;
219
223
  this._pxShape.setGeometry(this._pxGeometry);
220
224
  this._updateController(tempExtents);
@@ -242,6 +246,7 @@ var ShapeFlag;
242
246
  var _this;
243
247
  _this = PhysXColliderShape1.call(this, physXPhysics) || this;
244
248
  _this._upAxis = /** Up axis is Y. */ 1;
249
+ _this._sizeScale = new Vector3(1, 1, 1);
245
250
  _this._radius = radius;
246
251
  _this._halfHeight = height * 0.5;
247
252
  _this._axis = new Quaternion(0, 0, PhysXColliderShape.halfSqrt, PhysXColliderShape.halfSqrt);
@@ -256,15 +261,16 @@ var ShapeFlag;
256
261
  * {@inheritDoc ICapsuleColliderShape.setRadius }
257
262
  */ _proto.setRadius = function setRadius(value) {
258
263
  this._radius = value;
264
+ var sizeScale = this._sizeScale;
259
265
  switch(this._upAxis){
260
266
  case /** Up axis is X. */ 0:
261
- this._pxGeometry.radius = this._radius * Math.max(this._worldScale.y, this._worldScale.z);
267
+ this._pxGeometry.radius = this._radius * Math.max(sizeScale.y, sizeScale.z);
262
268
  break;
263
269
  case 1:
264
- this._pxGeometry.radius = this._radius * Math.max(this._worldScale.x, this._worldScale.z);
270
+ this._pxGeometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.z);
265
271
  break;
266
272
  case /** Up axis is Z. */ 2:
267
- this._pxGeometry.radius = this._radius * Math.max(this._worldScale.x, this._worldScale.y);
273
+ this._pxGeometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.y);
268
274
  break;
269
275
  }
270
276
  this._pxShape.setGeometry(this._pxGeometry);
@@ -278,15 +284,16 @@ var ShapeFlag;
278
284
  * {@inheritDoc ICapsuleColliderShape.setHeight }
279
285
  */ _proto.setHeight = function setHeight(value) {
280
286
  this._halfHeight = value * 0.5;
287
+ var sizeScale = this._sizeScale;
281
288
  switch(this._upAxis){
282
289
  case 0:
283
- this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.x;
290
+ this._pxGeometry.halfHeight = this._halfHeight * sizeScale.x;
284
291
  break;
285
292
  case 1:
286
- this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.y;
293
+ this._pxGeometry.halfHeight = this._halfHeight * sizeScale.y;
287
294
  break;
288
295
  case 2:
289
- this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.z;
296
+ this._pxGeometry.halfHeight = this._halfHeight * sizeScale.z;
290
297
  break;
291
298
  }
292
299
  this._pxShape.setGeometry(this._pxGeometry);
@@ -324,19 +331,20 @@ var ShapeFlag;
324
331
  * {@inheritDoc IColliderShape.setWorldScale }
325
332
  */ _proto.setWorldScale = function setWorldScale(scale) {
326
333
  PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
334
+ var sizeScale = this._sizeScale.set(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
327
335
  var geometry = this._pxGeometry;
328
336
  switch(this._upAxis){
329
337
  case 0:
330
- geometry.radius = this._radius * Math.max(scale.y, scale.z);
331
- geometry.halfHeight = this._halfHeight * scale.x;
338
+ geometry.radius = this._radius * Math.max(sizeScale.y, sizeScale.z);
339
+ geometry.halfHeight = this._halfHeight * sizeScale.x;
332
340
  break;
333
341
  case 1:
334
- geometry.radius = this._radius * Math.max(scale.x, scale.z);
335
- geometry.halfHeight = this._halfHeight * scale.y;
342
+ geometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.z);
343
+ geometry.halfHeight = this._halfHeight * sizeScale.y;
336
344
  break;
337
345
  case 2:
338
- geometry.radius = this._radius * Math.max(scale.x, scale.y);
339
- geometry.halfHeight = this._halfHeight * scale.z;
346
+ geometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.y);
347
+ geometry.halfHeight = this._halfHeight * sizeScale.z;
340
348
  break;
341
349
  }
342
350
  this._pxShape.setGeometry(geometry);
@@ -1258,7 +1266,7 @@ var /**
1258
1266
  * {@inheritDoc IColliderShape.setWorldScale }
1259
1267
  */ _proto.setWorldScale = function setWorldScale(scale) {
1260
1268
  PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
1261
- this._maxScale = Math.max(scale.x, scale.y, scale.z);
1269
+ this._maxScale = Math.max(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
1262
1270
  this._pxGeometry.radius = this._radius * this._maxScale;
1263
1271
  this._pxShape.setGeometry(this._pxGeometry);
1264
1272
  };
@@ -1425,7 +1433,7 @@ var InitializeState;
1425
1433
  })(InitializeState || (InitializeState = {}));
1426
1434
 
1427
1435
  //@ts-ignore
1428
- var version = "1.2.0-beta.2";
1436
+ var version = "1.2.0-beta.4";
1429
1437
  console.log("Galacean PhysX version: " + version);
1430
1438
 
1431
1439
  export { PhysXPhysics, PhysXRuntimeMode, version };