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

Consider remapping uv range [0, 1] to image pixel range [0, w-1] (or [0, h-1]) in MeshT.BinPackTextures #57

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

EzioHelios
Copy link
Contributor

@EzioHelios EzioHelios commented Dec 8, 2023

In case where I have u = 1.0 or v 1.0 of vt {u} {v} in my obj file, the following line in Obj2Tiles.Library.Common.CopyImage will throw index out of range exception.

targetRow[x + destX] = sourceRow[x + sourceX];

I traced back and found that when clusterBoundary.Left (u) is exactly 1.0, clusterX will be equal to textureWidth and cause this problem.

Maybe we should consider remapping uv range [0, 1] to image pixel range [0, w-1] (or [0, h-1])?

          var clusterX = (int)Math.Floor(clusterBoundary.Left * (textureWidth - 1));
          var clusterY = (int)Math.Floor(clusterBoundary.Top * (textureHeight - 1));

As for uv out of range [0, 1], it might not be necessary to handle repetition.

@pierotofy
Copy link
Member

Hey @EzioHelios thanks for looking into this and for the fix !

@pierotofy pierotofy merged commit 1909c8f into OpenDroneMap:master Dec 13, 2023
1 check passed
@EzioHelios EzioHelios deleted the fix-tiling-uv branch December 19, 2023 08:31
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.

2 participants