Paste Code
Paste Blends
Paste Images
Index: release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- release/scripts/ui/space_view3d_toolbar.py (revision 28882)
+++ release/scripts/ui/space_view3d_toolbar.py (working copy)
@@ -547,7 +547,7 @@
col.separator()

row = col.row(align=True)
- row.prop(brush, "size", slider=True)
+ row.prop(brush, "size", slider=True)

if brush.sculpt_tool != 'GRAB':
row.prop(brush, "use_size_pressure", toggle=True, text="")
@@ -559,16 +559,15 @@
# XXX - TODO
#row = col.row(align=True)
#row.prop(brush, "jitter", slider=True)
- #row.prop(brush, "use_jitter_pressure", toggle=True, text="")
-
+ #row.prop(brush, "use_jitter_pressure", toggle=True, text="")
col = layout.column()

if brush.sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'):
col.row().prop(brush, "direction", expand=True)

if brush.sculpt_tool in ('DRAW', 'INFLATE', 'LAYER'):
- col.prop(brush, "use_accumulate")
-
+ col.prop(brush, "use_accumulate")
+
if brush.sculpt_tool == 'LAYER':
ob = context.sculpt_object
do_persistent = True
@@ -581,6 +580,10 @@
if do_persistent:
col.prop(brush, "use_persistent")
col.operator("sculpt.set_persistent_base")
+
+ col.prop(brush,"use_dynamic_subdiv")
+ if brush.use_dynamic_subdiv ==True:
+ col.prop(brush,"detail",slider=True)

# Texture Paint Mode #

Index: source/blender/blenkernel/BKE_paint.h
===================================================================
--- source/blender/blenkernel/BKE_paint.h (revision 28882)
+++ source/blender/blenkernel/BKE_paint.h (working copy)
@@ -72,6 +72,9 @@
struct Object *ob;
struct KeyBlock *kb, *refkb;

+ struct Scene *scene; //Mio
+ struct EditMesh *em; //Mio
+
/* Mesh connectivity */
struct ListBase *fmap;

Index: source/blender/blenkernel/intern/brush.c
===================================================================
--- source/blender/blenkernel/intern/brush.c (revision 28882)
+++ source/blender/blenkernel/intern/brush.c (working copy)
@@ -83,6 +83,7 @@
brush->clone.alpha= 0.5;
brush->sculpt_tool = SCULPT_TOOL_DRAW;
brush->flag |= BRUSH_SPACE;
+ brush->detail = 0.25f;

brush_curve_preset(brush, CURVE_PRESET_SMOOTH);

Index: source/blender/blenkernel/intern/object.c
===================================================================
--- source/blender/blenkernel/intern/object.c (revision 28882)
+++ source/blender/blenkernel/intern/object.c (working copy)
@@ -243,8 +243,8 @@
MEM_freeN(ss->texcache);

if(ss->layer_co)
- MEM_freeN(ss->layer_co);
-
+ MEM_freeN(ss->layer_co);
+
MEM_freeN(ss);

ob->sculpt = NULL;
Index: source/blender/editors/include/ED_mesh.h
===================================================================
--- source/blender/editors/include/ED_mesh.h (revision 28882)
+++ source/blender/editors/include/ED_mesh.h (working copy)
@@ -221,5 +221,134 @@
int ED_mesh_color_add(struct bContext *C, struct Scene *scene, struct Object *ob, struct Mesh *me);
int ED_mesh_color_remove(struct bContext *C, struct Object *ob, struct Mesh *me);

+//---ibli
+
+/* Internal for editmesh_xxxx.c functions */
+struct bContext;
+struct wmOperatorType;
+struct wmOperator;
+
+
+#define UVCOPY(t, s) memcpy(t, s, 2 * sizeof(float));
+
+/* ******************** editface.c */
+
+int edgetag_context_check(struct Scene *scene,struct EditEdge *eed);
+void edgetag_context_set(struct Scene *scene, struct EditEdge *eed, int val);
+int edgetag_shortest_path(struct Scene *scene,struct EditMesh *em,struct EditEdge *source,struct EditEdge *target);
+
+/* ******************* editmesh.c */
+
+extern void free_editvert(struct EditMesh *em, struct EditVert *eve);
+extern void free_editedge(struct EditMesh *em, struct EditEdge *eed);
+extern void free_editface(struct EditMesh *em, struct EditFace *efa);
+void free_editMesh(struct EditMesh *em);
+
+extern void free_vertlist(struct EditMesh *em, struct ListBase *edve);
+extern void free_edgelist(struct EditMesh *em,struct ListBase *lb);
+extern void free_facelist(struct EditMesh *em,struct ListBase *lb);
+
+extern void remedge(struct EditMesh *em,struct EditEdge *eed);
+
+extern struct EditVert *addvertlist(struct EditMesh *em, float *vec, struct EditVert *example);
+extern struct EditEdge *addedgelist(struct EditMesh *em, struct EditVert *v1, struct EditVert *v2, struct EditEdge *example);
+extern struct EditFace *addfacelist(struct EditMesh *em, struct EditVert *v1, struct EditVert *v2, struct EditVert *v3, struct EditVert *v4, struct EditFace *example, struct EditFace *exampleEdges);
+extern struct EditEdge *findedgelist(struct EditMesh *em, struct EditVert *v1, struct EditVert *v2);
+
+void em_setup_viewcontext(struct bContext *C, struct ViewContext *vc);
+
+/* ******************* editmesh_lib.c */
+void EM_stats_update(struct EditMesh *em);
+
+extern void EM_fgon_flags(struct EditMesh *em);
+extern void EM_hide_reset(struct EditMesh *em);
+
+extern int faceselectedOR(struct EditFace *efa, int flag);
+extern int faceselectedAND(struct EditFace *efa, int flag);
+
+void EM_remove_selection(struct EditMesh *em, void *data, int type);
+void EM_clear_flag_all(struct EditMesh *em, int flag);
+void EM_set_flag_all(struct EditMesh *em, int flag);
+void EM_set_flag_all_selectmode(struct EditMesh *em, int flag);
+
+void EM_data_interp_from_verts(struct EditMesh *em,struct EditVert *v1, struct EditVert *v2, struct EditVert *eve, float fac);
+void EM_data_interp_from_faces(struct EditMesh *em,struct EditFace *efa1,struct EditFace *efa2,struct EditFace *efan, int i1, int i2, int i3, int i4);
+
+int EM_nvertices_selected(struct EditMesh *em);
+int EM_nedges_selected(struct EditMesh *em);
+int EM_nfaces_selected(struct EditMesh *em);
+
+float EM_face_perimeter(struct EditFace *efa);
+
+void EM_store_selection(struct EditMesh *em, void *data, int type);
+
+extern struct EditFace *exist_face(struct EditMesh *em, struct EditVert *v1,struct EditVert *v2,struct EditVert *v3, struct EditVert *v4);
+extern void flipface(struct EditMesh *em, struct EditFace *efa); // flips for normal direction
+extern int compareface(struct EditFace *vl1,struct EditFace *vl2);
+
+/* flag for selection bits, *nor will be filled with normal for extrusion constraint */
+/* return value defines if such normal was set */
+extern short extrudeflag_face_indiv(struct EditMesh *em, short flag, float *nor);
+extern short extrudeflag_verts_indiv(struct EditMesh *em, short flag, float *nor);
+extern short extrudeflag_edges_indiv(struct EditMesh *em, short flag, float *nor);
+extern short extrudeflag_vert(struct Object *obedit,struct EditMesh *em, short flag, float *nor, int all);
+extern short extrudeflag(struct Object *obedit,struct EditMesh *em, short flag, float *nor, int all);
+
+extern void adduplicateflag(struct EditMesh *em, int flag);
+extern void delfaceflag(struct EditMesh *em, int flag);
+
+extern void rotateflag(struct EditMesh *em, short flag, float *cent, float rotmat[][3]);
+extern void translateflag(struct EditMesh *em, short flag, float *vec);
+
+extern int convex(float *v1, float *v2, float *v3, float *v4);
+
+extern struct EditFace *EM_face_from_faces(struct EditMesh *em, struct EditFace *efa1,struct EditFace *efa2, int i1, int i2, int i3, int i4);
+
+extern int EM_view3d_poll(struct bContext *C);
+
+/* ******************* editmesh_loop.c */
+
+#define LOOP_SELECT 1
+#define LOOP_CUT 2
+
+
+extern struct EditEdge *findnearestedge(struct ViewContext *vc, int *dist);
+extern void EM_automerge(struct Scene *scene,struct Object *obedit, int update);
+void editmesh_select_by_material(struct EditMesh *em, int index);
+void EM_recalc_normal_direction(struct EditMesh *em, int inside, int select); /* makes faces righthand turning */
+void EM_select_more(struct EditMesh *em);
+void selectconnected_mesh_all(struct EditMesh *em);
+void faceloop_select(struct EditMesh *em, struct EditEdge *startedge, int select);
+
+/**
+ * findnearestvert
+ *
+ * dist (in/out): minimal distance to the nearest and at the end, actual distance
+ * sel: selection bias
+ * if SELECT, selected vertice are given a 5 pixel bias to make them farter than unselect verts
+ * if 0, unselected vertice are given the bias
+ * strict: if 1, the vertice corresponding to the sel parameter are ignored and not just biased
+ */
+extern struct EditVert *findnearestvert(struct ViewContext *vc, int *dist, short sel, short strict);
+
+
+/* ******************* editmesh_tools.c */
+
+#define SUBDIV_SELECT_ORIG 0
+#define SUBDIV_SELECT_INNER 1
+#define SUBDIV_SELECT_INNER_SEL 2
+#define SUBDIV_SELECT_LOOPCUT 3
+
+/* edge subdivide corner cut types */
+#define SUBDIV_CORNER_PATH 0
+#define SUBDIV_CORNER_INNERVERT 1
+#define SUBDIV_CORNER_FAN 2
+
+
+
+void join_triangles(struct EditMesh *em);
+int removedoublesflag(struct EditMesh *em, short flag, short automerge, float limit); /* return amount */
+void esubdivideflag(struct Object *obedit,struct EditMesh *em, int flag, float smooth, float fractal, int beautify, int numcuts, int corner_pattern, int seltype);
+
#endif /* ED_MESH_H */

