After few tries i replaced NSMutableArray with usual NSArray with 9 elements for superposition matrix. It covers all situations and has a more clear logic for me.
But the main problem is creating body without adding to the world. For example:
In collision logic (pseudocode)
Code:
[self.bodies addObjectAtIndex:index] = [self masterBody];
where
Code:
masterBody
returns a template (master copy) for object body. But i can't write this method because there is only one
Code:
world->CreateBody(&bodyDef);
method.
I can create separately only definition of the body, but full creation (with fixtures) can't be made without adding it to the world.
Any ideas? Use separate world for storing template bodies of every game object?