-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KHR extensions #894
KHR extensions #894
Conversation
Fix default test behavior and prepare support for clearcoat, sheen and transmission
@@ -63,7 +67,7 @@ public bool ShouldSerializeemissiveTexture() | |||
|
|||
public bool ShouldSerializeemissiveFactor() | |||
{ | |||
return (this.emissiveFactor != null && !this.emissiveFactor.SequenceEqual(new float[] { 0f, 0f, 0f })); | |||
return (this.emissiveFactor != null && !this.emissiveFactor.SequenceEqual(zeros3)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reccomend using tools.isAlmostEqualTo() instead of doing floating point equivalency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, Then we use the MathUtilities wich is already used in GLTFLight and the ArrayExtension. Both on Utilities shared project
ok ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, thanks
@@ -8,6 +8,10 @@ namespace GLTFExport.Entities | |||
[DataContract] | |||
public class GLTFMaterial : GLTFIndexedChildRootProperty | |||
{ | |||
internal static float[] one2 = { 1.0f, 1.0f }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we instead add a definition to our Tools.Math file with definitions of vector2, vector3 and the zero and one constants, similar to babylon.js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we may have this , but if we create vector, i recommend to introduce this vector class directly into the GltfExport.Entities to avoid new dependencies. The gltf project is supposed to be standalone and self sufficient (wich its not the case today). So, similar to babylon.js, introduce one Maths.cs file with Vector2 and Vector3, and some logic to replace the MathUtilities used in only one place so far.
in the mean time, as you pointed out a poor code design option, i propose to clear this static and introduce
public static bool IsAllAlmostEqualTo(this float[] current, float value, float epsilon)
{
if( current == null)
{
return false;
}
for (var i = 0; i < current.Length; ++i)
{
if (!MathUtilities.IsAlmostEqualTo(current[i], value, epsilon))
{
return false;
}
}
return true;
}
into ArrayExtensions.cs
then we may discard the static and use the extension as
public bool ShouldSerializescale()
{
return this.scale != null && !this.scale.IsAllAlmostEqualTo(1,float.Epsilon);
}
then make the code more resilient without the need to introduce new classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems like an alright decision, I just like code reuse, and not making architectural decisions for convenience sake, Currently we take dependencies on some shared utilities, helper functions and structures in SharedProjects, as long as we don't take any additional dependencies directly from Max or/Maya2Babylon.
Some standalone math utility, as opposed to an appendix to the gltf entities, but I don't think it matters that much to hold up the PR if you decide otherwise. Where we're using them, we also reused some entities defined in our babylon utilities as part of the glTF exporter, as they are used by the babylon entities.
Ultimately, it would be a good goal to architect such that we can easily make Babylon2GLTF its own standalone executable.
Contributing to our utilities should still allow the project to be relatively standalone, right? That would be akin to using a shared math library or scientific computing library in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely agree with adding a helper function to compare arrays via IsAllAlmostEqualTo,
Alternatively you can override IsAlmostEqualTo to use float[] as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok this is what i done. I guess PR is ready now.
Thanks, checking in. |
Fix #872 default test behavior and prepare #892 support for clearcoat, sheen and transmission