Merging r49226 through r49238 from trunk into soc-2011-tomato

This commit is contained in:
Sergey Sharybin
2012-07-26 09:51:28 +00:00
22 changed files with 196 additions and 49 deletions

View File

@@ -127,7 +127,9 @@ void BKE_mask_free(struct Mask *mask);
void BKE_mask_unlink(struct Main *bmain, struct Mask *mask);
void BKE_mask_coord_from_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2]);
void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2]);
void BKE_mask_coord_to_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2]);
void BKE_mask_coord_to_frame(float r_co[2], const float co[2], const float frame_size[2]);
/* parenting */

View File

@@ -52,9 +52,10 @@ extern const char PAINT_CURSOR_WEIGHT_PAINT[3];
extern const char PAINT_CURSOR_TEXTURE_PAINT[3];
void BKE_paint_init(struct Paint *p, const char col[3]);
void free_paint(struct Paint *p);
void copy_paint(struct Paint *src, struct Paint *tar);
void BKE_paint_free(struct Paint *p);
void BKE_paint_copy(struct Paint *src, struct Paint *tar);
/* TODO, give these BKE_ prefix too */
struct Paint *paint_get_active(struct Scene *sce);
struct Paint *paint_get_active_from_context(const struct bContext *C);
struct Brush *paint_brush(struct Paint *paint);

View File

@@ -962,7 +962,7 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short
hist->channels = 3;
hist->x_resolution = 256;
hist->xmax = 1.0f;
hist->ymax = 1.0f;
/* hist->ymax = 1.0f; */ /* now do this on the operator _only_ */
if (ibuf->rect == NULL && ibuf->rect_float == NULL) return;

View File

@@ -1543,47 +1543,63 @@ void BKE_mask_unlink(Main *bmain, Mask *mask)
mask->id.us = 0;
}
void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2])
{
if (frame_size[0] == frame_size[1]) {
r_co[0] = co[0];
r_co[1] = co[1];
}
else if (frame_size[0] < frame_size[1]) {
r_co[0] = ((co[0] - 0.5f) * (frame_size[0] / frame_size[1])) + 0.5f;
r_co[1] = co[1];
}
else { /* (frame_size[0] > frame_size[1]) */
r_co[0] = co[0];
r_co[1] = ((co[1] - 0.5f) * (frame_size[1] / frame_size[0])) + 0.5f;
}
}
void BKE_mask_coord_from_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2])
{
int width, height;
float frame_size[2];
/* scaling for the clip */
BKE_movieclip_get_size(clip, user, &width, &height);
if (width == height) {
r_co[0] = co[0];
r_co[1] = co[1];
}
else if (width < height) {
r_co[0] = ((co[0] - 0.5f) * ((float)width / (float)height)) + 0.5f;
r_co[1] = co[1];
}
else { /* (width > height) */
r_co[0] = co[0];
r_co[1] = ((co[1] - 0.5f) * ((float)height / (float)width)) + 0.5f;
}
frame_size[0] = (float)width;
frame_size[1] = (float)height;
BKE_mask_coord_from_frame(r_co, co, frame_size);
}
/* as above but divide */
void BKE_mask_coord_to_frame(float r_co[2], const float co[2], const float frame_size[2])
{
if (frame_size[0] == frame_size[1]) {
r_co[0] = co[0];
r_co[1] = co[1];
}
else if (frame_size[0] < frame_size[1]) {
r_co[0] = ((co[0] - 0.5f) / (frame_size[0] / frame_size[1])) + 0.5f;
r_co[1] = co[1];
}
else { /* (frame_size[0] > frame_size[1]) */
r_co[0] = co[0];
r_co[1] = ((co[1] - 0.5f) / (frame_size[1] / frame_size[0])) + 0.5f;
}
}
void BKE_mask_coord_to_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2])
{
int width, height;
float frame_size[2];
/* scaling for the clip */
BKE_movieclip_get_size(clip, user, &width, &height);
if (width == height) {
r_co[0] = co[0];
r_co[1] = co[1];
}
else if (width < height) {
r_co[0] = ((co[0] - 0.5f) / ((float)width / (float)height)) + 0.5f;
r_co[1] = co[1];
}
else { /* (width > height) */
r_co[0] = co[0];
r_co[1] = ((co[1] - 0.5f) / ((float)height / (float)width)) + 0.5f;
}
frame_size[0] = (float)width;
frame_size[1] = (float)height;
BKE_mask_coord_to_frame(r_co, co, frame_size);
}
static int BKE_mask_evaluate_parent(MaskParent *parent, float ctime, float r_co[2])

