forked from bartvdbraak/blender
2.5 Sculpt:
* Added a new Paint type in scene DNA. This is now the base struct for Sculpt. * The Paint type contains a list of Brushes, you can add or remove these much like material and texture slots. * Modified the UI for the new Paint type, now shows the list of brushes active for this mode * Added a New Brush operator, shows in the UI as a list of brush tool types to add * Made the sculpt tool property UI smaller and not expanded, expectation is that we will have a number of preset brushes that will cover the basic sculpt brush types TODO: * Vertex paint, weight paint, texture paint need to be converted to this system next * Add brush presets to the default blend
This commit is contained in:
parent
d5c990664e
commit
afa0fa5e29
@ -292,10 +292,22 @@ class VIEW3D_PT_tools_brush(PaintPanel):
|
||||
|
||||
settings = self.paint_settings(context)
|
||||
brush = settings.brush
|
||||
|
||||
|
||||
if not context.particle_edit_object:
|
||||
layout.split().row().template_ID(settings, "brush")
|
||||
|
||||
col = layout.split().column()
|
||||
if context.sculpt_object:
|
||||
row = col.row()
|
||||
row.template_list(settings, "brushes", settings, "active_brush_index", rows=2)
|
||||
|
||||
sub_col = row.column(align=True)
|
||||
sub_col.itemO("paint.brush_slot_add", icon="ICON_ZOOMIN", text="")
|
||||
sub_col.itemO("paint.brush_slot_remove", icon="ICON_ZOOMOUT", text="")
|
||||
|
||||
col.template_ID(settings, "brush")
|
||||
|
||||
if(context.sculpt_object):
|
||||
col.item_menu_enumO("brush.new", "sculpt_tool");
|
||||
|
||||
# Particle Mode #
|
||||
|
||||
# XXX This needs a check if psys is editable.
|
||||
@ -323,9 +335,7 @@ class VIEW3D_PT_tools_brush(PaintPanel):
|
||||
|
||||
# Sculpt Mode #
|
||||
|
||||
elif context.sculpt_object:
|
||||
layout.column().itemR(brush, "sculpt_tool", expand=True)
|
||||
|
||||
elif context.sculpt_object and settings.brush:
|
||||
col = layout.column()
|
||||
|
||||
row = col.row(align=True)
|
||||
@ -348,6 +358,8 @@ class VIEW3D_PT_tools_brush(PaintPanel):
|
||||
if brush.sculpt_tool == 'LAYER':
|
||||
col.itemR(brush, "persistent")
|
||||
col.itemO("sculpt.set_persistent_base")
|
||||
|
||||
col.itemR(brush, "sculpt_tool")
|
||||
|
||||
# Texture Paint Mode #
|
||||
|
||||
|
@ -38,13 +38,12 @@ struct Scene;
|
||||
struct wmOperator;
|
||||
|
||||
/* datablock functions */
|
||||
struct Brush *add_brush(char *name);
|
||||
struct Brush *add_brush(const char *name);
|
||||
struct Brush *copy_brush(struct Brush *brush);
|
||||
void make_local_brush(struct Brush *brush);
|
||||
void free_brush(struct Brush *brush);
|
||||
|
||||
/* brush library operations used by different paint panels */
|
||||
struct Brush **current_brush_source(struct Scene *sce);
|
||||
int brush_set_nr(struct Brush **current_brush, int nr);
|
||||
int brush_delete(struct Brush **current_brush);
|
||||
void brush_check_exists(struct Brush **brush);
|
||||
|
@ -28,7 +28,19 @@
|
||||
#ifndef BKE_PAINT_H
|
||||
#define BKE_PAINT_H
|
||||
|
||||
struct Brush;
|
||||
struct Object;
|
||||
struct Paint;
|
||||
struct Scene;
|
||||
|
||||
void free_paint(Paint *p);
|
||||
void copy_paint(Paint *orig, Paint *new);
|
||||
|
||||
struct Paint *paint_get_active(struct Scene *sce);
|
||||
struct Brush *paint_brush(struct Paint *paint);
|
||||
void paint_brush_set(struct Paint *paint, struct Brush *br);
|
||||
void paint_brush_slot_add(struct Paint *p);
|
||||
void paint_brush_slot_remove(struct Paint *p);
|
||||
|
||||
/* testing face select mode
|
||||
* Texture paint could be removed since selected faces are not used
|
||||
|
@ -62,7 +62,7 @@
|
||||
|
||||
/* Datablock add/copy/free/make_local */
|
||||
|
||||
Brush *add_brush(char *name)
|
||||
Brush *add_brush(const char *name)
|
||||
{
|
||||
Brush *brush;
|
||||
|
||||
@ -186,23 +186,6 @@ void make_local_brush(Brush *brush)
|
||||
|
||||
/* Library Operations */
|
||||
|
||||
Brush **current_brush_source(Scene *sce)
|
||||
{
|
||||
Object *ob = sce->basact ? sce->basact->object : NULL;
|
||||
|
||||
if(ob) {
|
||||
if(ob->mode & OB_MODE_SCULPT)
|
||||
return &sce->toolsettings->sculpt->brush;
|
||||
else if(ob->mode & OB_MODE_VERTEX_PAINT)
|
||||
return &sce->toolsettings->vpaint->brush;
|
||||
else if(ob->mode & OB_MODE_WEIGHT_PAINT)
|
||||
return &sce->toolsettings->wpaint->brush;
|
||||
else if(ob->mode & OB_MODE_TEXTURE_PAINT)
|
||||
return &sce->toolsettings->imapaint.brush;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int brush_set_nr(Brush **current_brush, int nr)
|
||||
{
|
||||
ID *idtest, *id;
|
||||
|
@ -25,13 +25,126 @@
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include "DNA_object_types.h"
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_brush_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BKE_brush.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_paint.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
Paint *paint_get_active(Scene *sce)
|
||||
{
|
||||
if(sce && sce->basact && sce->basact->object) {
|
||||
switch(sce->basact->object->mode) {
|
||||
case OB_MODE_SCULPT:
|
||||
return &sce->toolsettings->sculpt->paint;
|
||||
}
|
||||
}
|
||||
/*else if(G.f & G_VERTEXPAINT)
|
||||
return &sce->toolsettings->vpaint->paint;
|
||||
else if(G.f & G_WEIGHTPAINT)
|
||||
return &sce->toolsettings->wpaint->paint;
|
||||
else if(G.f & G_TEXTUREPAINT)
|
||||
return &sce->toolsettings->imapaint.paint;*/
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Brush *paint_brush(Paint *p)
|
||||
{
|
||||
return p && p->brushes ? p->brushes[p->active_brush_index] : NULL;
|
||||
}
|
||||
|
||||
void paint_brush_set(Paint *p, Brush *br)
|
||||
{
|
||||
if(p && p->brushes) {
|
||||
int i;
|
||||
|
||||
/* See if there's already a slot with the brush */
|
||||
for(i = 0; i < p->brush_count; ++i) {
|
||||
if(p->brushes[i] == br) {
|
||||
p->active_brush_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
paint_brush_slot_add(p);
|
||||
|
||||
/* Make sure the current slot is the new brush */
|
||||
p->brushes[p->active_brush_index] = br;
|
||||
}
|
||||
|
||||
static void paint_brush_slots_alloc(Paint *p, const int count)
|
||||
{
|
||||
p->brush_count = count;
|
||||
if(count == 0)
|
||||
p->brushes = NULL;
|
||||
else
|
||||
p->brushes = MEM_callocN(sizeof(Brush*) * count, "Brush slots");
|
||||
}
|
||||
|
||||
void paint_brush_slot_add(Paint *p)
|
||||
{
|
||||
Brush **orig = p->brushes;
|
||||
int orig_count = p->brushes ? p->brush_count : 0;
|
||||
|
||||
/* Increase size of brush slot array */
|
||||
paint_brush_slots_alloc(p, orig_count + 1);
|
||||
if(orig) {
|
||||
memcpy(p->brushes, orig, sizeof(Brush*) * orig_count);
|
||||
MEM_freeN(orig);
|
||||
}
|
||||
|
||||
p->active_brush_index = orig_count;
|
||||
}
|
||||
|
||||
void paint_brush_slot_remove(Paint *p)
|
||||
{
|
||||
if(p->brushes) {
|
||||
Brush **orig = p->brushes;
|
||||
int src, dst;
|
||||
|
||||
/* Decrease size of brush slot array */
|
||||
paint_brush_slots_alloc(p, p->brush_count - 1);
|
||||
if(p->brushes) {
|
||||
for(src = 0, dst = 0; dst < p->brush_count; ++src) {
|
||||
if(src != p->active_brush_index) {
|
||||
p->brushes[dst] = orig[src];
|
||||
++dst;
|
||||
}
|
||||
}
|
||||
}
|
||||
MEM_freeN(orig);
|
||||
|
||||
if(p->active_brush_index >= p->brush_count)
|
||||
p->active_brush_index = p->brush_count - 1;
|
||||
if(p->active_brush_index < 0)
|
||||
p->active_brush_index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int paint_facesel_test(Object *ob)
|
||||
{
|
||||
return (G.f&G_FACESELECT) && (ob && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)));
|
||||
|
||||
}
|
||||
|
||||
void free_paint(Paint *paint)
|
||||
{
|
||||
if(paint->brushes)
|
||||
MEM_freeN(paint->brushes);
|
||||
}
|
||||
|
||||
void copy_paint(Paint *orig, Paint *new)
|
||||
{
|
||||
if(orig->brushes)
|
||||
new->brushes = MEM_dupallocN(orig->brushes);
|
||||
}
|
||||
|
@ -76,6 +76,7 @@
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_node.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_paint.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_sequence.h"
|
||||
#include "BKE_world.h"
|
||||
@ -173,7 +174,7 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type)
|
||||
}
|
||||
if(ts->sculpt) {
|
||||
ts->sculpt= MEM_dupallocN(ts->sculpt);
|
||||
id_us_plus((ID *)ts->sculpt->brush);
|
||||
copy_paint(&ts->sculpt->paint, &ts->sculpt->paint);
|
||||
}
|
||||
|
||||
id_us_plus((ID *)ts->imapaint.brush);
|
||||
@ -275,8 +276,10 @@ void free_scene(Scene *sce)
|
||||
MEM_freeN(sce->toolsettings->vpaint);
|
||||
if(sce->toolsettings->wpaint)
|
||||
MEM_freeN(sce->toolsettings->wpaint);
|
||||
if(sce->toolsettings->sculpt)
|
||||
if(sce->toolsettings->sculpt) {
|
||||
free_paint(&sce->toolsettings->sculpt->paint);
|
||||
MEM_freeN(sce->toolsettings->sculpt);
|
||||
}
|
||||
|
||||
MEM_freeN(sce->toolsettings);
|
||||
sce->toolsettings = NULL;
|
||||
|
@ -4036,9 +4036,12 @@ static void lib_link_scene(FileData *fd, Main *main)
|
||||
|
||||
sce->toolsettings->imapaint.brush=
|
||||
newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.brush);
|
||||
if(sce->toolsettings->sculpt)
|
||||
sce->toolsettings->sculpt->brush=
|
||||
newlibadr_us(fd, sce->id.lib, sce->toolsettings->sculpt->brush);
|
||||
if(sce->toolsettings->sculpt && sce->toolsettings->sculpt->paint.brushes) {
|
||||
int i;
|
||||
for(i = 0; i < sce->toolsettings->sculpt->paint.brush_count; ++i)
|
||||
sce->toolsettings->sculpt->paint.brushes[i]=
|
||||
newlibadr_us(fd, sce->id.lib, sce->toolsettings->sculpt->paint.brushes[i]);
|
||||
}
|
||||
if(sce->toolsettings->vpaint)
|
||||
sce->toolsettings->vpaint->brush=
|
||||
newlibadr_us(fd, sce->id.lib, sce->toolsettings->vpaint->brush);
|
||||
@ -4148,6 +4151,8 @@ static void direct_link_scene(FileData *fd, Scene *sce)
|
||||
sce->toolsettings->vpaint= newdataadr(fd, sce->toolsettings->vpaint);
|
||||
sce->toolsettings->wpaint= newdataadr(fd, sce->toolsettings->wpaint);
|
||||
sce->toolsettings->sculpt= newdataadr(fd, sce->toolsettings->sculpt);
|
||||
if(sce->toolsettings->sculpt)
|
||||
sce->toolsettings->sculpt->paint.brushes= newdataadr(fd, sce->toolsettings->sculpt->paint.brushes);
|
||||
sce->toolsettings->imapaint.paintcursor= NULL;
|
||||
sce->toolsettings->particle.paintcursor= NULL;
|
||||
}
|
||||
|
@ -1710,8 +1710,13 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
|
||||
writestruct(wd, DATA, "VPaint", 1, sce->toolsettings->vpaint);
|
||||
if(sce->toolsettings->wpaint)
|
||||
writestruct(wd, DATA, "VPaint", 1, sce->toolsettings->wpaint);
|
||||
if(sce->toolsettings->sculpt)
|
||||
if(sce->toolsettings->sculpt) {
|
||||
writestruct(wd, DATA, "Sculpt", 1, sce->toolsettings->sculpt);
|
||||
if(sce->toolsettings->sculpt->paint.brushes) {
|
||||
Paint *p = &sce->toolsettings->sculpt->paint;
|
||||
writedata(wd, DATA, p->brush_count * sizeof(Brush*), p->brushes);
|
||||
}
|
||||
}
|
||||
|
||||
ed= sce->ed;
|
||||
if(ed) {
|
||||
|
@ -1453,7 +1453,7 @@ ListBase uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, char *pr
|
||||
/* init numbers */
|
||||
RNA_property_int_range(activeptr, activeprop, &min, &max);
|
||||
|
||||
len= max - min + 1;
|
||||
len= RNA_property_collection_length(ptr, prop);
|
||||
items= CLAMPIS(len, rows, 5);
|
||||
|
||||
pa->list_scroll= MIN2(pa->list_scroll, len-items);
|
||||
|
@ -1,16 +1,139 @@
|
||||
/**
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BKE_brush.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_paint.h"
|
||||
|
||||
#include "ED_sculpt.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
#include "RNA_enum_types.h"
|
||||
|
||||
#include "paint_intern.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* Brush operators */
|
||||
static int new_brush_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
int sculpt_tool = RNA_enum_get(op->ptr, "sculpt_tool");
|
||||
const char *name = NULL;
|
||||
Brush *br = NULL;
|
||||
|
||||
RNA_enum_name(brush_sculpt_tool_items, sculpt_tool, &name);
|
||||
br = add_brush(name);
|
||||
|
||||
if(br) {
|
||||
br->sculpt_tool = sculpt_tool;
|
||||
paint_brush_set(paint_get_active(CTX_data_scene(C)), br);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void BRUSH_OT_new(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Add Brush";
|
||||
ot->idname= "BRUSH_OT_new";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= new_brush_exec;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* TODO: add enum props for other paint modes */
|
||||
RNA_def_enum(ot->srna, "sculpt_tool", brush_sculpt_tool_items, 0, "Sculpt Tool", "");
|
||||
}
|
||||
|
||||
/* Paint operators */
|
||||
static int paint_poll(bContext *C)
|
||||
{
|
||||
return !!paint_get_active(CTX_data_scene(C));
|
||||
}
|
||||
|
||||
static int brush_slot_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Paint *p = paint_get_active(CTX_data_scene(C));
|
||||
|
||||
paint_brush_slot_add(p);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void PAINT_OT_brush_slot_add(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Add Brush Slot";
|
||||
ot->idname= "PAINT_OT_brush_slot_add";
|
||||
|
||||
/* api callbacks */
|
||||
ot->poll= paint_poll;
|
||||
ot->exec= brush_slot_add_exec;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
static int brush_slot_remove_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Paint *p = paint_get_active(CTX_data_scene(C));
|
||||
|
||||
paint_brush_slot_remove(p);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void PAINT_OT_brush_slot_remove(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Remove Brush Slot";
|
||||
ot->idname= "PAINT_OT_brush_slot_remove";
|
||||
|
||||
/* api callbacks */
|
||||
ot->poll= paint_poll;
|
||||
ot->exec= brush_slot_remove_exec;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/**************************** registration **********************************/
|
||||
|
||||
void ED_operatortypes_paint(void)
|
||||
{
|
||||
/* paint */
|
||||
WM_operatortype_append(PAINT_OT_brush_slot_add);
|
||||
WM_operatortype_append(PAINT_OT_brush_slot_remove);
|
||||
|
||||
/* brush */
|
||||
WM_operatortype_append(BRUSH_OT_new);
|
||||
WM_operatortype_append(BRUSH_OT_curve_preset);
|
||||
|
||||
/* image */
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_DerivedMesh.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_paint.h"
|
||||
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "BIF_gl.h"
|
||||
@ -168,7 +170,7 @@ int imapaint_pick_face(ViewContext *vc, Mesh *me, int *mval, unsigned int *index
|
||||
/* used for both 3d view and image window */
|
||||
void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */
|
||||
{
|
||||
Brush **br = current_brush_source(scene);
|
||||
Brush *br = paint_brush(paint_get_active(scene));
|
||||
unsigned int col;
|
||||
char *cp;
|
||||
|
||||
@ -181,16 +183,16 @@ void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */
|
||||
|
||||
cp = (char *)&col;
|
||||
|
||||
if(br && *br) {
|
||||
(*br)->rgb[0]= cp[0]/255.0f;
|
||||
(*br)->rgb[1]= cp[1]/255.0f;
|
||||
(*br)->rgb[2]= cp[2]/255.0f;
|
||||
if(br) {
|
||||
br->rgb[0]= cp[0]/255.0f;
|
||||
br->rgb[1]= cp[1]/255.0f;
|
||||
br->rgb[2]= cp[2]/255.0f;
|
||||
}
|
||||
}
|
||||
|
||||
static int brush_curve_preset_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Brush *br = *current_brush_source(CTX_data_scene(C));
|
||||
Brush *br = paint_brush(paint_get_active(CTX_data_scene(C)));
|
||||
brush_curve_preset(br, RNA_enum_get(op->ptr, "shape"));
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@ -198,9 +200,9 @@ static int brush_curve_preset_exec(bContext *C, wmOperator *op)
|
||||
|
||||
static int brush_curve_preset_poll(bContext *C)
|
||||
{
|
||||
Brush **br = current_brush_source(CTX_data_scene(C));
|
||||
Brush *br = paint_brush(paint_get_active(CTX_data_scene(C)));
|
||||
|
||||
return br && *br && (*br)->curve;
|
||||
return br && br->curve;
|
||||
}
|
||||
|
||||
void BRUSH_OT_curve_preset(wmOperatorType *ot)
|
||||
|
@ -64,6 +64,7 @@
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_multires.h"
|
||||
#include "BKE_paint.h"
|
||||
#include "BKE_sculpt.h"
|
||||
#include "BKE_texture.h"
|
||||
#include "BKE_utildefines.h"
|
||||
@ -219,9 +220,10 @@ static void project(bglMats *mats, const float v[3], short p[2])
|
||||
tablet */
|
||||
static char brush_size(Sculpt *sd, SculptSession *ss)
|
||||
{
|
||||
float size= sd->brush->size;
|
||||
Brush *brush = paint_brush(&sd->paint);
|
||||
float size= brush->size;
|
||||
|
||||
if((sd->brush->sculpt_tool != SCULPT_TOOL_GRAB) && (sd->brush->flag & BRUSH_SIZE_PRESSURE))
|
||||
if((brush->sculpt_tool != SCULPT_TOOL_GRAB) && (brush->flag & BRUSH_SIZE_PRESSURE))
|
||||
size *= ss->cache->pressure;
|
||||
|
||||
return size;
|
||||
@ -232,17 +234,18 @@ static char brush_size(Sculpt *sd, SculptSession *ss)
|
||||
special multiplier found experimentally to scale the strength factor. */
|
||||
static float brush_strength(Sculpt *sd, StrokeCache *cache)
|
||||
{
|
||||
Brush *brush = paint_brush(&sd->paint);
|
||||
/* Primary strength input; square it to make lower values more sensitive */
|
||||
float alpha = sd->brush->alpha * sd->brush->alpha;
|
||||
float alpha = brush->alpha * brush->alpha;
|
||||
|
||||
float dir= sd->brush->flag & BRUSH_DIR_IN ? -1 : 1;
|
||||
float dir= brush->flag & BRUSH_DIR_IN ? -1 : 1;
|
||||
float pressure= 1;
|
||||
float flip= cache->flip ? -1:1;
|
||||
|
||||
if(sd->brush->flag & BRUSH_ALPHA_PRESSURE)
|
||||
if(brush->flag & BRUSH_ALPHA_PRESSURE)
|
||||
pressure *= cache->pressure;
|
||||
|
||||
switch(sd->brush->sculpt_tool){
|
||||
switch(brush->sculpt_tool){
|
||||
case SCULPT_TOOL_DRAW:
|
||||
case SCULPT_TOOL_INFLATE:
|
||||
case SCULPT_TOOL_CLAY:
|
||||
@ -293,15 +296,16 @@ static void add_norm_if(float view_vec[3], float out[3], float out_flip[3], cons
|
||||
vertices */
|
||||
static void calc_area_normal(Sculpt *sd, SculptSession *ss, float out[3], const ListBase* active_verts)
|
||||
{
|
||||
Brush *brush = paint_brush(&sd->paint);
|
||||
StrokeCache *cache = ss->cache;
|
||||
ActiveData *node = active_verts->first;
|
||||
const int view = 0; /* XXX: should probably be a flag, not number: sd->brush_type==SCULPT_TOOL_DRAW ? sculptmode_brush()->view : 0; */
|
||||
const int view = 0; /* XXX: should probably be a flag, not number: brush_type==SCULPT_TOOL_DRAW ? sculptmode_brush()->view : 0; */
|
||||
float out_flip[3];
|
||||
float *out_dir = cache->view_normal_symmetry;
|
||||
|
||||
out[0]=out[1]=out[2] = out_flip[0]=out_flip[1]=out_flip[2] = 0;
|
||||
|
||||
if(sd->brush->flag & BRUSH_ANCHORED) {
|
||||
if(brush->flag & BRUSH_ANCHORED) {
|
||||
for(; node; node = node->next)
|
||||
add_norm_if(out_dir, out, out_flip, cache->orig_norms[node->Index]);
|
||||
}
|
||||
@ -652,7 +656,7 @@ static float get_texcache_pixel_bilinear(const SculptSession *ss, float u, float
|
||||
/* Return a multiplier for brush strength on a particular vertex. */
|
||||
static float tex_strength(Sculpt *sd, SculptSession *ss, float *point, const float len)
|
||||
{
|
||||
Brush *br = sd->brush;
|
||||
Brush *br = paint_brush(&sd->paint);
|
||||
MTex *tex = NULL;
|
||||
float avg= 1;
|
||||
|
||||
@ -722,7 +726,7 @@ static float tex_strength(Sculpt *sd, SculptSession *ss, float *point, const flo
|
||||
}
|
||||
}
|
||||
|
||||
avg*= brush_curve_strength(sd->brush, len, ss->cache->radius); /* Falloff curve */
|
||||
avg*= brush_curve_strength(br, len, ss->cache->radius); /* Falloff curve */
|
||||
|
||||
return avg;
|
||||
}
|
||||
@ -762,6 +766,7 @@ static void sculpt_add_damaged_rect(SculptSession *ss)
|
||||
|
||||
static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache)
|
||||
{
|
||||
Brush *brush = paint_brush(&sd->paint);
|
||||
float av_dist;
|
||||
ListBase active_verts={0,0};
|
||||
ListBase *grab_active_verts = &ss->cache->grab_active_verts[ss->cache->symmetry];
|
||||
@ -770,7 +775,7 @@ static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache)
|
||||
Mesh *me= NULL; /*XXX: get_mesh(OBACT); */
|
||||
const float bstrength= brush_strength(sd, cache);
|
||||
KeyBlock *keyblock= NULL; /*XXX: ob_get_keyblock(OBACT); */
|
||||
Brush *b = sd->brush;
|
||||
Brush *b = brush;
|
||||
int i;
|
||||
|
||||
sculpt_add_damaged_rect(ss);
|
||||
@ -954,15 +959,17 @@ static void projverts_clear_inside(SculptSession *ss)
|
||||
|
||||
static void sculpt_update_tex(Sculpt *sd, SculptSession *ss)
|
||||
{
|
||||
Brush *brush = paint_brush(&sd->paint);
|
||||
|
||||
if(ss->texcache) {
|
||||
MEM_freeN(ss->texcache);
|
||||
ss->texcache= NULL;
|
||||
}
|
||||
|
||||
/* Need to allocate a bigger buffer for bigger brush size */
|
||||
ss->texcache_side = sd->brush->size * 2;
|
||||
ss->texcache_side = brush->size * 2;
|
||||
if(!ss->texcache || ss->texcache_side > ss->texcache_actual) {
|
||||
ss->texcache = brush_gen_texture_cache(sd->brush, sd->brush->size);
|
||||
ss->texcache = brush_gen_texture_cache(brush, brush->size);
|
||||
ss->texcache_actual = ss->texcache_side;
|
||||
}
|
||||
}
|
||||
@ -1053,7 +1060,8 @@ static int sculpt_mode_poll(bContext *C)
|
||||
|
||||
static int sculpt_poll(bContext *C)
|
||||
{
|
||||
return sculpt_mode_poll(C) && CTX_wm_area(C)->spacetype == SPACE_VIEW3D &&
|
||||
return sculpt_mode_poll(C) && paint_brush(&CTX_data_tool_settings(C)->sculpt->paint) &&
|
||||
CTX_wm_area(C)->spacetype == SPACE_VIEW3D &&
|
||||
CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW;
|
||||
}
|
||||
|
||||
@ -1062,16 +1070,17 @@ static void draw_paint_cursor(bContext *C, int x, int y, void *customdata)
|
||||
{
|
||||
Sculpt *sd= CTX_data_tool_settings(C)->sculpt;
|
||||
SculptSession *ss= CTX_data_active_object(C)->sculpt;
|
||||
Brush *brush = paint_brush(&sd->paint);
|
||||
|
||||
glColor4ub(255, 100, 100, 128);
|
||||
glEnable( GL_LINE_SMOOTH );
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glTranslatef((float)x, (float)y, 0.0f);
|
||||
glutil_draw_lined_arc(0.0, M_PI*2.0, sd->brush->size, 40);
|
||||
glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40);
|
||||
glTranslatef((float)-x, (float)-y, 0.0f);
|
||||
|
||||
if(ss && ss->cache && sd->brush && (sd->brush->flag & BRUSH_SMOOTH_STROKE)) {
|
||||
if(ss && ss->cache && brush && (brush->flag & BRUSH_SMOOTH_STROKE)) {
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
sdrawline(x, y, ss->cache->mouse[0] - ar->winrct.xmin, ss->cache->mouse[1] - ar->winrct.ymin);
|
||||
}
|
||||
@ -1096,7 +1105,9 @@ static void toggle_paint_cursor(bContext *C)
|
||||
|
||||
static void sculpt_undo_push(bContext *C, Sculpt *sd)
|
||||
{
|
||||
switch(sd->brush->sculpt_tool) {
|
||||
Brush *brush = paint_brush(&sd->paint);
|
||||
|
||||
switch(brush->sculpt_tool) {
|
||||
case SCULPT_TOOL_DRAW:
|
||||
ED_undo_push(C, "Draw Brush"); break;
|
||||
case SCULPT_TOOL_SMOOTH:
|
||||
@ -1119,8 +1130,9 @@ static void sculpt_undo_push(bContext *C, Sculpt *sd)
|
||||
/**** Radial control ****/
|
||||
static int sculpt_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
Brush *brush = paint_brush(&CTX_data_tool_settings(C)->sculpt->paint);
|
||||
toggle_paint_cursor(C);
|
||||
brush_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->sculpt->brush, 1);
|
||||
brush_radial_control_invoke(op, brush, 1);
|
||||
return WM_radial_control_invoke(C, op, event);
|
||||
}
|
||||
|
||||
@ -1134,7 +1146,9 @@ static int sculpt_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve
|
||||
|
||||
static int sculpt_radial_control_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
return brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->sculpt->brush, 1);
|
||||
Brush *brush = paint_brush(&CTX_data_tool_settings(C)->sculpt->paint);
|
||||
|
||||
return brush_radial_control_exec(op, brush, 1);
|
||||
}
|
||||
|
||||
static void SCULPT_OT_radial_control(wmOperatorType *ot)
|
||||
@ -1181,6 +1195,7 @@ static void sculpt_cache_free(StrokeCache *cache)
|
||||
static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, bContext *C, wmOperator *op)
|
||||
{
|
||||
StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache");
|
||||
Brush *brush = paint_brush(&sd->paint);
|
||||
int i;
|
||||
|
||||
ss->cache = cache;
|
||||
@ -1204,17 +1219,17 @@ static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, bConte
|
||||
sculpt_update_mesh_elements(C);
|
||||
|
||||
/* Initialize layer brush displacements */
|
||||
if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER &&
|
||||
(!ss->layer_disps || !(sd->brush->flag & BRUSH_PERSISTENT))) {
|
||||
if(brush->sculpt_tool == SCULPT_TOOL_LAYER &&
|
||||
(!ss->layer_disps || !(brush->flag & BRUSH_PERSISTENT))) {
|
||||
if(ss->layer_disps)
|
||||
MEM_freeN(ss->layer_disps);
|
||||
ss->layer_disps = MEM_callocN(sizeof(float) * ss->totvert, "layer brush displacements");
|
||||
}
|
||||
|
||||
/* Make copies of the mesh vertex locations and normals for some tools */
|
||||
if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER || (sd->brush->flag & BRUSH_ANCHORED)) {
|
||||
if(sd->brush->sculpt_tool != SCULPT_TOOL_LAYER ||
|
||||
!ss->mesh_co_orig || !(sd->brush->flag & BRUSH_PERSISTENT)) {
|
||||
if(brush->sculpt_tool == SCULPT_TOOL_LAYER || (brush->flag & BRUSH_ANCHORED)) {
|
||||
if(brush->sculpt_tool != SCULPT_TOOL_LAYER ||
|
||||
!ss->mesh_co_orig || !(brush->flag & BRUSH_PERSISTENT)) {
|
||||
if(!ss->mesh_co_orig)
|
||||
ss->mesh_co_orig= MEM_mallocN(sizeof(float) * 3 * ss->totvert,
|
||||
"sculpt mesh vertices copy");
|
||||
@ -1222,7 +1237,7 @@ static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, bConte
|
||||
VecCopyf(ss->mesh_co_orig[i], ss->mvert[i].co);
|
||||
}
|
||||
|
||||
if(sd->brush->flag & BRUSH_ANCHORED) {
|
||||
if(brush->flag & BRUSH_ANCHORED) {
|
||||
cache->orig_norms= MEM_mallocN(sizeof(short) * 3 * ss->totvert, "Sculpt orig norm");
|
||||
for(i = 0; i < ss->totvert; ++i) {
|
||||
cache->orig_norms[i][0] = ss->mvert[i].no[0];
|
||||
@ -1249,10 +1264,11 @@ static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, bConte
|
||||
static void sculpt_update_cache_variants(Sculpt *sd, SculptSession *ss, PointerRNA *ptr)
|
||||
{
|
||||
StrokeCache *cache = ss->cache;
|
||||
Brush *brush = paint_brush(&sd->paint);
|
||||
float grab_location[3];
|
||||
int dx, dy;
|
||||
|
||||
if(!(sd->brush->flag & BRUSH_ANCHORED))
|
||||
if(!(brush->flag & BRUSH_ANCHORED))
|
||||
RNA_float_get_array(ptr, "location", cache->true_location);
|
||||
cache->flip = RNA_boolean_get(ptr, "flip");
|
||||
RNA_int_get_array(ptr, "mouse", cache->mouse);
|
||||
@ -1262,14 +1278,14 @@ static void sculpt_update_cache_variants(Sculpt *sd, SculptSession *ss, PointerR
|
||||
cache->previous_pixel_radius = cache->pixel_radius;
|
||||
cache->pixel_radius = brush_size(sd, ss);
|
||||
|
||||
if(sd->brush->flag & BRUSH_ANCHORED) {
|
||||
if(brush->flag & BRUSH_ANCHORED) {
|
||||
dx = cache->mouse[0] - cache->initial_mouse[0];
|
||||
dy = cache->mouse[1] - cache->initial_mouse[1];
|
||||
cache->pixel_radius = sqrt(dx*dx + dy*dy);
|
||||
cache->radius = unproject_brush_radius(ss, cache->pixel_radius);
|
||||
cache->rotation = atan2(dy, dx);
|
||||
}
|
||||
else if(sd->brush->flag & BRUSH_RAKE) {
|
||||
else if(brush->flag & BRUSH_RAKE) {
|
||||
int update;
|
||||
|
||||
dx = cache->last_rake[0] - cache->mouse[0];
|
||||
@ -1288,7 +1304,7 @@ static void sculpt_update_cache_variants(Sculpt *sd, SculptSession *ss, PointerR
|
||||
}
|
||||
|
||||
/* Find the grab delta */
|
||||
if(sd->brush->sculpt_tool == SCULPT_TOOL_GRAB) {
|
||||
if(brush->sculpt_tool == SCULPT_TOOL_GRAB) {
|
||||
unproject(cache->mats, grab_location, cache->mouse[0], cache->mouse[1], cache->depth);
|
||||
if(!cache->first_time)
|
||||
VecSubf(cache->grab_delta, grab_location, cache->old_grab_location);
|
||||
@ -1361,10 +1377,11 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even
|
||||
static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss)
|
||||
{
|
||||
StrokeCache *cache = ss->cache;
|
||||
Brush *brush = paint_brush(&sd->paint);
|
||||
int i;
|
||||
|
||||
/* Restore the mesh before continuing with anchored stroke */
|
||||
if((sd->brush->flag & BRUSH_ANCHORED) && ss->mesh_co_orig) {
|
||||
if((brush->flag & BRUSH_ANCHORED) && ss->mesh_co_orig) {
|
||||
for(i = 0; i < ss->totvert; ++i) {
|
||||
VecCopyf(ss->mvert[i].co, ss->mesh_co_orig[i]);
|
||||
ss->mvert[i].no[0] = cache->orig_norms[i][0];
|
||||
@ -1378,7 +1395,7 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss)
|
||||
VecCopyf(fn, cache->face_norms[i]);
|
||||
}
|
||||
|
||||
if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER)
|
||||
if(brush->sculpt_tool == SCULPT_TOOL_LAYER)
|
||||
memset(ss->layer_disps, 0, sizeof(float) * ss->totvert);
|
||||
}
|
||||
}
|
||||
@ -1413,10 +1430,12 @@ static void sculpt_flush_update(bContext *C)
|
||||
/* Returns zero if no sculpt changes should be made, non-zero otherwise */
|
||||
static int sculpt_smooth_stroke(Sculpt *s, SculptSession *ss, int output[2], wmEvent *event)
|
||||
{
|
||||
Brush *brush = paint_brush(&s->paint);
|
||||
|
||||
output[0] = event->x;
|
||||
output[1] = event->y;
|
||||
|
||||
if(s->brush->flag & BRUSH_SMOOTH_STROKE && s->brush->sculpt_tool != SCULPT_TOOL_GRAB) {
|
||||
if(brush->flag & BRUSH_SMOOTH_STROKE && brush->sculpt_tool != SCULPT_TOOL_GRAB) {
|
||||
StrokeCache *cache = ss->cache;
|
||||
float u = .9, v = 1.0 - u;
|
||||
int dx = cache->mouse[0] - event->x, dy = cache->mouse[1] - event->y;
|
||||
@ -1437,7 +1456,7 @@ static int sculpt_smooth_stroke(Sculpt *s, SculptSession *ss, int output[2], wmE
|
||||
/* Returns zero if the stroke dots should not be spaced, non-zero otherwise */
|
||||
int sculpt_space_stroke_enabled(Sculpt *s)
|
||||
{
|
||||
Brush *br = s->brush;
|
||||
Brush *br = paint_brush(&s->paint);
|
||||
return (br->flag & BRUSH_SPACE) && !(br->flag & BRUSH_ANCHORED) && (br->sculpt_tool != SCULPT_TOOL_GRAB);
|
||||
}
|
||||
|
||||
@ -1470,6 +1489,7 @@ static void sculpt_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *e
|
||||
static int sculpt_space_stroke(bContext *C, wmOperator *op, wmEvent *event, Sculpt *s, SculptSession *ss, const int final_mouse[2])
|
||||
{
|
||||
StrokeCache *cache = ss->cache;
|
||||
Brush *brush = paint_brush(&s->paint);
|
||||
int cnt = 0;
|
||||
|
||||
if(sculpt_space_stroke_enabled(s)) {
|
||||
@ -1482,11 +1502,11 @@ static int sculpt_space_stroke(bContext *C, wmOperator *op, wmEvent *event, Scul
|
||||
length = sqrt(vec[0]*vec[0] + vec[1]*vec[1]);
|
||||
|
||||
if(length > FLT_EPSILON) {
|
||||
scale = s->brush->spacing / length;
|
||||
scale = brush->spacing / length;
|
||||
vec[0] *= scale;
|
||||
vec[1] *= scale;
|
||||
|
||||
steps = (int)(length / s->brush->spacing);
|
||||
steps = (int)(length / brush->spacing);
|
||||
for(i = 0; i < steps; ++i, ++cnt) {
|
||||
mouse[0] += vec[0];
|
||||
mouse[1] += vec[1];
|
||||
@ -1666,6 +1686,8 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op)
|
||||
free_sculptsession(&ob->sculpt);
|
||||
}
|
||||
else {
|
||||
Brush *brush;
|
||||
|
||||
/* Enter sculptmode */
|
||||
|
||||
ob->mode |= OB_MODE_SCULPT;
|
||||
@ -1683,7 +1705,9 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op)
|
||||
toggle_paint_cursor(C);
|
||||
|
||||
/* If there's no brush, create one */
|
||||
brush_check_exists(&ts->sculpt->brush);
|
||||
brush = paint_brush(&ts->sculpt->paint);
|
||||
brush_check_exists(&brush);
|
||||
paint_brush_set(&ts->sculpt->paint, brush);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_MODE, CTX_data_scene(C));
|
||||
}
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_material.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_paint.h"
|
||||
#include "BKE_particle.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_utildefines.h"
|
||||
@ -323,7 +324,7 @@ static int buttons_context_path_brush(const bContext *C, ButsContextPath *path)
|
||||
|
||||
if(obact) {
|
||||
if(obact->mode & OB_MODE_SCULPT)
|
||||
br= ts->sculpt->brush;
|
||||
paint_brush(&ts->sculpt->paint);
|
||||
else if(obact->mode & OB_MODE_VERTEX_PAINT)
|
||||
br= ts->vpaint->brush;
|
||||
else if(obact->mode & OB_MODE_WEIGHT_PAINT)
|
||||
|
@ -56,6 +56,7 @@
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_node.h"
|
||||
#include "BKE_material.h"
|
||||
#include "BKE_paint.h"
|
||||
#include "BKE_texture.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_utildefines.h"
|
||||
@ -625,10 +626,9 @@ void snode_set_context(SpaceNode *snode, Scene *scene)
|
||||
MTex *mtex= NULL;
|
||||
|
||||
if(ob && ob->mode & OB_MODE_SCULPT) {
|
||||
Sculpt *sd= scene->toolsettings->sculpt;
|
||||
if(sd && sd->brush)
|
||||
if(sd->brush->texact != -1)
|
||||
mtex= sd->brush->mtex[sd->brush->texact];
|
||||
Brush *brush = paint_brush(&scene->toolsettings->sculpt->paint);
|
||||
if(brush && brush->texact != -1)
|
||||
mtex= brush->mtex[brush->texact];
|
||||
}
|
||||
else {
|
||||
Brush *br= scene->toolsettings->imapaint.brush;
|
||||
|
@ -465,12 +465,19 @@ typedef struct TransformOrientation {
|
||||
float mat[3][3];
|
||||
} TransformOrientation;
|
||||
|
||||
typedef struct Paint {
|
||||
/* Array of brushes selected for use in this paint mode */
|
||||
Brush **brushes;
|
||||
int active_brush_index, brush_count;
|
||||
|
||||
/* WM handle */
|
||||
void *paint_cursor;
|
||||
} Paint;
|
||||
|
||||
typedef struct Sculpt
|
||||
{
|
||||
/* Note! a deep copy of this struct must be done scene.c's copy_scene function */
|
||||
|
||||
struct Brush *brush;
|
||||
|
||||
Paint paint;
|
||||
|
||||
/* WM handle */
|
||||
void *cursor;
|
||||
|
||||
|
@ -49,6 +49,8 @@ extern EnumPropertyItem nla_mode_blend_items[];
|
||||
extern EnumPropertyItem event_value_items[];
|
||||
extern EnumPropertyItem event_type_items[];
|
||||
|
||||
extern EnumPropertyItem brush_sculpt_tool_items[];
|
||||
|
||||
#endif /* RNA_ENUM_TYPES */
|
||||
|
||||
|
||||
|
@ -32,6 +32,17 @@
|
||||
#include "DNA_brush_types.h"
|
||||
#include "DNA_texture_types.h"
|
||||
|
||||
EnumPropertyItem brush_sculpt_tool_items[] = {
|
||||
{SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""},
|
||||
{SCULPT_TOOL_SMOOTH, "SMOOTH", 0, "Smooth", ""},
|
||||
{SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", ""},
|
||||
{SCULPT_TOOL_INFLATE, "INFLATE", 0, "Inflate", ""},
|
||||
{SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", ""},
|
||||
{SCULPT_TOOL_LAYER, "LAYER", 0, "Layer", ""},
|
||||
{SCULPT_TOOL_FLATTEN, "FLATTEN", 0, "Flatten", ""},
|
||||
{SCULPT_TOOL_CLAY, "CLAY", 0, "Clay", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
#ifdef RNA_RUNTIME
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
@ -92,17 +103,6 @@ void rna_def_brush(BlenderRNA *brna)
|
||||
{BRUSH_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting."},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
static EnumPropertyItem prop_sculpt_tool_items[] = {
|
||||
{SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""},
|
||||
{SCULPT_TOOL_SMOOTH, "SMOOTH", 0, "Smooth", ""},
|
||||
{SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", ""},
|
||||
{SCULPT_TOOL_INFLATE, "INFLATE", 0, "Inflate", ""},
|
||||
{SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", ""},
|
||||
{SCULPT_TOOL_LAYER, "LAYER", 0, "Layer", ""},
|
||||
{SCULPT_TOOL_FLATTEN, "FLATTEN", 0, "Flatten", ""},
|
||||
{SCULPT_TOOL_CLAY, "CLAY", 0, "Clay", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
srna= RNA_def_struct(brna, "Brush", "ID");
|
||||
RNA_def_struct_ui_text(srna, "Brush", "Brush datablock for storing brush settings for painting and sculpting.");
|
||||
RNA_def_struct_ui_icon(srna, ICON_BRUSH_DATA);
|
||||
@ -113,7 +113,7 @@ void rna_def_brush(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Blending mode", "Brush blending mode.");
|
||||
|
||||
prop= RNA_def_property(srna, "sculpt_tool", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, prop_sculpt_tool_items);
|
||||
RNA_def_property_enum_items(prop, brush_sculpt_tool_items);
|
||||
RNA_def_property_ui_text(prop, "Sculpt Tool", "");
|
||||
|
||||
/* number values */
|
||||
|
@ -31,6 +31,8 @@
|
||||
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BKE_paint.h"
|
||||
|
||||
#ifdef RNA_RUNTIME
|
||||
|
||||
static PointerRNA rna_ParticleEdit_brush_get(PointerRNA *ptr)
|
||||
@ -49,20 +51,67 @@ static PointerRNA rna_ParticleBrush_curve_get(PointerRNA *ptr)
|
||||
return rna_pointer_inherit_refine(ptr, &RNA_CurveMapping, NULL);
|
||||
}
|
||||
|
||||
static void rna_Paint_brushes_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||
{
|
||||
Paint *p= (Paint*)ptr->data;
|
||||
rna_iterator_array_begin(iter, (void*)p->brushes, sizeof(Brush*), p->brush_count, 0, NULL);
|
||||
}
|
||||
|
||||
static int rna_Paint_brushes_length(PointerRNA *ptr)
|
||||
{
|
||||
Paint *p= (Paint*)ptr->data;
|
||||
|
||||
return p->brush_count;
|
||||
}
|
||||
|
||||
static PointerRNA rna_Paint_active_brush_get(PointerRNA *ptr)
|
||||
{
|
||||
return rna_pointer_inherit_refine(ptr, &RNA_Brush, paint_brush(ptr->data));
|
||||
}
|
||||
|
||||
static void rna_Paint_active_brush_set(PointerRNA *ptr, PointerRNA value)
|
||||
{
|
||||
paint_brush_set(ptr->data, value.data);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void rna_def_paint(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
srna= RNA_def_struct(brna, "Paint", NULL);
|
||||
RNA_def_struct_ui_text(srna, "Paint", "");
|
||||
|
||||
prop= RNA_def_property(srna, "brushes", PROP_COLLECTION, PROP_NONE);
|
||||
RNA_def_property_struct_type(prop, "Brush");
|
||||
RNA_def_property_collection_funcs(prop, "rna_Paint_brushes_begin",
|
||||
"rna_iterator_array_next",
|
||||
"rna_iterator_array_end",
|
||||
"rna_iterator_array_dereference_get",
|
||||
"rna_Paint_brushes_length", 0, 0, 0, 0);
|
||||
RNA_def_property_ui_text(prop, "Brushes", "Brushes selected for this paint mode.");
|
||||
|
||||
prop= RNA_def_property(srna, "active_brush_index", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_range(prop, 0, INT_MAX);
|
||||
|
||||
/* Fake property to get active brush directly, rather than integer index */
|
||||
prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_struct_type(prop, "Brush");
|
||||
RNA_def_property_pointer_funcs(prop, "rna_Paint_active_brush_get", "rna_Paint_active_brush_set", NULL);
|
||||
RNA_def_property_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "Brush", "Active paint brush.");
|
||||
}
|
||||
|
||||
static void rna_def_sculpt(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
srna= RNA_def_struct(brna, "Sculpt", NULL);
|
||||
srna= RNA_def_struct(brna, "Sculpt", "Paint");
|
||||
RNA_def_struct_ui_text(srna, "Sculpt", "");
|
||||
|
||||
prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_struct_type(prop, "Brush");
|
||||
RNA_def_property_ui_text(prop, "Brush", "");
|
||||
|
||||
prop= RNA_def_property(srna, "symmetry_x", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMM_X);
|
||||
RNA_def_property_ui_text(prop, "Symmetry X", "Mirror brush across the X axis.");
|
||||
@ -353,6 +402,7 @@ static void rna_def_particle_edit(BlenderRNA *brna)
|
||||
|
||||
void RNA_def_sculpt_paint(BlenderRNA *brna)
|
||||
{
|
||||
rna_def_paint(brna);
|
||||
rna_def_sculpt(brna);
|
||||
rna_def_vertex_paint(brna);
|
||||
rna_def_image_paint(brna);
|
||||
|
Loading…
Reference in New Issue
Block a user