Merging r49212 through r49222 from trunk into soc-2011-tomato

This commit is contained in:
Sergey Sharybin
2012-07-25 19:46:23 +00:00
27 changed files with 583 additions and 301 deletions

View File

@@ -662,15 +662,16 @@ void print_qt(const char *str, const float q[4])
/* Axis angle to Quaternions */
void axis_angle_to_quat(float q[4], const float axis[3], const float angle)
{
float nor[3];
if (LIKELY(normalize_v3_v3(q + 1, axis) != 0.0f)) {
if (LIKELY(normalize_v3_v3(nor, axis) != 0.0f)) {
const float phi = angle / 2.0f;
float si;
si = sinf(phi);
q[0] = cosf(phi);
q[1] *= si;
q[2] *= si;
q[3] *= si;
q[1] = nor[0] * si;
q[2] = nor[1] * si;
q[3] = nor[2] * si;
}
else {
unit_qt(q);

View File

@@ -50,17 +50,17 @@ struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **lock
void ED_space_image_release_buffer(struct SpaceImage *sima, void *lock);
int ED_space_image_has_buffer(struct SpaceImage *sima);
void ED_space_image_size(struct SpaceImage *sima, int *width, int *height);
void ED_space_image_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
void ED_space_image_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy);
void ED_space_image_uv_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
void ED_space_image_get_size(struct SpaceImage *sima, int *width, int *height);
void ED_space_image_get_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
void ED_space_image_get_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy);
void ED_space_image_get_uv_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
void ED_space_image_paint_update(struct wmWindowManager *wm, struct ToolSettings *settings);
void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct ToolSettings *settings);
void ED_image_size(struct Image *ima, int *width, int *height);
void ED_image_aspect(struct Image *ima, float *aspx, float *aspy);
void ED_image_uv_aspect(struct Image *ima, float *aspx, float *aspy);
void ED_image_get_size(struct Image *ima, int *width, int *height);
void ED_image_get_aspect(struct Image *ima, float *aspx, float *aspy);
void ED_image_get_uv_aspect(struct Image *ima, float *aspx, float *aspy);
int ED_space_image_show_render(struct SpaceImage *sima);
int ED_space_image_show_paint(struct SpaceImage *sima);

View File

@@ -41,6 +41,7 @@ struct bContext;
struct bPoseChannel;
struct Curve;
struct EnumPropertyItem;
struct ID;
struct KeyBlock;
struct Lattice;
struct Main;
@@ -183,6 +184,9 @@ int ED_object_iter_other(struct Main *bmain, struct Object *orig_ob, int include
int ED_object_multires_update_totlevels_cb(struct Object *ob, void *totlevel_v);
/* ibject_select.c */
void ED_object_select_linked_by_id(struct bContext *C, struct ID *id);
#ifdef __cplusplus
}
#endif

View File

@@ -5845,6 +5845,8 @@ static int ui_handle_list_event(bContext *C, wmEvent *event, ARegion *ar)
else
value++;
CLAMP(value, 0, pa->list_last_len - 1);
if (value < pa->list_scroll)
pa->list_scroll = value;
else if (value >= pa->list_scroll + pa->list_size)

View File

@@ -48,6 +48,8 @@
#include "ED_sequencer.h"
#include "ED_transform.h"
#include "UI_view2d.h"
#include "RNA_access.h"
#include "mask_intern.h" /* own include */
@@ -101,11 +103,17 @@ void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2])
break;
}
case SPACE_SEQ:
zero_v2(co); /* MASKTODO */
{
ARegion *ar = CTX_wm_region(C);
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
break;
}
case SPACE_IMAGE:
zero_v2(co); /* MASKTODO */
{
ARegion *ar = CTX_wm_region(C);
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
break;
}
default:
/* possible other spaces from which mask editing is available */
BLI_assert(0);
@@ -139,8 +147,11 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr
zero_v2(co); /* MASKTODO */
break;
case SPACE_IMAGE:
{
//SpaceImage *sima = sa->spacedata.first;
zero_v2(co); /* MASKTODO */
break;
}
default:
/* possible other spaces from which mask editing is available */
BLI_assert(0);
@@ -215,7 +226,7 @@ void ED_mask_size(const bContext *C, int *width, int *height)
case SPACE_IMAGE:
{
SpaceImage *sima = sa->spacedata.first;
ED_space_image_size(sima, width, height);
ED_space_image_get_size(sima, width, height);
break;
}
default:
@@ -251,8 +262,8 @@ void ED_mask_aspect(const bContext *C, float *aspx, float *aspy)
}
case SPACE_IMAGE:
{
// SpaceImage *sima = sa->spacedata.first;
*aspx = *aspy = 1.0f; /* MASKTODO - image aspect? */
SpaceImage *sima = sa->spacedata.first;
ED_space_image_get_aspect(sima, aspx, aspy);
break;
}
default:
@@ -270,25 +281,53 @@ void ED_mask_aspect(const bContext *C, float *aspx, float *aspy)
void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley)
{
SpaceClip *sc = CTX_wm_space_clip(C);
ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacedata.first) {
switch (sa->spacetype) {
case SPACE_CLIP:
{
SpaceClip *sc = sa->spacedata.first;
int width, height;
float zoomx, zoomy, aspx, aspy;
/* MASKTODO */
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_zoom(C, &zoomx, &zoomy);
ED_space_clip_get_aspect(sc, &aspx, &aspy);
if (sc) {
int width, height;
float zoomx, zoomy, aspx, aspy;
*scalex = ((float)width * aspx) * zoomx;
*scaley = ((float)height * aspy) * zoomy;
break;
}
case SPACE_SEQ:
{
*scalex = *scaley = 1.0f; /* MASKTODO? */
break;
}
case SPACE_IMAGE:
{
SpaceImage *sima = sa->spacedata.first;
ARegion *ar = CTX_wm_region(C);
int width, height;
float zoomx, zoomy, aspx, aspy;
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_zoom(C, &zoomx, &zoomy);
ED_space_clip_get_aspect(sc, &aspx, &aspy);
ED_space_image_get_size(sima, &width, &height);
ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
ED_space_image_get_aspect(sima, &aspx, &aspy);
*scalex = ((float)width * aspx) * zoomx;
*scaley = ((float)height * aspy) * zoomy;
*scalex = ((float)width * aspx) * zoomx;
*scaley = ((float)height * aspy) * zoomy;
break;
}
default:
/* possible other spaces from which mask editing is available */
BLI_assert(0);
*scalex = *scaley = 1.0f;
break;
}
}
else {
/* possible other spaces from which mask editing is available */
*scalex = 1.0f;
*scaley = 1.0f;
BLI_assert(0);
*scalex = *scaley = 1.0f;
}
}

View File