View File

@@ -1080,7 +1080,7 @@ void BKE_movieclip_reload(MovieClip *clip)
else
clip->source = MCLIP_SRC_SEQUENCE;
clip->lastsize[0] = clip->lastsize[1] = 0;
clip->lastsize[0] = clip->lastsize[1] = IMG_SIZE_FALLBACK;
movieclip_load_get_szie(clip);
movieclip_calc_length(clip);

View File

@@ -210,7 +210,14 @@ void BKE_object_link_modifiers(struct Object *ob, struct Object *from)
for (md = from->modifiers.first; md; md = md->next) {
ModifierData *nmd = NULL;
if (ELEM4(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_ParticleInstance, eModifierType_Collision)) continue;
if (ELEM4(md->type,
eModifierType_Hook,
eModifierType_Softbody,
eModifierType_ParticleInstance,
eModifierType_Collision))
{
continue;
}
if (!BKE_object_support_modifier_type_check(ob, md->type))
continue;
@@ -1318,7 +1325,8 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
if ((Object *)dtar->id == target)
dtar->id = (ID *)ob;
else {
/* only on local objects because this causes indirect links a -> b -> c, blend to point directly to a.blend
/* only on local objects because this causes indirect links
* 'a -> b -> c', blend to point directly to a.blend
* when a.blend has a proxy thats linked into c.blend */
if (ob->id.lib == NULL)
id_lib_extern((ID *)dtar->id);
@@ -1803,7 +1811,11 @@ static void give_parvert(Object *par, int nr, float vec[3])
dm->getVertCo(dm, 0, vec);
}
}
else fprintf(stderr, "%s: DerivedMesh is needed to solve parenting, object position can be wrong now\n", __func__);
else {
fprintf(stderr,
"%s: DerivedMesh is needed to solve parenting, "
"object position can be wrong now\n", __func__);
}
}
else if (ELEM(par->type, OB_CURVE, OB_SURF)) {
Nurb *nu;

View File

@@ -184,7 +184,7 @@ void BKE_paint_init(Paint *p, const char col[3])
p->flags |= PAINT_SHOW_BRUSH;
}
void free_paint(Paint *paint)
void BKE_paint_free(Paint *paint)
{
id_us_min((ID *)paint->brush);
}
@@ -193,7 +193,7 @@ void free_paint(Paint *paint)
* still do a id_us_plus(), rather then if we were copying betweem 2 existing
* scenes where a matching value should decrease the existing user count as
* with paint_brush_set() */
void copy_paint(Paint *src, Paint *tar)
void BKE_paint_copy(Paint *src, Paint *tar)
{
tar->brush = src->brush;
id_us_plus((ID *)tar->brush);

View File

@@ -188,21 +188,21 @@ Scene *BKE_scene_copy(Scene *sce, int type)
ts->vpaint->paintcursor = NULL;
ts->vpaint->vpaint_prev = NULL;
ts->vpaint->wpaint_prev = NULL;
copy_paint(&ts->vpaint->paint, &ts->vpaint->paint);
BKE_paint_copy(&ts->vpaint->paint, &ts->vpaint->paint);
}
if (ts->wpaint) {
ts->wpaint = MEM_dupallocN(ts->wpaint);
ts->wpaint->paintcursor = NULL;
ts->wpaint->vpaint_prev = NULL;
ts->wpaint->wpaint_prev = NULL;
copy_paint(&ts->wpaint->paint, &ts->wpaint->paint);
BKE_paint_copy(&ts->wpaint->paint, &ts->wpaint->paint);
}
if (ts->sculpt) {
ts->sculpt = MEM_dupallocN(ts->sculpt);
copy_paint(&ts->sculpt->paint, &ts->sculpt->paint);
BKE_paint_copy(&ts->sculpt->paint, &ts->sculpt->paint);
}
copy_paint(&ts->imapaint.paint, &ts->imapaint.paint);
BKE_paint_copy(&ts->imapaint.paint, &ts->imapaint.paint);
ts->imapaint.paintcursor = NULL;
ts->particle.paintcursor = NULL;
}
@@ -304,22 +304,22 @@ void BKE_scene_free(Scene *sce)
if (sce->toolsettings) {
if (sce->toolsettings->vpaint) {
free_paint(&sce->toolsettings->vpaint->paint);
BKE_paint_free(&sce->toolsettings->vpaint->paint);
MEM_freeN(sce->toolsettings->vpaint);
}
if (sce->toolsettings->wpaint) {
free_paint(&sce->toolsettings->wpaint->paint);
BKE_paint_free(&sce->toolsettings->wpaint->paint);
MEM_freeN(sce->toolsettings->wpaint);
}
if (sce->toolsettings->sculpt) {
free_paint(&sce->toolsettings->sculpt->paint);
BKE_paint_free(&sce->toolsettings->sculpt->paint);
MEM_freeN(sce->toolsettings->sculpt);
}
if (sce->toolsettings->uvsculpt) {
free_paint(&sce->toolsettings->uvsculpt->paint);
BKE_paint_free(&sce->toolsettings->uvsculpt->paint);
MEM_freeN(sce->toolsettings->uvsculpt);
}
free_paint(&sce->toolsettings->imapaint.paint);
BKE_paint_free(&sce->toolsettings->imapaint.paint);
MEM_freeN(sce->toolsettings);
sce->toolsettings = NULL;

View File

@@ -39,6 +39,7 @@ struct ToolSettings;
struct uiBlock;
struct wmWindowManager;
struct ARegion;
struct wmEvent;
/* image_edit.c, exported for transform */
struct Image *ED_space_image(struct SpaceImage *sima);
@@ -61,6 +62,7 @@ void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct ToolSett
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);
void ED_image_mouse_pos(struct SpaceImage *sima, struct ARegion *ar, struct wmEvent *event, float co[2]);
int ED_space_image_show_render(struct SpaceImage *sima);
int ED_space_image_show_paint(struct SpaceImage *sima);

