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

Infer missing bufferView targets #275

Merged
merged 3 commits into from
May 18, 2017
Merged

Infer missing bufferView targets #275

merged 3 commits into from
May 18, 2017

Conversation

lasalvavida
Copy link
Contributor

@pjcozzi, @lilleyse, this infers missing bufferView targets as discussed offline

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 91.987% when pulling c43c6d8 on 2.0-bufferView-targets into 1406b32 on 2.0.

function inferBufferViewTargets(gltf) {
// If bufferView elements are missing targets, we can infer their type from their use
var needsTarget = {};
var shouldTraverse = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this optimization worth it: change this boolean to an integer with the number of bufferViews that need a target, decrease it and set needsTarget[bufferViewId] = false every time a target is set, then exit the outer most ForEach.mesh early when it is zero. The return value of the callback could indicate break if it doesn't already.

Given that this is simple, it could be worth it, I just think most models will either always have target defined or never have target defined.

@pjcozzi
Copy link
Contributor

pjcozzi commented May 3, 2017

LGTM, just that one comment.

@lasalvavida
Copy link
Contributor Author

@pjcozzi, updated

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 91.966% when pulling 119d008 on 2.0-bufferView-targets into 1406b32 on 2.0.

var offset = defaultValue(handler(object, i), 0);
i += offset;
var returnValue = handler(object, i);
if (typeof returnValue === 'number') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed? I didn't expect it and it doesn't look like it is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is used by the removal functions: RemoveUnusedProperties.js#L42, to make sure that the ForEach adjusts the index when elements get removed.

i += returnValue;
}
else if (returnValue) {
break;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a unit test for this?

@lasalvavida
Copy link
Contributor Author

Updated

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 91.98% when pulling 9891c39 on 2.0-bufferView-targets into 1406b32 on 2.0.

@lilleyse
Copy link
Contributor

Looks good.

@lilleyse lilleyse merged commit 3d107c2 into 2.0 May 18, 2017
@lilleyse lilleyse deleted the 2.0-bufferView-targets branch May 18, 2017 13:45
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