Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

virtual #1475

Merged
merged 3 commits into from
Mar 3, 2024
Merged

virtual #1475

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

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

### January 29, 2024 version 1.5.10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ public class btCollisionWorld extends Pointer {

public native void updateSingleAabb(btCollisionObject colObj);

public native void updateAabbs();
@Virtual public native void updateAabbs();

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

public native void setDebugDrawer(btIDebugDraw debugDrawer);
@Virtual public native void setDebugDrawer(btIDebugDraw debugDrawer);

public native btIDebugDraw getDebugDrawer();
@Virtual public native btIDebugDraw getDebugDrawer();

public native void debugDrawWorld();
@Virtual public native void debugDrawWorld();

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

/**LocalShapeInfo gives extra information for complex shapes
* Currently, only btTriangleMeshShape is available, so it just contains triangleIndex and subpart */
Expand Down Expand Up @@ -99,6 +99,15 @@ private native void allocate(@Const btCollisionObject collisionObject,
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public RayResultCallback(Pointer p) { super(p); }
/** Native array allocator. Access with {@link Pointer#position(long)}. */
public RayResultCallback(long size) { super((Pointer)null); allocateArray(size); }
private native void allocateArray(long size);
@Override public RayResultCallback position(long position) {
return (RayResultCallback)super.position(position);
}
@Override public RayResultCallback getPointer(long i) {
return new RayResultCallback((Pointer)this).offsetAddress(i);
}

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

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

public native @Cast("btScalar") double addSingleResult(@ByRef LocalRayResult rayResult, @Cast("bool") boolean normalInWorldSpace);
@Virtual(true) public native @Cast("btScalar") double addSingleResult(@ByRef LocalRayResult rayResult, @Cast("bool") boolean normalInWorldSpace);
}

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

public native @Cast("btScalar") double addSingleResult(@ByRef LocalRayResult rayResult, @Cast("bool") boolean normalInWorldSpace);
@Virtual public native @Cast("btScalar") double addSingleResult(@ByRef LocalRayResult rayResult, @Cast("bool") boolean normalInWorldSpace);
}

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

public native @Cast("btScalar") double addSingleResult(@ByRef LocalRayResult rayResult, @Cast("bool") boolean normalInWorldSpace);
@Virtual public native @Cast("btScalar") double addSingleResult(@ByRef LocalRayResult rayResult, @Cast("bool") boolean normalInWorldSpace);
}

@NoOffset public static class LocalConvexResult extends Pointer {
Expand Down Expand Up @@ -178,16 +187,25 @@ private native void allocate(@Const btCollisionObject hitCollisionObject,
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public ConvexResultCallback(Pointer p) { super(p); }
/** Native array allocator. Access with {@link Pointer#position(long)}. */
public ConvexResultCallback(long size) { super((Pointer)null); allocateArray(size); }
private native void allocateArray(long size);
@Override public ConvexResultCallback position(long position) {
return (ConvexResultCallback)super.position(position);
}
@Override public ConvexResultCallback getPointer(long i) {
return new ConvexResultCallback((Pointer)this).offsetAddress(i);
}

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

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

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

public native @Cast("btScalar") double addSingleResult(@ByRef LocalConvexResult convexResult, @Cast("bool") boolean normalInWorldSpace);
@Virtual(true) public native @Cast("btScalar") double addSingleResult(@ByRef LocalConvexResult convexResult, @Cast("bool") boolean normalInWorldSpace);
}

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

public native @Cast("btScalar") double addSingleResult(@ByRef LocalConvexResult convexResult, @Cast("bool") boolean normalInWorldSpace);
@Virtual public native @Cast("btScalar") double addSingleResult(@ByRef LocalConvexResult convexResult, @Cast("bool") boolean normalInWorldSpace);
}

/**ContactResultCallback is used to report contact points */
@NoOffset public static class ContactResultCallback extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public ContactResultCallback(Pointer p) { super(p); }
/** Native array allocator. Access with {@link Pointer#position(long)}. */
public ContactResultCallback(long size) { super((Pointer)null); allocateArray(size); }
private native void allocateArray(long size);
@Override public ContactResultCallback position(long position) {
return (ContactResultCallback)super.position(position);
}
@Override public ContactResultCallback getPointer(long i) {
return new ContactResultCallback((Pointer)this).offsetAddress(i);
}

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

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

