Strange thing happen when creating boxes

Sep 9, 2008 at 9:28 AM

 

BoxObject obj;

 

 

int Perimeter = 10;

 

 

int iterations = 2;

 

 

int StartX = -100;

 

 

int StartY = -14;

 

 

int StartZ = -10;

 

 

int stepsX = 18;

 

 

int stepDown = 0;

 

 

List<BoxObject> objects = new List<BoxObject>();

 

 


// in this first loop i create 20 boxes top and bottom , here 7 boxes that i create isnt collidable
for
(int topBottom = 0; topBottom < iterations; ++topBottom)

 

{

 

for (int countBoxes = 0; countBoxes < Perimeter; ++countBoxes)

 

{

obj =

new BoxObject(baseGame, FetchModel(PHYS_MODEL_TYPES.BOX), new Vector3(19.0f, 5.0f, 2.0f), Matrix.Identity, new Vector3(StartX + (stepsX * countBoxes), StartY, StartZ + stepDown));

 

objects.Add(obj);

}

stepDown += 140;

}

 

int stepsZ = 15;

 

 

int stepLeftRight = 0;

 

 


// in this loop i create 20 boxes left and right , the strange thing is that 3 boxes from this list isnt collidable
for
(int leftRight = 0; leftRight < iterations; ++leftRight)

 

{

 

for (int countBoxes = 0; countBoxes < Perimeter; ++countBoxes)

 

{

obj =

new BoxObject(baseGame, FetchModel(PHYS_MODEL_TYPES.BOX), new Vector3(2.0f, 5.0f, 16.0f), Matrix.Identity, new Vector3(StartX + stepLeftRight, StartY, (StartZ+5) + (stepsZ * countBoxes)));

 

objects.Add(obj);

}

stepLeftRight += 150;

}

 


// here i add the boxes i have created to my physList which updates all of them.
for
(int countObjects = 0; countObjects < objects.Count; ++countObjects)

 

{

objects[countObjects].PhysicsBody.Immovable =

true;

 

physProperties.Add(

new PhysEntity(objects[countObjects], GetPhysID(), true, PhysicsType.OBJECT, COLLISION_TYPE.PLAYER_COLLISION));

 

}

objects.Clear();

// The thing i wonder is why isnt all boxes collidable when i create them in a similar way. I set all the boxes to immovable but some of them
// i can still go right through like they arent even there i have tested to add the collision skins manually but that doesnt work either.

Anyone that has any tips.

Sep 9, 2008 at 8:12 PM
I believe these errors have to do with the collision islands that have some problems.  the ones that aren't collidable i'm assuming are inactive and not getting reactivated correctly.  I ended up rewriting the portion a bit and having 2 methods, one for the initial creation of the islands and one for updating pre-existing islands.
Sep 10, 2008 at 7:21 AM
The weird thing is that i alrady update the boxes separately, i have tried to add the lines object.setActive(); when creating the objects. Nothing new happens.

i only have around 50 objects on screen so it shouldnt be to much i think.

Im quite new to jiggleX, when you talk about collision islands what do you mean with islands??


Sep 10, 2008 at 11:12 AM
I found it, my grid wasnt big enough didnt think of that.
physicSystem.CollisionSystem = new CollisionSystemGrid(132, 132, 132, 130, 130, 130);
before i had
physicSystem.CollisionSystem = new CollisionSystemGrid(32, 32, 32, 30, 30, 30);

this shouldnt be static values at all i havent had time to change them thou.
is should really be size of the scene.

thanks for the help Eth.
Sep 15, 2008 at 8:37 PM
Ah what I meant with the collision islands is, if you look at the main overall physics function, in PhysicsSystem.Integrate.  This is what it goes through to update everything.  One of the functions it does is create CollisionIslands which helps in determining what to activate/deactivate.  This is generally correct the first time it creates them, but once items fall asleep, wacky things happen because it only creates these islands with the activate bodies, if you draw the islands you can see strange stuff.  Especially if you plan on deleting items from the physics system while the it is running you'll probably have to update this method.