stephengold / Libbulletjme

A JNI interface to Bullet Physics and V-HACD
https://stephengold.github.io/Libbulletjme/lbj-en/English/overview.html
Other
84 stars 10 forks source link

Question about min/max size when creating physics space #9

Closed tmvkrpxl0 closed 2 years ago

tmvkrpxl0 commented 2 years ago

Hello, I have question about setting min/max size when creating physics space AFAIK, it is not required to set max size when creating discrete dynamics world with dbvt, but I need to provide it when using this library Does the input size important even If I use dbvt? and Can I set it really big values without worrying about performance?

My plan is to use this library in minecraft mod, and I originally used Jbullet from 10 years ago. I have switched from original Jbullet to this library after I realized I need double precision I need to make bullet physics work on any coordinates in any minecraft world.

tmvkrpxl0 commented 2 years ago

Also, I'm not seeing debug drawer in this library, Is there alternative way to draw it?

stephengold commented 2 years ago

Thanks for reaching out to me. I'm always curious how my work is being reused.

The max/min coordinate values are ignored when using DBVT broadphase acceleration, so there shouldn't be any measurable performance impact. There's even a single-argument constructor for PhysicsSpace which you can use to avoid having to specify max/min coordinate values.

The library does not provide access to Bullet's debug drawer. That's because I mostly use the library with JMonkeyEngine, which has its own debug drawer. I'll add "debug drawer" to the "What's missing" list in the README.

tmvkrpxl0 commented 2 years ago

I see, I expected it to work with double precision but I don't see a way to do so, even though there's native libraries for double precision. Is there way to use double precision on java binding? All values in Transform is float, and It mostly, if not only, uses Vector3f

stephengold commented 2 years ago

The JNI interface is entirely single-precision. The "Dp" native libraries use double precision internally, but use the single-precision interface to communicate with Java.

stephengold commented 2 years ago

Adding double-precision methods to the library wouldn't be difficult. If you tell me which methods you think would be most useful, I'll start adding them. Along with Vec3d, Quatd, Matrix3d, and so on.

tmvkrpxl0 commented 2 years ago

Adding double-precision methods to the library wouldn't be difficult. If you tell me which methods you think would be most useful, I'll start adding them. Along with Vec3d, Quatd, Matrix3d, and so on.

I'd like to contribute on this project. As it seems that I'll need to work with mostly double. I have not worked with JNI before, but I'll try

stephengold commented 2 years ago

I don't need contributed code. Just tell me which methods you would use, and I'll create double-precision versions of those methods.

tmvkrpxl0 commented 2 years ago

I don't need contributed code. Just tell me which methods you would use, and I'll create double-precision versions of those methods.

They are no actually methods. I need a way to set/get position and velocity of a rigid body in double precision. Currently it uses Matrix4f or Vector3f to interface with native library. I need it to use Matrix4d and Vector3d instead

stephengold commented 2 years ago

I'll add double-precision versions of

in the next release.

tmvkrpxl0 commented 2 years ago

Thank you

stephengold commented 2 years ago

The anticipated release is now available: https://github.com/stephengold/Libbulletjme/releases/tag/12.1.1

I'll be very interested in any feedback you have on the new double-precision accessors:

tmvkrpxl0 commented 2 years ago

Thank you. I have one more question, I want to render physical object myself, as I'm using it with minecraft. How do I get world position of each vertices of a rigid body?

stephengold commented 2 years ago

If you created the body's collision shape using MeshCollisionShape or GImpactCollisionShape or HeightfieldCollisionShape, then your application knows the position of every vertex and triangle in the mesh.

In any event, you can use DebugShapeFactory.getDebugTriangles() to generate a triangle mesh that approximates a specified collision shape.

tmvkrpxl0 commented 2 years ago

Thank you