Skip to content

Commit

Permalink
* Add presets for Bullet Physics SDK 3.21 (pull #1153)
Browse files Browse the repository at this point in the history
  • Loading branch information
mode89 authored Mar 28, 2022
1 parent 769f213 commit c5cdae9
Show file tree
Hide file tree
Showing 801 changed files with 68,325 additions and 1 deletion.
64 changes: 64 additions & 0 deletions .github/workflows/bullet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: bullet
on:
push:
paths:
- bullet/**
pull_request:
paths:
- bullet/**
workflow_dispatch:
env:
CI_DEPLOY_MODULE: ${{ github.workflow }}
CI_DEPLOY_PLATFORM: ${{ github.job }}
CI_DEPLOY_SETTINGS: ${{ secrets.CI_DEPLOY_SETTINGS }}
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
STAGING_REPOSITORY: ${{ secrets.STAGING_REPOSITORY }}
jobs:
android-arm:
runs-on: ubuntu-18.04
container: centos:7
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-centos@actions
android-arm64:
runs-on: ubuntu-18.04
container: centos:7
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-centos@actions
android-x86:
runs-on: ubuntu-18.04
container: centos:7
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-centos@actions
android-x86_64:
runs-on: ubuntu-18.04
container: centos:7
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-centos@actions
linux-x86:
runs-on: ubuntu-18.04
container: centos:7
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-centos@actions
linux-x86_64:
runs-on: ubuntu-18.04
container: centos:7
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-centos@actions
macosx-x86_64:
runs-on: macos-10.15
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-macosx@actions
windows-x86:
runs-on: windows-2019
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-windows@actions
windows-x86_64:
runs-on: windows-2019
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-windows@actions
redeploy:
needs: [android-arm, android-arm64, android-x86, android-x86_64, linux-x86, linux-x86_64, macosx-x86_64, windows-x86, windows-x86_64]
runs-on: ubuntu-18.04
steps:
- uses: bytedeco/javacpp-presets/.github/actions/redeploy@actions
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Add presets for Bullet Physics SDK 3.21 ([pull #1153](https://github.com/bytedeco/javacpp-presets/pull/1153))
* Add `long[] pytorch.Tensor.shape()` method for convenience ([pull #1161](https://github.com/bytedeco/javacpp-presets/pull/1161))
* Enable DNNL codegen as BYOC backend in presets for TVM
* Allow passing raw pointer as deleter to `from_blob()`, etc functions of PyTorch ([discussion #1160](https://github.com/bytedeco/javacpp-presets/discussions/1160))
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ JavaCPP Presets
[![ngraph](https://github.com/bytedeco/javacpp-presets/workflows/ngraph/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Angraph)
[![onnxruntime](https://github.com/bytedeco/javacpp-presets/workflows/onnxruntime/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Aonnxruntime)
[![tvm](https://github.com/bytedeco/javacpp-presets/workflows/tvm/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Atvm)
[![bullet](https://github.com/bytedeco/javacpp-presets/workflows/bullet/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Abullet)
[![liquidfun](https://github.com/bytedeco/javacpp-presets/workflows/liquidfun/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Aliquidfun)
[![qt](https://github.com/bytedeco/javacpp-presets/workflows/qt/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Aqt)
[![skia](https://github.com/bytedeco/javacpp-presets/workflows/skia/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Askia)
Expand Down Expand Up @@ -224,6 +225,7 @@ Each child module in turn relies by default on the included [`cppbuild.sh` scrip
* nGraph 0.26.0 https://github.com/NervanaSystems/ngraph
* ONNX Runtime 1.11.x https://github.com/microsoft/onnxruntime
* TVM 0.8.x https://github.com/apache/tvm
* Bullet Physics SDK 3.21 https://pybullet.org
* LiquidFun http://google.github.io/liquidfun/
* Qt 5.15.x https://download.qt.io/archive/qt/
* Mono/Skia 2.80.x https://github.com/mono/skia
Expand Down
15 changes: 15 additions & 0 deletions bullet/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

The files in this repository are licensed under the zlib license, except for the files under 'Extras' and examples/ThirdPartyLibs.

Bullet Continuous Collision Detection and Physics Library
http://bulletphysics.org

This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
166 changes: 166 additions & 0 deletions bullet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
JavaCPP Presets for Bullet Physics SDK
======================================

[![Gitter](https://badges.gitter.im/bytedeco/javacpp.svg)](https://gitter.im/bytedeco/javacpp) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.bytedeco/bullet/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.bytedeco/bullet) [![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.bytedeco/bullet.svg)](http://bytedeco.org/builds/)
<sup>Build status for all platforms:</sup> [![bullet](https://github.com/bytedeco/javacpp-presets/workflows/bullet/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Abullet) <sup>Commercial support:</sup> [![xscode](https://img.shields.io/badge/Available%20on-xs%3Acode-blue?style=?style=plastic&logo=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRF////////VXz1bAAAAAJ0Uk5T/wDltzBKAAAAlUlEQVR42uzXSwqAMAwE0Mn9L+3Ggtgkk35QwcnSJo9S+yGwM9DCooCbgn4YrJ4CIPUcQF7/XSBbx2TEz4sAZ2q1RAECBAiYBlCtvwN+KiYAlG7UDGj59MViT9hOwEqAhYCtAsUZvL6I6W8c2wcbd+LIWSCHSTeSAAECngN4xxIDSK9f4B9t377Wd7H5Nt7/Xz8eAgwAvesLRjYYPuUAAAAASUVORK5CYII=)](https://xscode.com/bytedeco/javacpp-presets)


Introduction
------------
This directory contains the JavaCPP Presets module for:

* Bullet Physics SDK 3.21 https://github.com/bulletphysics/bullet3

Please refer to the parent README.md file for more detailed information about the JavaCPP Presets.


Documentation
-------------
Java API documentation is available here:

* http://bytedeco.org/javacpp-presets/bullet/apidocs/


### Special Mappings
Mappings of `btAlignedObjectArray`'s instances for privitime types:

| C++ | Java |
|--------------------------------------|-----------------|
| `btAlignedObjectArray<bool>` | `btBoolArray` |
| `btAlignedObjectArray<char>` | `btCharArray` |
| `btAlignedObjectArray<int>` | `btIntArray` |
| `btAlignedObjectArray<unsigned int>` | `btUIntArray` |
| `btAlignedObjectArray<btScalar>` | `btScalarArray` |

Name of a Java class, corresponding to an instance of `btAlignedObjectArray`
for a composite type, is constructed by adding `Array` suffix to the name of
the composite type, e.g. `btAlignedObjectArray<btQuaternion>` maps to
`btQuaternionArray`.


Sample Usage
------------
Here is a simple example of Bullet Physics SDK ported to Java and based on code found from:

* https://github.com/bulletphysics/bullet3/tree/3.21/examples/

We can use [Maven 3](http://maven.apache.org/) to download and install automatically all the class files as well as the native binaries. To run this sample code, after creating the `pom.xml` and `SimpleBox.java` source files below, simply execute on the command line:
```bash
$ mvn compile exec:java
```

### The `pom.xml` build file
```xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.bytedeco.bullet</groupId>
<artifactId>samples</artifactId>
<version>1.5.8-SNAPSHOT</version>
<properties>
<exec.mainClass>SimpleBox</exec.mainClass>
</properties>
<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>bullet-platform</artifactId>
<version>3.21-1.5.8-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>.</sourceDirectory>
</build>
</project>
```

### The `SimpleBox.java` source file
```java
import org.bytedeco.javacpp.*;
import org.bytedeco.bullet.BulletCollision.*;
import org.bytedeco.bullet.BulletDynamics.*;
import org.bytedeco.bullet.LinearMath.*;

public class SimpleBox {

private static btDefaultCollisionConfiguration m_collisionConfiguration;
private static btCollisionDispatcher m_dispatcher;
private static btBroadphaseInterface m_broadphase;
private static btConstraintSolver m_solver;
private static btDiscreteDynamicsWorld m_dynamicsWorld;

public static void main(String[] args)
{
createEmptyDynamicsWorld();

btBoxShape groundShape = new btBoxShape(new btVector3(50, 50, 50));

btTransform groundTransform = new btTransform();
groundTransform.setIdentity();
groundTransform.setOrigin(new btVector3(0, -50, 0));

createRigidBody(0, groundTransform, groundShape);

btBoxShape colShape = new btBoxShape(new btVector3(1, 1, 1));
float mass = 1.0f;

colShape.calculateLocalInertia(mass, new btVector3(0, 0, 0));

btTransform startTransform = new btTransform();
startTransform.setIdentity();
startTransform.setOrigin(new btVector3(0, 3, 0));
btRigidBody box = createRigidBody(mass, startTransform, colShape);

for (int i = 0; i < 10; ++ i)
{
m_dynamicsWorld.stepSimulation(0.1f, 10, 0.01f);
btVector3 position = box.getWorldTransform().getOrigin();
System.out.println(position.y());
}

System.out.println(
"\n" +
"This sample simulates falling of a rigid box, followed by \n" +
"an inelastic collision with a ground plane.\n" +
"The numbers show height of the box at each simulation step. \n" +
"It should start around 3.0 and end up around 1.0.\n");
}

private static void createEmptyDynamicsWorld()
{
m_collisionConfiguration = new btDefaultCollisionConfiguration();
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
m_broadphase = new btDbvtBroadphase();
m_solver = new btSequentialImpulseConstraintSolver();
m_dynamicsWorld = new btDiscreteDynamicsWorld(
m_dispatcher, m_broadphase, m_solver, m_collisionConfiguration);
m_dynamicsWorld.setGravity(new btVector3(0, -10, 0));
}

private static btRigidBody createRigidBody(
float mass,
btTransform startTransform,
btCollisionShape shape)
{
boolean isDynamic = (mass != 0.f);

btVector3 localInertia = new btVector3(0, 0, 0);
if (isDynamic)
shape.calculateLocalInertia(mass, localInertia);

btDefaultMotionState motionState = new btDefaultMotionState(
startTransform, btTransform.getIdentity());

btRigidBody.btRigidBodyConstructionInfo cInfo =
new btRigidBody.btRigidBodyConstructionInfo(
mass, motionState, shape, localInertia);

btRigidBody body = new btRigidBody(cInfo);

body.setUserIndex(-1);
m_dynamicsWorld.addRigidBody(body);

return body;
}
}
```

See the [samples](samples) subdirectory for more.
Loading

0 comments on commit c5cdae9

Please sign in to comment.