Skip to content

Commit 0ad9293

Browse files
committed
BoxShape{/Settings}: alter the half-extent constraints
1 parent 49efa05 commit 0ad9293

File tree

2 files changed

+25
-30
lines changed

2 files changed

+25
-30
lines changed

src/main/java/com/github/stephengold/joltjni/BoxShape.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class BoxShape extends ConvexShape {
3737
/**
3838
* Instantiate a cubic shape with the specified half extents.
3939
*
40-
* @param halfExtent the desired half extents (≥0.05)
40+
* @param halfExtent the desired half extents (>0)
4141
*/
4242
public BoxShape(float halfExtent) {
4343
this(halfExtent, halfExtent, halfExtent);
@@ -46,22 +46,18 @@ public BoxShape(float halfExtent) {
4646
/**
4747
* Instantiate a shape with the specified half extents.
4848
*
49-
* @param xHalfExtent the desired half extents on the local X axis
50-
* (≥0.05)
51-
* @param yHalfExtent the desired half extents on the local Y axis
52-
* (≥0.05)
53-
* @param zHalfExtent the desired half extents on the local Z axis
54-
* (≥0.05)
49+
* @param xHalfExtent the desired half extent on the local X axis (>0)
50+
* @param yHalfExtent the desired half extent on the local Y axis (>0)
51+
* @param zHalfExtent the desired half extent on the local Z axis (>0)
5552
*/
5653
public BoxShape(float xHalfExtent, float yHalfExtent, float zHalfExtent) {
57-
float convexRadius = Jolt.cDefaultConvexRadius;
58-
assert xHalfExtent >= convexRadius : xHalfExtent;
59-
assert yHalfExtent >= convexRadius : yHalfExtent;
60-
assert zHalfExtent >= convexRadius : zHalfExtent;
54+
assert xHalfExtent > 0f : xHalfExtent;
55+
assert yHalfExtent > 0f : yHalfExtent;
56+
assert zHalfExtent > 0f : zHalfExtent;
6157

6258
long materialVa = 0L;
6359
long shapeVa = createBoxShape(xHalfExtent, yHalfExtent, zHalfExtent,
64-
convexRadius, materialVa);
60+
Jolt.cDefaultConvexRadius, materialVa);
6561
setVirtualAddressAsCoOwner(shapeVa);
6662
}
6763

@@ -79,7 +75,7 @@ public BoxShape(float xHalfExtent, float yHalfExtent, float zHalfExtent) {
7975
* Instantiate a shape with the specified half extents.
8076
*
8177
* @param halfExtents the desired half extents on each local axis (not null,
82-
* all components ≥0.05, unaffected)
78+
* all components >0, unaffected)
8379
*/
8480
public BoxShape(Vec3Arg halfExtents) {
8581
this(halfExtents, Jolt.cDefaultConvexRadius);
@@ -100,7 +96,7 @@ public BoxShape(Vec3Arg halfExtents, float convexRadius) {
10096
* Instantiate a shape with the specified parameters.
10197
*
10298
* @param halfExtents the desired half extents on each local axis (not null,
103-
* all components ≥convexRadius, unaffected)
99+
* all components >0, unaffected)
104100
* @param convexRadius the desired convex radius (default=0.05)
105101
* @param material the desired material (default=null)
106102
*/
@@ -109,9 +105,9 @@ public BoxShape(Vec3Arg halfExtents, float convexRadius,
109105
float xHalfExtent = halfExtents.getX();
110106
float yHalfExtent = halfExtents.getY();
111107
float zHalfExtent = halfExtents.getZ();
112-
assert xHalfExtent >= convexRadius : xHalfExtent;
113-
assert yHalfExtent >= convexRadius : yHalfExtent;
114-
assert zHalfExtent >= convexRadius : zHalfExtent;
108+
assert xHalfExtent > 0f : xHalfExtent;
109+
assert yHalfExtent > 0f : yHalfExtent;
110+
assert zHalfExtent > 0f : zHalfExtent;
115111

116112
long materialVa = (material == null) ? 0L : material.targetVa();
117113
long shapeVa = createBoxShape(xHalfExtent, yHalfExtent, zHalfExtent,

src/main/java/com/github/stephengold/joltjni/BoxShapeSettings.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,22 @@ public BoxShapeSettings(float radius) {
6969
/**
7070
* Instantiate a shape with the specified half extents.
7171
*
72-
* @param xHalfExtent the desired half extents on the local X axis
73-
* (≥0.05)
74-
* @param yHalfExtent the desired half extents on the local Y axis
75-
* (≥0.05)
76-
* @param zHalfExtent the desired half extents on the local Z axis
77-
* (≥0.05)
72+
* @param xHalfExtent the desired half extent on the local X axis
73+
* (>0)
74+
* @param yHalfExtent the desired half extent on the local Y axis
75+
* (>0)
76+
* @param zHalfExtent the desired half extent on the local Z axis
77+
* (>0)
7878
*/
7979
public BoxShapeSettings(
8080
float xHalfExtent, float yHalfExtent, float zHalfExtent) {
81-
float convexRadius = Jolt.cDefaultConvexRadius;
82-
assert xHalfExtent >= convexRadius : xHalfExtent;
83-
assert yHalfExtent >= convexRadius : yHalfExtent;
84-
assert zHalfExtent >= convexRadius : zHalfExtent;
81+
assert xHalfExtent > 0f : xHalfExtent;
82+
assert yHalfExtent > 0f : yHalfExtent;
83+
assert zHalfExtent > 0f : zHalfExtent;
8584

8685
long materialVa = 0L;
8786
long settingsVa = createBoxShapeSettings(xHalfExtent, yHalfExtent,
88-
zHalfExtent, convexRadius, materialVa);
87+
zHalfExtent, Jolt.cDefaultConvexRadius, materialVa);
8988
setVirtualAddressAsCoOwner(settingsVa, EShapeSubType.Box);
9089
}
9190

@@ -113,7 +112,7 @@ public BoxShapeSettings(Vec3Arg halfExtents) {
113112
* Instantiate settings for the specified half extents and convex radius.
114113
*
115114
* @param halfExtents the desired half extents on each local axis (not null,
116-
* all components ≥0, unaffected)
115+
* all components >0, unaffected)
117116
* @param convexRadius the desired convex radius (≥0, default=0.05)
118117
*/
119118
public BoxShapeSettings(Vec3Arg halfExtents, float convexRadius) {
@@ -125,7 +124,7 @@ public BoxShapeSettings(Vec3Arg halfExtents, float convexRadius) {
125124
* material.
126125
*
127126
* @param halfExtents the desired half extents on each local axis (not null,
128-
* all components ≥0, unaffected)
127+
* all components >0, unaffected)
129128
* @param convexRadius the desired convex radius (≥0, default=0.05)
130129
* @param material the desired surface properties (not null, unaffected) or
131130
* {@code null} for default properties (default=null)

0 commit comments

Comments
 (0)