Weird stuff going on with Delphi port of Box2D
The application creates many balls like below...
Then I want to simply draw them like so:
Code:
for vBallIndex := 0 to mBallCount-1 do
begin
mBall[vBallIndex].Draw( OpenGLAPI );
end;
But all balls draw samiliaryly... it seems as if there is only one ball ?!?
I checked the constructor and it seems there is only one mCircle ?!?!
All ball instances point towards the same mCircle ?!?
I am not even sure if there are multiple ball instances ?!?
But when I use the "body lists", "fixture lists" and such it does more or less work
with the drawing ?!?!
Very weird situation because I know Delphi pretty well... and it's supposed to create
multiple objects like I tell it to below ?!? But it doesn't seem to do that ?!?
I can think of a number of possibilities:
1. Compiler bug.
2. Box2D does something special.
3. Special memory manager being used ?
4. My IDE is momentarily corrupted ?!?!?
Weird:
Code:
type
TBall = class
private
protected
public
mBodyDefinition : Tb2BodyDef;
mFixtureDefinition : Tb2FixtureDef;
mCircle : Tb2CircleShape;
mRadius : double;
mBody : Tb2Body;
mFixture : Tb2Fixture;
constructor Create( ParaWorld : Tb2World; ParaPositionX, ParaPositionY, ParaRadius : double );
destructor Destroy; override;
procedure Draw( ParaOpenGLAPI : TOpenGLAPIVersion110 );
end;
constructor TBall.Create( ParaWorld : Tb2World; ParaPositionX, ParaPositionY, ParaRadius : double );
begin
inherited Create;
mBodyDefinition := Tb2BodyDef.Create;
mBodyDefinition.bodyType := b2_dynamicBody;
mBodyDefinition.position.SetValue( ParaPositionX, ParaPositionY );
mBodyDefinition.bullet := true;
mCircle := Tb2CircleShape.Create;
mCircle.m_radius := ParaRadius;
writeln( longword(mCircle) ); // all circles have same pointer ?!?! huh ?!?!?
mFixtureDefinition := Tb2FixtureDef.Create;
mFixtureDefinition.shape := mCircle;
mFixtureDefinition.density := 1;
// mFixtureDefinition.friction := 0.03;
mFixtureDefinition.friction := 0;
mFixtureDefinition.restitution := 1.0;
mBody := ParaWorld.CreateBody( mBodyDefinition, True );
mFixture := mBody.CreateFixture( mFixtureDefinition, true, true, true );
end;
(Also this first post on this new board section ! =D)
Bye,
Skybuck.