making a body without a shape.

I was going to post, and say that I can't get my particles to move, but then I realized that That was probably because I hadn't given them a shape. I assume that a body is assumed to be static by the integrator if it has no shape(more specifically, no mass)

I gave it no mass because I wanted it not to collide. I just realized that this engine would be quite wasteful with these particles. They don't collide, thy don't rotate, they don't even have acceleration. Overhead for these things is a waste of processing power.

Anyway, I wondered about the role of shape. What would you do if you wanted an object to move under the influence of forces, but not collide? Is it possible to make things collide without affecting the thing they ran into? I ask because I have vague notions of massless energy spiders that collide with each other and objects, but without affecting what it runs into. I got that when I was reading ODE's docs on collision callbacks.

The idea is that they are attracted and affected by electromagnetic fields, and live in the sun when not harassing passing fusion torchships, or giving birth to magnetic monopoles in the helium oceans of planet x.

I still have another question. Why does this line(python):
print vel.x, vel.y, self.body.GetLinearVelocity().x,self.body.GetLinearVelocity().y

cause my time/frame to quadruple? I know it's not the print, because I've had much more elaborate print statements in the past.

It gets executed twice per turn while under thrust. Framerate is 60fps nominally.

Edit: Why don't your vectors support multiplication by a float? I tried to multiply velocity by dT and python threw an exception.
A body is a container and interface for holding and manipulating shapes. You may as well take the engine out of your car and ask why the gas pedal doesn't do anything when you press it 😉

If you want things to register collisions, but not react physically, use sensors (much information on the forums here). If you want objects to pass directly through other certain objects, and not register collisions either, use categoryBits and maskBits. These are also explained in the manual and on the forums. There is no official release yet with sensors though, but the source in the SVN supports them.

Your other problems seem specific to Python, which I don't know anything about. I'm multiplying vectors by floats in Flash just fine. Maybe someone else who has more experience in that area can help.
It's possible the automatic code translation didn't do a perfect job translating the operator overloading. Looking at the code, it seems only vec*=float is defined, so you might want to try that instead.

You're print statement doesn't look too hard to run, but it could be slowing your code down through sheer number of characters output. If you're running that for 100 objects, 60 times a second, it'll have difficulties feeding it all through, I should image. You are calling GetLinearVelocity() twice, which would be bad if it is an expensive function (it isn't), so you could try replacing it with one call, and use a variable.
My experience with Python is limited, but from what I have done I remember that print statements can often bottleneck the program, esp. @ 60 fps - to see if this is the case, try swapping that statement with one that just prints a static string of roughly the length of the tuple that you're creating. If the frame rate drops the same amount, it's just the print, don't worry about it, otherwise there's likely a problem with the GetLinearVelocity function which should be addressed.

BTW, how is the performance of the Python wrapped library overall? Has anyone tried running Box2d on an OLPC XO laptop? I'm soon going to update a game I wrote for that platform during a game jam, and I was considering swapping out my hacked together physics library for Box2d if it looks like it will run okay despite the Python<->C++ interface.
Yeah, Python's print is the bottleneck. Would not have figured that!
I'm not sure about the performance of the python bindings. They don't seem to be too slow. At least they out perform ODE, but that's a given.

As for taking the shape out of the body: I don't think that's an obvious metaphor. It seems to me that a body should behave as a rigid body in a free body diagram, reacting to the forces applied to it, and the shape should collect and feed collision data to that free body. That's how ODE, which is what I was using before, did it. *shrugs* Different libraries, different internals.
TimRau wrote:
As for taking the shape out of the body: I don't think that's an obvious metaphor. It seems to me that a body should behave as a rigid body in a free body diagram, reacting to the forces applied to it, and the shape should collect and feed collision data to that free body. That's how ODE, which is what I was using before, did it. *shrugs* Different libraries, different internals.
Man, when you phrase it like that, I do have difficulties seeing what's wrong with shapeless bodies. 1.4.3 takes zero mass to mean a static body, but perhaps all that is necessary is to explicitly set the mass of your shapeless body, and remove a few asserts? 2.0 looks even better behaved, though I haven't tried either.

It still begs the question of why you would want shapeless bodies. True, you can apply external forces to them to move them around in physically accurate ways, but with no interaction with other objects or each other, you are not really using the Box2d engine to do anything. Integrating forces and velocities up into position is trivial in itself, you might as well implement these particles outside the engine.
Box2D 2.0 should support shapeless bodies. I will fix it if it doesn't.

One use of shapeless bodies would be for simulating machines that don't need collision, or certain linkages that don't collide.

Original thread: https://box2d.org/forum/viewtopic.php?t=347