@@ -186,36 +186,217 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot)
/*********************** Selection by Links *********************/
enum {
OBJECT_SELECT_LINKED_IPO = 1,
OBJECT_SELECT_LINKED_OBDATA,
OBJECT_SELECT_LINKED_MATERIAL,
OBJECT_SELECT_LINKED_TEXTURE,
OBJECT_SELECT_LINKED_DUPGROUP,
OBJECT_SELECT_LINKED_PARTICLE,
OBJECT_SELECT_LINKED_LIBRARY,
OBJECT_SELECT_LINKED_LIBRARY_OBDATA
};
static EnumPropertyItem prop_select_linked_types[] = {
//{1, "IPO", 0, "Object IPO", ""}, // XXX depreceated animation system stuff...
{2, "OBDATA", 0, "Object Data", ""},
{3, "MATERIAL", 0, "Material", ""},
{4, "TEXTURE", 0, "Texture", ""},
{5, "DUPGROUP", 0, "Dupligroup", ""},
{6, "PARTICLE", 0, "Particle System", ""},
{7, "LIBRARY", 0, "Library", ""},
{8, "LIBRARY_OBDATA", 0, "Library (Object Data)", ""},
//{OBJECT_SELECT_LINKED_IPO, "IPO", 0, "Object IPO", ""}, // XXX depreceated animation system stuff...
{OBJECT_SELECT_LINKED_OBDATA, "OBDATA", 0, "Object Data", ""},
{OBJECT_SELECT_LINKED_MATERIAL, "MATERIAL", 0, "Material", ""},
{OBJECT_SELECT_LINKED_TEXTURE, "TEXTURE", 0, "Texture", ""},
{OBJECT_SELECT_LINKED_DUPGROUP, "DUPGROUP", 0, "Dupligroup", ""},
{OBJECT_SELECT_LINKED_PARTICLE, "PARTICLE", 0, "Particle System", ""},
{OBJECT_SELECT_LINKED_LIBRARY, "LIBRARY", 0, "Library", ""},
{OBJECT_SELECT_LINKED_LIBRARY_OBDATA, "LIBRARY_OBDATA", 0, "Library (Object Data)", ""},
{0, NULL, 0, NULL, NULL}
};
// XXX old animation system
#if 0
static int object_select_all_by_ipo(bContext *C, Ipo *ipo)
{
int changed = FALSE;
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
{
if (base->object->ipo == ipo) {
base->flag |= SELECT;
base->object->flag = base->flag;
changed = TRUE;
}
}
CTX_DATA_END;
return changed;
}
#endif
static int object_select_all_by_obdata(bContext *C, void *obdata)
{
int changed = FALSE;
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
{
if (base->object->data == obdata) {
base->flag |= SELECT;
base->object->flag = base->flag;
changed = TRUE;
}
}
CTX_DATA_END;
return changed;
}
static int object_select_all_by_material_texture(bContext *C, int use_texture, Material *mat, Tex *tex)
{
int changed = FALSE;
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
{
Object *ob = base->object;
Material *mat1;
int a, b;
for (a = 1; a <= ob->totcol; a++) {
mat1 = give_current_material(ob, a);
if (!use_texture) {
if (mat1 == mat) {
base->flag |= SELECT;
changed = TRUE;
}
}
else if (mat1 && use_texture) {
for (b = 0; b < MAX_MTEX; b++) {
if (mat1->mtex[b]) {
if (tex == mat1->mtex[b]->tex) {
base->flag |= SELECT;
changed = TRUE;
break;
}
}
}
}
}
base->object->flag = base->flag;
}
CTX_DATA_END;
return changed;
}
static int object_select_all_by_dup_group(bContext *C, Group *dup_group)
{
int changed = FALSE;
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
{
if (base->object->dup_group == dup_group) {
base->flag |= SELECT;
base->object->flag = base->flag;
changed = TRUE;
}
}
CTX_DATA_END;
return changed;
}
static int object_select_all_by_particle(bContext *C, Object *ob)
{
int changed = FALSE;
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
{
/* loop through other, then actives particles*/
ParticleSystem *psys;
ParticleSystem *psys_act;
for (psys = base->object->particlesystem.first; psys; psys = psys->next) {
for (psys_act = ob->particlesystem.first; psys_act; psys_act = psys_act->next) {
if (psys->part == psys_act->part) {
base->flag |= SELECT;
changed = TRUE;
break;
}
}
if (base->flag & SELECT) {
break;
}
}
base->object->flag = base->flag;
}
CTX_DATA_END;
return changed;
}
static int object_select_all_by_library(bContext *C, Library *lib)
{
int changed = FALSE;
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
{
if (lib == base->object->id.lib) {
base->flag |= SELECT;
base->object->flag = base->flag;
changed = TRUE;
}
}
CTX_DATA_END;
return changed;
}
static int object_select_all_by_library_obdata(bContext *C, Library *lib)
{
int changed = FALSE;
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
{
if (base->object->data && lib == ((ID *)base->object->data)->lib) {
base->flag |= SELECT;
base->object->flag = base->flag;
changed = TRUE;
}
}
CTX_DATA_END;
return changed;
}
void ED_object_select_linked_by_id(bContext *C, ID *id)
{
int gs = GS(id->name);
int changed = FALSE;
if (ELEM8(gs, ID_ME, ID_CU, ID_MB, ID_LT, ID_LA, ID_CA, ID_TXT, ID_SPK)) {
changed = object_select_all_by_obdata(C, id);
}
else if (gs == ID_MA) {
changed = object_select_all_by_material_texture(C, FALSE, (Material *)id, NULL);
}
else if (gs == ID_LI) {
changed = object_select_all_by_library(C, (Library *) id);
}
if (changed)
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
}
static int object_select_linked_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *ob;
void *obdata = NULL;
Material *mat = NULL, *mat1;
Tex *tex = NULL;
int a, b;
int nr = RNA_enum_get(op->ptr, "type");
short changed = 0, extend;
/* events (nr):
* Object Ipo: 1
* ObData: 2
* Current Material: 3
* Current Texture: 4
* DupliGroup: 5
* PSys: 6
*/
short changed = FALSE, extend;
extend = RNA_boolean_get(op->ptr, "extend");
@@ -233,113 +414,59 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
if (nr == 1) {
if (nr == OBJECT_SELECT_LINKED_IPO) {
// XXX old animation system
//ipo= ob->ipo;
//if (ipo==0) return OPERATOR_CANCELLED;
//if (ob->ipo==0) return OPERATOR_CANCELLED;
//object_select_all_by_ipo(C, ob->ipo)
return OPERATOR_CANCELLED;
}
else if (nr == 2) {
if (ob->data == NULL) return OPERATOR_CANCELLED;
obdata = ob->data;
else if (nr == OBJECT_SELECT_LINKED_OBDATA) {
if (ob->data == 0)
return OPERATOR_CANCELLED;
changed = object_select_all_by_obdata(C, ob->data);
}
else if (nr == 3 || nr == 4) {
else if (nr == OBJECT_SELECT_LINKED_MATERIAL || nr == OBJECT_SELECT_LINKED_TEXTURE) {
Material *mat = NULL;
Tex *tex = NULL;
int use_texture = FALSE;
mat = give_current_material(ob, ob->actcol);
if (mat == NULL) return OPERATOR_CANCELLED;
if (nr == 4) {
if (nr == OBJECT_SELECT_LINKED_TEXTURE) {
use_texture = TRUE;
if (mat->mtex[(int)mat->texact]) tex = mat->mtex[(int)mat->texact]->tex;
if (tex == NULL) return OPERATOR_CANCELLED;
}
changed = object_select_all_by_material_texture(C, use_texture, mat, tex);
}
else if (nr == 5) {
if (ob->dup_group == NULL) return OPERATOR_CANCELLED;
else if (nr == OBJECT_SELECT_LINKED_DUPGROUP) {
if (ob->dup_group == NULL)
return OPERATOR_CANCELLED;
changed = object_select_all_by_dup_group(C, ob->dup_group);
}
else if (nr == 6) {
if (ob->particlesystem.first == NULL) return OPERATOR_CANCELLED;
else if (nr == OBJECT_SELECT_LINKED_PARTICLE) {
if (ob->particlesystem.first == NULL)
return OPERATOR_CANCELLED;
changed = object_select_all_by_particle(C, ob);
}
else if (nr == 7) {
else if (nr == OBJECT_SELECT_LINKED_LIBRARY) {
/* do nothing */
changed = object_select_all_by_library(C, ob->id.lib);
}
else if (nr == 8) {
if (ob->data == NULL) return OPERATOR_CANCELLED;
else if (nr == OBJECT_SELECT_LINKED_LIBRARY_OBDATA) {
if (ob->data == NULL)
return OPERATOR_CANCELLED;
changed = object_select_all_by_library_obdata(C, ((ID *) ob->data)->lib);
}
else
return OPERATOR_CANCELLED;
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
{
if (nr == 1) {
// XXX old animation system
//if (base->object->ipo == ipo) base->flag |= SELECT;
//changed = 1;
}
else if (nr == 2) {
if (base->object->data == obdata) base->flag |= SELECT;
changed = 1;
}
else if (nr == 3 || nr == 4) {
ob = base->object;
for (a = 1; a <= ob->totcol; a++) {
mat1 = give_current_material(ob, a);
if (nr == 3) {
if (mat1 == mat) base->flag |= SELECT;
changed = 1;
}
else if (mat1 && nr == 4) {
for (b = 0; b < MAX_MTEX; b++) {
if (mat1->mtex[b]) {
if (tex == mat1->mtex[b]->tex) {
base->flag |= SELECT;
changed = 1;
break;
}
}
}
}
}
}
else if (nr == 5) {
if (base->object->dup_group == ob->dup_group) {
base->flag |= SELECT;
changed = 1;
}
}
else if (nr == 6) {
/* loop through other, then actives particles*/
ParticleSystem *psys;
ParticleSystem *psys_act;
for (psys = base->object->particlesystem.first; psys; psys = psys->next) {
for (psys_act = ob->particlesystem.first; psys_act; psys_act = psys_act->next) {
if (psys->part == psys_act->part) {
base->flag |= SELECT;
changed = 1;
break;
}
}
if (base->flag & SELECT) {
break;
}
}
}
else if (nr == 7) {
if (ob->id.lib == base->object->id.lib) {
base->flag |= SELECT;
changed = 1;
}
}
else if (nr == 8) {
if (base->object->data && ((ID *)ob->data)->lib == ((ID *)base->object->data)->lib) {
base->flag |= SELECT;
changed = 1;
}
}
base->object->flag = base->flag;
}
CTX_DATA_END;
if (changed) {
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
return OPERATOR_FINISHED;
@@ -989,5 +1116,3 @@ void OBJECT_OT_select_random(wmOperatorType *ot)
RNA_def_float_percentage(ot->srna, "percent", 50.f, 0.0f, 100.0f, "Percent", "Percentage of objects to select randomly", 0.f, 100.0f);
RNA_def_boolean(ot->srna, "extend", FALSE, "Extend Selection", "Extend selection instead of deselecting everything first");
}

View File

@@ -5201,7 +5201,7 @@ int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
ED_space_image_zoom(sima, ar, zoomx, zoomy);
ED_space_image_get_zoom(sima, ar, zoomx, zoomy);
return 1;
}

View File

@@ -315,8 +315,8 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, wmEvent *event,
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
sima = CTX_wm_space_image(C);
ED_space_image_size(sima, &width, &height);
ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
ED_space_image_get_size(sima, &width, &height);
ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
radius = BKE_brush_size_get(scene, brush) / (width * zoomx);
aspectRatio = width / (float)height;
@@ -683,8 +683,8 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
radius = BKE_brush_size_get(scene, brush);
sima = CTX_wm_space_image(C);
ED_space_image_size(sima, &width, &height);
ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
ED_space_image_get_size(sima, &width, &height);
ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
aspectRatio = width / (float)height;
radius /= (width * zoomx);

View File

@@ -128,11 +128,11 @@ void ED_space_clip_get_size(const bContext *C, int *width, int *height)
{
SpaceClip *sc = CTX_wm_space_clip(C);
if (!sc->clip) {
*width = *height = 0;
if (sc->clip) {
BKE_movieclip_get_size(sc->clip, &sc->user, width, height);
}
else {
BKE_movieclip_get_size(sc->clip, &sc->user, width, height);
*width = *height = IMG_SIZE_FALLBACK;
}
}

View File

@@ -734,7 +734,7 @@ void draw_image_main(const bContext *C, ARegion *ar)
what_image(sima);
if (sima->image) {
ED_image_aspect(sima->image, &xuser_asp, &yuser_asp);
ED_image_get_aspect(sima->image, &xuser_asp, &yuser_asp);
/* UGLY hack? until now iusers worked fine... but for flipbook viewer we need this */
if (sima->image->type == IMA_TYPE_COMPOSITE) {
@@ -751,7 +751,7 @@ void draw_image_main(const bContext *C, ARegion *ar)
/* retrieve the image and information about it */
ima = ED_space_image(sima);
ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
show_viewer = (ima && ima->source == IMA_SRC_VIEWER);
show_render = (show_viewer && ima->type == IMA_TYPE_R_RESULT);

View File

@@ -136,7 +136,7 @@ int ED_space_image_has_buffer(SpaceImage *sima)
return has_buffer;
}
void ED_image_size(Image *ima, int *width, int *height)
void ED_image_get_size(Image *ima, int *width, int *height)
{
ImBuf *ibuf = NULL;
void *lock;
@@ -149,15 +149,15 @@ void ED_image_size(Image *ima, int *width, int *height)
*height = ibuf->y;
}
else {
*width = 256;
*height = 256;
*width = IMG_SIZE_FALLBACK;
*height = IMG_SIZE_FALLBACK;
}
if (ima)
BKE_image_release_ibuf(ima, lock);
}
void ED_space_image_size(SpaceImage *sima, int *width, int *height)
void ED_space_image_get_size(SpaceImage *sima, int *width, int *height)
{
Scene *scene = sima->iuser.scene;
ImBuf *ibuf;
@@ -183,14 +183,14 @@ void ED_space_image_size(SpaceImage *sima, int *width, int *height)
/* I know a bit weak... but preview uses not actual image size */
// XXX else if (image_preview_active(sima, width, height));
else {
*width = 256;
*height = 256;
*width = IMG_SIZE_FALLBACK;
*height = IMG_SIZE_FALLBACK;
}
ED_space_image_release_buffer(sima, lock);
}
void ED_image_aspect(Image *ima, float *aspx, float *aspy)
void ED_image_get_aspect(Image *ima, float *aspx, float *aspy)
{
*aspx = *aspy = 1.0;
@@ -204,27 +204,27 @@ void ED_image_aspect(Image *ima, float *aspx, float *aspy)
*aspy = ima->aspy / ima->aspx;
}
void ED_space_image_aspect(SpaceImage *sima, float *aspx, float *aspy)
void ED_space_image_get_aspect(SpaceImage *sima, float *aspx, float *aspy)
{
ED_image_aspect(ED_space_image(sima), aspx, aspy);
ED_image_get_aspect(ED_space_image(sima), aspx, aspy);
}
void ED_space_image_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoomy)
void ED_space_image_get_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoomy)
{
int width, height;
ED_space_image_size(sima, &width, &height);
ED_space_image_get_size(sima, &width, &height);
*zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width);
*zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height);
}
void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
void ED_space_image_get_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
{
int w, h;
ED_space_image_aspect(sima, aspx, aspy);
ED_space_image_size(sima, &w, &h);
ED_space_image_get_aspect(sima, aspx, aspy);
ED_space_image_get_size(sima, &w, &h);
*aspx *= (float)w;
*aspy *= (float)h;
@@ -239,12 +239,12 @@ void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
}
}
void ED_image_uv_aspect(Image *ima, float *aspx, float *aspy)
void ED_image_get_uv_aspect(Image *ima, float *aspx, float *aspy)
{
int w, h;
ED_image_aspect(ima, aspx, aspy);
ED_image_size(ima, &w, &h);
ED_image_get_aspect(ima, aspx, aspy);
ED_image_get_size(ima, &w, &h);
*aspx *= (float)w;
*aspy *= (float)h;

View File

@@ -92,7 +92,7 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, float locat
if (sima->zoom < 0.1f || sima->zoom > 4.0f) {
/* check zoom limits */
ED_space_image_size(sima, &width, &height);
ED_space_image_get_size(sima, &width, &height);
width *= sima->zoom;
height *= sima->zoom;
@@ -108,8 +108,8 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, float locat
if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) {
float aspx, aspy, w, h;
ED_space_image_size(sima, &width, &height);
ED_space_image_aspect(sima, &aspx, &aspy);
ED_space_image_get_size(sima, &width, &height);
ED_space_image_get_aspect(sima, &aspx, &aspy);
w = width * aspx;
h = height * aspy;
@@ -565,8 +565,8 @@ static int image_view_all_exec(bContext *C, wmOperator *UNUSED(op))
sima = CTX_wm_space_image(C);
ar = CTX_wm_region(C);
ED_space_image_size(sima, &width, &height);
ED_space_image_aspect(sima, &aspx, &aspy);
ED_space_image_get_size(sima, &width, &height);
ED_space_image_get_aspect(sima, &aspx, &aspy);
w = width * aspx;
h = height * aspy;
@@ -622,8 +622,8 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
obedit = CTX_data_edit_object(C);
ima = ED_space_image(sima);
ED_space_image_size(sima, &width, &height);
ED_image_aspect(ima, &aspx, &aspy);
ED_space_image_get_size(sima, &width, &height);
ED_image_get_aspect(ima, &aspx, &aspy);
width = width * aspx;
height = height * aspy;

View File

@@ -512,7 +512,7 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar)
if (image_preview_active(curarea, &width, &height)) ;
else
#endif
ED_space_image_size(sima, &width, &height);
ED_space_image_get_size(sima, &width, &height);
w = width;
h = height;

View File

@@ -324,6 +324,14 @@ static void id_fake_user_clear_cb(bContext *UNUSED(C), Scene *UNUSED(scene), Tre
}
}
static void id_select_linked_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
{
ID *id = tselem->id;
ED_object_select_linked_by_id(C, id);
}
static void singleuser_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
TreeStoreElem *tsep, TreeStoreElem *tselem)
{
@@ -728,7 +736,9 @@ typedef enum eOutlinerIdOpTypes {
OUTLINER_IDOP_FAKE_ADD,
OUTLINER_IDOP_FAKE_CLEAR,
OUTLINER_IDOP_RENAME
OUTLINER_IDOP_RENAME,
OUTLINER_IDOP_SELECT_LINKED
} eOutlinerIdOpTypes;
// TODO: implement support for changing the ID-block used
@@ -740,6 +750,7 @@ static EnumPropertyItem prop_id_op_types[] = {
"Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"},
{OUTLINER_IDOP_FAKE_CLEAR, "CLEAR_FAKE", 0, "Clear Fake User", ""},
{OUTLINER_IDOP_RENAME, "RENAME", 0, "Rename", ""},
{OUTLINER_IDOP_SELECT_LINKED, "SELECT_LINKED", 0, "Select Linked", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -855,6 +866,11 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
ED_undo_push(C, "Rename");
}
break;
case OUTLINER_IDOP_SELECT_LINKED:
outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_select_linked_cb);
ED_undo_push(C, "Select");
break;
default:
// invalid - unhandled

View File

@@ -120,16 +120,44 @@ void setTransformViewMatrices(TransInfo *t)
calculateCenter2D(t);
}
static void convertViewVec2D(View2D *v2d, float vec[3], int dx, int dy)
static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy)
{
float divx, divy;
divx = v2d->mask.xmax - v2d->mask.xmin;
divy = v2d->mask.ymax - v2d->mask.ymin;
vec[0] = (v2d->cur.xmax - v2d->cur.xmin) * dx / divx;
vec[1] = (v2d->cur.ymax - v2d->cur.ymin) * dy / divy;
vec[2] = 0.0f;
r_vec[0] = (v2d->cur.xmax - v2d->cur.xmin) * dx / divx;
r_vec[1] = (v2d->cur.ymax - v2d->cur.ymin) * dy / divy;
r_vec[2] = 0.0f;
}
static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy)
{
float divx, divy;
float mulx, muly;
divx = v2d->mask.xmax - v2d->mask.xmin;
divy = v2d->mask.ymax - v2d->mask.ymin;
mulx = (v2d->cur.xmax - v2d->cur.xmin);
muly = (v2d->cur.ymax - v2d->cur.ymin);
/* difference with convertViewVec2D */
/* clamp w/h, mask only */
if (mulx / divx < muly / divy) {
divy = divx;
muly = mulx;
}
else {
divx = divy;
mulx = muly;
}
/* end difference */
r_vec[0] = mulx * dx / divx;
r_vec[1] = muly * dy / divy;
r_vec[2] = 0.0f;
}
void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
@@ -143,9 +171,17 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
else if (t->spacetype == SPACE_IMAGE) {
float aspx, aspy;
convertViewVec2D(t->view, r_vec, dx, dy);
if (t->options & CTX_MASK) {
convertViewVec2D_mask(t->view, r_vec, dx, dy);
ED_space_image_get_aspect(t->sa->spacedata.first, &aspx, &aspy);
}
else {
convertViewVec2D(t->view, r_vec, dx, dy);
ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
}
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
r_vec[0] *= aspx;
r_vec[1] *= aspy;
}
@@ -156,32 +192,14 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
convertViewVec2D(&t->ar->v2d, r_vec, dx, dy);
}
else if (t->spacetype == SPACE_CLIP) {
View2D *v2d = t->view;
float divx, divy;
float mulx, muly;
float aspx = 1.0f, aspy = 1.0f;
divx = v2d->mask.xmax - v2d->mask.xmin;
divy = v2d->mask.ymax - v2d->mask.ymin;
mulx = (v2d->cur.xmax - v2d->cur.xmin);
muly = (v2d->cur.ymax - v2d->cur.ymin);
float aspx, aspy;
if (t->options & CTX_MASK) {
/* clamp w/h, mask only */
if (mulx / divx < muly / divy) {
divy = divx;
muly = mulx;
}
else {
divx = divy;
mulx = muly;
}
convertViewVec2D_mask(t->view, r_vec, dx, dy);
}
else {
convertViewVec2D(t->view, r_vec, dx, dy);
}
r_vec[0] = mulx * (dx) / divx;
r_vec[1] = muly * (dy) / divy;
r_vec[2] = 0.0f;
if (t->options & CTX_MOVIECLIP) {
ED_space_clip_get_aspect_dimension_aware(t->sa->spacedata.first, &aspx, &aspy);
@@ -209,7 +227,7 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2])
else if (t->spacetype == SPACE_IMAGE) {
float aspx, aspy, v[2];
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
v[0] = vec[0] / aspx;
v[1] = vec[1] / aspy;
@@ -304,13 +322,13 @@ void applyAspectRatio(TransInfo *t, float vec[2])
if ((sima->flag & SI_COORDFLOATS) == 0) {
int width, height;
ED_space_image_size(sima, &width, &height);
ED_space_image_get_size(sima, &width, &height);
vec[0] *= width;
vec[1] *= height;
}
ED_space_image_uv_aspect(sima, &aspx, &aspy);
ED_space_image_get_uv_aspect(sima, &aspx, &aspy);
vec[0] /= aspx;
vec[1] /= aspy;
}
@@ -344,13 +362,13 @@ void removeAspectRatio(TransInfo *t, float vec[2])
if ((sima->flag & SI_COORDFLOATS) == 0) {
int width, height;
ED_space_image_size(sima, &width, &height);
ED_space_image_get_size(sima, &width, &height);
vec[0] /= width;
vec[1] /= height;
}
ED_space_image_uv_aspect(sima, &aspx, &aspy);
ED_space_image_get_uv_aspect(sima, &aspx, &aspy);
vec[0] *= aspx;
vec[1] *= aspy;
}
@@ -406,10 +424,17 @@ static void viewRedrawForce(const 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?
SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
if (sima->lock) WM_event_add_notifier(C, NC_GEOM | ND_DATA, t->obedit->data);
else ED_area_tag_redraw(t->sa);
if (t->options & CTX_MASK) {
Mask *mask = CTX_data_edit_mask(C);
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
}
else {
// XXX how to deal with lock?
SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
if (sima->lock) WM_event_add_notifier(C, NC_GEOM | ND_DATA, t->obedit->data);
else ED_area_tag_redraw(t->sa);
}
}
else if (t->spacetype == SPACE_CLIP) {
SpaceClip *sc = (SpaceClip *)t->sa->spacedata.first;
@@ -423,7 +448,7 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
}
else if (ED_space_clip_check_show_maskedit(sc)) {
Mask *mask = ED_space_clip_get_mask(sc);
Mask *mask = CTX_data_edit_mask(C);
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
}

