This project has moved and is read-only. For the latest updates, please go here.

GeomFactory Doesn't Add Geoms To Simulator Right Away?

Topics: User Forum
Dec 10, 2007 at 11:03 PM
I'm getting to work on loading data for my geoms, but it seems they aren't added to the simulation right away. I have a bunch of Bodys and Geoms created using the factories in my initialize method. Then in my LoadContent method I iterate through the Simulator.GeomList collection to load any data attached to the Tag property, but it seems that the GeomList is empty then. But given a few frames, sure enough, my game breaks when it tries to draw some geoms (accessed through the same list) a few frames into the game. So when do the factories actually add objects to the simulator?
Dec 11, 2007 at 12:32 PM
They are overloaded. If you passs in a phsyics parameter as the 1st parameter, they will be added immediately.
Dec 11, 2007 at 3:43 PM
That is what I'm doing in Initialize. I'm using the factory overload that adds them to the simulator, but the don't seem to get added to the GeomList right away. It's strange. I solved the problem by adding

while (simulator.GeomList.Count == 0)

to the start of my LoadContent method. Sure enough, it updates once or twice and then the geoms appear in the list.
Dec 11, 2007 at 5:24 PM
ahh, yes. The geoms that are added are que'd up and then they are really added when update runs. You fix should do the trick.

I will add this to my list of things to fix.