Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2015-08-03 18:30:44 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-08-03 18:51:18 +0300
commit7667ad2d4e616ea0d412ac63e76c220a7106d065 (patch)
treeef6f86ffa9af39c52ba32346044957c743e33544
parente90fea72c1430d270ccf4b5c3880f7e25e35947e (diff)
OpenSubdiv: Made it a modifier option to enable OSD for viewport
The idea of this commit is to make it so we can enable OpenSubdiv by default for the release builds but keep it limited to the viewport only for a specific meshes. This is a temporary solution for until all the needed features are supported on the OpenSubdiv side. Flag itself is done as a dedicated field in modifier DNA so we can easily remove it in the future without ending up with some temporary flag hanging around forever.
-rw-r--r--release/scripts/startup/bl_ui/properties_data_modifier.py2
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c2
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c47
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c7
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c6
6 files changed, 40 insertions, 25 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 549c75d6fda..de8617ecc52 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -874,6 +874,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col.label(text="Options:")
col.prop(md, "use_subsurf_uv")
col.prop(md, "show_only_control_edges")
+ if hasattr(md, "use_opensubdiv"):
+ col.prop(md, "use_opensubdiv")
def SURFACE(self, layout, ob, md):
layout.label(text="Settings are inside the Physics tab")
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index d952e68696e..bd5ddba9590 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -853,7 +853,7 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
static void ccgSubSurf__sync(CCGSubSurf *ss)
{
#ifdef WITH_OPENSUBDIV
- if (true) {
+ if (ss->skip_grids) {
ccgSubSurf__sync_opensubdiv(ss);
}
else
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index cfc9c32e81e..019c3e58aa7 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -273,7 +273,6 @@ static int getFaceIndex(CCGSubSurf *ss, CCGFace *f, int S, int x, int y, int edg
}
}
-#ifndef WITH_OPENSUBDIV
static void get_face_uv_map_vert(UvVertMap *vmap, struct MPoly *mpoly, struct MLoop *ml, int fi, CCGVertHDL *fverts)
{
UvMapVert *v, *nv;
@@ -415,13 +414,12 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
return 1;
}
-#endif /* WITH_OPENSUBDIV */
#ifdef WITH_OPENSUBDIV
-static void set_subsurf_ccg_uv(CCGSubSurf *ss,
- DerivedMesh *dm,
- DerivedMesh *result,
- int layer_index)
+static void UNUSED_FUNCTION(set_subsurf_osd_ccg_uv)(CCGSubSurf *ss,
+ DerivedMesh *dm,
+ DerivedMesh *result,
+ int layer_index)
{
CCGFace **faceMap;
MTFace *tf;
@@ -498,22 +496,9 @@ static void set_subsurf_ccg_uv(CCGSubSurf *ss,
}
MEM_freeN(faceMap);
}
+#endif /* WITH_OPENSUBDIV */
-static void set_subsurf_uv(CCGSubSurf *ss,
- DerivedMesh *dm,
- DerivedMesh *result,
- int layer_index)
-{
- if (!ccgSubSurf_needGrids(ss)) {
- /* GPU backend is used, no need to evaluate UVs on CPU. */
- /* TODO(sergey): Think of how to support edit mode of UVs. */
- }
- else {
- set_subsurf_ccg_uv(ss, dm, result, layer_index);
- }
-}
-#else /* WITH_OPENSUBDIV */
-static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, int n)
+static void set_subsurf_legacy_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, int n)
{
CCGSubSurf *uvss;
CCGFace **faceMap;
@@ -593,7 +578,23 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result,
ccgSubSurf_free(uvss);
MEM_freeN(faceMap);
}
-#endif /* WITH_OPENSUBDIV */
+
+static void set_subsurf_uv(CCGSubSurf *ss,
+ DerivedMesh *dm,
+ DerivedMesh *result,
+ int layer_index)
+{
+#ifdef WITH_OPENSUBDIV
+ if (!ccgSubSurf_needGrids(ss)) {
+ /* GPU backend is used, no need to evaluate UVs on CPU. */
+ /* TODO(sergey): Think of how to support edit mode of UVs. */
+ }
+ else
+#endif
+ {
+ set_subsurf_legacy_uv(ss, dm, result, layer_index);
+ }
+}
/* face weighting */
typedef struct FaceVertWeightEntry {
@@ -797,9 +798,9 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss,
/* Reset all related descriptors if actual mesh topology changed or if
* other evlauation-related settings changed.
*/
- ccgSubSurf_checkTopologyChanged(ss, dm);
if (!ccgSubSurf_needGrids(ss)) {
/* TODO(sergey): Use vertex coordinates and flat subdiv flag. */
+ ccgSubSurf_checkTopologyChanged(ss, dm);
ss_sync_osd_from_derivedmesh(ss, dm);
}
else
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 634159e4e60..77b9e290cbf 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -134,6 +134,7 @@ typedef struct SubsurfModifierData {
ModifierData modifier;
short subdivType, levels, renderLevels, flags;
+ short use_opensubdiv, pad[3];
void *emCache, *mCache;
} SubsurfModifierData;
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index affaef3aa7b..6c595076fbd 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -1119,6 +1119,13 @@ static void rna_def_modifier_subsurf(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flags", eSubsurfModifierFlag_SubsurfUv);
RNA_def_property_ui_text(prop, "Subdivide UVs", "Use subsurf to subdivide UVs");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+#ifdef WITH_OPENSUBDIV
+ prop = RNA_def_property(srna, "use_opensubdiv", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "use_opensubdiv", 1);
+ RNA_def_property_ui_text(prop, "Use OpenSubdiv", "Use OpenSubdiv for the subdivisions (viewport only)");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+#endif
}
static void rna_def_modifier_generic_map_info(StructRNA *srna)
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index ff778e62507..2a804b0f735 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -120,7 +120,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/* TODO(sergey): Not entirely correct, modifiers on top of subsurf
* could be disabled.
*/
- if (md->next == NULL && allow_gpu && do_cddm_convert == false) {
+ if (md->next == NULL &&
+ allow_gpu &&
+ do_cddm_convert == false &&
+ smd->use_opensubdiv)
+ {
if ((DAG_get_eval_flags_for_object(md->scene, ob) & DAG_EVAL_NEED_CPU) == 0) {
subsurf_flags |= SUBSURF_USE_GPU_BACKEND;
}