static void mikk_get_texture_coordinate(const SMikkTSpaceContext *context, float uv[2], const int face_num, const int vert_num) { MikkUserData *userdata = (MikkUserData*)context->m_pUserData; if(userdata->layer != NULL) { BL::MeshTextureFace tf = userdata->layer->data[face_num]; float3 tfuv; switch(vert_num) { case 0: tfuv = get_float3(tf.uv1()); break; case 1: tfuv = get_float3(tf.uv2()); break; case 2: tfuv = get_float3(tf.uv3()); break; default: tfuv = get_float3(tf.uv4()); break; } uv[0] = tfuv.x; uv[1] = tfuv.y; } else { int vert_idx = userdata->mesh.tessfaces[face_num].vertices()[vert_num]; float3 orco = get_float3(userdata->mesh.vertices[vert_idx].undeformed_co()); float2 tmp = map_to_sphere(make_float3(orco[0], orco[1], orco[2])); uv[0] = tmp.x; uv[1] = tmp.y; } }
static void mikk_get_texture_coordinate(const SMikkTSpaceContext *context, float uv[2], const int face_num, const int vert_num) { MikkUserData *userdata = (MikkUserData*)context->m_pUserData; BL::MeshTextureFace tf = userdata->layer.data[face_num]; float3 tfuv; switch (vert_num) { case 0: tfuv = get_float3(tf.uv1()); break; case 1: tfuv = get_float3(tf.uv2()); break; case 2: tfuv = get_float3(tf.uv3()); break; default: tfuv = get_float3(tf.uv4()); break; } uv[0] = tfuv.x; uv[1] = tfuv.y; }