SUUVHelperGetFrontUVQ return SUUVQ with q = 0.0f

Hi there,

I am using Sketchup SDK and SUUVHelperGetFrontUVQ to get the UV coordinates for a specific point position. This is something done like this (summarized code)

SUVertexGetPosition(vertice, &pos);
SUUVHelperGetFrontUVQ(front_uv_helper, &pos, &uvq);
float u = uvq.u / uvq.q;
float v = uvq.v / uvq.q;

Everything work fine since a long time.
But the joined mesh return a q = 0.0;
This result in division by zero as shown in the screenshot.

This occurs for vertex 0 of face #24 of Group 0 which position is :
{x=2.2055715423330184 y=1.1811023622046832 z=8.8582822051845707 }

What to do when q is 0.0 ?
Is this supposed to occur sometime?

Thanks for your help!

extract.skp (1.5 MB)

Is this an entity ID or PID?

#24 is the index of the face in the face array you get using SUEntitiesGetFaces.
The ID of the face is 87854 if that can help, and that face belong to Group 0

The entityID isn’t not reliably across sessions. Can you get the persistent ID please? I want to make sure we deal with the same entity.

Oups! Please apologize Thomas.
The PID of the face is 7302967

Hello Thomas,
Did you had a chance to dig the UV on the face #7302967.
I wonder how to get correct uv when q = 0.0
Any idea? Thanks!

Sorry, been swamped with work. I had a look at this today, and as far as I can tell there is some corruption with this particular face. I’m getting 0.0, 0.0, 0.0 for all requested UVQs.

I used the Ruby API to aid me in quicker inspection of the file.

model = Sketchup.active_model
face = model.find_entity_by_persistent_id(7302967)
uvh = face.get_UVHelper(true, true)
uvqs = face.vertices.map { |v| uvh.get_front_UVQ(v.position) }

Output:

[Point3d(0, 0, 0), Point3d(0, 0, 0), Point3d(0, 0, 0), Point3d(0, 0, 0), Point3d(0, 0, 0), Point3d(0, 0, 0), Point3d(0, 0, 0), Point3d(0, 0, 0)]

When testing other faces in the model they behave better:

model = Sketchup.active_model
face = model.selection.first
uvh = face.get_UVHelper(true, true)
uvqs = face.vertices.map { |v| uvh.get_front_UVQ(v.position) }

This looks like a bug. But I’m not sure where the source of it is, when the texture was created or when serializing the data.

Could you log it as a bug in our issue tracker please? https://github.com/SketchUp/api-issue-tracker

By the way, do you know the origin of this model? A model a user created? Or the result of an importer?

1 Like

Thanks for your analyze.

I asked the user where the model came from and even though he is not 100% sure, it came from either Sketchup or 3D Warehouse.

I wonder if using the Texture > Position tool incorrectly cannot lead to such invalid values.

I’ll drop this issue on the tracker.

2 Likes