Index: source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- source/blender/editors/mesh/editmesh_tools.c (revision 28882)
+++ source/blender/editors/mesh/editmesh_tools.c (working copy)
@@ -2611,7 +2611,7 @@
for(eve=em->verts.first; eve; eve=eve->next) {
if(!(beauty & B_KNIFE)) /* knife sets this flag for vertex cuts */
eve->f1 = 0;
- eve->f2 = 0;
+ eve->f2 = 0;
}

for (; md; md=md->next) {
@@ -6745,7 +6745,7 @@
if(fractal != 0.0f)
flag |= B_FRACTAL;

- esubdivideflag(obedit, em, 1, smooth, fractal, ts->editbutflag|flag, cuts, corner_cut_pattern, 0);
+ esubdivideflag(obedit, em, 1, smooth, fractal, ts->editbutflag|flag, cuts, corner_cut_pattern, 0);

DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
Index: source/blender/editors/mesh/mesh_intern.h
===================================================================
--- source/blender/editors/mesh/mesh_intern.h (revision 28882)
+++ source/blender/editors/mesh/mesh_intern.h (working copy)
@@ -26,47 +26,12 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
+#ifndef MESH_INTERN
+#define MESH_INTERN

-/* Internal for editmesh_xxxx.c functions */
+extern EnumPropertyItem corner_type_items[];

-#ifndef MESH_INTERN_H
-#define MESH_INTERN_H
-
-struct bContext;
-struct wmOperatorType;
-struct wmOperator;
-
-
-#define UVCOPY(t, s) memcpy(t, s, 2 * sizeof(float));
-
-/* ******************** editface.c */
-
-int edgetag_context_check(Scene *scene, EditEdge *eed);
-void edgetag_context_set(Scene *scene, EditEdge *eed, int val);
-int edgetag_shortest_path(Scene *scene, EditMesh *em, EditEdge *source, EditEdge *target);
-
-/* ******************* editmesh.c */
-
-extern void free_editvert(EditMesh *em, EditVert *eve);
-extern void free_editedge(EditMesh *em, EditEdge *eed);
-extern void free_editface(EditMesh *em, EditFace *efa);
-void free_editMesh(EditMesh *em);
-
-extern void free_vertlist(EditMesh *em, ListBase *edve);
-extern void free_edgelist(EditMesh *em, ListBase *lb);
-extern void free_facelist(EditMesh *em, ListBase *lb);
-
-extern void remedge(EditMesh *em, EditEdge *eed);
-
-extern struct EditVert *addvertlist(EditMesh *em, float *vec, struct EditVert *example);
-extern struct EditEdge *addedgelist(EditMesh *em, struct EditVert *v1, struct EditVert *v2, struct EditEdge *example);
-extern struct EditFace *addfacelist(EditMesh *em, struct EditVert *v1, struct EditVert *v2, struct EditVert *v3, struct EditVert *v4, struct EditFace *example, struct EditFace *exampleEdges);
-extern struct EditEdge *findedgelist(EditMesh *em, struct EditVert *v1, struct EditVert *v2);
-
-void em_setup_viewcontext(struct bContext *C, ViewContext *vc);
-
void MESH_OT_separate(struct wmOperatorType *ot);
-
/* ******************* editmesh_add.c */
void MESH_OT_primitive_plane_add(struct wmOperatorType *ot);
void MESH_OT_primitive_cube_add(struct wmOperatorType *ot);
@@ -85,61 +50,7 @@
void MESH_OT_fgon_make(struct wmOperatorType *ot);
void MESH_OT_fgon_clear(struct wmOperatorType *ot);

-/* ******************* editmesh_lib.c */
-void EM_stats_update(EditMesh *em);

-extern void EM_fgon_flags(EditMesh *em);
-extern void EM_hide_reset(EditMesh *em);
-
-extern int faceselectedOR(EditFace *efa, int flag);
-extern int faceselectedAND(EditFace *efa, int flag);
-
-void EM_remove_selection(EditMesh *em, void *data, int type);
-void EM_clear_flag_all(EditMesh *em, int flag);
-void EM_set_flag_all(EditMesh *em, int flag);
-void EM_set_flag_all_selectmode(EditMesh *em, int flag);
-
-void EM_data_interp_from_verts(EditMesh *em, EditVert *v1, EditVert *v2, EditVert *eve, float fac);
-void EM_data_interp_from_faces(EditMesh *em, EditFace *efa1, EditFace *efa2, EditFace *efan, int i1, int i2, int i3, int i4);
-
-int EM_nvertices_selected(EditMesh *em);
-int EM_nedges_selected(EditMesh *em);
-int EM_nfaces_selected(EditMesh *em);
-
-float EM_face_perimeter(EditFace *efa);
-
-void EM_store_selection(EditMesh *em, void *data, int type);
-
-extern EditFace *exist_face(EditMesh *em, EditVert *v1, EditVert *v2, EditVert *v3, EditVert *v4);
-extern void flipface(EditMesh *em, EditFace *efa); // flips for normal direction
-extern int compareface(EditFace *vl1, EditFace *vl2);
-
-/* flag for selection bits, *nor will be filled with normal for extrusion constraint */
-/* return value defines if such normal was set */
-extern short extrudeflag_face_indiv(EditMesh *em, short flag, float *nor);
-extern short extrudeflag_verts_indiv(EditMesh *em, short flag, float *nor);
-extern short extrudeflag_edges_indiv(EditMesh *em, short flag, float *nor);
-extern short extrudeflag_vert(Object *obedit, EditMesh *em, short flag, float *nor, int all);
-extern short extrudeflag(Object *obedit, EditMesh *em, short flag, float *nor, int all);
-
-extern void adduplicateflag(EditMesh *em, int flag);
-extern void delfaceflag(EditMesh *em, int flag);
-
-extern void rotateflag(EditMesh *em, short flag, float *cent, float rotmat[][3]);
-extern void translateflag(EditMesh *em, short flag, float *vec);
-
-extern int convex(float *v1, float *v2, float *v3, float *v4);
-
-extern struct EditFace *EM_face_from_faces(EditMesh *em, struct EditFace *efa1,
- struct EditFace *efa2, int i1, int i2, int i3, int i4);
-
-extern int EM_view3d_poll(struct bContext *C);
-
-/* ******************* editmesh_loop.c */
-
-#define LOOP_SELECT 1
-#define LOOP_CUT 2
-
void MESH_OT_knife_cut(struct wmOperatorType *ot);

/* ******************* editmesh_mods.c */
@@ -170,45 +81,6 @@
void MESH_OT_select_nth(struct wmOperatorType *ot);


-extern EditEdge *findnearestedge(ViewContext *vc, int *dist);
-extern void EM_automerge(Scene *scene, Object *obedit, int update);
-void editmesh_select_by_material(EditMesh *em, int index);
-void EM_recalc_normal_direction(EditMesh *em, int inside, int select); /* makes faces righthand turning */
-void EM_select_more(EditMesh *em);
-void selectconnected_mesh_all(EditMesh *em);
-void faceloop_select(EditMesh *em, EditEdge *startedge, int select);
-
-/**
- * findnearestvert
- *
- * dist (in/out): minimal distance to the nearest and at the end, actual distance
- * sel: selection bias
- * if SELECT, selected vertice are given a 5 pixel bias to make them farter than unselect verts
- * if 0, unselected vertice are given the bias
- * strict: if 1, the vertice corresponding to the sel parameter are ignored and not just biased
- */
-extern EditVert *findnearestvert(ViewContext *vc, int *dist, short sel, short strict);
-
-
-/* ******************* editmesh_tools.c */
-
-#define SUBDIV_SELECT_ORIG 0
-#define SUBDIV_SELECT_INNER 1
-#define SUBDIV_SELECT_INNER_SEL 2
-#define SUBDIV_SELECT_LOOPCUT 3
-
-/* edge subdivide corner cut types */
-#define SUBDIV_CORNER_PATH 0
-#define SUBDIV_CORNER_INNERVERT 1
-#define SUBDIV_CORNER_FAN 2
-
-extern EnumPropertyItem corner_type_items[];
-
-void join_triangles(EditMesh *em);
-int removedoublesflag(EditMesh *em, short flag, short automerge, float limit); /* return amount */
-void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float fractal, int beautify, int numcuts, int corner_pattern, int seltype);
-int EdgeSlide(EditMesh *em, struct wmOperator *op, short immediate, float imperc);
-
void MESH_OT_merge(struct wmOperatorType *ot);
void MESH_OT_subdivide(struct wmOperatorType *ot);
void MESH_OT_remove_doubles(struct wmOperatorType *ot);
@@ -243,7 +115,9 @@
void MESH_OT_blend_from_shape(struct wmOperatorType *ot);

/* ******************* mesh_data.c */
+int EdgeSlide(struct EditMesh *em, struct wmOperator *op, short immediate, float imperc);

+
void MESH_OT_uv_texture_add(struct wmOperatorType *ot);
void MESH_OT_uv_texture_remove(struct wmOperatorType *ot);
void MESH_OT_vertex_color_add(struct wmOperatorType *ot);
@@ -255,5 +129,6 @@
void MESH_OT_edgering_select(struct wmOperatorType *ot);
void MESH_OT_loopcut(struct wmOperatorType *ot);

-#endif // MESH_INTERN_H

+#endif /* MESH_INTERN */
+
Index: source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- source/blender/editors/sculpt_paint/sculpt.c (revision 28882)
+++ source/blender/editors/sculpt_paint/sculpt.c (working copy)
@@ -38,6 +38,7 @@
#include "BLI_ghash.h"
#include "BLI_pbvh.h"
#include "BLI_threads.h"
+#include "BLI_editVert.h"

#include "DNA_key_types.h"
#include "DNA_mesh_types.h"
@@ -73,6 +74,7 @@
#include "ED_screen.h"
#include "ED_sculpt.h"
#include "ED_view3d.h"
+#include "ED_mesh.h"
#include "paint_intern.h"
#include "sculpt_intern.h"

@@ -113,6 +115,7 @@
int flag;
float clip_tolerance[3];
float initial_mouse[2];
+ float detail;

/* Variants */
float radius;
@@ -302,6 +305,7 @@
Object *ob = CTX_data_active_object(C);
DerivedMesh *dm = mesh_get_derived_final(scene, ob, 0);
SculptSession *ss = ob->sculpt;
+
SculptUndoNode *unode;
MVert *mvert;
MultiresModifierData *mmd;
@@ -536,7 +540,74 @@
/* ===== Sculpting =====
*
*/
+
+static void create_EditMesh_sculpt(SculptSession *ss) //Mio
+{
+ EditEdge *eed;
+ Object *obedit= ss->ob;
+ Mesh *me= obedit->data;
+
+ int tempselectmode = ss->scene->toolsettings->selectmode; /* store temporal scene select mode*/
+ ss->scene->toolsettings->selectmode = SCE_SELECT_VERTEX;
+
+ make_editMesh(ss->scene, obedit);
+ EditMesh *em = me->edit_mesh;
+
+ ss->scene->toolsettings->selectmode = tempselectmode; /* restore scene select mode*/
+
+ /*select all edges associated with every selected vertex*/
+ for(eed= em->edges.first; eed; eed= eed->next){
+ if(eed->v1->f&SELECT) eed->f1 = 1;
+ else if(eed->v2->f&SELECT) eed->f1 = 1;
+ }
+
+ for(eed= em->edges.first; eed; eed= eed->next)
+ if(eed->f1 == 1) EM_select_edge(eed,1);
+
+ ss->em = em;
+}

+static void unlimited_clay(SculptSession *ss, Object *ob)
+{
+ /*---- adaptive dynamic subdivission -- */
+ float v1co[3],v2co[3],diff[3], edgeLength;
+
+ if (ss->scene != NULL && ob != NULL)
+ {
+ create_EditMesh_sculpt(ss);
+ Object *obedit= ob;
+ Mesh *me= obedit->data;
+ EditEdge *eed;
+
+ for(eed = me->edit_mesh->edges.first; eed; eed = eed->next){
+ if (eed->f & SELECT)
+ {
+ sub_v3_v3v3(diff, eed->v1->co, eed->v2->co);
+ edgeLength = len_v3(diff);
+
+ float detail = ss->cache->detail * ss->cache->radius;
+
+ if (edgeLength < detail)
+ EM_select_edge(eed, 0);
+ else
+ EM_select_edge(eed, 1);
+
+ }
+
+ }
+ esubdivideflag(obedit, me->edit_mesh, SELECT,0.4,0,B_SMOOTH,1, SUBDIV_CORNER_PATH, SUBDIV_SELECT_INNER);
+
+ /* Clear selection */
+ for(eed = me->edit_mesh->edges.first; eed; eed = eed->next)
+ EM_select_edge(eed, 0);
+
+ load_editMesh(ss->scene, ob);
+ DAG_id_flush_update(ob->data, OB_RECALC_DATA); //?
+ }
+
+}
+
+
/* Return modified brush strength. Includes the direction of the brush, positive
values pull vertices, negative values push. Uses tablet pressure and a
special multiplier found experimentally to scale the strength factor. */
@@ -864,15 +935,20 @@
vd.co[2] + offset[2]*fade};

sculpt_clip(sd, ss, vd.co, val);
- if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if(vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1;
+ }
}
}
BLI_pbvh_vertex_iter_end;

BLI_pbvh_node_mark_update(nodes[n]);
}
+
}

+
/* For the smooth brush, uses the neighboring vertices around vert to calculate
a smoothed location for vert. Skips corner vertices (used by only one
polygon.) */
@@ -883,8 +959,8 @@
char ncount= BLI_countlist(&ss->fmap[vert]);
MFace *f;

- avg[0] = avg[1] = avg[2] = 0;
-
+ avg[0] = avg[1] = avg[2] = 0;
+
/* Don't modify corner vertices */
if(ncount==1) {
copy_v3_v3(avg, ss->mvert[vert].co);
@@ -893,7 +969,7 @@

while(node){
f= &ss->mface[node->index];
-
+
if(f->v4) {
skip= (f->v1==vert?2:
f->v2==vert?3:
@@ -906,6 +982,7 @@
add_v3_v3(avg, ss->mvert[(&f->v1)[i]].co);
++total;
}
+
}

node= node->next;
@@ -939,7 +1016,10 @@
val[2] = vd.co[2]+(avg[2]-vd.co[2])*fade;

sculpt_clip(sd, ss, vd.co, val);
- if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if(vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1;
+ }
}
}
BLI_pbvh_vertex_iter_end;
@@ -1068,7 +1148,10 @@
vd.co[2]+(test.location[2]-vd.co[2])*fade};

sculpt_clip(sd, ss, vd.co, val);
- if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if(vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1;
+ }
}
}
BLI_pbvh_vertex_iter_end;
@@ -1082,8 +1165,8 @@
Brush *brush = paint_brush(&sd->paint);
float bstrength= ss->cache->bstrength;
float grab_delta[3];
- int n;
-
+ int n;
+
copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);

#pragma omp parallel for private(n) schedule(static)
@@ -1103,7 +1186,10 @@
vd.co[2]+fade*grab_delta[2]};

sculpt_clip(sd, ss, vd.co, add);
- if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if(vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1;
+ }
}
}
BLI_pbvh_vertex_iter_end;
@@ -1171,7 +1257,10 @@
}

sculpt_clip(sd, ss, vd.co, val);
- if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if(vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1;
+ }
}
}
BLI_pbvh_vertex_iter_end;
@@ -1184,7 +1273,9 @@
{
Brush *brush = paint_brush(&sd->paint);
float bstrength= ss->cache->bstrength;
- int n;
+ int n, exitmode = 0;
+
+

#pragma omp parallel for private(n) schedule(static)
for(n=0; n<totnode; n++) {
@@ -1209,7 +1300,10 @@
add_v3_v3(add, vd.co);

sculpt_clip(sd, ss, vd.co, add);
- if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if(vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1;
+ }
}
}
BLI_pbvh_vertex_iter_end;
@@ -1297,7 +1391,7 @@
float area_normal[3];
float cntr[3], cntr2[3] = {0}, bstr = 0;
int n, flip = 0;
-
+
calc_area_normal(sd, ss, area_normal, nodes, totnode);
calc_flatten_center(sd, ss, nodes, totnode, cntr);

@@ -1307,7 +1401,7 @@
cntr2[0]=cntr[0]+area_normal[0]*bstr*ss->cache->scale[0];
cntr2[1]=cntr[1]+area_normal[1]*bstr*ss->cache->scale[1];
cntr2[2]=cntr[2]+area_normal[2]*bstr*ss->cache->scale[2];
- flip = bstr < 0;
+ flip = bstr < 0;
}

//#pragma omp parallel for private(n) schedule(static)
@@ -1346,11 +1440,15 @@
add_v3_v3(val, vd.co);

sculpt_clip(sd, ss, vd.co, val);
- if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if(vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1;
+ }
+
}
}
}
- BLI_pbvh_vertex_iter_end;
+ BLI_pbvh_vertex_iter_end;

