Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

FNA Code Style ./I* - R* #188

Merged
merged 5 commits into from
Apr 6, 2014

Conversation

3vi1
Copy link

@3vi1 3vi1 commented Apr 3, 2014

Flibitized for #147. All the usual, and removed unnecessary parenthesis from commutative additions.

Flibitized.  Removed unnecessary parenthesis from commutative additions.
public long MaxTime { get; set; }
public long HitCount { get; set; }
public string Name { get; set; }
public long PreviousTime { get; set; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate lines for all this stuff

@flibitijibibo
Copy link
Owner

Other than the two style things I pointed out above, seems great!

This fixes the items Flibitijibibo noted, and a couple of whitespacing issues
that MonoDevelop slipped into the code.
@3vi1
Copy link
Author

3vi1 commented Apr 3, 2014

Can't believe I missed those get/set's.

I guess I had done so many bool expressions that I got stuck in a groove on that last string concatenation.

Thanks for catching those.

/// </returns>
public static float ClassifyPoint(ref Vector3 point, ref Plane plane)
{
return ( (point.X * plane.Normal.X) +
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this formatting issue runs across most of these diffs, not just the one I pointed out.

SOFTWARE.
*/
#endregion
The above copyright notice and this permission notice shall be included in all
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guessing this was borked in the retabbing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a problem with this file being corrupted (I believe I used sed on it while I had it open in another editor), so I copy/pasted over it from a backup inside of MonoDevelop (I was on my daily commuter van, so couldn't just checkout the old version). I just re-tested now, and sure enough Monodevelop will screw up the licensing tabbing when doing that. Good to know.

@flibitijibibo flibitijibibo changed the title FNA Code Style ./P* - R* FNA Code Style ./I* - R* Apr 5, 2014
@flibitijibibo
Copy link
Owner

Will look at this one more time in detail tomorrow... you can do another passthrough of the P-R section one more time if you want. The new stuff all looks good (but I haven't checked Matrix yet).

For Matrix, the only thing I'd check right off the bat is the file results. In upstream it complains about very long lines, so if it still does that, see what's needed to fix that...

Hoping to finally merge this tomorrow or Sunday.

@3vi1
Copy link
Author

3vi1 commented Apr 5, 2014

[mono] ~/src/fna-jl/MonoGame.Framework @ file Ma*
MathHelper.cs: ASCII text
Matrix.cs:     ASCII text

:)

Yeah, Matrix was a bear. One line was even 467 characters wide. I can see where the original coder might have found it hard to break up since he nested so many of the operations, but most of that nesting was unnecessary (it was controlling the order of addition of floats, which is totally commutative) so I was able to simplify it and multi-line it all.

I'll go comment on a couple of other items I think you might want to offer feedback on, since I apparently have insomnia this morning. :)

@3vi1
Copy link
Author

3vi1 commented Apr 5, 2014

Hmmmm... looks like I can't do inline comments on Matrix. I guess it's hidden because it's so long.

Anyway, the two items I was thinking of are:

  • Overloaded operators. There was redundant code for all the operators, I simplified this to have the operators (ex. operator-+) hand off to the named method (.Add), eliminating the second implementation of the same function.
  • Matrix as a parameter. At least one function (FindDeterminants) passes a 4x4 matrices as 12 floats. Instead of putting each float parameter on a separate line of the function header, I put 4 to a line to make it more clear what it was doing.

flibitijibibo added a commit that referenced this pull request Apr 6, 2014
@flibitijibibo flibitijibibo merged commit a671673 into flibitijibibo:monogame-sdl2 Apr 6, 2014
@flibitijibibo
Copy link
Owner

Turns out the same can be said of Quaternion regarding obnoxious copypasted code...

This should be considered an additional commit on top of this merge: 24f1eb3

Matrix seemed okay, but I gave it a very lazy glance... the only thing that leaves me unsure about this commit is the possible change of behavior from changing nests/parens in order of operations, as that can be super super hard to detect if something goes wrong. I tested this with Capsized, which uses these bits extensively, and it seemed okay, but if we get a report about weird maths somewhere down the line, we should probably look to these two sets of changes.

@flibitijibibo
Copy link
Owner

Sure enough:

8c452e3

a671673#diff-5eecd4f30a1b3dd7256f6b1d0695e716L644
a671673#diff-5eecd4f30a1b3dd7256f6b1d0695e716R709

Definitely do a second pass through these files and be sure more of those didn't slip through...

@3vi1
Copy link
Author

3vi1 commented Apr 6, 2014

the only thing that leaves me unsure about this commit is the possible change of behavior from changing nests/parens in order of operations

It should be fine. I don't think I changed any nesting that affects anything but the additions, which should be totally commutative for the vectors and float operations I modified.

If we do get any reports, I'll be happy to go back and investigate/fix anything I @%^!'d up.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants