Closed odalet closed 4 years ago
This is awesome! I'm checking out the code now, will give it a quick test and look over and then merge and cut a release! Thanks for this @odalet, amazing contribution :)
Glad I could help!
OK I added a couple of minor changes:
coverage.ps1
script to also collect coverage data from the new test library you wroteIt's merged into master now, cut as release 2.4.4
, just waiting for the build to complete and the new version should be available on Nuget shortly. Thanks so much for your contributions (and adding tests, that makes things so much easier and improves the quality of the codebase) 😄
Thanks!
OK, so here is what I did in this PR:
First I wanted to fix all possible errors when parsing floating point numbers, especially for people who do not use '.' as their decimal separator.
So I went searching for all occurences of
.Parse(
,Convert.To
and also.Replace
(as the hack consisting in replacing '.' with ',' did not work in the first place - it even messed with US culture parsing for ',' is the thousands separator in such cultures and thus1.234
was considered to be1234
)...All this research led to essentially 3 distinct places where parsing occured:
NETDesignSurface
where I fixed the parsing logic by explicitely specifyingCultureInfo.InvariantCulture
so that '.' would be the decimal separator.VertextControl
. Here, I did not change the logic: becaus it is user-facing UI code, it makes sense to have the user use the decimal separator defined in his regional settings.float.Parse
andConvert.ToSingle
that needed the extraCultureInfo.InvariantCulture
argument. Here were also the '.4 replaced by ',' hacks that neeed be removed.All of this, I ensured was working in two ways:
InternalsVisibleTo
attribute toSharpGL.SceneGraph
).While I was at it fixing floating-point parsing, I motivated myself into verifying I could load a more complex OBJ file with materialsx. Hence I hacked a bit
ducky.obj
, added amtl
and apng
file to go with it. Then I needed a gratifying reward, hence the "Ducky Sample". However, because I'm no 3D designer, and barely understand the various light and texture concepts, I suppose the resulting duck could be far nicer. However, the sample serves its purpose at demonstrating one can now load an OBJ with materials and PNG textures.This explains all the other little modifications, not strictly related to floating-point parsing. Hope you don't mind!
PS: I also tried to have the OBJ serializer working, however, I think there is a problem in the way vertices are saved (I suppose there are some unwanted duplications), and so I commented back everything after I had fixed in here too floating-point formatting issues.