View File

@@ -714,6 +714,8 @@ static void histogram_draw_one(float r, float g, float b, float alpha,
}
}
#define HISTOGRAM_TOT_GRID_LINES 4
void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti)
{
Histogram *hist = (Histogram *)but->poin;
@@ -749,9 +751,16 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
glColor4f(1.f, 1.f, 1.f, 0.08f);
/* draw grid lines here */
for (i = 1; i < 4; i++) {
fdrawline(rect.xmin, rect.ymin + (i / 4.f) * h, rect.xmax, rect.ymin + (i / 4.f) * h);
fdrawline(rect.xmin + (i / 4.f) * w, rect.ymin, rect.xmin + (i / 4.f) * w, rect.ymax);
for (i = 1; i < (HISTOGRAM_TOT_GRID_LINES + 1); i++) {
const float fac = (float)i / (float)HISTOGRAM_TOT_GRID_LINES;
/* so we can tell the 1.0 color point */
if (i == HISTOGRAM_TOT_GRID_LINES) {
glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
}
fdrawline(rect.xmin, rect.ymin + fac * h, rect.xmax, rect.ymin + fac * h);
fdrawline(rect.xmin + fac * w, rect.ymin, rect.xmin + fac * w, rect.ymax);
}
if (hist->mode == HISTO_MODE_LUMA) {
@@ -773,6 +782,8 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
draw_scope_end(&rect, scissor);
}
#undef HISTOGRAM_TOT_GRID_LINES
void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti)
{
Scopes *scopes = (Scopes *)but->poin;

View File

@@ -3872,7 +3872,8 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx
const float yfac = minf(powf(hist->ymax, 2.0f), 1.0f) * 0.5f;
hist->ymax += dy * yfac;
CLAMP(hist->ymax, 1.f, 100.f);
/* 0.1 allows us to see HDR colors up to 10 */
CLAMP(hist->ymax, 0.1f, 100.f);
}
data->draglastx = mx;

View File

@@ -110,8 +110,15 @@ void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2])
}
case SPACE_IMAGE:
{
int width, height;
float frame_size[2];
SpaceImage *sima = sa->spacedata.first;
ARegion *ar = CTX_wm_region(C);
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
ED_space_image_get_size(sima, &width, &height);
frame_size[0] = width;
frame_size[1] = height;
ED_image_mouse_pos(sima, ar, event, co);
BKE_mask_coord_from_frame(co, co, frame_size);
break;
}
default:

