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

Fixed alignment issues #298

Merged
merged 2 commits into from
Jul 7, 2017
Merged

Conversation

tfili
Copy link

@tfili tfili commented Jul 6, 2017

Fixed issues with merging buffers that weren't a multiple of 4.

I wrote up #299 because there are some issues that prevented me from writing a test for the degenerate triangles. It opened a can of worms that was outside the scope of this PR.

…fixed generate face normals to not crash on degenerate triangles.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 93.542% when pulling d445114 on buffer-padding-degenerate-triangles into cb7af37 on master.


var sourceBuffer = buffer.extras._pipeline.source;
var currentBufferLength = sourceBuffer.length;
if (currentBufferLength % 4)
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 4 because of Float32 based on the implementation note here? https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#bufferview-and-accessor-byte-alignment

It might be worthwhile to add a blurb summarizing why the 4-byte alignment is needed.

Copy link
Author

@tfili tfili Jul 7, 2017

Choose a reason for hiding this comment

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

Yep. A float must also start on 4-byte boundary. My particular case had something like 102 bytes of shorts containing batch ids so every float array after it in the buffer was unable to be read. The C++ converter handles this, but during the processing the padding is thrown out, so the problem creeps back in again.

Cartesian3.cross(scratchNormalOne, scratchNormalTwo, normal);
Cartesian3.normalize(normal, normal);

// Check for degenerate triangles
Copy link
Contributor

Choose a reason for hiding this comment

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

When this is merged, please update #242 to note that this check is here.

@likangning93
Copy link
Contributor

Thanks @tfili!

@likangning93 likangning93 merged commit 82d562f into master Jul 7, 2017
@lilleyse lilleyse deleted the buffer-padding-degenerate-triangles branch July 7, 2017 16:17
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.

None yet

3 participants