BLI_pbvh_node_mark_update(nodes[n]);
}
@@ -1514,8 +1612,6 @@
{
DerivedMesh *dm = mesh_get_derived_final(scene, ob, 0);
SculptSession *ss = ob->sculpt;
-
- ss->ob= ob;

if((ob->shapeflag & OB_SHAPE_LOCK) && !sculpt_multires_active(ob)) {
ss->kb= ob_get_keyblock(ob);
@@ -1678,6 +1774,7 @@

cache->vc = vc;
cache->brush = brush;
+ if (brush->flag & BRUSH_SUBDIV) cache->detail = brush->detail;

cache->mats = MEM_callocN(sizeof(bglMats), "sculpt bglMats");
view3d_get_transformation(vc->ar, vc->rv3d, vc->obact, cache->mats);
@@ -1728,7 +1825,7 @@
cache->flip = RNA_boolean_get(ptr, "flip");
RNA_float_get_array(ptr, "mouse", cache->mouse);
cache->pressure = RNA_float_get(ptr, "pressure");
-
+
/* Truly temporary data that isn't stored in properties */

cache->previous_pixel_radius = cache->pixel_radius;
@@ -1842,6 +1939,7 @@
{
ViewContext *vc = paint_stroke_view_context(stroke);
SculptSession *ss= vc->obact->sculpt;
+
StrokeCache *cache= ss->cache;
float ray_start[3], ray_end[3], ray_normal[3], dist;
float obimat[4][4];
@@ -1919,6 +2017,7 @@
Object *ob= CTX_data_active_object(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
SculptSession *ss = CTX_data_active_object(C)->sculpt;
+
Brush *brush = paint_brush(&sd->paint);

if(ob_get_key(ob) && !(ob->shapeflag & OB_SHAPE_LOCK)) {
@@ -1983,9 +2082,10 @@
{
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
+ SculptSession *ss = ob->sculpt;
ARegion *ar = CTX_wm_region(C);
MultiresModifierData *mmd = ss->multires;
+
int redraw = 0;

if(mmd)
@@ -2028,17 +2128,17 @@
/* Don't start the stroke until mouse goes over the mesh */
if(over_mesh(C, op, event->x, event->y)) {
Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
+ SculptSession *ss = ob->sculpt;
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
-
+
ED_view3d_init_mats_rv3d(ob, CTX_wm_region_view3d(C));

sculpt_brush_stroke_init_properties(C, op, event, ss);

- sculpt_update_cache_invariants(sd, ss, C, op);
+ sculpt_update_cache_invariants(sd, ss, C, op);

- sculpt_undo_push_begin(ss, sculpt_tool_name(sd));
-
+ sculpt_undo_push_begin(ss, sculpt_tool_name(sd));
+
return 1;
}
else
@@ -2048,8 +2148,8 @@
static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
{
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- SculptSession *ss = CTX_data_active_object(C)->sculpt;
-
+ SculptSession *ss = CTX_data_active_object(C)->sculpt;
+
sculpt_stroke_modifiers_check(C, ss);
sculpt_update_cache_variants(sd, ss, stroke, itemptr);
sculpt_restore_mesh(sd, ss);
@@ -2063,11 +2163,15 @@
{
Object *ob= CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ Brush *brush = paint_brush(&sd->paint);

/* Finished */
if(ss->cache) {
sculpt_stroke_modifiers_check(C, ss);
-
+
+ if(brush->flag & BRUSH_SUBDIV) unlimited_clay(ss, ob);
+
sculpt_cache_free(ss->cache);
ss->cache = NULL;

@@ -2077,7 +2181,7 @@

if(ss->refkb) sculpt_key_to_mesh(ss->refkb, ob);

- ss->partial_redraw = 0;
+ ss->partial_redraw = 0;

/* try to avoid calling this, only for e.g. linked duplicates now */
if(((Mesh*)ob->data)->id.us > 1)
@@ -2122,7 +2226,7 @@
{
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
SculptSession *ss = CTX_data_active_object(C)->sculpt;
-
+
if(!sculpt_brush_stroke_init(C, op->reports))
return OPERATOR_CANCELLED;

@@ -2130,7 +2234,7 @@
sculpt_stroke_update_step, sculpt_stroke_done);

sculpt_update_cache_invariants(sd, ss, C, op);
-
+
paint_stroke_exec(C, op);

sculpt_flush_update(C);
@@ -2181,7 +2285,7 @@
static int sculpt_set_persistent_base(bContext *C, wmOperator *op)
{
SculptSession *ss = CTX_data_active_object(C)->sculpt;
-
+
if(ss) {
if(ss->layer_co)
MEM_freeN(ss->layer_co);
@@ -2208,8 +2312,11 @@

static void sculpt_init_session(Scene *scene, Object *ob)
{
- ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
+ ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");

+ ob->sculpt->ob = ob; //Mio
+ ob->sculpt->scene = scene;
+
sculpt_update_mesh_elements(scene, ob, 0);

if(ob->sculpt->refkb)
Index: source/blender/makesdna/DNA_brush_types.h
===================================================================
--- source/blender/makesdna/DNA_brush_types.h (revision 28882)
+++ source/blender/makesdna/DNA_brush_types.h (working copy)
@@ -56,6 +56,7 @@

short flag, blend; /* general purpose flag, blend mode */
int size; /* brush diameter */
+ float detail,pad; /* dynamic subdivission detail */
float jitter; /* jitter the position of the brush */
float spacing; /* spacing of paint operations */
int smooth_stroke_radius; /* turning radius (in pixels) for smooth stroke */
@@ -87,6 +88,7 @@
#define BRUSH_PERSISTENT 4096
#define BRUSH_ACCUMULATE 8192
#define BRUSH_LOCK_ALPHA 16384
+#define BRUSH_SUBDIV 32768

/* Brush.sculpt_tool */
#define SCULPT_TOOL_DRAW 1
Index: source/blender/makesdna/DNA_scene_types.h
===================================================================
--- source/blender/makesdna/DNA_scene_types.h (revision 28882)
+++ source/blender/makesdna/DNA_scene_types.h (working copy)
@@ -584,7 +584,7 @@

/* Control tablet input */
char tablet_size, tablet_strength;
- char pad[6];
+ char pad[6];
} Sculpt;

typedef struct VPaint {
Index: source/blender/makesrna/intern/rna_brush.c
===================================================================
--- source/blender/makesrna/intern/rna_brush.c (revision 28882)
+++ source/blender/makesrna/intern/rna_brush.c (working copy)
@@ -167,6 +167,11 @@
RNA_def_property_ui_text(prop, "Size", "Diameter of the brush");
RNA_def_property_update(prop, 0, "rna_Brush_update");

+ prop= RNA_def_property(srna, "detail", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.05f, 1.0f);
+ RNA_def_property_ui_text(prop, "Detail", "Dynamic subdivission detail");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
prop= RNA_def_property(srna, "jitter", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "jitter");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -273,6 +278,11 @@
RNA_def_property_ui_text(prop, "Accumulate", "Accumulate stroke dabs on top of each other");
RNA_def_property_update(prop, 0, "rna_Brush_update");

+ prop= RNA_def_property(srna, "use_dynamic_subdiv", PROP_BOOLEAN, PROP_NONE); //Mio
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SUBDIV);
+ RNA_def_property_ui_text(prop, "Unlimited clay", "Dynamic subdivission on the fly while sculpting");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
/* not exposed in the interface yet
prop= RNA_def_property(srna, "fixed_tex", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_FIXED_TEX);
  1. Index: release/scripts/ui/space_view3d_toolbar.py
  2. ===================================================================
  3. --- release/scripts/ui/space_view3d_toolbar.py  (revision 28882)
  4. +++ release/scripts/ui/space_view3d_toolbar.py  (working copy)
  5. @@ -547,7 +547,7 @@
  6.              col.separator()
  7.  
  8.              row = col.row(align=True)
  9. -            row.prop(brush, "size", slider=True)
  10. +            row.prop(brush, "size", slider=True)                  
  11.  
  12.              if brush.sculpt_tool != 'GRAB':
  13.                  row.prop(brush, "use_size_pressure", toggle=True, text="")
  14. @@ -559,16 +559,15 @@
  15.                  # XXX - TODO
  16.                  #row = col.row(align=True)
  17.                  #row.prop(brush, "jitter", slider=True)
  18. -                #row.prop(brush, "use_jitter_pressure", toggle=True, text="")
  19. -
  20. +                #row.prop(brush, "use_jitter_pressure", toggle=True, text="")                
  21.                  col = layout.column()
  22.  
  23.                  if brush.sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'):
  24.                      col.row().prop(brush, "direction", expand=True)
  25.  
  26.                  if brush.sculpt_tool in ('DRAW', 'INFLATE', 'LAYER'):
  27. -                    col.prop(brush, "use_accumulate")
  28. -
  29. +                    col.prop(brush, "use_accumulate")                     
  30. +       
  31.                  if brush.sculpt_tool == 'LAYER':
  32.                      ob = context.sculpt_object
  33.                      do_persistent = True
  34. @@ -581,6 +580,10 @@
  35.                      if do_persistent:
  36.                          col.prop(brush, "use_persistent")
  37.                          col.operator("sculpt.set_persistent_base")
  38. +                        
  39. +            col.prop(brush,"use_dynamic_subdiv")
  40. +            if brush.use_dynamic_subdiv ==True:
  41. +                col.prop(brush,"detail",slider=True)
  42.  
  43.          # Texture Paint Mode #
  44.  
  45. Index: source/blender/blenkernel/BKE_paint.h
  46. ===================================================================
  47. --- source/blender/blenkernel/BKE_paint.h       (revision 28882)
  48. +++ source/blender/blenkernel/BKE_paint.h       (working copy)
  49. @@ -72,6 +72,9 @@
  50.         struct Object *ob;
  51.         struct KeyBlock *kb, *refkb;
  52.         
  53. +       struct Scene *scene; //Mio
  54. +       struct EditMesh *em; //Mio  
  55. +                      
  56.         /* Mesh connectivity */
  57.         struct ListBase *fmap;
  58.  
  59. Index: source/blender/blenkernel/intern/brush.c
  60. ===================================================================
  61. --- source/blender/blenkernel/intern/brush.c    (revision 28882)
  62. +++ source/blender/blenkernel/intern/brush.c    (working copy)
  63. @@ -83,6 +83,7 @@
  64.         brush->clone.alpha= 0.5;
  65.         brush->sculpt_tool = SCULPT_TOOL_DRAW;
  66.         brush->flag |= BRUSH_SPACE;
  67. +       brush->detail = 0.25f;
  68.  
  69.         brush_curve_preset(brush, CURVE_PRESET_SMOOTH);
  70.         
  71. Index: source/blender/blenkernel/intern/object.c
  72. ===================================================================
  73. --- source/blender/blenkernel/intern/object.c   (revision 28882)
  74. +++ source/blender/blenkernel/intern/object.c   (working copy)
  75. @@ -243,8 +243,8 @@
  76.                         MEM_freeN(ss->texcache);
  77.  
  78.                 if(ss->layer_co)
  79. -                       MEM_freeN(ss->layer_co);
  80. -
  81. +                       MEM_freeN(ss->layer_co);       
  82. +                              
  83.                 MEM_freeN(ss);
  84.  
  85.                 ob->sculpt = NULL;
  86. Index: source/blender/editors/include/ED_mesh.h
  87. ===================================================================
  88. --- source/blender/editors/include/ED_mesh.h    (revision 28882)
  89. +++ source/blender/editors/include/ED_mesh.h    (working copy)
  90. @@ -221,5 +221,134 @@
  91.  int ED_mesh_color_add(struct bContext *C, struct Scene *scene, struct Object *ob, struct Mesh *me);
  92.  int ED_mesh_color_remove(struct bContext *C, struct Object *ob, struct Mesh *me);
  93.  
  94. +//---ibli
  95. +
  96. +/* Internal for editmesh_xxxx.c functions */
  97. +struct bContext;
  98. +struct wmOperatorType;
  99. +struct wmOperator;
  100. +
  101. +
  102. +#define UVCOPY(t, s) memcpy(t, s, 2 * sizeof(float));
  103. +
  104. +/* ******************** editface.c */
  105. +
  106. +int edgetag_context_check(struct Scene *scene,struct EditEdge *eed);
  107. +void edgetag_context_set(struct Scene *scene, struct EditEdge *eed, int val);
  108. +int edgetag_shortest_path(struct Scene *scene,struct EditMesh *em,struct EditEdge *source,struct EditEdge *target);
  109. +
  110. +/* ******************* editmesh.c */
  111. +
  112. +extern void free_editvert(struct  EditMesh *em, struct EditVert *eve);
  113. +extern void free_editedge(struct EditMesh *em, struct EditEdge *eed);
  114. +extern void free_editface(struct EditMesh *em, struct EditFace *efa);
  115. +void free_editMesh(struct EditMesh *em);
  116. +
  117. +extern void free_vertlist(struct EditMesh *em, struct ListBase *edve);
  118. +extern void free_edgelist(struct EditMesh *em,struct  ListBase *lb);
  119. +extern void free_facelist(struct EditMesh *em,struct  ListBase *lb);
  120. +
  121. +extern void remedge(struct EditMesh *em,struct EditEdge *eed);
  122. +
  123. +extern struct EditVert *addvertlist(struct EditMesh *em, float *vec, struct EditVert *example);
  124. +extern struct EditEdge *addedgelist(struct EditMesh *em, struct EditVert *v1, struct EditVert *v2, struct EditEdge *example);
  125. +extern struct EditFace *addfacelist(struct EditMesh *em, struct EditVert *v1, struct EditVert *v2, struct EditVert *v3, struct EditVert *v4, struct EditFace *example, struct EditFace *exampleEdges);
  126. +extern struct EditEdge *findedgelist(struct EditMesh *em, struct EditVert *v1, struct EditVert *v2);
  127. +
  128. +void em_setup_viewcontext(struct bContext *C, struct ViewContext *vc);
  129. +
  130. +/* ******************* editmesh_lib.c */
  131. +void EM_stats_update(struct EditMesh *em);
  132. +
  133. +extern void EM_fgon_flags(struct EditMesh *em);
  134. +extern void EM_hide_reset(struct EditMesh *em);
  135. +
  136. +extern int faceselectedOR(struct EditFace *efa, int flag);
  137. +extern int faceselectedAND(struct EditFace *efa, int flag);
  138. +
  139. +void EM_remove_selection(struct EditMesh *em, void *data, int type);
  140. +void EM_clear_flag_all(struct EditMesh *em, int flag);
  141. +void EM_set_flag_all(struct EditMesh *em, int flag);
  142. +void EM_set_flag_all_selectmode(struct EditMesh *em, int flag);
  143. +
  144. +void EM_data_interp_from_verts(struct EditMesh *em,struct  EditVert *v1, struct EditVert *v2, struct EditVert *eve, float fac);
  145. +void EM_data_interp_from_faces(struct EditMesh *em,struct  EditFace *efa1,struct  EditFace *efa2,struct  EditFace *efan, int i1, int i2, int i3, int i4);
  146. +
  147. +int EM_nvertices_selected(struct EditMesh *em);
  148. +int EM_nedges_selected(struct EditMesh *em);
  149. +int EM_nfaces_selected(struct EditMesh *em);
  150. +
  151. +float EM_face_perimeter(struct EditFace *efa);
  152. +
  153. +void EM_store_selection(struct EditMesh *em, void *data, int type);
  154. +
  155. +extern struct EditFace *exist_face(struct EditMesh *em, struct  EditVert *v1,struct  EditVert *v2,struct  EditVert *v3, struct EditVert *v4);
  156. +extern void flipface(struct EditMesh *em, struct  EditFace *efa); // flips for normal direction
  157. +extern int compareface(struct EditFace *vl1,struct EditFace *vl2);
  158. +
  159. +/* flag for selection bits, *nor will be filled with normal for extrusion constraint */
  160. +/* return value defines if such normal was set */
  161. +extern short extrudeflag_face_indiv(struct EditMesh *em, short flag, float *nor);
  162. +extern short extrudeflag_verts_indiv(struct EditMesh *em, short flag, float *nor);
  163. +extern short extrudeflag_edges_indiv(struct EditMesh *em, short flag, float *nor);
  164. +extern short extrudeflag_vert(struct Object *obedit,struct  EditMesh *em, short flag, float *nor, int all);
  165. +extern short extrudeflag(struct Object *obedit,struct  EditMesh *em, short flag, float *nor, int all);
  166. +
  167. +extern void adduplicateflag(struct EditMesh *em, int flag);
  168. +extern void delfaceflag(struct EditMesh *em, int flag);
  169. +
  170. +extern void rotateflag(struct EditMesh *em, short flag, float *cent, float rotmat[][3]);
  171. +extern void translateflag(struct EditMesh *em, short flag, float *vec);
  172. +
  173. +extern int convex(float *v1, float *v2, float *v3, float *v4);
  174. +
  175. +extern struct EditFace *EM_face_from_faces(struct EditMesh *em, struct EditFace *efa1,struct EditFace *efa2, int i1, int i2, int i3, int i4);
  176. +
  177. +extern int EM_view3d_poll(struct bContext *C);
  178. +
  179. +/* ******************* editmesh_loop.c */
  180. +
  181. +#define LOOP_SELECT    1
  182. +#define LOOP_CUT       2
  183. +
  184. +
  185. +extern struct EditEdge *findnearestedge(struct ViewContext *vc, int *dist);
  186. +extern void EM_automerge(struct Scene *scene,struct Object *obedit, int update);
  187. +void editmesh_select_by_material(struct EditMesh *em, int index);
  188. +void EM_recalc_normal_direction(struct EditMesh *em, int inside, int select);  /* makes faces righthand turning */
  189. +void EM_select_more(struct EditMesh *em);
  190. +void selectconnected_mesh_all(struct EditMesh *em);
  191. +void faceloop_select(struct EditMesh *em, struct EditEdge *startedge, int select);
  192. +
  193. +/**
  194. + * findnearestvert
  195. + *
  196. + * dist (in/out): minimal distance to the nearest and at the end, actual distance
  197. + * sel: selection bias
  198. + *             if SELECT, selected vertice are given a 5 pixel bias to make them farter than unselect verts
  199. + *             if 0, unselected vertice are given the bias
  200. + * strict: if 1, the vertice corresponding to the sel parameter are ignored and not just biased
  201. + */
  202. +extern struct EditVert *findnearestvert(struct ViewContext *vc, int *dist, short sel, short strict);
  203. +
  204. +
  205. +/* ******************* editmesh_tools.c */
  206. +
  207. +#define SUBDIV_SELECT_ORIG      0
  208. +#define SUBDIV_SELECT_INNER     1
  209. +#define SUBDIV_SELECT_INNER_SEL 2
  210. +#define SUBDIV_SELECT_LOOPCUT 3
  211. +
  212. +/* edge subdivide corner cut types */
  213. +#define SUBDIV_CORNER_PATH             0
  214. +#define SUBDIV_CORNER_INNERVERT        1
  215. +#define SUBDIV_CORNER_FAN              2
  216. +
  217. +
  218. +
  219. +void join_triangles(struct EditMesh *em);
  220. +int removedoublesflag(struct EditMesh *em, short flag, short automerge, float limit);          /* return amount */
  221. +void esubdivideflag(struct Object *obedit,struct  EditMesh *em, int flag, float smooth, float fractal, int beautify, int numcuts, int corner_pattern, int seltype);
  222. +
  223.  #endif /* ED_MESH_H */
  224.  
  225. Index: source/blender/editors/mesh/editmesh_tools.c
  226. ===================================================================
  227. --- source/blender/editors/mesh/editmesh_tools.c        (revision 28882)
  228. +++ source/blender/editors/mesh/editmesh_tools.c        (working copy)
  229. @@ -2611,7 +2611,7 @@
  230.         for(eve=em->verts.first; eve; eve=eve->next) {
  231.                 if(!(beauty & B_KNIFE)) /* knife sets this flag for vertex cuts */
  232.                         eve->f1 = 0;
  233. -               eve->f2 = 0;
  234. +               eve->f2 = 0;
  235.         }
  236.  
  237.         for (; md; md=md->next) {
  238. @@ -6745,7 +6745,7 @@
  239.         if(fractal != 0.0f)
  240.                 flag |= B_FRACTAL;
  241.  
  242. -       esubdivideflag(obedit, em, 1, smooth, fractal, ts->editbutflag|flag, cuts, corner_cut_pattern, 0);
  243. +       esubdivideflag(obedit, em, 1, smooth, fractal, ts->editbutflag|flag, cuts, corner_cut_pattern, 0);
  244.  
  245.         DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
  246.         WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
  247. Index: source/blender/editors/mesh/mesh_intern.h
  248. ===================================================================
  249. --- source/blender/editors/mesh/mesh_intern.h   (revision 28882)
  250. +++ source/blender/editors/mesh/mesh_intern.h   (working copy)
  251. @@ -26,47 +26,12 @@
  252.   *
  253.   * ***** END GPL LICENSE BLOCK *****
  254.   */
  255. +#ifndef MESH_INTERN
  256. +#define MESH_INTERN
  257.  
  258. -/* Internal for editmesh_xxxx.c functions */
  259. +extern EnumPropertyItem corner_type_items[];
  260.  
  261. -#ifndef MESH_INTERN_H
  262. -#define MESH_INTERN_H
  263. -
  264. -struct bContext;
  265. -struct wmOperatorType;
  266. -struct wmOperator;
  267. -
  268. -
  269. -#define UVCOPY(t, s) memcpy(t, s, 2 * sizeof(float));
  270. -
  271. -/* ******************** editface.c */
  272. -
  273. -int edgetag_context_check(Scene *scene, EditEdge *eed);
  274. -void edgetag_context_set(Scene *scene, EditEdge *eed, int val);
  275. -int edgetag_shortest_path(Scene *scene, EditMesh *em, EditEdge *source, EditEdge *target);
  276. -
  277. -/* ******************* editmesh.c */
  278. -
  279. -extern void free_editvert(EditMesh *em, EditVert *eve);
  280. -extern void free_editedge(EditMesh *em, EditEdge *eed);
  281. -extern void free_editface(EditMesh *em, EditFace *efa);
  282. -void free_editMesh(EditMesh *em);
  283. -
  284. -extern void free_vertlist(EditMesh *em, ListBase *edve);
  285. -extern void free_edgelist(EditMesh *em, ListBase *lb);
  286. -extern void free_facelist(EditMesh *em, ListBase *lb);
  287. -
  288. -extern void remedge(EditMesh *em, EditEdge *eed);
  289. -
  290. -extern struct EditVert *addvertlist(EditMesh *em, float *vec, struct EditVert *example);
  291. -extern struct EditEdge *addedgelist(EditMesh *em, struct EditVert *v1, struct EditVert *v2, struct EditEdge *example);
  292. -extern struct EditFace *addfacelist(EditMesh *em, struct EditVert *v1, struct EditVert *v2, struct EditVert *v3, struct EditVert *v4, struct EditFace *example, struct EditFace *exampleEdges);
  293. -extern struct EditEdge *findedgelist(EditMesh *em, struct EditVert *v1, struct EditVert *v2);
  294. -
  295. -void em_setup_viewcontext(struct bContext *C, ViewContext *vc);
  296. -
  297.  void MESH_OT_separate(struct wmOperatorType *ot);
  298. -
  299.  /* ******************* editmesh_add.c */
  300.  void MESH_OT_primitive_plane_add(struct wmOperatorType *ot);
  301.  void MESH_OT_primitive_cube_add(struct wmOperatorType *ot);
  302. @@ -85,61 +50,7 @@
  303.  void MESH_OT_fgon_make(struct wmOperatorType *ot);
  304.  void MESH_OT_fgon_clear(struct wmOperatorType *ot);
  305.  
  306. -/* ******************* editmesh_lib.c */
  307. -void EM_stats_update(EditMesh *em);
  308.  
  309. -extern void EM_fgon_flags(EditMesh *em);
  310. -extern void EM_hide_reset(EditMesh *em);
  311. -
  312. -extern int faceselectedOR(EditFace *efa, int flag);
  313. -extern int faceselectedAND(EditFace *efa, int flag);
  314. -
  315. -void EM_remove_selection(EditMesh *em, void *data, int type);
  316. -void EM_clear_flag_all(EditMesh *em, int flag);
  317. -void EM_set_flag_all(EditMesh *em, int flag);
  318. -void EM_set_flag_all_selectmode(EditMesh *em, int flag);
  319. -
  320. -void EM_data_interp_from_verts(EditMesh *em, EditVert *v1, EditVert *v2, EditVert *eve, float fac);
  321. -void EM_data_interp_from_faces(EditMesh *em, EditFace *efa1, EditFace *efa2, EditFace *efan, int i1, int i2, int i3, int i4);
  322. -
  323. -int EM_nvertices_selected(EditMesh *em);
  324. -int EM_nedges_selected(EditMesh *em);
  325. -int EM_nfaces_selected(EditMesh *em);
  326. -
  327. -float EM_face_perimeter(EditFace *efa);
  328. -
  329. -void EM_store_selection(EditMesh *em, void *data, int type);
  330. -
  331. -extern EditFace *exist_face(EditMesh *em, EditVert *v1, EditVert *v2, EditVert *v3, EditVert *v4);
  332. -extern void flipface(EditMesh *em, EditFace *efa); // flips for normal direction
  333. -extern int compareface(EditFace *vl1, EditFace *vl2);
  334. -
  335. -/* flag for selection bits, *nor will be filled with normal for extrusion constraint */
  336. -/* return value defines if such normal was set */
  337. -extern short extrudeflag_face_indiv(EditMesh *em, short flag, float *nor);
  338. -extern short extrudeflag_verts_indiv(EditMesh *em, short flag, float *nor);
  339. -extern short extrudeflag_edges_indiv(EditMesh *em, short flag, float *nor);
  340. -extern short extrudeflag_vert(Object *obedit, EditMesh *em, short flag, float *nor, int all);
  341. -extern short extrudeflag(Object *obedit, EditMesh *em, short flag, float *nor, int all);
  342. -
  343. -extern void adduplicateflag(EditMesh *em, int flag);
  344. -extern void delfaceflag(EditMesh *em, int flag);
  345. -
  346. -extern void rotateflag(EditMesh *em, short flag, float *cent, float rotmat[][3]);
  347. -extern void translateflag(EditMesh *em, short flag, float *vec);
  348. -
  349. -extern int convex(float *v1, float *v2, float *v3, float *v4);
  350. -
  351. -extern struct EditFace *EM_face_from_faces(EditMesh *em, struct EditFace *efa1,
  352. -                                                                                  struct EditFace *efa2, int i1, int i2, int i3, int i4);
  353. -
  354. -extern int EM_view3d_poll(struct bContext *C);
  355. -
  356. -/* ******************* editmesh_loop.c */
  357. -
  358. -#define LOOP_SELECT    1
  359. -#define LOOP_CUT       2
  360. -
  361.  void MESH_OT_knife_cut(struct wmOperatorType *ot);
  362.  
  363.  /* ******************* editmesh_mods.c */
  364. @@ -170,45 +81,6 @@
  365.  void MESH_OT_select_nth(struct wmOperatorType *ot);
  366.  
  367.  
  368. -extern EditEdge *findnearestedge(ViewContext *vc, int *dist);
  369. -extern void EM_automerge(Scene *scene, Object *obedit, int update);
  370. -void editmesh_select_by_material(EditMesh *em, int index);
  371. -void EM_recalc_normal_direction(EditMesh *em, int inside, int select); /* makes faces righthand turning */
  372. -void EM_select_more(EditMesh *em);
  373. -void selectconnected_mesh_all(EditMesh *em);
  374. -void faceloop_select(EditMesh *em, EditEdge *startedge, int select);
  375. -
  376. -/**
  377. - * findnearestvert
  378. - *
  379. - * dist (in/out): minimal distance to the nearest and at the end, actual distance
  380. - * sel: selection bias
  381. - *             if SELECT, selected vertice are given a 5 pixel bias to make them farter than unselect verts
  382. - *             if 0, unselected vertice are given the bias
  383. - * strict: if 1, the vertice corresponding to the sel parameter are ignored and not just biased
  384. - */
  385. -extern EditVert *findnearestvert(ViewContext *vc, int *dist, short sel, short strict);
  386. -
  387. -
  388. -/* ******************* editmesh_tools.c */
  389. -
  390. -#define SUBDIV_SELECT_ORIG      0
  391. -#define SUBDIV_SELECT_INNER     1
  392. -#define SUBDIV_SELECT_INNER_SEL 2
  393. -#define SUBDIV_SELECT_LOOPCUT 3
  394. -
  395. -/* edge subdivide corner cut types */
  396. -#define SUBDIV_CORNER_PATH             0
  397. -#define SUBDIV_CORNER_INNERVERT        1
  398. -#define SUBDIV_CORNER_FAN              2
  399. -
  400. -extern EnumPropertyItem corner_type_items[];
  401. -
  402. -void join_triangles(EditMesh *em);
  403. -int removedoublesflag(EditMesh *em, short flag, short automerge, float limit);         /* return amount */
  404. -void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float fractal, int beautify, int numcuts, int corner_pattern, int seltype);
  405. -int EdgeSlide(EditMesh *em, struct wmOperator *op, short immediate, float imperc);
  406. -
  407.  void MESH_OT_merge(struct wmOperatorType *ot);
  408.  void MESH_OT_subdivide(struct wmOperatorType *ot);
  409.  void MESH_OT_remove_doubles(struct wmOperatorType *ot);
  410. @@ -243,7 +115,9 @@
  411.  void MESH_OT_blend_from_shape(struct wmOperatorType *ot);
  412.  
  413.  /* ******************* mesh_data.c */
  414. +int EdgeSlide(struct EditMesh *em, struct wmOperator *op, short immediate, float imperc);
  415.  
  416. +
  417.  void MESH_OT_uv_texture_add(struct wmOperatorType *ot);
  418.  void MESH_OT_uv_texture_remove(struct wmOperatorType *ot);
  419.  void MESH_OT_vertex_color_add(struct wmOperatorType *ot);
  420. @@ -255,5 +129,6 @@
  421.  void MESH_OT_edgering_select(struct wmOperatorType *ot);
  422.  void MESH_OT_loopcut(struct wmOperatorType *ot);
  423.  
  424. -#endif // MESH_INTERN_H
  425.  
  426. +#endif /* MESH_INTERN */
  427. +
  428. Index: source/blender/editors/sculpt_paint/sculpt.c
  429. ===================================================================
  430. --- source/blender/editors/sculpt_paint/sculpt.c        (revision 28882)
  431. +++ source/blender/editors/sculpt_paint/sculpt.c        (working copy)
  432. @@ -38,6 +38,7 @@
  433.  #include "BLI_ghash.h"
  434.  #include "BLI_pbvh.h"
  435.  #include "BLI_threads.h"
  436. +#include "BLI_editVert.h"
  437.  
  438.  #include "DNA_key_types.h"
  439.  #include "DNA_mesh_types.h"
  440. @@ -73,6 +74,7 @@
  441.  #include "ED_screen.h"
  442.  #include "ED_sculpt.h"
  443.  #include "ED_view3d.h"
  444. +#include "ED_mesh.h"
  445.  #include "paint_intern.h"
  446.  #include "sculpt_intern.h"
  447.  
  448. @@ -113,6 +115,7 @@
  449.         int flag;
  450.         float clip_tolerance[3];
  451.         float initial_mouse[2];
  452. +       float detail;
  453.  
  454.         /* Variants */
  455.         float radius;
  456. @@ -302,6 +305,7 @@
  457.         Object *ob = CTX_data_active_object(C);
  458.         DerivedMesh *dm = mesh_get_derived_final(scene, ob, 0);
  459.         SculptSession *ss = ob->sculpt;
  460. +                
  461.         SculptUndoNode *unode;
  462.         MVert *mvert;
  463.         MultiresModifierData *mmd;
  464. @@ -536,7 +540,74 @@
  465.  /* ===== Sculpting =====
  466.   *
  467.   */
  468. +
  469. +static void create_EditMesh_sculpt(SculptSession *ss) //Mio
  470. +{     
  471. +       EditEdge *eed; 
  472. +       Object *obedit= ss->ob;
  473. +       Mesh *me= obedit->data;
  474. +       
  475. +       int tempselectmode = ss->scene->toolsettings->selectmode; /* store temporal scene select mode*/
  476. +       ss->scene->toolsettings->selectmode = SCE_SELECT_VERTEX;       
  477. +       
  478. +       make_editMesh(ss->scene, obedit);                                              
  479. +       EditMesh *em = me->edit_mesh;   
  480. +       
  481. +       ss->scene->toolsettings->selectmode = tempselectmode; /* restore scene select mode*/   
  482. +              
  483. +       /*select all edges associated with every selected vertex*/
  484. +       for(eed= em->edges.first; eed; eed= eed->next){
  485. +               if(eed->v1->f&SELECT) eed->f1 = 1;
  486. +               else if(eed->v2->f&SELECT) eed->f1 = 1;
  487. +       }
  488. +                      
  489. +       for(eed= em->edges.first; eed; eed= eed->next)
  490. +               if(eed->f1 == 1) EM_select_edge(eed,1); 
  491. +              
  492. +       ss->em = em;
  493. +}
  494.  
  495. +static void unlimited_clay(SculptSession *ss, Object *ob)
  496. +{
  497. +       /*---- adaptive dynamic subdivission -- */
  498. +               float v1co[3],v2co[3],diff[3], edgeLength;      
  499. +                      
  500. +               if (ss->scene != NULL && ob != NULL)
  501. +               {
  502. +                       create_EditMesh_sculpt(ss);
  503. +                       Object *obedit= ob;
  504. +                       Mesh *me= obedit->data;                
  505. +                       EditEdge *eed;
  506. +                        
  507. +                       for(eed = me->edit_mesh->edges.first; eed; eed = eed->next){
  508. +                               if (eed->f & SELECT)
  509. +                               {
  510. +                                       sub_v3_v3v3(diff, eed->v1->co, eed->v2->co);
  511. +                                       edgeLength = len_v3(diff);
  512. +                                      
  513. +                                       float detail = ss->cache->detail * ss->cache->radius;  
  514. +                                                                                                                      
  515. +                                       if (edgeLength < detail)
  516. +                                               EM_select_edge(eed, 0); 
  517. +                                       else   
  518. +                                               EM_select_edge(eed, 1);                                        
  519. +                              
  520. +                               }                                                                      
  521. +                                      
  522. +                       }                                                                      
  523. +                       esubdivideflag(obedit, me->edit_mesh, SELECT,0.4,0,B_SMOOTH,1, SUBDIV_CORNER_PATH, SUBDIV_SELECT_INNER);                       
  524. +                      
  525. +                       /* Clear selection */
  526. +                       for(eed = me->edit_mesh->edges.first; eed; eed = eed->next)
  527. +                               EM_select_edge(eed, 0); 
  528. +                              
  529. +                       load_editMesh(ss->scene, ob);
  530. +                       DAG_id_flush_update(ob->data, OB_RECALC_DATA); //?                                     
  531. +               }      
  532. +
  533. +}
  534. +
  535. +
  536.  /* Return modified brush strength. Includes the direction of the brush, positive
  537.     values pull vertices, negative values push. Uses tablet pressure and a
  538.     special multiplier found experimentally to scale the strength factor. */
  539. @@ -864,15 +935,20 @@
  540.                                                            vd.co[2] + offset[2]*fade};
  541.  
  542.                                 sculpt_clip(sd, ss, vd.co, val);
  543. -                               if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
  544. +                               if(vd.mvert) {
  545. +                                       vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
  546. +                                       if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1;
  547. +                               }
  548.                         }
  549.                 }
  550.                 BLI_pbvh_vertex_iter_end;
  551.  
  552.                 BLI_pbvh_node_mark_update(nodes[n]);
  553.         }
  554. +       
  555.  }
  556.  
  557. +
  558.  /* For the smooth brush, uses the neighboring vertices around vert to calculate
  559.     a smoothed location for vert. Skips corner vertices (used by only one
  560.     polygon.) */
  561. @@ -883,8 +959,8 @@
  562.         char ncount= BLI_countlist(&ss->fmap[vert]);
  563.         MFace *f;
  564.  
  565. -       avg[0] = avg[1] = avg[2] = 0;
  566. -              
  567. +       avg[0] = avg[1] = avg[2] = 0;          
  568. +                              
  569.         /* Don't modify corner vertices */
  570.         if(ncount==1) {
  571.                 copy_v3_v3(avg, ss->mvert[vert].co);
  572. @@ -893,7 +969,7 @@
  573.  
  574.         while(node){
  575.                 f= &ss->mface[node->index];
  576. -              
  577. +                              
  578.                 if(f->v4) {
  579.                         skip= (f->v1==vert?2:
  580.                                    f->v2==vert?3:
  581. @@ -906,6 +982,7 @@
  582.                                 add_v3_v3(avg, ss->mvert[(&f->v1)[i]].co);
  583.                                 ++total;
  584.                         }
  585. +                      
  586.                 }
  587.  
  588.                 node= node->next;
  589. @@ -939,7 +1016,10 @@
  590.                         val[2] = vd.co[2]+(avg[2]-vd.co[2])*fade;
  591.                        
  592.                         sculpt_clip(sd, ss, vd.co, val);                       
  593. -                       if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
  594. +                       if(vd.mvert) {
  595. +                               vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
  596. +                               if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1;
  597. +                       }              
  598.                 }
  599.         }
  600.         BLI_pbvh_vertex_iter_end;
  601. @@ -1068,7 +1148,10 @@
  602.                                                            vd.co[2]+(test.location[2]-vd.co[2])*fade};
  603.  
  604.                                 sculpt_clip(sd, ss, vd.co, val);                       
  605. -                               if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
  606. +                               if(vd.mvert) {
  607. +                                       vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
  608. +                                       if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1;
  609. +                               }
  610.                         }
  611.                 }
  612.                 BLI_pbvh_vertex_iter_end;
  613. @@ -1082,8 +1165,8 @@
  614.         Brush *brush = paint_brush(&sd->paint);
  615.         float bstrength= ss->cache->bstrength;
  616.         float grab_delta[3];
  617. -       int n;
  618. -       
  619. +       int n; 
  620. +              
  621.         copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);
  622.  
  623.         #pragma omp parallel for private(n) schedule(static)
  624. @@ -1103,7 +1186,10 @@
  625.                                                            vd.co[2]+fade*grab_delta[2]};
  626.  
  627.                                 sculpt_clip(sd, ss, vd.co, add);                       
  628. -                               if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
  629. +                               if(vd.mvert) {
  630. +                                       vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
  631. +                                       if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1;
  632. +                               }
  633.                         }
  634.                 }
  635.                 BLI_pbvh_vertex_iter_end;
  636. @@ -1171,7 +1257,10 @@
  637.                                 }
  638.  
  639.                                 sculpt_clip(sd, ss, vd.co, val);
  640. -                               if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
  641. +                               if(vd.mvert) {
  642. +                                       vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
  643. +                                       if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1;
  644. +                               }
  645.                         }
  646.                 }
  647.                 BLI_pbvh_vertex_iter_end;
  648. @@ -1184,7 +1273,9 @@
  649.  {
  650.         Brush *brush = paint_brush(&sd->paint);
  651.         float bstrength= ss->cache->bstrength;
  652. -       int n;
  653. +       int n, exitmode = 0;
  654. +       
  655. +       
  656.  
  657.         #pragma omp parallel for private(n) schedule(static)
  658.         for(n=0; n<totnode; n++) {
  659. @@ -1209,7 +1300,10 @@
  660.                                 add_v3_v3(add, vd.co);
  661.                                
  662.                                 sculpt_clip(sd, ss, vd.co, add);
  663. -                               if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
  664. +                               if(vd.mvert) {
  665. +                                       vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
  666. +                                       if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1;
  667. +                               }
  668.                         }
  669.                 }
  670.                 BLI_pbvh_vertex_iter_end;
  671. @@ -1297,7 +1391,7 @@
  672.         float area_normal[3];
  673.         float cntr[3], cntr2[3] = {0}, bstr = 0;
  674.         int n, flip = 0;
  675. -
  676. +       
  677.         calc_area_normal(sd, ss, area_normal, nodes, totnode);
  678.         calc_flatten_center(sd, ss, nodes, totnode, cntr);
  679.  
  680. @@ -1307,7 +1401,7 @@
  681.                 cntr2[0]=cntr[0]+area_normal[0]*bstr*ss->cache->scale[0];
  682.                 cntr2[1]=cntr[1]+area_normal[1]*bstr*ss->cache->scale[1];
  683.                 cntr2[2]=cntr[2]+area_normal[2]*bstr*ss->cache->scale[2];
  684. -               flip = bstr < 0;
  685. +               flip = bstr < 0;         
  686.         }
  687.  
  688.         //#pragma omp parallel for private(n) schedule(static)
  689. @@ -1346,11 +1440,15 @@
  690.                                         add_v3_v3(val, vd.co);
  691.  
  692.                                         sculpt_clip(sd, ss, vd.co, val);
  693. -                                       if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
  694. +                                       if(vd.mvert) {
  695. +                                               vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
  696. +                                               if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1;
  697. +                                       }
  698. +
  699.                                 }
  700.                         }
  701.                 }
  702. -               BLI_pbvh_vertex_iter_end;
  703. +               BLI_pbvh_vertex_iter_end;       
  704.  
  705.                 BLI_pbvh_node_mark_update(nodes[n]);
  706.         }
  707. @@ -1514,8 +1612,6 @@
  708.  {
  709.         DerivedMesh *dm = mesh_get_derived_final(scene, ob, 0);
  710.         SculptSession *ss = ob->sculpt;
  711. -       
  712. -       ss->ob= ob;
  713.  
  714.         if((ob->shapeflag & OB_SHAPE_LOCK) && !sculpt_multires_active(ob)) {
  715.                 ss->kb= ob_get_keyblock(ob);
  716. @@ -1678,6 +1774,7 @@
  717.  
  718.         cache->vc = vc;
  719.         cache->brush = brush;
  720. +       if (brush->flag & BRUSH_SUBDIV) cache->detail = brush->detail;
  721.  
  722.         cache->mats = MEM_callocN(sizeof(bglMats), "sculpt bglMats");
  723.         view3d_get_transformation(vc->ar, vc->rv3d, vc->obact, cache->mats);
  724. @@ -1728,7 +1825,7 @@
  725.         cache->flip = RNA_boolean_get(ptr, "flip");
  726.         RNA_float_get_array(ptr, "mouse", cache->mouse);
  727.         cache->pressure = RNA_float_get(ptr, "pressure");
  728. -       
  729. +              
  730.         /* Truly temporary data that isn't stored in properties */
  731.  
  732.         cache->previous_pixel_radius = cache->pixel_radius;
  733. @@ -1842,6 +1939,7 @@
  734.  {
  735.         ViewContext *vc = paint_stroke_view_context(stroke);
  736.         SculptSession *ss= vc->obact->sculpt;
  737. +              
  738.         StrokeCache *cache= ss->cache;
  739.         float ray_start[3], ray_end[3], ray_normal[3], dist;
  740.         float obimat[4][4];
  741. @@ -1919,6 +2017,7 @@
  742.         Object *ob= CTX_data_active_object(C);
  743.         Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
  744.         SculptSession *ss = CTX_data_active_object(C)->sculpt;
  745. +              
  746.         Brush *brush = paint_brush(&sd->paint);
  747.  
  748.         if(ob_get_key(ob) && !(ob->shapeflag & OB_SHAPE_LOCK)) {
  749. @@ -1983,9 +2082,10 @@
  750.  {
  751.         Scene *scene = CTX_data_scene(C);
  752.         Object *ob = CTX_data_active_object(C);
  753. -       SculptSession *ss = ob->sculpt;
  754. +       SculptSession *ss = ob->sculpt; 
  755.         ARegion *ar = CTX_wm_region(C);
  756.         MultiresModifierData *mmd = ss->multires;
  757. +       
  758.         int redraw = 0;
  759.  
  760.         if(mmd)
  761. @@ -2028,17 +2128,17 @@
  762.         /* Don't start the stroke until mouse goes over the mesh */
  763.         if(over_mesh(C, op, event->x, event->y)) {
  764.                 Object *ob = CTX_data_active_object(C);
  765. -               SculptSession *ss = ob->sculpt;
  766. +               SculptSession *ss = ob->sculpt;        
  767.                 Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
  768. -
  769. +       
  770.                 ED_view3d_init_mats_rv3d(ob, CTX_wm_region_view3d(C));
  771.  
  772.                 sculpt_brush_stroke_init_properties(C, op, event, ss);
  773.  
  774. -               sculpt_update_cache_invariants(sd, ss, C, op);
  775. +               sculpt_update_cache_invariants(sd, ss, C, op);         
  776.  
  777. -               sculpt_undo_push_begin(ss, sculpt_tool_name(sd));
  778. -
  779. +               sculpt_undo_push_begin(ss, sculpt_tool_name(sd));                
  780. +              
  781.                 return 1;
  782.         }
  783.         else
  784. @@ -2048,8 +2148,8 @@
  785.  static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
  786.  {
  787.         Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
  788. -       SculptSession *ss = CTX_data_active_object(C)->sculpt;
  789. -
  790. +       SculptSession *ss = CTX_data_active_object(C)->sculpt;         
  791. +       
  792.         sculpt_stroke_modifiers_check(C, ss);
  793.         sculpt_update_cache_variants(sd, ss, stroke, itemptr);
  794.         sculpt_restore_mesh(sd, ss);
  795. @@ -2063,11 +2163,15 @@
  796.  {
  797.         Object *ob= CTX_data_active_object(C);
  798.         SculptSession *ss = ob->sculpt;
  799. +       Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
  800. +       Brush *brush = paint_brush(&sd->paint);
  801.  
  802.         /* Finished */
  803.         if(ss->cache) {
  804.                 sculpt_stroke_modifiers_check(C, ss);
  805. -
  806. +              
  807. +               if(brush->flag & BRUSH_SUBDIV) unlimited_clay(ss, ob);
  808. +                                              
  809.                 sculpt_cache_free(ss->cache);
  810.                 ss->cache = NULL;
  811.  
  812. @@ -2077,7 +2181,7 @@
  813.  
  814.                 if(ss->refkb) sculpt_key_to_mesh(ss->refkb, ob);
  815.  
  816. -               ss->partial_redraw = 0;
  817. +               ss->partial_redraw = 0;                
  818.                
  819.                 /* try to avoid calling this, only for e.g. linked duplicates now */
  820.                 if(((Mesh*)ob->data)->id.us > 1)
  821. @@ -2122,7 +2226,7 @@
  822.  {
  823.         Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
  824.         SculptSession *ss = CTX_data_active_object(C)->sculpt;
  825. -
  826. +              
  827.         if(!sculpt_brush_stroke_init(C, op->reports))
  828.                 return OPERATOR_CANCELLED;
  829.  
  830. @@ -2130,7 +2234,7 @@
  831.                                           sculpt_stroke_update_step, sculpt_stroke_done);
  832.  
  833.         sculpt_update_cache_invariants(sd, ss, C, op);
  834. -
  835. +       
  836.         paint_stroke_exec(C, op);
  837.  
  838.         sculpt_flush_update(C);
  839. @@ -2181,7 +2285,7 @@
  840.  static int sculpt_set_persistent_base(bContext *C, wmOperator *op)
  841.  {
  842.         SculptSession *ss = CTX_data_active_object(C)->sculpt;
  843. -
  844. +       
  845.         if(ss) {
  846.                 if(ss->layer_co)
  847.                         MEM_freeN(ss->layer_co);
  848. @@ -2208,8 +2312,11 @@
  849.  
  850.  static void sculpt_init_session(Scene *scene, Object *ob)
  851.  {
  852. -       ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
  853. +       ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
  854.         
  855. +       ob->sculpt->ob = ob; //Mio     
  856. +       ob->sculpt->scene = scene;
  857. +                      
  858.         sculpt_update_mesh_elements(scene, ob, 0);
  859.  
  860.         if(ob->sculpt->refkb)
  861. Index: source/blender/makesdna/DNA_brush_types.h
  862. ===================================================================
  863. --- source/blender/makesdna/DNA_brush_types.h   (revision 28882)
  864. +++ source/blender/makesdna/DNA_brush_types.h   (working copy)
  865. @@ -56,6 +56,7 @@
  866.         
  867.         short flag, blend;                      /* general purpose flag, blend mode */
  868.         int size;                                       /* brush diameter */
  869. +       float detail,pad;                       /* dynamic subdivission detail */
  870.         float jitter;                           /* jitter the position of the brush */
  871.         float spacing;                          /* spacing of paint operations */
  872.         int smooth_stroke_radius;               /* turning radius (in pixels) for smooth stroke */
  873. @@ -87,6 +88,7 @@
  874.  #define BRUSH_PERSISTENT               4096
  875.  #define BRUSH_ACCUMULATE               8192
  876.  #define BRUSH_LOCK_ALPHA               16384
  877. +#define BRUSH_SUBDIV                   32768                  
  878.  
  879.  /* Brush.sculpt_tool */
  880.  #define SCULPT_TOOL_DRAW    1
  881. Index: source/blender/makesdna/DNA_scene_types.h
  882. ===================================================================
  883. --- source/blender/makesdna/DNA_scene_types.h   (revision 28882)
  884. +++ source/blender/makesdna/DNA_scene_types.h   (working copy)
  885. @@ -584,7 +584,7 @@
  886.  
  887.         /* Control tablet input */
  888.         char tablet_size, tablet_strength;
  889. -       char pad[6];
  890. +       char pad[6];   
  891.  } Sculpt;
  892.  
  893.  typedef struct VPaint {
  894. Index: source/blender/makesrna/intern/rna_brush.c
  895. ===================================================================
  896. --- source/blender/makesrna/intern/rna_brush.c  (revision 28882)
  897. +++ source/blender/makesrna/intern/rna_brush.c  (working copy)
  898. @@ -167,6 +167,11 @@
  899.         RNA_def_property_ui_text(prop, "Size", "Diameter of the brush");
  900.         RNA_def_property_update(prop, 0, "rna_Brush_update");
  901.         
  902. +       prop= RNA_def_property(srna, "detail", PROP_FLOAT, PROP_NONE);
  903. +       RNA_def_property_range(prop, 0.05f, 1.0f);
  904. +       RNA_def_property_ui_text(prop, "Detail", "Dynamic subdivission detail");
  905. +       RNA_def_property_update(prop, 0, "rna_Brush_update");
  906. +       
  907.         prop= RNA_def_property(srna, "jitter", PROP_FLOAT, PROP_NONE);
  908.         RNA_def_property_float_sdna(prop, NULL, "jitter");
  909.         RNA_def_property_range(prop, 0.0f, 1.0f);
  910. @@ -273,6 +278,11 @@
  911.         RNA_def_property_ui_text(prop, "Accumulate", "Accumulate stroke dabs on top of each other");
  912.         RNA_def_property_update(prop, 0, "rna_Brush_update");
  913.         
  914. +       prop= RNA_def_property(srna, "use_dynamic_subdiv", PROP_BOOLEAN, PROP_NONE); //Mio
  915. +       RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SUBDIV);
  916. +       RNA_def_property_ui_text(prop, "Unlimited clay", "Dynamic subdivission on the fly while sculpting");
  917. +       RNA_def_property_update(prop, 0, "rna_Brush_update");
  918. +       
  919.         /* not exposed in the interface yet
  920.         prop= RNA_def_property(srna, "fixed_tex", PROP_BOOLEAN, PROP_NONE);
  921.         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_FIXED_TEX);
  922.  
go to heaven