Crate liquidfun [] [src]

Rust bindings for LiquidFun.

Repository

Anything with a B2 prefix indicates ffi boundry with the C++ API.

User Data

Some objects in LiquidFun allow you to attach your own data to them. These are bound as usize. You can store raw pointers to your data there.

usage: move raw pointer in: &user_data as *const T as size_t;

dereference raw pointer out: *(user_data as *const T)

example:
ground_body_def.user_data = &Vec2::new(6.0, 66.0) as *const Vec2 as usize;

Passing structs by value from C++ to Rust

// C++
struct b2Vec2 {
    b2Vec2() {}
    ...
    float32 x, y;
};
 
// new C struct
typedef struct c_b2Vec2 { float32 x, y; } c_b2Vec2;
c_b2Vec2* cast(b2Vec2* v) {
    return reinterpret_cast<c_b2Vec2*>(v);
}
 
c_b2Vec2 sendStructFromCppToRustByValue() {
    b2Vec2 tmp;
    return *cast(&tmp);
}

Modules

box2d

Canonical Liquid Fun bindings.

ext

Extra idomatic Rust features.