forked from bartvdbraak/blender
merge with 2.5 at r18865
This commit is contained in:
commit
1e3a23ee0c
@ -198,7 +198,7 @@ IF(UNIX)
|
||||
SET(PLATFORM_LINKFLAGS "-pthread")
|
||||
|
||||
# Better warnings
|
||||
SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Waggregate-return -Wnested-externs -Wdeclaration-after-statement")
|
||||
SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wnested-externs -Wdeclaration-after-statement")
|
||||
|
||||
INCLUDE_DIRECTORIES(/usr/include /usr/local/include)
|
||||
ENDIF(UNIX)
|
||||
|
@ -382,6 +382,10 @@
|
||||
RelativePath="..\..\..\source\blender\editors\interface\interface_regions.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\interface\interface_utils.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\interface\keyval.c"
|
||||
>
|
||||
@ -564,34 +568,34 @@
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="space_ipo"
|
||||
Name="space_graph"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\space_ipo\ipo_draw.c"
|
||||
RelativePath="..\..\..\source\blender\editors\space_graph\graph_draw.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\space_ipo\ipo_edit.c"
|
||||
RelativePath="..\..\..\source\blender\editors\space_graph\graph_edit.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\space_ipo\ipo_header.c"
|
||||
RelativePath="..\..\..\source\blender\editors\space_graph\graph_header.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\space_ipo\ipo_intern.h"
|
||||
RelativePath="..\..\..\source\blender\editors\space_graph\graph_intern.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\space_ipo\ipo_ops.c"
|
||||
RelativePath="..\..\..\source\blender\editors\space_graph\graph_ops.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\space_ipo\ipo_select.c"
|
||||
RelativePath="..\..\..\source\blender\editors\space_graph\graph_select.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\space_ipo\space_ipo.c"
|
||||
RelativePath="..\..\..\source\blender\editors\space_graph\space_graph.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
@ -1082,6 +1086,10 @@
|
||||
RelativePath="..\..\..\source\blender\editors\armature\armature_intern.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\armature\armature_ops.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\armature\editarmature.c"
|
||||
>
|
||||
|
@ -652,10 +652,6 @@
|
||||
RelativePath="..\..\..\source\blender\makesrna\intern\rna_image.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\makesrna\intern\rna_ipo.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\makesrna\intern\rna_key.c"
|
||||
>
|
||||
|
@ -222,10 +222,6 @@
|
||||
RelativePath="..\..\..\source\blender\makesrna\intern\rna.crna_image_gen.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\makesrna\intern\rna.crna_ipo_gen.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\makesrna\intern\rna.crna_key_gen.c"
|
||||
>
|
||||
|
@ -232,8 +232,7 @@ PULIB += $(OCGDIR)/blender/ed_file/libed_file.a
|
||||
PULIB += $(OCGDIR)/blender/ed_info/libed_info.a
|
||||
PULIB += $(OCGDIR)/blender/ed_buttons/libed_buttons.a
|
||||
PULIB += $(OCGDIR)/blender/ed_node/libed_node.a
|
||||
PULIB += $(OCGDIR)/blender/ed_image/libed_image.a
|
||||
PULIB += $(OCGDIR)/blender/ed_ipo/libed_ipo.a
|
||||
PULIB += $(OCGDIR)/blender/ed_graph/libed_graph.a
|
||||
PULIB += $(OCGDIR)/blender/ed_outliner/libed_outliner.a
|
||||
PULIB += $(OCGDIR)/blender/ed_time/libed_time.a
|
||||
PULIB += $(OCGDIR)/blender/ed_preview/libed_preview.a
|
||||
@ -248,8 +247,9 @@ PULIB += $(OCGDIR)/blender/ed_physics/libed_physics.a
|
||||
PULIB += $(OCGDIR)/blender/ed_animation/libed_animation.a
|
||||
PULIB += $(OCGDIR)/blender/ed_transform/libed_transform.a
|
||||
PULIB += $(OCGDIR)/blender/ed_util/libed_util.a
|
||||
PULIB += $(OCGDIR)/blender/ed_uvedit/libed_uvedit.a
|
||||
PULIB += $(OCGDIR)/blender/ed_datafiles/libed_datafiles.a
|
||||
PULIB += $(OCGDIR)/blender/ed_image/libed_image.a
|
||||
PULIB += $(OCGDIR)/blender/ed_uvedit/libed_uvedit.a
|
||||
PULIB += $(OCGDIR)/blender/ed_screen/libed_screen.a
|
||||
PULIB += $(OCGDIR)/blender/windowmanager/libwindowmanager.a
|
||||
PULIB += $(OCGDIR)/blender/python/$(DEBUG_DIR)libpython.a
|
||||
|
@ -51,6 +51,8 @@ struct StructRNA;
|
||||
struct ToolSettings;
|
||||
struct Image;
|
||||
struct ImBuf;
|
||||
struct EditBone;
|
||||
struct bPoseChannel;
|
||||
struct wmWindow;
|
||||
struct wmWindowManager;
|
||||
|
||||
@ -81,7 +83,14 @@ enum {
|
||||
CTX_DATA_EDIT_IMAGE,
|
||||
CTX_DATA_EDIT_IMAGE_BUFFER,
|
||||
|
||||
CTX_DATA_SELECTED_NODES
|
||||
CTX_DATA_SELECTED_NODES,
|
||||
|
||||
CTX_DATA_SELECTED_BONES,
|
||||
CTX_DATA_SELECTED_EDITABLE_BONES,
|
||||
CTX_DATA_SELECTED_PCHANS,
|
||||
|
||||
CTX_DATA_ACTIVE_BONE,
|
||||
CTX_DATA_ACTIVE_PCHAN,
|
||||
};
|
||||
|
||||
typedef int bContextDataMember;
|
||||
@ -185,6 +194,13 @@ struct ImBuf *CTX_data_edit_image_buffer(const bContext *C);
|
||||
|
||||
int CTX_data_selected_nodes(const bContext *C, ListBase *list);
|
||||
|
||||
struct EditBone *CTX_data_active_bone(const bContext *C);
|
||||
int CTX_data_selected_bones(const bContext *C, ListBase *list);
|
||||
int CTX_data_selected_editable_bones(const bContext *C, ListBase *list);
|
||||
|
||||
struct bPoseChannel *CTX_data_active_pchan(const bContext *C);
|
||||
int CTX_data_selected_pchans(const bContext *C, ListBase *list);
|
||||
|
||||
/* Data Evaluation Context */
|
||||
|
||||
float CTX_eval_frame(const bContext *C);
|
||||
|
@ -52,9 +52,6 @@ struct GPUMaterial;
|
||||
struct GPUNode;
|
||||
struct GPUNodeStack;
|
||||
|
||||
#define SOCK_IN 1
|
||||
#define SOCK_OUT 2
|
||||
|
||||
/* ************** NODE TYPE DEFINITIONS ***** */
|
||||
|
||||
typedef struct bNodeSocketType {
|
||||
|
@ -224,7 +224,7 @@ behaviour, though it may not be the best in practice.
|
||||
#define V_DECLARE(vec) int _##vec##_count=0; void *_##vec##_tmp
|
||||
|
||||
/*this returns the entire size of the array, including any buffering.*/
|
||||
#define V_SIZE(vec) ((vec)==NULL ? 0 : MEM_allocN_len(vec) / sizeof(*vec))
|
||||
#define V_SIZE(vec) ((signed int)((vec)==NULL ? 0 : MEM_allocN_len(vec) / sizeof(*vec)))
|
||||
|
||||
/*this returns the logical size of the array, not including buffering.*/
|
||||
#define V_COUNT(vec) _##vec##_count
|
||||
|
@ -511,7 +511,7 @@ static float get_actionstrip_frame(bActionStrip *strip, float cframe, int invert
|
||||
repeat = (strip->flag & ACTSTRIP_USESTRIDE) ? (1.0f) : (strip->repeat);
|
||||
|
||||
if (strip->scale == 0.0f) strip->scale= 1.0f;
|
||||
scale = fabs(strip->scale); /* scale must be positive (for now) */
|
||||
scale = (float)fabs(strip->scale); /* scale must be positive (for now) */
|
||||
|
||||
actlength = strip->actend-strip->actstart;
|
||||
if (actlength == 0.0f) actlength = 1.0f;
|
||||
|
@ -242,10 +242,18 @@ void brush_curve_preset(Brush *b, BrushCurvePreset preset)
|
||||
if(cm->curve)
|
||||
MEM_freeN(cm->curve);
|
||||
|
||||
if(preset == BRUSH_PRESET_SHARP) {
|
||||
cm->curve= MEM_callocN(3*sizeof(CurveMapPoint), "curve points");
|
||||
cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
|
||||
if(preset == BRUSH_PRESET_SHARP)
|
||||
cm->totpoint= 3;
|
||||
if(preset == BRUSH_PRESET_SMOOTH)
|
||||
cm->totpoint= 6;
|
||||
if(preset == BRUSH_PRESET_MAX)
|
||||
cm->totpoint= 2;
|
||||
|
||||
|
||||
cm->curve= MEM_callocN(cm->totpoint*sizeof(CurveMapPoint), "curve points");
|
||||
cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
|
||||
|
||||
if(preset == BRUSH_PRESET_SHARP) {
|
||||
cm->curve[0].x= 0;
|
||||
cm->curve[0].y= 1;
|
||||
cm->curve[1].x= 0.33;
|
||||
@ -254,10 +262,24 @@ void brush_curve_preset(Brush *b, BrushCurvePreset preset)
|
||||
cm->curve[2].y= 0;
|
||||
}
|
||||
else if(preset == BRUSH_PRESET_SMOOTH) {
|
||||
// XXX: todo
|
||||
cm->curve[0].x= 0;
|
||||
cm->curve[0].y= 1;
|
||||
cm->curve[1].x= 0.1;
|
||||
cm->curve[1].y= 0.97553;
|
||||
cm->curve[2].x= 0.3;
|
||||
cm->curve[2].y= 0.79389;
|
||||
cm->curve[3].x= 0.9;
|
||||
cm->curve[3].y= 0.02447;
|
||||
cm->curve[4].x= 0.7;
|
||||
cm->curve[4].y= 0.20611;
|
||||
cm->curve[5].x= 1;
|
||||
cm->curve[5].y= 0;
|
||||
}
|
||||
else if(preset == BRUSH_PRESET_MAX) {
|
||||
// XXX: todo
|
||||
cm->curve[0].x= 0;
|
||||
cm->curve[0].y= 1;
|
||||
cm->curve[1].x= 1;
|
||||
cm->curve[1].y= 1;
|
||||
}
|
||||
|
||||
curvemapping_changed(b->curve, 0);
|
||||
|
@ -333,8 +333,11 @@ int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase
|
||||
{
|
||||
ListBase list;
|
||||
|
||||
if(func(C, &list))
|
||||
return BLI_countlist(&list);
|
||||
if(func(C, &list)) {
|
||||
int tot= BLI_countlist(&list);
|
||||
BLI_freelistN(&list);
|
||||
return tot;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@ -441,6 +444,31 @@ struct ImBuf *CTX_data_edit_image_buffer(const bContext *C)
|
||||
return ctx_data_pointer_get(C, CTX_DATA_EDIT_IMAGE_BUFFER);
|
||||
}
|
||||
|
||||
struct EditBone *CTX_data_active_bone(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, CTX_DATA_ACTIVE_BONE);
|
||||
}
|
||||
|
||||
int CTX_data_selected_bones(const bContext *C, ListBase *list)
|
||||
{
|
||||
return ctx_data_collection_get(C, CTX_DATA_SELECTED_BONES, list);
|
||||
}
|
||||
|
||||
int CTX_data_selected_editable_bones(const bContext *C, ListBase *list)
|
||||
{
|
||||
return ctx_data_collection_get(C, CTX_DATA_SELECTED_EDITABLE_BONES, list);
|
||||
}
|
||||
|
||||
struct bPoseChannel *CTX_data_active_pchan(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, CTX_DATA_ACTIVE_PCHAN);
|
||||
}
|
||||
|
||||
int CTX_data_selected_pchans(const bContext *C, ListBase *list)
|
||||
{
|
||||
return ctx_data_collection_get(C, CTX_DATA_SELECTED_PCHANS, list);
|
||||
}
|
||||
|
||||
/* data evaluation */
|
||||
|
||||
float CTX_eval_frame(const bContext *C)
|
||||
|
@ -1797,14 +1797,30 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser)
|
||||
|
||||
/* showing RGBA result itself (from compo/sequence) or
|
||||
like exr, using layers etc */
|
||||
/* always returns a single ibuf, also during render progress */
|
||||
static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser)
|
||||
{
|
||||
Render *re;
|
||||
RenderResult *rr= NULL;
|
||||
|
||||
if(iuser->scene)
|
||||
rr= RE_GetResult(RE_GetRender(iuser->scene->id.name));
|
||||
if(iuser->scene) {
|
||||
re= RE_GetRender(iuser->scene->id.name);
|
||||
rr= RE_GetResult(re);
|
||||
}
|
||||
if(rr==NULL) return NULL;
|
||||
|
||||
if(rr) {
|
||||
if(RE_RenderInProgress(re)) {
|
||||
ImBuf *ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0);
|
||||
|
||||
/* make ibuf if needed, and initialize it */
|
||||
/* this only gets called when mutex locked */
|
||||
if(ibuf==NULL) {
|
||||
ibuf= IMB_allocImBuf(rr->rectx, rr->recty, 32, IB_rect, 0);
|
||||
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
|
||||
}
|
||||
return ibuf;
|
||||
}
|
||||
else {
|
||||
RenderResult rres;
|
||||
float *rectf;
|
||||
unsigned int *rect;
|
||||
|
@ -151,39 +151,40 @@ static AdrBit2Path ob_layer_bits[]= {
|
||||
{(1<<20), "layer", 20}
|
||||
};
|
||||
|
||||
/* Material mode */
|
||||
static AdrBit2Path ma_mode_bits[]= {
|
||||
// {MA_TRACEBLE, "traceable", 0},
|
||||
// {MA_SHADOW, "shadow", 0},
|
||||
// {MA_SHLESS, "shadeless", 0},
|
||||
// ...
|
||||
{MA_RAYTRANSP, "raytrace_transparency.enabled", 0},
|
||||
{MA_RAYMIRROR, "raytrace_mirror.enabled", 0},
|
||||
{MA_HALO, "halo.enabled", 0}
|
||||
};
|
||||
|
||||
/* ----------------- */
|
||||
|
||||
/* quick macro for returning the appropriate array for adrcode_bitmaps_to_paths() */
|
||||
#define RET_ABP(items) \
|
||||
{ \
|
||||
*tot= sizeof(items)/sizeof(AdrBit2Path); \
|
||||
return items; \
|
||||
}
|
||||
|
||||
/* This function checks if a Blocktype+Adrcode combo, returning a mapping table */
|
||||
static AdrBit2Path *adrcode_bitmaps_to_paths (int blocktype, int adrcode, int *tot)
|
||||
{
|
||||
/* Object layers */
|
||||
if ((blocktype == ID_OB) && (adrcode == OB_LAY)) {
|
||||
*tot= sizeof(ob_layer_bits)/sizeof(AdrBit2Path);
|
||||
return ob_layer_bits;
|
||||
}
|
||||
else if ((blocktype == ID_MA) && (adrcode == MA_MODE)) {
|
||||
// XXX to be added...
|
||||
}
|
||||
if ((blocktype == ID_OB) && (adrcode == OB_LAY))
|
||||
RET_ABP(ob_layer_bits)
|
||||
else if ((blocktype == ID_MA) && (adrcode == MA_MODE))
|
||||
RET_ABP(ma_mode_bits)
|
||||
// XXX TODO: add other types...
|
||||
|
||||
/* Normal curve */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This function makes a copy of a path stored in AdrBit2Path entry, and makes a guardedalloc copy */
|
||||
static char *adrcode_bitmap_path_copy (const char *abp_path)
|
||||
{
|
||||
char *path;
|
||||
int len;
|
||||
|
||||
/* copy the path */
|
||||
len= strlen(abp_path) + 1; // XXX is this safe?
|
||||
path= MEM_callocN(len, "Bitflag IPO-Curve RNA-Path");
|
||||
memcpy(path, abp_path, len);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/* *************************************************** */
|
||||
/* ADRCODE to RNA-Path Conversion Code - Standard */
|
||||
|
||||
@ -351,6 +352,76 @@ static char *shapekey_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* MTex (Texture Slot) types */
|
||||
static char *mtex_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
{
|
||||
char *base=NULL, *prop=NULL;
|
||||
static char buf[128];
|
||||
|
||||
/* base part of path */
|
||||
if (adrcode & MA_MAP1) base= "textures[0]";
|
||||
else if (adrcode & MA_MAP2) base= "textures[1]";
|
||||
else if (adrcode & MA_MAP3) base= "textures[2]";
|
||||
else if (adrcode & MA_MAP4) base= "textures[3]";
|
||||
else if (adrcode & MA_MAP5) base= "textures[4]";
|
||||
else if (adrcode & MA_MAP6) base= "textures[5]";
|
||||
else if (adrcode & MA_MAP7) base= "textures[6]";
|
||||
else if (adrcode & MA_MAP8) base= "textures[7]";
|
||||
else if (adrcode & MA_MAP9) base= "textures[8]";
|
||||
else if (adrcode & MA_MAP10) base= "textures[9]";
|
||||
else if (adrcode & MA_MAP11) base= "textures[10]";
|
||||
else if (adrcode & MA_MAP12) base= "textures[11]";
|
||||
else if (adrcode & MA_MAP13) base= "textures[12]";
|
||||
else if (adrcode & MA_MAP14) base= "textures[13]";
|
||||
else if (adrcode & MA_MAP15) base= "textures[14]";
|
||||
else if (adrcode & MA_MAP16) base= "textures[15]";
|
||||
else if (adrcode & MA_MAP17) base= "textures[16]";
|
||||
else if (adrcode & MA_MAP18) base= "textures[17]";
|
||||
|
||||
/* property identifier for path */
|
||||
adrcode= (adrcode & (MA_MAP1-1));
|
||||
switch (adrcode) {
|
||||
#if 0 // XXX these are not wrapped in RNA yet!
|
||||
case MAP_OFS_X:
|
||||
poin= &(mtex->ofs[0]); break;
|
||||
case MAP_OFS_Y:
|
||||
poin= &(mtex->ofs[1]); break;
|
||||
case MAP_OFS_Z:
|
||||
poin= &(mtex->ofs[2]); break;
|
||||
case MAP_SIZE_X:
|
||||
poin= &(mtex->size[0]); break;
|
||||
case MAP_SIZE_Y:
|
||||
poin= &(mtex->size[1]); break;
|
||||
case MAP_SIZE_Z:
|
||||
poin= &(mtex->size[2]); break;
|
||||
case MAP_R:
|
||||
poin= &(mtex->r); break;
|
||||
case MAP_G:
|
||||
poin= &(mtex->g); break;
|
||||
case MAP_B:
|
||||
poin= &(mtex->b); break;
|
||||
case MAP_DVAR:
|
||||
poin= &(mtex->def_var); break;
|
||||
case MAP_COLF:
|
||||
poin= &(mtex->colfac); break;
|
||||
case MAP_NORF:
|
||||
poin= &(mtex->norfac); break;
|
||||
case MAP_VARF:
|
||||
poin= &(mtex->varfac); break;
|
||||
#endif
|
||||
case MAP_DISP:
|
||||
prop= "warp_factor"; break;
|
||||
}
|
||||
|
||||
/* only build and return path if there's a property */
|
||||
if (prop) {
|
||||
BLI_snprintf(buf, 128, "%s.%s", base, prop);
|
||||
return buf;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Texture types */
|
||||
static char *texture_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
{
|
||||
@ -465,67 +536,54 @@ static char *material_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
|
||||
case MA_REF:
|
||||
return "diffuse_reflection";
|
||||
|
||||
// XXX add other types...
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
#if 0
|
||||
case MA_EMIT:
|
||||
poin= &(ma->emit); break;
|
||||
case MA_AMB:
|
||||
poin= &(ma->amb); break;
|
||||
case MA_SPEC:
|
||||
poin= &(ma->spec); break;
|
||||
case MA_HARD:
|
||||
poin= &(ma->har); *type= IPO_SHORT; break;
|
||||
case MA_SPTR:
|
||||
poin= &(ma->spectra); break;
|
||||
case MA_IOR:
|
||||
poin= &(ma->ang); break;
|
||||
case MA_HASIZE:
|
||||
poin= &(ma->hasize); break;
|
||||
case MA_TRANSLU:
|
||||
poin= &(ma->translucency); break;
|
||||
case MA_RAYM:
|
||||
poin= &(ma->ray_mirror); break;
|
||||
case MA_FRESMIR:
|
||||
poin= &(ma->fresnel_mir); break;
|
||||
case MA_FRESMIRI:
|
||||
poin= &(ma->fresnel_mir_i); break;
|
||||
case MA_FRESTRA:
|
||||
poin= &(ma->fresnel_tra); break;
|
||||
case MA_FRESTRAI:
|
||||
poin= &(ma->fresnel_tra_i); break;
|
||||
case MA_ADD:
|
||||
poin= &(ma->add); break;
|
||||
|
||||
if (poin == NULL) {
|
||||
if (icu->adrcode & MA_MAP1) mtex= ma->mtex[0];
|
||||
else if (icu->adrcode & MA_MAP2) mtex= ma->mtex[1];
|
||||
else if (icu->adrcode & MA_MAP3) mtex= ma->mtex[2];
|
||||
else if (icu->adrcode & MA_MAP4) mtex= ma->mtex[3];
|
||||
else if (icu->adrcode & MA_MAP5) mtex= ma->mtex[4];
|
||||
else if (icu->adrcode & MA_MAP6) mtex= ma->mtex[5];
|
||||
else if (icu->adrcode & MA_MAP7) mtex= ma->mtex[6];
|
||||
else if (icu->adrcode & MA_MAP8) mtex= ma->mtex[7];
|
||||
else if (icu->adrcode & MA_MAP9) mtex= ma->mtex[8];
|
||||
else if (icu->adrcode & MA_MAP10) mtex= ma->mtex[9];
|
||||
else if (icu->adrcode & MA_MAP12) mtex= ma->mtex[11];
|
||||
else if (icu->adrcode & MA_MAP11) mtex= ma->mtex[10];
|
||||
else if (icu->adrcode & MA_MAP13) mtex= ma->mtex[12];
|
||||
else if (icu->adrcode & MA_MAP14) mtex= ma->mtex[13];
|
||||
else if (icu->adrcode & MA_MAP15) mtex= ma->mtex[14];
|
||||
else if (icu->adrcode & MA_MAP16) mtex= ma->mtex[15];
|
||||
else if (icu->adrcode & MA_MAP17) mtex= ma->mtex[16];
|
||||
else if (icu->adrcode & MA_MAP18) mtex= ma->mtex[17];
|
||||
|
||||
if (mtex)
|
||||
poin= give_mtex_poin(mtex, (icu->adrcode & (MA_MAP1-1)));
|
||||
case MA_EMIT:
|
||||
return "emit";
|
||||
|
||||
case MA_AMB:
|
||||
return "ambient";
|
||||
|
||||
case MA_SPEC:
|
||||
return "specularity";
|
||||
|
||||
case MA_HARD:
|
||||
return "specular_hardness";
|
||||
|
||||
case MA_SPTR:
|
||||
return "specular_opacity";
|
||||
|
||||
case MA_IOR:
|
||||
return "ior";
|
||||
|
||||
case MA_HASIZE:
|
||||
return "halo.size";
|
||||
|
||||
case MA_TRANSLU:
|
||||
return "translucency";
|
||||
|
||||
case MA_RAYM:
|
||||
return "raytrace_mirror.reflect";
|
||||
|
||||
case MA_FRESMIR:
|
||||
return "raytrace_mirror.fresnel";
|
||||
|
||||
case MA_FRESMIRI:
|
||||
return "raytrace_mirror.fresnel_fac";
|
||||
|
||||
case MA_FRESTRA:
|
||||
return "raytrace_transparency.fresnel";
|
||||
|
||||
case MA_FRESTRAI:
|
||||
return "raytrace_transparency.fresnel_fac";
|
||||
|
||||
case MA_ADD:
|
||||
return "halo.add";
|
||||
|
||||
default: /* for now, we assume that the others were MTex channels */
|
||||
return mtex_adrcodes_to_paths(adrcode, array_index);
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Camera Types */
|
||||
@ -600,38 +658,91 @@ static char *lamp_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
|
||||
case LA_HALOINT:
|
||||
return "halo_intensity";
|
||||
}
|
||||
|
||||
#if 0 // XXX to be converted
|
||||
if (poin == NULL) {
|
||||
if (icu->adrcode & MA_MAP1) mtex= la->mtex[0];
|
||||
else if (icu->adrcode & MA_MAP2) mtex= la->mtex[1];
|
||||
else if (icu->adrcode & MA_MAP3) mtex= la->mtex[2];
|
||||
else if (icu->adrcode & MA_MAP4) mtex= la->mtex[3];
|
||||
else if (icu->adrcode & MA_MAP5) mtex= la->mtex[4];
|
||||
else if (icu->adrcode & MA_MAP6) mtex= la->mtex[5];
|
||||
else if (icu->adrcode & MA_MAP7) mtex= la->mtex[6];
|
||||
else if (icu->adrcode & MA_MAP8) mtex= la->mtex[7];
|
||||
else if (icu->adrcode & MA_MAP9) mtex= la->mtex[8];
|
||||
else if (icu->adrcode & MA_MAP10) mtex= la->mtex[9];
|
||||
else if (icu->adrcode & MA_MAP11) mtex= la->mtex[10];
|
||||
else if (icu->adrcode & MA_MAP12) mtex= la->mtex[11];
|
||||
else if (icu->adrcode & MA_MAP13) mtex= la->mtex[12];
|
||||
else if (icu->adrcode & MA_MAP14) mtex= la->mtex[13];
|
||||
else if (icu->adrcode & MA_MAP15) mtex= la->mtex[14];
|
||||
else if (icu->adrcode & MA_MAP16) mtex= la->mtex[15];
|
||||
else if (icu->adrcode & MA_MAP17) mtex= la->mtex[16];
|
||||
else if (icu->adrcode & MA_MAP18) mtex= la->mtex[17];
|
||||
|
||||
if (mtex)
|
||||
poin= give_mtex_poin(mtex, (icu->adrcode & (MA_MAP1-1)));
|
||||
}
|
||||
#endif // XXX to be converted
|
||||
default: /* for now, we assume that the others were MTex channels */
|
||||
return mtex_adrcodes_to_paths(adrcode, array_index);
|
||||
}
|
||||
|
||||
/* unrecognised adrcode, or not-yet-handled ones! */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Sound Types */
|
||||
static char *sound_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
{
|
||||
/* set array index like this in-case nothing sets it correctly */
|
||||
*array_index= 0;
|
||||
|
||||
/* result depends on adrcode */
|
||||
switch (adrcode) {
|
||||
case SND_VOLUME:
|
||||
return "volume";
|
||||
case SND_PITCH:
|
||||
return "pitch";
|
||||
/* XXX Joshua -- I had wrapped panning in rna, but someone commented out, calling it "unused" */
|
||||
/* case SND_PANNING:
|
||||
return "panning"; */
|
||||
case SND_ATTEN:
|
||||
return "attenuation";
|
||||
}
|
||||
|
||||
/* unrecognised adrcode, or not-yet-handled ones! */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* World Types */
|
||||
static char *world_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
{
|
||||
/* set array index like this in-case nothing sets it correctly */
|
||||
*array_index= 0;
|
||||
|
||||
/* result depends on adrcode */
|
||||
switch (adrcode) {
|
||||
case WO_HOR_R:
|
||||
*array_index= 0; return "horizon_color";
|
||||
case WO_HOR_G:
|
||||
*array_index= 1; return "horizon_color";
|
||||
case WO_HOR_B:
|
||||
*array_index= 2; return "horizon_color";
|
||||
case WO_ZEN_R:
|
||||
*array_index= 0; return "zenith_color";
|
||||
case WO_ZEN_G:
|
||||
*array_index= 1; return "zenith_color";
|
||||
case WO_ZEN_B:
|
||||
*array_index= 2; return "zenith_color";
|
||||
|
||||
case WO_EXPOS:
|
||||
return "exposure";
|
||||
|
||||
case WO_MISI:
|
||||
return "mist.intensity";
|
||||
case WO_MISTDI:
|
||||
return "mist.depth";
|
||||
case WO_MISTSTA:
|
||||
return "mist.start";
|
||||
case WO_MISTHI:
|
||||
return "mist.height";
|
||||
|
||||
/* Star Color is unused -- recommend removal */
|
||||
/* case WO_STAR_R:
|
||||
*array_index= 0; return "stars.color";
|
||||
case WO_STAR_G:
|
||||
*array_index= 1; return "stars.color";
|
||||
case WO_STAR_B:
|
||||
*array_index= 2; return "stars.color"; */
|
||||
|
||||
case WO_STARDIST:
|
||||
return "stars.min_distance";
|
||||
case WO_STARSIZE:
|
||||
return "stars.size";
|
||||
|
||||
default: /* for now, we assume that the others were MTex channels */
|
||||
return mtex_adrcodes_to_paths(adrcode, array_index);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ------- */
|
||||
|
||||
/* Allocate memory for RNA-path for some property given a blocktype, adrcode, and 'root' parts of path
|
||||
@ -682,6 +793,12 @@ char *get_rna_access (int blocktype, int adrcode, char actname[], char constname
|
||||
case ID_LA: /* lamp */
|
||||
propname= lamp_adrcodes_to_paths(adrcode, &dummy_index);
|
||||
break;
|
||||
|
||||
case ID_SO: /* sound */
|
||||
propname= sound_adrcodes_to_paths(adrcode, &dummy_index);
|
||||
|
||||
case ID_WO: /* world */
|
||||
propname= world_adrcodes_to_paths(adrcode, &dummy_index);
|
||||
|
||||
/* XXX problematic blocktypes */
|
||||
case ID_CU: /* curve */
|
||||
@ -936,7 +1053,7 @@ static void icu_to_fcurves (ListBase *list, IpoCurve *icu, char *actname, char *
|
||||
fcurve= fcu;
|
||||
|
||||
/* set path */
|
||||
fcurve->rna_path= adrcode_bitmap_path_copy(abp->path);
|
||||
fcurve->rna_path= BLI_strdupn(abp->path, strlen(abp->path));
|
||||
fcurve->array_index= abp->array_index;
|
||||
|
||||
/* convert keyframes
|
||||
@ -1490,45 +1607,6 @@ void do_versions_ipos_to_animato(Main *main)
|
||||
|
||||
/* --------------------- Get Pointer API ----------------------------- */
|
||||
|
||||
/* get texture-slot/mapping channel */
|
||||
void *give_mtex_poin (MTex *mtex, int adrcode)
|
||||
{
|
||||
void *poin= NULL;
|
||||
|
||||
switch (adrcode) {
|
||||
case MAP_OFS_X:
|
||||
poin= &(mtex->ofs[0]); break;
|
||||
case MAP_OFS_Y:
|
||||
poin= &(mtex->ofs[1]); break;
|
||||
case MAP_OFS_Z:
|
||||
poin= &(mtex->ofs[2]); break;
|
||||
case MAP_SIZE_X:
|
||||
poin= &(mtex->size[0]); break;
|
||||
case MAP_SIZE_Y:
|
||||
poin= &(mtex->size[1]); break;
|
||||
case MAP_SIZE_Z:
|
||||
poin= &(mtex->size[2]); break;
|
||||
case MAP_R:
|
||||
poin= &(mtex->r); break;
|
||||
case MAP_G:
|
||||
poin= &(mtex->g); break;
|
||||
case MAP_B:
|
||||
poin= &(mtex->b); break;
|
||||
case MAP_DVAR:
|
||||
poin= &(mtex->def_var); break;
|
||||
case MAP_COLF:
|
||||
poin= &(mtex->colfac); break;
|
||||
case MAP_NORF:
|
||||
poin= &(mtex->norfac); break;
|
||||
case MAP_VARF:
|
||||
poin= &(mtex->varfac); break;
|
||||
case MAP_DISP:
|
||||
poin= &(mtex->dispfac); break;
|
||||
}
|
||||
|
||||
/* return pointer */
|
||||
return poin;
|
||||
}
|
||||
|
||||
/* GS reads the memory pointed at in a specific ordering. There are,
|
||||
* however two definitions for it. I have jotted them down here, both,
|
||||
@ -1555,90 +1633,6 @@ void *get_ipo_poin (ID *id, IpoCurve *icu, int *type)
|
||||
|
||||
/* data is divided into 'blocktypes' based on ID-codes */
|
||||
switch (GS(id->name)) {
|
||||
case ID_WO: /* world channels ----------------------------- */
|
||||
{
|
||||
World *wo= (World *)id;
|
||||
|
||||
switch (icu->adrcode) {
|
||||
case WO_HOR_R:
|
||||
poin= &(wo->horr); break;
|
||||
case WO_HOR_G:
|
||||
poin= &(wo->horg); break;
|
||||
case WO_HOR_B:
|
||||
poin= &(wo->horb); break;
|
||||
case WO_ZEN_R:
|
||||
poin= &(wo->zenr); break;
|
||||
case WO_ZEN_G:
|
||||
poin= &(wo->zeng); break;
|
||||
case WO_ZEN_B:
|
||||
poin= &(wo->zenb); break;
|
||||
|
||||
case WO_EXPOS:
|
||||
poin= &(wo->exposure); break;
|
||||
|
||||
case WO_MISI:
|
||||
poin= &(wo->misi); break;
|
||||
case WO_MISTDI:
|
||||
poin= &(wo->mistdist); break;
|
||||
case WO_MISTSTA:
|
||||
poin= &(wo->miststa); break;
|
||||
case WO_MISTHI:
|
||||
poin= &(wo->misthi); break;
|
||||
|
||||
case WO_STAR_R:
|
||||
poin= &(wo->starr); break;
|
||||
case WO_STAR_G:
|
||||
poin= &(wo->starg); break;
|
||||
case WO_STAR_B:
|
||||
poin= &(wo->starb); break;
|
||||
|
||||
case WO_STARDIST:
|
||||
poin= &(wo->stardist); break;
|
||||
case WO_STARSIZE:
|
||||
poin= &(wo->starsize); break;
|
||||
}
|
||||
|
||||
if (poin == NULL) {
|
||||
if (icu->adrcode & MA_MAP1) mtex= wo->mtex[0];
|
||||
else if (icu->adrcode & MA_MAP2) mtex= wo->mtex[1];
|
||||
else if (icu->adrcode & MA_MAP3) mtex= wo->mtex[2];
|
||||
else if (icu->adrcode & MA_MAP4) mtex= wo->mtex[3];
|
||||
else if (icu->adrcode & MA_MAP5) mtex= wo->mtex[4];
|
||||
else if (icu->adrcode & MA_MAP6) mtex= wo->mtex[5];
|
||||
else if (icu->adrcode & MA_MAP7) mtex= wo->mtex[6];
|
||||
else if (icu->adrcode & MA_MAP8) mtex= wo->mtex[7];
|
||||
else if (icu->adrcode & MA_MAP9) mtex= wo->mtex[8];
|
||||
else if (icu->adrcode & MA_MAP10) mtex= wo->mtex[9];
|
||||
else if (icu->adrcode & MA_MAP11) mtex= wo->mtex[10];
|
||||
else if (icu->adrcode & MA_MAP12) mtex= wo->mtex[11];
|
||||
else if (icu->adrcode & MA_MAP13) mtex= wo->mtex[12];
|
||||
else if (icu->adrcode & MA_MAP14) mtex= wo->mtex[13];
|
||||
else if (icu->adrcode & MA_MAP15) mtex= wo->mtex[14];
|
||||
else if (icu->adrcode & MA_MAP16) mtex= wo->mtex[15];
|
||||
else if (icu->adrcode & MA_MAP17) mtex= wo->mtex[16];
|
||||
else if (icu->adrcode & MA_MAP18) mtex= wo->mtex[17];
|
||||
|
||||
if (mtex)
|
||||
poin= give_mtex_poin(mtex, (icu->adrcode & (MA_MAP1-1)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ID_SO: /* sound channels ----------------------------- */
|
||||
{
|
||||
bSound *snd= (bSound *)id;
|
||||
|
||||
switch (icu->adrcode) {
|
||||
case SND_VOLUME:
|
||||
poin= &(snd->volume); break;
|
||||
case SND_PITCH:
|
||||
poin= &(snd->pitch); break;
|
||||
case SND_PANNING:
|
||||
poin= &(snd->panning); break;
|
||||
case SND_ATTEN:
|
||||
poin= &(snd->attenuation); break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ID_PA: /* particle channels ----------------------------- */
|
||||
{
|
||||
ParticleSettings *part= (ParticleSettings *)id;
|
||||
|
@ -1204,7 +1204,7 @@ static void multiresModifier_update(DerivedMesh *dm)
|
||||
|
||||
void multires_force_update(Object *ob)
|
||||
{
|
||||
if(ob->derivedFinal) {
|
||||
if(ob && ob->derivedFinal) {
|
||||
ob->derivedFinal->needsFree =1;
|
||||
ob->derivedFinal->release(ob->derivedFinal);
|
||||
ob->derivedFinal = NULL;
|
||||
|
@ -1124,7 +1124,8 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select)
|
||||
|
||||
/* check for copying links */
|
||||
for(link= ntree->links.first; link; link= link->next) {
|
||||
if(link->fromnode->new_node && link->tonode->new_node) {
|
||||
if(link->fromnode==NULL || link->tonode==NULL);
|
||||
else if(link->fromnode->new_node && link->tonode->new_node) {
|
||||
nlink= nodeAddLink(newtree, link->fromnode->new_node, NULL, link->tonode->new_node, NULL);
|
||||
/* sockets were copied in order */
|
||||
for(a=0, sock= link->fromnode->outputs.first; sock; sock= sock->next, a++) {
|
||||
@ -2269,8 +2270,10 @@ static int setExecutableNodes(bNodeTree *ntree, ThreadData *thd)
|
||||
/* is sock in use? */
|
||||
else if(sock->link) {
|
||||
bNodeLink *link= sock->link;
|
||||
|
||||
/* this is the test for a cyclic case */
|
||||
if(link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF) {
|
||||
if(link->fromnode==NULL || link->tonode==NULL);
|
||||
else if(link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF) {
|
||||
if(link->fromnode->need_exec) {
|
||||
node->need_exec= 1;
|
||||
break;
|
||||
|
@ -3672,6 +3672,17 @@ static void direct_link_object(FileData *fd, Object *ob)
|
||||
|
||||
/* ************ READ SCENE ***************** */
|
||||
|
||||
/* patch for missing scene IDs, can't be in do-versions */
|
||||
static void composite_patch(bNodeTree *ntree, Scene *scene)
|
||||
{
|
||||
bNode *node;
|
||||
|
||||
for(node= ntree->nodes.first; node; node= node->next)
|
||||
if(node->id==NULL && ELEM(node->type, CMP_NODE_R_LAYERS, CMP_NODE_COMPOSITE))
|
||||
node->id= &scene->id;
|
||||
}
|
||||
|
||||
|
||||
static void lib_link_scene(FileData *fd, Main *main)
|
||||
{
|
||||
Scene *sce;
|
||||
@ -3736,8 +3747,10 @@ static void lib_link_scene(FileData *fd, Main *main)
|
||||
|
||||
lib_link_scriptlink(fd, &sce->id, &sce->scriptlink);
|
||||
|
||||
if(sce->nodetree)
|
||||
if(sce->nodetree) {
|
||||
lib_link_ntree(fd, &sce->id, sce->nodetree);
|
||||
composite_patch(sce->nodetree, sce);
|
||||
}
|
||||
|
||||
for(srl= sce->r.layers.first; srl; srl= srl->next) {
|
||||
srl->mat_override= newlibadr_us(fd, sce->id.lib, srl->mat_override);
|
||||
@ -4503,7 +4516,7 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
|
||||
/* 2.50: we now always add spacedata for info */
|
||||
if(sa->spacedata.first==NULL) {
|
||||
SpaceInfo *sinfo= MEM_callocN(sizeof(SpaceInfo), "spaceinfo");
|
||||
sa->spacetype= SPACE_INFO;
|
||||
sa->spacetype= sinfo->spacetype= SPACE_INFO;
|
||||
BLI_addtail(&sa->spacedata, sinfo);
|
||||
}
|
||||
/* add local view3d too */
|
||||
|
@ -157,6 +157,13 @@ enum {
|
||||
BMOP_ESUBDIVIDE_FLAG, //beauty flag in esubdivide
|
||||
BMOP_ESUBDIVIDE_RADIUS,
|
||||
BMOP_ESUBDIVIDE_SELACTION,
|
||||
|
||||
BMOP_ESUBDIVIDE_CUSTOMFILL_FACES,
|
||||
BMOP_ESUBDIVIDE_CUSTOMFILL_PATTERNS,
|
||||
|
||||
BMOP_ESUBDIVIDE_PERCENT_VERTS,
|
||||
BMOP_ESUBDIVIDE_PERCENT_VALUES,
|
||||
|
||||
BMOP_ESUBDIVIDE_TOTSLOT,
|
||||
};
|
||||
/*
|
||||
|
@ -38,7 +38,11 @@ BMOpDefine def_subdop = {
|
||||
BMOP_OPSLOT_INT,
|
||||
BMOP_OPSLOT_INT,
|
||||
BMOP_OPSLOT_FLT,
|
||||
BMOP_OPSLOT_INT},
|
||||
BMOP_OPSLOT_INT,
|
||||
BMOP_OPSLOT_PNT_BUF,
|
||||
BMOP_OPSLOT_PNT_BUF,
|
||||
BMOP_OPSLOT_PNT_BUF,
|
||||
BMOP_OPSLOT_FLT},
|
||||
esubdivide_exec,
|
||||
BMOP_ESUBDIVIDE_TOTSLOT,
|
||||
0
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "BLI_arithb.h"
|
||||
#include "BLI_rand.h"
|
||||
#include "BLI_ghash.h"
|
||||
|
||||
#include "DNA_object_types.h"
|
||||
|
||||
@ -11,6 +12,7 @@
|
||||
|
||||
#include "bmesh.h"
|
||||
#include "mesh_intern.h"
|
||||
#include "subdivideop.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -18,8 +20,11 @@
|
||||
#include <math.h>
|
||||
|
||||
#define SUBD_SPLIT 1
|
||||
#define FACE_NEW 1
|
||||
#define MAX_FACE 800
|
||||
|
||||
/*I don't think new faces are flagged, currently, but
|
||||
better safe than sorry.*/
|
||||
#define FACE_NEW 2
|
||||
#define FACE_CUSTOMFILL 4
|
||||
|
||||
/*stuff for the flag paramter. note that
|
||||
what used to live in "beauty" and
|
||||
@ -29,26 +34,10 @@
|
||||
collision).*/
|
||||
#define SELTYPE_INNER 128
|
||||
|
||||
|
||||
/*
|
||||
NOTE: beauty has been renamed to flag!
|
||||
*/
|
||||
|
||||
/*
|
||||
note: this is a pattern-based edge subdivider.
|
||||
it tries to match a pattern to edge selections on faces,
|
||||
then executes functions to cut them.
|
||||
*/
|
||||
typedef struct subdpattern {
|
||||
int seledges[20]; //selected edges mask, for splitting
|
||||
|
||||
/*verts starts at the first new vert cut, not the first vert in the
|
||||
face*/
|
||||
void (*connectexec)(BMesh *bm, BMFace *face, BMVert **verts,
|
||||
int numcuts, int flag, float rad);
|
||||
int len; /*total number of verts*/
|
||||
} subdpattern;
|
||||
|
||||
/*generic subdivision rules:
|
||||
|
||||
* two selected edges in a face should make a link
|
||||
@ -256,6 +245,7 @@ v4---v3---v2
|
||||
v5---v0---v1
|
||||
|
||||
*/
|
||||
|
||||
static void q_2edge_op_split(BMesh *bm, BMFace *face, BMVert **vlist,
|
||||
int numcuts, int flag, float rad) {
|
||||
BMFace *nf;
|
||||
@ -587,19 +577,20 @@ typedef struct subd_facedata {
|
||||
|
||||
void esubdivide_exec(BMesh *bmesh, BMOperator *op)
|
||||
{
|
||||
BMOpSlot *einput;
|
||||
BMEdge *edge, **edges = NULL;
|
||||
V_DECLARE(facedata);
|
||||
V_DECLARE(verts);
|
||||
V_DECLARE(edges);
|
||||
BMOpSlot *einput, *finput, *pinput;
|
||||
BMEdge *edge, **edges = NULL;
|
||||
BMFace *face;
|
||||
BMLoop *nl;
|
||||
BMVert **verts = NULL;
|
||||
V_DECLARE(verts);
|
||||
BMIter fiter, liter;
|
||||
GHash *customfill_hash;
|
||||
subdpattern *pat;
|
||||
float rad;
|
||||
int i, j, matched, a, b, numcuts, flag, selaction;
|
||||
subd_facedata *facedata = NULL;
|
||||
V_DECLARE(facedata);
|
||||
float rad;
|
||||
int i, j, matched, a, b, numcuts, flag, selaction, fillindex;
|
||||
|
||||
BMO_Flag_Buffer(bmesh, op, BMOP_ESUBDIVIDE_EDGES, SUBD_SPLIT);
|
||||
|
||||
@ -618,12 +609,26 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op)
|
||||
BMO_SetFlag(bmesh, edge, SUBD_SPLIT);
|
||||
}
|
||||
|
||||
customfill_hash = BLI_ghash_new(BLI_ghashutil_ptrhash,
|
||||
BLI_ghashutil_ptrcmp);
|
||||
|
||||
/*process custom fill patterns*/
|
||||
finput = BMO_GetSlot(op, BMOP_ESUBDIVIDE_CUSTOMFILL_FACES);
|
||||
pinput = BMO_GetSlot(op, BMOP_ESUBDIVIDE_CUSTOMFILL_PATTERNS);
|
||||
for (i=0; i<finput->len; i++) {
|
||||
face = ((BMFace**)finput->data.p)[i];
|
||||
BMO_SetFlag(bmesh, face, FACE_CUSTOMFILL);
|
||||
BLI_ghash_insert(customfill_hash, face,
|
||||
((void**)pinput->data.p)[i]);
|
||||
}
|
||||
|
||||
for (face=BMIter_New(&fiter, bmesh, BM_FACES, NULL);
|
||||
face; face=BMIter_Step(&fiter)) {
|
||||
/*figure out which pattern to use*/
|
||||
i = 0;
|
||||
|
||||
V_RESET(edges);
|
||||
V_RESET(verts);
|
||||
i = 0;
|
||||
for (nl=BMIter_New(&liter, bmesh, BM_LOOPS_OF_FACE, face);
|
||||
nl; nl=BMIter_Step(&liter)) {
|
||||
V_GROW(edges);
|
||||
@ -633,6 +638,35 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op)
|
||||
i++;
|
||||
}
|
||||
|
||||
if (BMO_TestFlag(bmesh, face, FACE_CUSTOMFILL)) {
|
||||
pat = BLI_ghash_lookup(customfill_hash, face);
|
||||
for (i=0; i<pat->len; i++) {
|
||||
matched = 1;
|
||||
for (j=0; j<pat->len; j++) {
|
||||
a = (j + i) % pat->len;
|
||||
if ((!!BMO_TestFlag(bmesh, edges[a], SUBD_SPLIT))
|
||||
!= (!!pat->seledges[j])) {
|
||||
matched = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (matched) {
|
||||
V_GROW(facedata);
|
||||
b = V_COUNT(facedata)-1;
|
||||
facedata[b].pat = pat;
|
||||
facedata[b].start = verts[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!matched) {
|
||||
/*if no match, append null element to array.*/
|
||||
V_GROW(facedata);
|
||||
}
|
||||
|
||||
/*obvously don't test for other patterns matching*/
|
||||
continue;
|
||||
}
|
||||
|
||||
for (i=0; i<PLEN; i++) {
|
||||
pat = patterns[i];
|
||||
if (pat->len == face->len) {
|
||||
@ -677,7 +711,7 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op)
|
||||
/*figure out which pattern to use*/
|
||||
V_RESET(verts);
|
||||
if (BMO_TestFlag(bmesh, face, SUBD_SPLIT) == 0) continue;
|
||||
|
||||
|
||||
pat = facedata[i].pat;
|
||||
if (!pat) continue;
|
||||
|
||||
|
@ -29,6 +29,6 @@
|
||||
# Bounces make to subdirectories.
|
||||
|
||||
SOURCEDIR = source/blender/editors
|
||||
DIRS = armature mesh animation object sculpt datafiles transform screen curve gpencil physics preview uvedit space_outliner space_time space_view3d interface util space_api space_ipo space_image space_node space_buttons space_info space_file space_sound space_action space_nla space_script space_text space_sequencer
|
||||
DIRS = armature mesh animation object sculpt datafiles transform screen curve gpencil physics preview uvedit space_outliner space_time space_view3d interface util space_api space_graph space_image space_node space_buttons space_info space_file space_sound space_action space_nla space_script space_text space_sequencer
|
||||
|
||||
include nan_subdirs.mk
|
||||
|
@ -18,7 +18,7 @@ SConscript(['datafiles/SConscript',
|
||||
'space_file/SConscript',
|
||||
'space_image/SConscript',
|
||||
'space_info/SConscript',
|
||||
'space_ipo/SConscript',
|
||||
'space_graph/SConscript',
|
||||
'space_node/SConscript',
|
||||
'space_outliner/SConscript',
|
||||
'space_time/SConscript',
|
||||
|
@ -35,21 +35,14 @@
|
||||
#include "DNA_armature_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_texture_types.h"
|
||||
#include "DNA_view3d_types.h"
|
||||
#include "DNA_windowmanager_types.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_node.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
@ -62,22 +55,7 @@
|
||||
#include "WM_types.h"
|
||||
|
||||
/* ***************** depsgraph calls and anim updates ************* */
|
||||
|
||||
static unsigned int screen_view3d_layers(bScreen *screen)
|
||||
{
|
||||
if(screen) {
|
||||
unsigned int layer= screen->scene->lay; /* as minimum this */
|
||||
ScrArea *sa;
|
||||
|
||||
/* get all used view3d layers */
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
if(sa->spacetype==SPACE_VIEW3D)
|
||||
layer |= ((View3D *)sa->spacedata.first)->lay;
|
||||
}
|
||||
return layer;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* ***************** only these can be called from editors ******** */
|
||||
|
||||
/* generic update flush, reads from context Screen (layers) and scene */
|
||||
/* this is for compliancy, later it can do all windows etc */
|
||||
@ -86,7 +64,7 @@ void ED_anim_dag_flush_update(const bContext *C)
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
bScreen *screen= CTX_wm_screen(C);
|
||||
|
||||
DAG_scene_flush_update(scene, screen_view3d_layers(screen), 0);
|
||||
DAG_scene_flush_update(scene, ED_screen_view3d_layers(screen), 0);
|
||||
}
|
||||
|
||||
/* flushes changes from object to all relations in scene */
|
||||
@ -95,46 +73,10 @@ void ED_anim_object_flush_update(const bContext *C, Object *ob)
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
bScreen *screen= CTX_wm_screen(C);
|
||||
|
||||
DAG_object_update_flags(scene, ob, screen_view3d_layers(screen));
|
||||
DAG_object_update_flags(scene, ob, ED_screen_view3d_layers(screen));
|
||||
}
|
||||
|
||||
|
||||
/* results in fully updated anim system */
|
||||
/* in future sound should be on WM level, only 1 sound can play! */
|
||||
void ED_update_for_newframe(const bContext *C, int mute)
|
||||
{
|
||||
bScreen *screen= CTX_wm_screen(C);
|
||||
Scene *scene= screen->scene;
|
||||
|
||||
//extern void audiostream_scrub(unsigned int frame); /* seqaudio.c */
|
||||
|
||||
/* this function applies the changes too */
|
||||
/* XXX future: do all windows */
|
||||
scene_update_for_newframe(scene, screen_view3d_layers(screen)); /* BKE_scene.h */
|
||||
|
||||
//if ( (CFRA>1) && (!mute) && (scene->audio.flag & AUDIO_SCRUB))
|
||||
// audiostream_scrub( CFRA );
|
||||
|
||||
/* 3d window, preview */
|
||||
//BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
|
||||
|
||||
/* all movie/sequence images */
|
||||
//BIF_image_update_frame();
|
||||
|
||||
/* composite */
|
||||
if(scene->use_nodes && scene->nodetree)
|
||||
ntreeCompositTagAnimated(scene->nodetree);
|
||||
|
||||
/* update animated texture nodes */
|
||||
{
|
||||
Tex *tex;
|
||||
for(tex= G.main->tex.first; tex; tex= tex->id.next)
|
||||
if( tex->use_nodes && tex->nodetree ) {
|
||||
ntreeTexTagAnimated( tex->nodetree );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* **************************** animation tool notifiers ******************************** */
|
||||
|
||||
/* Send notifiers on behalf of animation editing tools, based on various context info
|
||||
@ -153,10 +95,10 @@ void ANIM_animdata_send_notifiers (bContext *C, bAnimContext *ac, short data_cha
|
||||
case ANIM_CHANGED_KEYFRAMES_VALUES:
|
||||
/* keyframe values changed, so transform may have changed */
|
||||
// XXX what about other cases? maybe we need general ND_KEYFRAMES or ND_ANIMATION?
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS|ND_TRANSFORM, NULL);
|
||||
break;
|
||||
case ANIM_CHANGED_KEYFRAMES_SELECT: // XXX what to do here?
|
||||
WM_event_add_notifier(C, NC_SCENE, NULL);
|
||||
case ANIM_CHANGED_KEYFRAMES_SELECT:
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL);
|
||||
break;
|
||||
case ANIM_CHANGED_CHANNELS:
|
||||
// XXX err... check available datatypes in dopesheet first?
|
||||
@ -175,8 +117,24 @@ void ANIM_animdata_send_notifiers (bContext *C, bAnimContext *ac, short data_cha
|
||||
{
|
||||
Object *obact= CTX_data_active_object(C);
|
||||
|
||||
// only update active object for now... more detail to come!
|
||||
WM_event_add_notifier(C, NC_OBJECT, obact);
|
||||
switch (data_changed) {
|
||||
case ANIM_CHANGED_KEYFRAMES_VALUES:
|
||||
/* keyframe values changed, so transform may have changed */
|
||||
// XXX what about other cases? maybe we need general ND_KEYFRAMES or ND_ANIMATION?
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS|ND_TRANSFORM, obact);
|
||||
break;
|
||||
case ANIM_CHANGED_KEYFRAMES_SELECT:
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obact);
|
||||
break;
|
||||
case ANIM_CHANGED_CHANNELS:
|
||||
// XXX err... check available datatypes in dopesheet first?
|
||||
// FIXME: this currently doesn't work (to update own view)
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE|ND_BONE_SELECT, obact);
|
||||
break;
|
||||
}
|
||||
|
||||
// XXX for now, at least update own editor!
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -33,11 +33,15 @@ struct wmOperatorType;
|
||||
|
||||
/* editarmature.c */
|
||||
void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep);
|
||||
EditBone *armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo);
|
||||
|
||||
void ARMATURE_OT_align_bones(struct wmOperatorType *ot);
|
||||
void ARMATURE_OT_calculate_roll(struct wmOperatorType *ot);
|
||||
|
||||
void POSE_OT_hide(struct wmOperatorType *ot);
|
||||
void POSE_OT_reveil(struct wmOperatorType *ot);
|
||||
|
||||
void POSE_OT_rot_clear(struct wmOperatorType *ot);
|
||||
void POSE_OT_loc_clear(struct wmOperatorType *ot);
|
||||
void POSE_OT_scale_clear(struct wmOperatorType *ot);
|
||||
|
||||
#endif /* ED_ARMATURE_INTERN_H */
|
||||
|
||||
|
@ -58,24 +58,83 @@
|
||||
|
||||
#include "armature_intern.h"
|
||||
|
||||
/* ************************** quick tests **********************************/
|
||||
|
||||
/* XXX This is a quick test operator to print names of all EditBones in context
|
||||
* that should be removed once tool coding starts...
|
||||
*/
|
||||
|
||||
static int armature_test_exec (bContext *C, wmOperator *op)
|
||||
{
|
||||
printf("EditMode Armature Test: \n");
|
||||
|
||||
printf("\tSelected Bones \n");
|
||||
CTX_DATA_BEGIN(C, EditBone*, ebone, selected_bones)
|
||||
{
|
||||
printf("\t\tEditBone '%s' \n", ebone->name);
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
printf("\tEditable Bones \n");
|
||||
CTX_DATA_BEGIN(C, EditBone*, ebone, selected_editable_bones)
|
||||
{
|
||||
printf("\t\tEditBone '%s' \n", ebone->name);
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
printf("\tActive Bone \n");
|
||||
{
|
||||
EditBone *ebone= CTX_data_active_bone(C);
|
||||
if (ebone) printf("\t\tEditBone '%s' \n", ebone->name);
|
||||
else printf("\t\t<None> \n");
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ARMATURE_OT_test(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Test Context";
|
||||
ot->idname= "ARMATURE_OT_test";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= armature_test_exec;
|
||||
}
|
||||
|
||||
/* ************************** registration **********************************/
|
||||
|
||||
/* Both operators ARMATURE_OT_xxx and POSE_OT_xxx here */
|
||||
void ED_operatortypes_armature(void)
|
||||
{
|
||||
WM_operatortype_append(ARMATURE_OT_align_bones);
|
||||
WM_operatortype_append(ARMATURE_OT_calculate_roll);
|
||||
|
||||
WM_operatortype_append(POSE_OT_hide);
|
||||
WM_operatortype_append(POSE_OT_reveil);
|
||||
WM_operatortype_append(POSE_OT_rot_clear);
|
||||
WM_operatortype_append(POSE_OT_loc_clear);
|
||||
WM_operatortype_append(POSE_OT_scale_clear);
|
||||
|
||||
WM_operatortype_append(ARMATURE_OT_test); // XXX temp test for context iterators... to be removed
|
||||
}
|
||||
|
||||
void ED_keymap_armature(wmWindowManager *wm)
|
||||
{
|
||||
ListBase *keymap= WM_keymap_listbase(wm, "Armature", 0, 0);
|
||||
ListBase *keymap;
|
||||
wmKeymapItem *kmi;
|
||||
|
||||
/* Armature ------------------------ */
|
||||
keymap= WM_keymap_listbase(wm, "Armature", 0, 0);
|
||||
|
||||
/* only set in editmode armature, by space_view3d listener */
|
||||
// WM_keymap_add_item(keymap, "ARMATURE_OT_hide", HKEY, KM_PRESS, 0, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_align_bones", AKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_calculate_roll", NKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_test", TKEY, KM_PRESS, 0, 0); // XXX temp test for context iterators... to be removed
|
||||
|
||||
/* Pose ------------------------ */
|
||||
/* only set in posemode, by space_view3d listener */
|
||||
keymap= WM_keymap_listbase(wm, "Pose", 0, 0);
|
||||
|
||||
@ -83,6 +142,9 @@ void ED_keymap_armature(wmWindowManager *wm)
|
||||
kmi= WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "invert", 1);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_reveil", HKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
/*clear pose*/
|
||||
WM_keymap_add_item(keymap, "POSE_OT_rot_clear", RKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_loc_clear", GKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0);
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_subsurf.h"
|
||||
#include "BKE_utildefines.h"
|
||||
#include "BKE_modifier.h"
|
||||
@ -102,7 +103,6 @@ static void error() {};
|
||||
static void error_libdata() {}
|
||||
static void BIF_undo_push() {}
|
||||
static void adduplicate() {}
|
||||
static void countall() {}
|
||||
/* ************* XXX *************** */
|
||||
|
||||
/* **************** tools on Editmode Armature **************** */
|
||||
@ -113,12 +113,13 @@ static void armature_sync_selection(ListBase *edbo)
|
||||
EditBone *ebo;
|
||||
|
||||
for (ebo=edbo->first; ebo; ebo= ebo->next) {
|
||||
if ((ebo->flag & BONE_CONNECTED) && ebo->parent){
|
||||
if ((ebo->flag & BONE_CONNECTED) && (ebo->parent)) {
|
||||
if (ebo->parent->flag & BONE_TIPSEL)
|
||||
ebo->flag |= BONE_ROOTSEL;
|
||||
else
|
||||
ebo->flag &= ~BONE_ROOTSEL;
|
||||
}
|
||||
|
||||
if ((ebo->flag & BONE_TIPSEL) && (ebo->flag & BONE_ROOTSEL))
|
||||
ebo->flag |= BONE_SELECTED;
|
||||
else
|
||||
@ -1038,8 +1039,6 @@ void separate_armature (Scene *scene, View3D *v3d)
|
||||
|
||||
/* recalc/redraw + cleanup */
|
||||
waitcursor(0);
|
||||
|
||||
countall(); // flush!
|
||||
|
||||
BIF_undo_push("Separate Armature");
|
||||
}
|
||||
@ -1247,7 +1246,7 @@ void armature_select_hierarchy(Scene *scene, short direction, short add_to_sel)
|
||||
}
|
||||
}
|
||||
|
||||
countall(); // flushes selection!
|
||||
armature_sync_selection(arm->edbo);
|
||||
|
||||
if (direction==BONE_SELECT_PARENT)
|
||||
BIF_undo_push("Select edit bone parent");
|
||||
@ -1380,7 +1379,8 @@ void selectconnected_posearmature(bContext *C)
|
||||
selectconnected_posebonechildren (ob, curBone);
|
||||
}
|
||||
|
||||
countall(); // flushes selection!
|
||||
// XXX this only counted the number of pose channels selected
|
||||
//countall(); // flushes selection!
|
||||
|
||||
BIF_undo_push("Select connected");
|
||||
|
||||
@ -1444,7 +1444,7 @@ void selectconnected_armature(bContext *C)
|
||||
|
||||
}
|
||||
|
||||
countall(); // flushes selection!
|
||||
armature_sync_selection(arm->edbo);
|
||||
|
||||
BIF_undo_push("Select connected");
|
||||
|
||||
@ -1556,11 +1556,14 @@ static void delete_bone(ListBase *edbo, EditBone* exBone)
|
||||
}
|
||||
|
||||
/* context: editmode armature */
|
||||
EditBone *armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo)
|
||||
EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo)
|
||||
{
|
||||
EditBone *eboflip= NULL;
|
||||
char name[32];
|
||||
|
||||
if (ebo == NULL)
|
||||
return NULL;
|
||||
|
||||
BLI_strncpy(name, ebo->name, sizeof(name));
|
||||
bone_flip_name(name, 0); // 0 = don't strip off number extensions
|
||||
|
||||
@ -1589,7 +1592,7 @@ void delete_armature(Scene *scene)
|
||||
for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
|
||||
if (arm->layer & curBone->layer) {
|
||||
if (curBone->flag & BONE_SELECTED) {
|
||||
next = armature_bone_get_mirrored(arm->edbo, curBone);
|
||||
next = ED_armature_bone_get_mirrored(arm->edbo, curBone);
|
||||
if (next)
|
||||
next->flag |= BONE_SELECTED;
|
||||
}
|
||||
@ -1647,16 +1650,16 @@ void delete_armature(Scene *scene)
|
||||
}
|
||||
|
||||
|
||||
countall(); // flushes selection!
|
||||
armature_sync_selection(arm->edbo);
|
||||
|
||||
BIF_undo_push("Delete bone(s)");
|
||||
}
|
||||
|
||||
/* toggle==0: deselect
|
||||
toggle==1: swap (based on test)
|
||||
toggle==2: only active tag
|
||||
toggle==3: swap (no test)
|
||||
*/
|
||||
* toggle==1: swap (based on test)
|
||||
* toggle==2: only active tag
|
||||
* toggle==3: swap (no test)
|
||||
*/
|
||||
void deselectall_armature(Object *obedit, int toggle, int doundo)
|
||||
{
|
||||
bArmature *arm= obedit->data;
|
||||
@ -1704,7 +1707,7 @@ void deselectall_armature(Object *obedit, int toggle, int doundo)
|
||||
}
|
||||
}
|
||||
|
||||
countall(); // flushes selection!
|
||||
armature_sync_selection(arm->edbo);
|
||||
if (doundo) {
|
||||
if (sel==1) BIF_undo_push("Select All");
|
||||
else BIF_undo_push("Deselect All");
|
||||
@ -1844,92 +1847,131 @@ float ED_rollBoneToVector(EditBone *bone, float new_up_axis[3])
|
||||
return roll;
|
||||
}
|
||||
|
||||
/* Sets the roll value of selected bones, depending on the mode
|
||||
* mode == 0: their z-axes point upwards
|
||||
* mode == 1: their z-axes point towards 3d-cursor
|
||||
*/
|
||||
void auto_align_armature(Scene *scene, View3D *v3d, short mode)
|
||||
|
||||
/* Set roll value for given bone -> Z-Axis Point up (original method) */
|
||||
void auto_align_ebone_zaxisup(Scene *scene, View3D *v3d, EditBone *ebone)
|
||||
{
|
||||
float delta[3], curmat[3][3];
|
||||
float xaxis[3]={1.0f, 0.0f, 0.0f}, yaxis[3], zaxis[3]={0.0f, 0.0f, 1.0f};
|
||||
float targetmat[3][3], imat[3][3], diffmat[3][3];
|
||||
|
||||
/* Find the current bone matrix */
|
||||
VecSubf(delta, ebone->tail, ebone->head);
|
||||
vec_roll_to_mat3(delta, 0.0f, curmat);
|
||||
|
||||
/* Make new matrix based on y axis & z-up */
|
||||
VECCOPY(yaxis, curmat[1]);
|
||||
|
||||
Mat3One(targetmat);
|
||||
VECCOPY(targetmat[0], xaxis);
|
||||
VECCOPY(targetmat[1], yaxis);
|
||||
VECCOPY(targetmat[2], zaxis);
|
||||
Mat3Ortho(targetmat);
|
||||
|
||||
/* Find the difference between the two matrices */
|
||||
Mat3Inv(imat, targetmat);
|
||||
Mat3MulMat3(diffmat, imat, curmat);
|
||||
|
||||
// old-method... let's see if using mat3_to_vec_roll is more accurate
|
||||
//ebone->roll = atan2(diffmat[2][0], diffmat[2][2]);
|
||||
mat3_to_vec_roll(diffmat, delta, &ebone->roll);
|
||||
}
|
||||
|
||||
/* Set roll value for given bone -> Z-Axis point towards cursor */
|
||||
void auto_align_ebone_tocursor(Scene *scene, View3D *v3d, EditBone *ebone)
|
||||
{
|
||||
Object *obedit= scene->obedit; // XXX get from context
|
||||
bArmature *arm= obedit->data;
|
||||
EditBone *ebone;
|
||||
EditBone *flipbone = NULL;
|
||||
float delta[3];
|
||||
float curmat[3][3];
|
||||
float *cursor= give_cursor(scene, v3d);
|
||||
float delta[3], curmat[3][3];
|
||||
float mat[4][4], tmat[4][4], imat[4][4];
|
||||
float rmat[4][4], rot[3];
|
||||
float vec[3];
|
||||
|
||||
/* find the current bone matrix as a 4x4 matrix (in Armature Space) */
|
||||
VecSubf(delta, ebone->tail, ebone->head);
|
||||
vec_roll_to_mat3(delta, ebone->roll, curmat);
|
||||
Mat4CpyMat3(mat, curmat);
|
||||
VECCOPY(mat[3], ebone->head);
|
||||
|
||||
/* multiply bone-matrix by object matrix (so that bone-matrix is in WorldSpace) */
|
||||
Mat4MulMat4(tmat, mat, obedit->obmat);
|
||||
Mat4Invert(imat, tmat);
|
||||
|
||||
/* find position of cursor relative to bone */
|
||||
VecMat4MulVecfl(vec, imat, cursor);
|
||||
|
||||
/* check that cursor is in usable position */
|
||||
if ((IS_EQ(vec[0], 0)==0) && (IS_EQ(vec[2], 0)==0)) {
|
||||
/* Compute a rotation matrix around y */
|
||||
rot[1] = atan2(vec[0], vec[2]);
|
||||
rot[0] = rot[2] = 0.0f;
|
||||
EulToMat4(rot, rmat);
|
||||
|
||||
for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
if (EBONE_VISIBLE(arm, ebone)) {
|
||||
if (arm->flag & ARM_MIRROR_EDIT)
|
||||
flipbone = armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
|
||||
if ((ebone->flag & BONE_SELECTED) ||
|
||||
(flipbone && (flipbone->flag & BONE_SELECTED)))
|
||||
{
|
||||
/* specific method used to calculate roll depends on mode */
|
||||
if (mode == 1) {
|
||||
/* Z-Axis point towards cursor */
|
||||
float mat[4][4], tmat[4][4], imat[4][4];
|
||||
float rmat[4][4], rot[3];
|
||||
float vec[3];
|
||||
|
||||
/* find the current bone matrix as a 4x4 matrix (in Armature Space) */
|
||||
VecSubf(delta, ebone->tail, ebone->head);
|
||||
vec_roll_to_mat3(delta, ebone->roll, curmat);
|
||||
Mat4CpyMat3(mat, curmat);
|
||||
VECCOPY(mat[3], ebone->head);
|
||||
|
||||
/* multiply bone-matrix by object matrix (so that bone-matrix is in WorldSpace) */
|
||||
Mat4MulMat4(tmat, mat, obedit->obmat);
|
||||
Mat4Invert(imat, tmat);
|
||||
|
||||
/* find position of cursor relative to bone */
|
||||
VecMat4MulVecfl(vec, imat, cursor);
|
||||
|
||||
/* check that cursor is in usable position */
|
||||
if ((IS_EQ(vec[0], 0)==0) && (IS_EQ(vec[2], 0)==0)) {
|
||||
/* Compute a rotation matrix around y */
|
||||
rot[1] = atan2(vec[0], vec[2]);
|
||||
rot[0] = rot[2] = 0.0f;
|
||||
EulToMat4(rot, rmat);
|
||||
|
||||
/* Multiply the bone matrix by rotation matrix. This should be new bone-matrix */
|
||||
Mat4MulMat4(tmat, rmat, mat);
|
||||
Mat3CpyMat4(curmat, tmat);
|
||||
|
||||
/* Now convert from new bone-matrix, back to a roll value (in radians) */
|
||||
mat3_to_vec_roll(curmat, delta, &ebone->roll);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Z-Axis Point Up */
|
||||
float xaxis[3]={1.0, 0.0, 0.0}, yaxis[3], zaxis[3]={0.0, 0.0, 1.0};
|
||||
float targetmat[3][3], imat[3][3], diffmat[3][3];
|
||||
|
||||
/* Find the current bone matrix */
|
||||
VecSubf(delta, ebone->tail, ebone->head);
|
||||
vec_roll_to_mat3(delta, 0.0, curmat);
|
||||
|
||||
/* Make new matrix based on y axis & z-up */
|
||||
VECCOPY (yaxis, curmat[1]);
|
||||
|
||||
Mat3One(targetmat);
|
||||
VECCOPY (targetmat[0], xaxis);
|
||||
VECCOPY (targetmat[1], yaxis);
|
||||
VECCOPY (targetmat[2], zaxis);
|
||||
Mat3Ortho(targetmat);
|
||||
|
||||
/* Find the difference between the two matrices */
|
||||
Mat3Inv(imat, targetmat);
|
||||
Mat3MulMat3(diffmat, imat, curmat);
|
||||
|
||||
ebone->roll = atan2(diffmat[2][0], diffmat[2][2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Multiply the bone matrix by rotation matrix. This should be new bone-matrix */
|
||||
Mat4MulMat4(tmat, rmat, mat);
|
||||
Mat3CpyMat4(curmat, tmat);
|
||||
|
||||
/* Now convert from new bone-matrix, back to a roll value (in radians) */
|
||||
mat3_to_vec_roll(curmat, delta, &ebone->roll);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static EnumPropertyItem prop_calc_roll_types[] = {
|
||||
{0, "GLOBALUP", "Z-Axis Up", ""},
|
||||
{1, "CURSOR", "Z-Axis to Cursor", ""},
|
||||
{0, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
static int armature_calc_roll_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
View3D *v3d= (View3D *)CTX_wm_space_data(C);
|
||||
Object *ob= CTX_data_edit_object(C);
|
||||
void (*roll_func)(Scene *, View3D *, EditBone *) = NULL;
|
||||
|
||||
/* specific method used to calculate roll depends on mode */
|
||||
switch (RNA_enum_get(op->ptr, "type")) {
|
||||
case 1: /* Z-Axis point towards cursor */
|
||||
roll_func= auto_align_ebone_tocursor;
|
||||
break;
|
||||
default: /* Z-Axis Point Up */
|
||||
roll_func= auto_align_ebone_zaxisup;
|
||||
break;
|
||||
}
|
||||
|
||||
/* recalculate roll on selected bones */
|
||||
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) {
|
||||
/* roll func is a callback which assumes that all is well */
|
||||
roll_func(scene, v3d, ebone);
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ARMATURE_OT_calculate_roll(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Recalculate Roll";
|
||||
ot->idname= "ARMATURE_OT_calculate_roll";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke = WM_menu_invoke;
|
||||
ot->exec = armature_calc_roll_exec;
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_enum(ot->srna, "type", prop_calc_roll_types, 0, "Type", "");
|
||||
}
|
||||
|
||||
/* **************** undo for armatures ************** */
|
||||
|
||||
static void undoBones_to_editBones(void *lbuv, void *lbev)
|
||||
@ -2023,14 +2065,14 @@ static EditBone *add_editbone(Object *obedit, char *name)
|
||||
BLI_addtail(arm->edbo, bone);
|
||||
|
||||
bone->flag |= BONE_TIPSEL;
|
||||
bone->weight= 1.0F;
|
||||
bone->dist= 0.25F;
|
||||
bone->xwidth= 0.1;
|
||||
bone->zwidth= 0.1;
|
||||
bone->ease1= 1.0;
|
||||
bone->ease2= 1.0;
|
||||
bone->rad_head= 0.10;
|
||||
bone->rad_tail= 0.05;
|
||||
bone->weight= 1.0f;
|
||||
bone->dist= 0.25f;
|
||||
bone->xwidth= 0.1f;
|
||||
bone->zwidth= 0.1f;
|
||||
bone->ease1= 1.0f;
|
||||
bone->ease2= 1.0f;
|
||||
bone->rad_head= 0.10f;
|
||||
bone->rad_tail= 0.05f;
|
||||
bone->segments= 1;
|
||||
bone->layer= arm->layer;
|
||||
|
||||
@ -2100,7 +2142,7 @@ void add_primitiveArmature(Scene *scene, View3D *v3d, int type)
|
||||
/* no primitive support yet */
|
||||
add_primitive_bone(scene, v3d, rv3d, newob);
|
||||
|
||||
countall(); // flushes selection!
|
||||
//armature_sync_selection(arm->edbo); // XXX which armature?
|
||||
|
||||
if ((newob) && !(U.flag & USER_ADD_EDITMODE)) {
|
||||
ED_armature_from_edit(scene, obedit);
|
||||
@ -2145,7 +2187,7 @@ void addvert_armature(Scene *scene, View3D *v3d)
|
||||
/* we re-use code for mirror editing... */
|
||||
flipbone= NULL;
|
||||
if (arm->flag & ARM_MIRROR_EDIT)
|
||||
flipbone= armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
flipbone= ED_armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
|
||||
for (a=0; a<2; a++) {
|
||||
if (a==1) {
|
||||
@ -2188,7 +2230,7 @@ void addvert_armature(Scene *scene, View3D *v3d)
|
||||
|
||||
}
|
||||
|
||||
countall();
|
||||
armature_sync_selection(arm->edbo);
|
||||
|
||||
BIF_undo_push("Add Bone");
|
||||
}
|
||||
@ -2279,14 +2321,14 @@ void adduplicate_armature(Scene *scene)
|
||||
EditBone *curBone;
|
||||
EditBone *firstDup=NULL; /* The beginning of the duplicated bones in the edbo list */
|
||||
|
||||
countall(); // flushes selection!
|
||||
armature_sync_selection(arm->edbo); // XXX why is this needed?
|
||||
|
||||
/* Select mirrored bones */
|
||||
if (arm->flag & ARM_MIRROR_EDIT) {
|
||||
for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
|
||||
if (EBONE_VISIBLE(arm, curBone)) {
|
||||
if (curBone->flag & BONE_SELECTED) {
|
||||
eBone = armature_bone_get_mirrored(arm->edbo, curBone);
|
||||
eBone = ED_armature_bone_get_mirrored(arm->edbo, curBone);
|
||||
if (eBone)
|
||||
eBone->flag |= BONE_SELECTED;
|
||||
}
|
||||
@ -2795,7 +2837,7 @@ void merge_armature(Scene *scene)
|
||||
}
|
||||
|
||||
/* undo + updates */
|
||||
countall();
|
||||
armature_sync_selection(arm->edbo);
|
||||
BIF_undo_push("Merge Bones");
|
||||
}
|
||||
|
||||
@ -2817,7 +2859,7 @@ void hide_selected_armature_bones(Scene *scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
countall();
|
||||
armature_sync_selection(arm->edbo);
|
||||
BIF_undo_push("Hide Bones");
|
||||
}
|
||||
|
||||
@ -2837,7 +2879,7 @@ void hide_unselected_armature_bones(Scene *scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
countall();
|
||||
armature_sync_selection(arm->edbo);
|
||||
BIF_undo_push("Hide Unselected Bones");
|
||||
}
|
||||
|
||||
@ -2855,7 +2897,7 @@ void show_all_armature_bones(Scene *scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
countall();
|
||||
armature_sync_selection(arm->edbo);
|
||||
BIF_undo_push("Reveal Bones");
|
||||
}
|
||||
|
||||
@ -2966,7 +3008,7 @@ void make_bone_parent(Scene *scene)
|
||||
bone_connect_to_existing_parent(actbone);
|
||||
|
||||
if (arm->flag & ARM_MIRROR_EDIT) {
|
||||
flipbone = armature_bone_get_mirrored(arm->edbo, actbone);
|
||||
flipbone = ED_armature_bone_get_mirrored(arm->edbo, actbone);
|
||||
if (flipbone)
|
||||
bone_connect_to_existing_parent(flipbone);
|
||||
}
|
||||
@ -2986,8 +3028,8 @@ void make_bone_parent(Scene *scene)
|
||||
* - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
|
||||
* then just use actbone. Useful when doing upper arm to spine.
|
||||
*/
|
||||
flipbone = armature_bone_get_mirrored(arm->edbo, selbone);
|
||||
flippar = armature_bone_get_mirrored(arm->edbo, actbone);
|
||||
flipbone = ED_armature_bone_get_mirrored(arm->edbo, selbone);
|
||||
flippar = ED_armature_bone_get_mirrored(arm->edbo, actbone);
|
||||
|
||||
if (flipbone) {
|
||||
if (flippar)
|
||||
@ -3001,7 +3043,7 @@ void make_bone_parent(Scene *scene)
|
||||
}
|
||||
}
|
||||
|
||||
countall(); /* checks selection */
|
||||
armature_sync_selection(arm->edbo);
|
||||
BIF_undo_push("Make Parent");
|
||||
|
||||
return;
|
||||
@ -3033,7 +3075,7 @@ void clear_bone_parent(Scene *scene)
|
||||
if (EBONE_VISIBLE(arm, ebone)) {
|
||||
if (ebone->flag & BONE_SELECTED) {
|
||||
if (arm->flag & ARM_MIRROR_EDIT)
|
||||
flipbone = armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
|
||||
if (flipbone)
|
||||
editbone_clear_parent(flipbone, val);
|
||||
@ -3042,7 +3084,7 @@ void clear_bone_parent(Scene *scene)
|
||||
}
|
||||
}
|
||||
|
||||
countall(); // checks selection
|
||||
armature_sync_selection(arm->edbo);
|
||||
BIF_undo_push("Clear Parent");
|
||||
}
|
||||
|
||||
@ -3085,7 +3127,7 @@ void extrude_armature(Scene *scene, int forked)
|
||||
/* we re-use code for mirror editing... */
|
||||
flipbone= NULL;
|
||||
if (arm->flag & ARM_MIRROR_EDIT) {
|
||||
flipbone= armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
flipbone= ED_armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
if (flipbone) {
|
||||
forked= 0; // we extrude 2 different bones
|
||||
if (flipbone->flag & (BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED))
|
||||
@ -3169,7 +3211,7 @@ void extrude_armature(Scene *scene, int forked)
|
||||
if (totbone==1 && first) first->flag |= BONE_ACTIVE;
|
||||
|
||||
/* Transform the endpoints */
|
||||
countall(); // flushes selection!
|
||||
armature_sync_selection(arm->edbo);
|
||||
// XXX BIF_TransformSetUndo("Extrude");
|
||||
// initTransform(TFM_TRANSLATION, CTX_NO_PET);
|
||||
// Transform();
|
||||
@ -3203,7 +3245,7 @@ void subdivide_armature(Scene *scene, int numcuts)
|
||||
/* try to find mirrored bone on a != 0 */
|
||||
if (a) {
|
||||
if (arm->flag & ARM_MIRROR_EDIT)
|
||||
ebone= armature_bone_get_mirrored(arm->edbo, mbone);
|
||||
ebone= ED_armature_bone_get_mirrored(arm->edbo, mbone);
|
||||
else
|
||||
ebone= NULL;
|
||||
}
|
||||
@ -3326,7 +3368,7 @@ void switch_direction_armature (Scene *scene)
|
||||
BIF_undo_push("Switch Direction");
|
||||
}
|
||||
|
||||
/* editbone alignment */
|
||||
/* ***************** EditBone Alignment ********************* */
|
||||
|
||||
/* helper to fix a ebone position if its parent has moved due to alignment*/
|
||||
static void fix_connected_bone(EditBone *ebone)
|
||||
@ -3378,159 +3420,85 @@ static void bone_align_to_bone(ListBase *edbo, EditBone *selbone, EditBone *actb
|
||||
return;
|
||||
}
|
||||
|
||||
void align_selected_bones(Scene *scene)
|
||||
static int armature_align_bones_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= scene->obedit; // XXX get from context
|
||||
bArmature *arm= obedit->data;
|
||||
EditBone *actbone, *ebone, *selbone;
|
||||
EditBone *flipbone, *flippar;
|
||||
short allchildbones= 0, foundselbone= 0;
|
||||
Object *ob= CTX_data_edit_object(C);
|
||||
bArmature *arm= (bArmature *)ob->data;
|
||||
EditBone *actbone= CTX_data_active_bone(C);
|
||||
EditBone *actmirb= NULL;
|
||||
|
||||
/* find active bone to align to */
|
||||
for (actbone = arm->edbo->first; actbone; actbone=actbone->next) {
|
||||
if (arm->layer & actbone->layer) {
|
||||
if (actbone->flag & BONE_ACTIVE)
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* there must be an active bone */
|
||||
if (actbone == NULL) {
|
||||
error("Needs an active bone");
|
||||
return;
|
||||
BKE_report(op->reports, RPT_ERROR, "Operation requires an Active Bone");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
/* find selected bones */
|
||||
for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
if (arm->layer & ebone->layer) {
|
||||
if ((ebone->flag & BONE_SELECTED) && (ebone != actbone)) {
|
||||
foundselbone++;
|
||||
if (ebone->parent != actbone) allchildbones= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* abort if no selected bones, and active bone doesn't have a parent to work with instead */
|
||||
if (foundselbone==0 && actbone->parent==NULL) {
|
||||
error("Need selected bone(s)");
|
||||
return;
|
||||
else if (arm->flag & ARM_MIRROR_EDIT) {
|
||||
/* For X-Axis Mirror Editing option, we may need a mirror copy of actbone
|
||||
* - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone
|
||||
* (i.e. selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R").
|
||||
* This is useful for arm-chains, for example parenting lower arm to upper arm
|
||||
* - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
|
||||
* then just use actbone. Useful when doing upper arm to spine.
|
||||
*/
|
||||
actmirb= ED_armature_bone_get_mirrored(arm->edbo, actbone);
|
||||
if (actmirb == NULL)
|
||||
actmirb= actbone;
|
||||
}
|
||||
|
||||
if (foundselbone==0 && actbone->parent) {
|
||||
/* if there is only 1 selected bone, we assume that that is the active bone,
|
||||
* since a user will need to have clicked on a bone (thus selecting it) to make it active
|
||||
*/
|
||||
if (CTX_DATA_COUNT(C, selected_editable_bones) <= 1) {
|
||||
/* When only the active bone is selected, and it has a parent,
|
||||
* align it to the parent, as that is the only possible outcome.
|
||||
*/
|
||||
bone_align_to_bone(arm->edbo, actbone, actbone->parent);
|
||||
|
||||
if (arm->flag & ARM_MIRROR_EDIT) {
|
||||
flipbone = armature_bone_get_mirrored(arm->edbo, actbone);
|
||||
if (flipbone)
|
||||
bone_align_to_bone(arm->edbo, flipbone, flipbone->parent);
|
||||
if (actbone->parent) {
|
||||
bone_align_to_bone(arm->edbo, actbone, actbone->parent);
|
||||
|
||||
if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent))
|
||||
bone_align_to_bone(arm->edbo, actmirb, actmirb->parent);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* loop through all editbones, aligning all selected bones to the active bone */
|
||||
for (selbone = arm->edbo->first; selbone; selbone=selbone->next) {
|
||||
if (arm->layer & selbone->layer) {
|
||||
if ((selbone->flag & BONE_SELECTED) && (selbone!=actbone)) {
|
||||
/* align selbone to actbone */
|
||||
bone_align_to_bone(arm->edbo, selbone, actbone);
|
||||
|
||||
if (arm->flag & ARM_MIRROR_EDIT) {
|
||||
/* - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone
|
||||
* (i.e. selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R").
|
||||
* This is useful for arm-chains, for example parenting lower arm to upper arm
|
||||
* - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
|
||||
* then just use actbone. Useful when doing upper arm to spine.
|
||||
*/
|
||||
flipbone = armature_bone_get_mirrored(arm->edbo, selbone);
|
||||
flippar = armature_bone_get_mirrored(arm->edbo, actbone);
|
||||
|
||||
if (flipbone) {
|
||||
if (flippar)
|
||||
bone_align_to_bone(arm->edbo, flipbone, flippar);
|
||||
else
|
||||
bone_align_to_bone(arm->edbo, flipbone, actbone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Align 'selected' bones to the active one
|
||||
* - the context iterator contains both selected bones and their mirrored copies,
|
||||
* so we assume that unselected bones are mirrored copies of some selected bone
|
||||
*/
|
||||
|
||||
/* align selected bones to the active one */
|
||||
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) {
|
||||
if (ebone->flag & BONE_SELECTED)
|
||||
bone_align_to_bone(arm->edbo, ebone, actbone);
|
||||
else
|
||||
bone_align_to_bone(arm->edbo, ebone, actmirb);
|
||||
}
|
||||
CTX_DATA_END;
|
||||
}
|
||||
|
||||
|
||||
countall(); /* checks selection */
|
||||
BIF_undo_push("Align bones");
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
return;
|
||||
void ARMATURE_OT_align_bones(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Align Bones";
|
||||
ot->idname= "ARMATURE_OT_align_bones";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke = WM_operator_confirm;
|
||||
ot->exec = armature_align_bones_exec;
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ***************** Pose tools ********************* */
|
||||
|
||||
void clear_armature(Scene *scene, Object *ob, char mode)
|
||||
{
|
||||
bPoseChannel *pchan;
|
||||
bArmature *arm= ob->data;
|
||||
|
||||
/* only clear those channels that are not locked */
|
||||
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
if (pchan->bone && (pchan->bone->flag & BONE_SELECTED)) {
|
||||
if (arm->layer & pchan->bone->layer) {
|
||||
switch (mode) {
|
||||
case 'r':
|
||||
if (pchan->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ)) {
|
||||
float eul[3], oldeul[3], quat1[4];
|
||||
|
||||
QUATCOPY(quat1, pchan->quat);
|
||||
QuatToEul(pchan->quat, oldeul);
|
||||
eul[0]= eul[1]= eul[2]= 0.0f;
|
||||
|
||||
if (pchan->protectflag & OB_LOCK_ROTX)
|
||||
eul[0]= oldeul[0];
|
||||
if (pchan->protectflag & OB_LOCK_ROTY)
|
||||
eul[1]= oldeul[1];
|
||||
if (pchan->protectflag & OB_LOCK_ROTZ)
|
||||
eul[2]= oldeul[2];
|
||||
|
||||
EulToQuat(eul, pchan->quat);
|
||||
/* quaternions flip w sign to accumulate rotations correctly */
|
||||
if ((quat1[0]<0.0f && pchan->quat[0]>0.0f) || (quat1[0]>0.0f && pchan->quat[0]<0.0f)) {
|
||||
QuatMulf(pchan->quat, -1.0f);
|
||||
}
|
||||
}
|
||||
else {
|
||||
pchan->quat[1]=pchan->quat[2]=pchan->quat[3]=0.0F;
|
||||
pchan->quat[0]=1.0F;
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
if ((pchan->protectflag & OB_LOCK_LOCX)==0)
|
||||
pchan->loc[0]= 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_LOCY)==0)
|
||||
pchan->loc[1]= 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_LOCZ)==0)
|
||||
pchan->loc[2]= 0.0f;
|
||||
break;
|
||||
case 's':
|
||||
if ((pchan->protectflag & OB_LOCK_SCALEX)==0)
|
||||
pchan->size[0]= 1.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_SCALEY)==0)
|
||||
pchan->size[1]= 1.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_SCALEZ)==0)
|
||||
pchan->size[2]= 1.0f;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
/* the current values from IPO's may not be zero, so tag as unkeyed */
|
||||
pchan->bone->flag |= BONE_UNKEYED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
|
||||
/* no update for this object, this will execute the action again */
|
||||
/* is weak... like for ipo editing which uses ctime now... */
|
||||
where_is_pose (scene, ob);
|
||||
ob->recalc= 0;
|
||||
}
|
||||
|
||||
/* helper for function below */
|
||||
static int clear_active_flag(Object *ob, Bone *bone, void *data)
|
||||
{
|
||||
@ -3539,6 +3507,7 @@ static int clear_active_flag(Object *ob, Bone *bone, void *data)
|
||||
}
|
||||
|
||||
|
||||
// XXX bone_looper is only to be used when we want to access settings (i.e. editability/visibility/selected) that context doesn't offer
|
||||
static int bone_looper(Object *ob, Bone *bone, void *data,
|
||||
int (*bone_func)(Object *, Bone *, void *))
|
||||
{
|
||||
@ -3669,7 +3638,7 @@ void ED_pose_deselectall (Object *ob, int test, int doundo)
|
||||
}
|
||||
}
|
||||
|
||||
countall();
|
||||
//countall(); // XXX need an equivalent to this...
|
||||
|
||||
if (doundo) {
|
||||
if (selectmode==1) BIF_undo_push("Select All");
|
||||
@ -4058,7 +4027,167 @@ void create_vgroups_from_armature(Scene *scene, Object *ob, Object *par)
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* ************* Clear Pose *****************************/
|
||||
|
||||
static int pose_clear_scale_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *ob= CTX_data_active_object(C);
|
||||
|
||||
/* only clear those channels that are not locked */
|
||||
CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans) {
|
||||
if ((pchan->protectflag & OB_LOCK_SCALEX)==0)
|
||||
pchan->size[0]= 1.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_SCALEY)==0)
|
||||
pchan->size[1]= 1.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_SCALEZ)==0)
|
||||
pchan->size[2]= 1.0f;
|
||||
|
||||
/* the current values from IPO's may not be zero, so tag as unkeyed */
|
||||
//pchan->bone->flag |= BONE_UNKEYED;
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void POSE_OT_scale_clear(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Clear Pose Scale";
|
||||
ot->idname= "POSE_OT_scale_clear";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke = WM_operator_confirm;
|
||||
ot->exec = pose_clear_scale_exec;
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
static int pose_clear_loc_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *ob= CTX_data_active_object(C);
|
||||
|
||||
/* only clear those channels that are not locked */
|
||||
CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans) {
|
||||
if ((pchan->protectflag & OB_LOCK_LOCX)==0)
|
||||
pchan->loc[0]= 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_LOCY)==0)
|
||||
pchan->loc[1]= 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_LOCZ)==0)
|
||||
pchan->loc[2]= 0.0f;
|
||||
|
||||
/* the current values from IPO's may not be zero, so tag as unkeyed */
|
||||
//pchan->bone->flag |= BONE_UNKEYED;
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void POSE_OT_loc_clear(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Clear Pose Location";
|
||||
ot->idname= "POSE_OT_loc_clear";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke = WM_operator_confirm;
|
||||
ot->exec = pose_clear_loc_exec;
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
static int pose_clear_rot_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *ob= CTX_data_active_object(C);
|
||||
|
||||
/* only clear those channels that are not locked */
|
||||
CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans) {
|
||||
if (pchan->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ)) {
|
||||
float eul[3], oldeul[3], quat1[4];
|
||||
|
||||
if (pchan->rotmode == PCHAN_ROT_QUAT) {
|
||||
QUATCOPY(quat1, pchan->quat);
|
||||
QuatToEul(pchan->quat, oldeul);
|
||||
}
|
||||
else {
|
||||
VECCOPY(oldeul, pchan->eul);
|
||||
}
|
||||
eul[0]= eul[1]= eul[2]= 0.0f;
|
||||
|
||||
if (pchan->protectflag & OB_LOCK_ROTX)
|
||||
eul[0]= oldeul[0];
|
||||
if (pchan->protectflag & OB_LOCK_ROTY)
|
||||
eul[1]= oldeul[1];
|
||||
if (pchan->protectflag & OB_LOCK_ROTZ)
|
||||
eul[2]= oldeul[2];
|
||||
|
||||
if (pchan->rotmode == PCHAN_ROT_QUAT) {
|
||||
EulToQuat(eul, pchan->quat);
|
||||
/* quaternions flip w sign to accumulate rotations correctly */
|
||||
if ((quat1[0]<0.0f && pchan->quat[0]>0.0f) || (quat1[0]>0.0f && pchan->quat[0]<0.0f)) {
|
||||
QuatMulf(pchan->quat, -1.0f);
|
||||
}
|
||||
}
|
||||
else {
|
||||
VECCOPY(pchan->eul, eul);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (pchan->rotmode == PCHAN_ROT_QUAT) {
|
||||
pchan->quat[1]=pchan->quat[2]=pchan->quat[3]= 0.0f;
|
||||
pchan->quat[0]= 1.0f;
|
||||
}
|
||||
else {
|
||||
pchan->eul[0]= pchan->eul[1]= pchan->eul[2]= 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
/* the current values from IPO's may not be zero, so tag as unkeyed */
|
||||
//pchan->bone->flag |= BONE_UNKEYED;
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void POSE_OT_rot_clear(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Clear Pose Rotation";
|
||||
ot->idname= "POSE_OT_rot_clear";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke = WM_operator_confirm;
|
||||
ot->exec = pose_clear_rot_exec;
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
}
|
||||
/* ************* hide/unhide pose bones ******************* */
|
||||
|
||||
static int hide_selected_pose_bone(Object *ob, Bone *bone, void *ptr)
|
||||
@ -4414,7 +4543,7 @@ void transform_armature_mirror_update(Object *obedit)
|
||||
for (ebo= arm->edbo->first; ebo; ebo=ebo->next) {
|
||||
/* no layer check, correct mirror is more important */
|
||||
if (ebo->flag & (BONE_TIPSEL|BONE_ROOTSEL)) {
|
||||
eboflip= armature_bone_get_mirrored(arm->edbo, ebo);
|
||||
eboflip= ED_armature_bone_get_mirrored(arm->edbo, ebo);
|
||||
|
||||
if (eboflip) {
|
||||
/* we assume X-axis flipping for now */
|
||||
|
@ -91,11 +91,10 @@ static void error() {};
|
||||
static void BIF_undo_push() {}
|
||||
static void countall() {}
|
||||
static void add_constraint() {}
|
||||
static void select_actionchannel_by_name() {}
|
||||
static void autokeyframe_pose_cb_func() {}
|
||||
/* ************* XXX *************** */
|
||||
|
||||
|
||||
/* This function is used to indicate that a bone is selected and needs keyframes inserted */
|
||||
void set_pose_keys (Object *ob)
|
||||
{
|
||||
bArmature *arm= ob->data;
|
||||
@ -104,16 +103,15 @@ void set_pose_keys (Object *ob)
|
||||
if (ob->pose){
|
||||
for (chan=ob->pose->chanbase.first; chan; chan=chan->next){
|
||||
Bone *bone= chan->bone;
|
||||
if(bone && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer)) {
|
||||
chan->flag |= POSE_KEY;
|
||||
}
|
||||
else {
|
||||
if ((bone) && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer))
|
||||
chan->flag |= POSE_KEY;
|
||||
else
|
||||
chan->flag &= ~POSE_KEY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* This function is used to process the necessary updates for */
|
||||
void ED_armature_enter_posemode(bContext *C, Base *base)
|
||||
{
|
||||
Object *ob= base->object;
|
||||
@ -472,9 +470,7 @@ void pose_select_hierarchy(Scene *scene, short direction, short add_to_sel)
|
||||
curbone->flag &= ~BONE_ACTIVE;
|
||||
pabone->flag |= (BONE_ACTIVE|BONE_SELECTED);
|
||||
|
||||
// XXX this is evil... this sort of stuff is to be handled in one go as a result of a notifier
|
||||
select_actionchannel_by_name (ob->action, pchan->name, 0);
|
||||
select_actionchannel_by_name (ob->action, pchan->parent->name, 1);
|
||||
// XXX notifiers need to be sent to other editors to update
|
||||
break;
|
||||
}
|
||||
} else { // BONE_SELECT_CHILD
|
||||
@ -488,9 +484,7 @@ void pose_select_hierarchy(Scene *scene, short direction, short add_to_sel)
|
||||
curbone->flag &= ~BONE_ACTIVE;
|
||||
chbone->flag |= (BONE_ACTIVE|BONE_SELECTED);
|
||||
|
||||
// XXX this is evil... this sort of stuff is to be handled in one go as a result of a notifier
|
||||
select_actionchannel_by_name (ob->action, pchan->name, 0);
|
||||
select_actionchannel_by_name (ob->action, pchan->child->name, 1);
|
||||
// XXX notifiers need to be sent to other editors to update
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1339,8 +1333,7 @@ void pose_activate_flipped_bone(Scene *scene)
|
||||
DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA);
|
||||
}
|
||||
|
||||
// XXX this is evil... this sort of stuff is to be handled in one go as a result of a notifier
|
||||
select_actionchannel_by_name(ob->action, name, 1);
|
||||
// XXX notifiers need to be sent to other editors to update
|
||||
|
||||
}
|
||||
}
|
||||
@ -1392,7 +1385,7 @@ void pose_movetolayer(Scene *scene)
|
||||
if (ebo->flag & BONE_SELECTED) {
|
||||
ebo->layer= lay;
|
||||
if (arm->flag & ARM_MIRROR_EDIT) {
|
||||
flipBone = armature_bone_get_mirrored(arm->edbo, ebo);
|
||||
flipBone = ED_armature_bone_get_mirrored(arm->edbo, ebo);
|
||||
if (flipBone)
|
||||
flipBone->layer = lay;
|
||||
}
|
||||
|
@ -66,6 +66,9 @@
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "ED_anim_api.h"
|
||||
#include "ED_keyframes_edit.h"
|
||||
#include "ED_object.h"
|
||||
@ -2759,7 +2762,7 @@ void addsegment_nurb(Scene *scene)
|
||||
|
||||
void mouse_nurb(bContext *C, short mval[2], int extend)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C); // XXX
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
ListBase *editnurb= curve_get_editcurve(obedit);
|
||||
Curve *cu= obedit->data;
|
||||
ViewContext vc;
|
||||
@ -2812,7 +2815,7 @@ void mouse_nurb(bContext *C, short mval[2], int extend)
|
||||
|
||||
}
|
||||
|
||||
// rightmouse_transform();
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
|
||||
if(nu!=get_actNurb(obedit)) {
|
||||
set_actNurb(obedit, nu);
|
||||
|
@ -37,6 +37,7 @@ struct ListBase;
|
||||
struct wmEvent;
|
||||
struct bContext;
|
||||
struct Object;
|
||||
struct uiMenuItem;
|
||||
|
||||
void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *keymap, int spaceid);
|
||||
void transform_operatortypes(void);
|
||||
@ -113,6 +114,7 @@ int BIF_menuselectTransformOrientation(void);
|
||||
void BIF_selectTransformOrientation(struct bContext *C, struct TransformOrientation *ts);
|
||||
void BIF_selectTransformOrientationValue(struct bContext *C, int orientation);
|
||||
|
||||
void BIF_menuTransformOrientation(struct bContext *C, struct uiMenuItem *head, void *arg);
|
||||
char * BIF_menustringTransformOrientation(const struct bContext *C, char *title); /* the returned value was allocated and needs to be freed after use */
|
||||
int BIF_countTransformOrientation(const struct bContext *C);
|
||||
|
||||
|
@ -304,12 +304,10 @@ void ANIM_nla_mapping_apply_fcurve(struct Object *ob, struct FCurve *fcu, short
|
||||
|
||||
/* --------- anim_deps.c, animation updates -------- */
|
||||
|
||||
/* generic update flush, reads from Context screen (layers) and scene */
|
||||
/* generic update flush, does tagged objects only, reads from Context screen (layers) and scene */
|
||||
void ED_anim_dag_flush_update(const struct bContext *C);
|
||||
/* only flush object */
|
||||
void ED_anim_object_flush_update(const struct bContext *C, struct Object *ob);
|
||||
/* flush + do the actual update for all involved objects */
|
||||
void ED_update_for_newframe(const struct bContext *C, int mute);
|
||||
|
||||
/* pose <-> action syncing */
|
||||
void ANIM_action_to_pose_sync(struct Object *ob);
|
||||
|
@ -100,6 +100,7 @@ int ED_do_pose_selectbuffer(struct Scene *scene, struct Base *base, unsigned int
|
||||
void mouse_armature(struct bContext *C, short mval[2], int extend);
|
||||
struct Bone *get_indexed_bone (struct Object *ob, int index);
|
||||
float ED_rollBoneToVector(EditBone *bone, float new_up_axis[3]);
|
||||
EditBone *ED_armature_bone_get_mirrored(struct ListBase *edbo, EditBone *ebo); // XXX this is needed for populating the context iterators
|
||||
|
||||
void transform_armature_mirror_update(struct Object *obedit);
|
||||
void clear_armature(struct Scene *scene, struct Object *ob, char mode);
|
||||
|
@ -29,11 +29,15 @@
|
||||
#define ED_IMAGE_H
|
||||
|
||||
struct SpaceImage;
|
||||
struct bContext;
|
||||
|
||||
/* space_image.c, exported for transform */
|
||||
struct Image *ED_space_image(struct SpaceImage *sima);
|
||||
void ED_space_image_size(struct SpaceImage *sima, int *width, int *height);
|
||||
void ED_space_image_uv_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
|
||||
|
||||
/* image_render.c, export for screen_ops.c, render operator */
|
||||
void ED_space_image_output(struct bContext *C);
|
||||
|
||||
#endif /* ED_IMAGE_H */
|
||||
|
||||
|
@ -112,6 +112,8 @@ void EM_add_data_layer(struct EditMesh *em, struct CustomData *data,
|
||||
void EM_select_edge(struct EditEdge *eed, int sel);
|
||||
void EM_select_face(struct EditFace *efa, int sel);
|
||||
void EM_select_face_fgon(struct EditMesh *em, struct EditFace *efa, int val);
|
||||
void EM_select_swap(struct EditMesh *em);
|
||||
void EM_toggle_select_all(struct EditMesh *em);
|
||||
void EM_selectmode_flush(struct EditMesh *em);
|
||||
void EM_deselect_flush(struct EditMesh *em);
|
||||
void EM_selectmode_set(struct EditMesh *em);
|
||||
|
@ -39,12 +39,14 @@ struct wmNotifier;
|
||||
struct wmEvent;
|
||||
struct bContext;
|
||||
struct SpaceType;
|
||||
struct AreagionType;
|
||||
struct Scene;
|
||||
struct bScreen;
|
||||
struct ARegion;
|
||||
struct uiBlock;
|
||||
struct rcti;
|
||||
|
||||
/* regions */
|
||||
void ED_region_do_listen(ARegion *ar, struct wmNotifier *note);
|
||||
void ED_region_do_listen(struct ARegion *ar, struct wmNotifier *note);
|
||||
void ED_region_do_draw(struct bContext *C, struct ARegion *ar);
|
||||
void ED_region_exit(struct bContext *C, struct ARegion *ar);
|
||||
void ED_region_pixelspace(struct ARegion *ar);
|
||||
@ -78,12 +80,17 @@ void ED_screen_draw(struct wmWindow *win);
|
||||
void ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win);
|
||||
void ED_screen_do_listen(struct wmWindow *win, struct wmNotifier *note);
|
||||
bScreen *ED_screen_duplicate(struct wmWindow *win, struct bScreen *sc);
|
||||
void ED_screen_set(struct bContext *C, struct bScreen *sc);
|
||||
void ED_screen_set_scene(struct bContext *C, struct Scene *scene);
|
||||
void ED_screen_set_subwinactive(struct wmWindow *win, struct wmEvent *event);
|
||||
void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen);
|
||||
void ED_screen_animation_timer(struct bContext *C, int enable);
|
||||
void ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type);
|
||||
int ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type);
|
||||
void ED_screen_full_prevspace(struct bContext *C);
|
||||
|
||||
/* anim */
|
||||
void ED_update_for_newframe(const struct bContext *C, int mute);
|
||||
unsigned int ED_screen_view3d_layers(struct bScreen *screen);
|
||||
|
||||
void ED_operatortypes_screen(void);
|
||||
void ED_keymap_screen(struct wmWindowManager *wm);
|
||||
@ -104,12 +111,14 @@ int ED_operator_buttons_active(struct bContext *C);
|
||||
int ED_operator_node_active(struct bContext *C);
|
||||
int ED_operator_ipo_active(struct bContext *C);
|
||||
int ED_operator_sequencer_active(struct bContext *C);
|
||||
int ED_operator_image_active(struct bContext *C);
|
||||
|
||||
int ED_operator_object_active(struct bContext *C);
|
||||
int ED_operator_editmesh(struct bContext *C);
|
||||
int ED_operator_editarmature(struct bContext *C);
|
||||
int ED_operator_editcurve(struct bContext *C);
|
||||
int ED_operator_uvedit(struct bContext *C);
|
||||
int ED_operator_uvmap(struct bContext *C);
|
||||
int ED_operator_posemode(struct bContext *C);
|
||||
|
||||
|
||||
|
@ -44,6 +44,7 @@ void ED_editors_exit (struct bContext *C);
|
||||
/* undo.c */
|
||||
void ED_undo_push (struct bContext *C, char *str);
|
||||
void ED_undo_push_op (struct bContext *C, struct wmOperator *op);
|
||||
void ED_undo_pop (struct bContext *C);
|
||||
void ED_OT_undo (struct wmOperatorType *ot);
|
||||
void ED_OT_redo (struct wmOperatorType *ot);
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
/* Struct Declarations */
|
||||
|
||||
struct ID;
|
||||
struct Main;
|
||||
struct ListBase;
|
||||
struct ARegion;
|
||||
struct wmWindow;
|
||||
@ -210,11 +211,12 @@ void uiMenuContext(uiMenuItem *head, int opcontext);
|
||||
|
||||
void uiMenuItemVal(uiMenuItem *head, const char *name, int icon, int argval);
|
||||
|
||||
void uiMenuItemEnumO(uiMenuItem *head, char *opname, char *propname, int value);
|
||||
void uiMenuItemBooleanO(uiMenuItem *head, char *opname, char *propname, int value);
|
||||
void uiMenuItemEnumO(uiMenuItem *head, int icon, char *opname, char *propname, int value);
|
||||
void uiMenuItemBooleanO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, int value);
|
||||
void uiMenuItemsEnumO(uiMenuItem *head, char *opname, char *propname);
|
||||
void uiMenuItemFloatO(uiMenuItem *head, const char *name, char *opname, char *propname, float value);
|
||||
void uiMenuItemO(uiMenuItem *head, char *name, int icon);
|
||||
void uiMenuItemIntO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, int value);
|
||||
void uiMenuItemFloatO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, float value);
|
||||
void uiMenuItemO(uiMenuItem *head, int icon, char *opname);
|
||||
|
||||
void uiMenuItemBooleanR(uiMenuItem *head, struct PointerRNA *ptr, char *propname);
|
||||
void uiMenuItemEnumR(uiMenuItem *head, struct PointerRNA *ptr, char *propname, int value);
|
||||
@ -233,11 +235,10 @@ void uiMenuSeparator(uiMenuItem *head);
|
||||
* the uiMenu functions inbetween. If it is a simple confirmation menu
|
||||
* or similar, popups can be created with a single function call. */
|
||||
|
||||
uiMenuItem *uiPupMenuBegin(const char *title);
|
||||
uiMenuItem *uiPupMenuBegin(const char *title, int icon);
|
||||
void uiPupMenuEnd(struct bContext *C, struct uiMenuItem *head);
|
||||
|
||||
void uiPupMenu(struct bContext *C, int maxrow, uiMenuHandleFunc func, void *arg, char *str, ...);
|
||||
void uiPupMenuOperator(struct bContext *C, int maxrow, struct wmOperator *op, const char *propname, char *str);
|
||||
void uiPupMenuOkee(struct bContext *C, char *opname, char *str, ...);
|
||||
void uiPupMenuSaveOver(struct bContext *C, char *opname, char *filename, ...);
|
||||
void uiPupMenuNotice(struct bContext *C, char *str, ...);
|
||||
@ -251,8 +252,10 @@ void uiPupMenuSetActive(int val);
|
||||
* Functions used to create popup blocks. These are like popup menus
|
||||
* but allow using all button types and creating an own layout. */
|
||||
|
||||
uiBlock *uiPupBlockBegin(struct bContext *C, const char *title);
|
||||
void uiPupBlockEnd(struct bContext *C, uiBlock *block);
|
||||
typedef uiBlock* (*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, void *arg1);
|
||||
|
||||
void uiPupBlock(struct bContext *C, uiBlockCreateFunc func, void *arg);
|
||||
void uiPupBlockO(struct bContext *C, uiBlockCreateFunc func, void *arg, char *opname, int opcontext);
|
||||
|
||||
/* Blocks
|
||||
*
|
||||
@ -295,7 +298,8 @@ void uiBlockEndAlign(uiBlock *block);
|
||||
|
||||
void uiBoundsBlock(struct uiBlock *block, int addval);
|
||||
void uiTextBoundsBlock(uiBlock *block, int addval);
|
||||
void uiPopupBoundsBlock(uiBlock *block, int addval);
|
||||
void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my);
|
||||
void uiMenuPopupBoundsBlock(uiBlock *block, int addvall, int mx, int my);
|
||||
|
||||
int uiBlocksGetYMin (ListBase *lb);
|
||||
int uiBlockGetCol (uiBlock *block);
|
||||
@ -389,13 +393,28 @@ struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but);
|
||||
* - PulldownBut: like MenuBut, but creating a uiBlock (for compatibility).
|
||||
* - BlockBut: buttons that popup a block with more buttons.
|
||||
* - KeyevtBut: buttons that can be used to turn key events into values.
|
||||
* - PickerButtons: buttons like the color picker (for code sharing). */
|
||||
* - PickerButtons: buttons like the color picker (for code sharing).
|
||||
* - AutoButR: RNA property button with type automatically defined. */
|
||||
|
||||
typedef uiBlock* (*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, void *arg1);
|
||||
typedef void (*uiIDPoinFuncFP)(struct bContext *C, char *str, struct ID **idpp);
|
||||
#define UI_ID_RENAME 1
|
||||
#define UI_ID_BROWSE 2
|
||||
#define UI_ID_ADD_NEW 4
|
||||
#define UI_ID_OPEN 8
|
||||
#define UI_ID_ALONE 16
|
||||
#define UI_ID_DELETE 32
|
||||
#define UI_ID_LOCAL 64
|
||||
#define UI_ID_AUTO_NAME 128
|
||||
#define UI_ID_FAKE_USER 256
|
||||
#define UI_ID_PIN 512
|
||||
#define UI_ID_BROWSE_RENDER 1024
|
||||
#define UI_ID_FULL (UI_ID_RENAME|UI_ID_BROWSE|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_ALONE|UI_ID_DELETE|UI_ID_LOCAL)
|
||||
|
||||
uiBut *uiDefIDPoinBut(struct uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str,
|
||||
typedef void (*uiIDPoinFuncFP)(struct bContext *C, char *str, struct ID **idpp);
|
||||
typedef void (*uiIDPoinFunc)(struct bContext *C, struct ID *id, int event);
|
||||
|
||||
uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str,
|
||||
short x1, short y1, short x2, short y2, void *idpp, char *tip);
|
||||
int uiDefIDPoinButs(uiBlock *block, struct Main *main, struct ID *parid, struct ID **id_p, int id_code, short *pin_p, int x, int y, uiIDPoinFunc func, int events);
|
||||
|
||||
uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip);
|
||||
uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip);
|
||||
@ -409,6 +428,9 @@ void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1,
|
||||
|
||||
void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval);
|
||||
|
||||
uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, char *name, int x1, int y1, int x2, int y2);
|
||||
int uiDefAutoButsRNA(uiBlock *block, struct PointerRNA *ptr);
|
||||
|
||||
/* Links
|
||||
*
|
||||
* Game engine logic brick links. Non-functional currently in 2.5,
|
||||
@ -428,9 +450,12 @@ uiBut *uiFindInlink(uiBlock *block, void *poin);
|
||||
* uiButSetCompleteFunc is for tab completion.
|
||||
*
|
||||
* uiBlockSetFunc and uiButSetFunc are callbacks run when a button is used,
|
||||
* in case events, operators or RNA are not sufficient to handle the button. */
|
||||
* in case events, operators or RNA are not sufficient to handle the button.
|
||||
*
|
||||
* uiButSetNFunc will free the argument with MEM_freeN. */
|
||||
|
||||
typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2);
|
||||
typedef void (*uiButHandleNFunc)(struct bContext *C, void *argN, void *arg2);
|
||||
typedef void (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg);
|
||||
typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event);
|
||||
|
||||
@ -439,6 +464,7 @@ void uiBlockSetButmFunc (uiBlock *block, uiMenuHandleFunc func, void *arg);
|
||||
|
||||
void uiBlockSetFunc (uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2);
|
||||
void uiButSetFunc (uiBut *but, uiButHandleFunc func, void *arg1, void *arg2);
|
||||
void uiButSetNFunc (uiBut *but, uiButHandleNFunc func, void *argN, void *arg2);
|
||||
|
||||
void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg);
|
||||
|
||||
|
@ -878,6 +878,7 @@ enum {
|
||||
/* specific defines per space should have higher define values */
|
||||
|
||||
struct bTheme;
|
||||
struct PointerRNA;
|
||||
|
||||
// THE CODERS API FOR THEMES:
|
||||
|
||||
@ -919,6 +920,8 @@ void UI_ColorPtrBlendShade3ubv(char *cp1, char *cp2, float fac, int offset);
|
||||
// get a 3 byte color, blended and shaded between two other char color pointers
|
||||
void UI_GetColorPtrBlendShade3ubv(char *cp1, char *cp2, char *col, float fac, int offset);
|
||||
|
||||
// get pointer from RNA pointer
|
||||
int UI_GetIconRNA(struct PointerRNA *ptr);
|
||||
|
||||
struct ScrArea;
|
||||
|
||||
|
@ -304,23 +304,28 @@ void ui_bounds_block(uiBlock *block)
|
||||
block->safety.ymax= block->maxy+xof;
|
||||
}
|
||||
|
||||
static void ui_popup_bounds_block(const bContext *C, uiBlock *block)
|
||||
static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int menu)
|
||||
{
|
||||
wmWindow *window= CTX_wm_window(C);
|
||||
int startx, starty, endx, endy, width, height;
|
||||
int oldbounds, mx, my, xmax, ymax;
|
||||
|
||||
oldbounds= block->bounds;
|
||||
|
||||
/* compute bounds */
|
||||
/* compute mouse position with user defined offset */
|
||||
ui_bounds_block(block);
|
||||
mx= block->minx;
|
||||
my= block->miny;
|
||||
mx= window->eventstate->x + block->minx + block->mx;
|
||||
my= window->eventstate->y + block->miny + block->my;
|
||||
|
||||
wm_window_get_size(CTX_wm_window(C), &xmax, &ymax);
|
||||
wm_window_get_size(window, &xmax, &ymax);
|
||||
|
||||
/* first we ensure wide enough text bounds */
|
||||
block->bounds= 50;
|
||||
ui_text_bounds_block(block, block->minx);
|
||||
if(menu) {
|
||||
if(block->flag & UI_BLOCK_LOOP) {
|
||||
block->bounds= 50;
|
||||
ui_text_bounds_block(block, block->minx);
|
||||
}
|
||||
}
|
||||
|
||||
/* next we recompute bounds */
|
||||
block->bounds= oldbounds;
|
||||
@ -373,11 +378,22 @@ void uiTextBoundsBlock(uiBlock *block, int addval)
|
||||
block->dobounds= 2;
|
||||
}
|
||||
|
||||
/* used for menu popups */
|
||||
void uiPopupBoundsBlock(uiBlock *block, int addval)
|
||||
/* used for block popups */
|
||||
void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my)
|
||||
{
|
||||
block->bounds= addval;
|
||||
block->dobounds= 3;
|
||||
block->mx= mx;
|
||||
block->my= my;
|
||||
}
|
||||
|
||||
/* used for menu popups */
|
||||
void uiMenuPopupBoundsBlock(uiBlock *block, int addval, int mx, int my)
|
||||
{
|
||||
block->bounds= addval;
|
||||
block->dobounds= 4;
|
||||
block->mx= mx;
|
||||
block->my= my;
|
||||
}
|
||||
|
||||
void ui_autofill(uiBlock *block)
|
||||
@ -487,13 +503,14 @@ static int ui_but_equals_old(uiBut *but, uiBut *oldbut)
|
||||
/* various properties are being compared here, hopfully sufficient
|
||||
* to catch all cases, but it is simple to add more checks later */
|
||||
if(but->retval != oldbut->retval) return 0;
|
||||
if(but->poin != oldbut->poin || but->pointype != oldbut->pointype) return 0;
|
||||
if(but->rnapoin.data != oldbut->rnapoin.data) return 0;
|
||||
if(but->rnaprop != oldbut->rnaprop)
|
||||
if(but->rnaindex != oldbut->rnaindex) return 0;
|
||||
if(but->func != oldbut->func) return 0;
|
||||
if(but->funcN != oldbut->funcN) return 0;
|
||||
if(oldbut->func_arg1 != oldbut && but->func_arg1 != oldbut->func_arg1) return 0;
|
||||
if(oldbut->func_arg2 != oldbut && but->func_arg2 != oldbut->func_arg2) return 0;
|
||||
if(!but->funcN && (but->poin != oldbut->poin || but->pointype != oldbut->pointype)) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -594,7 +611,7 @@ void uiEndBlock(const bContext *C, uiBlock *block)
|
||||
/* after keymaps! */
|
||||
if(block->dobounds == 1) ui_bounds_block(block);
|
||||
else if(block->dobounds == 2) ui_text_bounds_block(block, 0.0f);
|
||||
else if(block->dobounds == 3) ui_popup_bounds_block(C, block);
|
||||
else if(block->dobounds) ui_popup_bounds_block(C, block, (block->dobounds == 4));
|
||||
|
||||
if(block->autofill) ui_autofill(block);
|
||||
if(block->minx==0.0 && block->maxx==0.0) uiBoundsBlock(block, 0);
|
||||
@ -886,8 +903,10 @@ static int ui_do_but_LINK(uiBlock *block, uiBut *but)
|
||||
|
||||
void uiBlockSetButLock(uiBlock *block, int val, char *lockstr)
|
||||
{
|
||||
block->lock |= val;
|
||||
if(val) block->lockstr= lockstr;
|
||||
if(val) {
|
||||
block->lock |= val;
|
||||
block->lockstr= lockstr;
|
||||
}
|
||||
}
|
||||
|
||||
void uiBlockClearButLock(uiBlock *block)
|
||||
@ -1480,6 +1499,7 @@ static void ui_free_but(const bContext *C, uiBut *but)
|
||||
WM_operator_properties_free(but->opptr);
|
||||
MEM_freeN(but->opptr);
|
||||
}
|
||||
if(but->func_argN) MEM_freeN(but->func_argN);
|
||||
if(but->active) ui_button_active_cancel(C, but);
|
||||
if(but->str && but->str != but->strdata) MEM_freeN(but->str);
|
||||
ui_free_link(but->link);
|
||||
@ -2836,19 +2856,19 @@ PointerRNA *uiButGetOperatorPtrRNA(uiBut *but)
|
||||
return but->opptr;
|
||||
}
|
||||
|
||||
void uiBlockSetHandleFunc(uiBlock *block, void (*func)(struct bContext *C, void *arg, int event), void *arg)
|
||||
void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg)
|
||||
{
|
||||
block->handle_func= func;
|
||||
block->handle_func_arg= arg;
|
||||
}
|
||||
|
||||
void uiBlockSetButmFunc(uiBlock *block, void (*func)(struct bContext *C, void *arg, int but_a2), void *arg)
|
||||
void uiBlockSetButmFunc(uiBlock *block, uiMenuHandleFunc func, void *arg)
|
||||
{
|
||||
block->butm_func= func;
|
||||
block->butm_func_arg= arg;
|
||||
}
|
||||
|
||||
void uiBlockSetFunc(uiBlock *block, void (*func)(struct bContext *C, void *arg1, void *arg2), void *arg1, void *arg2)
|
||||
void uiBlockSetFunc(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2)
|
||||
{
|
||||
block->func= func;
|
||||
block->func_arg1= arg1;
|
||||
@ -2860,14 +2880,21 @@ void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)())
|
||||
block->drawextra= func;
|
||||
}
|
||||
|
||||
void uiButSetFunc(uiBut *but, void (*func)(struct bContext *C, void *arg1, void *arg2), void *arg1, void *arg2)
|
||||
void uiButSetFunc(uiBut *but, uiButHandleFunc func, void *arg1, void *arg2)
|
||||
{
|
||||
but->func= func;
|
||||
but->func_arg1= arg1;
|
||||
but->func_arg2= arg2;
|
||||
}
|
||||
|
||||
void uiButSetCompleteFunc(uiBut *but, void (*func)(struct bContext *C, char *str, void *arg), void *arg)
|
||||
void uiButSetNFunc(uiBut *but, uiButHandleNFunc funcN, void *argN, void *arg2)
|
||||
{
|
||||
but->funcN= funcN;
|
||||
but->func_argN= argN;
|
||||
but->func_arg2= arg2;
|
||||
}
|
||||
|
||||
void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg)
|
||||
{
|
||||
but->autocomplete_func= func;
|
||||
but->autofunc_arg= arg;
|
||||
|
@ -23,6 +23,7 @@
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -133,15 +134,18 @@ typedef struct uiHandleButtonData {
|
||||
typedef struct uiAfterFunc {
|
||||
struct uiAfterFunc *next, *prev;
|
||||
|
||||
void (*func)(struct bContext*, void *, void *);
|
||||
uiButHandleFunc func;
|
||||
void *func_arg1;
|
||||
void *func_arg2;
|
||||
|
||||
void (*handle_func)(struct bContext*, void *arg, int event);
|
||||
uiButHandleNFunc funcN;
|
||||
void *func_argN;
|
||||
|
||||
uiBlockHandleFunc handle_func;
|
||||
void *handle_func_arg;
|
||||
int retval;
|
||||
|
||||
void (*butm_func)(struct bContext*, void *arg, int event);
|
||||
uiMenuHandleFunc butm_func;
|
||||
void *butm_func_arg;
|
||||
int a2;
|
||||
|
||||
@ -216,13 +220,16 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
|
||||
* handling is done, i.e. menus are closed, in order to avoid conflicts
|
||||
* with these functions removing the buttons we are working with */
|
||||
|
||||
if(but->func || block->handle_func || (but->type == BUTM && block->butm_func) || but->opname || but->rnaprop) {
|
||||
if(but->func || but->funcN || block->handle_func || (but->type == BUTM && block->butm_func) || but->opname || but->rnaprop) {
|
||||
after= MEM_callocN(sizeof(uiAfterFunc), "uiAfterFunc");
|
||||
|
||||
after->func= but->func;
|
||||
after->func_arg1= but->func_arg1;
|
||||
after->func_arg2= but->func_arg2;
|
||||
|
||||
after->funcN= but->funcN;
|
||||
after->func_argN= but->func_argN;
|
||||
|
||||
after->handle_func= block->handle_func;
|
||||
after->handle_func_arg= block->handle_func_arg;
|
||||
after->retval= but->retval;
|
||||
@ -250,34 +257,37 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
|
||||
|
||||
static void ui_apply_but_funcs_after(bContext *C)
|
||||
{
|
||||
uiAfterFunc *after;
|
||||
uiAfterFunc *afterf, after;
|
||||
ListBase funcs;
|
||||
|
||||
/* copy to avoid recursive calls */
|
||||
funcs= UIAfterFuncs;
|
||||
UIAfterFuncs.first= UIAfterFuncs.last= NULL;
|
||||
|
||||
for(after=funcs.first; after; after=after->next) {
|
||||
if(after->func)
|
||||
after->func(C, after->func_arg1, after->func_arg2);
|
||||
|
||||
if(after->handle_func)
|
||||
after->handle_func(C, after->handle_func_arg, after->retval);
|
||||
if(after->butm_func)
|
||||
after->butm_func(C, after->butm_func_arg, after->a2);
|
||||
for(afterf=funcs.first; afterf; afterf=after.next) {
|
||||
after= *afterf; /* copy to avoid memleak on exit() */
|
||||
BLI_freelinkN(&funcs, afterf);
|
||||
|
||||
if(after->opname)
|
||||
WM_operator_name_call(C, after->opname, after->opcontext, after->opptr);
|
||||
if(after->opptr) {
|
||||
WM_operator_properties_free(after->opptr);
|
||||
MEM_freeN(after->opptr);
|
||||
if(after.func)
|
||||
after.func(C, after.func_arg1, after.func_arg2);
|
||||
if(after.funcN)
|
||||
after.funcN(C, after.func_argN, after.func_arg2);
|
||||
|
||||
if(after.handle_func)
|
||||
after.handle_func(C, after.handle_func_arg, after.retval);
|
||||
if(after.butm_func)
|
||||
after.butm_func(C, after.butm_func_arg, after.a2);
|
||||
|
||||
if(after.opname)
|
||||
WM_operator_name_call(C, after.opname, after.opcontext, after.opptr);
|
||||
if(after.opptr) {
|
||||
WM_operator_properties_free(after.opptr);
|
||||
MEM_freeN(after.opptr);
|
||||
}
|
||||
|
||||
if(after->rnapoin.data)
|
||||
RNA_property_update(C, &after->rnapoin, after->rnaprop);
|
||||
if(after.rnapoin.data)
|
||||
RNA_property_update(C, &after.rnapoin, after.rnaprop);
|
||||
}
|
||||
|
||||
BLI_freelistN(&funcs);
|
||||
}
|
||||
|
||||
static void ui_apply_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||
@ -1373,9 +1383,18 @@ static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, u
|
||||
|
||||
/* ************* number editing for various types ************* */
|
||||
|
||||
static void but_clamped_range(uiBut *but, float *butmin, float *butmax, float *butrange)
|
||||
{
|
||||
/* clamp button range to something reasonable in case
|
||||
* we get -inf/inf from RNA properties */
|
||||
*butmin= MAX2(but->min, -1e4f);
|
||||
*butmax= MIN2(but->max, 1e4f);
|
||||
*butrange= *butmax - *butmin;
|
||||
}
|
||||
|
||||
static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data)
|
||||
{
|
||||
float butrange;
|
||||
float butrange, butmin, butmax;
|
||||
|
||||
if(but->type == BUT_CURVE) {
|
||||
data->cumap= (CurveMapping*)but->poin;
|
||||
@ -1395,8 +1414,9 @@ static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data)
|
||||
data->value= data->origvalue;
|
||||
but->editval= &data->value;
|
||||
|
||||
butrange= (but->max - but->min);
|
||||
data->dragfstart= (butrange == 0.0)? 0.0f: (data->value - but->min)/butrange;
|
||||
but_clamped_range(but, &butmin, &butmax, &butrange);
|
||||
|
||||
data->dragfstart= (butrange == 0.0)? 0.0f: (data->value - butmin)/butrange;
|
||||
data->dragf= data->dragfstart;
|
||||
}
|
||||
|
||||
@ -1603,7 +1623,7 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
|
||||
|
||||
static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, int snap, int mx)
|
||||
{
|
||||
float deler, tempf;
|
||||
float deler, tempf, butmin, butmax, butrange;
|
||||
int lvalue, temp, changed= 0;
|
||||
|
||||
if(mx == data->draglastx)
|
||||
@ -1619,28 +1639,30 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
|
||||
data->dragstartx= mx; /* ignore mouse movement within drag-lock */
|
||||
}
|
||||
|
||||
but_clamped_range(but, &butmin, &butmax, &butrange);
|
||||
|
||||
deler= 500;
|
||||
if(!ui_is_but_float(but)) {
|
||||
if((but->max-but->min)<100) deler= 200.0;
|
||||
if((but->max-but->min)<25) deler= 50.0;
|
||||
if((butrange)<100) deler= 200.0;
|
||||
if((butrange)<25) deler= 50.0;
|
||||
}
|
||||
deler /= fac;
|
||||
|
||||
if(ui_is_but_float(but) && but->max-but->min > 11) {
|
||||
if(ui_is_but_float(but) && butrange > 11) {
|
||||
/* non linear change in mouse input- good for high precicsion */
|
||||
data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabs(data->dragstartx-mx)*0.002);
|
||||
} else if (!ui_is_but_float(but) && but->max-but->min > 129) { /* only scale large int buttons */
|
||||
} else if (!ui_is_but_float(but) && butrange > 129) { /* only scale large int buttons */
|
||||
/* non linear change in mouse input- good for high precicsionm ints need less fine tuning */
|
||||
data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabs(data->dragstartx-mx)*0.004);
|
||||
} else {
|
||||
/*no scaling */
|
||||
data->dragf+= ((float)(mx-data->draglastx))/deler ;
|
||||
}
|
||||
|
||||
|
||||
if(data->dragf>1.0) data->dragf= 1.0;
|
||||
if(data->dragf<0.0) data->dragf= 0.0;
|
||||
data->draglastx= mx;
|
||||
tempf= ( but->min + data->dragf*(but->max-but->min));
|
||||
tempf= (butmin + data->dragf*butrange);
|
||||
|
||||
if(!ui_is_but_float(but)) {
|
||||
|
||||
@ -1667,14 +1689,14 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
|
||||
if(snap) {
|
||||
if(snap == 2) {
|
||||
if(tempf==but->min || tempf==but->max);
|
||||
else if(but->max-but->min < 2.10) tempf= 0.01*floor(100.0*tempf);
|
||||
else if(but->max-but->min < 21.0) tempf= 0.1*floor(10.0*tempf);
|
||||
else if(butrange < 2.10) tempf= 0.01*floor(100.0*tempf);
|
||||
else if(butrange < 21.0) tempf= 0.1*floor(10.0*tempf);
|
||||
else tempf= floor(tempf);
|
||||
}
|
||||
else {
|
||||
if(tempf==but->min || tempf==but->max);
|
||||
else if(but->max-but->min < 2.10) tempf= 0.1*floor(10*tempf);
|
||||
else if(but->max-but->min < 21.0) tempf= floor(tempf);
|
||||
else if(butrange < 2.10) tempf= 0.1*floor(10*tempf);
|
||||
else if(butrange < 21.0) tempf= floor(tempf);
|
||||
else tempf= 10.0*floor(tempf/10.0);
|
||||
}
|
||||
}
|
||||
@ -1818,9 +1840,11 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
|
||||
|
||||
static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, int ctrl, int mx)
|
||||
{
|
||||
float deler, f, tempf;
|
||||
float deler, f, tempf, butmin, butmax, butrange;
|
||||
int temp, lvalue, changed= 0;
|
||||
|
||||
but_clamped_range(but, &butmin, &butmax, &butrange);
|
||||
|
||||
if(but->type==NUMSLI) deler= ((but->x2-but->x1)/2 - 5.0*but->aspect);
|
||||
else if(but->type==HSVSLI) deler= ((but->x2-but->x1)/2 - 5.0*but->aspect);
|
||||
else deler= (but->x2-but->x1- 5.0*but->aspect);
|
||||
@ -1831,7 +1855,7 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i
|
||||
f= (f-data->dragfstart)/10.0 + data->dragfstart;
|
||||
|
||||
CLAMP(f, 0.0, 1.0);
|
||||
tempf= but->min+f*(but->max-but->min);
|
||||
tempf= butmin + f*butrange;
|
||||
temp= floor(tempf+.5);
|
||||
|
||||
if(ctrl) {
|
||||
@ -1927,11 +1951,13 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
|
||||
|
||||
if(click) {
|
||||
float f, h;
|
||||
float tempf;
|
||||
float tempf, butmin, butmax, butrange;
|
||||
int temp;
|
||||
|
||||
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
|
||||
|
||||
but_clamped_range(but, &butmin, &butmax, &butrange);
|
||||
|
||||
tempf= data->value;
|
||||
temp= (int)data->value;
|
||||
|
||||
@ -1940,7 +1966,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
|
||||
if(but->type==SLI) f= (float)(mx-but->x1)/(but->x2-but->x1-h);
|
||||
else f= (float)(mx- (but->x1+but->x2)/2)/((but->x2-but->x1)/2 - h);
|
||||
|
||||
f= but->min+f*(but->max-but->min);
|
||||
f= butmin + f*butrange;
|
||||
|
||||
if(!ui_is_but_float(but)) {
|
||||
if(f<temp) temp--;
|
||||
@ -2593,6 +2619,9 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
|
||||
data= but->active;
|
||||
retval= WM_UI_HANDLER_CONTINUE;
|
||||
|
||||
if(but->flag & UI_BUT_DISABLED)
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
|
||||
/* handle copy-paste */
|
||||
if(data->state == BUTTON_STATE_HIGHLIGHT) {
|
||||
if(ELEM(event->type, CKEY, VKEY) && event->val==KM_PRESS && (event->ctrl || event->oskey)) {
|
||||
@ -2848,7 +2877,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
|
||||
button_tooltip_timer_reset(but);
|
||||
|
||||
/* automatic open pulldown block timer */
|
||||
if(ELEM5(but->type, BLOCK, MENU, PULLDOWN, HMENU, ICONTEXTROW)) {
|
||||
if(ELEM4(but->type, BLOCK, PULLDOWN, HMENU, ICONTEXTROW)) {
|
||||
if(!data->autoopentimer) {
|
||||
int time;
|
||||
|
||||
@ -3510,8 +3539,18 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu,
|
||||
if((/*inside &&*/ !menu->menuretval && retval == WM_UI_HANDLER_CONTINUE) || event->type == TIMER) {
|
||||
but= ui_but_find_activated(ar);
|
||||
|
||||
if(but)
|
||||
if(but) {
|
||||
ScrArea *ctx_area= CTX_wm_area(C);
|
||||
ARegion *ctx_region= CTX_wm_region(C);
|
||||
|
||||
if(menu->ctx_area) CTX_wm_area_set(C, menu->ctx_area);
|
||||
if(menu->ctx_region) CTX_wm_region_set(C, menu->ctx_region);
|
||||
|
||||
retval= ui_handle_button_event(C, event, but);
|
||||
|
||||
if(menu->ctx_area) CTX_wm_area_set(C, ctx_area);
|
||||
if(menu->ctx_region) CTX_wm_region_set(C, ctx_region);
|
||||
}
|
||||
else
|
||||
retval= ui_handle_button_over(C, event, ar);
|
||||
}
|
||||
@ -3709,19 +3748,11 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata)
|
||||
WM_event_remove_ui_handler(&CTX_wm_window(C)->handlers, ui_handler_popup, ui_handler_remove_popup, menu);
|
||||
|
||||
if(temp.menuretval == UI_RETURN_OK) {
|
||||
if(temp.popup_func) {
|
||||
temp.popup_func(C, temp.op_arg, temp.retvalue);
|
||||
}
|
||||
else if(temp.op_arg) {
|
||||
if(temp.propname)
|
||||
RNA_enum_set(temp.op_arg->ptr, temp.propname, temp.retvalue);
|
||||
WM_operator_call(C, temp.op_arg);
|
||||
}
|
||||
if(temp.popup_func)
|
||||
temp.popup_func(C, temp.popup_arg, temp.retvalue);
|
||||
if(temp.opname)
|
||||
WM_operator_name_call(C, temp.opname, temp.opcontext, NULL);
|
||||
}
|
||||
/* always free operator */
|
||||
else if(temp.op_arg)
|
||||
WM_operator_free(temp.op_arg);
|
||||
|
||||
}
|
||||
else {
|
||||
/* re-enable tooltips */
|
||||
@ -3757,3 +3788,4 @@ void UI_add_popup_handlers(ListBase *handlers, uiPopupBlockHandle *menu)
|
||||
{
|
||||
WM_event_add_ui_handler(NULL, handlers, ui_handler_popup, ui_handler_remove_popup, menu);
|
||||
}
|
||||
|
||||
|
@ -125,6 +125,9 @@ struct uiBut {
|
||||
void *func_arg1;
|
||||
void *func_arg2;
|
||||
|
||||
uiButHandleNFunc funcN;
|
||||
void *func_argN;
|
||||
|
||||
void (*embossfunc)(int , int , float, float, float, float, float, int);
|
||||
void (*sliderfunc)(int , float, float, float, float, float, float, int);
|
||||
|
||||
@ -218,7 +221,7 @@ struct uiBlock {
|
||||
char *lockstr;
|
||||
|
||||
float xofs, yofs; // offset to parent button
|
||||
int bounds, dobounds; // for doing delayed
|
||||
int bounds, dobounds, mx, my; // for doing delayed
|
||||
int endblock; // uiEndBlock done?
|
||||
|
||||
rctf safety; // pulldowns, to detect outside, can differ per case how it is created
|
||||
@ -277,9 +280,12 @@ struct uiPopupBlockHandle {
|
||||
int popup;
|
||||
void (*popup_func)(struct bContext *C, void *arg, int event);
|
||||
void *popup_arg;
|
||||
/* for operator menus */
|
||||
struct wmOperator *op_arg;
|
||||
const char *propname;
|
||||
|
||||
/* for operator popups */
|
||||
const char *opname;
|
||||
int opcontext;
|
||||
ScrArea *ctx_area;
|
||||
ARegion *ctx_region;
|
||||
|
||||
/* return values */
|
||||
int butretval;
|
||||
|
@ -635,6 +635,10 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
|
||||
/* create handle */
|
||||
handle= MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle");
|
||||
|
||||
/* store context for operator */
|
||||
handle->ctx_area= CTX_wm_area(C);
|
||||
handle->ctx_region= CTX_wm_region(C);
|
||||
|
||||
/* create area region */
|
||||
ar= ui_add_temporary_region(CTX_wm_screen(C));
|
||||
|
||||
@ -1657,13 +1661,14 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle,
|
||||
#define MENU_ITEM_OPNAME 2
|
||||
#define MENU_ITEM_OPNAME_BOOL 3
|
||||
#define MENU_ITEM_OPNAME_ENUM 4
|
||||
#define MENU_ITEM_OPNAME_FLOAT 5
|
||||
#define MENU_ITEM_RNA_BOOL 6
|
||||
#define MENU_ITEM_RNA_ENUM 7
|
||||
#define MENU_ITEM_LEVEL 8
|
||||
#define MENU_ITEM_LEVEL_OPNAME_ENUM 9
|
||||
#define MENU_ITEM_LEVEL_RNA_ENUM 10
|
||||
#define MENU_ITEM_SEPARATOR 11
|
||||
#define MENU_ITEM_OPNAME_INT 5
|
||||
#define MENU_ITEM_OPNAME_FLOAT 6
|
||||
#define MENU_ITEM_RNA_BOOL 7
|
||||
#define MENU_ITEM_RNA_ENUM 8
|
||||
#define MENU_ITEM_LEVEL 9
|
||||
#define MENU_ITEM_LEVEL_OPNAME_ENUM 10
|
||||
#define MENU_ITEM_LEVEL_RNA_ENUM 11
|
||||
#define MENU_ITEM_SEPARATOR 12
|
||||
|
||||
struct uiMenuItem {
|
||||
struct uiMenuItem *next, *prev;
|
||||
@ -1675,7 +1680,7 @@ struct uiMenuItem {
|
||||
char *opname; /* static string */
|
||||
char *propname; /* static string */
|
||||
|
||||
int retval, enumval, boolval;
|
||||
int retval, enumval, boolval, intval;
|
||||
float fltval;
|
||||
int opcontext;
|
||||
uiMenuHandleFunc eventfunc;
|
||||
@ -1762,15 +1767,15 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle,
|
||||
block->themecol= TH_MENU_ITEM;
|
||||
block->direction= UI_DOWN;
|
||||
|
||||
width= 50; // fixed with, uiPopupBoundsBlock will compute actual width
|
||||
width= 50; // fixed with, uiMenuPopupBoundsBlock will compute actual width
|
||||
|
||||
for(item= head->items.first; item; item= item->next) {
|
||||
if(0) height+= PUP_LABELH; // XXX sepr line
|
||||
else height+= MENU_BUTTON_HEIGHT;
|
||||
}
|
||||
|
||||
startx= info->mx;
|
||||
starty= info->my-height+MENU_BUTTON_HEIGHT/2;
|
||||
startx= 0;
|
||||
starty= 0;
|
||||
|
||||
/* here we go! */
|
||||
if(head->name[0]) {
|
||||
@ -1819,7 +1824,7 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle,
|
||||
y1 -= MENU_BUTTON_HEIGHT;
|
||||
}
|
||||
else if(item->type==MENU_ITEM_OPNAME_BOOL) {
|
||||
but= uiDefIconTextButO(block, BUTM, item->opname, head->opcontext, item->icon, item->name, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, "");
|
||||
but= uiDefIconTextButO(block, BUTM, item->opname, item->opcontext, item->icon, item->name, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, "");
|
||||
RNA_boolean_set(uiButGetOperatorPtrRNA(but), item->propname, item->boolval);
|
||||
|
||||
y1 -= MENU_BUTTON_HEIGHT;
|
||||
@ -1831,19 +1836,25 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle,
|
||||
name= ui_menu_enumpropname(item->opname, item->propname, item->enumval);
|
||||
BLI_strncpy(bname, name, sizeof(bname));
|
||||
|
||||
but= uiDefIconTextButO(block, BUTM, item->opname, head->opcontext, item->icon, bname, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, "");
|
||||
but= uiDefIconTextButO(block, BUTM, item->opname, item->opcontext, item->icon, bname, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, "");
|
||||
RNA_enum_set(uiButGetOperatorPtrRNA(but), item->propname, item->enumval);
|
||||
|
||||
y1 -= MENU_BUTTON_HEIGHT;
|
||||
}
|
||||
else if(item->type==MENU_ITEM_OPNAME_FLOAT) {
|
||||
else if(item->type==MENU_ITEM_OPNAME_INT) {
|
||||
but= uiDefIconTextButO(block, BUTM, item->opname, head->opcontext, item->icon, item->name, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, "");
|
||||
RNA_int_set(uiButGetOperatorPtrRNA(but), item->propname, item->intval);
|
||||
|
||||
y1 -= MENU_BUTTON_HEIGHT;
|
||||
}
|
||||
else if(item->type==MENU_ITEM_OPNAME_FLOAT) {
|
||||
but= uiDefIconTextButO(block, BUTM, item->opname, item->opcontext, item->icon, item->name, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, "");
|
||||
RNA_float_set(uiButGetOperatorPtrRNA(but), item->propname, item->fltval);
|
||||
|
||||
y1 -= MENU_BUTTON_HEIGHT;
|
||||
}
|
||||
else if(item->type==MENU_ITEM_OPNAME) {
|
||||
uiDefIconTextButO(block, BUTM, item->opname, head->opcontext, item->icon, NULL, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, NULL);
|
||||
uiDefIconTextButO(block, BUTM, item->opname, item->opcontext, item->icon, NULL, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, NULL);
|
||||
y1 -= MENU_BUTTON_HEIGHT;
|
||||
}
|
||||
else if(item->type==MENU_ITEM_RNA_BOOL) {
|
||||
@ -1890,7 +1901,8 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle,
|
||||
uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT|UI_BLOCK_RET_1);
|
||||
uiBlockSetDirection(block, UI_DOWN);
|
||||
|
||||
uiPopupBoundsBlock(block, 1);
|
||||
/* here we set an offset for the mouse position */
|
||||
uiMenuPopupBoundsBlock(block, 1, 0, -height+MENU_BUTTON_HEIGHT/2);
|
||||
}
|
||||
else {
|
||||
/* for a header menu we set the direction automatic */
|
||||
@ -1954,7 +1966,8 @@ static uiMenuItem *ui_menu_add_item(uiMenuItem *head, const char *name, int icon
|
||||
else
|
||||
item->icon= ICON_BLANK1;
|
||||
item->retval= argval;
|
||||
item->opcontext= WM_OP_EXEC_REGION_WIN;
|
||||
|
||||
item->opcontext= head->opcontext;
|
||||
|
||||
BLI_addtail(&head->items, item);
|
||||
|
||||
@ -1984,18 +1997,18 @@ void uiMenuItemVal(uiMenuItem *head, const char *name, int icon, int argval)
|
||||
}
|
||||
|
||||
/* regular operator item */
|
||||
void uiMenuItemO(uiMenuItem *head, char *name, int icon)
|
||||
void uiMenuItemO(uiMenuItem *head, int icon, char *opname)
|
||||
{
|
||||
uiMenuItem *item= ui_menu_add_item(head, name, icon, 0);
|
||||
uiMenuItem *item= ui_menu_add_item(head, "", icon, 0);
|
||||
|
||||
item->opname= name; // static!
|
||||
item->opname= opname; // static!
|
||||
item->type = MENU_ITEM_OPNAME;
|
||||
}
|
||||
|
||||
/* single operator item with property */
|
||||
void uiMenuItemEnumO(uiMenuItem *head, char *opname, char *propname, int value)
|
||||
void uiMenuItemEnumO(uiMenuItem *head, int icon, char *opname, char *propname, int value)
|
||||
{
|
||||
uiMenuItem *item= ui_menu_add_item(head, "", 0, 0);
|
||||
uiMenuItem *item= ui_menu_add_item(head, "", icon, 0);
|
||||
|
||||
item->opname= opname; // static!
|
||||
item->propname= propname; // static!
|
||||
@ -2004,9 +2017,20 @@ void uiMenuItemEnumO(uiMenuItem *head, char *opname, char *propname, int value)
|
||||
}
|
||||
|
||||
/* single operator item with property */
|
||||
void uiMenuItemFloatO(uiMenuItem *head, const char *name, char *opname, char *propname, float value)
|
||||
void uiMenuItemIntO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, int value)
|
||||
{
|
||||
uiMenuItem *item= ui_menu_add_item(head, name, 0, 0);
|
||||
uiMenuItem *item= ui_menu_add_item(head, name, icon, 0);
|
||||
|
||||
item->opname= opname; // static!
|
||||
item->propname= propname; // static!
|
||||
item->intval= value;
|
||||
item->type = MENU_ITEM_OPNAME_INT;
|
||||
}
|
||||
|
||||
/* single operator item with property */
|
||||
void uiMenuItemFloatO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, float value)
|
||||
{
|
||||
uiMenuItem *item= ui_menu_add_item(head, name, icon, 0);
|
||||
|
||||
item->opname= opname; // static!
|
||||
item->propname= propname; // static!
|
||||
@ -2015,9 +2039,9 @@ void uiMenuItemFloatO(uiMenuItem *head, const char *name, char *opname, char *pr
|
||||
}
|
||||
|
||||
/* single operator item with property */
|
||||
void uiMenuItemBooleanO(uiMenuItem *head, char *opname, char *propname, int value)
|
||||
void uiMenuItemBooleanO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, int value)
|
||||
{
|
||||
uiMenuItem *item= ui_menu_add_item(head, "", 0, 0);
|
||||
uiMenuItem *item= ui_menu_add_item(head, name, icon, 0);
|
||||
|
||||
item->opname= opname; // static!
|
||||
item->propname= propname; // static!
|
||||
@ -2045,7 +2069,7 @@ void uiMenuItemsEnumO(uiMenuItem *head, char *opname, char *propname)
|
||||
RNA_property_enum_items(&ptr, prop, &item, &totitem);
|
||||
|
||||
for (i=0; i<totitem; i++)
|
||||
uiMenuItemEnumO(head, opname, propname, item[i].value);
|
||||
uiMenuItemEnumO(head, 0, opname, propname, item[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2141,12 +2165,13 @@ void uiMenuSeparator(uiMenuItem *head)
|
||||
/*************************** Popup Menu API **************************/
|
||||
|
||||
/* only return handler, and set optional title */
|
||||
uiMenuItem *uiPupMenuBegin(const char *title)
|
||||
uiMenuItem *uiPupMenuBegin(const char *title, int icon)
|
||||
{
|
||||
uiMenuItem *item= MEM_callocN(sizeof(uiMenuItem), "menu start");
|
||||
|
||||
item->type = MENU_ITEM_TITLE;
|
||||
item->opcontext= WM_OP_EXEC_REGION_WIN;
|
||||
item->icon= icon;
|
||||
|
||||
/* NULL is no title */
|
||||
if(title)
|
||||
@ -2178,32 +2203,6 @@ void uiPupMenuEnd(bContext *C, uiMenuItem *head)
|
||||
MEM_freeN(head);
|
||||
}
|
||||
|
||||
/* This one will set enum propname, call operator and register it, and free the operator itself,
|
||||
call it in op->invoke with returning OPERATOR_RUNNING_MODAL */
|
||||
/* Note: propname has to be static */
|
||||
void uiPupMenuOperator(bContext *C, int maxrow, wmOperator *op, const char *propname, char *str)
|
||||
{
|
||||
wmWindow *window= CTX_wm_window(C);
|
||||
uiPupMenuInfo info;
|
||||
uiPopupBlockHandle *menu;
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.mx= window->eventstate->x;
|
||||
info.my= window->eventstate->y;
|
||||
info.maxrow= maxrow;
|
||||
info.instr= str;
|
||||
|
||||
menu= ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_PUPMENU, &info);
|
||||
menu->popup= 1;
|
||||
|
||||
UI_add_popup_handlers(&window->handlers, menu);
|
||||
WM_event_add_mousemove(C);
|
||||
|
||||
menu->op_arg= op;
|
||||
menu->propname= propname;
|
||||
}
|
||||
|
||||
|
||||
/* this one only to be called with operatortype name option */
|
||||
void uiPupMenu(bContext *C, int maxrow, uiMenuHandleFunc func, void *arg, char *str, ...)
|
||||
{
|
||||
@ -2338,3 +2337,24 @@ void uiPupMenuReports(bContext *C, ReportList *reports)
|
||||
BLI_dynstr_free(ds);
|
||||
}
|
||||
|
||||
/*************************** Popup Block API **************************/
|
||||
|
||||
void uiPupBlockO(bContext *C, uiBlockCreateFunc func, void *arg, char *opname, int opcontext)
|
||||
{
|
||||
wmWindow *window= CTX_wm_window(C);
|
||||
uiPopupBlockHandle *handle;
|
||||
|
||||
handle= ui_popup_block_create(C, NULL, NULL, func, NULL, arg);
|
||||
handle->popup= 1;
|
||||
handle->opname= opname;
|
||||
handle->opcontext= opcontext;
|
||||
|
||||
UI_add_popup_handlers(&window->handlers, handle);
|
||||
WM_event_add_mousemove(C);
|
||||
}
|
||||
|
||||
void uiPupBlock(bContext *C, uiBlockCreateFunc func, void *arg)
|
||||
{
|
||||
uiPupBlockO(C, func, arg, NULL, 0);
|
||||
}
|
||||
|
||||
|
672
source/blender/editors/interface/interface_utils.c
Normal file
672
source/blender/editors/interface/interface_utils.c
Normal file
@ -0,0 +1,672 @@
|
||||
/**
|
||||
* ***** 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.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Contributor(s): Blender Foundation
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
#include "DNA_material_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_windowmanager_types.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_library.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "ED_util.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#define DEF_BUT_WIDTH 150
|
||||
#define DEF_ICON_BUT_WIDTH 20
|
||||
#define DEF_BUT_HEIGHT 20
|
||||
|
||||
/*************************** RNA Utilities ******************************/
|
||||
|
||||
int UI_GetIconRNA(PointerRNA *ptr)
|
||||
{
|
||||
StructRNA *rnatype= ptr->type;
|
||||
|
||||
if(rnatype == &RNA_Scene)
|
||||
return ICON_SCENE_DEHLT;
|
||||
else if(rnatype == &RNA_World)
|
||||
return ICON_WORLD;
|
||||
else if(rnatype == &RNA_Object)
|
||||
return ICON_OBJECT;
|
||||
else if(rnatype == &RNA_Mesh)
|
||||
return ICON_MESH;
|
||||
else if(rnatype == &RNA_MeshVertex)
|
||||
return ICON_VERTEXSEL;
|
||||
else if(rnatype == &RNA_MeshEdge)
|
||||
return ICON_EDGESEL;
|
||||
else if(rnatype == &RNA_MeshFace)
|
||||
return ICON_FACESEL;
|
||||
else if(rnatype == &RNA_MeshTextureFace)
|
||||
return ICON_FACESEL_HLT;
|
||||
else if(rnatype == &RNA_VertexGroup)
|
||||
return ICON_VGROUP;
|
||||
else if(rnatype == &RNA_VertexGroupElement)
|
||||
return ICON_VGROUP;
|
||||
else if(rnatype == &RNA_Curve)
|
||||
return ICON_CURVE;
|
||||
else if(rnatype == &RNA_MetaBall)
|
||||
return ICON_MBALL;
|
||||
else if(rnatype == &RNA_MetaElement)
|
||||
return ICON_OUTLINER_DATA_META;
|
||||
else if(rnatype == &RNA_Lattice)
|
||||
return ICON_LATTICE;
|
||||
else if(rnatype == &RNA_Armature)
|
||||
return ICON_ARMATURE;
|
||||
else if(rnatype == &RNA_Bone)
|
||||
return ICON_BONE_DEHLT;
|
||||
else if(rnatype == &RNA_Camera)
|
||||
return ICON_CAMERA;
|
||||
else if(rnatype == &RNA_LocalLamp)
|
||||
return ICON_LAMP;
|
||||
else if(rnatype == &RNA_AreaLamp)
|
||||
return ICON_LAMP;
|
||||
else if(rnatype == &RNA_SpotLamp)
|
||||
return ICON_LAMP;
|
||||
else if(rnatype == &RNA_SunLamp)
|
||||
return ICON_LAMP;
|
||||
else if(rnatype == &RNA_HemiLamp)
|
||||
return ICON_LAMP;
|
||||
else if(rnatype == &RNA_Lamp)
|
||||
return ICON_LAMP;
|
||||
else if(rnatype == &RNA_Group)
|
||||
return ICON_GROUP;
|
||||
else if(rnatype == &RNA_ParticleSystem)
|
||||
return ICON_PARTICLES;
|
||||
else if(rnatype == &RNA_ParticleSettings)
|
||||
return ICON_PARTICLES;
|
||||
else if(rnatype == &RNA_Material)
|
||||
return ICON_MATERIAL;
|
||||
else if(rnatype == &RNA_Texture)
|
||||
return ICON_TEXTURE;
|
||||
else if(rnatype == &RNA_TextureSlot)
|
||||
return ICON_TEXTURE;
|
||||
else if(rnatype == &RNA_WorldTextureSlot)
|
||||
return ICON_TEXTURE;
|
||||
else if(rnatype == &RNA_MaterialTextureSlot)
|
||||
return ICON_TEXTURE;
|
||||
else if(rnatype == &RNA_Image)
|
||||
return ICON_TEXTURE;
|
||||
else if(rnatype == &RNA_Screen)
|
||||
return ICON_SPLITSCREEN;
|
||||
else if(rnatype == &RNA_NodeTree)
|
||||
return ICON_NODE;
|
||||
else if(rnatype == &RNA_Text)
|
||||
return ICON_TEXT;
|
||||
else if(rnatype == &RNA_Sound)
|
||||
return ICON_SOUND;
|
||||
else if(rnatype == &RNA_Brush)
|
||||
return ICON_TPAINT_HLT;
|
||||
else if(rnatype == &RNA_Library)
|
||||
return ICON_LIBRARY_DEHLT;
|
||||
else if(rnatype == &RNA_Action)
|
||||
return ICON_ACTION;
|
||||
else if(rnatype == &RNA_FCurve)
|
||||
return ICON_IPO_DEHLT;
|
||||
//else if(rnatype == &RNA_Ipo)
|
||||
// return ICON_IPO_DEHLT;
|
||||
else if(rnatype == &RNA_Key)
|
||||
return ICON_SHAPEKEY;
|
||||
else if(rnatype == &RNA_Main)
|
||||
return ICON_BLENDER;
|
||||
else if(rnatype == &RNA_Struct)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_Property)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_BooleanProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_IntProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_FloatProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_StringProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_EnumProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_EnumPropertyItem)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_PointerProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_CollectionProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_GameObjectSettings)
|
||||
return ICON_GAME;
|
||||
else if(rnatype == &RNA_ScriptLink)
|
||||
return ICON_PYTHON;
|
||||
|
||||
/* modifiers */
|
||||
else if(rnatype == &RNA_SubsurfModifier)
|
||||
return ICON_MOD_SUBSURF;
|
||||
else if(rnatype == &RNA_ArmatureModifier)
|
||||
return ICON_ARMATURE;
|
||||
else if(rnatype == &RNA_LatticeModifier)
|
||||
return ICON_LATTICE;
|
||||
else if(rnatype == &RNA_CurveModifier)
|
||||
return ICON_CURVE;
|
||||
else if(rnatype == &RNA_BuildModifier)
|
||||
return ICON_MOD_BUILD;
|
||||
else if(rnatype == &RNA_MirrorModifier)
|
||||
return ICON_MOD_MIRROR;
|
||||
else if(rnatype == &RNA_DecimateModifier)
|
||||
return ICON_MOD_DECIM;
|
||||
else if(rnatype == &RNA_WaveModifier)
|
||||
return ICON_MOD_WAVE;
|
||||
else if(rnatype == &RNA_HookModifier)
|
||||
return ICON_HOOK;
|
||||
else if(rnatype == &RNA_SoftbodyModifier)
|
||||
return ICON_MOD_SOFT;
|
||||
else if(rnatype == &RNA_BooleanModifier)
|
||||
return ICON_MOD_BOOLEAN;
|
||||
else if(rnatype == &RNA_ParticleInstanceModifier)
|
||||
return ICON_MOD_PARTICLEINSTANCE;
|
||||
else if(rnatype == &RNA_ParticleSystemModifier)
|
||||
return ICON_MOD_PARTICLES;
|
||||
else if(rnatype == &RNA_EdgeSplitModifier)
|
||||
return ICON_MOD_EDGESPLIT;
|
||||
else if(rnatype == &RNA_ArrayModifier)
|
||||
return ICON_MOD_ARRAY;
|
||||
else if(rnatype == &RNA_UVProjectModifier)
|
||||
return ICON_MOD_UVPROJECT;
|
||||
else if(rnatype == &RNA_DisplaceModifier)
|
||||
return ICON_MOD_DISPLACE;
|
||||
else
|
||||
return ICON_DOT;
|
||||
}
|
||||
|
||||
uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, char *name, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
uiBut *but=NULL;
|
||||
const char *propname= RNA_property_identifier(ptr, prop);
|
||||
int arraylen= RNA_property_array_length(ptr, prop);
|
||||
|
||||
switch(RNA_property_type(ptr, prop)) {
|
||||
case PROP_BOOLEAN: {
|
||||
int value, length;
|
||||
|
||||
if(arraylen && index == -1)
|
||||
return NULL;
|
||||
|
||||
length= RNA_property_array_length(ptr, prop);
|
||||
|
||||
if(length)
|
||||
value= RNA_property_boolean_get_index(ptr, prop, index);
|
||||
else
|
||||
value= RNA_property_boolean_get(ptr, prop);
|
||||
|
||||
if(name && strcmp(name, "") == 0)
|
||||
name= (value)? "Enabled": "Disabled";
|
||||
|
||||
but= uiDefButR(block, TOG, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
|
||||
break;
|
||||
}
|
||||
case PROP_INT:
|
||||
case PROP_FLOAT:
|
||||
if(arraylen && index == -1) {
|
||||
if(RNA_property_subtype(ptr, prop) == PROP_COLOR)
|
||||
but= uiDefButR(block, COL, 0, name, x1, y1, x2, y2, ptr, propname, 0, 0, 0, -1, -1, NULL);
|
||||
}
|
||||
else
|
||||
but= uiDefButR(block, NUM, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
|
||||
break;
|
||||
case PROP_ENUM:
|
||||
but= uiDefButR(block, MENU, 0, NULL, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
|
||||
break;
|
||||
case PROP_STRING:
|
||||
but= uiDefButR(block, TEX, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
|
||||
break;
|
||||
case PROP_POINTER: {
|
||||
PointerRNA pptr;
|
||||
PropertyRNA *nameprop;
|
||||
char *text, *descr, textbuf[256];
|
||||
int icon;
|
||||
|
||||
pptr= RNA_property_pointer_get(ptr, prop);
|
||||
|
||||
if(!pptr.data)
|
||||
return NULL;
|
||||
|
||||
icon= UI_GetIconRNA(&pptr);
|
||||
nameprop= RNA_struct_name_property(&pptr);
|
||||
|
||||
if(nameprop) {
|
||||
text= RNA_property_string_get_alloc(&pptr, nameprop, textbuf, sizeof(textbuf));
|
||||
descr= (char*)RNA_property_ui_description(&pptr, prop);
|
||||
but= uiDefIconTextBut(block, LABEL, 0, icon, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, descr);
|
||||
if(text != textbuf)
|
||||
MEM_freeN(text);
|
||||
}
|
||||
else {
|
||||
text= (char*)RNA_struct_ui_name(&pptr);
|
||||
descr= (char*)RNA_property_ui_description(&pptr, prop);
|
||||
but= uiDefIconTextBut(block, LABEL, 0, icon, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, descr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PROP_COLLECTION: {
|
||||
char text[256];
|
||||
sprintf(text, "%d items", RNA_property_collection_length(ptr, prop));
|
||||
but= uiDefBut(block, LABEL, 0, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, NULL);
|
||||
uiButSetFlag(but, UI_BUT_DISABLED);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
but= NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
return but;
|
||||
}
|
||||
|
||||
int uiDefAutoButsRNA(uiBlock *block, PointerRNA *ptr)
|
||||
{
|
||||
CollectionPropertyIterator iter;
|
||||
PropertyRNA *iterprop, *prop;
|
||||
PropertySubType subtype;
|
||||
char *name, namebuf[128];
|
||||
int a, length, x= 0, y= 0;
|
||||
|
||||
x= 0;
|
||||
y= 0;
|
||||
|
||||
/* create buttons */
|
||||
uiSetCurFont(block, UI_HELVB);
|
||||
uiDefBut(block, LABEL, 0, (char*)RNA_struct_ui_name(ptr), x, y, DEF_BUT_WIDTH, DEF_BUT_HEIGHT-1, NULL, 0, 0, 0, 0, "");
|
||||
y -= DEF_BUT_HEIGHT;
|
||||
uiSetCurFont(block, UI_HELV);
|
||||
|
||||
iterprop= RNA_struct_iterator_property(ptr);
|
||||
RNA_property_collection_begin(ptr, iterprop, &iter);
|
||||
|
||||
for(; iter.valid; RNA_property_collection_next(&iter)) {
|
||||
prop= iter.ptr.data;
|
||||
|
||||
if(strcmp(RNA_property_identifier(ptr, prop), "rna_type") == 0)
|
||||
continue;
|
||||
|
||||
if((length= RNA_property_array_length(ptr, prop))) {
|
||||
name= (char*)RNA_property_ui_name(ptr, prop);
|
||||
uiDefBut(block, LABEL, 0, name, x, y, DEF_BUT_WIDTH, DEF_BUT_HEIGHT-1, NULL, 0, 0, 0, 0, "");
|
||||
}
|
||||
else
|
||||
length= 1;
|
||||
|
||||
subtype= RNA_property_subtype(ptr, prop);
|
||||
|
||||
name= (char*)RNA_property_ui_name(ptr, prop);
|
||||
uiDefBut(block, LABEL, 0, name, x, y, DEF_BUT_WIDTH, DEF_BUT_HEIGHT-1, NULL, 0, 0, 0, 0, "");
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
|
||||
if(length <= 16 && subtype == PROP_MATRIX) {
|
||||
/* matrix layout */
|
||||
int size, row, col, butwidth;
|
||||
|
||||
size= ceil(sqrt(length));
|
||||
butwidth= DEF_BUT_WIDTH*2/size;
|
||||
y -= DEF_BUT_HEIGHT;
|
||||
|
||||
for(a=0; a<length; a++) {
|
||||
col= a%size;
|
||||
row= a/size;
|
||||
|
||||
uiDefAutoButR(block, ptr, prop, a, "", x+butwidth*col, y-row*DEF_BUT_HEIGHT, butwidth, DEF_BUT_HEIGHT-1);
|
||||
}
|
||||
|
||||
y -= DEF_BUT_HEIGHT*(length/size);
|
||||
}
|
||||
else if(length <= 4 && ELEM3(subtype, PROP_ROTATION, PROP_VECTOR, PROP_COLOR)) {
|
||||
static char *vectoritem[4]= {"X:", "Y:", "Z:", "W:"};
|
||||
static char *quatitem[4]= {"W:", "X:", "Y:", "Z:"};
|
||||
static char *coloritem[4]= {"R:", "G:", "B:", "A:"};
|
||||
int butwidth;
|
||||
|
||||
butwidth= DEF_BUT_WIDTH*2/length;
|
||||
y -= DEF_BUT_HEIGHT;
|
||||
|
||||
for(a=0; a<length; a++) {
|
||||
if(length == 4 && subtype == PROP_ROTATION)
|
||||
name= quatitem[a];
|
||||
else if(subtype == PROP_VECTOR || subtype == PROP_ROTATION)
|
||||
name= vectoritem[a];
|
||||
else
|
||||
name= coloritem[a];
|
||||
|
||||
uiDefAutoButR(block, ptr, prop, a, name, x+butwidth*a, y, butwidth, DEF_BUT_HEIGHT-1);
|
||||
}
|
||||
y -= DEF_BUT_HEIGHT;
|
||||
}
|
||||
else {
|
||||
if(RNA_property_array_length(ptr, prop)) {
|
||||
sprintf(namebuf, "%d:", a+1);
|
||||
name= namebuf;
|
||||
}
|
||||
else
|
||||
name= "";
|
||||
|
||||
uiDefAutoButR(block, ptr, prop, a, name, x+DEF_BUT_WIDTH, y, DEF_BUT_WIDTH, DEF_BUT_HEIGHT-1);
|
||||
y -= DEF_BUT_HEIGHT;
|
||||
}
|
||||
|
||||
uiBlockEndAlign(block);
|
||||
}
|
||||
|
||||
RNA_property_collection_end(&iter);
|
||||
|
||||
return -y;
|
||||
}
|
||||
|
||||
/***************************** ID Utilities *******************************/
|
||||
|
||||
typedef struct uiIDPoinParams {
|
||||
uiIDPoinFunc func;
|
||||
ID **id_p;
|
||||
short id_code;
|
||||
short browsenr;
|
||||
} uiIDPoinParams;
|
||||
|
||||
static void idpoin_cb(bContext *C, void *arg_params, void *arg_event)
|
||||
{
|
||||
Main *bmain;
|
||||
ListBase *lb;
|
||||
uiIDPoinParams *params= (uiIDPoinParams*)arg_params;
|
||||
uiIDPoinFunc func= params->func;
|
||||
ID **id_p= params->id_p;
|
||||
ID *id= *id_p, *idtest;
|
||||
int nr, event= GET_INT_FROM_POINTER(arg_event);
|
||||
|
||||
bmain= CTX_data_main(C);
|
||||
lb= wich_libbase(bmain, params->id_code);
|
||||
|
||||
switch(event) {
|
||||
case UI_ID_RENAME:
|
||||
if(id) test_idbutton(id->name+2);
|
||||
else return;
|
||||
break;
|
||||
case UI_ID_BROWSE: {
|
||||
if(id==0) id= lb->first;
|
||||
if(id==0) return;
|
||||
|
||||
if(params->browsenr== -2) {
|
||||
/* XXX implement or find a replacement
|
||||
* activate_databrowse((ID *)G.buts->lockpoin, GS(id->name), 0, B_MESHBROWSE, ¶ms->browsenr, do_global_buttons); */
|
||||
return;
|
||||
}
|
||||
if(params->browsenr < 0)
|
||||
return;
|
||||
|
||||
for(idtest=lb->first, nr=1; idtest; idtest=idtest->next, nr++) {
|
||||
if(nr==params->browsenr) {
|
||||
if(id == idtest)
|
||||
return;
|
||||
|
||||
*id_p= idtest;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case UI_ID_DELETE:
|
||||
*id_p= NULL;
|
||||
break;
|
||||
case UI_ID_FAKE_USER:
|
||||
if(id) {
|
||||
if(id->flag & LIB_FAKEUSER) id->us++;
|
||||
else id->us--;
|
||||
}
|
||||
else return;
|
||||
break;
|
||||
case UI_ID_PIN:
|
||||
break;
|
||||
case UI_ID_ADD_NEW:
|
||||
break;
|
||||
case UI_ID_OPEN:
|
||||
break;
|
||||
case UI_ID_ALONE:
|
||||
if(!id || id->us < 1)
|
||||
return;
|
||||
break;
|
||||
case UI_ID_LOCAL:
|
||||
if(!id || id->us < 1)
|
||||
return;
|
||||
break;
|
||||
case UI_ID_AUTO_NAME:
|
||||
break;
|
||||
}
|
||||
|
||||
if(func)
|
||||
func(C, *id_p, event);
|
||||
}
|
||||
|
||||
int uiDefIDPoinButs(uiBlock *block, Main *bmain, ID *parid, ID **id_p, int id_code, short *pin_p, int x, int y, uiIDPoinFunc func, int events)
|
||||
{
|
||||
ListBase *lb;
|
||||
uiBut *but;
|
||||
ID *id= *id_p;
|
||||
uiIDPoinParams *params, *dup_params;
|
||||
char *str=NULL, str1[10];
|
||||
int len, oldcol, add_addbutton=0;
|
||||
|
||||
/* setup struct that we will pass on with the buttons */
|
||||
params= MEM_callocN(sizeof(uiIDPoinParams), "uiIDPoinParams");
|
||||
params->id_p= id_p;
|
||||
params->id_code= id_code;
|
||||
params->func= func;
|
||||
|
||||
lb= wich_libbase(bmain, id_code);
|
||||
|
||||
/* create buttons */
|
||||
uiBlockBeginAlign(block);
|
||||
oldcol= uiBlockGetCol(block);
|
||||
|
||||
if(id && id->us>1)
|
||||
uiBlockSetCol(block, TH_BUT_SETTING1);
|
||||
|
||||
if((events & UI_ID_PIN) && *pin_p)
|
||||
uiBlockSetCol(block, TH_BUT_SETTING2);
|
||||
|
||||
/* pin button */
|
||||
if(id && (events & UI_ID_PIN)) {
|
||||
but= uiDefIconButS(block, ICONTOG, (events & UI_ID_PIN), ICON_KEY_DEHLT, x, y ,DEF_ICON_BUT_WIDTH,DEF_BUT_HEIGHT, pin_p, 0, 0, 0, 0, "Keeps this view displaying the current data regardless of what object is selected");
|
||||
uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_PIN));
|
||||
x+= DEF_ICON_BUT_WIDTH;
|
||||
}
|
||||
|
||||
/* browse menu */
|
||||
if(events & UI_ID_BROWSE) {
|
||||
char *extrastr= NULL;
|
||||
|
||||
if(ELEM4(id_code, ID_MA, ID_TE, ID_BR, ID_PA))
|
||||
add_addbutton= 1;
|
||||
|
||||
if(ELEM8(id_code, ID_SCE, ID_SCR, ID_MA, ID_TE, ID_WO, ID_IP, ID_AC, ID_BR) || id_code == ID_PA)
|
||||
extrastr= "ADD NEW %x 32767";
|
||||
else if(id_code==ID_TXT)
|
||||
extrastr= "OPEN NEW %x 32766 |ADD NEW %x 32767";
|
||||
else if(id_code==ID_SO)
|
||||
extrastr= "OPEN NEW %x 32766";
|
||||
|
||||
/* XXX should be moved out of this function
|
||||
uiBlockSetButLock(block, G.scene->id.lib!=0, "Can't edit external libdata");
|
||||
if( id_code==ID_SCE || id_code==ID_SCR ) uiBlockClearButLock(block); */
|
||||
|
||||
/* XXX should be moved out of this function
|
||||
if(curarea->spacetype==SPACE_BUTS)
|
||||
uiBlockSetButLock(block, id_code!=ID_SCR && G.obedit!=0 && G.buts->mainb==CONTEXT_EDITING, "Cannot perform in EditMode"); */
|
||||
|
||||
if(parid)
|
||||
uiBlockSetButLock(block, parid->lib!=0, "Can't edit external libdata");
|
||||
|
||||
if(lb) {
|
||||
if(id_code!=ID_IM || (events & UI_ID_BROWSE_RENDER))
|
||||
IDnames_to_pupstring(&str, NULL, extrastr, lb, id, ¶ms->browsenr);
|
||||
else
|
||||
IMAnames_to_pupstring(&str, NULL, extrastr, lb, id, ¶ms->browsenr);
|
||||
}
|
||||
|
||||
dup_params= MEM_dupallocN(params);
|
||||
but= uiDefButS(block, MENU, 0, str, x, y, DEF_ICON_BUT_WIDTH, DEF_BUT_HEIGHT, &dup_params->browsenr, 0, 0, 0, 0, "Browse existing choices, or add new");
|
||||
uiButSetNFunc(but, idpoin_cb, dup_params, SET_INT_IN_POINTER(UI_ID_BROWSE));
|
||||
x+= DEF_ICON_BUT_WIDTH;
|
||||
|
||||
uiBlockClearButLock(block);
|
||||
|
||||
MEM_freeN(str);
|
||||
}
|
||||
|
||||
uiBlockSetCol(block, oldcol);
|
||||
|
||||
/* text button with name */
|
||||
if(id) {
|
||||
/* name */
|
||||
if(id->us > 1)
|
||||
uiBlockSetCol(block, TH_BUT_SETTING1);
|
||||
|
||||
/* pinned data? */
|
||||
if((events & UI_ID_PIN) && *pin_p)
|
||||
uiBlockSetCol(block, TH_BUT_SETTING2);
|
||||
|
||||
/* redalert overrides pin color */
|
||||
if(id->us<=0)
|
||||
uiBlockSetCol(block, TH_REDALERT);
|
||||
|
||||
uiBlockSetButLock(block, id->lib!=0, "Can't edit external libdata");
|
||||
|
||||
/* name button */
|
||||
if(GS(id->name)==ID_SCE)
|
||||
strcpy(str1, "SCE:");
|
||||
else if(GS(id->name)==ID_SCE)
|
||||
strcpy(str1, "SCR:");
|
||||
else if(GS(id->name)==ID_MA && ((Material*)id)->use_nodes)
|
||||
strcpy(str1, "NT:");
|
||||
else {
|
||||
str1[0]= id->name[0];
|
||||
str1[1]= id->name[1];
|
||||
str1[2]= ':';
|
||||
str1[3]= 0;
|
||||
}
|
||||
|
||||
if(GS(id->name)==ID_IP) len= 110;
|
||||
else if((y) && (GS(id->name)==ID_AC)) len= 100; // comes from button panel (poselib)
|
||||
else if(y) len= 140; // comes from button panel
|
||||
else len= 120;
|
||||
|
||||
but= uiDefBut(block, TEX, 0, str1,x, y, (short)len, DEF_BUT_HEIGHT, id->name+2, 0.0, 21.0, 0, 0, "Displays current Datablock name. Click to change.");
|
||||
uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_RENAME));
|
||||
|
||||
x+= len;
|
||||
|
||||
uiBlockClearButLock(block);
|
||||
|
||||
/* lib make local button */
|
||||
if(id->lib) {
|
||||
if(id->flag & LIB_INDIRECT) uiDefIconBut(block, BUT, 0, 0 /* XXX ICON_DATALIB */,x,y,DEF_ICON_BUT_WIDTH,DEF_BUT_HEIGHT, 0, 0, 0, 0, 0, "Indirect Library Datablock. Cannot change.");
|
||||
else {
|
||||
but= uiDefIconBut(block, BUT, 0, 0 /* XXX ICON_PARLIB */, x,y,DEF_ICON_BUT_WIDTH,DEF_BUT_HEIGHT, 0, 0, 0, 0, 0,
|
||||
(events & UI_ID_LOCAL)? "Direct linked Library Datablock. Click to make local.": "Direct linked Library Datablock, cannot make local.");
|
||||
uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_ALONE));
|
||||
}
|
||||
|
||||
x+= DEF_ICON_BUT_WIDTH;
|
||||
}
|
||||
|
||||
/* number of users / make local button */
|
||||
if((events & UI_ID_ALONE) && id->us>1) {
|
||||
int butwidth;
|
||||
|
||||
uiBlockSetButLock(block, (events & UI_ID_PIN) && *pin_p, "Can't make pinned data single-user");
|
||||
|
||||
sprintf(str1, "%d", id->us);
|
||||
butwidth= (id->us<10)? DEF_ICON_BUT_WIDTH: DEF_ICON_BUT_WIDTH+10;
|
||||
|
||||
but= uiDefBut(block, BUT, 0, str1, x, y, butwidth, DEF_BUT_HEIGHT, 0, 0, 0, 0, 0, "Displays number of users of this data. Click to make a single-user copy.");
|
||||
uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_ALONE));
|
||||
x+= butwidth;
|
||||
|
||||
uiBlockClearButLock(block);
|
||||
}
|
||||
|
||||
/* delete button */
|
||||
if(events & UI_ID_DELETE) {
|
||||
uiBlockSetButLock(block, (events & UI_ID_PIN) && *pin_p, "Can't unlink pinned data");
|
||||
if(parid && parid->lib);
|
||||
else {
|
||||
but= uiDefIconBut(block, BUT, 0, ICON_X, x,y,DEF_ICON_BUT_WIDTH,DEF_BUT_HEIGHT, 0, 0, 0, 0, 0, "Deletes link to this Datablock");
|
||||
uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_DELETE));
|
||||
x+= DEF_ICON_BUT_WIDTH;
|
||||
}
|
||||
|
||||
uiBlockClearButLock(block);
|
||||
}
|
||||
|
||||
/* auto name button */
|
||||
if(events & UI_ID_AUTO_NAME) {
|
||||
if(parid && parid->lib);
|
||||
else {
|
||||
but= uiDefIconBut(block, BUT, 0, ICON_AUTO,x,y,DEF_ICON_BUT_WIDTH,DEF_BUT_HEIGHT, 0, 0, 0, 0, 0, "Generates an automatic name");
|
||||
uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_AUTO_NAME));
|
||||
x+= DEF_ICON_BUT_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
/* fake user button */
|
||||
if(events & UI_ID_FAKE_USER) {
|
||||
but= uiDefButBitS(block, TOG, LIB_FAKEUSER, 0, "F", x,y,DEF_ICON_BUT_WIDTH,DEF_BUT_HEIGHT, &id->flag, 0, 0, 0, 0, "Saves this datablock even if it has no users");
|
||||
uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_FAKE_USER));
|
||||
x+= DEF_ICON_BUT_WIDTH;
|
||||
}
|
||||
}
|
||||
/* add new button */
|
||||
else if(add_addbutton) {
|
||||
uiBlockSetCol(block, oldcol);
|
||||
if(parid) uiBlockSetButLock(block, parid->lib!=0, "Can't edit external libdata");
|
||||
dup_params= MEM_dupallocN(params);
|
||||
but= uiDefButS(block, TOG, 0, "Add New", x, y, 110, DEF_BUT_HEIGHT, &dup_params->browsenr, params->browsenr, 32767.0, 0, 0, "Add new data block");
|
||||
uiButSetNFunc(but, idpoin_cb, dup_params, SET_INT_IN_POINTER(UI_ID_ADD_NEW));
|
||||
x+= 110;
|
||||
}
|
||||
|
||||
uiBlockSetCol(block, oldcol);
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
MEM_freeN(params);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
@ -487,12 +487,12 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
|
||||
dx= (v2d->cur.xmax - v2d->cur.xmin) * (float)RNA_float_get(op->ptr, "zoomfacx");
|
||||
dy= (v2d->cur.ymax - v2d->cur.ymin) * (float)RNA_float_get(op->ptr, "zoomfacy");
|
||||
|
||||
/* only move view on an axis if change is allowed */
|
||||
if ((v2d->keepzoom & V2D_LOCKOFS_X)==0) {
|
||||
/* only resize view on an axis if change is allowed */
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_X)==0) {
|
||||
v2d->cur.xmin += dx;
|
||||
v2d->cur.xmax -= dx;
|
||||
}
|
||||
if ((v2d->keepzoom & V2D_LOCKOFS_Y)==0) {
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_Y)==0) {
|
||||
v2d->cur.ymin += dy;
|
||||
v2d->cur.ymax -= dy;
|
||||
}
|
||||
|
@ -1895,42 +1895,7 @@ static int check_vnormal_flip(float *n, float *vnorm)
|
||||
}
|
||||
#endif
|
||||
|
||||
void flipface(EditMesh *em, EditFace *efa)
|
||||
{
|
||||
if(efa->v4) {
|
||||
SWAP(EditVert *, efa->v2, efa->v4);
|
||||
SWAP(EditEdge *, efa->e1, efa->e4);
|
||||
SWAP(EditEdge *, efa->e2, efa->e3);
|
||||
EM_data_interp_from_faces(em, efa, NULL, efa, 0, 3, 2, 1);
|
||||
}
|
||||
else {
|
||||
SWAP(EditVert *, efa->v2, efa->v3);
|
||||
SWAP(EditEdge *, efa->e1, efa->e3);
|
||||
efa->e2->dir= 1-efa->e2->dir;
|
||||
EM_data_interp_from_faces(em, efa, NULL, efa, 0, 2, 1, 3);
|
||||
}
|
||||
|
||||
if(efa->v4) CalcNormFloat4(efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co, efa->n);
|
||||
else CalcNormFloat(efa->v1->co, efa->v2->co, efa->v3->co, efa->n);
|
||||
}
|
||||
|
||||
|
||||
void flip_editnormals(EditMesh *em)
|
||||
{
|
||||
EditFace *efa;
|
||||
|
||||
efa= em->faces.first;
|
||||
while(efa) {
|
||||
if( efa->f & SELECT ){
|
||||
flipface(em, efa);
|
||||
}
|
||||
efa= efa->next;
|
||||
}
|
||||
|
||||
/* update vertex normals too */
|
||||
recalc_editnormals(em);
|
||||
|
||||
}
|
||||
|
||||
/* does face centers too */
|
||||
void recalc_editnormals(EditMesh *em)
|
||||
|
@ -52,6 +52,7 @@ editmesh_loop: tools with own drawing subloops, select, knife, subdiv
|
||||
#include "BLI_editVert.h"
|
||||
#include "BLI_ghash.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_displist.h"
|
||||
#include "BKE_global.h"
|
||||
@ -64,9 +65,14 @@ editmesh_loop: tools with own drawing subloops, select, knife, subdiv
|
||||
|
||||
#include "BIF_gl.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_screen.h"
|
||||
#include "ED_view3d.h"
|
||||
|
||||
#include "mesh_intern.h"
|
||||
@ -75,7 +81,6 @@ editmesh_loop: tools with own drawing subloops, select, knife, subdiv
|
||||
static void BIF_undo_push() {}
|
||||
static void BIF_undo() {}
|
||||
static void error() {}
|
||||
static int pupmenu() {return 0;}
|
||||
static int qtest() {return 0;}
|
||||
/* **** XXX ******** */
|
||||
|
||||
@ -427,11 +432,6 @@ typedef struct CutCurve {
|
||||
float y;
|
||||
} CutCurve;
|
||||
|
||||
static CutCurve *get_mouse_trail(int *len, char mode, char cutmode, struct GHash *gh)
|
||||
{
|
||||
return NULL; // XXX
|
||||
}
|
||||
|
||||
|
||||
/* ******************************************************************** */
|
||||
/* Knife Subdivide Tool. Subdivides edges intersected by a mouse trail
|
||||
@ -444,94 +444,24 @@ static CutCurve *get_mouse_trail(int *len, char mode, char cutmode, struct GHash
|
||||
ESC cancels as expected.
|
||||
|
||||
Contributed by Robert Wenzlaff (Det. Thorn).
|
||||
|
||||
2.5 revamp:
|
||||
- non modal (no menu before cutting)
|
||||
- exit on mouse release
|
||||
- polygon/segment drawing can become handled by WM cb later
|
||||
|
||||
*/
|
||||
|
||||
/* prototype */
|
||||
static float seg_intersect(struct EditEdge * e, CutCurve *c, int len, char mode, struct GHash *gh);
|
||||
#define KNIFE_EXACT 1
|
||||
#define KNIFE_MIDPOINT 2
|
||||
#define KNIFE_MULTICUT 3
|
||||
|
||||
void KnifeSubdivide(Object *obedit, EditMesh *em, char mode)
|
||||
{
|
||||
EditEdge *eed;
|
||||
EditVert *eve;
|
||||
CutCurve *curve;
|
||||
|
||||
struct GHash *gh;
|
||||
int len=0;
|
||||
float isect=0.0;
|
||||
short numcuts=1;
|
||||
float *scr, co[4];
|
||||
|
||||
if (em==NULL) return;
|
||||
|
||||
if (EM_nvertices_selected(em) < 2) {
|
||||
error("No edges are selected to operate on");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode==KNIFE_PROMPT) {
|
||||
short val= pupmenu("Cut Type %t|Exact Line%x1|Midpoints%x2|Multicut%x3");
|
||||
if(val<1) return;
|
||||
mode = val; // warning, mode is char, pupmenu returns -1 with ESC
|
||||
}
|
||||
|
||||
if(mode == KNIFE_MULTICUT) {
|
||||
// XXX if(button(&numcuts, 2, 128, "Number of Cuts:")==0) return;
|
||||
}
|
||||
|
||||
/* XXX Set a knife cursor here */
|
||||
|
||||
for(eed=em->edges.first; eed; eed= eed->next) eed->tmp.fp = 0.0; /*store percentage of edge cut for KNIFE_EXACT here.*/
|
||||
|
||||
/*the floating point coordinates of verts in screen space will be stored in a hash table according to the vertices pointer*/
|
||||
gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
|
||||
for(eve=em->verts.first; eve; eve=eve->next){
|
||||
scr = MEM_mallocN(sizeof(float)*2, "Vertex Screen Coordinates");
|
||||
VECCOPY(co, eve->co);
|
||||
co[3]= 1.0;
|
||||
// Mat4MulVec4fl(obedit->obmat, co);
|
||||
// XXX project_float(co,scr);
|
||||
BLI_ghash_insert(gh, eve, scr);
|
||||
eve->f1 = 0; /*store vertex intersection flag here*/
|
||||
|
||||
}
|
||||
|
||||
curve=get_mouse_trail(&len, TRAIL_MIXED, mode, gh);
|
||||
|
||||
if (curve && len && mode){
|
||||
eed= em->edges.first;
|
||||
while(eed) {
|
||||
if( eed->v1->f & eed->v2->f & SELECT ){ // NOTE: uses vertex select, subdiv doesnt do edges yet
|
||||
isect=seg_intersect(eed, curve, len, mode, gh);
|
||||
if (isect) eed->f2= 1;
|
||||
else eed->f2=0;
|
||||
eed->tmp.fp= isect;
|
||||
//printf("isect=%i\n", isect);
|
||||
}
|
||||
else {
|
||||
eed->f2=0;
|
||||
eed->f1=0;
|
||||
}
|
||||
eed= eed->next;
|
||||
}
|
||||
|
||||
if(mode==KNIFE_EXACT) esubdivideflag(obedit, em, SELECT, 0, B_KNIFE|B_PERCENTSUBD,1,SUBDIV_SELECT_ORIG);
|
||||
else if (mode==KNIFE_MIDPOINT) esubdivideflag(obedit, em, SELECT, 0, B_KNIFE,1,SUBDIV_SELECT_ORIG);
|
||||
else if (mode==KNIFE_MULTICUT) esubdivideflag(obedit, em, SELECT, 0, B_KNIFE,numcuts,SUBDIV_SELECT_ORIG);
|
||||
|
||||
eed=em->edges.first;
|
||||
while(eed){
|
||||
eed->f2=0;
|
||||
eed->f1=0;
|
||||
eed=eed->next;
|
||||
}
|
||||
}
|
||||
/* Return to old cursor and flags...*/
|
||||
|
||||
BLI_ghash_free(gh, NULL, (GHashValFreeFP)MEM_freeN);
|
||||
if (curve) MEM_freeN(curve);
|
||||
|
||||
BIF_undo_push("Knife");
|
||||
}
|
||||
static EnumPropertyItem knife_items[]= {
|
||||
{KNIFE_EXACT, "EXACT", "Exact", ""},
|
||||
{KNIFE_MIDPOINT, "MIDPOINTS", "Midpoints", ""},
|
||||
{KNIFE_MULTICUT, "MULTICUT", "Multicut", ""},
|
||||
{0, NULL, NULL}
|
||||
};
|
||||
|
||||
/* seg_intersect() Determines if and where a mouse trail intersects an EditEdge */
|
||||
|
||||
@ -547,7 +477,7 @@ static float seg_intersect(EditEdge *e, CutCurve *c, int len, char mode, struct
|
||||
int i;
|
||||
|
||||
//threshold = 0.000001; /*tolerance for vertex intersection*/
|
||||
// XXX threshold = scene->toolsettings->select_thresh / 100;
|
||||
// XXX threshold = scene->toolsettings->select_thresh / 100;
|
||||
|
||||
/* Get screen coords of verts */
|
||||
scr = BLI_ghash_lookup(gh, e->v1);
|
||||
@ -612,7 +542,7 @@ static float seg_intersect(EditEdge *e, CutCurve *c, int len, char mode, struct
|
||||
|
||||
/* Perp. Distance from point to line */
|
||||
if (m2!=MAXSLOPE) dist=(y12-m2*x12-b2);/* /sqrt(m2*m2+1); Only looking for */
|
||||
/* change in sign. Skip extra math */
|
||||
/* change in sign. Skip extra math */
|
||||
else dist=x22-x12;
|
||||
|
||||
if (i==0) lastdist=dist;
|
||||
@ -635,7 +565,7 @@ static float seg_intersect(EditEdge *e, CutCurve *c, int len, char mode, struct
|
||||
|
||||
/* Found an intersect, calc intersect point */
|
||||
if (m1==m2){ /* co-incident lines */
|
||||
/* cut at 50% of overlap area*/
|
||||
/* cut at 50% of overlap area*/
|
||||
x1max=MAX2(x11, x12);
|
||||
x1min=MIN2(x11, x12);
|
||||
xi= (MIN2(x2max,x1max)+MAX2(x2min,x1min))/2.0;
|
||||
@ -679,6 +609,7 @@ static float seg_intersect(EditEdge *e, CutCurve *c, int len, char mode, struct
|
||||
if ((m2<=1.0)&&(m2>=-1.0)) perc = (xi-x21)/(x22-x21);
|
||||
else perc=(yi-y21)/(y22-y21); /*lower slope more accurate*/
|
||||
//isect=32768.0*(perc+0.0000153); /* Percentage in 1/32768ths */
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -687,27 +618,112 @@ static float seg_intersect(EditEdge *e, CutCurve *c, int len, char mode, struct
|
||||
return(perc);
|
||||
}
|
||||
|
||||
void LoopMenu(Object *obedit, EditMesh *em) /* Called by KKey */
|
||||
|
||||
#define MAX_CUTS 256
|
||||
|
||||
static int knife_cut_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
short ret;
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
EditEdge *eed;
|
||||
EditVert *eve;
|
||||
CutCurve curve[MAX_CUTS];
|
||||
struct GHash *gh;
|
||||
float isect=0.0;
|
||||
float *scr, co[4];
|
||||
int len=0;
|
||||
short numcuts=1, mode= RNA_int_get(op->ptr, "type");
|
||||
|
||||
ret=pupmenu("Loop/Cut Menu %t|Loop Cut (CTRL-R)%x2|"
|
||||
"Knife (Exact) %x3|Knife (Midpoints)%x4|Knife (Multicut)%x5");
|
||||
|
||||
switch (ret){
|
||||
case 2:
|
||||
CutEdgeloop(obedit, em, 1);
|
||||
break;
|
||||
case 3:
|
||||
KnifeSubdivide(obedit, em, KNIFE_EXACT);
|
||||
break;
|
||||
case 4:
|
||||
KnifeSubdivide(obedit, em, KNIFE_MIDPOINT);
|
||||
break;
|
||||
case 5:
|
||||
KnifeSubdivide(obedit, em, KNIFE_MULTICUT);
|
||||
break;
|
||||
if (EM_nvertices_selected(em) < 2) {
|
||||
error("No edges are selected to operate on");
|
||||
return OPERATOR_CANCELLED;;
|
||||
}
|
||||
|
||||
/* get the cut curve */
|
||||
RNA_BEGIN(op->ptr, itemptr, "path") {
|
||||
|
||||
RNA_float_get_array(&itemptr, "loc", (float *)&curve[len]);
|
||||
len++;
|
||||
if(len>= MAX_CUTS) break;
|
||||
}
|
||||
RNA_END;
|
||||
|
||||
if(len<2) return OPERATOR_CANCELLED;
|
||||
|
||||
/*store percentage of edge cut for KNIFE_EXACT here.*/
|
||||
for(eed=em->edges.first; eed; eed= eed->next)
|
||||
eed->tmp.fp = 0.0;
|
||||
|
||||
/*the floating point coordinates of verts in screen space will be stored in a hash table according to the vertices pointer*/
|
||||
gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
|
||||
for(eve=em->verts.first; eve; eve=eve->next){
|
||||
scr = MEM_mallocN(sizeof(float)*2, "Vertex Screen Coordinates");
|
||||
VECCOPY(co, eve->co);
|
||||
co[3]= 1.0;
|
||||
Mat4MulVec4fl(obedit->obmat, co);
|
||||
project_float(ar, co, scr);
|
||||
BLI_ghash_insert(gh, eve, scr);
|
||||
eve->f1 = 0; /*store vertex intersection flag here*/
|
||||
|
||||
}
|
||||
|
||||
eed= em->edges.first;
|
||||
while(eed) {
|
||||
if( eed->v1->f & eed->v2->f & SELECT ){ // NOTE: uses vertex select, subdiv doesnt do edges yet
|
||||
isect= seg_intersect(eed, curve, len, mode, gh);
|
||||
if (isect!=0.0f) eed->f2= 1;
|
||||
else eed->f2=0;
|
||||
eed->tmp.fp= isect;
|
||||
//printf("isect=%i\n", isect);
|
||||
}
|
||||
else {
|
||||
eed->f2=0;
|
||||
eed->f1=0;
|
||||
}
|
||||
eed= eed->next;
|
||||
}
|
||||
|
||||
if (mode==KNIFE_MIDPOINT) esubdivideflag(obedit, em, SELECT, 0, B_KNIFE, 1, SUBDIV_SELECT_ORIG);
|
||||
else if (mode==KNIFE_MULTICUT) esubdivideflag(obedit, em, SELECT, 0, B_KNIFE, numcuts, SUBDIV_SELECT_ORIG);
|
||||
else esubdivideflag(obedit, em, SELECT, 0, B_KNIFE|B_PERCENTSUBD, 1, SUBDIV_SELECT_ORIG);
|
||||
|
||||
eed=em->edges.first;
|
||||
while(eed){
|
||||
eed->f2=0;
|
||||
eed->f1=0;
|
||||
eed=eed->next;
|
||||
}
|
||||
|
||||
BLI_ghash_free(gh, NULL, (GHashValFreeFP)MEM_freeN);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
||||
void MESH_OT_knife_cut(wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
ot->name= "Knife Cut";
|
||||
ot->idname= "MESH_OT_knife_cut";
|
||||
|
||||
ot->invoke= WM_gesture_lines_invoke;
|
||||
ot->modal= WM_gesture_lines_modal;
|
||||
ot->exec= knife_cut_exec;
|
||||
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
RNA_def_enum(ot->srna, "type", knife_items, KNIFE_EXACT, "Type", "");
|
||||
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
|
||||
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
|
||||
|
||||
/* internal */
|
||||
RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
|
||||
}
|
||||
|
||||
/* ******************************************************* */
|
||||
|
||||
|
@ -3355,7 +3355,7 @@ void MESH_OT_select_non_manifold(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
static void selectswap_mesh(EditMesh *em) /* UI level */
|
||||
void EM_select_swap(EditMesh *em) /* exported for UV */
|
||||
{
|
||||
EditVert *eve;
|
||||
EditEdge *eed;
|
||||
@ -3396,7 +3396,7 @@ static int selectswap_mesh_exec(bContext *C, wmOperator *op)
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
selectswap_mesh(em);
|
||||
EM_select_swap(em);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
return OPERATOR_FINISHED;
|
||||
@ -3418,21 +3418,23 @@ void MESH_OT_select_invert(wmOperatorType *ot)
|
||||
|
||||
/* ******************** (de)select all operator **************** */
|
||||
|
||||
void EM_toggle_select_all(EditMesh *em) /* exported for UV */
|
||||
{
|
||||
if(EM_nvertices_selected(em))
|
||||
EM_clear_flag_all(em, SELECT);
|
||||
else
|
||||
EM_set_flag_all(em, SELECT);
|
||||
}
|
||||
|
||||
static int toggle_select_all_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
if( EM_nvertices_selected(em) ) {
|
||||
EM_clear_flag_all(em, SELECT);
|
||||
}
|
||||
else {
|
||||
EM_set_flag_all(em, SELECT);
|
||||
}
|
||||
|
||||
// if (EM_texFaceCheck())
|
||||
EM_toggle_select_all(em);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@ -3853,10 +3855,13 @@ void MESH_OT_selection_type(wmOperatorType *ot)
|
||||
}
|
||||
/* ************************* SEAMS AND EDGES **************** */
|
||||
|
||||
void editmesh_mark_seam(EditMesh *em, int clear)
|
||||
static int editmesh_mark_seam(bContext *C, wmOperator *op)
|
||||
{
|
||||
Mesh *me= NULL; // XXX
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
Mesh *me= ((Mesh *)obedit->data);
|
||||
EditEdge *eed;
|
||||
int clear = RNA_boolean_get(op->ptr, "clear");
|
||||
|
||||
/* auto-enable seams drawing */
|
||||
if(clear==0) {
|
||||
@ -3882,11 +3887,33 @@ void editmesh_mark_seam(EditMesh *em, int clear)
|
||||
}
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void editmesh_mark_sharp(EditMesh *em, int set)
|
||||
void MESH_OT_mark_seam(wmOperatorType *ot)
|
||||
{
|
||||
Mesh *me= NULL;
|
||||
/* identifiers */
|
||||
ot->name= "Mark seam";
|
||||
ot->idname= "MESH_OT_mark_seam";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= editmesh_mark_seam;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
RNA_def_boolean(ot->srna, "clear", 0, "Clear", "");
|
||||
}
|
||||
|
||||
static int editmesh_mark_sharp(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
Mesh *me= ((Mesh *)obedit->data);
|
||||
int set = RNA_boolean_get(op->ptr, "set");
|
||||
EditEdge *eed;
|
||||
|
||||
/* auto-enable sharp edge drawing */
|
||||
@ -3908,6 +3935,25 @@ void editmesh_mark_sharp(EditMesh *em, int set)
|
||||
}
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void MESH_OT_mark_sharp(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Mark sharp";
|
||||
ot->idname= "MESH_OT_mark_sharp";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= editmesh_mark_sharp;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
RNA_def_boolean(ot->srna, "set", 0, "Set", "");
|
||||
}
|
||||
|
||||
void BME_Menu() {
|
||||
@ -3964,10 +4010,10 @@ void Edge_Menu(EditMesh *em)
|
||||
switch(ret)
|
||||
{
|
||||
case 1:
|
||||
editmesh_mark_seam(em, 0);
|
||||
//editmesh_mark_seam(em, 0);
|
||||
break;
|
||||
case 2:
|
||||
editmesh_mark_seam(em, 1);
|
||||
//editmesh_mark_seam(em, 1);
|
||||
break;
|
||||
case 3:
|
||||
// edge_rotate_selected(em, 2);
|
||||
@ -4488,9 +4534,13 @@ void editmesh_align_view_to_selected(Object *obedit, EditMesh *em, View3D *v3d,
|
||||
|
||||
/* **************** VERTEX DEFORMS *************** */
|
||||
|
||||
void vertexsmooth(Object *obedit, EditMesh *em)
|
||||
static int smooth_vertex(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= NULL; // XXX
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
Mesh *me= obedit->data;
|
||||
EditMesh *em= me->edit_mesh;
|
||||
|
||||
EditVert *eve, *eve_mir = NULL;
|
||||
EditEdge *eed;
|
||||
float *adror, *adr, fac;
|
||||
@ -4498,7 +4548,7 @@ void vertexsmooth(Object *obedit, EditMesh *em)
|
||||
int teller=0;
|
||||
ModifierData *md= obedit->modifiers.first;
|
||||
|
||||
if(em==NULL) return;
|
||||
if(em==NULL) return OPERATOR_CANCELLED;
|
||||
|
||||
/* count */
|
||||
eve= em->verts.first;
|
||||
@ -4506,7 +4556,7 @@ void vertexsmooth(Object *obedit, EditMesh *em)
|
||||
if(eve->f & SELECT) teller++;
|
||||
eve= eve->next;
|
||||
}
|
||||
if(teller==0) return;
|
||||
if(teller==0) return OPERATOR_CANCELLED;
|
||||
|
||||
adr=adror= (float *)MEM_callocN(3*sizeof(float *)*teller, "vertsmooth");
|
||||
eve= em->verts.first;
|
||||
@ -4615,8 +4665,25 @@ void vertexsmooth(Object *obedit, EditMesh *em)
|
||||
|
||||
recalc_editnormals(em);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
|
||||
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void MESH_OT_smooth_vertex(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Smooth Vertex";
|
||||
ot->idname= "MESH_OT_smooth_vertex";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= smooth_vertex;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
void vertexnoise(Object *obedit, EditMesh *em)
|
||||
@ -4751,3 +4818,57 @@ void MESH_OT_vertices_to_sphere(wmOperatorType *ot)
|
||||
/* props */
|
||||
RNA_def_float(ot->srna, "percent", 100.0f, 0.0f, 100.0f, "Percent", "DOC_BROKEN", 0.01f, 100.0f);
|
||||
}
|
||||
|
||||
void flipface(EditMesh *em, EditFace *efa)
|
||||
{
|
||||
if(efa->v4) {
|
||||
SWAP(EditVert *, efa->v2, efa->v4);
|
||||
SWAP(EditEdge *, efa->e1, efa->e4);
|
||||
SWAP(EditEdge *, efa->e2, efa->e3);
|
||||
EM_data_interp_from_faces(em, efa, NULL, efa, 0, 3, 2, 1);
|
||||
}
|
||||
else {
|
||||
SWAP(EditVert *, efa->v2, efa->v3);
|
||||
SWAP(EditEdge *, efa->e1, efa->e3);
|
||||
efa->e2->dir= 1-efa->e2->dir;
|
||||
EM_data_interp_from_faces(em, efa, NULL, efa, 0, 2, 1, 3);
|
||||
}
|
||||
|
||||
if(efa->v4) CalcNormFloat4(efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co, efa->n);
|
||||
else CalcNormFloat(efa->v1->co, efa->v2->co, efa->v3->co, efa->n);
|
||||
}
|
||||
|
||||
|
||||
static int flip_editnormals(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
EditFace *efa;
|
||||
|
||||
efa= em->faces.first;
|
||||
while(efa) {
|
||||
if( efa->f & SELECT ){
|
||||
flipface(em, efa);
|
||||
}
|
||||
efa= efa->next;
|
||||
}
|
||||
|
||||
/* update vertex normals too */
|
||||
recalc_editnormals(em);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void MESH_OT_flip_editnormals(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Flip Normals";
|
||||
ot->idname= "MESH_OT_flip_editnormals";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= flip_editnormals;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
/**
|
||||
* $Id:
|
||||
/* $Id:
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
@ -717,10 +716,12 @@ void MESH_OT_extrude(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
void split_mesh(EditMesh *em)
|
||||
static int split_mesh(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
waitcursor(1);
|
||||
WM_cursor_wait(1);
|
||||
|
||||
/* make duplicate first */
|
||||
adduplicateflag(em, SELECT);
|
||||
@ -728,14 +729,40 @@ void split_mesh(EditMesh *em)
|
||||
delfaceflag(em, 128);
|
||||
recalc_editnormals(em);
|
||||
|
||||
waitcursor(0);
|
||||
WM_cursor_wait(0);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
|
||||
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void extrude_repeat_mesh(RegionView3D *rv3d, Object *obedit, EditMesh *em, int steps, float offs)
|
||||
void MESH_OT_split_mesh(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Split Mesh";
|
||||
ot->idname= "MESH_OT_split_mesh";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= split_mesh;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
static int extrude_repeat_mesh(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
RegionView3D *rv3d = CTX_wm_region_view3d(C);
|
||||
|
||||
int steps = RNA_int_get(op->ptr,"steps");
|
||||
|
||||
float offs = RNA_float_get(op->ptr,"offset");
|
||||
|
||||
float dvec[3], tmat[3][3], bmat[3][3], nor[3]= {0.0, 0.0, 0.0};
|
||||
short a;
|
||||
|
||||
@ -762,10 +789,30 @@ void extrude_repeat_mesh(RegionView3D *rv3d, Object *obedit, EditMesh *em, int s
|
||||
|
||||
EM_fgon_flags(em);
|
||||
|
||||
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
|
||||
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void MESH_OT_extrude_repeat(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Extrude Repeat Mesh";
|
||||
ot->idname= "MESH_OT_extrude_repeat";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= extrude_repeat_mesh;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
RNA_def_float(ot->srna, "offset", 2.0f, 0.0f, 100.0f, "Offset", "", 0.0f, FLT_MAX);
|
||||
RNA_def_int(ot->srna, "steps", 10, 0, 180, "Steps", "", 0, INT_MAX);
|
||||
}
|
||||
|
||||
void spin_mesh(View3D *v3d, Object *obedit, EditMesh *em, int steps, float degr, float *dvec, int mode)
|
||||
{
|
||||
Scene *scene= NULL; // XXX from context!
|
||||
@ -1215,11 +1262,12 @@ void fill_mesh(EditMesh *em)
|
||||
|
||||
// XXX option beautyfill */
|
||||
|
||||
waitcursor(0);
|
||||
WM_cursor_wait(0);
|
||||
EM_select_flush(em);
|
||||
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
|
||||
}
|
||||
|
||||
/*GB*/
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
/*--------------------------- Edge Based Subdivide ------------------------------*/
|
||||
@ -3726,9 +3774,14 @@ static void edge_rotate(EditMesh *em, EditEdge *eed,int dir)
|
||||
free_editface(em, face[1]);
|
||||
}
|
||||
|
||||
// XXX ton please check
|
||||
/* only accepts 1 selected edge, or 2 selected faces */
|
||||
void edge_rotate_selected(EditMesh *em, int dir)
|
||||
static int edge_rotate_selected(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
int dir = RNA_int_get(op->ptr,"dir"); // dir == 2 when clockwise and ==1 for counter CW.
|
||||
EditEdge *eed;
|
||||
EditFace *efa;
|
||||
short edgeCount = 0;
|
||||
@ -3762,7 +3815,11 @@ void edge_rotate_selected(EditMesh *em, int dir)
|
||||
}
|
||||
}
|
||||
}
|
||||
else error("Select one edge or two adjacent faces");
|
||||
else
|
||||
{
|
||||
error("Select one edge or two adjacent faces");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
}
|
||||
else if(edgeCount==1) {
|
||||
for(eed= em->edges.first; eed; eed= eed->next) {
|
||||
@ -3773,16 +3830,43 @@ void edge_rotate_selected(EditMesh *em, int dir)
|
||||
}
|
||||
}
|
||||
}
|
||||
else error("Select one edge or two adjacent faces");
|
||||
else
|
||||
{
|
||||
error("Select one edge or two adjacent faces");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
||||
/* flush selected vertices (again) to edges/faces */
|
||||
EM_select_flush(em);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
|
||||
|
||||
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
||||
}
|
||||
|
||||
void MESH_OT_edge_rotate_selected(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Rotate Selected Edge";
|
||||
ot->idname= "MESH_OT_edge_rotate_selected";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= edge_rotate_selected;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
RNA_def_int(ot->srna, "dir", 1, 1, 2, "Direction", "Clockwise and Counter Clockwise", 1, 2);
|
||||
}
|
||||
|
||||
|
||||
/******************* BEVEL CODE STARTS HERE ********************/
|
||||
|
||||
/* XXX old bevel not ported yet */
|
||||
@ -5916,8 +6000,11 @@ void pathselect(EditMesh *em)
|
||||
}
|
||||
}
|
||||
|
||||
void region_to_loop(EditMesh *em)
|
||||
static int region_to_loop(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
EditEdge *eed;
|
||||
EditFace *efa;
|
||||
|
||||
@ -5947,6 +6034,24 @@ void region_to_loop(EditMesh *em)
|
||||
// if (EM_texFaceCheck())
|
||||
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void MESH_OT_region_to_loop(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Region to Loop";
|
||||
ot->idname= "MESH_OT_region_to_loop";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= region_to_loop;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
static int validate_loop(EditMesh *em, Collection *edgecollection)
|
||||
@ -6073,8 +6178,12 @@ static int loop_bisect(EditMesh *em, Collection *edgecollection){
|
||||
else return(2);
|
||||
}
|
||||
|
||||
void loop_to_region(EditMesh *em)
|
||||
static int loop_to_region(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
|
||||
EditFace *efa;
|
||||
ListBase allcollections={NULL,NULL};
|
||||
Collection *edgecollection;
|
||||
@ -6103,13 +6212,34 @@ void loop_to_region(EditMesh *em)
|
||||
|
||||
// if (EM_texFaceCheck())
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void MESH_OT_loop_to_region(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Loop to Region";
|
||||
ot->idname= "MESH_OT_loop_to_region";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= loop_to_region;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
// XXX please check if these functions do what you want them to
|
||||
/* texface and vertex color editmode tools for the face menu */
|
||||
|
||||
void mesh_rotate_uvs(EditMesh *em)
|
||||
static int mesh_rotate_uvs(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
EditFace *efa;
|
||||
short change = 0, ccw;
|
||||
MTFace *tf;
|
||||
@ -6118,7 +6248,7 @@ void mesh_rotate_uvs(EditMesh *em)
|
||||
|
||||
if (!EM_texFaceCheck(em)) {
|
||||
error("mesh has no uv/image layers");
|
||||
return;
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
ccw = (shift);
|
||||
@ -6171,12 +6301,17 @@ void mesh_rotate_uvs(EditMesh *em)
|
||||
|
||||
if (change) {
|
||||
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void mesh_mirror_uvs(EditMesh *em)
|
||||
static int mesh_mirror_uvs(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
EditFace *efa;
|
||||
short change = 0, altaxis;
|
||||
MTFace *tf;
|
||||
@ -6185,7 +6320,7 @@ void mesh_mirror_uvs(EditMesh *em)
|
||||
|
||||
if (!EM_texFaceCheck(em)) {
|
||||
error("mesh has no uv/image layers");
|
||||
return;
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
altaxis = (shift);
|
||||
@ -6253,12 +6388,16 @@ void mesh_mirror_uvs(EditMesh *em)
|
||||
|
||||
if (change) {
|
||||
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
}
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void mesh_rotate_colors(EditMesh *em)
|
||||
static int mesh_rotate_colors(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
EditFace *efa;
|
||||
short change = 0, ccw;
|
||||
MCol tmpcol, *mcol;
|
||||
@ -6266,7 +6405,7 @@ void mesh_rotate_colors(EditMesh *em)
|
||||
|
||||
if (!EM_vertColorCheck(em)) {
|
||||
error("mesh has no color layers");
|
||||
return;
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
ccw = (shift);
|
||||
@ -6302,13 +6441,18 @@ void mesh_rotate_colors(EditMesh *em)
|
||||
|
||||
if (change) {
|
||||
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
||||
void mesh_mirror_colors(EditMesh *em)
|
||||
static int mesh_mirror_colors(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
EditFace *efa;
|
||||
short change = 0, altaxis;
|
||||
MCol tmpcol, *mcol;
|
||||
@ -6316,7 +6460,7 @@ void mesh_mirror_colors(EditMesh *em)
|
||||
|
||||
if (!EM_vertColorCheck(em)) {
|
||||
error("mesh has no color layers");
|
||||
return;
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
altaxis = (shift);
|
||||
@ -6351,7 +6495,66 @@ void mesh_mirror_colors(EditMesh *em)
|
||||
|
||||
if (change) {
|
||||
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void MESH_OT_rotate_uvs(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Rotate UVs";
|
||||
ot->idname= "MESH_OT_rotate_uvs";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= mesh_rotate_uvs;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
void MESH_OT_mirror_uvs(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Mirror UVs";
|
||||
ot->idname= "MESH_OT_mirror_uvs";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= mesh_mirror_uvs;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
void MESH_OT_rotate_colors(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Rotate Colors";
|
||||
ot->idname= "MESH_OT_rotate_colors";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= mesh_rotate_colors;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
void MESH_OT_mirror_colors(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Mirror Colors";
|
||||
ot->idname= "MESH_OT_mirror_colors";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= mesh_mirror_colors;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
static int subdivide_exec(bContext *C, wmOperator *op)
|
||||
@ -6474,39 +6677,29 @@ void MESH_OT_subdivide_smooth(wmOperatorType *ot)
|
||||
|
||||
static int subdivs_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
int items;
|
||||
char *menu, *p;
|
||||
uiMenuItem *head;
|
||||
|
||||
head= uiPupMenuBegin("Subdivision Type", 0);
|
||||
uiMenuItemsEnumO(head, "MESH_OT_subdivs", "type");
|
||||
uiPupMenuEnd(C, head);
|
||||
|
||||
items = 4;
|
||||
|
||||
menu= MEM_callocN(items * OP_MAX_TYPENAME, "string");
|
||||
|
||||
p= menu + sprintf(menu, "%s %%t", "subdiv");
|
||||
p+= sprintf(p, "|%s %%x%d", "simple", 3);
|
||||
p+= sprintf(p, "|%s %%x%d", "multi", 2);
|
||||
p+= sprintf(p, "|%s %%x%d", "fractal", 1);
|
||||
p+= sprintf(p, "|%s %%x%d", "smooth", 0);
|
||||
|
||||
uiPupMenuOperator(C, 20, op, "index", menu);
|
||||
MEM_freeN(menu);
|
||||
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
static int subdivs_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
switch(RNA_int_get(op->ptr, "index"))
|
||||
switch(RNA_int_get(op->ptr, "type"))
|
||||
{
|
||||
case 3: // simple
|
||||
case 0: // simple
|
||||
subdivide_exec(C,op);
|
||||
break;
|
||||
case 2: // multi
|
||||
case 1: // multi
|
||||
subdivide_multi_exec(C,op);
|
||||
break;
|
||||
case 1: // fractal;
|
||||
case 2: // fractal;
|
||||
subdivide_multi_fractal_exec(C,op);
|
||||
break;
|
||||
case 0: //smooth
|
||||
case 3: //smooth
|
||||
subdivide_smooth_exec(C,op);
|
||||
break;
|
||||
}
|
||||
@ -6516,6 +6709,13 @@ static int subdivs_exec(bContext *C, wmOperator *op)
|
||||
|
||||
void MESH_OT_subdivs(wmOperatorType *ot)
|
||||
{
|
||||
static EnumPropertyItem type_items[]= {
|
||||
{0, "SIMPLE", "Simple", ""},
|
||||
{1, "MULTI", "Multi", ""},
|
||||
{2, "FRACTAL", "Fractal", ""},
|
||||
{3, "SMOOTH", "Smooth", ""},
|
||||
{0, NULL, NULL}};
|
||||
|
||||
/* identifiers */
|
||||
ot->name= "subdivs";
|
||||
ot->idname= "MESH_OT_subdivs";
|
||||
@ -6530,7 +6730,7 @@ void MESH_OT_subdivs(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/*props */
|
||||
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000);
|
||||
RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "");
|
||||
|
||||
/* this is temp, the ops are different, but they are called from subdivs, so all the possible props should be here as well*/
|
||||
RNA_def_int(ot->srna, "number_cuts", 4, 0, 100, "Number of Cuts", "", 0, INT_MAX);
|
||||
|
@ -168,14 +168,10 @@ extern struct EditFace *EM_face_from_faces(EditMesh *em, struct EditFace *efa1,
|
||||
|
||||
/* ******************* editmesh_loop.c */
|
||||
|
||||
#define KNIFE_PROMPT 0
|
||||
#define KNIFE_EXACT 1
|
||||
#define KNIFE_MIDPOINT 2
|
||||
#define KNIFE_MULTICUT 3
|
||||
|
||||
#define LOOP_SELECT 1
|
||||
#define LOOP_CUT 2
|
||||
|
||||
void MESH_OT_knife_cut(struct wmOperatorType *ot);
|
||||
|
||||
/* ******************* editmesh_mods.c */
|
||||
void MESH_OT_loop_select(struct wmOperatorType *ot);
|
||||
@ -200,6 +196,10 @@ void MESH_OT_select_random(struct wmOperatorType *ot);
|
||||
void MESH_OT_vertices_to_sphere(struct wmOperatorType *ot);
|
||||
void MESH_OT_selection_type(struct wmOperatorType *ot);
|
||||
void MESH_OT_select_multi_loop(struct wmOperatorType *ot);
|
||||
void MESH_OT_mark_seam(struct wmOperatorType *ot);
|
||||
void MESH_OT_mark_sharp(struct wmOperatorType *ot);
|
||||
void MESH_OT_smooth_vertex(struct wmOperatorType *ot);
|
||||
void MESH_OT_flip_editnormals(struct wmOperatorType *ot);
|
||||
|
||||
extern EditEdge *findnearestedge(struct ViewContext *vc, int *dist);
|
||||
extern void EM_automerge(int update);
|
||||
@ -247,6 +247,16 @@ void MESH_OT_convert_tris_to_quads(struct wmOperatorType *ot);
|
||||
void MESH_OT_edge_flip(struct wmOperatorType *ot);
|
||||
void MESH_OT_faces_shade_smooth(struct wmOperatorType *ot);
|
||||
void MESH_OT_faces_shade_solid(struct wmOperatorType *ot);
|
||||
void MESH_OT_split_mesh(struct wmOperatorType *ot);
|
||||
void MESH_OT_extrude_repeat(struct wmOperatorType *ot);
|
||||
void MESH_OT_edge_rotate_selected(struct wmOperatorType *ot);
|
||||
void MESH_OT_loop_to_region(struct wmOperatorType *ot);
|
||||
void MESH_OT_region_to_loop(struct wmOperatorType *ot);
|
||||
|
||||
void MESH_OT_rotate_uvs(struct wmOperatorType *ot);
|
||||
void MESH_OT_mirror_uvs(struct wmOperatorType *ot);
|
||||
void MESH_OT_rotate_colors(struct wmOperatorType *ot);
|
||||
void MESH_OT_mirror_colors(struct wmOperatorType *ot);
|
||||
|
||||
void MESH_OT_delete(struct wmOperatorType *ot);
|
||||
|
||||
|
@ -107,7 +107,6 @@ static void MESH_OT_add_duplicate(wmOperatorType *ot)
|
||||
void ED_operatortypes_mesh(void)
|
||||
{
|
||||
WM_operatortype_append(MESH_OT_de_select_all);
|
||||
WM_operatortype_append(MESH_OT_bmesh_test);
|
||||
WM_operatortype_append(MESH_OT_select_more);
|
||||
WM_operatortype_append(MESH_OT_select_less);
|
||||
WM_operatortype_append(MESH_OT_select_invert);
|
||||
@ -142,7 +141,17 @@ void ED_operatortypes_mesh(void)
|
||||
WM_operatortype_append(MESH_OT_removedoublesflag);
|
||||
WM_operatortype_append(MESH_OT_extrude);
|
||||
WM_operatortype_append(MESH_OT_vertices_to_sphere);
|
||||
|
||||
WM_operatortype_append(MESH_OT_split_mesh);
|
||||
WM_operatortype_append(MESH_OT_extrude_repeat);
|
||||
WM_operatortype_append(MESH_OT_edge_rotate_selected);
|
||||
WM_operatortype_append(MESH_OT_loop_to_region);
|
||||
WM_operatortype_append(MESH_OT_region_to_loop);
|
||||
|
||||
WM_operatortype_append(MESH_OT_rotate_uvs);
|
||||
WM_operatortype_append(MESH_OT_mirror_uvs);
|
||||
WM_operatortype_append(MESH_OT_rotate_colors);
|
||||
WM_operatortype_append(MESH_OT_mirror_colors);
|
||||
|
||||
WM_operatortype_append(MESH_OT_fill);
|
||||
WM_operatortype_append(MESH_OT_beauty_fill);
|
||||
WM_operatortype_append(MESH_OT_convert_quads_to_tris);
|
||||
@ -162,7 +171,11 @@ void ED_operatortypes_mesh(void)
|
||||
WM_operatortype_append(MESH_OT_similar_edge_select);
|
||||
WM_operatortype_append(MESH_OT_similar_face_select);
|
||||
WM_operatortype_append(MESH_OT_select_multi_loop);
|
||||
WM_operatortype_append(MESH_OT_separate);
|
||||
WM_operatortype_append(MESH_OT_mark_seam);
|
||||
WM_operatortype_append(MESH_OT_mark_sharp);
|
||||
WM_operatortype_append(MESH_OT_smooth_vertex);
|
||||
WM_operatortype_append(MESH_OT_flip_editnormals);
|
||||
WM_operatortype_append(MESH_OT_knife_cut);
|
||||
|
||||
}
|
||||
|
||||
@ -186,7 +199,6 @@ void ED_keymap_mesh(wmWindowManager *wm)
|
||||
WM_keymap_add_item(keymap, "MESH_OT_shortest_path_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "MESH_OT_de_select_all", AKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_bmesh_test", JKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_select_invert", IKEY, KM_PRESS, KM_CTRL, 0);
|
||||
@ -201,7 +213,17 @@ void ED_keymap_mesh(wmWindowManager *wm)
|
||||
|
||||
WM_keymap_add_item(keymap, "MESH_OT_select_random", SPACEKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_vertices_to_sphere", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT , 0);
|
||||
|
||||
|
||||
WM_keymap_add_item(keymap, "MESH_OT_mark_seam", ONEKEY, KM_PRESS, KM_CTRL , 0);
|
||||
RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_mark_seam", ONEKEY, KM_PRESS, KM_ALT , 0)->ptr,"clear",1);
|
||||
|
||||
WM_keymap_add_item(keymap, "MESH_OT_mark_sharp", TWOKEY, KM_PRESS, KM_CTRL , 0);
|
||||
RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_mark_sharp", TWOKEY, KM_PRESS, KM_ALT , 0)->ptr,"set",1);
|
||||
|
||||
WM_keymap_add_item(keymap, "MESH_OT_smooth_vertex", THREEKEY, KM_PRESS, KM_CTRL , 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "MESH_OT_flip_editnormals", THREEKEY, KM_PRESS, KM_ALT , 0);
|
||||
|
||||
/* temp hotkeys! */
|
||||
WM_keymap_add_item(keymap, "MESH_OT_similar_vertex_select", GKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_similar_edge_select", GKEY, KM_PRESS, KM_SHIFT2|KM_CTRL, 0);
|
||||
@ -233,6 +255,21 @@ void ED_keymap_mesh(wmWindowManager *wm)
|
||||
WM_keymap_add_item(keymap, "MESH_OT_convert_quads_to_tris", TKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_convert_tris_to_quads", JKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "MESH_OT_split_mesh", FOURKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_extrude_repeat", FOURKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_edge_rotate_selected", FIVEKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "MESH_OT_loop_to_region",SIXKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_region_to_loop",SIXKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "MESH_OT_rotate_uvs",SEVENKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_mirror_uvs",SEVENKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_rotate_colors",EIGHTKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_mirror_colors",EIGHTKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
/* add/remove */
|
||||
WM_keymap_add_item(keymap, "MESH_OT_add_edge_face", FKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_add_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
@ -246,6 +283,9 @@ void ED_keymap_mesh(wmWindowManager *wm)
|
||||
WM_keymap_add_item(keymap, "MESH_OT_make_fgon", FKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_clear_fgon", FKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "MESH_OT_knife_cut", LEFTMOUSE, KM_PRESS, KM_ALT|KM_CTRL, 0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -479,17 +479,17 @@ void OBJECT_OT_curve_add(wmOperatorType *ot)
|
||||
|
||||
static int object_add_primitive_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
uiMenuItem *head= uiPupMenuBegin("Add Object");
|
||||
uiMenuItem *head= uiPupMenuBegin("Add Object", 0);
|
||||
|
||||
uiMenuLevelEnumO(head, "OBJECT_OT_mesh_add", "type");
|
||||
uiMenuLevelEnumO(head, "OBJECT_OT_curve_add", "type");
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_SURF);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_MBALL);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_CAMERA);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_LAMP);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_EMPTY);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_ARMATURE);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_LATTICE);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_SURF);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_MBALL);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_CAMERA);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_LAMP);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_EMPTY);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_ARMATURE);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_LATTICE);
|
||||
|
||||
uiPupMenuEnd(C, head);
|
||||
|
||||
@ -526,70 +526,53 @@ void ED_base_object_free_and_unlink(Scene *scene, Base *base)
|
||||
MEM_freeN(base);
|
||||
}
|
||||
|
||||
void delete_obj(Scene *scene, View3D *v3d, int ok)
|
||||
static int object_delete_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Base *base, *nbase;
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
int islamp= 0;
|
||||
|
||||
if(scene->obedit) return; // XXX get from context
|
||||
if(scene->id.lib) return;
|
||||
if(CTX_data_edit_object(C))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
ED_view3d_exit_paint_modes(C);
|
||||
|
||||
for(base= FIRSTBASE; base; base= nbase) {
|
||||
nbase= base->next;
|
||||
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
|
||||
|
||||
if(TESTBASE(v3d, base)) {
|
||||
if(ok==0) {
|
||||
int shift= 0; // XXX
|
||||
/* Shift Del is global delete */
|
||||
if (shift) {
|
||||
if(!okee("Erase selected Object(s) Globally")) return;
|
||||
ok= 2;
|
||||
} else {
|
||||
if(!okee("Erase selected Object(s)")) return;
|
||||
ok= 1;
|
||||
}
|
||||
}
|
||||
|
||||
// ED_view3d_exit_paint_modes(C);
|
||||
|
||||
if(base->object->type==OB_LAMP) islamp= 1;
|
||||
|
||||
if (ok==2) {
|
||||
Scene *scene;
|
||||
Base *base_other;
|
||||
|
||||
for (scene= G.main->scene.first; scene; scene= scene->id.next) {
|
||||
if (scene != scene && !(scene->id.lib)) {
|
||||
base_other= object_in_scene( base->object, scene );
|
||||
if (base_other) {
|
||||
ED_base_object_free_and_unlink( scene, base_other );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* remove from current scene only */
|
||||
ED_base_object_free_and_unlink(scene, base);
|
||||
}
|
||||
if(base->object->type==OB_LAMP) islamp= 1;
|
||||
|
||||
/* remove from current scene only */
|
||||
ED_base_object_free_and_unlink(scene, base);
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
if(islamp) reshadeall_displist(scene); /* only frees displist */
|
||||
|
||||
// XXX redraw_test_buttons(OBACT);
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
allqueue (REDRAWACTION, 0);
|
||||
allqueue(REDRAWIPO, 0);
|
||||
allqueue(REDRAWDATASELECT, 0);
|
||||
// allspace(OOPS_TEST, 0);
|
||||
allqueue(REDRAWOOPS, 0);
|
||||
allqueue(REDRAWACTION, 0);
|
||||
allqueue(REDRAWNLA, 0);
|
||||
|
||||
DAG_scene_sort(scene);
|
||||
ED_anim_dag_flush_update(C);
|
||||
|
||||
ED_anim_dag_flush_update(C);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, CTX_data_scene(C));
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void OBJECT_OT_delete(wmOperatorType *ot)
|
||||
{
|
||||
|
||||
/* identifiers */
|
||||
ot->name= "Delete Objects";
|
||||
ot->idname= "OBJECT_OT_delete";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= WM_operator_confirm;
|
||||
ot->exec= object_delete_exec;
|
||||
ot->poll= ED_operator_scene_editable;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void single_object_users__forwardModifierLinks(void *userData, Object *ob, Object **obpoin)
|
||||
{
|
||||
ID_NEW(*obpoin);
|
||||
@ -1686,17 +1669,7 @@ static int object_clear_location_exec(bContext *C, wmOperator *op)
|
||||
int armature_clear= 0;
|
||||
|
||||
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
||||
if ((ob->flag & OB_POSEMODE)) {
|
||||
/* only clear pose transforms if:
|
||||
* - with a mesh in weightpaint mode, it's related armature needs to be cleared
|
||||
* - with clearing transform of object being edited at the time
|
||||
*/
|
||||
if ((G.f & G_WEIGHTPAINT) || (ob==OBACT)) {
|
||||
clear_armature(scene, ob, 'g');
|
||||
armature_clear= 1; /* silly system to prevent another dag update, so no action applied */
|
||||
}
|
||||
}
|
||||
else if((G.f & G_WEIGHTPAINT)==0) {
|
||||
if((G.f & G_WEIGHTPAINT)==0) {
|
||||
if ((ob->protectflag & OB_LOCK_LOCX)==0)
|
||||
ob->loc[0]= ob->dloc[0]= 0.0f;
|
||||
if ((ob->protectflag & OB_LOCK_LOCY)==0)
|
||||
@ -1739,17 +1712,7 @@ static int object_clear_rotation_exec(bContext *C, wmOperator *op)
|
||||
int armature_clear= 0;
|
||||
|
||||
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
||||
if ((ob->flag & OB_POSEMODE)) {
|
||||
/* only clear pose transforms if:
|
||||
* - with a mesh in weightpaint mode, it's related armature needs to be cleared
|
||||
* - with clearing transform of object being edited at the time
|
||||
*/
|
||||
if ((G.f & G_WEIGHTPAINT) || (ob==OBACT)) {
|
||||
clear_armature(scene, ob, 'r');
|
||||
armature_clear= 1; /* silly system to prevent another dag update, so no action applied */
|
||||
}
|
||||
}
|
||||
else if((G.f & G_WEIGHTPAINT)==0) {
|
||||
if((G.f & G_WEIGHTPAINT)==0) {
|
||||
/* eulers can only get cleared if they are not protected */
|
||||
if ((ob->protectflag & OB_LOCK_ROTX)==0)
|
||||
ob->rot[0]= ob->drot[0]= 0.0f;
|
||||
@ -1793,17 +1756,7 @@ static int object_clear_scale_exec(bContext *C, wmOperator *op)
|
||||
int armature_clear= 0;
|
||||
|
||||
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
||||
if ((ob->flag & OB_POSEMODE)) {
|
||||
/* only clear pose transforms if:
|
||||
* - with a mesh in weightpaint mode, it's related armature needs to be cleared
|
||||
* - with clearing transform of object being edited at the time
|
||||
*/
|
||||
if ((G.f & G_WEIGHTPAINT) || (ob==OBACT)) {
|
||||
clear_armature(scene, ob, 's');
|
||||
armature_clear= 1; /* silly system to prevent another dag update, so no action applied */
|
||||
}
|
||||
}
|
||||
else if((G.f & G_WEIGHTPAINT)==0) {
|
||||
if((G.f & G_WEIGHTPAINT)==0) {
|
||||
if ((ob->protectflag & OB_LOCK_SCALEX)==0) {
|
||||
ob->dsize[0]= 0.0f;
|
||||
ob->size[0]= 1.0f;
|
||||
@ -2452,23 +2405,23 @@ static int make_parent_exec(bContext *C, wmOperator *op)
|
||||
static int make_parent_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
Object *ob= CTX_data_active_object(C);
|
||||
uiMenuItem *head= uiPupMenuBegin("Make Parent To");
|
||||
uiMenuItem *head= uiPupMenuBegin("Make Parent To", 0);
|
||||
|
||||
uiMenuContext(head, WM_OP_EXEC_DEFAULT);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_OBJECT);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_OBJECT);
|
||||
|
||||
/* ob becomes parent, make the associated menus */
|
||||
if(ob->type==OB_ARMATURE) {
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_ARMATURE);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_BONE);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_ARMATURE);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_BONE);
|
||||
}
|
||||
else if(ob->type==OB_CURVE) {
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_CURVE);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_FOLLOW);
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_PATH_CONST);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_CURVE);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_FOLLOW);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_PATH_CONST);
|
||||
}
|
||||
else if(ob->type == OB_LATTICE) {
|
||||
uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_LATTICE);
|
||||
uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_LATTICE);
|
||||
}
|
||||
|
||||
uiPupMenuEnd(C, head);
|
||||
@ -3118,6 +3071,8 @@ void ED_object_enter_editmode(bContext *C, int flag)
|
||||
}
|
||||
|
||||
if(flag & EM_WAITCURSOR) waitcursor(1);
|
||||
|
||||
ED_view3d_exit_paint_modes(C);
|
||||
|
||||
if(ob->type==OB_MESH) {
|
||||
Mesh *me= ob->data;
|
||||
|
@ -65,6 +65,7 @@ void OBJECT_OT_set_center(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_make_dupli_real(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_object_add(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_add_duplicate(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_delete(struct wmOperatorType *ot);
|
||||
|
||||
void OBJECT_OT_mesh_add(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_curve_add(struct wmOperatorType *ot);
|
||||
|
@ -89,7 +89,8 @@ void ED_operatortypes_object(void)
|
||||
WM_operatortype_append(GROUP_OT_group_remove);
|
||||
WM_operatortype_append(GROUP_OT_objects_add_active);
|
||||
WM_operatortype_append(GROUP_OT_objects_remove_active);
|
||||
|
||||
|
||||
WM_operatortype_append(OBJECT_OT_delete);
|
||||
WM_operatortype_append(OBJECT_OT_mesh_add);
|
||||
WM_operatortype_append(OBJECT_OT_curve_add);
|
||||
WM_operatortype_append(OBJECT_OT_object_add);
|
||||
@ -127,6 +128,7 @@ void ED_keymap_object(wmWindowManager *wm)
|
||||
WM_keymap_verify_item(keymap, "OBJECT_OT_clear_restrictview", HKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_verify_item(keymap, "OBJECT_OT_set_restrictview", HKEY, KM_PRESS, 0, 0);
|
||||
|
||||
WM_keymap_verify_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_verify_item(keymap, "OBJECT_OT_primitive_add", AKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_verify_item(keymap, "OBJECT_OT_add_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
|
@ -48,6 +48,7 @@ CPPFLAGS += -I../../makesdna
|
||||
CPPFLAGS += -I../../makesrna
|
||||
CPPFLAGS += -I../../imbuf
|
||||
CPPFLAGS += -I../../python
|
||||
CPPFLAGS += -I../../render/extern/include
|
||||
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
|
||||
|
||||
# own include
|
||||
|
@ -5,6 +5,7 @@ sources = env.Glob('*.c')
|
||||
|
||||
incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
|
||||
incs += ' ../../blenloader ../../windowmanager ../../python ../../makesrna'
|
||||
incs += ' ../../render/extern/include'
|
||||
incs += ' #/intern/guardedalloc #/extern/glew/include #intern/bmfont'
|
||||
|
||||
defs = ''
|
||||
|
@ -109,6 +109,10 @@ void ED_region_do_listen(ARegion *ar, wmNotifier *note)
|
||||
{
|
||||
/* generic notes first */
|
||||
switch(note->category) {
|
||||
case NC_WM:
|
||||
if(note->data==ND_FILEREAD)
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
case NC_WINDOW:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
@ -640,6 +644,8 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space)
|
||||
BKE_spacedata_copylist(&sa1->spacedata, &sa2->spacedata);
|
||||
}
|
||||
|
||||
/* Note; SPACE_EMPTY is possible on new screens */
|
||||
|
||||
/* regions */
|
||||
st= BKE_spacetype_from_id(sa1->spacetype);
|
||||
for(ar= sa1->regionbase.first; ar; ar= ar->next)
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "DNA_vec_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_texture_types.h"
|
||||
#include "DNA_userdef_types.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
@ -38,7 +40,9 @@
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_library.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_node.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "BIF_gl.h"
|
||||
@ -408,6 +412,7 @@ bScreen *screen_add(wmWindow *win, Scene *scene, char *name)
|
||||
sc= alloc_libblock(&G.main->screen, ID_SCR, name);
|
||||
sc->scene= scene;
|
||||
sc->do_refresh= 1;
|
||||
sc->winid= win->winid;
|
||||
|
||||
sv1= screen_addvert(sc, 0, 0);
|
||||
sv2= screen_addvert(sc, 0, win->sizey-1);
|
||||
@ -904,6 +909,10 @@ bScreen *ED_screen_duplicate(wmWindow *win, bScreen *sc)
|
||||
/* set in window */
|
||||
win->screen= newsc;
|
||||
|
||||
/* store identifier */
|
||||
win->screen->winid= win->winid;
|
||||
BLI_strncpy(win->screenname, win->screen->id.name+2, 21);
|
||||
|
||||
return newsc;
|
||||
}
|
||||
|
||||
@ -931,6 +940,10 @@ void ED_screen_do_listen(wmWindow *win, wmNotifier *note)
|
||||
|
||||
/* generic notes */
|
||||
switch(note->category) {
|
||||
case NC_WM:
|
||||
if(note->data==ND_FILEREAD)
|
||||
win->screen->do_draw= 1;
|
||||
break;
|
||||
case NC_WINDOW:
|
||||
win->screen->do_draw= 1;
|
||||
break;
|
||||
@ -988,7 +1001,7 @@ void ED_screen_draw(wmWindow *win)
|
||||
scrarea_draw_shape_light(sa1, dira);
|
||||
}
|
||||
|
||||
if(G.f & G_DEBUG) printf("draw screen\n");
|
||||
// if(G.f & G_DEBUG) printf("draw screen\n");
|
||||
win->screen->do_draw= 0;
|
||||
}
|
||||
|
||||
@ -1081,12 +1094,20 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
|
||||
WM_event_remove_window_timer(window, screen->animtimer);
|
||||
screen->animtimer= NULL;
|
||||
|
||||
if(screen->mainwin)
|
||||
wm_subwindow_close(window, screen->mainwin);
|
||||
screen->mainwin= 0;
|
||||
screen->subwinactive= 0;
|
||||
|
||||
for(ar= screen->regionbase.first; ar; ar= ar->next)
|
||||
ED_region_exit(C, ar);
|
||||
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next)
|
||||
ED_area_exit(C, sa);
|
||||
|
||||
/* mark it available for use for other windows */
|
||||
screen->winid= 0;
|
||||
|
||||
CTX_wm_window_set(C, prevwin);
|
||||
}
|
||||
|
||||
@ -1188,24 +1209,35 @@ int ED_screen_area_active(const bContext *C)
|
||||
|
||||
/* operator call, WM + Window + screen already existed before */
|
||||
/* Do NOT call in area/region queues! */
|
||||
void ed_screen_set(bContext *C, bScreen *sc)
|
||||
void ED_screen_set(bContext *C, bScreen *sc)
|
||||
{
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
bScreen *oldscreen= CTX_wm_screen(C);
|
||||
ID *id;
|
||||
|
||||
/* validate screen, it's called with notifier reference */
|
||||
for(id= CTX_data_main(C)->screen.first; id; id= id->next)
|
||||
if(sc == (bScreen *)id)
|
||||
break;
|
||||
if(id==NULL)
|
||||
return;
|
||||
|
||||
/* check for valid winid */
|
||||
if(sc->winid!=0 && sc->winid!=win->winid)
|
||||
return;
|
||||
|
||||
if(sc->full) { /* find associated full */
|
||||
bScreen *sc1;
|
||||
for(sc1= G.main->screen.first; sc1; sc1= sc1->id.next) {
|
||||
for(sc1= CTX_data_main(C)->screen.first; sc1; sc1= sc1->id.next) {
|
||||
ScrArea *sa= sc1->areabase.first;
|
||||
if(sa->full==sc) {
|
||||
sc= sc1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(sc1==NULL) printf("set screen error\n");
|
||||
}
|
||||
|
||||
if (oldscreen != sc) {
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
wmTimer *wt= oldscreen->animtimer;
|
||||
|
||||
/* we put timer to sleep, so screen_exit has to think there's no timer */
|
||||
@ -1219,16 +1251,77 @@ void ed_screen_set(bContext *C, bScreen *sc)
|
||||
win->screen= sc;
|
||||
CTX_wm_window_set(C, win); // stores C->wm.screen... hrmf
|
||||
|
||||
/* prevent multiwin errors */
|
||||
sc->winid= win->winid;
|
||||
|
||||
ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C));
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* only call outside of area/region loops */
|
||||
void ED_screen_set_scene(bContext *C, Scene *scene)
|
||||
{
|
||||
bScreen *sc;
|
||||
bScreen *curscreen= CTX_wm_screen(C);
|
||||
|
||||
for(sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) {
|
||||
if((U.flag & USER_SCENEGLOBAL) || sc==curscreen) {
|
||||
|
||||
if(scene != sc->scene) {
|
||||
/* all areas endlocalview */
|
||||
// XXX ScrArea *sa= sc->areabase.first;
|
||||
// while(sa) {
|
||||
// endlocalview(sa);
|
||||
// sa= sa->next;
|
||||
// }
|
||||
sc->scene= scene;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// copy_view3d_lock(0); /* space.c */
|
||||
|
||||
/* are there cameras in the views that are not in the scene? */
|
||||
for(sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) {
|
||||
if( (U.flag & USER_SCENEGLOBAL) || sc==curscreen) {
|
||||
ScrArea *sa= sc->areabase.first;
|
||||
while(sa) {
|
||||
SpaceLink *sl= sa->spacedata.first;
|
||||
while(sl) {
|
||||
if(sl->spacetype==SPACE_VIEW3D) {
|
||||
View3D *v3d= (View3D*) sl;
|
||||
if (!v3d->camera || !object_in_scene(v3d->camera, scene)) {
|
||||
v3d->camera= scene_find_camera(sc->scene);
|
||||
// XXX if (sc==curscreen) handle_view3d_lock();
|
||||
if (!v3d->camera && v3d->persp==V3D_CAMOB)
|
||||
v3d->persp= V3D_PERSP;
|
||||
}
|
||||
}
|
||||
sl= sl->next;
|
||||
}
|
||||
sa= sa->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CTX_data_scene_set(C, scene);
|
||||
set_scene_bg(scene);
|
||||
|
||||
ED_update_for_newframe(C, 1);
|
||||
|
||||
// set_radglobal();
|
||||
|
||||
/* complete redraw */
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
|
||||
}
|
||||
|
||||
/* this function toggles: if area is full then the parent will be restored */
|
||||
void ed_screen_fullarea(bContext *C)
|
||||
void ed_screen_fullarea(bContext *C, ScrArea *sa)
|
||||
{
|
||||
bScreen *sc, *oldscreen;
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
|
||||
if(sa==NULL) {
|
||||
return;
|
||||
@ -1260,7 +1353,7 @@ void ed_screen_fullarea(bContext *C)
|
||||
// in autoplay screens the headers are disabled by
|
||||
// default. So use the old headertype instead
|
||||
|
||||
area_copy_data(old, CTX_wm_area(C), 1); /* 1 = swap spacelist */
|
||||
area_copy_data(old, sa, 1); /* 1 = swap spacelist */
|
||||
|
||||
old->full= NULL;
|
||||
|
||||
@ -1268,10 +1361,10 @@ void ed_screen_fullarea(bContext *C)
|
||||
sc->animtimer= oldscreen->animtimer;
|
||||
oldscreen->animtimer= NULL;
|
||||
|
||||
ed_screen_set(C, sc);
|
||||
ED_screen_set(C, sc);
|
||||
|
||||
free_screen(oldscreen);
|
||||
free_libblock(&G.main->screen, oldscreen);
|
||||
free_libblock(&CTX_data_main(C)->screen, oldscreen);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -1280,12 +1373,13 @@ void ed_screen_fullarea(bContext *C)
|
||||
oldscreen= CTX_wm_screen(C);
|
||||
|
||||
/* is there only 1 area? */
|
||||
if(oldscreen->areabase.first==CTX_wm_screen(C)->areabase.last) return;
|
||||
if(CTX_wm_area(C)->spacetype==SPACE_INFO) return;
|
||||
if(oldscreen->areabase.first==oldscreen->areabase.last) return;
|
||||
if(sa->spacetype==SPACE_INFO) return;
|
||||
|
||||
oldscreen->full = SCREENFULL;
|
||||
|
||||
sc= screen_add(CTX_wm_window(C), CTX_data_scene(C), "temp");
|
||||
sc->full = SCREENFULL; // XXX
|
||||
|
||||
/* timer */
|
||||
sc->animtimer= oldscreen->animtimer;
|
||||
@ -1297,13 +1391,13 @@ void ed_screen_fullarea(bContext *C)
|
||||
|
||||
/* copy area */
|
||||
newa= newa->prev;
|
||||
area_copy_data(newa, CTX_wm_area(C), 1); /* 1 = swap spacelist */
|
||||
area_copy_data(newa, sa, 1); /* 1 = swap spacelist */
|
||||
|
||||
CTX_wm_area(C)->full= oldscreen;
|
||||
sa->full= oldscreen;
|
||||
newa->full= oldscreen;
|
||||
newa->next->full= oldscreen;
|
||||
newa->next->full= oldscreen; // XXX
|
||||
|
||||
ed_screen_set(C, sc);
|
||||
ED_screen_set(C, sc);
|
||||
}
|
||||
|
||||
/* XXX bad code: setscreen() ends with first area active. fullscreen render assumes this too */
|
||||
@ -1313,12 +1407,18 @@ void ed_screen_fullarea(bContext *C)
|
||||
|
||||
}
|
||||
|
||||
void ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
|
||||
int ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
|
||||
{
|
||||
if(sa==NULL)
|
||||
return 0;
|
||||
|
||||
if(sa->full==0)
|
||||
ed_screen_fullarea(C);
|
||||
ed_screen_fullarea(C, sa);
|
||||
|
||||
/* CTX_wm_area(C) is new area */
|
||||
ED_area_newspace(C, CTX_wm_area(C), type);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ED_screen_full_prevspace(bContext *C)
|
||||
@ -1328,7 +1428,7 @@ void ED_screen_full_prevspace(bContext *C)
|
||||
ED_area_prevspace(C);
|
||||
|
||||
if(sa->full)
|
||||
ed_screen_fullarea(C);
|
||||
ed_screen_fullarea(C, sa);
|
||||
}
|
||||
|
||||
void ED_screen_animation_timer(bContext *C, int enable)
|
||||
@ -1345,3 +1445,57 @@ void ED_screen_animation_timer(bContext *C, int enable)
|
||||
screen->animtimer= WM_event_add_window_timer(win, TIMER0, (1.0/FPS));
|
||||
}
|
||||
|
||||
unsigned int ED_screen_view3d_layers(bScreen *screen)
|
||||
{
|
||||
if(screen) {
|
||||
unsigned int layer= screen->scene->lay; /* as minimum this */
|
||||
ScrArea *sa;
|
||||
|
||||
/* get all used view3d layers */
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
if(sa->spacetype==SPACE_VIEW3D)
|
||||
layer |= ((View3D *)sa->spacedata.first)->lay;
|
||||
}
|
||||
return layer;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* results in fully updated anim system */
|
||||
/* in future sound should be on WM level, only 1 sound can play! */
|
||||
void ED_update_for_newframe(const bContext *C, int mute)
|
||||
{
|
||||
bScreen *screen= CTX_wm_screen(C);
|
||||
Scene *scene= screen->scene;
|
||||
|
||||
//extern void audiostream_scrub(unsigned int frame); /* seqaudio.c */
|
||||
|
||||
/* this function applies the changes too */
|
||||
/* XXX future: do all windows */
|
||||
scene_update_for_newframe(scene, ED_screen_view3d_layers(screen)); /* BKE_scene.h */
|
||||
|
||||
//if ( (CFRA>1) && (!mute) && (scene->audio.flag & AUDIO_SCRUB))
|
||||
// audiostream_scrub( CFRA );
|
||||
|
||||
/* 3d window, preview */
|
||||
//BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
|
||||
|
||||
/* all movie/sequence images */
|
||||
//BIF_image_update_frame();
|
||||
|
||||
/* composite */
|
||||
if(scene->use_nodes && scene->nodetree)
|
||||
ntreeCompositTagAnimated(scene->nodetree);
|
||||
|
||||
/* update animated texture nodes */
|
||||
{
|
||||
Tex *tex;
|
||||
for(tex= CTX_data_main(C)->tex.first; tex; tex= tex->id.next)
|
||||
if( tex->use_nodes && tex->nodetree ) {
|
||||
ntreeTexTagAnimated( tex->nodetree );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,8 +52,7 @@ ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my);
|
||||
|
||||
AZone *is_in_area_actionzone(ScrArea *sa, int x, int y);
|
||||
|
||||
void ed_screen_set(bContext *C, bScreen *sc);
|
||||
void ed_screen_fullarea(bContext *C);
|
||||
void ed_screen_fullarea(bContext *C, ScrArea *sa);
|
||||
|
||||
/* screen_context.c */
|
||||
void ed_screen_context(const bContext *C, bContextDataMember member, bContextDataResult *result);
|
||||
|
@ -30,28 +30,37 @@
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_editVert.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_customdata.h"
|
||||
#include "BKE_library.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "DNA_armature_types.h"
|
||||
#include "DNA_image_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_curve_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BKE_blender.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_customdata.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_library.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_multires.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "ED_markers.h"
|
||||
#include "ED_util.h"
|
||||
#include "ED_screen.h"
|
||||
#include "ED_screen_types.h"
|
||||
|
||||
#include "RE_pipeline.h"
|
||||
#include "IMB_imbuf.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
|
||||
@ -152,6 +161,11 @@ int ED_operator_sequencer_active(bContext *C)
|
||||
return ed_spacetype_test(C, SPACE_SEQ);
|
||||
}
|
||||
|
||||
int ED_operator_image_active(bContext *C)
|
||||
{
|
||||
return ed_spacetype_test(C, SPACE_IMAGE);
|
||||
}
|
||||
|
||||
int ED_operator_object_active(bContext *C)
|
||||
{
|
||||
return NULL != CTX_data_active_object(C);
|
||||
@ -196,6 +210,20 @@ int ED_operator_uvedit(bContext *C)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ED_operator_uvmap(bContext *C)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= NULL;
|
||||
|
||||
if(obedit && obedit->type==OB_MESH)
|
||||
em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
if(em && (em->faces.first))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ED_operator_editcurve(bContext *C)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
@ -997,26 +1025,36 @@ void SCREEN_OT_frame_offset(wmOperatorType *ot)
|
||||
static int screen_set_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bScreen *screen= CTX_wm_screen(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
int tot= BLI_countlist(&CTX_data_main(C)->screen);
|
||||
int delta= RNA_int_get(op->ptr, "delta");
|
||||
|
||||
/* this screen is 'fake', solve later XXX */
|
||||
if(CTX_wm_area(C)->full)
|
||||
if(sa && sa->full)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
if(delta==1) {
|
||||
screen= screen->id.next;
|
||||
if(screen==NULL) screen= CTX_data_main(C)->screen.first;
|
||||
while(tot--) {
|
||||
screen= screen->id.next;
|
||||
if(screen==NULL) screen= CTX_data_main(C)->screen.first;
|
||||
if(screen->winid==0 && screen->full==0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(delta== -1) {
|
||||
screen= screen->id.prev;
|
||||
if(screen==NULL) screen= CTX_data_main(C)->screen.last;
|
||||
while(tot--) {
|
||||
screen= screen->id.prev;
|
||||
if(screen==NULL) screen= CTX_data_main(C)->screen.last;
|
||||
if(screen->winid==0 && screen->full==0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
screen= NULL;
|
||||
}
|
||||
|
||||
if(screen) {
|
||||
ed_screen_set(C, screen);
|
||||
ED_screen_set(C, screen);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
return OPERATOR_CANCELLED;
|
||||
@ -1041,7 +1079,7 @@ void SCREEN_OT_screen_set(wmOperatorType *ot)
|
||||
/* function to be called outside UI context, or for redo */
|
||||
static int screen_full_area_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
ed_screen_fullarea(C);
|
||||
ed_screen_fullarea(C, CTX_wm_area(C));
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@ -1051,7 +1089,7 @@ void SCREEN_OT_screen_full_area(wmOperatorType *ot)
|
||||
ot->idname = "SCREEN_OT_screen_full_area";
|
||||
|
||||
ot->exec= screen_full_area_exec;
|
||||
ot->poll= ED_operator_screenactive;
|
||||
ot->poll= ED_operator_areaactive;
|
||||
ot->flag= OPTYPE_REGISTER;
|
||||
|
||||
}
|
||||
@ -1324,7 +1362,7 @@ void SCREEN_OT_area_join(wmOperatorType *ot)
|
||||
ot->invoke= area_join_invoke;
|
||||
ot->modal= area_join_modal;
|
||||
|
||||
ot->poll= ED_operator_screenactive;
|
||||
ot->poll= ED_operator_areaactive;
|
||||
|
||||
/* rna */
|
||||
RNA_def_int(ot->srna, "x1", -100, INT_MIN, INT_MAX, "X 1", "", INT_MIN, INT_MAX);
|
||||
@ -1362,23 +1400,21 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
wmOperator *lastop;
|
||||
uiMenuItem *head;
|
||||
int items, i;
|
||||
char *menu, *p;
|
||||
|
||||
items= BLI_countlist(&wm->operators);
|
||||
if(items==0)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
menu= MEM_callocN(items * OP_MAX_TYPENAME, "string");
|
||||
|
||||
p= menu + sprintf(menu, "%s %%t", op->type->name);
|
||||
head= uiPupMenuBegin(op->type->name, 0);
|
||||
|
||||
for (i=items-1, lastop= wm->operators.last; lastop; lastop= lastop->prev, i--)
|
||||
p+= sprintf(p, "|%s %%x%d", lastop->type->name, i);
|
||||
uiMenuItemIntO(head, lastop->type->name, 0, op->type->idname, "index", i);
|
||||
|
||||
uiPupMenuEnd(C, head);
|
||||
|
||||
uiPupMenuOperator(C, i/20, op, "index", menu);
|
||||
MEM_freeN(menu);
|
||||
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
static int repeat_history_exec(bContext *C, wmOperator *op)
|
||||
@ -1412,6 +1448,90 @@ void SCREEN_OT_repeat_history(wmOperatorType *ot)
|
||||
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000);
|
||||
}
|
||||
|
||||
/* ********************** redo operator ***************************** */
|
||||
|
||||
static int redo_last_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
#if 0
|
||||
/* XXX context is not correct after popup menu */
|
||||
wmOperator *lastop= CTX_wm_manager(C)->operators.last;
|
||||
|
||||
if(lastop) {
|
||||
ED_undo_pop(C);
|
||||
WM_operator_repeat(C, lastop);
|
||||
}
|
||||
#endif
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
static void redo_last_cb(bContext *C, void *arg1, void *arg2)
|
||||
{
|
||||
wmOperator *lastop= CTX_wm_manager(C)->operators.last;
|
||||
|
||||
if(lastop) {
|
||||
ED_undo_pop(C);
|
||||
WM_operator_repeat(C, lastop);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static uiBlock *ui_block_create_redo_last(bContext *C, ARegion *ar, void *arg_op)
|
||||
{
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
wmOperator *op= arg_op;
|
||||
PointerRNA ptr;
|
||||
uiBlock *block;
|
||||
int height;
|
||||
|
||||
block= uiBeginBlock(C, ar, "redo_last_popup", UI_EMBOSS, UI_HELV);
|
||||
uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1);
|
||||
uiBlockSetFunc(block, redo_last_cb, NULL, NULL);
|
||||
|
||||
if(!op->properties) {
|
||||
IDPropertyTemplate val = {0};
|
||||
op->properties= IDP_New(IDP_GROUP, val, "wmOperatorProperties");
|
||||
}
|
||||
|
||||
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
|
||||
height= uiDefAutoButsRNA(block, &ptr);
|
||||
|
||||
uiPopupBoundsBlock(block, 4.0f, 0, 0);
|
||||
uiEndBlock(C, block);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
static int redo_last_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
wmOperator *lastop= wm->operators.last;
|
||||
|
||||
if(!lastop)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* only for operators that are registered and did an undo push */
|
||||
if(!(lastop->type->flag & OPTYPE_REGISTER) || !(lastop->type->flag & OPTYPE_UNDO))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
uiPupBlockO(C, ui_block_create_redo_last, lastop, op->type->idname, WM_OP_EXEC_DEFAULT);
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
void SCREEN_OT_redo_last(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Redo Last";
|
||||
ot->idname= "SCREEN_OT_redo_last";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= redo_last_invoke;
|
||||
ot->exec= redo_last_exec;
|
||||
|
||||
ot->poll= ED_operator_screenactive;
|
||||
}
|
||||
|
||||
/* ************** region split operator ***************************** */
|
||||
|
||||
/* insert a region in the area region list */
|
||||
@ -1585,14 +1705,14 @@ static void newlevel1(bContext *C, uiMenuItem *head, void *arg)
|
||||
|
||||
static int testing123(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
uiMenuItem *head= uiPupMenuBegin("Hello world");
|
||||
uiMenuItem *head= uiPupMenuBegin("Hello world", 0);
|
||||
|
||||
uiMenuContext(head, WM_OP_EXEC_DEFAULT);
|
||||
uiMenuItemO(head, "SCREEN_OT_region_flip", ICON_PROP_ON);
|
||||
uiMenuItemO(head, "SCREEN_OT_screen_full_area", ICON_PROP_CON);
|
||||
uiMenuItemO(head, "SCREEN_OT_region_foursplit", ICON_SMOOTHCURVE);
|
||||
uiMenuItemO(head, ICON_PROP_ON, "SCREEN_OT_region_flip");
|
||||
uiMenuItemO(head, ICON_PROP_CON, "SCREEN_OT_screen_full_area");
|
||||
uiMenuItemO(head, ICON_SMOOTHCURVE, "SCREEN_OT_region_foursplit");
|
||||
uiMenuLevel(head, "Submenu", newlevel1);
|
||||
uiMenuItemO(head, "SCREEN_OT_area_rip", ICON_PROP_ON);
|
||||
uiMenuItemO(head, ICON_PROP_ON, "SCREEN_OT_area_rip");
|
||||
|
||||
uiPupMenuEnd(C, head);
|
||||
|
||||
@ -1715,6 +1835,384 @@ void SCREEN_OT_border_select(wmOperatorType *ot)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ****************************** render invoking ***************** */
|
||||
|
||||
/* set callbacks, exported to sequence render too.
|
||||
Only call in foreground (UI) renders. */
|
||||
|
||||
/* returns biggest area that is not uv/image editor. Note that it uses buttons */
|
||||
/* window as the last possible alternative. */
|
||||
static ScrArea *biggest_non_image_area(bContext *C)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
ScrArea *sa, *big= NULL;
|
||||
int size, maxsize= 0, bwmaxsize= 0;
|
||||
short foundwin= 0;
|
||||
|
||||
for(sa= sc->areabase.first; sa; sa= sa->next) {
|
||||
if(sa->winx > 10 && sa->winy > 10) {
|
||||
size= sa->winx*sa->winy;
|
||||
if(sa->spacetype == SPACE_BUTS) {
|
||||
if(foundwin == 0 && size > bwmaxsize) {
|
||||
bwmaxsize= size;
|
||||
big= sa;
|
||||
}
|
||||
}
|
||||
else if(sa->spacetype != SPACE_IMAGE && size > maxsize) {
|
||||
maxsize= size;
|
||||
big= sa;
|
||||
foundwin= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return big;
|
||||
}
|
||||
|
||||
static ScrArea *biggest_area(bContext *C)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
ScrArea *sa, *big= NULL;
|
||||
int size, maxsize= 0;
|
||||
|
||||
for(sa= sc->areabase.first; sa; sa= sa->next) {
|
||||
size= sa->winx*sa->winy;
|
||||
if(size > maxsize) {
|
||||
maxsize= size;
|
||||
big= sa;
|
||||
}
|
||||
}
|
||||
return big;
|
||||
}
|
||||
|
||||
|
||||
static ScrArea *find_area_showing_r_result(bContext *C)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
ScrArea *sa;
|
||||
SpaceImage *sima;
|
||||
|
||||
/* find an imagewindow showing render result */
|
||||
for(sa=sc->areabase.first; sa; sa= sa->next) {
|
||||
if(sa->spacetype==SPACE_IMAGE) {
|
||||
sima= sa->spacedata.first;
|
||||
if(sima->image && sima->image->type==IMA_TYPE_R_RESULT)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sa;
|
||||
}
|
||||
|
||||
static void screen_set_image_output(bContext *C)
|
||||
{
|
||||
ScrArea *sa;
|
||||
SpaceImage *sima;
|
||||
|
||||
sa= find_area_showing_r_result(C);
|
||||
|
||||
if(sa==NULL) {
|
||||
/* find largest open non-image area */
|
||||
sa= biggest_non_image_area(C);
|
||||
if(sa) {
|
||||
ED_area_newspace(C, sa, SPACE_IMAGE);
|
||||
sima= sa->spacedata.first;
|
||||
|
||||
/* makes ESC go back to prev space */
|
||||
sima->flag |= SI_PREVSPACE;
|
||||
}
|
||||
else {
|
||||
/* use any area of decent size */
|
||||
sa= biggest_area(C);
|
||||
if(sa->spacetype!=SPACE_IMAGE) {
|
||||
// XXX newspace(sa, SPACE_IMAGE);
|
||||
sima= sa->spacedata.first;
|
||||
|
||||
/* makes ESC go back to prev space */
|
||||
sima->flag |= SI_PREVSPACE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sima= sa->spacedata.first;
|
||||
|
||||
/* get the correct image, and scale it */
|
||||
sima->image= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
|
||||
|
||||
if(G.displaymode==2) { // XXX
|
||||
if(sa->full==0) {
|
||||
sima->flag |= SI_FULLWINDOW;
|
||||
|
||||
ed_screen_fullarea(C, sa);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* executes blocking render */
|
||||
static int screen_render_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Render *re= RE_GetRender(scene->id.name);
|
||||
|
||||
if(re==NULL) {
|
||||
re= RE_NewRender(scene->id.name);
|
||||
}
|
||||
RE_test_break_cb(re, NULL, (int (*)(void *)) blender_test_break);
|
||||
|
||||
if(RNA_boolean_get(op->ptr, "anim"))
|
||||
RE_BlenderAnim(re, scene, scene->r.sfra, scene->r.efra, scene->frame_step);
|
||||
else
|
||||
RE_BlenderFrame(re, scene, scene->r.cfra);
|
||||
|
||||
// no redraw needed, we leave state as we entered it
|
||||
ED_update_for_newframe(C, 1);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
typedef struct RenderJob {
|
||||
Scene *scene;
|
||||
Render *re;
|
||||
wmWindow *win;
|
||||
int anim;
|
||||
Image *image;
|
||||
ImageUser iuser;
|
||||
short *stop;
|
||||
short *do_update;
|
||||
} RenderJob;
|
||||
|
||||
static void render_freejob(void *rjv)
|
||||
{
|
||||
RenderJob *rj= rjv;
|
||||
|
||||
MEM_freeN(rj);
|
||||
}
|
||||
|
||||
/* called inside thread! */
|
||||
static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrect)
|
||||
{
|
||||
RenderJob *rj= rjv;
|
||||
ImBuf *ibuf;
|
||||
float x1, y1, *rectf= NULL;
|
||||
int ymin, ymax, xmin, xmax;
|
||||
int rymin, rxmin;
|
||||
char *rectc;
|
||||
|
||||
ibuf= BKE_image_get_ibuf(rj->image, &rj->iuser);
|
||||
if(ibuf==NULL) return;
|
||||
|
||||
/* if renrect argument, we only refresh scanlines */
|
||||
if(renrect) {
|
||||
/* if ymax==recty, rendering of layer is ready, we should not draw, other things happen... */
|
||||
if(rr->renlay==NULL || renrect->ymax>=rr->recty)
|
||||
return;
|
||||
|
||||
/* xmin here is first subrect x coord, xmax defines subrect width */
|
||||
xmin = renrect->xmin;
|
||||
xmax = renrect->xmax - xmin;
|
||||
if (xmax<2) return;
|
||||
|
||||
ymin= renrect->ymin;
|
||||
ymax= renrect->ymax - ymin;
|
||||
if(ymax<2)
|
||||
return;
|
||||
renrect->ymin= renrect->ymax;
|
||||
}
|
||||
else {
|
||||
xmin = ymin = rr->crop;
|
||||
xmax = rr->rectx - 2*rr->crop;
|
||||
ymax = rr->recty - 2*rr->crop;
|
||||
}
|
||||
|
||||
/* xmin ymin is in tile coords. transform to ibuf */
|
||||
rxmin= rr->tilerect.xmin + xmin;
|
||||
if(rxmin >= ibuf->x) return;
|
||||
rymin= rr->tilerect.ymin + ymin;
|
||||
if(rymin >= ibuf->y) return;
|
||||
|
||||
if(rxmin + xmax > ibuf->x)
|
||||
xmax= ibuf->x - rxmin;
|
||||
if(rymin + ymax > ibuf->y)
|
||||
ymax= ibuf->y - rymin;
|
||||
if(xmax < 1 || ymax < 1) return;
|
||||
|
||||
/* find current float rect for display, first case is after composit... still weak */
|
||||
if(rr->rectf)
|
||||
rectf= rr->rectf;
|
||||
else {
|
||||
if(rr->rect32)
|
||||
return;
|
||||
else {
|
||||
if(rr->renlay==NULL || rr->renlay->rectf==NULL) return;
|
||||
rectf= rr->renlay->rectf;
|
||||
}
|
||||
}
|
||||
if(rectf==NULL) return;
|
||||
|
||||
rectf+= 4*(rr->rectx*ymin + xmin);
|
||||
rectc= (char *)(ibuf->rect + ibuf->x*rymin + rxmin);
|
||||
|
||||
for(y1= 0; y1<ymax; y1++) {
|
||||
float *rf= rectf;
|
||||
char *rc= rectc;
|
||||
|
||||
for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
|
||||
rc[0]= FTOCHAR(rf[0]);
|
||||
rc[1]= FTOCHAR(rf[1]);
|
||||
rc[2]= FTOCHAR(rf[2]);
|
||||
rc[3]= FTOCHAR(rf[3]);
|
||||
}
|
||||
rectf += 4*rr->rectx;
|
||||
rectc += 4*ibuf->x;
|
||||
}
|
||||
|
||||
/* make jobs timer to send notifier */
|
||||
*(rj->do_update)= 1;
|
||||
}
|
||||
|
||||
static void render_startjob(void *rjv, short *stop, short *do_update)
|
||||
{
|
||||
RenderJob *rj= rjv;
|
||||
|
||||
rj->stop= stop;
|
||||
rj->do_update= do_update;
|
||||
|
||||
if(rj->anim)
|
||||
RE_BlenderAnim(rj->re, rj->scene, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->frame_step);
|
||||
else
|
||||
RE_BlenderFrame(rj->re, rj->scene, rj->scene->r.cfra);
|
||||
}
|
||||
|
||||
/* called by render, check job 'stop' value or the global */
|
||||
static int render_breakjob(void *rjv)
|
||||
{
|
||||
RenderJob *rj= rjv;
|
||||
|
||||
if(G.afbreek)
|
||||
return 1;
|
||||
if(rj->stop && *(rj->stop))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* using context, starts job */
|
||||
static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
/* new render clears all callbacks */
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Render *re;
|
||||
wmJob *steve;
|
||||
RenderJob *rj;
|
||||
Image *ima;
|
||||
|
||||
/* only one job at a time */
|
||||
if(WM_jobs_test(CTX_wm_manager(C), scene))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* handle UI stuff */
|
||||
WM_cursor_wait(1);
|
||||
|
||||
/* flush multires changes (for sculpt) */
|
||||
multires_force_update(CTX_data_active_object(C));
|
||||
|
||||
// get editmode results
|
||||
// store spare
|
||||
// get view3d layer, local layer, make this nice api call to render
|
||||
// store spare
|
||||
|
||||
/* ensure at least 1 area shows result */
|
||||
screen_set_image_output(C);
|
||||
|
||||
/* job custom data */
|
||||
rj= MEM_callocN(sizeof(RenderJob), "render job");
|
||||
rj->scene= scene;
|
||||
rj->win= CTX_wm_window(C);
|
||||
rj->anim= RNA_boolean_get(op->ptr, "anim");
|
||||
rj->iuser.scene= scene;
|
||||
rj->iuser.ok= 1;
|
||||
|
||||
/* setup job */
|
||||
steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene);
|
||||
WM_jobs_customdata(steve, rj, render_freejob);
|
||||
WM_jobs_timer(steve, 0.2, NC_SCENE|ND_RENDER_RESULT, 0);
|
||||
WM_jobs_callbacks(steve, render_startjob, NULL, NULL);
|
||||
|
||||
/* get a render result image, and make sure it is empty */
|
||||
ima= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
|
||||
BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
|
||||
rj->image= ima;
|
||||
|
||||
/* setup new render */
|
||||
re= RE_NewRender(scene->id.name);
|
||||
RE_test_break_cb(re, rj, render_breakjob);
|
||||
RE_display_draw_cb(re, rj, image_rect_update);
|
||||
rj->re= re;
|
||||
G.afbreek= 0;
|
||||
|
||||
// BKE_report in render!
|
||||
// RE_error_cb(re, error_cb);
|
||||
|
||||
WM_jobs_start(steve);
|
||||
|
||||
G.afbreek= 0;
|
||||
|
||||
WM_cursor_wait(0);
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
||||
/* contextual render, using current scene, view3d? */
|
||||
void SCREEN_OT_render(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Render";
|
||||
ot->idname= "SCREEN_OT_render";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= screen_render_invoke;
|
||||
ot->exec= screen_render_exec;
|
||||
|
||||
ot->poll= ED_operator_screenactive;
|
||||
|
||||
RNA_def_int(ot->srna, "layers", 0, 0, INT_MAX, "Layers", "", 0, INT_MAX);
|
||||
RNA_def_boolean(ot->srna, "anim", 0, "Animation", "");
|
||||
}
|
||||
|
||||
/* *********************** cancel render viewer *************** */
|
||||
|
||||
static int render_view_cancel_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
SpaceImage *sima= sa->spacedata.first;
|
||||
|
||||
if(sima->flag & SI_PREVSPACE) {
|
||||
sima->flag &= ~SI_PREVSPACE;
|
||||
ED_area_prevspace(C);
|
||||
}
|
||||
else if(sima->flag & SI_FULLWINDOW) {
|
||||
sima->flag &= ~SI_FULLWINDOW;
|
||||
ED_screen_full_prevspace(C);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void SCREEN_OT_render_view_cancel(struct wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Cancel Render View";
|
||||
ot->idname= "SCREEN_OT_render_view_cancel";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= render_view_cancel_exec;
|
||||
ot->poll= ED_operator_image_active;
|
||||
}
|
||||
|
||||
|
||||
/* **************** Assigning operatortypes to global list, adding handlers **************** */
|
||||
|
||||
/* called in spacetypes.c */
|
||||
@ -1724,6 +2222,7 @@ void ED_operatortypes_screen(void)
|
||||
WM_operatortype_append(SCREEN_OT_actionzone);
|
||||
WM_operatortype_append(SCREEN_OT_repeat_last);
|
||||
WM_operatortype_append(SCREEN_OT_repeat_history);
|
||||
WM_operatortype_append(SCREEN_OT_redo_last);
|
||||
|
||||
/* screen tools */
|
||||
WM_operatortype_append(SCREEN_OT_area_move);
|
||||
@ -1740,10 +2239,13 @@ void ED_operatortypes_screen(void)
|
||||
WM_operatortype_append(SCREEN_OT_frame_offset);
|
||||
WM_operatortype_append(SCREEN_OT_animation_play);
|
||||
|
||||
/* render */
|
||||
WM_operatortype_append(SCREEN_OT_render);
|
||||
WM_operatortype_append(SCREEN_OT_render_view_cancel);
|
||||
|
||||
/* tools shared by more space types */
|
||||
WM_operatortype_append(ED_OT_undo);
|
||||
WM_operatortype_append(ED_OT_redo);
|
||||
ED_marker_operatortypes();
|
||||
WM_operatortype_append(ED_OT_redo);
|
||||
|
||||
}
|
||||
|
||||
@ -1774,6 +2276,7 @@ void ED_keymap_screen(wmWindowManager *wm)
|
||||
WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", F3KEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_last", F4KEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* files */
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_load", RETKEY, KM_PRESS, 0, 0);
|
||||
@ -1785,9 +2288,9 @@ void ED_keymap_screen(wmWindowManager *wm)
|
||||
WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0);
|
||||
|
||||
/* screen level global keymaps */
|
||||
// err...
|
||||
ED_marker_keymap(wm);
|
||||
/* render */
|
||||
WM_keymap_add_item(keymap, "SCREEN_OT_render", F12KEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "SCREEN_OT_render_view_cancel", ESCKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* frame offsets */
|
||||
keymap= WM_keymap_listbase(wm, "Frames", 0, 0);
|
||||
|
@ -1083,6 +1083,8 @@ static void sculpt_update_mesh_elements(bContext *C)
|
||||
}
|
||||
|
||||
if(ss->totvert != ss->fmap_size) {
|
||||
if(ss->fmap) MEM_freeN(ss->fmap);
|
||||
if(ss->fmap_mem) MEM_freeN(ss->fmap_mem);
|
||||
create_vert_face_map(&ss->fmap, &ss->fmap_mem, ss->mface, ss->totvert, ss->totface);
|
||||
ss->fmap_size = ss->totvert;
|
||||
}
|
||||
@ -1230,6 +1232,31 @@ static void sculpt_undo_push(bContext *C, Sculpt *sd)
|
||||
}
|
||||
}
|
||||
|
||||
static int sculpt_brush_curve_preset_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
brush_curve_preset(CTX_data_scene(C)->toolsettings->sculpt->brush, RNA_enum_get(op->ptr, "mode"));
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static void SCULPT_OT_brush_curve_preset(wmOperatorType *ot)
|
||||
{
|
||||
static EnumPropertyItem prop_mode_items[] = {
|
||||
{BRUSH_PRESET_SHARP, "SHARP", "Sharp Curve", ""},
|
||||
{BRUSH_PRESET_SMOOTH, "SMOOTH", "Smooth Curve", ""},
|
||||
{BRUSH_PRESET_MAX, "MAX", "Max Curve", ""},
|
||||
{0, NULL, NULL, NULL}};
|
||||
|
||||
ot->name= "Preset";
|
||||
ot->idname= "SCULPT_OT_brush_curve_preset";
|
||||
|
||||
ot->exec= sculpt_brush_curve_preset_exec;
|
||||
ot->poll= sculpt_poll;
|
||||
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
RNA_def_enum(ot->srna, "mode", prop_mode_items, BRUSH_PRESET_SHARP, "Mode", "");
|
||||
}
|
||||
|
||||
/**** Radial control ****/
|
||||
static int sculpt_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
@ -1628,6 +1655,8 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op)
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
|
||||
if(G.f & G_SCULPTMODE) {
|
||||
multires_force_update(CTX_data_active_object(C));
|
||||
|
||||
/* Leave sculptmode */
|
||||
G.f &= ~G_SCULPTMODE;
|
||||
|
||||
@ -1692,6 +1721,7 @@ void ED_operatortypes_sculpt()
|
||||
WM_operatortype_append(SCULPT_OT_radial_control);
|
||||
WM_operatortype_append(SCULPT_OT_brush_stroke);
|
||||
WM_operatortype_append(SCULPT_OT_sculptmode_toggle);
|
||||
WM_operatortype_append(SCULPT_OT_brush_curve_preset);
|
||||
}
|
||||
|
||||
void sculpt(Sculpt *sd)
|
||||
|
@ -238,10 +238,8 @@ void ACT_OT_view_all (wmOperatorType *ot)
|
||||
// - insert key
|
||||
|
||||
/* ******************** Copy/Paste Keyframes Operator ************************* */
|
||||
/* - The copy/paste buffer currently stores a set of Action Channels, with temporary
|
||||
* IPO-blocks, and also temporary IpoCurves which only contain the selected keyframes.
|
||||
* - Only pastes between compatable data is possible (i.e. same achan->name, ipo-curve type, etc.)
|
||||
* Unless there is only one element in the buffer, names are also tested to check for compatability.
|
||||
/* - The copy/paste buffer currently stores a set of temporary F-Curves containing only the keyframes
|
||||
* that were selected in each of the original F-Curves
|
||||
* - All pasted frames are offset by the same amount. This is calculated as the difference in the times of
|
||||
* the current frame and the 'first keyframe' (i.e. the earliest one in all channels).
|
||||
* - The earliest frame is calculated per copy operation.
|
||||
@ -276,7 +274,6 @@ void free_actcopybuf ()
|
||||
*/
|
||||
static short copy_action_keys (bAnimContext *ac)
|
||||
{
|
||||
#if 0 // XXX old animation system
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
@ -285,11 +282,12 @@ static short copy_action_keys (bAnimContext *ac)
|
||||
free_actcopybuf();
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_IPOKEYS);
|
||||
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVESONLY);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* assume that each of these is an ipo-block */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
#if 0
|
||||
bActionChannel *achan;
|
||||
Ipo *ipo= ale->key_data;
|
||||
Ipo *ipn;
|
||||
@ -347,16 +345,21 @@ static short copy_action_keys (bAnimContext *ac)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//FCurve *fcu= (FCurve *)ale->key_data;
|
||||
//FCurve *fcn;
|
||||
//BezTriple *bezt;
|
||||
//int i;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* check if anything ended up in the buffer */
|
||||
if (ELEM(NULL, actcopybuf.first, actcopybuf.last))
|
||||
// error("Nothing copied to buffer");
|
||||
return -1;
|
||||
|
||||
/* free temp memory */
|
||||
BLI_freelistN(&anim_data);
|
||||
#endif // XXX old animation system
|
||||
|
||||
/* everything went fine */
|
||||
return 0;
|
||||
|
@ -29,8 +29,10 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "DNA_anim_types.h"
|
||||
#include "DNA_action_types.h"
|
||||
#include "DNA_key_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
@ -1551,6 +1553,38 @@ static void do_action_buttons(bContext *C, void *arg, int event)
|
||||
}
|
||||
}
|
||||
|
||||
static void saction_idpoin_handle(bContext *C, ID *id, int event)
|
||||
{
|
||||
SpaceAction *saction= (SpaceAction*)CTX_wm_space_data(C);
|
||||
Object *obact= CTX_data_active_object(C);
|
||||
AnimData *adt= BKE_id_add_animdata((ID *)obact);
|
||||
|
||||
switch (event) {
|
||||
case UI_ID_BROWSE:
|
||||
case UI_ID_DELETE:
|
||||
/* we must set this action to be the one used by active object (if not pinned) */
|
||||
if (saction->pin == 0)
|
||||
obact->adt->action= saction->action;
|
||||
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
ED_undo_push(C, "Assign Action");
|
||||
break;
|
||||
case UI_ID_RENAME:
|
||||
break;
|
||||
case UI_ID_ADD_NEW:
|
||||
/* XXX not implemented */
|
||||
break;
|
||||
case UI_ID_OPEN:
|
||||
/* XXX not implemented */
|
||||
break;
|
||||
case UI_ID_ALONE:
|
||||
/* XXX not implemented */
|
||||
break;
|
||||
case UI_ID_PIN:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void action_header_buttons(const bContext *C, ARegion *ar)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
@ -1628,7 +1662,8 @@ void action_header_buttons(const bContext *C, ARegion *ar)
|
||||
|
||||
xco += (90 + 8);
|
||||
|
||||
if (ac.data) {
|
||||
/*if (ac.data)*/
|
||||
{
|
||||
/* MODE-DEPENDENT DRAWING */
|
||||
if (saction->mode == SACTCONT_DOPESHEET) {
|
||||
/* FILTERING OPTIONS */
|
||||
@ -1652,17 +1687,12 @@ void action_header_buttons(const bContext *C, ARegion *ar)
|
||||
}
|
||||
else if (saction->mode == SACTCONT_ACTION) { // not too appropriate for shapekeys atm...
|
||||
/* NAME ETC */
|
||||
// XXX missing stuff here!
|
||||
//ob= OBACT;
|
||||
//from = (ID *)ob;
|
||||
|
||||
//xco= std_libbuttons(block, xco, 0, B_ACTPIN, saction->pin,
|
||||
// B_ACTIONBROWSE, ID_AC, 0, (ID*)saction->action,
|
||||
// from, &(saction->actnr), B_ACTALONE,
|
||||
// B_ACTLOCAL, B_ACTIONDELETE, 0, B_KEEPDATA);
|
||||
|
||||
//uiClearButLock();
|
||||
|
||||
/* NAME ETC (it is assumed that */
|
||||
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&saction->action, ID_AC, &saction->pin, xco, yco,
|
||||
saction_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_DELETE|UI_ID_FAKE_USER|UI_ID_ALONE|UI_ID_PIN);
|
||||
|
||||
xco += 8;
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,6 @@ static void action_channel_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
switch(wmn->data) {
|
||||
case ND_BONE_ACTIVE:
|
||||
case ND_BONE_SELECT:
|
||||
case ND_KEYS:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
@ -327,6 +326,7 @@ static void action_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
case ND_BONE_ACTIVE:
|
||||
case ND_BONE_SELECT:
|
||||
case ND_KEYS:
|
||||
case ND_TRANSFORM:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "ED_armature.h"
|
||||
#include "ED_curve.h"
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_markers.h"
|
||||
#include "ED_object.h"
|
||||
#include "ED_sculpt.h"
|
||||
#include "ED_screen.h"
|
||||
@ -83,6 +84,7 @@ void ED_spacetypes_init(void)
|
||||
ED_operatortypes_uvedit();
|
||||
ED_operatortypes_curve();
|
||||
ED_operatortypes_armature();
|
||||
ED_marker_operatortypes();
|
||||
|
||||
ui_view2d_operatortypes();
|
||||
|
||||
@ -108,7 +110,8 @@ void ED_spacetypes_keymap(wmWindowManager *wm)
|
||||
ED_keymap_uvedit(wm);
|
||||
ED_keymap_curve(wm);
|
||||
ED_keymap_armature(wm);
|
||||
|
||||
ED_marker_keymap(wm);
|
||||
|
||||
UI_view2d_keymap(wm);
|
||||
|
||||
spacetypes = BKE_spacetypes_list();
|
||||
|
@ -488,10 +488,10 @@ void file_draw_list(const bContext *C, ARegion *ar)
|
||||
if (params->active_file == i) {
|
||||
if (file->flags & ACTIVE) colorid= TH_HILITE;
|
||||
else colorid = TH_BACK;
|
||||
draw_tile(sx, sy-3, sfile->tile_w, sfile->tile_h, colorid,20);
|
||||
draw_tile(sx-2, sy-3, sfile->tile_w+2, sfile->tile_h, colorid,20);
|
||||
} else if (file->flags & ACTIVE) {
|
||||
colorid = TH_HILITE;
|
||||
draw_tile(sx, sy-3, sfile->tile_w, sfile->tile_h, colorid,0);
|
||||
draw_tile(sx-2, sy-3, sfile->tile_w+2, sfile->tile_h, colorid,0);
|
||||
} else {
|
||||
/*
|
||||
colorid = TH_PANEL;
|
||||
|
@ -28,7 +28,7 @@
|
||||
#
|
||||
# Makes module object directory and bounces make to subdirectories.
|
||||
|
||||
LIBNAME = ed_ipo
|
||||
LIBNAME = ed_graph
|
||||
DIR = $(OCGDIR)/blender/$(LIBNAME)
|
||||
|
||||
include nan_compile.mk
|
@ -6,4 +6,4 @@ sources = env.Glob('*.c')
|
||||
incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../makesrna ../../imbuf'
|
||||
incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
|
||||
|
||||
env.BlenderLib ( 'bf_editors_space_ipo', sources, Split(incs), [], libtype=['core'], priority=[50] )
|
||||
env.BlenderLib ( 'bf_editors_space_graph', sources, Split(incs), [], libtype=['core'], priority=[50] )
|
@ -76,7 +76,7 @@
|
||||
#include "ED_anim_api.h"
|
||||
#include "ED_util.h"
|
||||
|
||||
#include "ipo_intern.h"
|
||||
#include "graph_intern.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_interface_icons.h"
|
@ -82,7 +82,7 @@
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "ipo_intern.h"
|
||||
#include "graph_intern.h"
|
||||
|
||||
#if 0 // XXX code to be sanitied for new system
|
||||
|
@ -57,7 +57,7 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "ipo_intern.h"
|
||||
#include "graph_intern.h"
|
||||
|
||||
/* ********************************************************* */
|
||||
/* Menu Defines... */
|
@ -50,7 +50,7 @@
|
||||
|
||||
#include "BIF_transform.h"
|
||||
|
||||
#include "ipo_intern.h"
|
||||
#include "graph_intern.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
@ -79,7 +79,7 @@
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "ipo_intern.h"
|
||||
#include "graph_intern.h"
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
@ -58,7 +58,7 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "ipo_intern.h" // own include
|
||||
#include "graph_intern.h" // own include
|
||||
|
||||
/* ******************** default callbacks for ipo space ***************** */
|
||||
|
@ -667,6 +667,8 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* put scene context variable in iuser */
|
||||
sima->iuser.scene= scene;
|
||||
/* retrieve the image and information about it */
|
||||
ima= get_space_image(sima);
|
||||
ibuf= get_space_image_buffer(sima);
|
||||
|
@ -87,8 +87,8 @@ static void image_view_viewnavmenu(bContext *C, uiMenuItem *head, void *arg_unus
|
||||
{
|
||||
int a;
|
||||
|
||||
uiMenuItemO(head, "IMAGE_OT_view_zoom_in", ICON_BLANK1);
|
||||
uiMenuItemO(head, "IMAGE_OT_view_zoom_out", ICON_BLANK1);
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_view_zoom_in");
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_view_zoom_out");
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
@ -97,7 +97,7 @@ static void image_view_viewnavmenu(bContext *C, uiMenuItem *head, void *arg_unus
|
||||
char namestr[128];
|
||||
|
||||
sprintf(namestr, "Zoom %d:%d", ratios[a][0], ratios[a][1]);
|
||||
uiMenuItemFloatO(head, namestr, "IMAGE_OT_view_zoom_ratio", "ratio", (float)ratios[a][0]/(float)ratios[a][1]);
|
||||
uiMenuItemFloatO(head, namestr, 0, "IMAGE_OT_view_zoom_ratio", "ratio", (float)ratios[a][0]/(float)ratios[a][1]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,13 +137,13 @@ static void image_viewmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
show_uvedit= get_space_image_show_uvedit(sima, CTX_data_edit_object(C));
|
||||
|
||||
/* create menu */
|
||||
uiMenuItemO(head, "IMAGE_OT_toggle_view_properties_panel", ICON_MENU_PANEL); // View Properties...
|
||||
uiMenuItemO(head, "IMAGE_OT_toggle_image_properties_panel", ICON_MENU_PANEL); // Image Properties...|N
|
||||
uiMenuItemO(head, "IMAGE_OT_toggle_realtime_properties_panel", ICON_MENU_PANEL); // Real-time properties...
|
||||
if(show_paint) uiMenuItemO(head, "IMAGE_OT_toggle_paint_panel", ICON_MENU_PANEL); // Paint Tool...|C
|
||||
uiMenuItemO(head, "IMAGE_OT_toggle_curves_panel", ICON_MENU_PANEL); // Curves Tool...
|
||||
if(show_render) uiMenuItemO(head, "IMAGE_OT_toggle_compositing_preview_panel", ICON_MENU_PANEL); // Compositing Preview...|Shift P
|
||||
uiMenuItemO(head, "IMAGE_OT_toggle_grease_pencil_panel", ICON_MENU_PANEL); // Grease Pencil...
|
||||
uiMenuItemO(head, ICON_MENU_PANEL, "IMAGE_OT_toggle_view_properties_panel"); // View Properties...
|
||||
uiMenuItemO(head, ICON_MENU_PANEL, "IMAGE_OT_toggle_image_properties_panel"); // Image Properties...|N
|
||||
uiMenuItemO(head, ICON_MENU_PANEL, "IMAGE_OT_toggle_realtime_properties_panel"); // Real-time properties...
|
||||
if(show_paint) uiMenuItemO(head, ICON_MENU_PANEL, "IMAGE_OT_toggle_paint_panel"); // Paint Tool...|C
|
||||
uiMenuItemO(head, ICON_MENU_PANEL, "IMAGE_OT_toggle_curves_panel"); // Curves Tool...
|
||||
if(show_render) uiMenuItemO(head, ICON_MENU_PANEL, "IMAGE_OT_toggle_compositing_preview_panel"); // Compositing Preview...|Shift P
|
||||
uiMenuItemO(head, ICON_MENU_PANEL, "IMAGE_OT_toggle_grease_pencil_panel"); // Grease Pencil...
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
@ -153,46 +153,28 @@ static void image_viewmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiMenuLevel(head, "View Navigation", image_view_viewnavmenu);
|
||||
if(show_uvedit) uiMenuItemO(head, "IMAGE_OT_view_selected", ICON_BLANK1);
|
||||
uiMenuItemO(head, "IMAGE_OT_view_all", ICON_BLANK1);
|
||||
if(show_uvedit) uiMenuItemO(head, 0, "IMAGE_OT_view_selected");
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_view_all");
|
||||
|
||||
if(sa->full) uiMenuItemO(head, "SCREEN_OT_screen_full_area", ICON_BLANK1); // "Tile Window", Ctrl UpArrow
|
||||
else uiMenuItemO(head, "SCREEN_OT_screen_full_area", ICON_BLANK1); // "Maximize Window", Ctr DownArrow
|
||||
if(sa->full) uiMenuItemO(head, 0, "SCREEN_OT_screen_full_area"); // "Tile Window", Ctrl UpArrow
|
||||
else uiMenuItemO(head, 0, "SCREEN_OT_screen_full_area"); // "Maximize Window", Ctr DownArrow
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void do_selectmenu(bContext *C, void *arg, int event)
|
||||
{
|
||||
switch(event)
|
||||
{
|
||||
case 0: /* Border Select */
|
||||
borderselect_sima(UV_SELECT_ALL);
|
||||
break;
|
||||
case 8: /* Border Select Pinned */
|
||||
borderselect_sima(UV_SELECT_PINNED);
|
||||
break;
|
||||
case 7: /* Pinned UVs */
|
||||
select_pinned_tface_uv();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void image_selectmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
uiMenuItemO(head, "UV_OT_border_select", ICON_BLANK1); // Border Select|B
|
||||
uiMenuItemO(head, "UV_OT_border_select_pinned", ICON_BLANK1); // Border Select Pinned|Shift B
|
||||
uiMenuItemO(head, 0, "UV_OT_border_select");
|
||||
uiMenuItemBooleanO(head, "Border Select Pinned", 0, "UV_OT_border_select", "pinned", 1); // Border Select Pinned|Shift B
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemO(head, "UV_OT_de_select_all", ICON_BLANK1);
|
||||
uiMenuItemO(head, "UV_OT_select_invert", ICON_BLANK1);
|
||||
uiMenuItemO(head, "UV_OT_unlink_selection", ICON_BLANK1); // Unlink Selection|Alt L
|
||||
uiMenuItemO(head, 0, "UV_OT_de_select_all");
|
||||
uiMenuItemO(head, 0, "UV_OT_select_invert");
|
||||
uiMenuItemO(head, 0, "UV_OT_unlink_selection");
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemO(head, "UV_OT_select_pinned", ICON_BLANK1); // Select Pinned|Shift P
|
||||
uiMenuItemO(head, "UV_OT_select_linked", ICON_BLANK1); // Select Linked|Ctrl L
|
||||
uiMenuItemO(head, 0, "UV_OT_select_pinned");
|
||||
uiMenuItemO(head, 0, "UV_OT_select_linked");
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -277,27 +259,27 @@ static void image_imagemenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
RNA_pointer_create(&sc->id, &RNA_SpaceImageEditor, sima, &spaceptr);
|
||||
|
||||
/* create menu */
|
||||
uiMenuItemO(head, "IMAGE_OT_new", ICON_BLANK1); // New...|Alt N
|
||||
uiMenuItemO(head, "IMAGE_OT_open", ICON_BLANK1); // Open...|Alt O
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_new"); // New...|Alt N
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_open"); // Open...|Alt O
|
||||
|
||||
if(ima) {
|
||||
uiMenuItemO(head, "IMAGE_OT_replace", ICON_BLANK1); // Replace...
|
||||
uiMenuItemO(head, "IMAGE_OT_reload", ICON_BLANK1); // Reload...|Alt R
|
||||
uiMenuItemO(head, "IMAGE_OT_save", ICON_BLANK1); // Save|Alt S
|
||||
uiMenuItemO(head, "IMAGE_OT_save_as", ICON_BLANK1); // Save As...
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_replace"); // Replace...
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_reload"); // Reload...|Alt R
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_save"); // Save|Alt S
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_save_as"); // Save As...
|
||||
if(ima->source == IMA_SRC_SEQUENCE)
|
||||
uiMenuItemO(head, "IMAGE_OT_save_changed", ICON_BLANK1); // Save Changed Images
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_save_changed"); // Save Changed Images
|
||||
|
||||
if(!show_render) {
|
||||
uiMenuSeparator(head);
|
||||
|
||||
if(ima->packedfile) uiMenuItemO(head, "IMAGE_OT_unpack", ICON_BLANK1); // Unpack Image...
|
||||
else uiMenuItemO(head, "IMAGE_OT_pack", ICON_BLANK1); // Pack Image
|
||||
if(ima->packedfile) uiMenuItemO(head, 0, "IMAGE_OT_unpack"); // Unpack Image...
|
||||
else uiMenuItemO(head, 0, "IMAGE_OT_pack"); // Pack Image
|
||||
|
||||
/* only for dirty && specific image types : XXX poll? */
|
||||
if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
|
||||
if(ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_GENERATED) && ima->type != IMA_TYPE_MULTILAYER)
|
||||
uiMenuItemO(head, "IMAGE_OT_pack_as_png", ICON_BLANK1); // Pack Image As PNG
|
||||
uiMenuItemO(head, 0, "IMAGE_OT_pack_as_png"); // Pack Image As PNG
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
@ -344,9 +326,9 @@ static void do_image_uvs_showhidemenu(void *arg, int event)
|
||||
|
||||
static void image_uvs_showhidemenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
uiMenuItemO(head, "UV_OT_show_hidden_faces", ICON_BLANK1); // Show Hidden Faces|Alt H
|
||||
uiMenuItemO(head, "UV_OT_hide_selected_faces", ICON_BLANK1); // Hide Selected Faces|H
|
||||
uiMenuItemO(head, "UV_OT_hide_deselected_faces", ICON_BLANK1); // Hide Deselected Faces|Shift H
|
||||
uiMenuItemO(head, 0, "UV_OT_show_hidden_faces"); // Show Hidden Faces|Alt H
|
||||
uiMenuItemO(head, 0, "UV_OT_hide_selected_faces"); // Hide Selected Faces|H
|
||||
uiMenuItemO(head, 0, "UV_OT_hide_deselected_faces"); // Hide Deselected Faces|Shift H
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -371,67 +353,20 @@ static void do_image_uvs_transformmenu(void *arg, int event)
|
||||
|
||||
static void image_uvs_transformmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
uiMenuItemO(head, "UV_OT_grab", ICON_BLANK1); // Grab/Move|G
|
||||
uiMenuItemO(head, "UV_OT_rotate", ICON_BLANK1); // Rotate|R
|
||||
uiMenuItemO(head, "UV_OT_scale", ICON_BLANK1); // Scale|S
|
||||
uiMenuItemO(head, 0, "UV_OT_grab"); // Grab/Move|G
|
||||
uiMenuItemO(head, 0, "UV_OT_rotate"); // Rotate|R
|
||||
uiMenuItemO(head, 0, "UV_OT_scale"); // Scale|S
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void do_image_uvs_mirrormenu(void *arg, int event)
|
||||
{
|
||||
float mat[3][3];
|
||||
|
||||
Mat3One(mat);
|
||||
|
||||
switch(event) {
|
||||
case 0: /* X axis */
|
||||
initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM);
|
||||
BIF_setSingleAxisConstraint(mat[0], " on global X axis");
|
||||
Transform();
|
||||
break;
|
||||
case 1: /* Y axis */
|
||||
initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM);
|
||||
BIF_setSingleAxisConstraint(mat[1], " on global Y axis");
|
||||
Transform();
|
||||
break;
|
||||
}
|
||||
|
||||
BIF_undo_push("Mirror UV");
|
||||
}
|
||||
#endif
|
||||
|
||||
static void image_uvs_mirrormenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
uiMenuItemEnumO(head, "UV_OT_mirror", "axis", 'x'); // "X Axis", M, 1
|
||||
uiMenuItemEnumO(head, "UV_OT_mirror", "axis", 'y'); // "Y Axis", M, 2
|
||||
uiMenuItemEnumO(head, 0, "UV_OT_mirror", "axis", 'x'); // "X Axis", M, 1
|
||||
uiMenuItemEnumO(head, 0, "UV_OT_mirror", "axis", 'y'); // "Y Axis", M, 2
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void do_image_uvs_weldalignmenu(void *arg, int event)
|
||||
{
|
||||
switch(event) {
|
||||
case 0: /* Weld */
|
||||
weld_align_tface_uv('w');
|
||||
break;
|
||||
case 1: /* Align Auto */
|
||||
weld_align_tface_uv('a');
|
||||
break;
|
||||
case 2: /* Align X */
|
||||
weld_align_tface_uv('x');
|
||||
break;
|
||||
case 3: /* Align Y */
|
||||
weld_align_tface_uv('y');
|
||||
break;
|
||||
}
|
||||
|
||||
if(event==0) BIF_undo_push("Weld UV");
|
||||
else if(ELEM3(event, 1, 2, 3)) BIF_undo_push("Align UV");
|
||||
}
|
||||
#endif
|
||||
|
||||
static void image_uvs_weldalignmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
uiMenuItemO(head, "UV_OT_weld", ICON_BLANK1); // W, 1
|
||||
uiMenuItemO(head, 0, "UV_OT_weld"); // W, 1
|
||||
uiMenuItemsEnumO(head, "UV_OT_align", "axis"); // W, 2/3/4
|
||||
}
|
||||
|
||||
@ -474,32 +409,9 @@ static void image_uvs_scriptsmenu (void *args_unused)
|
||||
static void do_uvsmenu(bContext *C, void *arg, int event)
|
||||
{
|
||||
switch(event) {
|
||||
case 2: /* UVs Clipped to Image Size */
|
||||
if(sima->flag & SI_CLIP_UV) sima->flag &= ~SI_CLIP_UV;
|
||||
else sima->flag |= SI_CLIP_UV;
|
||||
break;
|
||||
case 5: /* Proportional Edit (toggle) */
|
||||
if(G.scene->proportional)
|
||||
G.scene->proportional= 0;
|
||||
else
|
||||
G.scene->proportional= 1;
|
||||
break;
|
||||
case 7: /* UVs Snap to Pixel */
|
||||
sima->flag ^= SI_PIXELSNAP;
|
||||
break;
|
||||
case 8:
|
||||
pin_tface_uv(1);
|
||||
break;
|
||||
case 9:
|
||||
pin_tface_uv(0);
|
||||
break;
|
||||
case 10:
|
||||
unwrap_lscm(0);
|
||||
break;
|
||||
case 11:
|
||||
if(sima->flag & SI_LIVE_UNWRAP) sima->flag &= ~SI_LIVE_UNWRAP;
|
||||
else sima->flag |= SI_LIVE_UNWRAP;
|
||||
break;
|
||||
case 12:
|
||||
minimize_stretch_tface_uv();
|
||||
break;
|
||||
@ -536,16 +448,16 @@ static void image_uvsmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemBooleanR(head, &uvptr, "live_unwrap");
|
||||
uiMenuItemO(head, "UV_OT_unwrap", ICON_BLANK1); // Unwrap|E
|
||||
uiMenuItemO(head, "UV_OT_unpin", ICON_BLANK1); // Unpin|Alt P
|
||||
uiMenuItemO(head, "UV_OT_pin", ICON_BLANK1); // Pin|P
|
||||
uiMenuItemO(head, 0, "UV_OT_unwrap");
|
||||
uiMenuItemBooleanO(head, "Unpin", 0, "UV_OT_pin", "clear", 1);
|
||||
uiMenuItemO(head, 0, "UV_OT_pin");
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemO(head, "UV_OT_pack_islands", ICON_BLANK1); // Pack Islands|Ctr P
|
||||
uiMenuItemO(head, "UV_OT_average_islands", ICON_BLANK1); // Average Islands Scale|Ctrl A
|
||||
uiMenuItemO(head, "UV_OT_minimize_stretch", ICON_BLANK1); // Minimize Stretch...|Ctrl V
|
||||
uiMenuItemO(head, "UV_OT_stitch", ICON_BLANK1);
|
||||
uiMenuItemO(head, 0, "UV_OT_pack_islands");
|
||||
uiMenuItemO(head, 0, "UV_OT_average_islands_scale");
|
||||
uiMenuItemO(head, 0, "UV_OT_minimize_stretch");
|
||||
uiMenuItemO(head, 0, "UV_OT_stitch");
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
@ -885,6 +797,39 @@ static void do_image_buttons_set_uvlayer_callback(void *act, void *data)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void sima_idpoin_handle(bContext *C, ID *id, int event)
|
||||
{
|
||||
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
|
||||
switch(event) {
|
||||
case UI_ID_BROWSE:
|
||||
case UI_ID_DELETE:
|
||||
set_space_image(sima, scene, obedit, sima->image);
|
||||
|
||||
if(sima->image && sima->image->id.us==0)
|
||||
sima->image->id.us= 1;
|
||||
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
ED_undo_push(C, "Assign Image UV");
|
||||
break;
|
||||
case UI_ID_RENAME:
|
||||
break;
|
||||
case UI_ID_ADD_NEW:
|
||||
/* XXX not implemented */
|
||||
break;
|
||||
case UI_ID_OPEN:
|
||||
/* XXX not implemented */
|
||||
break;
|
||||
case UI_ID_ALONE:
|
||||
/* XXX not implemented */
|
||||
break;
|
||||
case UI_ID_PIN:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void image_header_buttons(const bContext *C, ARegion *ar)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
@ -948,6 +893,11 @@ void image_header_buttons(const bContext *C, ARegion *ar)
|
||||
uiBlockSetEmboss(block, UI_EMBOSS);
|
||||
|
||||
/* image select */
|
||||
|
||||
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
|
||||
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_BROWSE_RENDER|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
|
||||
xco += 8;
|
||||
|
||||
#if 0
|
||||
char naam[256];
|
||||
|
||||
@ -1128,7 +1078,7 @@ static int toolbox_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
show_uvedit= get_space_image_show_uvedit(sima, obedit);
|
||||
|
||||
head= uiPupMenuBegin("Toolbox");
|
||||
head= uiPupMenuBegin("Toolbox", 0);
|
||||
|
||||
uiMenuLevel(head, "View", image_viewmenu);
|
||||
if(show_uvedit) uiMenuLevel(head, "Select", image_selectmenu);
|
||||
|
@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "DNA_image_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
@ -34,12 +35,17 @@
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "BIF_gl.h"
|
||||
#include "BIF_glutil.h"
|
||||
|
||||
#include "ED_screen.h"
|
||||
|
||||
#include "RE_pipeline.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
|
||||
#define HEADER_HEIGHT 18
|
||||
|
||||
/* *********************** render callbacks ***************** */
|
||||
@ -48,9 +54,9 @@
|
||||
static ScrArea *image_area= NULL;
|
||||
|
||||
/* can get as well the full picture, as the parts while rendering */
|
||||
static void imagewindow_progress(ScrArea *sa, RenderResult *rr, volatile rcti *renrect)
|
||||
/* XXX will be obsolete, here for reference now */
|
||||
void imagewindow_progress(SpaceImage *sima, RenderResult *rr, volatile rcti *renrect)
|
||||
{
|
||||
SpaceImage *sima= sa->spacedata.first;
|
||||
float x1, y1, *rectf= NULL;
|
||||
unsigned int *rect32= NULL;
|
||||
int ymin, ymax, xmin, xmax;
|
||||
@ -119,171 +125,6 @@ static void imagewindow_progress(ScrArea *sa, RenderResult *rr, volatile rcti *r
|
||||
|
||||
}
|
||||
|
||||
/* in render window; display a couple of scanlines of rendered image */
|
||||
/* NOTE: called while render, so no malloc allowed! */
|
||||
static void imagewindow_progress_display_cb(void *handle, RenderResult *rr, volatile rcti *rect)
|
||||
{
|
||||
if (image_area) {
|
||||
imagewindow_progress(image_area, rr, rect);
|
||||
|
||||
/* no screen_swapbuffers, prevent any other window to draw */
|
||||
// XXX myswapbuffers();
|
||||
}
|
||||
}
|
||||
|
||||
/* unused, init_display_cb is called on each render */
|
||||
static void imagewindow_clear_display_cb(void *handle, RenderResult *rr)
|
||||
{
|
||||
if (image_area) {
|
||||
}
|
||||
}
|
||||
|
||||
/* returns biggest area that is not uv/image editor. Note that it uses buttons */
|
||||
/* window as the last possible alternative. */
|
||||
static ScrArea *biggest_non_image_area(bContext *C)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
ScrArea *sa, *big= NULL;
|
||||
int size, maxsize= 0, bwmaxsize= 0;
|
||||
short foundwin= 0;
|
||||
|
||||
for(sa= sc->areabase.first; sa; sa= sa->next) {
|
||||
if(sa->winx > 10 && sa->winy > 10) {
|
||||
size= sa->winx*sa->winy;
|
||||
if(sa->spacetype == SPACE_BUTS) {
|
||||
if(foundwin == 0 && size > bwmaxsize) {
|
||||
bwmaxsize= size;
|
||||
big= sa;
|
||||
}
|
||||
}
|
||||
else if(sa->spacetype != SPACE_IMAGE && size > maxsize) {
|
||||
maxsize= size;
|
||||
big= sa;
|
||||
foundwin= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return big;
|
||||
}
|
||||
|
||||
static ScrArea *biggest_area(bContext *C)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
ScrArea *sa, *big= NULL;
|
||||
int size, maxsize= 0;
|
||||
|
||||
for(sa= sc->areabase.first; sa; sa= sa->next) {
|
||||
size= sa->winx*sa->winy;
|
||||
if(size > maxsize) {
|
||||
maxsize= size;
|
||||
big= sa;
|
||||
}
|
||||
}
|
||||
return big;
|
||||
}
|
||||
|
||||
|
||||
/* if R_DISPLAYIMAGE
|
||||
use Image Window showing Render Result
|
||||
else: turn largest non-image area into Image Window (not to frustrate texture or composite usage)
|
||||
else: then we use Image Window anyway...
|
||||
if R_DISPSCREEN
|
||||
make a new temp fullscreen area with Image Window
|
||||
*/
|
||||
|
||||
static ScrArea *find_area_showing_r_result(bContext *C)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
ScrArea *sa;
|
||||
SpaceImage *sima;
|
||||
|
||||
/* find an imagewindow showing render result */
|
||||
for(sa=sc->areabase.first; sa; sa= sa->next) {
|
||||
if(sa->spacetype==SPACE_IMAGE) {
|
||||
sima= sa->spacedata.first;
|
||||
if(sima->image && sima->image->type==IMA_TYPE_R_RESULT)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sa;
|
||||
}
|
||||
|
||||
static ScrArea *imagewindow_set_render_display(bContext *C)
|
||||
{
|
||||
ScrArea *sa;
|
||||
SpaceImage *sima;
|
||||
|
||||
sa= find_area_showing_r_result(C);
|
||||
|
||||
if(sa==NULL) {
|
||||
/* find largest open non-image area */
|
||||
sa= biggest_non_image_area(C);
|
||||
if(sa) {
|
||||
// XXX newspace(sa, SPACE_IMAGE);
|
||||
sima= sa->spacedata.first;
|
||||
|
||||
/* makes ESC go back to prev space */
|
||||
sima->flag |= SI_PREVSPACE;
|
||||
}
|
||||
else {
|
||||
/* use any area of decent size */
|
||||
sa= biggest_area(C);
|
||||
if(sa->spacetype!=SPACE_IMAGE) {
|
||||
// XXX newspace(sa, SPACE_IMAGE);
|
||||
sima= sa->spacedata.first;
|
||||
|
||||
/* makes ESC go back to prev space */
|
||||
sima->flag |= SI_PREVSPACE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sima= sa->spacedata.first;
|
||||
|
||||
/* get the correct image, and scale it */
|
||||
sima->image= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
|
||||
|
||||
if(0) { // XXX G.displaymode==R_DISPLAYSCREEN) {
|
||||
if(sa->full==0) {
|
||||
sima->flag |= SI_FULLWINDOW;
|
||||
/* fullscreen works with lousy curarea */
|
||||
// XXX curarea= sa;
|
||||
// XXX area_fullscreen();
|
||||
// XXX sa= curarea;
|
||||
}
|
||||
}
|
||||
|
||||
return sa;
|
||||
}
|
||||
|
||||
static void imagewindow_init_display_cb(void *handle, RenderResult *rr)
|
||||
{
|
||||
bContext *C= NULL; // XXX
|
||||
|
||||
image_area= imagewindow_set_render_display(C);
|
||||
|
||||
if(image_area) {
|
||||
SpaceImage *sima= image_area->spacedata.first;
|
||||
|
||||
// XXX areawinset(image_area->win);
|
||||
|
||||
/* calc location using original size (tiles don't tell) */
|
||||
sima->centx= (image_area->winx - sima->zoom*(float)rr->rectx)/2.0f;
|
||||
sima->centy= (image_area->winy - sima->zoom*(float)rr->recty)/2.0f;
|
||||
|
||||
sima->centx-= sima->zoom*sima->xof;
|
||||
sima->centy-= sima->zoom*sima->yof;
|
||||
|
||||
// XXX drawimagespace(image_area, sima);
|
||||
// XXX if(image_area->headertype) scrarea_do_headdraw(image_area);
|
||||
|
||||
/* no screen_swapbuffers, prevent any other window to draw */
|
||||
// XXX myswapbuffers();
|
||||
|
||||
// XXX allqueue(REDRAWIMAGE, 0); /* redraw in end */
|
||||
}
|
||||
}
|
||||
|
||||
/* coming from BIF_toggle_render_display() */
|
||||
void imagewindow_toggle_render(bContext *C)
|
||||
@ -306,7 +147,7 @@ void imagewindow_toggle_render(bContext *C)
|
||||
// XXX addqueue(sa->win, ESCKEY, 1); /* also returns from fullscreen */
|
||||
}
|
||||
else {
|
||||
sa= imagewindow_set_render_display(C);
|
||||
// sa= imagewindow_set_render_display(C);
|
||||
// XXX scrarea_queue_headredraw(sa);
|
||||
// XXX scrarea_queue_winredraw(sa);
|
||||
}
|
||||
@ -325,12 +166,12 @@ static void imagewindow_renderinfo_cb(void *handle, RenderStats *rs)
|
||||
}
|
||||
}
|
||||
|
||||
void imagewindow_render_callbacks(Render *re)
|
||||
void ED_space_image_render_callbacks(bContext *C, Render *re)
|
||||
{
|
||||
/* XXX fill in correct handler */
|
||||
RE_display_init_cb(re, NULL, imagewindow_init_display_cb);
|
||||
RE_display_draw_cb(re, NULL, imagewindow_progress_display_cb);
|
||||
RE_display_clear_cb(re, NULL, imagewindow_clear_display_cb);
|
||||
RE_stats_draw_cb(re, NULL, imagewindow_renderinfo_cb);
|
||||
|
||||
// RE_display_init_cb(re, C, imagewindow_init_display_cb);
|
||||
// RE_display_draw_cb(re, C, imagewindow_progress_display_cb);
|
||||
// RE_display_clear_cb(re, C, imagewindow_clear_display_cb);
|
||||
RE_stats_draw_cb(re, C, imagewindow_renderinfo_cb);
|
||||
}
|
||||
|
||||
|
@ -387,6 +387,7 @@ static void image_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
case NC_OBJECT:
|
||||
switch(wmn->data) {
|
||||
case ND_GEOM_SELECT:
|
||||
case ND_GEOM_DATA:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
@ -487,6 +488,9 @@ void set_space_image(SpaceImage *sima, Scene *scene, Object *obedit, Image *ima)
|
||||
|
||||
if(ima == NULL || ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE)
|
||||
sima->flag &= ~SI_DRAWTOOL;
|
||||
|
||||
if(sima->image)
|
||||
BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
|
||||
}
|
||||
|
||||
ImBuf *get_space_image_buffer(SpaceImage *sima)
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "ED_screen.h"
|
||||
@ -60,9 +61,10 @@
|
||||
|
||||
/* ************************ header area region *********************** */
|
||||
|
||||
#define B_STOPRENDER 1
|
||||
|
||||
static void do_viewmenu(bContext *C, void *arg, int event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static uiBlock *dummy_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
@ -95,13 +97,73 @@ static uiBlock *dummy_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
static void do_info_buttons(bContext *C, void *arg, int event)
|
||||
{
|
||||
switch(event) {
|
||||
case B_STOPRENDER:
|
||||
G.afbreek= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void screen_idpoin_handle(bContext *C, ID *id, int event)
|
||||
{
|
||||
|
||||
switch(event) {
|
||||
case UI_ID_BROWSE:
|
||||
/* exception: can't set screens inside of area/region handers */
|
||||
WM_event_add_notifier(C, NC_SCREEN|ND_SCREENBROWSE, id);
|
||||
break;
|
||||
case UI_ID_DELETE:
|
||||
ED_undo_push(C, "");
|
||||
break;
|
||||
case UI_ID_RENAME:
|
||||
break;
|
||||
case UI_ID_ADD_NEW:
|
||||
/* XXX not implemented */
|
||||
break;
|
||||
case UI_ID_OPEN:
|
||||
/* XXX not implemented */
|
||||
break;
|
||||
case UI_ID_ALONE:
|
||||
/* XXX not implemented */
|
||||
break;
|
||||
case UI_ID_PIN:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void scene_idpoin_handle(bContext *C, ID *id, int event)
|
||||
{
|
||||
|
||||
switch(event) {
|
||||
case UI_ID_BROWSE:
|
||||
/* exception: can't set screens inside of area/region handers */
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, id);
|
||||
break;
|
||||
case UI_ID_DELETE:
|
||||
ED_undo_push(C, "");
|
||||
break;
|
||||
case UI_ID_RENAME:
|
||||
break;
|
||||
case UI_ID_ADD_NEW:
|
||||
/* XXX not implemented */
|
||||
break;
|
||||
case UI_ID_OPEN:
|
||||
/* XXX not implemented */
|
||||
break;
|
||||
case UI_ID_ALONE:
|
||||
/* XXX not implemented */
|
||||
break;
|
||||
case UI_ID_PIN:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void info_header_buttons(const bContext *C, ARegion *ar)
|
||||
{
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
bScreen *screen= CTX_wm_screen(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
SpaceInfo *si= sa->spacedata.first;
|
||||
uiBlock *block;
|
||||
int xco, yco= 3;
|
||||
|
||||
@ -139,13 +201,25 @@ void info_header_buttons(const bContext *C, ARegion *ar)
|
||||
xmax= GetButStringLength("Help");
|
||||
uiDefPulldownBut(block, dummy_viewmenu, NULL, "Help", xco, yco, xmax-3, 22, "");
|
||||
xco+= xmax;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
uiBlockSetEmboss(block, UI_EMBOSS);
|
||||
|
||||
if(screen->full==NULL) {
|
||||
si->screen= win->screen;
|
||||
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&si->screen, ID_SCR, NULL, xco, yco,
|
||||
screen_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_DELETE);
|
||||
xco += 8;
|
||||
si->scene= screen->scene;
|
||||
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&si->scene, ID_SCE, NULL, xco, yco,
|
||||
scene_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_DELETE);
|
||||
xco += 8;
|
||||
}
|
||||
|
||||
if(WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) {
|
||||
uiDefIconTextBut(block, BUT, B_STOPRENDER, ICON_REC, "Render", xco+5,yco,75,19, NULL, 0.0f, 0.0f, 0, 0, "Stop rendering");
|
||||
}
|
||||
|
||||
/* always as last */
|
||||
UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
|
||||
|
||||
|
@ -192,6 +192,17 @@ static void info_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
/* context changes */
|
||||
}
|
||||
|
||||
static void info_header_listener(ARegion *ar, wmNotifier *wmn)
|
||||
{
|
||||
/* context changes */
|
||||
switch(wmn->category) {
|
||||
case NC_SCENE:
|
||||
if(wmn->data==ND_RENDER_RESULT)
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* only called once, from space/spacetypes.c */
|
||||
void ED_spacetype_info(void)
|
||||
{
|
||||
@ -222,7 +233,7 @@ void ED_spacetype_info(void)
|
||||
art->regionid = RGN_TYPE_HEADER;
|
||||
art->minsizey= HEADERY;
|
||||
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
|
||||
|
||||
art->listener= info_header_listener;
|
||||
art->init= info_header_area_init;
|
||||
art->draw= info_header_area_draw;
|
||||
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "DNA_userdef_types.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_curve.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_library.h"
|
||||
@ -1051,10 +1052,8 @@ static void node_browse_scene_cb(bContext *C, void *ntree_v, void *node_v)
|
||||
node->id= NULL;
|
||||
}
|
||||
sce= BLI_findlink(&G.main->scene, node->menunr-1);
|
||||
if(sce!=CTX_data_scene(C)) {
|
||||
node->id= &sce->id;
|
||||
id_us_plus(node->id);
|
||||
}
|
||||
node->id= &sce->id;
|
||||
id_us_plus(node->id);
|
||||
|
||||
set_render_layers_title(C, node, NULL);
|
||||
nodeSetActive(ntree, node);
|
||||
@ -2524,57 +2523,86 @@ static void draw_nodespace_back_tex(ScrArea *sa, SpaceNode *snode)
|
||||
}
|
||||
#endif
|
||||
|
||||
void node_draw_link_bezier(View2D *v2d, float vec[4][3], int th_col1, int th_col2, int do_shaded)
|
||||
/* if v2d not NULL, it clips and returns 0 if not visible */
|
||||
int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol)
|
||||
{
|
||||
float dist;
|
||||
float dist, vec[4][2];
|
||||
|
||||
/* in v0 and v3 we put begin/end points */
|
||||
if(link->fromsock) {
|
||||
vec[0][0]= link->fromsock->locx;
|
||||
vec[0][1]= link->fromsock->locy;
|
||||
}
|
||||
else {
|
||||
if(snode==NULL) return 0;
|
||||
vec[0][0]= snode->mx;
|
||||
vec[0][1]= snode->my;
|
||||
}
|
||||
if(link->tosock) {
|
||||
vec[3][0]= link->tosock->locx;
|
||||
vec[3][1]= link->tosock->locy;
|
||||
}
|
||||
else {
|
||||
if(snode==NULL) return 0;
|
||||
vec[3][0]= snode->mx;
|
||||
vec[3][1]= snode->my;
|
||||
}
|
||||
|
||||
dist= 0.5f*ABS(vec[0][0] - vec[3][0]);
|
||||
|
||||
|
||||
/* check direction later, for top sockets */
|
||||
vec[1][0]= vec[0][0]+dist;
|
||||
vec[1][1]= vec[0][1];
|
||||
|
||||
vec[2][0]= vec[3][0]-dist;
|
||||
vec[2][1]= vec[3][1];
|
||||
// printf("-> %f %f %f %f %f\n", dist, vec[0][0], vec[3][0], vec[1][0], vec[2][0]);
|
||||
|
||||
if( MIN4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax); /* clipped */
|
||||
else if ( MAX4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin); /* clipped */
|
||||
if(v2d && MIN4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax); /* clipped */
|
||||
else if (v2d && MAX4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin); /* clipped */
|
||||
else {
|
||||
float curve_res = 24, spline_step = 0.0f;
|
||||
|
||||
/* always do all three, to prevent data hanging around */
|
||||
forward_diff_bezier(vec[0][0], vec[1][0], vec[2][0], vec[3][0], coord_array[0], resol, 2);
|
||||
forward_diff_bezier(vec[0][1], vec[1][1], vec[2][1], vec[3][1], coord_array[0]+1, resol, 2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define LINK_RESOL 24
|
||||
void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int th_col2, int do_shaded)
|
||||
{
|
||||
float coord_array[LINK_RESOL+1][2];
|
||||
|
||||
if(node_link_bezier_points(v2d, snode, link, coord_array, LINK_RESOL)) {
|
||||
float dist, spline_step = 0.0f;
|
||||
int i;
|
||||
|
||||
/* we can reuse the dist variable here to increment the GL curve eval amount*/
|
||||
dist = 1.0f/curve_res;
|
||||
dist = 1.0f/(float)LINK_RESOL;
|
||||
|
||||
glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, vec[0]);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
while (spline_step < 1.000001f) {
|
||||
if(do_shaded)
|
||||
for(i=0; i<LINK_RESOL; i++) {
|
||||
if(do_shaded) {
|
||||
UI_ThemeColorBlend(th_col1, th_col2, spline_step);
|
||||
glEvalCoord1f(spline_step);
|
||||
spline_step += dist;
|
||||
spline_step += dist;
|
||||
}
|
||||
glVertex2fv(coord_array[i]);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* note; this is used for fake links in groups too */
|
||||
void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
|
||||
{
|
||||
float vec[4][3];
|
||||
float mx=0.0f, my=0.0f;
|
||||
int do_shaded= 1, th_col1= TH_WIRE, th_col2= TH_WIRE;
|
||||
|
||||
if(link->fromnode==NULL && link->tonode==NULL)
|
||||
return;
|
||||
|
||||
/* XXX fix -> notifier thingymajiggle this is dragging link */
|
||||
if(link->fromnode==NULL || link->tonode==NULL) {
|
||||
// short mval[2];
|
||||
// XXX getmouseco_areawin(mval);
|
||||
// XXX areamouseco_to_ipoco(v2d, mval, &mx, &my);
|
||||
UI_ThemeColor(TH_WIRE);
|
||||
do_shaded= 0;
|
||||
}
|
||||
@ -2605,28 +2633,7 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
|
||||
}
|
||||
}
|
||||
|
||||
vec[0][2]= vec[1][2]= vec[2][2]= vec[3][2]= 0.0; /* only 2d spline, set the Z to 0*/
|
||||
|
||||
/* in v0 and v3 we put begin/end points */
|
||||
if(link->fromnode) {
|
||||
vec[0][0]= link->fromsock->locx;
|
||||
vec[0][1]= link->fromsock->locy;
|
||||
}
|
||||
else {
|
||||
vec[0][0]= mx;
|
||||
vec[0][1]= my;
|
||||
}
|
||||
if(link->tonode) {
|
||||
vec[3][0]= link->tosock->locx;
|
||||
vec[3][1]= link->tosock->locy;
|
||||
}
|
||||
else {
|
||||
vec[3][0]= mx;
|
||||
vec[3][1]= my;
|
||||
}
|
||||
|
||||
node_draw_link_bezier(v2d, vec, th_col1, th_col2, do_shaded);
|
||||
// fdrawbezier(vec);
|
||||
node_draw_link_bezier(v2d, snode, link, th_col1, th_col2, do_shaded);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -356,10 +356,10 @@ static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node)
|
||||
{
|
||||
bNodeSocket *valsock= NULL, *colsock= NULL, *vecsock= NULL;
|
||||
bNodeSocket *sock;
|
||||
float vec[4][3];
|
||||
bNodeLink link;
|
||||
int a;
|
||||
|
||||
vec[0][2]= vec[1][2]= vec[2][2]= vec[3][2]= 0.0; /* only 2d spline, set the Z to 0*/
|
||||
memset(&link, 0, sizeof(bNodeLink));
|
||||
|
||||
/* connect the first value buffer in with first value out */
|
||||
/* connect the first RGBA buffer in with first RGBA out */
|
||||
@ -381,25 +381,21 @@ static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node)
|
||||
if(valsock || colsock || vecsock) {
|
||||
for(a=0, sock= node->outputs.first; sock; sock= sock->next, a++) {
|
||||
if(nodeCountSocketLinks(snode->edittree, sock)) {
|
||||
vec[3][0]= sock->locx;
|
||||
vec[3][1]= sock->locy;
|
||||
link.tosock= sock;
|
||||
|
||||
if(sock->type==SOCK_VALUE && valsock) {
|
||||
vec[0][0]= valsock->locx;
|
||||
vec[0][1]= valsock->locy;
|
||||
node_draw_link_bezier(v2d, vec, TH_WIRE, TH_WIRE, 0);
|
||||
link.fromsock= valsock;
|
||||
node_draw_link_bezier(v2d, snode, &link, TH_WIRE, TH_WIRE, 0);
|
||||
valsock= NULL;
|
||||
}
|
||||
if(sock->type==SOCK_VECTOR && vecsock) {
|
||||
vec[0][0]= vecsock->locx;
|
||||
vec[0][1]= vecsock->locy;
|
||||
node_draw_link_bezier(v2d, vec, TH_WIRE, TH_WIRE, 0);
|
||||
link.fromsock= vecsock;
|
||||
node_draw_link_bezier(v2d, snode, &link, TH_WIRE, TH_WIRE, 0);
|
||||
vecsock= NULL;
|
||||
}
|
||||
if(sock->type==SOCK_RGBA && colsock) {
|
||||
vec[0][0]= colsock->locx;
|
||||
vec[0][1]= colsock->locy;
|
||||
node_draw_link_bezier(v2d, vec, TH_WIRE, TH_WIRE, 0);
|
||||
link.fromsock= colsock;
|
||||
node_draw_link_bezier(v2d, snode, &link, TH_WIRE, TH_WIRE, 0);
|
||||
colsock= NULL;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -141,7 +141,7 @@ void do_node_addmenu(bContext *C, void *arg, int event)
|
||||
// toolbox_mousepos(mval, 0 ); /* get initial mouse position */
|
||||
// areamouseco_to_ipoco(G.v2d, mval, &locx, &locy);
|
||||
// NODE_FIX_ME
|
||||
node= node_add_node(snode, event, 0.0, 0.0);
|
||||
node= node_add_node(snode, CTX_data_scene(C), event, 0.0, 0.0);
|
||||
|
||||
/* uses test flag */
|
||||
// XXX snode_autoconnect(snode, node, NODE_TEST);
|
||||
@ -648,14 +648,17 @@ static uiBlock *node_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
|
||||
static void do_node_buttons(bContext *C, void *arg, int event)
|
||||
{
|
||||
// NODE_FIX_ME : instead of using "current material/texture/scene" a la old buttons/G.scene
|
||||
// have a panel from which enumerates textures, materials and scenes.
|
||||
// NODE_FIX_ME : instead of using "current material/texture/scene", node editor can also pin context?
|
||||
// note: scene context better not gets overridden, that'll clash too much (ton)
|
||||
SpaceNode *snode= (SpaceNode*)CTX_wm_space_data(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Material *ma;
|
||||
Tex *tx;
|
||||
|
||||
switch(event) {
|
||||
case B_REDR:
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
break;
|
||||
case B_NODE_USEMAT:
|
||||
ma= (Material *)snode->id;
|
||||
if(ma) {
|
||||
@ -663,21 +666,17 @@ static void do_node_buttons(bContext *C, void *arg, int event)
|
||||
node_shader_default(ma);
|
||||
snode_set_context(snode, scene);
|
||||
}
|
||||
/* BIF_preview_changed(ID_MA);
|
||||
allqueue(REDRAWNODE, 0);
|
||||
allqueue(REDRAWBUTSSHADING, 0);
|
||||
allqueue(REDRAWIPO, 0);*/
|
||||
}
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
break;
|
||||
|
||||
case B_NODE_USESCENE:
|
||||
if(scene->use_nodes) {
|
||||
if(scene->nodetree==NULL)
|
||||
node_composit_default(scene);
|
||||
// addqueue(curarea->win, UI_BUT_EVENT, B_NODE_TREE_EXEC);
|
||||
}
|
||||
snode_set_context(snode, scene);
|
||||
// allqueue(REDRAWNODE, 0);
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
break;
|
||||
|
||||
case B_NODE_USETEX:
|
||||
@ -688,11 +687,8 @@ static void do_node_buttons(bContext *C, void *arg, int event)
|
||||
node_texture_default(tx);
|
||||
snode_set_context(snode, scene);
|
||||
}
|
||||
/* BIF_preview_changed(ID_TE);
|
||||
allqueue(REDRAWNODE, 0);
|
||||
allqueue(REDRAWBUTSSHADING, 0);
|
||||
allqueue(REDRAWIPO, 0);*/
|
||||
}
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -59,18 +59,17 @@ void NODE_OT_extend_select(struct wmOperatorType *ot);
|
||||
void NODE_OT_visibility_toggle(struct wmOperatorType *ot);
|
||||
void NODE_OT_fit_all(struct wmOperatorType *ot);
|
||||
void NODE_OT_border_select(struct wmOperatorType *ot);
|
||||
void NODE_OT_delete_selection(struct wmOperatorType *ot);
|
||||
|
||||
/* drawnode.c */
|
||||
void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link);
|
||||
void node_draw_link_bezier(View2D *v2d, float vec[][3], int th_col1, int th_col2, int do_shaded);
|
||||
void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int th_col2, int do_shaded);
|
||||
int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol);
|
||||
void draw_nodespace_back_pix(ScrArea *sa, SpaceNode *snode);
|
||||
|
||||
/* node_edit.c */
|
||||
bNode *next_node(bNodeTree *ntree);
|
||||
bNode *node_add_node(SpaceNode *snode, int type, float locx, float locy);
|
||||
bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float locy);
|
||||
void snode_set_context(SpaceNode *snode, Scene *scene);
|
||||
void scale_node(SpaceNode *snode, bNode *node);
|
||||
void snode_make_group_editable(SpaceNode *snode, bNode *gnode);
|
||||
void snode_home(ScrArea *sa, ARegion *ar, SpaceNode *snode);
|
||||
void node_set_active(SpaceNode *snode, bNode *node);
|
||||
@ -81,6 +80,11 @@ void node_texture_default(Tex *tx);
|
||||
void snode_composite_job(const struct bContext *C, ScrArea *sa);
|
||||
bNode *snode_get_editgroup(SpaceNode *snode);
|
||||
|
||||
void NODE_OT_link(struct wmOperatorType *ot);
|
||||
void NODE_OT_delete_selection(struct wmOperatorType *ot);
|
||||
void NODE_OT_size_widget(struct wmOperatorType *ot);
|
||||
void NODE_OT_links_cut(struct wmOperatorType *ot);
|
||||
|
||||
// XXXXXX
|
||||
|
||||
// XXX from BSE_node.h
|
||||
|
@ -56,6 +56,9 @@ void node_operatortypes(void)
|
||||
WM_operatortype_append(NODE_OT_fit_all);
|
||||
WM_operatortype_append(NODE_OT_border_select);
|
||||
WM_operatortype_append(NODE_OT_delete_selection);
|
||||
WM_operatortype_append(NODE_OT_link);
|
||||
WM_operatortype_append(NODE_OT_size_widget);
|
||||
WM_operatortype_append(NODE_OT_links_cut);
|
||||
}
|
||||
|
||||
void node_keymap(struct wmWindowManager *wm)
|
||||
@ -68,7 +71,11 @@ void node_keymap(struct wmWindowManager *wm)
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "NODE_OT_extend_select", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "select_type", NODE_SELECT_MOUSE);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "NODE_OT_extend_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "select_type", NODE_SELECT_MOUSE);
|
||||
|
||||
WM_keymap_add_item(keymap, "NODE_OT_visibility_toggle", ACTIONMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "NODE_OT_size_widget", LEFTMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "NODE_OT_visibility_toggle", LEFTMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "NODE_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "NODE_OT_fit_all", HOMEKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "NODE_OT_border_select", BKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "NODE_OT_delete_selection", XKEY, KM_PRESS, 0, 0);
|
||||
|
@ -124,8 +124,10 @@ static int node_select_exec(bContext *C, wmOperator *op)
|
||||
break;
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL); /* Do we need to pass the scene? */
|
||||
|
||||
/* need refresh/a notifier vs compo notifier */
|
||||
// XXX WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL); /* Do we need to pass the scene? */
|
||||
ED_region_tag_redraw(ar);
|
||||
|
||||
/* allow tweak event to work too */
|
||||
return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
@ -96,14 +96,6 @@ static int do_header_node(SpaceNode *snode, bNode *node, float mx, float my)
|
||||
// XXX node_hide_unhide_sockets(snode, node);
|
||||
}
|
||||
|
||||
|
||||
totr= node->totr;
|
||||
totr.xmin= totr.xmax-10.0f;
|
||||
totr.ymax= totr.ymin+10.0f;
|
||||
if(BLI_in_rctf(&totr, mx, my)) {
|
||||
// XXX scale_node(snode, node);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -116,13 +108,6 @@ static int do_header_hidden_node(SpaceNode *snode, bNode *node, float mx, float
|
||||
node->flag &= ~NODE_HIDDEN;
|
||||
return 1;
|
||||
}
|
||||
|
||||
totr.xmax= node->totr.xmax;
|
||||
totr.xmin= node->totr.xmax-15.0f;
|
||||
if(BLI_in_rctf(&totr, mx, my)) {
|
||||
scale_node(snode, node);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,7 @@
|
||||
|
||||
#include "ED_armature.h"
|
||||
#include "ED_object.h"
|
||||
#include "ED_screen.h"
|
||||
|
||||
#include "outliner_intern.h"
|
||||
|
||||
@ -132,7 +133,6 @@
|
||||
static void allqueue() {}
|
||||
static void BIF_undo_push() {}
|
||||
static void BIF_preview_changed() {}
|
||||
static void set_scene() {}
|
||||
static void error() {}
|
||||
static int pupmenu() {return 0;}
|
||||
|
||||
@ -1665,8 +1665,7 @@ static void tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops
|
||||
|
||||
sce= (Scene *)outliner_search_back(soops, te, ID_SCE);
|
||||
if(sce && scene != sce) {
|
||||
// XXX if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
|
||||
set_scene(sce);
|
||||
ED_screen_set_scene(C, sce);
|
||||
}
|
||||
|
||||
/* find associated base in current scene */
|
||||
@ -1845,8 +1844,7 @@ static int tree_element_active_world(Scene *scene, SpaceOops *soops, TreeElement
|
||||
|
||||
if(set) { // make new scene active
|
||||
if(sce && scene != sce) {
|
||||
// XXX if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
|
||||
set_scene(sce);
|
||||
// XXX ED_screen_set_scene(C, sce);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2188,8 +2186,7 @@ static int do_outliner_mouse_event(bContext *C, Scene *scene, ARegion *ar, Space
|
||||
/* editmode? */
|
||||
if(te->idcode==ID_SCE) {
|
||||
if(scene!=(Scene *)tselem->id) {
|
||||
// XXX if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
|
||||
set_scene((Scene *)tselem->id);
|
||||
ED_screen_set_scene(C, (Scene *)tselem->id);
|
||||
}
|
||||
}
|
||||
else if(ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) {
|
||||
@ -2249,8 +2246,22 @@ static int outliner_activate_click(bContext *C, wmOperator *op, wmEvent *event)
|
||||
if(te) {
|
||||
BIF_undo_push("Outliner click event");
|
||||
}
|
||||
else
|
||||
outliner_select(ar, soops);
|
||||
else {
|
||||
short selecting= -1;
|
||||
int row;
|
||||
|
||||
/* get row number - 100 here is just a dummy value since we don't need the column */
|
||||
UI_view2d_listview_view_to_cell(&ar->v2d, 1000, OL_H, 0.0f, 0.0f,
|
||||
fmval[0], fmval[1], NULL, &row);
|
||||
|
||||
/* select relevant row */
|
||||
outliner_select(soops, &soops->tree, &row, &selecting);
|
||||
|
||||
// XXX old flag found in old code, do we still use this?
|
||||
//soops->storeflag |= SO_TREESTORE_REDRAW;
|
||||
|
||||
BIF_undo_push("Outliner selection event");
|
||||
}
|
||||
|
||||
ED_region_tag_redraw(ar);
|
||||
|
||||
@ -2553,64 +2564,46 @@ void outliner_show_hierarchy(Scene *scene, SpaceOops *soops)
|
||||
BIF_undo_push("Outliner show hierarchy");
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void do_outliner_select(SpaceOops *soops, ListBase *lb, float y1, float y2, short *selecting)
|
||||
void outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *selecting)
|
||||
{
|
||||
TreeElement *te;
|
||||
TreeStoreElem *tselem;
|
||||
|
||||
if(y1>y2) SWAP(float, y1, y2);
|
||||
|
||||
for(te= lb->first; te; te= te->next) {
|
||||
for (te= lb->first; te && *index >= 0; te=te->next, (*index)--) {
|
||||
tselem= TREESTORE(te);
|
||||
|
||||
if(te->ys + OL_H < y1) return;
|
||||
if(te->ys < y2) {
|
||||
if((te->flag & TE_ICONROW)==0) {
|
||||
if(*selecting == -1) {
|
||||
if( tselem->flag & TSE_SELECTED) *selecting= 0;
|
||||
else *selecting= 1;
|
||||
/* if we've encountered the right item, set its 'Outliner' selection status */
|
||||
if (*index == 0) {
|
||||
/* this should be the last one, so no need to do anything with index */
|
||||
if ((te->flag & TE_ICONROW)==0) {
|
||||
/* -1 value means toggle testing for now... */
|
||||
if (*selecting == -1) {
|
||||
if (tselem->flag & TSE_SELECTED)
|
||||
*selecting= 0;
|
||||
else
|
||||
*selecting= 1;
|
||||
}
|
||||
if(*selecting) tselem->flag |= TSE_SELECTED;
|
||||
else tselem->flag &= ~TSE_SELECTED;
|
||||
|
||||
/* set selection */
|
||||
if (*selecting)
|
||||
tselem->flag |= TSE_SELECTED;
|
||||
else
|
||||
tselem->flag &= ~TSE_SELECTED;
|
||||
}
|
||||
}
|
||||
if((tselem->flag & TSE_CLOSED)==0) do_outliner_select(soops, &te->subtree, y1, y2, selecting);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* its own redraw loop... urm */
|
||||
void outliner_select(ARegion *ar, SpaceOops *so)
|
||||
{
|
||||
#if 0
|
||||
XXX
|
||||
float fmval[2], y1, y2;
|
||||
short yo=-1, selecting= -1;
|
||||
|
||||
UI_view2d_region_to_view(&ar->v2d, event->x, event->y, fmval, fmval+1);
|
||||
|
||||
y1= fmval[1];
|
||||
|
||||
while (get_mbut() & (L_MOUSE|R_MOUSE)) {
|
||||
UI_view2d_region_to_view(&ar->v2d, event->x, event->y, fmval, fmval+1);
|
||||
y2= fmval[1];
|
||||
|
||||
if(yo!=mval[1]) {
|
||||
/* select the 'ouliner row' */
|
||||
do_outliner_select(so, &so->tree, y1, y2, &selecting);
|
||||
yo= mval[1];
|
||||
|
||||
so->storeflag |= SO_TREESTORE_REDRAW;
|
||||
// XXX screen_swapbuffers();
|
||||
|
||||
y1= y2;
|
||||
else if ((tselem->flag & TSE_CLOSED)==0) {
|
||||
/* Only try selecting sub-elements if we haven't hit the right element yet
|
||||
*
|
||||
* Hack warning:
|
||||
* Index must be reduced before supplying it to the sub-tree to try to do
|
||||
* selection, however, we need to increment it again for the next loop to
|
||||
* function correctly
|
||||
*/
|
||||
(*index)--;
|
||||
outliner_select(soops, &te->subtree, index, selecting);
|
||||
(*index)++;
|
||||
}
|
||||
else PIL_sleep_ms(30);
|
||||
}
|
||||
|
||||
BIF_undo_push("Outliner selection");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ************ SELECTION OPERATIONS ********* */
|
||||
@ -2857,7 +2850,7 @@ static void outliner_do_object_operation(Scene *scene, SpaceOops *soops, ListBas
|
||||
// when objects selected in other scenes... dunno if that should be allowed
|
||||
Scene *sce= (Scene *)outliner_search_back(soops, te, ID_SCE);
|
||||
if(sce && scene != sce) {
|
||||
set_scene(sce);
|
||||
// XXX ED_screen_set_scene(C, sce);
|
||||
}
|
||||
|
||||
operation_cb(te, NULL, tselem);
|
||||
@ -2978,7 +2971,7 @@ void outliner_operation_menu(Scene *scene, ARegion *ar, SpaceOops *soops)
|
||||
Scene *sce= scene; // to be able to delete, scenes are set...
|
||||
outliner_do_object_operation(scene, soops, &soops->tree, object_select_cb);
|
||||
if(scene != sce) {
|
||||
set_scene(sce);
|
||||
// XXX ED_screen_set_scene(C, sce);
|
||||
}
|
||||
|
||||
str= "Select Objects";
|
||||
@ -3096,161 +3089,6 @@ void outliner_operation_menu(Scene *scene, ARegion *ar, SpaceOops *soops)
|
||||
|
||||
/* ***************** DRAW *************** */
|
||||
|
||||
static int tselem_rna_icon(PointerRNA *ptr)
|
||||
{
|
||||
StructRNA *rnatype= ptr->type;
|
||||
|
||||
if(rnatype == &RNA_Scene)
|
||||
return ICON_SCENE_DEHLT;
|
||||
else if(rnatype == &RNA_World)
|
||||
return ICON_WORLD;
|
||||
else if(rnatype == &RNA_Object)
|
||||
return ICON_OBJECT;
|
||||
else if(rnatype == &RNA_Mesh)
|
||||
return ICON_MESH;
|
||||
else if(rnatype == &RNA_MeshVertex)
|
||||
return ICON_VERTEXSEL;
|
||||
else if(rnatype == &RNA_MeshEdge)
|
||||
return ICON_EDGESEL;
|
||||
else if(rnatype == &RNA_MeshFace)
|
||||
return ICON_FACESEL;
|
||||
else if(rnatype == &RNA_MeshTextureFace)
|
||||
return ICON_FACESEL_HLT;
|
||||
else if(rnatype == &RNA_VertexGroup)
|
||||
return ICON_VGROUP;
|
||||
else if(rnatype == &RNA_VertexGroupElement)
|
||||
return ICON_VGROUP;
|
||||
else if(rnatype == &RNA_Curve)
|
||||
return ICON_CURVE;
|
||||
else if(rnatype == &RNA_MetaBall)
|
||||
return ICON_MBALL;
|
||||
else if(rnatype == &RNA_MetaElement)
|
||||
return ICON_OUTLINER_DATA_META;
|
||||
else if(rnatype == &RNA_Lattice)
|
||||
return ICON_LATTICE;
|
||||
else if(rnatype == &RNA_Armature)
|
||||
return ICON_ARMATURE;
|
||||
else if(rnatype == &RNA_Bone)
|
||||
return ICON_BONE_DEHLT;
|
||||
else if(rnatype == &RNA_Camera)
|
||||
return ICON_CAMERA;
|
||||
else if(rnatype == &RNA_LocalLamp)
|
||||
return ICON_LAMP;
|
||||
else if(rnatype == &RNA_AreaLamp)
|
||||
return ICON_LAMP;
|
||||
else if(rnatype == &RNA_SpotLamp)
|
||||
return ICON_LAMP;
|
||||
else if(rnatype == &RNA_SunLamp)
|
||||
return ICON_LAMP;
|
||||
else if(rnatype == &RNA_HemiLamp)
|
||||
return ICON_LAMP;
|
||||
else if(rnatype == &RNA_Lamp)
|
||||
return ICON_LAMP;
|
||||
else if(rnatype == &RNA_Group)
|
||||
return ICON_GROUP;
|
||||
else if(rnatype == &RNA_ParticleSystem)
|
||||
return ICON_PARTICLES;
|
||||
else if(rnatype == &RNA_ParticleSettings)
|
||||
return ICON_PARTICLES;
|
||||
else if(rnatype == &RNA_Material)
|
||||
return ICON_MATERIAL;
|
||||
else if(rnatype == &RNA_Texture)
|
||||
return ICON_TEXTURE;
|
||||
else if(rnatype == &RNA_TextureSlot)
|
||||
return ICON_TEXTURE;
|
||||
else if(rnatype == &RNA_WorldTextureSlot)
|
||||
return ICON_TEXTURE;
|
||||
else if(rnatype == &RNA_MaterialTextureSlot)
|
||||
return ICON_TEXTURE;
|
||||
else if(rnatype == &RNA_Image)
|
||||
return ICON_TEXTURE;
|
||||
else if(rnatype == &RNA_Screen)
|
||||
return ICON_SPLITSCREEN;
|
||||
else if(rnatype == &RNA_NodeTree)
|
||||
return ICON_NODE;
|
||||
else if(rnatype == &RNA_Text)
|
||||
return ICON_TEXT;
|
||||
else if(rnatype == &RNA_Sound)
|
||||
return ICON_SOUND;
|
||||
else if(rnatype == &RNA_Brush)
|
||||
return ICON_TPAINT_HLT;
|
||||
else if(rnatype == &RNA_Library)
|
||||
return ICON_LIBRARY_DEHLT;
|
||||
else if(rnatype == &RNA_Action)
|
||||
return ICON_ACTION;
|
||||
else if(rnatype == &RNA_FCurve)
|
||||
return ICON_IPO_DEHLT;
|
||||
//else if(rnatype == &RNA_Ipo)
|
||||
// return ICON_IPO_DEHLT;
|
||||
else if(rnatype == &RNA_Key)
|
||||
return ICON_SHAPEKEY;
|
||||
else if(rnatype == &RNA_Main)
|
||||
return ICON_BLENDER;
|
||||
else if(rnatype == &RNA_Struct)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_Property)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_BooleanProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_IntProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_FloatProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_StringProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_EnumProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_EnumPropertyItem)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_PointerProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_CollectionProperty)
|
||||
return ICON_RNA;
|
||||
else if(rnatype == &RNA_GameObjectSettings)
|
||||
return ICON_GAME;
|
||||
else if(rnatype == &RNA_ScriptLink)
|
||||
return ICON_PYTHON;
|
||||
|
||||
/* modifiers */
|
||||
else if(rnatype == &RNA_SubsurfModifier)
|
||||
return ICON_MOD_SUBSURF;
|
||||
else if(rnatype == &RNA_ArmatureModifier)
|
||||
return ICON_ARMATURE;
|
||||
else if(rnatype == &RNA_LatticeModifier)
|
||||
return ICON_LATTICE;
|
||||
else if(rnatype == &RNA_CurveModifier)
|
||||
return ICON_CURVE;
|
||||
else if(rnatype == &RNA_BuildModifier)
|
||||
return ICON_MOD_BUILD;
|
||||
else if(rnatype == &RNA_MirrorModifier)
|
||||
return ICON_MOD_MIRROR;
|
||||
else if(rnatype == &RNA_DecimateModifier)
|
||||
return ICON_MOD_DECIM;
|
||||
else if(rnatype == &RNA_WaveModifier)
|
||||
return ICON_MOD_WAVE;
|
||||
else if(rnatype == &RNA_HookModifier)
|
||||
return ICON_HOOK;
|
||||
else if(rnatype == &RNA_SoftbodyModifier)
|
||||
return ICON_MOD_SOFT;
|
||||
else if(rnatype == &RNA_BooleanModifier)
|
||||
return ICON_MOD_BOOLEAN;
|
||||
else if(rnatype == &RNA_ParticleInstanceModifier)
|
||||
return ICON_MOD_PARTICLEINSTANCE;
|
||||
else if(rnatype == &RNA_ParticleSystemModifier)
|
||||
return ICON_MOD_PARTICLES;
|
||||
else if(rnatype == &RNA_EdgeSplitModifier)
|
||||
return ICON_MOD_EDGESPLIT;
|
||||
else if(rnatype == &RNA_ArrayModifier)
|
||||
return ICON_MOD_ARRAY;
|
||||
else if(rnatype == &RNA_UVProjectModifier)
|
||||
return ICON_MOD_UVPROJECT;
|
||||
else if(rnatype == &RNA_DisplaceModifier)
|
||||
return ICON_MOD_DISPLACE;
|
||||
|
||||
else
|
||||
return ICON_DOT;
|
||||
}
|
||||
|
||||
static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElement *te)
|
||||
{
|
||||
if(tselem->type) {
|
||||
@ -3357,7 +3195,7 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
|
||||
UI_icon_draw(x, y, ICON_OBJECT);
|
||||
break;
|
||||
case TSE_RNA_STRUCT:
|
||||
UI_icon_draw(x, y, tselem_rna_icon(&te->rnaptr));
|
||||
UI_icon_draw(x, y, UI_GetIconRNA(&te->rnaptr));
|
||||
break;
|
||||
default:
|
||||
UI_icon_draw(x, y, ICON_DOT); break;
|
||||
@ -3704,20 +3542,19 @@ static void outliner_draw_tree(Scene *scene, ARegion *ar, SpaceOops *soops)
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // only once
|
||||
|
||||
if(ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) {
|
||||
// struct marks
|
||||
if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) {
|
||||
/* struct marks */
|
||||
UI_ThemeColorShadeAlpha(TH_BACK, -15, -200);
|
||||
//UI_ThemeColorShade(TH_BACK, -20);
|
||||
starty= (int)ar->v2d.tot.ymax-OL_H;
|
||||
outliner_draw_struct_marks(ar, soops, &soops->tree, &starty);
|
||||
}
|
||||
else {
|
||||
// selection first
|
||||
UI_GetThemeColor3fv(TH_BACK, col);
|
||||
glColor3f(col[0]+0.06f, col[1]+0.08f, col[2]+0.10f);
|
||||
starty= (int)ar->v2d.tot.ymax-OL_H;
|
||||
outliner_draw_selection(ar, soops, &soops->tree, &starty);
|
||||
}
|
||||
|
||||
/* always draw selection fill before hierarchy */
|
||||
UI_GetThemeColor3fv(TH_BACK, col);
|
||||
glColor3f(col[0]+0.06f, col[1]+0.08f, col[2]+0.10f);
|
||||
starty= (int)ar->v2d.tot.ymax-OL_H;
|
||||
outliner_draw_selection(ar, soops, &soops->tree, &starty);
|
||||
|
||||
// grey hierarchy lines
|
||||
UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.2f);
|
||||
@ -4089,79 +3926,6 @@ static void outliner_draw_rnacols(ARegion *ar, SpaceOops *soops, int sizex)
|
||||
v2d->cur.ymin);
|
||||
}
|
||||
|
||||
static uiBut *outliner_draw_rnabut(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
uiBut *but=NULL;
|
||||
const char *propname= RNA_property_identifier(ptr, prop);
|
||||
int arraylen= RNA_property_array_length(ptr, prop);
|
||||
|
||||
switch(RNA_property_type(ptr, prop)) {
|
||||
case PROP_BOOLEAN: {
|
||||
int value, length;
|
||||
|
||||
if(arraylen && index == -1)
|
||||
return NULL;
|
||||
|
||||
length= RNA_property_array_length(ptr, prop);
|
||||
|
||||
if(length)
|
||||
value= RNA_property_boolean_get_index(ptr, prop, index);
|
||||
else
|
||||
value= RNA_property_boolean_get(ptr, prop);
|
||||
|
||||
but= uiDefButR(block, TOG, 0, (value)? "True": "False", x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
|
||||
break;
|
||||
}
|
||||
case PROP_INT:
|
||||
case PROP_FLOAT:
|
||||
if(arraylen && index == -1) {
|
||||
if(RNA_property_subtype(ptr, prop) == PROP_COLOR)
|
||||
but= uiDefButR(block, COL, 0, "", x1, y1, x2, y2, ptr, propname, 0, 0, 0, -1, -1, NULL);
|
||||
}
|
||||
else
|
||||
but= uiDefButR(block, NUM, 0, "", x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
|
||||
break;
|
||||
case PROP_ENUM:
|
||||
but= uiDefButR(block, MENU, 0, NULL, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
|
||||
break;
|
||||
case PROP_STRING:
|
||||
but= uiDefButR(block, TEX, 0, "", x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
|
||||
break;
|
||||
case PROP_POINTER: {
|
||||
PointerRNA pptr;
|
||||
PropertyRNA *nameprop;
|
||||
char *text, *descr, textbuf[256];
|
||||
int icon;
|
||||
|
||||
pptr= RNA_property_pointer_get(ptr, prop);
|
||||
|
||||
if(!pptr.data)
|
||||
return NULL;
|
||||
|
||||
icon= tselem_rna_icon(&pptr);
|
||||
nameprop= RNA_struct_name_property(&pptr);
|
||||
|
||||
if(nameprop) {
|
||||
text= RNA_property_string_get_alloc(&pptr, nameprop, textbuf, sizeof(textbuf));
|
||||
descr= (char*)RNA_property_ui_description(&pptr, prop);
|
||||
but= uiDefIconTextBut(block, LABEL, 0, icon, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, descr);
|
||||
if(text != textbuf)
|
||||
MEM_freeN(text);
|
||||
}
|
||||
else {
|
||||
text= (char*)RNA_struct_ui_name(&pptr);
|
||||
descr= (char*)RNA_property_ui_description(&pptr, prop);
|
||||
but= uiDefIconTextBut(block, LABEL, 0, icon, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, descr);
|
||||
}
|
||||
}
|
||||
default:
|
||||
but= NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
return but;
|
||||
}
|
||||
|
||||
static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, int sizex, ListBase *lb)
|
||||
{
|
||||
TreeElement *te;
|
||||
@ -4179,13 +3943,13 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
|
||||
prop= te->directdata;
|
||||
|
||||
if(!(RNA_property_type(ptr, prop) == PROP_POINTER && (tselem->flag & TSE_CLOSED)==0))
|
||||
outliner_draw_rnabut(block, ptr, prop, -1, sizex, te->ys, OL_RNA_COL_SIZEX, OL_H-1);
|
||||
uiDefAutoButR(block, ptr, prop, -1, "", sizex, te->ys, OL_RNA_COL_SIZEX, OL_H-1);
|
||||
}
|
||||
else if(tselem->type == TSE_RNA_ARRAY_ELEM) {
|
||||
ptr= &te->rnaptr;
|
||||
prop= te->directdata;
|
||||
|
||||
outliner_draw_rnabut(block, ptr, prop, te->index, sizex, te->ys, OL_RNA_COL_SIZEX, OL_H-1);
|
||||
uiDefAutoButR(block, ptr, prop, te->index, "", sizex, te->ys, OL_RNA_COL_SIZEX, OL_H-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ void outliner_header_buttons(const struct bContext *C, struct ARegion *ar);
|
||||
/* outliner.c */
|
||||
void outliner_free_tree(struct ListBase *lb);
|
||||
void outliner_operation_menu(struct Scene *scene, struct ARegion *ar, struct SpaceOops *soops);
|
||||
void outliner_select(struct ARegion *ar, struct SpaceOops *so);
|
||||
void outliner_select(struct SpaceOops *soops, struct ListBase *lb, int *index, short *selecting);
|
||||
void draw_outliner(const struct bContext *C);
|
||||
|
||||
void OUTLINER_OT_activate_click(struct wmOperatorType *ot);
|
||||
|
@ -4906,10 +4906,18 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
|
||||
|
||||
}
|
||||
|
||||
/* bad exception, solve this! otherwise outline shows too late */
|
||||
if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
|
||||
cu= ob->data;
|
||||
/* still needed for curves hidden in other layers. depgraph doesnt handle that yet */
|
||||
if (cu->disp.first==NULL) makeDispListCurveTypes(scene, ob, 0);
|
||||
}
|
||||
|
||||
/* draw outline for selected solid objects, mesh does itself */
|
||||
if((v3d->flag & V3D_SELECT_OUTLINE) && ob->type!=OB_MESH) {
|
||||
if(dt>OB_WIRE && dt<OB_TEXTURE && ob!=scene->obedit && (flag && DRAW_SCENESET)==0) {
|
||||
if (!(ob->dtx&OB_DRAWWIRE) && (ob->flag&SELECT) && !(flag&DRAW_PICKING)) {
|
||||
|
||||
drawSolidSelect(scene, v3d, rv3d, base);
|
||||
}
|
||||
}
|
||||
@ -4925,7 +4933,6 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
|
||||
break;
|
||||
case OB_FONT:
|
||||
cu= ob->data;
|
||||
if (cu->disp.first==NULL) makeDispListCurveTypes(scene, ob, 0);
|
||||
if(cu->editfont) {
|
||||
draw_textcurs(cu->editfont->textcurs);
|
||||
|
||||
@ -5017,8 +5024,6 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
|
||||
case OB_CURVE:
|
||||
case OB_SURF:
|
||||
cu= ob->data;
|
||||
/* still needed for curves hidden in other layers. depgraph doesnt handle that yet */
|
||||
if (cu->disp.first==NULL) makeDispListCurveTypes(scene, ob, 0);
|
||||
|
||||
if(cu->editnurb) {
|
||||
drawnurb(scene, v3d, rv3d, base, cu->editnurb->first, dt);
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "DNA_action_types.h"
|
||||
#include "DNA_armature_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
@ -41,11 +43,13 @@
|
||||
#include "BLI_arithb.h"
|
||||
#include "BLI_rand.h"
|
||||
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "ED_armature.h"
|
||||
#include "ED_space_api.h"
|
||||
#include "ED_screen.h"
|
||||
|
||||
@ -298,6 +302,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
case ND_BONE_SELECT:
|
||||
case ND_TRANSFORM:
|
||||
case ND_GEOM_SELECT:
|
||||
case ND_GEOM_DATA:
|
||||
case ND_DRAW:
|
||||
case ND_MODIFIER:
|
||||
case ND_KEYS:
|
||||
@ -458,6 +463,93 @@ static int view3d_context(const bContext *C, bContextDataMember member, bContext
|
||||
|
||||
return 1;
|
||||
}
|
||||
else if(ELEM(member, CTX_DATA_SELECTED_BONES, CTX_DATA_SELECTED_EDITABLE_BONES)) {
|
||||
Object *obedit= scene->obedit; // XXX get from context?
|
||||
bArmature *arm= (obedit) ? obedit->data : NULL;
|
||||
EditBone *ebone, *flipbone=NULL;
|
||||
|
||||
if (arm && arm->edbo) {
|
||||
/* Attention: X-Axis Mirroring is also handled here... */
|
||||
for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
|
||||
/* first and foremost, bone must be visible and selected */
|
||||
if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) {
|
||||
/* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
|
||||
* so that most users of this data don't need to explicitly check for it themselves.
|
||||
*
|
||||
* We need to make sure that these mirrored copies are not selected, otherwise some
|
||||
* bones will be operated on twice.
|
||||
*/
|
||||
if (arm->flag & ARM_MIRROR_EDIT)
|
||||
flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
|
||||
/* if we're filtering for editable too, use the check for that instead, as it has selection check too */
|
||||
if (member == CTX_DATA_SELECTED_EDITABLE_BONES) {
|
||||
/* only selected + editable */
|
||||
if (EBONE_EDITABLE(ebone)) {
|
||||
CTX_data_list_add(result, ebone);
|
||||
|
||||
if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
|
||||
CTX_data_list_add(result, flipbone);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* only include bones if selected */
|
||||
CTX_data_list_add(result, ebone);
|
||||
|
||||
if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
|
||||
CTX_data_list_add(result, flipbone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if(member == CTX_DATA_SELECTED_PCHANS) {
|
||||
Object *obact= OBACT;
|
||||
bArmature *arm= (obact) ? obact->data : NULL;
|
||||
bPoseChannel *pchan;
|
||||
|
||||
if (obact && arm) {
|
||||
for (pchan= obact->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
/* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
|
||||
if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
|
||||
if (pchan->bone->flag & (BONE_SELECTED|BONE_ACTIVE))
|
||||
CTX_data_list_add(result, pchan);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if(member == CTX_DATA_ACTIVE_BONE) {
|
||||
Object *obedit= scene->obedit; // XXX get from context?
|
||||
bArmature *arm= (obedit) ? obedit->data : NULL;
|
||||
EditBone *ebone;
|
||||
|
||||
if (arm && arm->edbo) {
|
||||
for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
|
||||
if (EBONE_VISIBLE(arm, ebone)) {
|
||||
if (ebone->flag & BONE_ACTIVE) {
|
||||
CTX_data_pointer_set(result, ebone);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(member == CTX_DATA_ACTIVE_PCHAN) {
|
||||
Object *obact= OBACT;
|
||||
bPoseChannel *pchan;
|
||||
|
||||
pchan= get_active_posechannel(obact);
|
||||
if (pchan) {
|
||||
CTX_data_pointer_set(result, pchan);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1370,7 +1370,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
|
||||
static int perspo=V3D_PERSP;
|
||||
int viewnum;
|
||||
|
||||
viewnum = RNA_enum_get(op->ptr, "view");
|
||||
viewnum = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
/* Use this to test if we started out with a camera */
|
||||
|
||||
@ -1463,7 +1463,7 @@ void VIEW3D_OT_viewnumpad(wmOperatorType *ot)
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER;
|
||||
|
||||
RNA_def_enum(ot->srna, "view", prop_view_items, 0, "View", "");
|
||||
RNA_def_enum(ot->srna, "type", prop_view_items, 0, "View", "The Type of view");
|
||||
}
|
||||
|
||||
static EnumPropertyItem prop_view_orbit_items[] = {
|
||||
|
@ -44,9 +44,12 @@
|
||||
#include "DNA_view3d_types.h"
|
||||
#include "DNA_windowmanager_types.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_brush.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_curve.h"
|
||||
#include "BKE_depsgraph.h"
|
||||
@ -116,9 +119,6 @@
|
||||
/* XXX port over */
|
||||
static void handle_view3d_lock(void) {}
|
||||
static void allqueue(int x, int y) {}
|
||||
static void persptoetsen(int x) {}
|
||||
static void fly(void) {}
|
||||
static void editmesh_align_view_to_selected(void *x, int y) {}
|
||||
static void countall(void) {}
|
||||
extern void borderselect();
|
||||
static int retopo_mesh_paint_check() {return 0;}
|
||||
@ -143,8 +143,10 @@ void ED_view3d_exit_paint_modes(bContext *C)
|
||||
else if(G.f & G_WEIGHTPAINT)
|
||||
WM_operator_name_call(C, "VIEW3D_OT_wpaint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
|
||||
|
||||
if(G.f & G_SCULPTMODE)
|
||||
WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
|
||||
|
||||
// if(G.f & G_TEXTUREPAINT) set_texturepaint();
|
||||
// if(G.f & G_SCULPTMODE) set_sculptmode();
|
||||
if(G.f & G_PARTICLEEDIT) PE_set_particle_edit(CTX_data_scene(C));
|
||||
|
||||
G.f &= ~(G_VERTEXPAINT+G_TEXTUREPAINT+G_WEIGHTPAINT+G_SCULPTMODE+G_PARTICLEEDIT);
|
||||
@ -248,6 +250,7 @@ void do_layer_buttons(bContext *C, short event)
|
||||
allqueue(REDRAWNLA, 0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void do_view3d_view_camerasmenu(bContext *C, void *arg, int event)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
@ -278,7 +281,7 @@ static void do_view3d_view_camerasmenu(bContext *C, void *arg, int event)
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
static uiBlock *view3d_view_camerasmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
@ -311,6 +314,8 @@ static uiBlock *view3d_view_camerasmenu(bContext *C, ARegion *ar, void *arg_unus
|
||||
return block;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static void do_view3d_view_cameracontrolsmenu(bContext *C, void *arg, int event)
|
||||
{
|
||||
switch(event) {
|
||||
@ -366,6 +371,7 @@ static void do_view3d_view_cameracontrolsmenu(bContext *C, void *arg, int event)
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
}
|
||||
|
||||
|
||||
static uiBlock *view3d_view_cameracontrolsmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
/* static short tog=0; */
|
||||
@ -456,7 +462,7 @@ static void do_view3d_view_alignviewmenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
}
|
||||
#if 0
|
||||
|
||||
static uiBlock *view3d_view_alignviewmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
/* static short tog=0; */
|
||||
@ -483,18 +489,15 @@ static uiBlock *view3d_view_alignviewmenu(bContext *C, ARegion *ar, void *arg_un
|
||||
uiTextBoundsBlock(block, 50);
|
||||
return block;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_PYTHON
|
||||
// XXX static void do_view3d_view_spacehandlers(bContext *C, void *arg, int event)
|
||||
//{
|
||||
//}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static uiBlock *view3d_view_spacehandlers(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
/* XXX */
|
||||
return NULL;
|
||||
}
|
||||
#endif /* DISABLE_PYTHON */
|
||||
|
||||
|
||||
static void do_view3d_viewmenu(bContext *C, void *arg, int event)
|
||||
{
|
||||
@ -553,90 +556,84 @@ static void do_view3d_viewmenu(bContext *C, void *arg, int event)
|
||||
}
|
||||
allqueue(REDRAWVIEW3D, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void view3d_view_viewnavmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
uiMenuItemO(head, "VIEW3D_OT_view_fly_mode", ICON_BLANK1);
|
||||
// uiMenuItemO(head, 0, "VIEW3D_OT_view_fly_mode");
|
||||
|
||||
// uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemsEnumO(head, "VIEW3D_OT_view_orbit", "type");
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemEnumO(head, "VIEW3D_OT_view_orbit", "type", V3D_VIEW_STEPLEFT);
|
||||
uiMenuItemEnumO(head, "VIEW3D_OT_view_orbit", "type", V3D_VIEW_STEPRIGHT);
|
||||
uiMenuItemEnumO(head, "VIEW3D_OT_view_orbit", "type", V3D_VIEW_STEPUP);
|
||||
uiMenuItemEnumO(head, "VIEW3D_OT_view_orbit", "type", V3D_VIEW_STEPDOWN);
|
||||
uiMenuItemsEnumO(head, "VIEW3D_OT_view_pan", "type");
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemEnumO(head, "VIEW3D_OT_view_pan", "type", V3D_VIEW_PANLEFT);
|
||||
uiMenuItemEnumO(head, "VIEW3D_OT_view_pan", "type", V3D_VIEW_PANRIGHT);
|
||||
uiMenuItemEnumO(head, "VIEW3D_OT_view_pan", "type", V3D_VIEW_PANUP);
|
||||
uiMenuItemEnumO(head, "VIEW3D_OT_view_pan", "type", V3D_VIEW_PANDOWN);
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemFloatO(head, "Zoom in", "VIEW3D_OT_viewzoom", "delta", 1.0f);
|
||||
uiMenuItemFloatO(head, "Zoom out", "VIEW3D_OT_viewzoom", "delta", -1.0f);
|
||||
uiMenuItemFloatO(head, "Zoom in", 0, "VIEW3D_OT_viewzoom", "delta", 1.0f);
|
||||
uiMenuItemFloatO(head, "Zoom out", 0, "VIEW3D_OT_viewzoom", "delta", -1.0f);
|
||||
|
||||
}
|
||||
static void view3d_view_alignviewmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
|
||||
}
|
||||
static void view3d_view_camerasmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void view3d_viewmenu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
|
||||
uiMenuItemO(head, "VIEW3D_OT_toggle_transform_orientations_panel", ICON_MENU_PANEL); // Transform Orientations...
|
||||
uiMenuItemO(head, "VIEW3D_OT_toggle_render_preview_panel", ICON_MENU_PANEL); // render preview...
|
||||
uiMenuItemO(head, "VIEW3D_OT_toggle_view_properties_panel", ICON_MENU_PANEL); // View Properties....
|
||||
uiMenuItemO(head, "VIEW3D_OT_toggle_background_image_panel", ICON_MENU_PANEL); // Background Image....
|
||||
uiMenuItemO(head, "VIEW3D_OT_toggle_grease_pencil_panel", ICON_MENU_PANEL); // Grease Pencil....
|
||||
// uiMenuItemO(head, ICON_MENU_PANEL, "VIEW3D_OT_toggle_transform_orientations_panel"); // Transform Orientations...
|
||||
// uiMenuItemO(head, ICON_MENU_PANEL, "VIEW3D_OT_toggle_render_preview_panel"); // render preview...
|
||||
// uiMenuItemO(head, ICON_MENU_PANEL, "VIEW3D_OT_toggle_view_properties_panel"); // View Properties....
|
||||
// uiMenuItemO(head, ICON_MENU_PANEL, "VIEW3D_OT_toggle_background_image_panel"); // Background Image....
|
||||
// uiMenuItemO(head, ICON_MENU_PANEL, "VIEW3D_OT_toggle_grease_pencil_panel"); // Grease Pencil....
|
||||
|
||||
uiMenuSeparator(head);
|
||||
// uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemEnumO(head, "VIEW3D_OT_viewnumpad", "view", V3D_VIEW_CAMERA);
|
||||
uiMenuItemEnumO(head, "VIEW3D_OT_viewnumpad", "view", V3D_VIEW_TOP);
|
||||
uiMenuItemEnumO(head, "VIEW3D_OT_viewnumpad", "view", V3D_VIEW_FRONT);
|
||||
uiMenuItemEnumO(head, "VIEW3D_OT_viewnumpad", "view", V3D_VIEW_RIGHT);
|
||||
uiMenuItemEnumO(head, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_CAMERA);
|
||||
uiMenuItemEnumO(head, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_TOP);
|
||||
uiMenuItemEnumO(head, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_FRONT);
|
||||
uiMenuItemEnumO(head, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_RIGHT);
|
||||
|
||||
uiMenuLevel(head, "Cameras", view3d_view_camerasmenu);
|
||||
//uiMenuLevel(head, "Cameras", view3d_view_camerasmenu);
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemO(head, "VIEW3D_OT_view_persportho", ICON_BLANK1);
|
||||
uiMenuItemO(head, 0, "VIEW3D_OT_view_persportho");
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemO(head, "VIEW3D_OT_view_show_all_layers", ICON_BLANK1);
|
||||
// uiMenuItemO(head, 0, "VIEW3D_OT_view_show_all_layers");
|
||||
|
||||
uiMenuSeparator(head);
|
||||
// uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemO(head, "VIEW3D_OT_view_local_view", ICON_BLANK1);
|
||||
uiMenuItemO(head, "VIEW3D_OT_view_global_view", ICON_BLANK1);
|
||||
// uiMenuItemO(head, 0, "VIEW3D_OT_view_local_view");
|
||||
// uiMenuItemO(head, 0, "VIEW3D_OT_view_global_view");
|
||||
|
||||
uiMenuSeparator(head);
|
||||
// uiMenuSeparator(head);
|
||||
|
||||
uiMenuLevel(head, "View Navigation", view3d_view_viewnavmenu);
|
||||
uiMenuLevel(head, "Align View", view3d_view_alignviewmenu);
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemO(head, "VIEW3D_OT_clipping", ICON_BLANK1);
|
||||
uiMenuItemO(head, "VIEW3D_OT_border_zoom", ICON_BLANK1);
|
||||
|
||||
uiMenuContext(head, WM_OP_INVOKE_REGION_WIN);
|
||||
|
||||
uiMenuItemO(head, 0, "VIEW3D_OT_clipping");
|
||||
uiMenuItemO(head, 0, "VIEW3D_OT_border_zoom");
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemO(head, "VIEW3D_OT_viewcenter", ICON_BLANK1);
|
||||
uiMenuItemO(head, "VIEW3D_OT_viewhome", ICON_BLANK1);
|
||||
uiMenuItemO(head, 0, "VIEW3D_OT_viewcenter");
|
||||
uiMenuItemO(head, 0, "VIEW3D_OT_viewhome");
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
if(sa->full) uiMenuItemO(head, "SCREEN_OT_screen_full_area", ICON_BLANK1); // "Tile Window", Ctrl UpArrow
|
||||
else uiMenuItemO(head, "SCREEN_OT_screen_full_area", ICON_BLANK1); // "Maximize Window", Ctr DownArrow
|
||||
if(sa->full) uiMenuItemO(head, 0, "SCREEN_OT_screen_full_area"); // "Tile Window", Ctrl UpArrow
|
||||
else uiMenuItemO(head, 0, "SCREEN_OT_screen_full_area"); // "Maximize Window", Ctr DownArrow
|
||||
}
|
||||
#if 0
|
||||
static uiBlock *view3d_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
@ -4836,22 +4833,6 @@ void do_view3d_sculptmenu(bContext *C, void *arg, int event)
|
||||
sd->brush_type= event+1;
|
||||
ED_undo_push(C, "Brush type");
|
||||
break;
|
||||
case 7:
|
||||
br->flag ^= SCULPT_BRUSH_AIRBRUSH;
|
||||
ED_undo_push(C, "Airbrush");
|
||||
break;
|
||||
case 8:
|
||||
sd->symm ^= SYMM_X;
|
||||
ED_undo_push(C, "X Symmetry");
|
||||
break;
|
||||
case 9:
|
||||
sd->symm ^= SYMM_Y;
|
||||
ED_undo_push(C, "Y Symmetry");
|
||||
break;
|
||||
case 10:
|
||||
sd->symm ^= SYMM_Z;
|
||||
ED_undo_push(C, "Z Symmetry");
|
||||
break;
|
||||
case 11:
|
||||
if(v3d)
|
||||
v3d->pivot_last= !v3d->pivot_last;
|
||||
@ -4876,14 +4857,6 @@ void do_view3d_sculptmenu(bContext *C, void *arg, int event)
|
||||
case 17:
|
||||
sculpt_radialcontrol_start(RADIALCONTROL_SIZE);
|
||||
break;
|
||||
case 18:
|
||||
br->dir= br->dir==1 ? 2 : 1;
|
||||
ED_undo_push(C, "Add/Sub");
|
||||
break;
|
||||
}
|
||||
|
||||
allqueue(REDRAWBUTSEDIT, 0);
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -4905,6 +4878,40 @@ uiBlock *view3d_sculpt_inputmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
return block;
|
||||
}
|
||||
|
||||
static void view3d_sculpt_menu(bContext *C, uiMenuItem *head, void *arg_unused)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
Sculpt *s = CTX_data_tool_settings(C)->sculpt;
|
||||
PointerRNA rna;
|
||||
|
||||
RNA_pointer_create(&sc->id, &RNA_Sculpt, s, &rna);
|
||||
|
||||
uiMenuItemBooleanR(head, &rna, "symmetry_x");
|
||||
uiMenuItemBooleanR(head, &rna, "symmetry_y");
|
||||
uiMenuItemBooleanR(head, &rna, "symmetry_z");
|
||||
uiMenuItemBooleanR(head, &rna, "lock_x");
|
||||
uiMenuItemBooleanR(head, &rna, "lock_y");
|
||||
uiMenuItemBooleanR(head, &rna, "lock_z");
|
||||
|
||||
/* Brush settings */
|
||||
RNA_pointer_create(&sc->id, &RNA_Brush, s->brush, &rna);
|
||||
|
||||
/* Curve */
|
||||
uiMenuSeparator(head);
|
||||
uiMenuItemEnumO(head, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SHARP);
|
||||
uiMenuItemEnumO(head, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SMOOTH);
|
||||
uiMenuItemEnumO(head, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_MAX);
|
||||
|
||||
uiMenuSeparator(head);
|
||||
|
||||
uiMenuItemBooleanR(head, &rna, "airbrush");
|
||||
uiMenuItemBooleanR(head, &rna, "rake");
|
||||
uiMenuItemBooleanR(head, &rna, "anchored");
|
||||
uiMenuItemBooleanR(head, &rna, "space");
|
||||
|
||||
uiMenuItemBooleanR(head, &rna, "flip_direction");
|
||||
}
|
||||
|
||||
uiBlock *view3d_sculptmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
@ -4932,19 +4939,6 @@ uiBlock *view3d_sculptmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Strengthen Brush|Shift F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Rotate Brush|Ctrl F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, "");
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, (sd->flags & SCULPT_SYMM_Z ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Z Symmetry|Z", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, (sd->flags & SCULPT_SYMM_Y ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Y Symmetry|Y", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, (sd->flags & SCULPT_SYMM_X ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "X Symmetry|X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, "");
|
||||
|
||||
/* XXX if(sd->brush_type!=GRAB_BRUSH) {
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, (br->flag & SCULPT_BRUSH_AIRBRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Airbrush|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
|
||||
|
||||
if(sd->brush_type!=SMOOTH_BRUSH && sd->brush_type!=FLATTEN_BRUSH) {
|
||||
uiDefIconTextBut(block, BUTM, 1, (br->dir==1 ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Add|V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 18, "");
|
||||
}
|
||||
}*/
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
/* XXX uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==FLATTEN_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Flatten|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==LAYER_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Layer|L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
|
||||
@ -5432,7 +5426,6 @@ static void do_view3d_buttons(bContext *C, void *arg, int event)
|
||||
else if (v3d->modeselect == V3D_EDITMODE_SEL) {
|
||||
if(!obedit) {
|
||||
v3d->flag &= ~V3D_MODE;
|
||||
ED_view3d_exit_paint_modes(C);
|
||||
ED_object_enter_editmode(C, EM_WAITCURSOR);
|
||||
ED_undo_push(C, "Original"); /* here, because all over code enter_editmode is abused */
|
||||
}
|
||||
@ -5731,7 +5724,7 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o
|
||||
}
|
||||
else if( G.f & G_SCULPTMODE) {
|
||||
xmax= GetButStringLength("Sculpt");
|
||||
uiDefPulldownBut(block, view3d_sculptmenu, NULL, "Sculpt", xco, yco-2, xmax-3, 24, "");
|
||||
uiDefMenuBut(block, view3d_sculpt_menu, NULL, "Sculpt", xco, yco-2, xmax-3, 24, "");
|
||||
xco+= xmax;
|
||||
}
|
||||
else if (FACESEL_PAINT_TEST) {
|
||||
@ -6057,15 +6050,15 @@ static int editmesh_face_toolbox_invoke(bContext *C, wmOperator *op, wmEvent *ev
|
||||
{
|
||||
uiMenuItem *head;
|
||||
|
||||
head= uiPupMenuBegin("Edit Faces");
|
||||
head= uiPupMenuBegin("Edit Faces", 0);
|
||||
|
||||
uiMenuItemO(head, "MESH_OT_fill", ICON_BLANK1);
|
||||
uiMenuItemO(head, "MESH_OT_beauty_fill", ICON_BLANK1);
|
||||
uiMenuItemO(head, "MESH_OT_convert_quads_to_tris", ICON_BLANK1);
|
||||
uiMenuItemO(head, "MESH_OT_convert_tris_to_quads", ICON_BLANK1);
|
||||
uiMenuItemO(head, "MESH_OT_edge_flip", ICON_BLANK1);
|
||||
uiMenuItemO(head, "MESH_OT_faces_shade_smooth", ICON_BLANK1);
|
||||
uiMenuItemO(head, "MESH_OT_faces_shade_solid", ICON_BLANK1);
|
||||
uiMenuItemO(head, 0, "MESH_OT_fill");
|
||||
uiMenuItemO(head, 0, "MESH_OT_beauty_fill");
|
||||
uiMenuItemO(head, 0, "MESH_OT_convert_quads_to_tris");
|
||||
uiMenuItemO(head, 0, "MESH_OT_convert_tris_to_quads");
|
||||
uiMenuItemO(head, 0, "MESH_OT_edge_flip");
|
||||
uiMenuItemO(head, 0, "MESH_OT_faces_shade_smooth");
|
||||
uiMenuItemO(head, 0, "MESH_OT_faces_shade_solid");
|
||||
uiPupMenuEnd(C, head);
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
|
@ -124,19 +124,19 @@ void view3d_keymap(wmWindowManager *wm)
|
||||
RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewhome", CKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "center", 1);
|
||||
|
||||
/* numpad view hotkeys*/
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD0, KM_PRESS, 0, 0)->ptr, "view", V3D_VIEW_CAMERA);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, 0, 0)->ptr, "view", V3D_VIEW_FRONT);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD0, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_CAMERA);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_FRONT);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD2, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPDOWN);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, 0, 0)->ptr, "view", V3D_VIEW_RIGHT);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_RIGHT);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD4, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPLEFT);
|
||||
WM_keymap_add_item(keymap, "VIEW3D_OT_view_persportho", PAD5, KM_PRESS, 0, 0);
|
||||
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD6, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPRIGHT);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, 0, 0)->ptr, "view", V3D_VIEW_TOP);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_TOP);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD8, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPUP);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_CTRL, 0)->ptr, "view", V3D_VIEW_BACK);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_CTRL, 0)->ptr, "view", V3D_VIEW_LEFT);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_CTRL, 0)->ptr, "view", V3D_VIEW_BOTTOM);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_BACK);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_LEFT);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_BOTTOM);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD2, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANDOWN);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD4, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANLEFT);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD6, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANRIGHT);
|
||||
|
@ -366,14 +366,14 @@ static void viewRedrawForce(bContext *C, TransInfo *t)
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, NULL);
|
||||
}
|
||||
else if (t->spacetype==SPACE_IMAGE) {
|
||||
// XXX how to deal with lock?
|
||||
#if 0
|
||||
SpaceImage *sima= (SpaceImage*)t->sa->spacedata.first;
|
||||
if(sima->lock) force_draw_plus(SPACE_VIEW3D, 0);
|
||||
else force_draw(0);
|
||||
#endif
|
||||
|
||||
// XXX better notifier, and how to deal with lock?
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, t->obedit);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, t->obedit);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3440,12 +3440,12 @@ void remake_graph_transdata (TransInfo *t, ListBase *anim_data)
|
||||
sort_time_beztmaps(bezm, fcu->totvert);
|
||||
beztmap_to_data(t, fcu, bezm, fcu->totvert);
|
||||
|
||||
/* re-sort actual beztriples (perhaps this could be done using the beztmaps to save time?) */
|
||||
sort_time_fcurve(fcu);
|
||||
|
||||
/* free mapping stuff */
|
||||
MEM_freeN(bezm);
|
||||
|
||||
/* re-sort actual beztriples (perhaps this could be done using the beztmaps to save time?) */
|
||||
sort_time_fcurve(fcu);
|
||||
|
||||
/* make sure handles are all set correctly */
|
||||
testhandles_fcurve(fcu);
|
||||
}
|
||||
|
@ -44,35 +44,40 @@
|
||||
|
||||
#include "transform.h"
|
||||
|
||||
|
||||
static int select_orientation_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
int orientation = RNA_int_get(op->ptr, "orientation");
|
||||
int orientation = RNA_enum_get(op->ptr, "orientation");
|
||||
int custom_index= RNA_int_get(op->ptr, "custom_index");;
|
||||
|
||||
if(orientation == V3D_MANIP_CUSTOM)
|
||||
orientation += custom_index;
|
||||
|
||||
if (orientation > -1)
|
||||
{
|
||||
BIF_selectTransformOrientationValue(C, orientation);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
BIF_selectTransformOrientationValue(C, orientation);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int select_orientation_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
char *string = BIF_menustringTransformOrientation(C, "Orientation");
|
||||
uiMenuItem *head;
|
||||
|
||||
op->customdata = string;
|
||||
head= uiPupMenuBegin("Orientation", 0);
|
||||
BIF_menuTransformOrientation(C, head, NULL);
|
||||
uiPupMenuEnd(C, head);
|
||||
|
||||
uiPupMenuOperator(C, 0, op, "orientation", string);
|
||||
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
void TFM_OT_select_orientation(struct wmOperatorType *ot)
|
||||
{
|
||||
static EnumPropertyItem orientation_items[]= {
|
||||
{V3D_MANIP_GLOBAL, "GLOBAL", "Global", ""},
|
||||
{V3D_MANIP_NORMAL, "NORMAL", "Normal", ""},
|
||||
{V3D_MANIP_LOCAL, "LOCAL", "Local", ""},
|
||||
{V3D_MANIP_VIEW, "VIEW", "View", ""},
|
||||
{V3D_MANIP_CUSTOM, "CUSTOM", "Custom", ""},
|
||||
{0, NULL, NULL, NULL}};
|
||||
|
||||
/* identifiers */
|
||||
ot->name = "Select Orientation";
|
||||
ot->idname = "TFM_OT_select_orientation";
|
||||
@ -82,7 +87,8 @@ void TFM_OT_select_orientation(struct wmOperatorType *ot)
|
||||
ot->exec = select_orientation_exec;
|
||||
ot->poll = ED_operator_areaactive;
|
||||
|
||||
RNA_def_int(ot->srna, "orientation", -1, INT_MIN, INT_MAX, "Orientation", "DOC_BROKEN", INT_MIN, INT_MAX);
|
||||
RNA_def_enum(ot->srna, "orientation", orientation_items, V3D_MANIP_CUSTOM, "Orientation", "DOC_BROKEN");
|
||||
RNA_def_int(ot->srna, "custom_index", 0, 0, INT_MAX, "Custom Index", "", 0, INT_MAX);
|
||||
}
|
||||
|
||||
static void transformops_exit(bContext *C, wmOperator *op)
|
||||
@ -208,7 +214,7 @@ void TFM_OT_transform(struct wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Transform";
|
||||
ot->idname = "TFM_OT_transform";
|
||||
ot->flag= OPTYPE_REGISTER;
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke = transform_invoke;
|
||||
|
@ -57,6 +57,8 @@
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_util.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
|
||||
#include "transform.h"
|
||||
|
||||
/* *********************** TransSpace ************************** */
|
||||
@ -352,6 +354,21 @@ void BIF_selectTransformOrientationValue(bContext *C, int orientation) {
|
||||
v3d->twmode = orientation;
|
||||
}
|
||||
|
||||
void BIF_menuTransformOrientation(bContext *C, uiMenuItem *head, void *arg)
|
||||
{
|
||||
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
|
||||
TransformOrientation *ts;
|
||||
int i= V3D_MANIP_CUSTOM;
|
||||
|
||||
uiMenuItemEnumO(head, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_GLOBAL);
|
||||
uiMenuItemEnumO(head, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_LOCAL);
|
||||
uiMenuItemEnumO(head, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_NORMAL);
|
||||
uiMenuItemEnumO(head, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_VIEW);
|
||||
|
||||
for(ts = transform_spaces->first; ts; ts = ts->next)
|
||||
uiMenuItemIntO(head, ts->name, 0, "TFM_OT_select_orientation", "custom_index", i++);
|
||||
}
|
||||
|
||||
char * BIF_menustringTransformOrientation(const bContext *C, char *title) {
|
||||
char menu[] = "%t|Global%x0|Local%x1|Normal%x2|View%x3";
|
||||
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
|
||||
|
@ -113,7 +113,7 @@ void ED_undo_push_op(bContext *C, wmOperator *op)
|
||||
ED_undo_push(C, op->type->name);
|
||||
}
|
||||
|
||||
static int ed_undo_step(bContext *C, wmOperator *op, int step)
|
||||
static int ed_undo_step(bContext *C, int step)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
@ -161,13 +161,18 @@ static int ed_undo_step(bContext *C, wmOperator *op, int step)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ED_undo_pop(bContext *C)
|
||||
{
|
||||
ed_undo_step(C, 1);
|
||||
}
|
||||
|
||||
static int ed_undo_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
return ed_undo_step(C, op, 1);
|
||||
return ed_undo_step(C, 1);
|
||||
}
|
||||
static int ed_redo_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
return ed_undo_step(C, op, -1);
|
||||
return ed_undo_step(C, -1);
|
||||
}
|
||||
|
||||
void ED_undo_menu(bContext *C)
|
||||
|
@ -66,7 +66,10 @@ float uv_area(float uv[][2], int quad);
|
||||
void uv_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy);
|
||||
|
||||
/* operators */
|
||||
void UV_OT_de_select_all(struct wmOperatorType *ot);
|
||||
void UV_OT_pack_islands(struct wmOperatorType *ot);
|
||||
void UV_OT_unwrap(struct wmOperatorType *ot);
|
||||
void UV_OT_minimize_stretch(struct wmOperatorType *ot);
|
||||
void UV_OT_average_islands_scale(struct wmOperatorType *ot);
|
||||
|
||||
#endif /* ED_UVEDIT_INTERN_H */
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user