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

Binding for b2DynamicTree::Query #531

Merged
merged 3 commits into from
Mar 6, 2018
Merged
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 @@

* 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;
};