No thats not the correct way:
1. Write all your static objects to a collision layer where only static objects reside in.
2. write all dynamic objects to the dynamic layer that shall send collisions, without reading their collision.
3. process all objects that shall receive collisions (not that are normally only a very very few) by writting it to the dynamic layer with the correctly applied read flag (dynamic layer | static layer), without writting it.
4. Most important step: Only clear the layer where the dynamic objects are in. DON'T clear the one of the static objects. That way you don't have to rewrite them to the layer ... To do so, you have to explicitely define the layer to delete within the clear collision call.
I'm using a similar approach in my simplified (for the user) collision routines in my entity system ... Due to the fact that normally only a few objects need to receive collisions it is an enormemous amount of speed gain.
[EDITED]
Edited out some inconsistencies that could lead to "faulty" structure
1. Write all your static objects to a collision layer where only static objects reside in.
2. write all dynamic objects to the dynamic layer that shall send collisions, without reading their collision.
3. process all objects that shall receive collisions (not that are normally only a very very few) by writting it to the dynamic layer with the correctly applied read flag (dynamic layer | static layer), without writting it.
4. Most important step: Only clear the layer where the dynamic objects are in. DON'T clear the one of the static objects. That way you don't have to rewrite them to the layer ... To do so, you have to explicitely define the layer to delete within the clear collision call.
I'm using a similar approach in my simplified (for the user) collision routines in my entity system ... Due to the fact that normally only a few objects need to receive collisions it is an enormemous amount of speed gain.
[EDITED]
Edited out some inconsistencies that could lead to "faulty" structure