| 1265 | } |
| 1266 | |
| 1267 | func (world *B2World) Dump() { |
| 1268 | if (world.M_flags & B2World_Flags.E_locked) == B2World_Flags.E_locked { |
| 1269 | return |
| 1270 | } |
| 1271 | |
| 1272 | fmt.Print(fmt.Printf("b2Vec2 g(%.15lef, %.15lef);\n", world.M_gravity.X, world.M_gravity.Y)) |
| 1273 | fmt.Print("m_world.SetGravity(g);\n") |
| 1274 | |
| 1275 | fmt.Print(fmt.Printf("b2Body** bodies = (b2Body**)b2Alloc(%d * sizeof(b2Body*));\n", world.M_bodyCount)) |
| 1276 | //fmt.Print("b2Joint** joints = (b2Joint**)b2Alloc(%d * sizeof(b2Joint*));\n", m_jointCount) |
| 1277 | fmt.Print(fmt.Printf("b2Joint** joints = (b2Joint**)b2Alloc(%d * sizeof(b2Joint*));\n", world.M_jointCount)) |
| 1278 | |
| 1279 | i := 0 |
| 1280 | for b := world.M_bodyList; b != nil; b = b.M_next { |
| 1281 | b.M_islandIndex = i |
| 1282 | b.Dump() |
| 1283 | i++ |
| 1284 | } |
| 1285 | |
| 1286 | i = 0 |
| 1287 | for j := world.M_jointList; j != nil; j = j.GetNext() { |
| 1288 | j.SetIndex(i) |
| 1289 | i++ |
| 1290 | } |
| 1291 | |
| 1292 | // First pass on joints, skip gear joints. |
| 1293 | for j := world.M_jointList; j != nil; j = j.GetNext() { |
| 1294 | if j.GetType() == B2JointType.E_gearJoint { |
| 1295 | continue |
| 1296 | } |
| 1297 | |
| 1298 | fmt.Print("{\n") |
| 1299 | j.Dump() |
| 1300 | fmt.Print("}\n") |
| 1301 | } |
| 1302 | |
| 1303 | // Second pass on joints, only gear joints. |
| 1304 | for j := world.M_jointList; j != nil; j = j.GetNext() { |
| 1305 | if j.GetType() != B2JointType.E_gearJoint { |
| 1306 | continue |
| 1307 | } |
| 1308 | |
| 1309 | fmt.Print("{\n") |
| 1310 | j.Dump() |
| 1311 | fmt.Print("}\n") |
| 1312 | } |
| 1313 | |
| 1314 | fmt.Print("b2Free(joints);\n") |
| 1315 | fmt.Print("b2Free(bodies);\n") |
| 1316 | fmt.Print("joints = nullptr;\n") |
| 1317 | fmt.Print("bodies = nullptr;\n") |
| 1318 | } |