not-fl3 / bulletrs

Bullet Physics wrapper for the Rust language.
MIT License
49 stars 2 forks source link

add support for Box shapes #4

Closed jice-nospam closed 7 years ago

not-fl3 commented 7 years ago

Thanks for PR! Reviewing your changes I found a problem in my code :) as far as I know using &mut something[0] is not guaranteed to be safe. Now its a little better: https://github.com/not-fl3/bulletrs/commit/35c57c3f44e39cc1114d84f53b104d8ea7daaf46

jice-nospam commented 7 years ago

nice. I'm quite new to rust and bullet, but I need a rust physics engine for my current project, so I'm interested in contributing to bulletrs if there is stuff to do.

2017-10-22 12:23 GMT+02:00 Fedor Logachev notifications@github.com:

Thanks for PR! Reviewing your changes I found a problem in my code :) as far as I know using &mut something[0] is not guaranteed to be safe. 35c57c3 https://github.com/not-fl3/bulletrs/commit/35c57c3f44e39cc1114d84f53b104d8ea7daaf46

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/not-fl3/bulletrs/pull/4#issuecomment-338466889, or mute the thread https://github.com/notifications/unsubscribe-auth/AHcbD0f8K7esCc-RdWBvf8n_FNphVdYwks5suxepgaJpZM4QBt8l .

not-fl3 commented 7 years ago

Do you actually use bulletrs for your project now? Feel free to open issues for missed features, I will try to implement it or at least will give some implementation advices. Next thing to implement on my roadmap - is joints API, I think I'll start working on them in a few days.

If you just want to play with bulletrs for a little - check that issue https://github.com/not-fl3/bulletrs/issues/5, let's build more gifs for readme :)

jice-nospam commented 7 years ago

I'm currently using nphysics and trying to port my code to bulletrs.

What I'm missing so far is being able to set a rigid body velocity. The old bullet API had a btRigidBody::setLinearVelocity function but I can't find an equivalent function in the new PhysicsClientAPI.

As far as I understand, the physics_client.rs module only covers a few features of the complete PhysicsClientAPI. I can help you adding them if needed. I'll probably need a few of them for my project anyway.

