Skip to content

Commit 351d203

Browse files
authored
* Virtualize btCollisionWorld, btOverlapFilterCallback, btOverlapCallback from Bullet Physics SDK (pull #1475)
1 parent 575a44e commit 351d203

File tree

5 files changed

+76
-24
lines changed

5 files changed

+76
-24
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
* Virtualize `btCollisionWorld`, `btOverlapFilterCallback`, `btOverlapCallback` from Bullet Physics SDK ([pull #1475](https://github.com/bytedeco/javacpp-presets/pull/1475))
23
* Upgrade presets for PyTorch 2.2.1 ([pull #1466](https://github.com/bytedeco/javacpp-presets/pull/1466))
34

45
### January 29, 2024 version 1.5.10

bullet/src/gen/java/org/bytedeco/bullet/BulletCollision/btCollisionWorld.java

+48-22
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ public class btCollisionWorld extends Pointer {
3434

3535
public native void updateSingleAabb(btCollisionObject colObj);
3636

37-
public native void updateAabbs();
37+
@Virtual public native void updateAabbs();
3838

3939
/**the computeOverlappingPairs is usually already called by performDiscreteCollisionDetection (or stepSimulation)
4040
* it can be useful to use if you perform ray tests without collision detection/simulation */
41-
public native void computeOverlappingPairs();
41+
@Virtual public native void computeOverlappingPairs();
4242

43-
public native void setDebugDrawer(btIDebugDraw debugDrawer);
43+
@Virtual public native void setDebugDrawer(btIDebugDraw debugDrawer);
4444

45-
public native btIDebugDraw getDebugDrawer();
45+
@Virtual public native btIDebugDraw getDebugDrawer();
4646

47-
public native void debugDrawWorld();
47+
@Virtual public native void debugDrawWorld();
4848

49-
public native void debugDrawObject(@Const @ByRef btTransform worldTransform, @Const btCollisionShape shape, @Const @ByRef btVector3 color);
49+
@Virtual public native void debugDrawObject(@Const @ByRef btTransform worldTransform, @Const btCollisionShape shape, @Const @ByRef btVector3 color);
5050

5151
/**LocalShapeInfo gives extra information for complex shapes
5252
* Currently, only btTriangleMeshShape is available, so it just contains triangleIndex and subpart */
@@ -99,6 +99,15 @@ private native void allocate(@Const btCollisionObject collisionObject,
9999
static { Loader.load(); }
100100
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
101101
public RayResultCallback(Pointer p) { super(p); }
102+
/** Native array allocator. Access with {@link Pointer#position(long)}. */
103+
public RayResultCallback(long size) { super((Pointer)null); allocateArray(size); }
104+
private native void allocateArray(long size);
105+
@Override public RayResultCallback position(long position) {
106+
return (RayResultCallback)super.position(position);
107+
}
108+
@Override public RayResultCallback getPointer(long i) {
109+
return new RayResultCallback((Pointer)this).offsetAddress(i);
110+
}
102111

103112
public native @Cast("btScalar") double m_closestHitFraction(); public native RayResultCallback m_closestHitFraction(double setter);
104113
public native @Const btCollisionObject m_collisionObject(); public native RayResultCallback m_collisionObject(btCollisionObject setter);
@@ -108,9 +117,9 @@ private native void allocate(@Const btCollisionObject collisionObject,
108117
public native @Cast("unsigned int") int m_flags(); public native RayResultCallback m_flags(int setter);
109118
public native @Cast("bool") boolean hasHit();
110119

111-
public native @Cast("bool") boolean needsCollision(btBroadphaseProxy proxy0);
120+
@Virtual public native @Cast("bool") @Const({false, false, true}) boolean needsCollision(btBroadphaseProxy proxy0);
112121

113-
public native @Cast("btScalar") double addSingleResult(@ByRef LocalRayResult rayResult, @Cast("bool") boolean normalInWorldSpace);
122+
@Virtual(true) public native @Cast("btScalar") double addSingleResult(@ByRef LocalRayResult rayResult, @Cast("bool") boolean normalInWorldSpace);
114123
}
115124

116125
@NoOffset public static class ClosestRayResultCallback extends RayResultCallback {
@@ -127,7 +136,7 @@ private native void allocate(@Const btCollisionObject collisionObject,
127136
public native @ByRef btVector3 m_hitNormalWorld(); public native ClosestRayResultCallback m_hitNormalWorld(btVector3 setter);
128137
public native @ByRef btVector3 m_hitPointWorld(); public native ClosestRayResultCallback m_hitPointWorld(btVector3 setter);
129138

130-
public native @Cast("btScalar") double addSingleResult(@ByRef LocalRayResult rayResult, @Cast("bool") boolean normalInWorldSpace);
139+
@Virtual public native @Cast("btScalar") double addSingleResult(@ByRef LocalRayResult rayResult, @Cast("bool") boolean normalInWorldSpace);
131140
}
132141

133142
@NoOffset public static class AllHitsRayResultCallback extends RayResultCallback {
@@ -147,7 +156,7 @@ private native void allocate(@Const btCollisionObject collisionObject,
147156
public native @ByRef btVector3Array m_hitPointWorld(); public native AllHitsRayResultCallback m_hitPointWorld(btVector3Array setter);
148157
public native @ByRef btScalarArray m_hitFractions(); public native AllHitsRayResultCallback m_hitFractions(btScalarArray setter);
149158

150-
public native @Cast("btScalar") double addSingleResult(@ByRef LocalRayResult rayResult, @Cast("bool") boolean normalInWorldSpace);
159+
@Virtual public native @Cast("btScalar") double addSingleResult(@ByRef LocalRayResult rayResult, @Cast("bool") boolean normalInWorldSpace);
151160
}
152161

153162
@NoOffset public static class LocalConvexResult extends Pointer {
@@ -178,16 +187,25 @@ private native void allocate(@Const btCollisionObject hitCollisionObject,
178187
static { Loader.load(); }
179188
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
180189
public ConvexResultCallback(Pointer p) { super(p); }
190+
/** Native array allocator. Access with {@link Pointer#position(long)}. */
191+
public ConvexResultCallback(long size) { super((Pointer)null); allocateArray(size); }
192+
private native void allocateArray(long size);
193+
@Override public ConvexResultCallback position(long position) {
194+
return (ConvexResultCallback)super.position(position);
195+
}
196+
@Override public ConvexResultCallback getPointer(long i) {
197+
return new ConvexResultCallback((Pointer)this).offsetAddress(i);
198+
}
181199

182200
public native @Cast("btScalar") double m_closestHitFraction(); public native ConvexResultCallback m_closestHitFraction(double setter);
183201
public native int m_collisionFilterGroup(); public native ConvexResultCallback m_collisionFilterGroup(int setter);
184202
public native int m_collisionFilterMask(); public native ConvexResultCallback m_collisionFilterMask(int setter);
185203

186204
public native @Cast("bool") boolean hasHit();
187205

188-
public native @Cast("bool") boolean needsCollision(btBroadphaseProxy proxy0);
206+
@Virtual public native @Cast("bool") @Const({false, false, true}) boolean needsCollision(btBroadphaseProxy proxy0);
189207

190-
public native @Cast("btScalar") double addSingleResult(@ByRef LocalConvexResult convexResult, @Cast("bool") boolean normalInWorldSpace);
208+
@Virtual(true) public native @Cast("btScalar") double addSingleResult(@ByRef LocalConvexResult convexResult, @Cast("bool") boolean normalInWorldSpace);
191209
}
192210

193211
@NoOffset public static class ClosestConvexResultCallback extends ConvexResultCallback {
@@ -205,29 +223,38 @@ private native void allocate(@Const btCollisionObject hitCollisionObject,
205223
public native @ByRef btVector3 m_hitPointWorld(); public native ClosestConvexResultCallback m_hitPointWorld(btVector3 setter);
206224
public native @Const btCollisionObject m_hitCollisionObject(); public native ClosestConvexResultCallback m_hitCollisionObject(btCollisionObject setter);
207225

208-
public native @Cast("btScalar") double addSingleResult(@ByRef LocalConvexResult convexResult, @Cast("bool") boolean normalInWorldSpace);
226+
@Virtual public native @Cast("btScalar") double addSingleResult(@ByRef LocalConvexResult convexResult, @Cast("bool") boolean normalInWorldSpace);
209227
}
210228

211229
/**ContactResultCallback is used to report contact points */
212230
@NoOffset public static class ContactResultCallback extends Pointer {
213231
static { Loader.load(); }
214232
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
215233
public ContactResultCallback(Pointer p) { super(p); }
234+
/** Native array allocator. Access with {@link Pointer#position(long)}. */
235+
public ContactResultCallback(long size) { super((Pointer)null); allocateArray(size); }
236+
private native void allocateArray(long size);
237+
@Override public ContactResultCallback position(long position) {
238+
return (ContactResultCallback)super.position(position);
239+
}
240+
@Override public ContactResultCallback getPointer(long i) {
241+
return new ContactResultCallback((Pointer)this).offsetAddress(i);
242+
}
216243

217244
public native int m_collisionFilterGroup(); public native ContactResultCallback m_collisionFilterGroup(int setter);
218245
public native int m_collisionFilterMask(); public native ContactResultCallback m_collisionFilterMask(int setter);
219246
public native @Cast("btScalar") double m_closestDistanceThreshold(); public native ContactResultCallback m_closestDistanceThreshold(double setter);
220247

221-
public native @Cast("bool") boolean needsCollision(btBroadphaseProxy proxy0);
248+
@Virtual public native @Cast("bool") @Const({false, false, true}) boolean needsCollision(btBroadphaseProxy proxy0);
222249

223-
public native @Cast("btScalar") double addSingleResult(@ByRef btManifoldPoint cp, @Const btCollisionObjectWrapper colObj0Wrap, int partId0, int index0, @Const btCollisionObjectWrapper colObj1Wrap, int partId1, int index1);
250+
@Virtual(true) public native @Cast("btScalar") double addSingleResult(@ByRef btManifoldPoint cp, @Const btCollisionObjectWrapper colObj0Wrap, int partId0, int index0, @Const btCollisionObjectWrapper colObj1Wrap, int partId1, int index1);
224251
}
225252

226253
public native int getNumCollisionObjects();
227254

228255
/** rayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback
229256
* This allows for several queries: first hit, all hits, any hit, dependent on the value returned by the callback. */
230-
public native void rayTest(@Const @ByRef btVector3 rayFromWorld, @Const @ByRef btVector3 rayToWorld, @ByRef RayResultCallback resultCallback);
257+
@Virtual public native @Const({false, false, true}) void rayTest(@Const @ByRef btVector3 rayFromWorld, @Const @ByRef btVector3 rayToWorld, @ByRef RayResultCallback resultCallback);
231258

232259
/** convexTest performs a swept convex cast on all objects in the btCollisionWorld, and calls the resultCallback
233260
* This allows for several queries: first hit, all hits, any hit, dependent on the value return by the callback. */
@@ -266,22 +293,21 @@ public static native void objectQuerySingleInternal(@Const btConvexShape castSha
266293
@Const btCollisionObjectWrapper colObjWrap,
267294
@ByRef ConvexResultCallback resultCallback, @Cast("btScalar") double allowedPenetration);
268295

269-
public native void addCollisionObject(btCollisionObject collisionObject, int collisionFilterGroup/*=btBroadphaseProxy::DefaultFilter*/, int collisionFilterMask/*=btBroadphaseProxy::AllFilter*/);
270-
public native void addCollisionObject(btCollisionObject collisionObject);
296+
@Virtual public native void addCollisionObject(btCollisionObject collisionObject, int collisionFilterGroup/*=btBroadphaseProxy::DefaultFilter*/, int collisionFilterMask/*=btBroadphaseProxy::AllFilter*/);
271297

272-
public native void refreshBroadphaseProxy(btCollisionObject collisionObject);
298+
@Virtual public native void refreshBroadphaseProxy(btCollisionObject collisionObject);
273299

274300
public native @ByRef btCollisionObjectArray getCollisionObjectArray();
275301

276-
public native void removeCollisionObject(btCollisionObject collisionObject);
302+
@Virtual public native void removeCollisionObject(btCollisionObject collisionObject);
277303

278-
public native void performDiscreteCollisionDetection();
304+
@Virtual public native void performDiscreteCollisionDetection();
279305

280306
public native @ByRef btDispatcherInfo getDispatchInfo();
281307

282308
public native @Cast("bool") boolean getForceUpdateAllAabbs();
283309
public native void setForceUpdateAllAabbs(@Cast("bool") boolean forceUpdateAllAabbs);
284310

285311
/**Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (Bullet/Demos/SerializeDemo) */
286-
public native void serialize(btSerializer serializer);
312+
@Virtual public native void serialize(btSerializer serializer);
287313
}

bullet/src/gen/java/org/bytedeco/bullet/BulletCollision/btOverlapCallback.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,21 @@
1616
@Properties(inherit = org.bytedeco.bullet.presets.BulletCollision.class)
1717
public class btOverlapCallback extends Pointer {
1818
static { Loader.load(); }
19+
/** Default native constructor. */
20+
public btOverlapCallback() { super((Pointer)null); allocate(); }
21+
/** Native array allocator. Access with {@link Pointer#position(long)}. */
22+
public btOverlapCallback(long size) { super((Pointer)null); allocateArray(size); }
1923
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
2024
public btOverlapCallback(Pointer p) { super(p); }
25+
private native void allocate();
26+
private native void allocateArray(long size);
27+
@Override public btOverlapCallback position(long position) {
28+
return (btOverlapCallback)super.position(position);
29+
}
30+
@Override public btOverlapCallback getPointer(long i) {
31+
return new btOverlapCallback((Pointer)this).offsetAddress(i);
32+
}
2133

2234
//return true for deletion of the pair
23-
public native @Cast("bool") boolean processOverlap(@ByRef btBroadphasePair pair);
35+
@Virtual(true) public native @Cast("bool") boolean processOverlap(@ByRef btBroadphasePair pair);
2436
}

bullet/src/gen/java/org/bytedeco/bullet/BulletCollision/btOverlapFilterCallback.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,21 @@
1616
@Properties(inherit = org.bytedeco.bullet.presets.BulletCollision.class)
1717
public class btOverlapFilterCallback extends Pointer {
1818
static { Loader.load(); }
19+
/** Default native constructor. */
20+
public btOverlapFilterCallback() { super((Pointer)null); allocate(); }
21+
/** Native array allocator. Access with {@link Pointer#position(long)}. */
22+
public btOverlapFilterCallback(long size) { super((Pointer)null); allocateArray(size); }
1923
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
2024
public btOverlapFilterCallback(Pointer p) { super(p); }
25+
private native void allocate();
26+
private native void allocateArray(long size);
27+
@Override public btOverlapFilterCallback position(long position) {
28+
return (btOverlapFilterCallback)super.position(position);
29+
}
30+
@Override public btOverlapFilterCallback getPointer(long i) {
31+
return new btOverlapFilterCallback((Pointer)this).offsetAddress(i);
32+
}
2133

2234
// return true when pairs need collision
23-
public native @Cast("bool") boolean needBroadphaseCollision(btBroadphaseProxy proxy0, btBroadphaseProxy proxy1);
35+
@Virtual(true) public native @Cast("bool") @Const({false, false, true}) boolean needBroadphaseCollision(btBroadphaseProxy proxy0, btBroadphaseProxy proxy1);
2436
}

bullet/src/main/java/org/bytedeco/bullet/presets/BulletCollision.java

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ public void map(InfoMap infoMap) {
220220
.put(new Info("btDbvt::sStkNPS").pointerTypes("btDbvt.sStkNPS"))
221221

222222
.put(new Info("btCollisionObjectWrapper").purify(true))
223+
.put(new Info("btCollisionWorld", "btOverlapFilterCallback", "btOverlapCallback").virtualize())
223224

224225
.put(new Info("btCollisionWorldImporter.h").linePatterns("struct btContactSolverInfo;").skip())
225226
.put(new Info("btDispatcher.h").linePatterns("class btRigidBody;").skip())

0 commit comments

Comments
 (0)