Refactoring:
Removed many newlines to tighten formatting.
Explicit casts added for several assignments and indexed access to arrays.
Modern syntax applied.
Renamed looping vars to remove warning of hidden vars in outer scope.
If statements with brackets applied.
Some if statements simplified.
Bugfix for #903 - “Categories” and “Masks” are not saved (physics).
Document was not marked as dirty when categoryType, categories or masks were changed.
Merge pull request #1063 from NickyWeber/bugfix/#903_cat_and_masks_not_saved

Bugfix/#903 cat and masks not saved