View File

@@ -135,6 +135,9 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
em = me->edit_btmesh;
EDBM_mesh_normals_update(em);
BMEdit_RecalcTessellation(em);
/* derivedMesh might be needed for solving parenting,
* so re-create it here */
makeDerivedMesh(scene, obedit, em, CD_MASK_BAREMESH, 0);

View File

@@ -150,6 +150,8 @@ void CLIP_OT_hide_tracks(struct wmOperatorType *ot);
void CLIP_OT_hide_tracks_clear(struct wmOperatorType *ot);
void CLIP_OT_lock_tracks(struct wmOperatorType *ot);
void CLIP_OT_set_solver_keyframe(struct wmOperatorType *ot);
void CLIP_OT_set_origin(struct wmOperatorType *ot);
void CLIP_OT_set_plane(struct wmOperatorType *ot);
void CLIP_OT_set_axis(struct wmOperatorType *ot);

View File

@@ -483,6 +483,8 @@ static void clip_operatortypes(void)
WM_operatortype_append(CLIP_OT_hide_tracks_clear);
WM_operatortype_append(CLIP_OT_lock_tracks);
WM_operatortype_append(CLIP_OT_set_solver_keyframe);
/* orientation */
WM_operatortype_append(CLIP_OT_set_origin);
WM_operatortype_append(CLIP_OT_set_plane);
@@ -568,6 +570,12 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "CLIP_OT_solve_camera", SKEY, KM_PRESS, KM_SHIFT, 0);
kmi = WM_keymap_add_item(keymap, "CLIP_OT_set_solver_keyframe", ONEKEY, KM_PRESS, KM_ALT, 0);
RNA_enum_set(kmi->ptr, "keyframe", 0);
kmi = WM_keymap_add_item(keymap, "CLIP_OT_set_solver_keyframe", TWOKEY, KM_PRESS, KM_ALT, 0);
RNA_enum_set(kmi->ptr, "keyframe", 1);
/* ******** Hotkeys avalaible for main region only ******** */
keymap = WM_keymap_find(keyconf, "Clip Editor", SPACE_CLIP, 0);

View File

@@ -2842,6 +2842,49 @@ void CLIP_OT_lock_tracks(wmOperatorType *ot)
RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Lock action to execute");
}
/********************** set keyframe operator *********************/
static int set_solver_keyframe_exec(bContext *C, wmOperator *op)
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
MovieTrackingSettings *settings = &tracking->settings;
int keyframe = RNA_enum_get(op->ptr, "keyframe");
int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr);
if (keyframe == 0)
settings->keyframe1 = framenr;
else
settings->keyframe2 = framenr;
return OPERATOR_FINISHED;
}
void CLIP_OT_set_solver_keyframe(wmOperatorType *ot)
{
static EnumPropertyItem keyframe_items[] = {
{0, "KEYFRAME_A", 0, "Keyframe A", ""},
{1, "KEYFRAME_B", 0, "Keyframe B", ""},
{0, NULL, 0, NULL, NULL}
};
/* identifiers */
ot->name = "Set Selver Keyframe";
ot->description = "Set keyframe used by solver";
ot->idname = "CLIP_OT_set_solver_keyframe";
/* api callbacks */
ot->exec = set_solver_keyframe_exec;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_enum(ot->srna, "keyframe", keyframe_items, 0, "Keyframe", "keyframe to set");
}
/********************** track copy color operator *********************/
static int track_copy_color_exec(bContext *C, wmOperator *UNUSED(op))

View File

