Problems with creating shapes

I 'm writing a little game, but I've got problems when creating my shapes.
I store a pointer to the b2World in my class IWorld
Code:
class IWorld
{
public:
   IWorld(f64 g, f32 lbound, f32 ubound);
   ~IWorld(void);
   void Draw(IVideoDriver* video) const; //drawing
    f64 g;
   IEntity* AddEnt(const IEntity& ent); //adding entities to the world, Bodies are created here
    bool RemoveEnt(u32 index);
   bool RemoveEnt(IEntity* ent);
   void Refresh(); //Updates position and angle values

   b2World* physics;
private:   
std::vector<IEntity> ents;

};


The IEntity class stores the graphics and some definitions for the bodies, and a vector for b2ShapeDefs

Code:
class IEntity
{
public:
   IEntity(ITexture* text, bool usePhysics=false);
   IEntity(ITexture* text, std::vector<b2ShapeDef> shapes);
   IEntity(ITexture* text, position2d<s32> pos, rect<s32> sourceRect, std::vector<b2ShapeDef> shapes);
   IEntity(ITexture* text, position2d<s32> pos, rect<s32> sourceRect);
   IEntity(ITexture* text, b2ShapeDef shape);
   IEntity();
   ~IEntity(void);
   void SetFlag(u32 flag, bool value);
   //void Refresh(); // not needed

   ITexture* graf;
   rect<s32> srcRect;
   position2d<s32> pos;
   f32 angle; //intial angle, later it's updated from the body every frame
   b2Body* physics;
   std::vector<b2ShapeDef> shapes; //Storing the Shapedefs until creating the body
    f32 mass; //ha nem használunk automass-t
   
   std::vector<bool> flags;
private:
   void SetFlagSize(); //saving some lines of code with this
};


The error happens when creating the shapes for the body in IWorld::AddEnt, something in a file named xutility triggers a breakpoint(strange, but the IDE say that).
The code part whics creates the body:
Code:
if (entp->flags[ENTFLAG_USEPHYSICS]) //if we want to use physics
{
   b2BodyDef bodydef; //creating the bodydef
    bodydef.position.Set(entp->pos.X/PIXEL_METER, entp->pos.Y/PIXEL_METER);//setting the position
   bodydef.angle=entp->angle;
   if (!entp->flags[ENTFLAG_AUTOSHAPE])//autoshaping using the border of the graphics image
   {
      if (!entp->flags[ENTFLAG_AUTOMASS]) // if not setting the mass from shapes
      {
         bodydef.massData.mass = entp->mass; 
      }
      entp->physics= this->physics->CreateBody(&bodydef);
      for(u32 i=0; i<(entp->shapes.size());i++)// looping through the shapes vector
      {
         entp->physics->CreateShape(&entp->shapes[i]); //ERROR happens here
      }
      if (entp->flags[ENTFLAG_AUTOMASS])
      {
         entp->physics->SetMassFromShapes(); 
      }
   }
   else
   {  //AUTOSHAPE code                     
   bodydef.massData.mass = entp->mass;
   dimension2d<s32> size= entp->graf->getSize();
    b2PolygonDef shDef= b2PolygonDef(); //error here too
    shDef.SetAsBox((size.Width/PIXEL_METER)/2,(size.Height/PIXEL_METER)/2);
   entp->physics= this->physics.CreateBody(&bodydef);                                   
   entp->physics.CreateShape(&shDef);
   }
                   
}

How should i solve this problem?
Which revision are you using? Shapes were changed some revisions ago. Instead of creating shapes on the body, you need to create fixtures. The code should be similar, except for some names. Here's an example from my code :
Code:
b2CircleDef lFixtureDef;
   
    lFixtureDef.radius = 0.1;
    lFixtureDef.isSensor = false;
mBody->CreateFixture(&lFixtureDef);
Tiblanc, don't expect people to always be using the latest version. It's going to be the most buggy, after all.

laci37, if it is something to do with a debugger breakpoint, then it is almost certainly to do with your setup and unrelated to Box2D. You need to sort out what sort of error it is, first.
I cannot see anything wrong with your code. I presume you've done the obvious, and check that shapes contains valid shapes?
BorisTheBrave wrote:
Tiblanc, don't expect people to always be using the latest version. It's going to be the most buggy, after all.


Yeah I know. That's why I was asking 😉

I had some weird issues when fixtures were added because the incremental builder did not detect the changes in Box2D's header files. Code compiled fine but crashed miserably. Thought it might have been something like that that went under the radar.
Fair enough.
I'm using version 2.0.1. Should I use fixtures then?
Shapedefs are valid, but when I call CreateShape it crashes, I couldn't find any reason with the debugger.
laci37 wrote:
I'm using version 2.0.1. Should I use fixtures then?
Shapedefs are valid, but when I call CreateShape it crashes, I couldn't find any reason with the debugger.


You should be using Shapes with that version.

Code:
b2World* physics;
this->physics.CreateBody(&bodydef);


physics is a pointer. You're calling CreateBody with a ., it should be with a ->

Code:
this->physics->CreateBody(&bodydef);
I just can't solve this problem, I'll try the newest version. Where can I download it?

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