0

I'm working with Bullet and OpenGL and basically I have one body, that I want it to appear in the screen but not to suffer collisions.

It only has to be visual.

I'am creating the object like this:

btBoxShape* colShape = createBoxShape(btVector3(1, 1, 1));
m_collisionShapes.push_back(colShape);
btTransform startTransform;
startTransform.setIdentity();
btScalar mass(0.5f);
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0, 0, 0);
   if (isDynamic)
       colShape->calculateLocalInertia(mass, localInertia);
startTransform.setOrigin(btVector3(5.0, 0.5, 0.0));
createRigidBody(mass, startTransform, colShape);

It does not have to collide or interact with any other bullet body.

Is there any flag or something like that in order to get this?

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
aserrin55
  • 350
  • 5
  • 15

2 Answers2

1

Just draw whatever you want to draw, without passing it into the physics engine calculations. OpenGL is completely unconcerned with collision calculations, you can draw with OpenGL whatever you want.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • The fact is that in the code that I have written I only draw Bullet Bodies graphically, so that I want to know if its possible to disable collisions from a body instead of changing my code. – aserrin55 Apr 12 '17 at 10:56
  • @aserrin55 as such it would help to know which flag you're checking or what you're querying to decide what to draw and what not to draw. – vallentin Apr 12 '17 at 11:45
  • @Vallentin I have added a class that make every Bullet Body visual. Now, I want a flag or a configuration parameter that disables the collision of a concrete body. Thanks again – aserrin55 Apr 12 '17 at 14:22
  • @javaLover no, it did not – aserrin55 May 17 '17 at 21:35
  • 1
    @javaLover: It's really hard to give you further information without seeing the relevant parts of your code. However the key insight you have to understand is: OpenGL does not deal with collision detection or scene management at all. If you want to have some object the moves freely through the scene you simply don't subject it to the physics simulation and *just draw* it, whereever you want it to be. – datenwolf May 17 '17 at 22:36
  • @aserrin55 As an additional suggestion, you have to think physic-graphic as 2 separate systems. I feel that your both systems are too coupling. – javaLover May 18 '17 at 03:34
0

The easiest way to make a RigidBody not collide with anything is to set it's collision group and mask to 0.

When adding rigid body to the world

mWorld->addRigidBody(object, 0, 0);

Note, however that if it's a dynamic body it's going to be still affected by gravity and it will fall down. But of course you can use such configuration if you need it. Just keep in mind that it will ignore all collisions but forces can still be applied to such a body.

Elvithari
  • 834
  • 1
  • 8
  • 13