Skip to content
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

Add mergeVertices option and disable by default #276

Merged
merged 6 commits into from
May 9, 2017
Merged

Conversation

mramato
Copy link
Contributor

@mramato mramato commented May 2, 2017

This works around #161 by adding a mergeVertices and disabling it by default. Once mergeDuplicateVertices is refactored to use less memory and be orders of magnitude faster, we can take out the option and just always do it.

CC @lilleyse

This works around #161 by adding a `mergeVertices` and disabling it by
default.  Once `mergeDuplicateVertices` is refectored to use less memory
and be orders of magnitude faster, we can take out the option and just
always do it.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 93.789% when pulling 60b5d4e on merge-vertices into ce48e5f on master.

lib/Pipeline.js Outdated
@@ -83,6 +83,7 @@ Pipeline.processJSON = function(gltf, options) {
* @param {Object} [options.compressTextureCoordinates=false] Flag to run compressTextureCoordinates stage.
* @param {Object} [options.kmcOptions=undefined] Options to pass to the generateModelMaterialsCommon stage, if undefined, stage is not run.
* @param {Object} [options.quantize] Flag to run quantizeAttributes stage.
* @param {Boolean} [options.mergeVertices = false} Flag to merge duplicate vertices, which can produce a smaller model size but greatly increases conversion time.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add this requires options.preserve. Same change in lib/parseArguments.

Or maybe we set var shouldPreserve = defaultValue(options.preserve, (defaultValue(options.mergeVertices, false));, but this could cause various other optimizations.

Or a 3rd option is to change

    if (!shouldPreserve) {
          if (options.mergeVertices) {
              mergeDuplicateVertices(gltfWithExtras);
          }
          MergeDuplicateProperties.mergeAll(gltfWithExtras);
          //....................
    }

to

    if (!shouldPreserve || options.mergeVertices) {
        mergeDuplicateVertices(gltfWithExtras);
    }
    if (!shouldPreserve) {
        MergeDuplicateProperties.mergeAll(gltfWithExtras);
        //....................
    }

PS. I also noticed that options.preserve is not documented here (it is documented in `lib/parseArguments').

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added doc for preserve and mention it in the doc for merge vertices. I left the logic as-is. This new option should hopefully go soon enough anyway, since it's just to work around #161

@mramato
Copy link
Contributor Author

mramato commented May 5, 2017

This is ready unless anyone else has any comments.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 93.789% when pulling cecce51 on merge-vertices into ce48e5f on master.

@shehzan10
Copy link
Member

LGTM. @lilleyse do you want to look over once and merge?

@mramato
Copy link
Contributor Author

mramato commented May 9, 2017

I added some unit tests to cover the new code path. @lilleyse if you can merge this once it goes green, I'd like to do a new release today (I can do the publish, since I have my linux laptop with me).

lib/Pipeline.js Outdated
@@ -83,6 +83,8 @@ Pipeline.processJSON = function(gltf, options) {
* @param {Object} [options.compressTextureCoordinates=false] Flag to run compressTextureCoordinates stage.
* @param {Object} [options.kmcOptions=undefined] Options to pass to the generateModelMaterialsCommon stage, if undefined, stage is not run.
* @param {Object} [options.quantize] Flag to run quantizeAttributes stage.
* @param {Object} [options.preserve=false] Flag to turn optimization pipeline stages on/off to preserve the original glTF hierarchy.
* @param {Boolean} [options.mergeVertices=false} Flag to merge duplicate vertices, which can produce a smaller model size but greatly increases conversion time. This setting only applies when options.preserve is false.
Copy link
Contributor

Choose a reason for hiding this comment

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

Small typo, should be [options.mergeVertices=false]

lib/Pipeline.js Outdated
@@ -112,7 +114,9 @@ Pipeline.processJSONWithExtras = function(gltfWithExtras, options) {
generateNormals(gltfWithExtras, options);
}
if (!shouldPreserve) {
mergeDuplicateVertices(gltfWithExtras);
if (options.mergeVertices) {
Copy link
Contributor

Choose a reason for hiding this comment

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

mergeVertices should be set to a default value before reaching here.

spyOn(mergeDuplicateVertices, '_implementation').and.callThrough();
var promise = readGltf(gltfPath)
.then(function (gltf) {
return processJSONWithExtras(gltf, {mergeVertices: true}).thenReturn(gltf);
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for the thenReturn(gltf), it already resolves to a gltf.

@mramato
Copy link
Contributor Author

mramato commented May 9, 2017

Thanks @lilleyse, your review comments have been addressed.

@lilleyse
Copy link
Contributor

lilleyse commented May 9, 2017

👍

@lilleyse lilleyse merged commit 2584b54 into master May 9, 2017
@lilleyse lilleyse deleted the merge-vertices branch May 9, 2017 15:01
@lilleyse
Copy link
Contributor

lilleyse commented May 9, 2017

I'll add to CHANGES.md before the next release.

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

Successfully merging this pull request may close these issues.

4 participants