-------- Original Message -------- Subject: Re: [not-fl3/bulletrs] add support for Box shapes (#4) Local Time: 22 October 2017 8:31 PM UTC Time: 22 October 2017 18:31 From: notifications@github.com To: not-fl3/bulletrs bulletrs@noreply.github.com jice-nospam jice.nospam@gmail.com, Author author@noreply.github.com

Do you actually use bulletrs for your project now? Feel free to open issues for missed features, I will try to implement it or at least will give some implementation advices. Next thing to implement on my roadmap - is joints API, I think I'll start working on them in a few days.

If you just want to play with bulletrs for a little - check that issue #5, let's build more gifs for readme :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

not-fl3 commented 7 years ago

Exactly, bulletrs covers some subset of PhysicsClient. The problem here - that PhysicsClient is abstraction over RigidBodyis and MultiBodys, which works perfectly for robots, but as for me - is not so good for general purpose game engine. This is why I am seriously considering moving away from PhysicsClient, but not still sure yet. For now - bulletrs covers most of my game's needs, let's see how it will go with joints.

I'll describe the current process of adding new functions:

For setLinearVelocity: Check pybullet's documentation for some similar method. https://docs.google.com/document/d/10sXEhzFRSnvFcl3XxNGhnD4N2SedqwdAvK3dsihxVUA/edit#

If you is lucky and your method is in pybullet (it is, check resetBaseVelocity, it is doing the same thing) - go to implementation: https://github.com/not-fl3/bullet3/blob/086ed37faf53d06bdb7ca7c919e95aeb0414784f/examples/pybullet/pybullet.c#L2633 You is interested in this code:

            commandHandle = b3CreatePoseCommandInit(sm, bodyUniqueId);

            if (linVelObj)
            {
                pybullet_internalSetVectord(linVelObj, linVel);
                b3CreatePoseCommandSetBaseLinearVelocity(commandHandle, linVel);
            }

            if (angVelObj)
            {
                pybullet_internalSetVectord(angVelObj, angVel);
                b3CreatePoseCommandSetBaseAngularVelocity(commandHandle, angVel);
            }

statusHandle = b3SubmitClientCommandAndWaitStatus(sm, commandHandle);

Now go here https://github.com/not-fl3/bulletrs/blob/master/src/command.rs#L232 for command reference implementation.

And then add method to rigidbody.rs like that one: https://github.com/not-fl3/bulletrs/blob/master/src/rigidbody.rs#L124

And if it is possible add some test. For example for set linear velocity - you could create rigidbody, than change velocity, then check that body actually moved to some point with that velocity.

But! If you will not found your method in pybullet's doc - you have a problem and you will need to write a lot of c++ :) https://github.com/not-fl3/bullet3/commit/3db95e56931f702d6efe0fbc5f2c05aa5f90655c its the reference implementation of one of unimplemented in PhysicsClient method - ApplyCentralImpulse.

jice-nospam commented 7 years ago

ok, thanks for all the information, I'll probably do some pull requests in the upcoming days :)

The advantage of PhysicsClient API is that it's network-ready. Not something I need for my game, but still nice to have. But yeah, it seems to have a lot less features than the old API.

-------- Original Message --------

Subject: Re: [not-fl3/bulletrs] add support for Box shapes (#4) Local Time: 22 October 2017 11:48 PM UTC Time: 22 October 2017 21:48 From: notifications@github.com To: not-fl3/bulletrs bulletrs@noreply.github.com jice-nospam jice.nospam@gmail.com, Author author@noreply.github.com

Exactly, bulletrs covers some subset of PhysicsClient. The problem here - that PhysicsClient is abstraction over RigidBodyis and MultiBodys, which works perfectly for robots, but as for me - is not so good for general purpose game engine. This is why I am seriously considering moving away from PhysicsClient, but not still sure yet. For now - bulletrs covers most of my game's needs, let's see how it will go with joints.

I'll describe the current process of adding new functions:

For setLinearVelocity: Check pybullet's documentation for some similar method. https://docs.google.com/document/d/10sXEhzFRSnvFcl3XxNGhnD4N2SedqwdAvK3dsihxVUA/edit#

If you is lucky and your method is in pybullet (it is, check resetBaseVelocity, it is doing the same thing) - go to implementation: https://github.com/not-fl3/bullet3/blob/086ed37faf53d06bdb7ca7c919e95aeb0414784f/examples/pybullet/pybullet.c#L2633 You is interested in this code:

commandHandle = b3CreatePoseCommandInit(sm, bodyUniqueId);

      if (linVelObj)
      {
          pybullet_internalSetVectord(linVelObj, linVel);
          b3CreatePoseCommandSetBaseLinearVelocity(commandHandle, linVel);
      }

      if (angVelObj)
      {
          pybullet_internalSetVectord(angVelObj, angVel);
          b3CreatePoseCommandSetBaseAngularVelocity(commandHandle, angVel);
      }

statusHandle = b3SubmitClientCommandAndWaitStatus(sm, commandHandle);

Now go here https://github.com/not-fl3/bulletrs/blob/master/src/command.rs#L232 for command reference implementation.

And then add method to rigidbody.rs like that one: https://github.com/not-fl3/bulletrs/blob/master/src/rigidbody.rs#L124

And if it is possible add some test. For example for set linear velocity - you could create rigidbody, than change velocity, then check that body actually moved to some point with that velocity.

But! If you will not found your method in pybullet's doc - you have a problem and you will need to write a lot of c++ :) not-fl3/bullet3@3db95e5 its the reference implementation of one of unimplemented in PhysicsClient method - ApplyCentralImpulse.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.