Skip to content

Commit

Permalink
* Add bindings for b2DynamicTree::Query and RayCast for LiquidFu…
Browse files Browse the repository at this point in the history
…n (pull #531)
  • Loading branch information
nornagon authored and saudet committed Mar 6, 2018
1 parent c53d4dd commit 7e48c5b
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Add bindings for `b2DynamicTree::Query` and `RayCast` for LiquidFun ([pull #531](https://github.com/bytedeco/javacpp-presets/pull/531))
* Add support for Windows to presets for LLVM ([pull #530](https://github.com/bytedeco/javacpp-presets/pull/530))
* Add builds for `android-arm64` and `android-x86_64` platforms ([issue #52](https://github.com/bytedeco/javacpp-presets/issues/52))
* Fix x265 encoding with FFmpeg on Android ([issue bytedeco/javacv#866](https://github.com/bytedeco/javacv/issues/866))
Expand Down
43 changes: 42 additions & 1 deletion liquidfun/src/main/java/org/bytedeco/javacpp/liquidfun.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Targeted by JavaCPP version 1.4: DO NOT EDIT THIS FILE
// Targeted by JavaCPP version 1.4.1-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.javacpp;

Expand Down Expand Up @@ -2515,6 +2515,7 @@ public static class b2TreeNode extends Pointer {

/** Query an AABB for overlapping proxies. The callback class
* is called for each proxy that overlaps the supplied AABB. */
public native void Query(b2DynamicTreeQueryCallback callback, @Const @ByRef b2AABB aabb);

/** Ray-cast against the proxies in the tree. This relies on the callback
* to perform a exact ray-cast in the case were the proxy contains a shape.
Expand All @@ -2523,6 +2524,7 @@ public static class b2TreeNode extends Pointer {
* number of proxies in the tree.
* @param input the ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
* @param callback a callback class that is called for each proxy that is hit by the ray. */
public native void RayCast(b2DynamicTreeRayCastCallback callback, @Const @ByRef b2RayCastInput input);

/** Validate this tree. For testing. */
public native void Validate();
Expand Down Expand Up @@ -7408,4 +7410,43 @@ public native int CopyWeightBuffer(int startIndex, int numParticles, Pointer out



// Parsed from liquidfun_adapters.h

// #include <Box2D/Common/b2Settings.h>

public static class b2DynamicTreeQueryCallback extends Pointer {
static { Loader.load(); }
/** Default native constructor. */
public b2DynamicTreeQueryCallback() { super((Pointer)null); allocate(); }
/** Native array allocator. Access with {@link Pointer#position(long)}. */
public b2DynamicTreeQueryCallback(long size) { super((Pointer)null); allocateArray(size); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public b2DynamicTreeQueryCallback(Pointer p) { super(p); }
private native void allocate();
private native void allocateArray(long size);
@Override public b2DynamicTreeQueryCallback position(long position) {
return (b2DynamicTreeQueryCallback)super.position(position);
}

@Virtual(true) public native @Cast("bool") boolean QueryCallback(@Cast("int32") int nodeId);
}

public static class b2DynamicTreeRayCastCallback extends Pointer {
static { Loader.load(); }
/** Default native constructor. */
public b2DynamicTreeRayCastCallback() { super((Pointer)null); allocate(); }
/** Native array allocator. Access with {@link Pointer#position(long)}. */
public b2DynamicTreeRayCastCallback(long size) { super((Pointer)null); allocateArray(size); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public b2DynamicTreeRayCastCallback(Pointer p) { super(p); }
private native void allocate();
private native void allocateArray(long size);
@Override public b2DynamicTreeRayCastCallback position(long position) {
return (b2DynamicTreeRayCastCallback)super.position(position);
}

@Virtual(true) public native @Cast("bool") boolean RayCastCallback(@ByRef b2RayCastInput subInput, @Cast("int32") int nodeId);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"<Box2D/Dynamics/Joints/b2WheelJoint.h>",
"<Box2D/Particle/b2Particle.h>",
"<Box2D/Particle/b2ParticleGroup.h>",
"<Box2D/Particle/b2ParticleSystem.h>"
"<Box2D/Particle/b2ParticleSystem.h>",
"liquidfun_adapters.h"
},
link = "liquidfun@.2.3.0")
})
Expand Down Expand Up @@ -102,7 +103,9 @@ public void map(InfoMap infoMap)
// enable callbacks
.put(new Info("b2QueryCallback", "b2RayCastCallback").virtualize())
.put(new Info("b2ContactListener", "b2ContactFilter", "b2DestructionListener").virtualize())
.put(new Info("b2Draw").virtualize())
.put(new Info("b2Draw", "b2DynamicTreeQueryCallback", "b2DynamicTreeRayCastCallback").virtualize())
.put(new Info("b2DynamicTree::Query<b2DynamicTreeQueryCallback>").javaNames("Query").define())
.put(new Info("b2DynamicTree::RayCast<b2DynamicTreeRayCastCallback>").javaNames("RayCast").define())
;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <Box2D/Common/b2Settings.h>

class b2DynamicTreeQueryCallback {
public:
virtual bool QueryCallback(int32 nodeId) = 0;
};

class b2DynamicTreeRayCastCallback {
public:
virtual bool RayCastCallback(b2RayCastInput& subInput, int32 nodeId) = 0;
};

0 comments on commit 7e48c5b

Please sign in to comment.