|
@@ -1,5 +1,5 @@
|
|
/*
|
|
/*
|
|
- * Copyright (c) 2009-2018 jMonkeyEngine
|
|
|
|
|
|
+ * Copyright (c) 2009-2019 jMonkeyEngine
|
|
* All rights reserved.
|
|
* All rights reserved.
|
|
*
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* Redistribution and use in source and binary forms, with or without
|
|
@@ -49,6 +49,11 @@ import java.util.logging.Logger;
|
|
*/
|
|
*/
|
|
public abstract class CollisionShape implements Savable {
|
|
public abstract class CollisionShape implements Savable {
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * default margin for new non-sphere/non-capsule shapes (in physics-space
|
|
|
|
+ * units, >0, default=0.04)
|
|
|
|
+ */
|
|
|
|
+ private static float defaultMargin = 0.04f;
|
|
/**
|
|
/**
|
|
* unique identifier of the btCollisionShape
|
|
* unique identifier of the btCollisionShape
|
|
* <p>
|
|
* <p>
|
|
@@ -63,7 +68,7 @@ public abstract class CollisionShape implements Savable {
|
|
/**
|
|
/**
|
|
* copy of collision margin (in physics-space units, >0, default=0)
|
|
* copy of collision margin (in physics-space units, >0, default=0)
|
|
*/
|
|
*/
|
|
- protected float margin = 0.0f;
|
|
|
|
|
|
+ protected float margin = defaultMargin;
|
|
|
|
|
|
public CollisionShape() {
|
|
public CollisionShape() {
|
|
}
|
|
}
|
|
@@ -135,6 +140,27 @@ public abstract class CollisionShape implements Savable {
|
|
|
|
|
|
private native float getMargin(long objectId);
|
|
private native float getMargin(long objectId);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Alter the default margin for new shapes that are neither capsules nor
|
|
|
|
+ * spheres.
|
|
|
|
+ *
|
|
|
|
+ * @param margin the desired margin distance (in physics-space units, >0,
|
|
|
|
+ * default=0.04)
|
|
|
|
+ */
|
|
|
|
+ public static void setDefaultMargin(float margin) {
|
|
|
|
+ defaultMargin = margin;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Read the default margin for new shapes.
|
|
|
|
+ *
|
|
|
|
+ * @return margin the default margin distance (in physics-space units,
|
|
|
|
+ * >0)
|
|
|
|
+ */
|
|
|
|
+ public static float getDefaultMargin() {
|
|
|
|
+ return defaultMargin;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Alter the collision margin of this shape. CAUTION: Margin is applied
|
|
* Alter the collision margin of this shape. CAUTION: Margin is applied
|
|
* differently, depending on the type of shape. Generally the collision
|
|
* differently, depending on the type of shape. Generally the collision
|
|
@@ -145,7 +171,7 @@ public abstract class CollisionShape implements Savable {
|
|
* compound shapes) changes can have unintended consequences.
|
|
* compound shapes) changes can have unintended consequences.
|
|
*
|
|
*
|
|
* @param margin the desired margin distance (in physics-space units, >0,
|
|
* @param margin the desired margin distance (in physics-space units, >0,
|
|
- * default=0)
|
|
|
|
|
|
+ * default=0.04)
|
|
*/
|
|
*/
|
|
public void setMargin(float margin) {
|
|
public void setMargin(float margin) {
|
|
setMargin(objectId, margin);
|
|
setMargin(objectId, margin);
|