View File

@@ -722,7 +722,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
else if (t->spacetype == SPACE_IMAGE) {
float aspx, aspy;
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
glScalef(1.0f / aspx, 1.0f / aspy, 1.0);
}

View File

@@ -2320,7 +2320,7 @@ static void UVsToTransData(SpaceImage *sima, TransData *td, TransData2D *td2d, f
{
float aspx, aspy;
ED_space_image_uv_aspect(sima, &aspx, &aspy);
ED_space_image_get_uv_aspect(sima, &aspx, &aspy);
/* uv coords are scaled by aspects. this is needed for rotations and
* proportional editing to be consistent with the stretched uv coords
@@ -2428,8 +2428,8 @@ void flushTransUVs(TransInfo *t)
int a, width, height;
float aspx, aspy, invx, invy;
ED_space_image_uv_aspect(sima, &aspx, &aspy);
ED_space_image_size(sima, &width, &height);
ED_space_image_get_uv_aspect(sima, &aspx, &aspy);
ED_space_image_get_size(sima, &width, &height);
invx = 1.0f / aspx;
invy = 1.0f / aspy;
@@ -2451,7 +2451,7 @@ int clipUVTransform(TransInfo *t, float *vec, int resize)
int a, clipx = 1, clipy = 1;
float aspx, aspy, min[2], max[2];
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
min[0] = min[1] = 0.0f;
max[0] = aspx; max[1] = aspy;
@@ -4964,6 +4964,36 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
}
}
static void special_aftertrans_update__mask(bContext *C, TransInfo *t)
{
Mask *mask;
if (t->spacetype == SPACE_CLIP) {
SpaceClip *sc = t->sa->spacedata.first;
mask = ED_space_clip_get_mask(sc);
}
else if (t->spacetype == SPACE_IMAGE) {
SpaceImage *sima = t->sa->spacedata.first;
mask = ED_space_image_get_mask(sima);
}
else {
BLI_assert(0);
}
if (t->scene->nodetree) {
/* tracks can be used for stabilization nodes,
* flush update for such nodes */
nodeUpdateID(t->scene->nodetree, &mask->id);
WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL);
}
/* TODO - dont key all masks... */
if (IS_AUTOKEY_ON(t->scene)) {
Scene *scene = t->scene;
ED_mask_layer_shape_auto_key_select(mask, CFRA);
}
}
/* inserting keys, pointcache, redraw events... */
/*
@@ -5009,7 +5039,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
}
}
if (t->spacetype == SPACE_SEQ) {
/* freeSeqData in transform_conversions.c does this
* keep here so the else at the end wont run... */
@@ -5030,7 +5061,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
ED_markers_post_apply_transform(&t->scene->markers, t->scene, TFM_TIME_EXTEND, t->values[0], t->frame_side);
}
}
}
else if (t->spacetype == SPACE_IMAGE) {
if (t->options & CTX_MASK) {
special_aftertrans_update__mask(C, t);
}
}
else if (t->spacetype == SPACE_NODE) {
SpaceNode *snode = (SpaceNode *)t->sa->spacedata.first;
@@ -5056,22 +5091,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
}
else if (t->options & CTX_MASK) {
SpaceClip *sc = t->sa->spacedata.first;
Mask *mask = ED_space_clip_get_mask(sc);
if (t->scene->nodetree) {
/* tracks can be used for stabilization nodes,
* flush update for such nodes */
nodeUpdateID(t->scene->nodetree, &mask->id);
WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL);
}
/* TODO - dont key all masks... */
if (IS_AUTOKEY_ON(t->scene)) {
Scene *scene = t->scene;
ED_mask_layer_shape_auto_key_select(mask, CFRA);
}
special_aftertrans_update__mask(C, t);
}
}
else if (t->spacetype == SPACE_ACTION) {
@@ -5356,6 +5376,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
else { /* Objects */
int i, recalcObPaths = 0;
BLI_assert(t->flag & T_OBJECT);
for (i = 0; i < t->total; i++) {
TransData *td = t->data + i;
ListBase pidlist;
@@ -6069,19 +6091,17 @@ typedef struct TransDataMasking {
MaskSplinePoint *point;
} TransDataMasking;
static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point,
TransData *td, TransData2D *td2d, TransDataMasking *tdm, int propmode)
static void MaskPointToTransData(MaskSplinePoint *point,
TransData *td, TransData2D *td2d, TransDataMasking *tdm,
const int propmode, const float asp[2])
{
BezTriple *bezt = &point->bezt;
float aspx, aspy;
short is_sel_point = MASKPOINT_ISSEL_KNOT(point);
short is_sel_any = MASKPOINT_ISSEL_ANY(point);
tdm->point = point;
copy_m3_m3(tdm->vec, bezt->vec);
ED_space_clip_get_aspect(sc, &aspx, &aspy);
if (propmode || is_sel_point) {
int i;
for (i = 0; i < 3; i++) {
@@ -6089,8 +6109,8 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point,
* proportional editing to be consistent with the stretched CV coords
* that are displayed. this also means that for display and numinput,
* and when the the CV coords are flushed, these are converted each time */
td2d->loc[0] = bezt->vec[i][0] * aspx;
td2d->loc[1] = bezt->vec[i][1] * aspy;
td2d->loc[0] = bezt->vec[i][0] * asp[0];
td2d->loc[1] = bezt->vec[i][1] * asp[1];
td2d->loc[2] = 0.0f;
td2d->loc2d = bezt->vec[i];
@@ -6132,8 +6152,8 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point,
copy_v2_v2(tdm->orig_handle, tdm->handle);
td2d->loc[0] = tdm->handle[0] * aspx;
td2d->loc[1] = tdm->handle[1] * aspy;
td2d->loc[0] = tdm->handle[0] * asp[0];
td2d->loc[1] = tdm->handle[1] * asp[1];
td2d->loc[2] = 0.0f;
td2d->loc2d = tdm->handle;
@@ -6164,7 +6184,6 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point,
static void createTransMaskingData(bContext *C, TransInfo *t)
{
SpaceClip *sc = CTX_wm_space_clip(C);
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *masklay;
TransData *td = NULL;
@@ -6172,6 +6191,7 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
TransDataMasking *tdm = NULL;
int count = 0, countsel = 0;
int propmode = t->flag & T_PROP_EDIT;
float asp[2];
t->total = 0;
@@ -6206,7 +6226,11 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
}
/* note: in prop mode we need at least 1 selected */
if (countsel == 0) return;
if (countsel == 0) {
return;
}
ED_mask_aspect(C, &asp[0], &asp[1]);
t->total = (propmode) ? count : countsel;
td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Mask Editing)");
@@ -6232,7 +6256,7 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
MaskSplinePoint *point = &spline->points[i];
if (propmode || MASKPOINT_ISSEL_ANY(point)) {
MaskPointToTransData(sc, point, td, td2d, tdm, propmode);
MaskPointToTransData(point, td, td2d, tdm, propmode, asp);
if (propmode || MASKPOINT_ISSEL_KNOT(point)) {
td += 3;
@@ -6252,20 +6276,19 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
void flushTransMasking(TransInfo *t)
{
SpaceClip *sc = t->sa->spacedata.first;
TransData2D *td;
TransDataMasking *tdm;
int a;
float aspx, aspy, invx, invy;
float asp[2], inv[2];
ED_space_clip_get_aspect(sc, &aspx, &aspy);
invx = 1.0f / aspx;
invy = 1.0f / aspy;
ED_mask_aspect(t->context, &asp[0], &asp[1]);
inv[0] = 1.0f / asp[0];
inv[1] = 1.0f / asp[1];
/* flush to 2d vector from internally used 3d vector */
for (a = 0, td = t->data2d, tdm = t->customData; a < t->total; a++, td++, tdm++) {
td->loc2d[0] = td->loc[0] * invx;
td->loc2d[1] = td->loc[1] * invy;
td->loc2d[0] = td->loc[0] * inv[0];
td->loc2d[1] = td->loc[1] * inv[1];
if (tdm->is_handle)
BKE_mask_point_set_handle(tdm->point, td->loc2d, t->flag & T_ALT_TRANSFORM, tdm->orig_handle, tdm->vec);
@@ -6297,11 +6320,23 @@ void createTransData(bContext *C, TransInfo *t)
}
else if (t->spacetype == SPACE_IMAGE) {
t->flag |= T_POINTS | T_2D_EDIT;
createTransUVs(C, t);
if (t->data && (t->flag & T_PROP_EDIT)) {
sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
sort_trans_data_dist(t);
if (t->options & CTX_MASK) {
/* copied from below */
createTransMaskingData(C, t);
if (t->data && (t->flag & T_PROP_EDIT)) {
sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, TRUE);
sort_trans_data_dist(t);
}
}
else {
createTransUVs(C, t);
if (t->data && (t->flag & T_PROP_EDIT)) {
sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
sort_trans_data_dist(t);
}
}
}
else if (t->spacetype == SPACE_ACTION) {
@@ -6342,6 +6377,7 @@ void createTransData(bContext *C, TransInfo *t)
if (t->options & CTX_MOVIECLIP)
createTransTrackingData(C, t);
else if (t->options & CTX_MASK) {
/* copied from above */
createTransMaskingData(C, t);
if (t->data && (t->flag & T_PROP_EDIT)) {

View File

@@ -607,6 +607,15 @@ static void recalcData_nla(TransInfo *t)
}
}
static void recalcData_mask_common(TransInfo *t)
{
Mask *mask = CTX_data_edit_mask(t->context);
flushTransMasking(t);
DAG_id_tag_update(&mask->id, 0);
}
/* helper for recalcData() - for Image Editor transforms */
static void recalcData_image(TransInfo *t)
{
@@ -619,6 +628,9 @@ static void recalcData_image(TransInfo *t)
DAG_id_tag_update(t->obedit->data, 0);
}
else if (t->options & CTX_MASK) {
recalcData_mask_common(t);
}
}
/* helper for recalcData() - for Movie Clip transforms */
@@ -662,12 +674,8 @@ static void recalcData_spaceclip(TransInfo *t)
DAG_id_tag_update(&clip->id, 0);
}
else if (ED_space_clip_check_show_maskedit(sc)) {
Mask *mask = ED_space_clip_get_mask(sc);
flushTransMasking(t);
DAG_id_tag_update(&mask->id, 0);
else if (t->options & CTX_MASK) {
recalcData_mask_common(t);
}
}
@@ -908,6 +916,10 @@ void recalcData(TransInfo *t)
else if (t->spacetype == SPACE_CLIP) {
recalcData_spaceclip(t);
}
if (t->options & CTX_MASK) {
}
}
void drawLine(TransInfo *t, float *center, float *dir, char axis, short options)
@@ -1099,6 +1111,16 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
// XXX for now, get View2D from the active region
t->view = &ar->v2d;
t->around = sima->around;
if (t->obedit) {
/* UV transform */
}
else if (sima->mode == SI_MODE_MASK) {
t->options |= CTX_MASK;
}
else {
BLI_assert(0);
}
}
else if (t->spacetype == SPACE_NODE) {
// XXX for now, get View2D from the active region
@@ -1280,9 +1302,14 @@ void postTrans(bContext *C, TransInfo *t)
}
if (t->spacetype == SPACE_IMAGE) {
SpaceImage *sima = t->sa->spacedata.first;
if (sima->flag & SI_LIVE_UNWRAP)
ED_uvedit_live_unwrap_end(t->state == TRANS_CANCEL);
if (t->options & CTX_MASK) {
/* pass */
}
else {
SpaceImage *sima = t->sa->spacedata.first;
if (sima->flag & SI_LIVE_UNWRAP)
ED_uvedit_live_unwrap_end(t->state == TRANS_CANCEL);
}
}
else if (t->spacetype == SPACE_VIEW3D) {
View3D *v3d = t->sa->spacedata.first;
@@ -1417,7 +1444,7 @@ void calculateCenterCursor2D(TransInfo *t)
if (t->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
/* only space supported right now but may change */
ED_space_image_uv_aspect(sima, &aspx, &aspy);
ED_space_image_get_uv_aspect(sima, &aspx, &aspy);
cursor = sima->cursor;
}

View File

@@ -206,10 +206,10 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
glLoadIdentity();
ED_space_image_aspect(t->sa->spacedata.first, &xuser_aspx, &yuser_asp);
ED_space_image_get_aspect(t->sa->spacedata.first, &xuser_aspx, &yuser_asp);
ED_space_image_width(t->sa->spacedata.first, &wi, &hi);
w = (((float)wi) / 256.0f) * G.sima->zoom * xuser_asp;
h = (((float)hi) / 256.0f) * G.sima->zoom * yuser_asp;
w = (((float)wi) / IMG_SIZE_FALLBACK) * G.sima->zoom * xuser_asp;
h = (((float)hi) / IMG_SIZE_FALLBACK) * G.sima->zoom * yuser_asp;
cpack(0xFFFFFF);
glTranslatef(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], 0.0f);
@@ -927,7 +927,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], co, co + 1);
if (ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint)) {
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
t->tsnap.snapPoint[0] *= aspx;
t->tsnap.snapPoint[1] *= aspy;
@@ -2135,7 +2135,7 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea
/* evil hack - snapping needs to be adapted for image aspect ratio */
if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) {
ED_space_image_uv_aspect(t->sa->spacedata.first, asp, asp + 1);
ED_space_image_get_uv_aspect(t->sa->spacedata.first, asp, asp + 1);
}
for (i = 0; i <= max_index; i++) {

View File

@@ -125,7 +125,7 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block)
float center[2];
int imx, imy, step, digits;
ED_space_image_size(sima, &imx, &imy);
ED_space_image_get_size(sima, &imx, &imy);
em = BMEdit_FromObject(obedit);
@@ -168,7 +168,7 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event)
em = BMEdit_FromObject(obedit);
ED_space_image_size(sima, &imx, &imy);
ED_space_image_get_size(sima, &imx, &imy);
uvedit_center(scene, em, ima, center);
if (sima->flag & SI_COORDFLOATS) {

View File

@@ -68,8 +68,8 @@ static void drawcursor_sima(SpaceImage *sima, ARegion *ar)
float zoomx, zoomy, w, h;
int width, height;
ED_space_image_size(sima, &width, &height);
ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
ED_space_image_get_size(sima, &width, &height);
ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
w = zoomx * width / 256.0f;
h = zoomy * height / 256.0f;
@@ -174,7 +174,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
float aspx, aspy, col[4], (*tf_uv)[2] = NULL, (*tf_uvorig)[2] = NULL;
int i, j, nverts;
ED_space_image_uv_aspect(sima, &aspx, &aspy);
ED_space_image_get_uv_aspect(sima, &aspx, &aspy);
switch (sima->dt_uvstretch) {
case SI_UVDT_STRETCH_AREA:

View File

@@ -199,8 +199,8 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im
float prev_aspect[2], fprev_aspect;
float aspect[2], faspect;
ED_image_uv_aspect(previma, prev_aspect, prev_aspect + 1);
ED_image_uv_aspect(ima, aspect, aspect + 1);
ED_image_get_uv_aspect(previma, prev_aspect, prev_aspect + 1);
ED_image_get_uv_aspect(ima, aspect, aspect + 1);
fprev_aspect = prev_aspect[0]/prev_aspect[1];
faspect = aspect[0]/aspect[1];
@@ -292,7 +292,7 @@ static void uvedit_pixel_to_float(SpaceImage *sima, float *dist, float pixeldist
int width, height;
if (sima) {
ED_space_image_size(sima, &width, &height);
ED_space_image_get_size(sima, &width, &height);
}
else {
width = 256;
@@ -2604,8 +2604,8 @@ static int circle_select_exec(bContext *C, wmOperator *op)
/* compute ellipse size and location, not a circle since we deal
* with non square image. ellipse is normalized, r = 1.0. */
ED_space_image_size(sima, &width, &height);
ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
ED_space_image_get_size(sima, &width, &height);
ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
ellipse[0] = width * zoomx / radius;
ellipse[1] = height * zoomy / radius;
@@ -2781,7 +2781,7 @@ static void snap_cursor_to_pixels(SpaceImage *sima)
{
int width = 0, height = 0;
ED_space_image_size(sima, &width, &height);
ED_space_image_get_size(sima, &width, &height);
snap_uv_to_pixel(sima->cursor, width, height);
}
@@ -2936,7 +2936,7 @@ static int snap_uvs_to_pixels(SpaceImage *sima, Scene *scene, Object *obedit)
float w, h;
short change = 0;
ED_space_image_size(sima, &width, &height);
ED_space_image_get_size(sima, &width, &height);
w = (float)width;
h = (float)height;

View File

@@ -198,7 +198,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
float aspx, aspy;
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
ED_image_uv_aspect(tf->tpage, &aspx, &aspy);
ED_image_get_uv_aspect(tf->tpage, &aspx, &aspy);
if (aspx != aspy)
param_aspect_ratio(handle, aspx, aspy);
@@ -388,7 +388,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
float aspx, aspy;
tf = CustomData_bmesh_get(&em->bm->pdata, editFace->head.data, CD_MTEXPOLY);
ED_image_uv_aspect(tf->tpage, &aspx, &aspy);
ED_image_get_uv_aspect(tf->tpage, &aspx, &aspy);
if (aspx != aspy)
param_aspect_ratio(handle, aspx, aspy);
@@ -1017,7 +1017,7 @@ static void correct_uv_aspect(BMEditMesh *em)
MTexPoly *tf;
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
ED_image_uv_aspect(tf->tpage, &aspx, &aspy);
ED_image_get_uv_aspect(tf->tpage, &aspx, &aspy);
}
if (aspx == aspy)

View File

@@ -1127,4 +1127,6 @@ typedef enum eSpace_Type {
SPACEICONMAX = SPACE_CLIP
} eSpace_Type;
#define IMG_SIZE_FALLBACK 256
#endif

View File

@@ -621,7 +621,7 @@ static void rna_SpaceImageEditor_zoom_get(PointerRNA *ptr, float *values)
sa = rna_area_from_space(ptr); /* can be NULL */
ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
if (ar) {
ED_space_image_zoom(sima, ar, &values[0], &values[1]);
ED_space_image_get_zoom(sima, ar, &values[0], &values[1]);
}
}
@@ -634,7 +634,7 @@ static void rna_SpaceImageEditor_cursor_location_get(PointerRNA *ptr, float *val
}
else {
int w, h;
ED_space_image_size(sima, &w, &h);
ED_space_image_get_size(sima, &w, &h);
values[0] = sima->cursor[0] * w;
values[1] = sima->cursor[1] * h;
@@ -650,7 +650,7 @@ static void rna_SpaceImageEditor_cursor_location_set(PointerRNA *ptr, const floa
}
else {
int w, h;
ED_space_image_size(sima, &w, &h);
ED_space_image_get_size(sima, &w, &h);
sima->cursor[0] = values[0] / w;
sima->cursor[1] = values[1] / h;

View File

@@ -1085,12 +1085,15 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
return NULL;
break;
case 2:
if (mathutils_array_parse(quat, 3, 3, seq, "mathutils.Quaternion()") == -1)
{
float axis[3];
if (mathutils_array_parse(axis, 3, 3, seq, "mathutils.Quaternion()") == -1)
return NULL;
angle = angle_wrap_rad(angle); /* clamp because of precision issues */
axis_angle_to_quat(quat, quat, angle);
axis_angle_to_quat(quat, axis, angle);
break;
/* PyArg_ParseTuple assures no more then 2 */
}
}
return Quaternion_CreatePyObject(quat, Py_NEW, type);
}

View File

@@ -64,6 +64,7 @@ struct LOD_Decimation_Info;
struct MCol;
struct MTex;
struct Main;
struct Mask;
struct Material;
struct MenuType;
struct Mesh;
@@ -229,6 +230,7 @@ void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct ToolSett
void ED_screen_set_scene(struct bContext *C, struct Scene *scene) {}
void ED_space_clip_set_clip(struct bContext *C, struct SpaceClip *sc, struct MovieClip *clip) {}
void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask) {}
void ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask) {}
void ED_area_tag_redraw_regiontype(struct ScrArea *sa, int regiontype) {}
void ED_render_engine_changed(struct Main *bmain) {}
@@ -271,7 +273,7 @@ short ANIM_add_driver(struct ID *id, const char rna_path[], int array_index, sho
short ANIM_remove_driver(struct ID *id, const char rna_path[], int array_index, short flag) {return 0;}
void ED_space_image_release_buffer(struct SpaceImage *sima, void *lock) {}
struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **lock_r) {return (struct ImBuf *) NULL;}
void ED_space_image_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy) {}
void ED_space_image_get_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy) {}
char *ED_info_stats_string(struct Scene *scene) {return (char *) NULL;}
void ED_area_tag_redraw(struct ScrArea *sa) {}
void ED_area_tag_refresh(struct ScrArea *sa) {}
@@ -345,7 +347,7 @@ intptr_t mesh_octree_table(struct Object *ob, struct BMEditMesh *em, float *co,
void ED_sequencer_update_view(struct bContext *C, int view) {}
float ED_rollBoneToVector(struct EditBone *bone, float new_up_axis[3]) {return 0.0f;}
void ED_space_image_size(struct SpaceImage *sima, int *width, int *height) {}
void ED_space_image_get_size(struct SpaceImage *sima, int *width, int *height) {}
void ED_nurb_set_spline_type(struct Nurb *nu, int type) {}