@@ -47,6 +47,8 @@
#include "ED_screen.h"
#include "ED_uvedit.h"
#include "UI_view2d.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -250,6 +252,20 @@ void ED_image_get_uv_aspect(Image *ima, float *aspx, float *aspy)
*aspy *= (float)h;
}
void ED_image_mouse_pos(SpaceImage *sima, ARegion *ar, wmEvent *event, float co[2])
{
int sx, sy, width, height;
float zoomx, zoomy;
ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
ED_space_image_get_size(sima, &width, &height);
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
co[0] = ((event->mval[0] - sx) / zoomx) / width;
co[1] = ((event->mval[1] - sy) / zoomy) / height;
}
int ED_space_image_show_render(SpaceImage *sima)
{
return (sima->image && ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE));

View File

@@ -214,6 +214,10 @@ static int space_image_image_sample_poll(bContext *C)
if (ED_space_image_show_uvedit(sima, obedit) && (toolsettings->use_uv_sculpt))
return 0;
}
else if (sima->mode != SI_MODE_VIEW) {
return 0;
}
return space_image_main_area_poll(C);
}
/********************** view pan operator *********************/
@@ -2204,6 +2208,9 @@ static int image_sample_line_exec(bContext *C, wmOperator *op)
BKE_histogram_update_sample_line(hist, ibuf, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) != 0);
/* reset y zoom */
hist->ymax = 1.0f;
ED_space_image_release_buffer(sima, lock);
ED_area_tag_redraw(CTX_wm_area(C));

View File

@@ -1331,10 +1331,11 @@ static void drawArc(float size, float angle_start, float angle_end, int segments
{
float delta = (angle_end - angle_start) / segments;
float angle;
int a;
glBegin(GL_LINE_STRIP);
for (angle = angle_start; angle < angle_end; angle += delta) {
for (angle = angle_start, a = 0; a < segments; angle += delta, a++) {
glVertex2f(cosf(angle) * size, sinf(angle) * size);
}
glVertex2f(cosf(angle_end) * size, sinf(angle_end) * size);

View File

@@ -1348,6 +1348,7 @@ static void do_material_tex(GPUShadeInput *shi)
void GPU_shadeinput_set(GPUMaterial *mat, Material *ma, GPUShadeInput *shi)
{
float hard = ma->har;
float one = 1.0f;
memset(shi, 0, sizeof(*shi));
@@ -1357,7 +1358,12 @@ void GPU_shadeinput_set(GPUMaterial *mat, Material *ma, GPUShadeInput *shi)
GPU_link(mat, "set_rgb", GPU_uniform(&ma->r), &shi->rgb);
GPU_link(mat, "set_rgb", GPU_uniform(&ma->specr), &shi->specrgb);
GPU_link(mat, "shade_norm", GPU_builtin(GPU_VIEW_NORMAL), &shi->vn);
GPU_link(mat, "set_value", GPU_uniform(&ma->alpha), &shi->alpha);
if (ma->mode & MA_TRANSP)
GPU_link(mat, "set_value", GPU_uniform(&ma->alpha), &shi->alpha);
else
GPU_link(mat, "set_value", GPU_uniform(&one), &shi->alpha);
GPU_link(mat, "set_value", GPU_uniform(&ma->ref), &shi->refl);
GPU_link(mat, "set_value", GPU_uniform(&ma->spec), &shi->spec);
GPU_link(mat, "set_value", GPU_uniform(&ma->emit), &shi->emit);

View File

@@ -214,6 +214,10 @@ void IMB_filterN(ImBuf *out, ImBuf *in)
rowlen = in->x;
/* generate 32-bit version for float images if it is not already generated by other space */
if (in->rect == NULL)
IMB_rect_from_float(in);
for (y = 0; y < in->y; y++) {
/* setup rows */
row2 = (char *)(in->rect + y * rowlen);

View File

@@ -836,6 +836,11 @@ void CcdPhysicsController::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *
if (m_cci.m_physicsEnv->removeCcdPhysicsController(this))
{
physicsEnv->addCcdPhysicsController(this);
// Set the object to be active so it can at least by evaluated once.
// This fixes issues with static objects not having their physics meshes
// in the right spot when lib loading.
this->GetCollisionObject()->setActivationState(ACTIVE_TAG);
}
m_cci.m_physicsEnv = physicsEnv;
}