Skip to content

Commit e857c4d

Browse files
committed
WIP
1 parent 7a3d927 commit e857c4d

File tree

645 files changed

+207070
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

645 files changed

+207070
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
bullet3/build
22
bullet_old/build
3+
node_modules/
34
*.diff
45

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Copyright (c) 2011 ammo.js contributors
2+
3+
This software is provided 'as-is', without any express or implied
4+
warranty. In no event will the authors be held liable for any damages
5+
arising from the use of this software.
6+
7+
Permission is granted to anyone to use this software for any purpose,
8+
including commercial applications, and to alter it and redistribute it
9+
freely, subject to the following restrictions:
10+
11+
1. The origin of this software must not be misrepresented; you must not
12+
claim that you wrote the original software. If you use this software
13+
in a product, an acknowledgment in the product documentation would be
14+
appreciated but is not required.
15+
2. Altered source versions must be plainly marked as such, and must not be
16+
misrepresented as being the original software.
17+
3. This notice may not be removed or altered from any source distribution.
18+
19+
---
20+
21+
See AUTHORS for list of contributors.
22+

README.markdown

+173
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
ammo.js
2+
=======
3+
4+
5+
# Demos
6+
7+
* [Cubes](http://kripken.github.com/ammo.js/examples/webgl_demo/ammo.html)
8+
* [SoftBody-Rope](http://kripken.github.com/ammo.js/examples/webgl_demo_softbody_rope/index.html)
9+
* [SoftBody-Cloth](http://kripken.github.com/ammo.js/examples/webgl_demo_softbody_cloth/index.html)
10+
* [SoftBody-Volume](http://kripken.github.com/ammo.js/examples/webgl_demo_softbody_volume/index.html)
11+
* [Heightmap](http://kripken.github.com/ammo.js/examples/webgl_demo_terrain/index.html)
12+
13+
# Overview
14+
15+
**Example code to give you an idea of the API: https://github.com/kripken/ammo.js/blob/master/examples/webgl_demo/ammo.html#L14**
16+
17+
ammo.js is a direct port of the [Bullet physics engine](http://bulletphysics.org/) to JavaScript, using Emscripten. The source code is translated directly to JavaScript, without human rewriting, so functionality should be identical to the original Bullet.
18+
19+
**Note: ammo.js has just been updated to a new porting approach. If you find some part of the Bullet API that is not supported that you need, please see https://github.com/kripken/ammo.js/issues/60**
20+
21+
'ammo' stands for "Avoided Making My Own js physics engine by compiling bullet from C++" ;)
22+
23+
ammo.js is zlib licensed, just like Bullet.
24+
25+
Discussion takes place on IRC at #emscripten on Mozilla's server (irc.mozilla.org)
26+
27+
28+
Instructions
29+
------------
30+
31+
`builds/ammo.js` contains a prebuilt version of ammo.js. This is probably what you want.
32+
33+
You can also build ammo.js yourself, as follows:
34+
35+
* Get Emscripten
36+
37+
http://emscripten.org
38+
39+
and set it up. See
40+
41+
https://github.com/kripken/emscripten/wiki/Getting-started
42+
43+
* Run the build script,
44+
45+
`python make.py`
46+
47+
which should generate builds/ammo.js.
48+
49+
* Optionally, run the automatic tests,
50+
51+
`python test.py`
52+
53+
54+
Usage
55+
-----
56+
57+
The most straightforward thing is if you want to write your code in C++, and
58+
run that on the web. If so, then compile your code into LLVM, link it with
59+
bullet, and compile that to JavaScript using emscripten. (The easiest way to
60+
link it is to add your .bc file to the llvm-link command in make.py.)
61+
62+
If, on the other hand, you want to write code in JavaScript, you can use the
63+
autogenerated binding code. A complete example appears in
64+
65+
`examples/hello_world.js`
66+
67+
That is HelloWorld.cpp from Bullet, translated to JavaScript. Other examples
68+
in that directory might be useful as well. In particular see the WebGL
69+
demo code in
70+
71+
`examples/webgl_demo/ammo.html`
72+
73+
74+
Bindings API
75+
============
76+
77+
ammo.js autogenerates its API from the Bullet source code, so it should
78+
be basically identical. There are however some differences and things
79+
to be aware of:
80+
81+
* See https://github.com/kripken/emscripten/wiki/WebIDL-Binder
82+
for a description of the bindings tool we use here, which includes
83+
instructions for how to use the wrapped objects.
84+
85+
* All ammo.js elements should be accessed through `Ammo.*`. For example,
86+
`Ammo.btVector3`, etc., as you can see in the example code.
87+
88+
* Member variables of structs and classes can be accessed through
89+
setter and getter functions, that are prefixed with `|get_|` or `|set_|`.
90+
For example,
91+
92+
`rayCallback.get_m_rayToWorld()`
93+
94+
will get `m_rayToWorld` from say a `ClosestRayResultCallback`. Native
95+
JavaScript getters and setters could give a slightly nicer API here,
96+
however their performance is potentially problematic.
97+
98+
* Functions returning or getting `float&` or `btScalar&` are converted to
99+
float. The reason is that `float&` is basically `float*` with nicer syntax
100+
in C++, but from JavaScript you would need to write to the heap every
101+
time you call such a function, making usage very ugly. With this change,
102+
you can do `|new btVector3(5, 6, 7)|` and it will work as expected. If
103+
you find a case where you need the float& method, please file an issue.
104+
105+
* Not all classes are exposed, as only what is described in ammo.idl is
106+
wrapped. Please submit pull requests with extra stuff that you need
107+
and add.
108+
109+
* There is experimental support for binding operator functions. The following
110+
might work:
111+
112+
| Operator | Name in JS |
113+
|---|---|
114+
| `=` | `op_set` |
115+
| `+` | `op_add` |
116+
| `-` | `op_sub` |
117+
| `*` | `op_mul` |
118+
| `/` | `op_div` |
119+
| `[]` | `op_get` |
120+
| `==` | `op_eq` |
121+
122+
123+
Troubleshooting
124+
===============
125+
126+
* It's easy to forget to write |new| when creating an object, for
127+
example
128+
129+
`var vec = Ammo.btVector3(1,2,3); // This is wrong! Need 'new'!`
130+
131+
This can lead to error messages like the following:
132+
133+
`Cannot read property 'a' of undefined`
134+
`Cannot read property 'ptr' of undefined`
135+
136+
This is an annoying aspect of JavaScript, sadly.
137+
138+
139+
Reporting Issues
140+
================
141+
142+
If you find a bug in ammo.js and file an issue, please include a script
143+
that reproduces the problem. That way it is easier to debug, and we can
144+
then include that script in our automatic tests.
145+
146+
147+
Release Process
148+
===============
149+
150+
Pushing a new build in `builds/ammo.js` should be done only after the
151+
following steps:
152+
153+
* Build a safe build and make sure it passes all automatic tests. Safe
154+
builds contain a lot of runtime assertions that can catch potential
155+
bugs (similar to the sort of things valgrind can catch).
156+
157+
* Build a fast build and make sure it passes all automatic tests.
158+
159+
* Run closure compiler on that fast build and make sure it passes
160+
all automatic tests.
161+
162+
* Make sure that the stress test benchmark did not regress
163+
compared to the old build.
164+
165+
* Run the WebGL demo in examples/webgl_demo and make sure it looks
166+
ok.
167+
168+
169+
Upstream Version
170+
================
171+
172+
Bullet 2.82
173+

bullet3/Extras/CMakeLists.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
SUBDIRS( Serialize ConvexDecomposition HACD GIMPACTUtils )
2+
3+
IF(BUILD_BULLET3)
4+
SUBDIRS( InverseDynamics)
5+
ENDIF()
6+
7+
#Maya Dynamica plugin is moved to http://dynamica.googlecode.com
8+
9+
#IF (USE_GLUT AND GLUT_FOUND)
10+
# SUBDIRS (glui)
11+
#ENDIF ()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
INCLUDE_DIRECTORIES(
2+
${BULLET_PHYSICS_SOURCE_DIR}/Extras/ConvexDecomposition ${BULLET_PHYSICS_SOURCE_DIR}/src
3+
)
4+
5+
SET(ConvexDecomposition_SRCS
6+
bestfitobb.cpp
7+
ConvexBuilder.cpp
8+
cd_wavefront.cpp
9+
fitsphere.cpp
10+
meshvolume.cpp
11+
raytri.cpp
12+
vlookup.cpp
13+
bestfit.cpp
14+
cd_hull.cpp
15+
ConvexDecomposition.cpp
16+
concavity.cpp
17+
float_math.cpp
18+
planetri.cpp
19+
splitplane.cpp
20+
)
21+
22+
SET(ConvexDecomposition_HDRS
23+
ConvexDecomposition.h
24+
cd_vector.h
25+
concavity.h
26+
bestfitobb.h
27+
ConvexBuilder.h
28+
cd_wavefront.h
29+
fitsphere.h
30+
meshvolume.h
31+
raytri.h
32+
vlookup.h
33+
bestfit.h
34+
cd_hull.h
35+
)
36+
37+
ADD_LIBRARY(ConvexDecomposition ${ConvexDecomposition_SRCS} ${ConvexDecomposition_HDRS})
38+
SET_TARGET_PROPERTIES(ConvexDecomposition PROPERTIES VERSION ${BULLET_VERSION})
39+
SET_TARGET_PROPERTIES(ConvexDecomposition PROPERTIES SOVERSION ${BULLET_VERSION})
40+
41+
IF (BUILD_SHARED_LIBS)
42+
TARGET_LINK_LIBRARIES(ConvexDecomposition BulletCollision LinearMath)
43+
ENDIF (BUILD_SHARED_LIBS)
44+
45+
IF (INSTALL_EXTRA_LIBS)
46+
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
47+
#FILES_MATCHING requires CMake 2.6
48+
IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
49+
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
50+
INSTALL(TARGETS ConvexDecomposition DESTINATION .)
51+
ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
52+
INSTALL(TARGETS ConvexDecomposition DESTINATION lib${LIB_SUFFIX})
53+
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
54+
DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN
55+
".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
56+
ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
57+
ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
58+
59+
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
60+
SET_TARGET_PROPERTIES(ConvexDecomposition PROPERTIES FRAMEWORK true)
61+
SET_TARGET_PROPERTIES(ConvexDecomposition PROPERTIES PUBLIC_HEADER "${ConvexDecomposition_HDRS}")
62+
ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
63+
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
64+
ENDIF (INSTALL_EXTRA_LIBS)

0 commit comments

Comments
 (0)