Skip to content

Commit

Permalink
updated for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
geekrelief committed May 22, 2021
1 parent 325d006 commit dea47ab
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 66 deletions.
92 changes: 46 additions & 46 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
# Godot bindings for the Rapier3D physics library

## How to use
There are two parts:

There are two parts:
* A Godot module which must be compiled with the engine. This is necessary to
communicate with the library through the PhysicsServer
* A library with the actual bindings

* A Godot module which must be compiled with the engine. This is necessary to
communicate with the library through the PhysicsServer
* A library with the actual bindings
## Linux:

1. Run `module/generate.py` first
2. Then, either make a symlink or copy the contents of `module` to the engine source
3. Build the engine
4. Build the library with the provided `Makefile` using `make`
5. Set `3d/physics_engine` to `Custom`
- Run `module/generate.py` first
- Then, either make a symlink or copy the contents of `module` to the engine source `modules/pluggable_physics`
- Build the engine
- Build the library with the provided `Makefile` using `make`
- Set `3d/physics_engine` to `Custom`

Note that these instructions have only been tested on Linux. If you have
difficulties, please contact me or open an issue.
## Windows:
- Run `python module/generate.py`
- Copy `module/api.json` to `rapier3d/api.json`
- Then, either make a symlink or copy the contents of `module` to the engine source `modules/pluggable_physics`
- Build the engine
- Build the library following these steps:
- ensure `LIBCLANG_PATH` environment variable is set to llvm's bin folder containing `libclang.dll`
- `rustup default nightly-msvc`
- If you get an error try: `cargo update`
- run `build_win.bat`
- Set `3d/physics_engine` to `Custom`

If you have difficulties, please contact me or open an issue.

# The editor may crash if you keep `3d/physics_engine` set to `Custom`. If it does, uncomment it in `project.godot`
2 changes: 2 additions & 0 deletions addons/rapier3d/rapier3d.gdnlib
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ reloadable=false
[entry]

X11.64="res://addons/rapier3d/lib/librapier3d.so"
Windows.64="res://addons/rapier3d/lib/rapier3d.dll"

[dependencies]

X11.64=[ ]
Windows.64=[ ]
3 changes: 3 additions & 0 deletions build_win.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off
cargo build --target x86_64-pc-windows-msvc --release
cp target/x86_64-pc-windows-msvc/release/rapier3d.dll addons/rapier3d/lib/rapier3d.dll
2 changes: 1 addition & 1 deletion module/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


PluggablePhysicsServer::PluggablePhysicsServer() {
zeromem(&this->fn_table, sizeof(this->fn_table));
memset(&this->fn_table, 0, sizeof(this->fn_table));
this->body_state_singleton = memnew(PluggablePhysicsDirectBodyState(this));
this->space_state_singleton = memnew(PluggablePhysicsDirectSpaceState(this));
this->body_state_singleton->space_state_singleton = this->space_state_singleton;
Expand Down
16 changes: 8 additions & 8 deletions module/space_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ bool PluggablePhysicsDirectSpaceState::intersect_ray(const Vector3 &from, const
}

struct physics_ray_info info = {
.from = from,
.to = to,
.exclude = e_list,
.exclude_count = (size_t)exclude.size(),
.collision_mask = collision_mask,
.collide_with_bodies = collide_with_bodies,
.collide_with_areas = collide_with_areas,
.pick_ray = pick_ray,
from,
to,
e_list,
(size_t)exclude.size(),
collision_mask,
collide_with_bodies,
collide_with_areas,
pick_ray,
};
struct physics_ray_result prr = {};
bool collided = (*this->server->fn_table.space_intersect_ray)(this->space, &info, &prr);
Expand Down

0 comments on commit dea47ab

Please sign in to comment.