filbs111 / box2d-learning

0 stars 0 forks source link

occasional pausing when destroying a lot of level #16

Closed filbs111 closed 7 years ago

filbs111 commented 7 years ago

after changes in #15 to make a new body and deleting the old one when editing, along with triple fire, see pauses of ~1s occasionally. suspect this is garbage collection. maybe can fix by instead of copying and deleting bodies, do the same thing but for fixtures (ideally without doing this for unchanged fixtures)

possibly making landscape blocks smaller would improve matters (if significant fraction of object size is the fixtures). however, even if acceptable on my machine, likely to still be crappy on weaker machines.

seems to happen more on chrome. if due to destroying/making loads of objects, could be affected more by making/deleting loads of bombs.

can make some test method to cut tons of explosions without making bombs.

filbs111 commented 7 years ago

git is ridiculous. tried to use branches but failed. in the end just reverted recent changes to duplicate and delete whole landscape blocks. TODO some hash of fixtures by co-ordinates, and only delete. should retain a workaround for mysterious things falling through level box2d behaviour described in #15 - ie retain fixture that are removing for a single mechanics iteration.

filbs111 commented 7 years ago

switching to destroying/adding fixtures instead of making new bodies has got back problem of shots occasionally tunneling through the scenery #15 should see if somehow is attempting to delete fixtures twice (was previously deleting bodies twice). if can't fix issue, should go back to duplicate bodies hack - possibly chopping landscape into smaller blocks will reduce slowdown when editing blocks (ie making and deleting)

filbs111 commented 7 years ago

hopefully now faster - deleting and replacing individual fixtures. apparently this requires that the fixtures want to remove are kept around for 2 frames after the replacement fixtures are "made", rather than 1 frame overlap needed when replacing the whole body. (otherwise collisions fail to get caught) this is an acceptable price IMO assuming the memory churn is less now. assume fixed. will test performance on crap computer when convenient.