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:
authorNicholas Bishop <nicholasbishop@gmail.com>2012-12-30 22:27:33 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2012-12-30 22:27:33 +0400
commitfc442dbd51a5ef71757a1a179222f358b6efdc8c (patch)
treecc7bc014df652579d3e31b7b620ba194077e663d /source/blender
parent31f978c8efdfd88d2cf2b5d9ae7c5d91c81e13d3 (diff)
Add DNA/RNA/BKE infrastructure for dynamic-topology sculpt mode
* Add a detail_size field to the Sculpt struct, two new sculpt flags, and a Mesh flag for dynamic-topology mode; that's it for file-level changes needed by dynamic topology * Add RNA for the new DNA field and flags * Add a new icon for dynamic-topology created by Julio Iglesias. TODO: update the icon for the new SVG icon format * Add a SculptSession function for converting from BMesh to Mesh, handles reordering mesh elements and setting face shading
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_paint.h8
-rw-r--r--source/blender/blenkernel/intern/object.c30
-rw-r--r--source/blender/editors/include/UI_icons.h4
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h1
-rw-r--r--source/blender/makesdna/DNA_scene_types.h11
-rw-r--r--source/blender/makesrna/intern/rna_object.c13
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c22
7 files changed, 85 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index c452c177143..0a4a7f75e25 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -33,6 +33,7 @@
*/
struct bContext;
+struct BMesh;
struct Brush;
struct MDisps;
struct MeshElemMap;
@@ -92,6 +93,12 @@ typedef struct SculptSession {
/* Mesh connectivity */
const struct MeshElemMap *pmap;
+ /* BMesh for dynamic topology sculpting */
+ struct BMesh *bm;
+ int bm_smooth_shading;
+ /* Undo/redo log for dynamic topology sculpting */
+ struct BMLog *bm_log;
+
/* PBVH acceleration structure */
struct PBVH *pbvh;
int show_diffuse_color;
@@ -121,5 +128,6 @@ typedef struct SculptSession {
void free_sculptsession(struct Object *ob);
void free_sculptsession_deformMats(struct SculptSession *ss);
+void sculptsession_bm_to_me(struct Object *ob, int reorder);
#endif
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 99b163ce45b..92b2c8231d3 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -264,14 +264,44 @@ void free_sculptsession_deformMats(SculptSession *ss)
ss->deform_imats = NULL;
}
+/* Write out the sculpt dynamic-topology BMesh to the Mesh */
+void sculptsession_bm_to_me(struct Object *ob, int reorder)
+{
+ if (ob && ob->sculpt) {
+ SculptSession *ss = ob->sculpt;
+
+ if (ss->bm) {
+ if (ob->data) {
+ BMIter iter;
+ BMFace *efa;
+ BM_ITER_MESH (efa, &iter, ss->bm, BM_FACES_OF_MESH) {
+ BM_elem_flag_set(efa, BM_ELEM_SMOOTH,
+ ss->bm_smooth_shading);
+ }
+ if (reorder)
+ BM_log_mesh_elems_reorder(ss->bm, ss->bm_log);
+ BM_mesh_bm_to_me(ss->bm, ob->data, FALSE);
+ }
+ }
+ }
+}
+
void free_sculptsession(Object *ob)
{
if (ob && ob->sculpt) {
SculptSession *ss = ob->sculpt;
DerivedMesh *dm = ob->derivedFinal;
+ if (ss->bm) {
+ sculptsession_bm_to_me(ob, TRUE);
+ BM_mesh_free(ss->bm);
+ }
+
if (ss->pbvh)
BLI_pbvh_free(ss->pbvh);
+ if (ss->bm_log)
+ BM_log_free(ss->bm_log);
+
if (dm && dm->getPBVH)
dm->getPBVH(NULL, dm); /* signal to clear */
diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h
index 99f7f0856b3..0a794040692 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -699,9 +699,7 @@ DEF_ICON(RNDCURVE)
DEF_ICON(PROP_OFF)
DEF_ICON(PROP_ON)
DEF_ICON(PROP_CON)
-#ifndef DEF_ICON_BLANK_SKIP
- DEF_ICON(BLANK212)
-#endif
+DEF_ICON(SCULPT_DYNTOPO)
DEF_ICON(PARTICLE_POINT)
DEF_ICON(PARTICLE_TIP)
DEF_ICON(PARTICLE_PATH)
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index 05f8d2645ad..4c9f6014445 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -170,6 +170,7 @@ typedef struct TFace {
#define ME_SUBSURF 128
#define ME_OPT_EDGES 256
#define ME_DS_EXPAND 512
+#define ME_SCULPT_DYNAMIC_TOPOLOGY 1024
/* me->drawflag, short */
#define ME_DRAWEDGES (1 << 0)
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 5af116df772..0d1ef7af591 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -830,7 +830,8 @@ typedef struct Sculpt {
float special_rotation;
- int pad;
+ /* Maximum edge length for dynamic topology sculpting (in pixels) */
+ int detail_size;
} Sculpt;
typedef struct UvSculpt {
@@ -1479,6 +1480,14 @@ typedef enum SculptFlags {
SCULPT_USE_OPENMP = (1<<7),
SCULPT_ONLY_DEFORM = (1<<8),
SCULPT_SHOW_DIFFUSE = (1<<9),
+
+ /* If set, the mesh will be drawn with smooth-shading in
+ dynamic-topology mode */
+ SCULPT_DYNTOPO_SMOOTH_SHADING = (1<<10),
+
+ /* If set, dynamic-topology brushes will collapse short edges in
+ addition to subdividing long ones */
+ SCULPT_DYNTOPO_COLLAPSE = (1<<11)
} SculptFlags;
/* ImagePaintSettings.flag */
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 4918aabdb1f..6e81e866118 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -48,6 +48,7 @@
#include "BLI_utildefines.h"
+#include "BKE_paint.h"
#include "BKE_tessmesh.h"
#include "BKE_group.h" /* needed for object_in_group() */
@@ -1436,6 +1437,12 @@ int rna_DupliObject_index_get(PointerRNA *ptr)
return dob->persistent_id[0];
}
+int rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr)
+{
+ SculptSession *ss = ((Object*)ptr->id.data)->sculpt;
+ return (ss && ss->bm);
+}
+
#else
static int rna_matrix_dimsize_4x4[] = {4, 4};
@@ -2629,6 +2636,12 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index");
RNA_def_property_update(prop, 0, "rna_Object_active_shape_update");
+ /* sculpt */
+ prop = RNA_def_property(srna, "use_dynamic_topology_sculpting", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_Object_use_dynamic_topology_sculpting_get", NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Dynamic Topology Sculpting", NULL);
+
RNA_api_object(srna);
}
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index f717c83075a..e3b41222a38 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -204,6 +204,11 @@ static void rna_Sculpt_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNU
if (ob) {
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
+
+ if (ob->sculpt) {
+ ob->sculpt->bm_smooth_shading = (scene->toolsettings->sculpt->flags &
+ SCULPT_DYNTOPO_SMOOTH_SHADING);
+ }
}
}
@@ -319,6 +324,23 @@ static void rna_def_sculpt(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Diffuse Color",
"Show diffuse color of object and overlay sculpt mask on top of it");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowDiffuseColor_update");
+
+ prop = RNA_def_property(srna, "detail_size", PROP_INT, PROP_DISTANCE);
+ RNA_def_property_ui_range(prop, 2, 100, 0, 0);
+ RNA_def_property_ui_text(prop, "Detail Size", "Maximum edge length for dynamic topology sculpting (in pixels)");
+
+ prop = RNA_def_property(srna, "use_smooth_shading", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_DYNTOPO_SMOOTH_SHADING);
+ RNA_def_property_ui_text(prop, "Smooth Shading",
+ "Show faces in dynamic-topology mode with smooth "
+ "shading rather than flat shaded");
+ RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update");
+
+ prop = RNA_def_property(srna, "use_edge_collapse", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_DYNTOPO_COLLAPSE);
+ RNA_def_property_ui_text(prop, "Collapse Short Edges",
+ "In dynamic-topology mode, collapse short edges "
+ "in addition to subdividing long ones");
}