OpenSubdiv: Properly respect Subdivide UVs option
This commit is contained in:
@@ -567,9 +567,12 @@ struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_createTopologyRefinerDescr(
|
|||||||
Options options;
|
Options options;
|
||||||
options.SetVtxBoundaryInterpolation(Options::VTX_BOUNDARY_EDGE_ONLY);
|
options.SetVtxBoundaryInterpolation(Options::VTX_BOUNDARY_EDGE_ONLY);
|
||||||
options.SetCreasingMethod(Options::CREASE_UNIFORM);
|
options.SetCreasingMethod(Options::CREASE_UNIFORM);
|
||||||
/* TODO(sergey): Get proper UV subdivide flag. */
|
if (converter->get_subdiv_uvs(converter)) {
|
||||||
// options.SetFVarLinearInterpolation(Options::FVAR_LINEAR_ALL);
|
options.SetFVarLinearInterpolation(Options::FVAR_LINEAR_CORNERS_ONLY);
|
||||||
options.SetFVarLinearInterpolation(Options::FVAR_LINEAR_CORNERS_ONLY);
|
}
|
||||||
|
else {
|
||||||
|
options.SetFVarLinearInterpolation(Options::FVAR_LINEAR_ALL);
|
||||||
|
}
|
||||||
|
|
||||||
TopologyRefinerFactory<TopologyRefinerData>::Options
|
TopologyRefinerFactory<TopologyRefinerData>::Options
|
||||||
topology_options(scheme_type, options);
|
topology_options(scheme_type, options);
|
||||||
@@ -649,6 +652,7 @@ int openSubdiv_topologyRefnerCompareConverter(
|
|||||||
const OpenSubdiv_TopologyRefinerDescr *topology_refiner,
|
const OpenSubdiv_TopologyRefinerDescr *topology_refiner,
|
||||||
OpenSubdiv_Converter *converter)
|
OpenSubdiv_Converter *converter)
|
||||||
{
|
{
|
||||||
|
typedef OpenSubdiv::Sdc::Options Options;
|
||||||
using OpenSubdiv::Far::ConstIndexArray;
|
using OpenSubdiv::Far::ConstIndexArray;
|
||||||
using OpenSubdiv::Far::TopologyRefiner;
|
using OpenSubdiv::Far::TopologyRefiner;
|
||||||
using OpenSubdiv::Far::TopologyLevel;
|
using OpenSubdiv::Far::TopologyLevel;
|
||||||
@@ -663,6 +667,12 @@ int openSubdiv_topologyRefnerCompareConverter(
|
|||||||
if (scheme_type != refiner->GetSchemeType()) {
|
if (scheme_type != refiner->GetSchemeType()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
const Options options = refiner->GetSchemeOptions();
|
||||||
|
Options::FVarLinearInterpolation interp = options.GetFVarLinearInterpolation();
|
||||||
|
const bool subdiv_uvs = (interp != Options::FVAR_LINEAR_ALL);
|
||||||
|
if (converter->get_subdiv_uvs(converter) != subdiv_uvs) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (converter->get_num_verts(converter) != num_verts ||
|
if (converter->get_num_verts(converter) != num_verts ||
|
||||||
converter->get_num_edges(converter) != num_edges ||
|
converter->get_num_edges(converter) != num_edges ||
|
||||||
converter->get_num_faces(converter) != num_faces)
|
converter->get_num_faces(converter) != num_faces)
|
||||||
|
@@ -47,6 +47,8 @@ typedef struct OpenSubdiv_Converter {
|
|||||||
|
|
||||||
OpenSubdiv_SchemeType (*get_type)(const OpenSubdiv_Converter *converter);
|
OpenSubdiv_SchemeType (*get_type)(const OpenSubdiv_Converter *converter);
|
||||||
|
|
||||||
|
bool (*get_subdiv_uvs)(const OpenSubdiv_Converter *converter);
|
||||||
|
|
||||||
int (*get_num_faces)(const OpenSubdiv_Converter *converter);
|
int (*get_num_faces)(const OpenSubdiv_Converter *converter);
|
||||||
int (*get_num_edges)(const OpenSubdiv_Converter *converter);
|
int (*get_num_edges)(const OpenSubdiv_Converter *converter);
|
||||||
int (*get_num_verts)(const OpenSubdiv_Converter *converter);
|
int (*get_num_verts)(const OpenSubdiv_Converter *converter);
|
||||||
|
@@ -316,6 +316,7 @@ CCGSubSurf *ccgSubSurf_new(CCGMeshIFC *ifc, int subdivLevels, CCGAllocatorIFC *a
|
|||||||
ss->osd_next_face_ptex_index = 0;
|
ss->osd_next_face_ptex_index = 0;
|
||||||
ss->osd_coarse_coords = NULL;
|
ss->osd_coarse_coords = NULL;
|
||||||
ss->osd_num_coarse_coords = 0;
|
ss->osd_num_coarse_coords = 0;
|
||||||
|
ss->osd_subdiv_uvs = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ss;
|
return ss;
|
||||||
|
@@ -244,6 +244,8 @@ void ccgSubSurf_free_osd_mesh(CCGSubSurf *ss);
|
|||||||
|
|
||||||
void ccgSubSurf_getMinMax(CCGSubSurf *ss, float r_min[3], float r_max[3]);
|
void ccgSubSurf_getMinMax(CCGSubSurf *ss, float r_min[3], float r_max[3]);
|
||||||
|
|
||||||
|
void ccgSubSurf__sync_subdivUvs(CCGSubSurf *ss, bool subsurf_uvs);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __CCGSUBSURF_H__ */
|
#endif /* __CCGSUBSURF_H__ */
|
||||||
|
@@ -254,6 +254,8 @@ struct CCGSubSurf {
|
|||||||
* to fill in PTex index of CCGFace.
|
* to fill in PTex index of CCGFace.
|
||||||
*/
|
*/
|
||||||
int osd_next_face_ptex_index;
|
int osd_next_face_ptex_index;
|
||||||
|
|
||||||
|
bool osd_subdiv_uvs;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -984,6 +984,11 @@ void ccgSubSurf__delete_pending(void)
|
|||||||
BLI_spin_unlock(&delete_spin);
|
BLI_spin_unlock(&delete_spin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ccgSubSurf__sync_subdivUvs(CCGSubSurf *ss, bool subdiv_uvs)
|
||||||
|
{
|
||||||
|
ss->osd_subdiv_uvs = subdiv_uvs;
|
||||||
|
}
|
||||||
|
|
||||||
/* ** Public API ** */
|
/* ** Public API ** */
|
||||||
|
|
||||||
void BKE_subsurf_osd_init(void)
|
void BKE_subsurf_osd_init(void)
|
||||||
|
@@ -84,6 +84,13 @@ static OpenSubdiv_SchemeType conv_dm_get_type(
|
|||||||
return OSD_SCHEME_CATMARK;
|
return OSD_SCHEME_CATMARK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool conv_dm_get_subdiv_uvs(
|
||||||
|
const OpenSubdiv_Converter *converter)
|
||||||
|
{
|
||||||
|
ConvDMStorage *storage = converter->user_data;
|
||||||
|
return (storage->ss->osd_subdiv_uvs);
|
||||||
|
}
|
||||||
|
|
||||||
static int conv_dm_get_num_faces(const OpenSubdiv_Converter *converter)
|
static int conv_dm_get_num_faces(const OpenSubdiv_Converter *converter)
|
||||||
{
|
{
|
||||||
ConvDMStorage *storage = converter->user_data;
|
ConvDMStorage *storage = converter->user_data;
|
||||||
@@ -424,6 +431,8 @@ void ccgSubSurf_converter_setup_from_derivedmesh(
|
|||||||
|
|
||||||
converter->get_type = conv_dm_get_type;
|
converter->get_type = conv_dm_get_type;
|
||||||
|
|
||||||
|
converter->get_subdiv_uvs = conv_dm_get_subdiv_uvs;
|
||||||
|
|
||||||
converter->get_num_faces = conv_dm_get_num_faces;
|
converter->get_num_faces = conv_dm_get_num_faces;
|
||||||
converter->get_num_edges = conv_dm_get_num_edges;
|
converter->get_num_edges = conv_dm_get_num_edges;
|
||||||
converter->get_num_verts = conv_dm_get_num_verts;
|
converter->get_num_verts = conv_dm_get_num_verts;
|
||||||
@@ -517,6 +526,13 @@ static OpenSubdiv_SchemeType conv_ccg_get_bilinear_type(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool conv_ccg_get_subdiv_uvs(
|
||||||
|
const OpenSubdiv_Converter *converter)
|
||||||
|
{
|
||||||
|
CCGSubSurf *ss = converter->user_data;
|
||||||
|
return (ss->osd_subdiv_uvs);
|
||||||
|
}
|
||||||
|
|
||||||
static int conv_ccg_get_num_faces(const OpenSubdiv_Converter *converter)
|
static int conv_ccg_get_num_faces(const OpenSubdiv_Converter *converter)
|
||||||
{
|
{
|
||||||
CCGSubSurf *ss = converter->user_data;
|
CCGSubSurf *ss = converter->user_data;
|
||||||
@@ -696,6 +712,8 @@ void ccgSubSurf_converter_setup_from_ccg(CCGSubSurf *ss,
|
|||||||
{
|
{
|
||||||
converter->get_type = conv_ccg_get_bilinear_type;
|
converter->get_type = conv_ccg_get_bilinear_type;
|
||||||
|
|
||||||
|
converter->get_subdiv_uvs = conv_ccg_get_subdiv_uvs;
|
||||||
|
|
||||||
converter->get_num_faces = conv_ccg_get_num_faces;
|
converter->get_num_faces = conv_ccg_get_num_faces;
|
||||||
converter->get_num_edges = conv_ccg_get_num_edges;
|
converter->get_num_edges = conv_ccg_get_num_edges;
|
||||||
converter->get_num_verts = conv_ccg_get_num_verts;
|
converter->get_num_verts = conv_ccg_get_num_verts;
|
||||||
|
@@ -794,7 +794,8 @@ static void ss_sync_osd_from_derivedmesh(CCGSubSurf *ss,
|
|||||||
static void ss_sync_from_derivedmesh(CCGSubSurf *ss,
|
static void ss_sync_from_derivedmesh(CCGSubSurf *ss,
|
||||||
DerivedMesh *dm,
|
DerivedMesh *dm,
|
||||||
float (*vertexCos)[3],
|
float (*vertexCos)[3],
|
||||||
int use_flat_subdiv)
|
int use_flat_subdiv,
|
||||||
|
bool use_subdiv_uvs)
|
||||||
{
|
{
|
||||||
#ifdef WITH_OPENSUBDIV
|
#ifdef WITH_OPENSUBDIV
|
||||||
/* Reset all related descriptors if actual mesh topology changed or if
|
/* Reset all related descriptors if actual mesh topology changed or if
|
||||||
@@ -802,6 +803,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss,
|
|||||||
*/
|
*/
|
||||||
if (!ccgSubSurf_needGrids(ss)) {
|
if (!ccgSubSurf_needGrids(ss)) {
|
||||||
/* TODO(sergey): Use vertex coordinates and flat subdiv flag. */
|
/* TODO(sergey): Use vertex coordinates and flat subdiv flag. */
|
||||||
|
ccgSubSurf__sync_subdivUvs(ss, use_subdiv_uvs);
|
||||||
ccgSubSurf_checkTopologyChanged(ss, dm);
|
ccgSubSurf_checkTopologyChanged(ss, dm);
|
||||||
ss_sync_osd_from_derivedmesh(ss, dm);
|
ss_sync_osd_from_derivedmesh(ss, dm);
|
||||||
}
|
}
|
||||||
@@ -5029,7 +5031,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
|
|||||||
#ifdef WITH_OPENSUBDIV
|
#ifdef WITH_OPENSUBDIV
|
||||||
ccgSubSurf_setSkipGrids(smd->emCache, use_gpu_backend);
|
ccgSubSurf_setSkipGrids(smd->emCache, use_gpu_backend);
|
||||||
#endif
|
#endif
|
||||||
ss_sync_from_derivedmesh(smd->emCache, dm, vertCos, useSimple);
|
ss_sync_from_derivedmesh(smd->emCache, dm, vertCos, useSimple, useSubsurfUv);
|
||||||
result = getCCGDerivedMesh(smd->emCache,
|
result = getCCGDerivedMesh(smd->emCache,
|
||||||
drawInteriorEdges,
|
drawInteriorEdges,
|
||||||
useSubsurfUv, dm, use_gpu_backend);
|
useSubsurfUv, dm, use_gpu_backend);
|
||||||
@@ -5044,7 +5046,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
|
|||||||
|
|
||||||
ss = _getSubSurf(NULL, levels, 3, useSimple | CCG_USE_ARENA | CCG_CALC_NORMALS);
|
ss = _getSubSurf(NULL, levels, 3, useSimple | CCG_USE_ARENA | CCG_CALC_NORMALS);
|
||||||
|
|
||||||
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple);
|
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple, useSubsurfUv);
|
||||||
|
|
||||||
result = getCCGDerivedMesh(ss,
|
result = getCCGDerivedMesh(ss,
|
||||||
drawInteriorEdges, useSubsurfUv, dm, false);
|
drawInteriorEdges, useSubsurfUv, dm, false);
|
||||||
@@ -5075,7 +5077,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
|
|||||||
if (useIncremental && (flags & SUBSURF_IS_FINAL_CALC)) {
|
if (useIncremental && (flags & SUBSURF_IS_FINAL_CALC)) {
|
||||||
smd->mCache = ss = _getSubSurf(smd->mCache, levels, 3, useSimple | useAging | CCG_CALC_NORMALS);
|
smd->mCache = ss = _getSubSurf(smd->mCache, levels, 3, useSimple | useAging | CCG_CALC_NORMALS);
|
||||||
|
|
||||||
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple);
|
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple, useSubsurfUv);
|
||||||
|
|
||||||
result = getCCGDerivedMesh(smd->mCache,
|
result = getCCGDerivedMesh(smd->mCache,
|
||||||
drawInteriorEdges,
|
drawInteriorEdges,
|
||||||
@@ -5115,7 +5117,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
|
|||||||
#ifdef WITH_OPENSUBDIV
|
#ifdef WITH_OPENSUBDIV
|
||||||
ccgSubSurf_setSkipGrids(ss, use_gpu_backend);
|
ccgSubSurf_setSkipGrids(ss, use_gpu_backend);
|
||||||
#endif
|
#endif
|
||||||
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple);
|
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple, useSubsurfUv);
|
||||||
|
|
||||||
result = getCCGDerivedMesh(ss, drawInteriorEdges, useSubsurfUv, dm, use_gpu_backend);
|
result = getCCGDerivedMesh(ss, drawInteriorEdges, useSubsurfUv, dm, use_gpu_backend);
|
||||||
|
|
||||||
@@ -5144,7 +5146,7 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*r_positions)[3])
|
|||||||
CCGVertIterator vi;
|
CCGVertIterator vi;
|
||||||
DerivedMesh *dm = CDDM_from_mesh(me);
|
DerivedMesh *dm = CDDM_from_mesh(me);
|
||||||
|
|
||||||
ss_sync_from_derivedmesh(ss, dm, NULL, 0);
|
ss_sync_from_derivedmesh(ss, dm, NULL, 0, 0);
|
||||||
|
|
||||||
for (ccgSubSurf_initVertIterator(ss, &vi); !ccgVertIterator_isStopped(&vi); ccgVertIterator_next(&vi)) {
|
for (ccgSubSurf_initVertIterator(ss, &vi); !ccgVertIterator_isStopped(&vi); ccgVertIterator_next(&vi)) {
|
||||||
CCGVert *v = ccgVertIterator_getCurrent(&vi);
|
CCGVert *v = ccgVertIterator_getCurrent(&vi);
|
||||||
|
Reference in New Issue
Block a user