public native @Cast("btScalar") double addSingleResult(@ByRef btManifoldPoint cp, @Const btCollisionObjectWrapper colObj0Wrap, int partId0, int index0, @Const btCollisionObjectWrapper colObj1Wrap, int partId1, int index1);
@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);
}

public native int getNumCollisionObjects();

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

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

public native void addCollisionObject(btCollisionObject collisionObject, int collisionFilterGroup/*=btBroadphaseProxy::DefaultFilter*/, int collisionFilterMask/*=btBroadphaseProxy::AllFilter*/);
public native void addCollisionObject(btCollisionObject collisionObject);
@Virtual public native void addCollisionObject(btCollisionObject collisionObject, int collisionFilterGroup/*=btBroadphaseProxy::DefaultFilter*/, int collisionFilterMask/*=btBroadphaseProxy::AllFilter*/);

public native void refreshBroadphaseProxy(btCollisionObject collisionObject);
@Virtual public native void refreshBroadphaseProxy(btCollisionObject collisionObject);

public native @ByRef btCollisionObjectArray getCollisionObjectArray();

public native void removeCollisionObject(btCollisionObject collisionObject);
@Virtual public native void removeCollisionObject(btCollisionObject collisionObject);

public native void performDiscreteCollisionDetection();
@Virtual public native void performDiscreteCollisionDetection();

public native @ByRef btDispatcherInfo getDispatchInfo();

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

/**Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (Bullet/Demos/SerializeDemo) */
public native void serialize(btSerializer serializer);
@Virtual public native void serialize(btSerializer serializer);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,21 @@
@Properties(inherit = org.bytedeco.bullet.presets.BulletCollision.class)
public class btOverlapCallback extends Pointer {
static { Loader.load(); }
/** Default native constructor. */
public btOverlapCallback() { super((Pointer)null); allocate(); }
/** Native array allocator. Access with {@link Pointer#position(long)}. */
public btOverlapCallback(long size) { super((Pointer)null); allocateArray(size); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public btOverlapCallback(Pointer p) { super(p); }
private native void allocate();
private native void allocateArray(long size);
@Override public btOverlapCallback position(long position) {
return (btOverlapCallback)super.position(position);
}
@Override public btOverlapCallback getPointer(long i) {
return new btOverlapCallback((Pointer)this).offsetAddress(i);
}

//return true for deletion of the pair
public native @Cast("bool") boolean processOverlap(@ByRef btBroadphasePair pair);
@Virtual(true) public native @Cast("bool") boolean processOverlap(@ByRef btBroadphasePair pair);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,21 @@
@Properties(inherit = org.bytedeco.bullet.presets.BulletCollision.class)
public class btOverlapFilterCallback extends Pointer {
static { Loader.load(); }
/** Default native constructor. */
public btOverlapFilterCallback() { super((Pointer)null); allocate(); }
/** Native array allocator. Access with {@link Pointer#position(long)}. */
public btOverlapFilterCallback(long size) { super((Pointer)null); allocateArray(size); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public btOverlapFilterCallback(Pointer p) { super(p); }
private native void allocate();
private native void allocateArray(long size);
@Override public btOverlapFilterCallback position(long position) {
return (btOverlapFilterCallback)super.position(position);
}
@Override public btOverlapFilterCallback getPointer(long i) {
return new btOverlapFilterCallback((Pointer)this).offsetAddress(i);
}

// return true when pairs need collision
public native @Cast("bool") boolean needBroadphaseCollision(btBroadphaseProxy proxy0, btBroadphaseProxy proxy1);
@Virtual(true) public native @Cast("bool") @Const({false, false, true}) boolean needBroadphaseCollision(btBroadphaseProxy proxy0, btBroadphaseProxy proxy1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ public void map(InfoMap infoMap) {
.put(new Info("btDbvt::sStkNPS").pointerTypes("btDbvt.sStkNPS"))

.put(new Info("btCollisionObjectWrapper").purify(true))
.put(new Info("btCollisionWorld", "btOverlapFilterCallback", "btOverlapCallback").virtualize())

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