Commit current working copy; having
weird file system issues
This commit is contained in:
parent
04c3690299
commit
d3bba94bf2
|
@ -269,7 +269,7 @@ static void brush_blend_write(BlendWriter *writer, ID *id, const void *id_addres
|
|||
}
|
||||
}
|
||||
|
||||
static void brush_blend_read_data(BlendDataReader *reader, ID *id)
|
||||
ATTR_NO_OPT static void brush_blend_read_data(BlendDataReader *reader, ID *id)
|
||||
{
|
||||
Brush *brush = (Brush *)id;
|
||||
|
||||
|
@ -277,6 +277,9 @@ static void brush_blend_read_data(BlendDataReader *reader, ID *id)
|
|||
BLO_read_data_address(reader, &brush->channels);
|
||||
BKE_brush_channelset_read(reader, brush->channels);
|
||||
}
|
||||
else {
|
||||
BKE_brush_builtin_create(brush, brush->sculpt_tool);
|
||||
}
|
||||
|
||||
if (brush->dyntopo.radius_scale == 0.0f) {
|
||||
brush->dyntopo.radius_scale = 1.0f;
|
||||
|
|
|
@ -214,7 +214,7 @@ void BKE_brush_channel_free(BrushChannel *ch)
|
|||
}
|
||||
}
|
||||
|
||||
void BKE_brush_channel_copy(BrushChannel *dst, BrushChannel *src)
|
||||
ATTR_NO_OPT void BKE_brush_channel_copy(BrushChannel *dst, BrushChannel *src)
|
||||
{
|
||||
*dst = *src;
|
||||
|
||||
|
@ -223,7 +223,7 @@ void BKE_brush_channel_copy(BrushChannel *dst, BrushChannel *src)
|
|||
}
|
||||
}
|
||||
|
||||
void BKE_brush_channel_init(BrushChannel *ch, BrushChannelType *def)
|
||||
ATTR_NO_OPT void BKE_brush_channel_init(BrushChannel *ch, BrushChannelType *def)
|
||||
{
|
||||
memset(ch, 0, sizeof(*ch));
|
||||
|
||||
|
@ -240,7 +240,7 @@ void BKE_brush_channel_init(BrushChannel *ch, BrushChannelType *def)
|
|||
BrushMapping *map = ch->mappings + i;
|
||||
CurveMapping *curve = &map->curve;
|
||||
|
||||
BKE_curvemapping_init(curve);
|
||||
memset(curve, 0, sizeof(*curve));
|
||||
|
||||
float min, max;
|
||||
|
||||
|
@ -259,6 +259,17 @@ void BKE_brush_channel_init(BrushChannel *ch, BrushChannelType *def)
|
|||
ch->mappings[i].flag |= BRUSH_MAPPING_INVERT;
|
||||
}
|
||||
|
||||
int slope = CURVEMAP_SLOPE_POSITIVE;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
BKE_curvemap_reset(&curve->cm[i],
|
||||
&(struct rctf){.xmax = 0, .ymax = min, .xmax = 1, .ymax = max},
|
||||
mdef->curve,
|
||||
slope);
|
||||
}
|
||||
|
||||
BKE_curvemapping_init(curve);
|
||||
|
||||
map->blendmode = mdef->blendmode;
|
||||
map->factor = 1.0f;
|
||||
|
||||
|
@ -290,17 +301,16 @@ void BKE_brush_channelset_add(BrushChannelSet *chset, BrushChannel *ch)
|
|||
chset->totchannel++;
|
||||
|
||||
if (!chset->channels) {
|
||||
chset->channels = MEM_callocN(sizeof(BrushChannelSet) * chset->totchannel, "chset->channels");
|
||||
chset->channels = MEM_callocN(sizeof(BrushChannel) * chset->totchannel, "chset->channels");
|
||||
}
|
||||
else {
|
||||
chset->channels = MEM_recallocN(chset->channels,
|
||||
sizeof(BrushChannelSet) * sizeof(chset->totchannel));
|
||||
chset->channels = MEM_recallocN(chset->channels, sizeof(BrushChannel) * chset->totchannel);
|
||||
}
|
||||
|
||||
memcpy(chset->channels + chset->totchannel - 1, ch, sizeof(BrushChannelSet));
|
||||
memcpy(chset->channels + chset->totchannel - 1, ch, sizeof(BrushChannel));
|
||||
}
|
||||
|
||||
BrushChannel *BKE_brush_channelset_lookup(BrushChannelSet *chset, const char *idname)
|
||||
ATTR_NO_OPT BrushChannel *BKE_brush_channelset_lookup(BrushChannelSet *chset, const char *idname)
|
||||
{
|
||||
for (int i = 0; i < chset->totchannel; i++) {
|
||||
if (STREQ(chset->channels[i].idname, idname)) {
|
||||
|
@ -316,12 +326,12 @@ bool BKE_brush_channelset_has(BrushChannelSet *chset, const char *idname)
|
|||
return BKE_brush_channelset_lookup(chset, idname) != NULL;
|
||||
}
|
||||
|
||||
void BKE_brush_channelset_add_builtin(BrushChannelSet *chset, const char *idname)
|
||||
ATTR_NO_OPT void BKE_brush_channelset_add_builtin(BrushChannelSet *chset, const char *idname)
|
||||
{
|
||||
BrushChannelType *def = NULL;
|
||||
|
||||
for (int i = 0; i < builtin_channel_len; i++) {
|
||||
BrushChannelType *def2 = builtin_channel_len + i;
|
||||
BrushChannelType *def2 = brush_builtin_channels + i;
|
||||
|
||||
if (STREQ(def2->idname, idname)) {
|
||||
def = def2;
|
||||
|
@ -485,8 +495,8 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
|
|||
ADDCH("STRENGTH");
|
||||
ADDCH("AUTOSMOOTH");
|
||||
ADDCH("TOPOLOGY_RAKE");
|
||||
ADDCH("AUTOSMOOTH_RADIUS_SCLAE");
|
||||
ADDCH("RAKE_RADIUS_SCALE");
|
||||
ADDCH("AUTOSMOOTH_RADIUS_SCALE");
|
||||
ADDCH("TOPOLOGY_RAKE_RADIUS_SCALE");
|
||||
|
||||
ADDCH("AUTOMASKING");
|
||||
|
||||
|
@ -498,6 +508,12 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
|
|||
ch->flag = BRUSH_CHANNEL_INHERIT;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// implement me!
|
||||
BKE_brush_channelset_free(chset);
|
||||
brush->channels = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,6 +99,8 @@ extern StructRNA RNA_BooleanModifier;
|
|||
extern StructRNA RNA_Brush;
|
||||
extern StructRNA RNA_BrushCapabilitiesImagePaint;
|
||||
extern StructRNA RNA_BrushCapabilitiesVertexPaint;
|
||||
extern StructRNA RNA_BrushChannel;
|
||||
extern StructRNA RNA_BrushChannelSet;
|
||||
extern StructRNA RNA_BrushTextureSlot;
|
||||
extern StructRNA RNA_BuildGpencilModifier;
|
||||
extern StructRNA RNA_BuildModifier;
|
||||
|
|
|
@ -3615,6 +3615,12 @@ static void rna_def_brush(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Gradient", "");
|
||||
RNA_def_property_update(prop, 0, "rna_Brush_update");
|
||||
|
||||
prop = RNA_def_property(srna, "channels", PROP_POINTER, 0);
|
||||
RNA_def_property_pointer_sdna(prop, NULL, "channels");
|
||||
RNA_def_property_struct_type(prop, "BrushChannelSet");
|
||||
RNA_def_property_ui_text(prop, "Channels", "");
|
||||
RNA_def_property_update(prop, 0, "rna_Brush_update");
|
||||
|
||||
/* gradient source */
|
||||
prop = RNA_def_property(srna, "gradient_stroke_mode", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, brush_gradient_items);
|
||||
|
|
|
@ -37,11 +37,80 @@
|
|||
|
||||
#include "IMB_imbuf.h"
|
||||
|
||||
#include "BKE_brush_engine.h"
|
||||
#include "DNA_sculpt_brush_types.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#ifdef RNA_RUNTIME
|
||||
|
||||
int rna_BrushChannelSet_channels_begin(CollectionPropertyIterator *iter, struct PointerRNA *ptr)
|
||||
{
|
||||
BrushChannelSet *chset = ptr->data;
|
||||
|
||||
rna_iterator_array_begin(
|
||||
iter, chset->channels, sizeof(BrushChannel), chset->totchannel, false, NULL);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int rna_BrushChannelSet_channels_assignint(struct PointerRNA *ptr,
|
||||
int key,
|
||||
const struct PointerRNA *assign_ptr)
|
||||
{
|
||||
BrushChannelSet *chset = ptr->data;
|
||||
BrushChannel *ch = chset->channels + key;
|
||||
BrushChannel *src = assign_ptr->data;
|
||||
|
||||
BKE_brush_channel_copy(ch, src);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void RNA_def_brush_channel(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
srna = RNA_def_struct(brna, "BrushChannel", NULL);
|
||||
RNA_def_struct_sdna(srna, "BrushChannel");
|
||||
RNA_def_struct_ui_text(srna, "Brush Channel", "Brush Channel");
|
||||
|
||||
prop = RNA_def_property(srna, "idname", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_sdna(prop, "BrushChannel", "idname");
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE | PROP_ANIMATABLE);
|
||||
|
||||
RNA_def_struct_name_property(srna, prop);
|
||||
}
|
||||
|
||||
void RNA_def_brush_channelset(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
srna = RNA_def_struct(brna, "BrushChannelSet", NULL);
|
||||
RNA_def_struct_sdna(srna, "BrushChannelSet");
|
||||
RNA_def_struct_ui_text(srna, "Channel Set", "Brush Channel Collection");
|
||||
|
||||
prop = RNA_def_property(srna, "channels", PROP_COLLECTION, PROP_NONE);
|
||||
RNA_def_property_collection_sdna(prop, NULL, "channels", "totchannel");
|
||||
RNA_def_property_collection_funcs(prop,
|
||||
"rna_BrushChannelSet_channels_begin",
|
||||
"rna_iterator_array_next",
|
||||
"rna_iterator_array_end",
|
||||
"rna_iterator_array_get",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
"rna_BrushChannelSet_channels_assignint");
|
||||
RNA_def_property_struct_type(prop, "BrushChannel");
|
||||
RNA_def_property_override_flag(
|
||||
prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY | PROPOVERRIDE_LIBRARY_INSERTION);
|
||||
}
|
||||
|
||||
void RNA_def_brush_engine(BlenderRNA *brna)
|
||||
{
|
||||
RNA_def_brush_channel(brna);
|
||||
RNA_def_brush_channelset(brna);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue