svn merge ^/trunk/blender -r49263:49280

This commit is contained in:
Campbell Barton
2012-07-27 10:27:28 +00:00
47 changed files with 559 additions and 231 deletions

View File

@@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 263
#define BLENDER_SUBVERSION 16
#define BLENDER_SUBVERSION 17
#define BLENDER_MINVERSION 250
#define BLENDER_MINSUBVERSION 0

View File

@@ -122,6 +122,8 @@ void BKE_mask_point_select_set_handle(struct MaskSplinePoint *point, const short
/* general */
struct Mask *BKE_mask_new(const char *name);
struct Mask *BKE_mask_copy_nolib(struct Mask *mask);
struct Mask *BKE_mask_copy(struct Mask *mask);
void BKE_mask_free(struct Mask *mask);
void BKE_mask_unlink(struct Main *bmain, struct Mask *mask);

View File

@@ -110,6 +110,8 @@ struct MovieTrackingMarker *BKE_tracking_marker_ensure(struct MovieTrackingTrack
void BKE_tracking_marker_pattern_minmax(const struct MovieTrackingMarker *marker, float min[2], float max[2]);
void BKE_tracking_marker_get_subframe_position(struct MovieTrackingTrack *track, float framenr, float pos[2]);
/* **** Object **** */
struct MovieTrackingObject *BKE_tracking_object_add(struct MovieTracking *tracking, const char *name);
void BKE_tracking_object_delete(struct MovieTracking *tracking, struct MovieTrackingObject *object);

View File

@@ -360,6 +360,8 @@ int id_copy(ID *id, ID **newid, int test)
return 0; /* can't be copied from here */
case ID_GD:
return 0; /* not implemented */
case ID_MSK:
if (!test) *newid = (ID *)BKE_mask_copy((Mask *)id);
}
return 0;

View File

@@ -203,28 +203,48 @@ void BKE_mask_layer_unique_name(Mask *mask, MaskLayer *masklay)
BLI_uniquename(&mask->masklayers, masklay, "MaskLayer", '.', offsetof(MaskLayer, name), sizeof(masklay->name));
}
MaskLayer *BKE_mask_layer_copy(MaskLayer *layer)
MaskLayer *BKE_mask_layer_copy(MaskLayer *masklay)
{
MaskLayer *layer_new;
MaskLayer *masklay_new;
MaskSpline *spline;
layer_new = MEM_callocN(sizeof(MaskLayer), "new mask layer");
masklay_new = MEM_callocN(sizeof(MaskLayer), "new mask layer");
BLI_strncpy(layer_new->name, layer->name, sizeof(layer_new->name));
BLI_strncpy(masklay_new->name, masklay->name, sizeof(masklay_new->name));
layer_new->alpha = layer->alpha;
layer_new->blend = layer->blend;
layer_new->blend_flag = layer->blend_flag;
layer_new->flag = layer->flag;
layer_new->restrictflag = layer->restrictflag;
masklay_new->alpha = masklay->alpha;
masklay_new->blend = masklay->blend;
masklay_new->blend_flag = masklay->blend_flag;
masklay_new->flag = masklay->flag;
masklay_new->restrictflag = masklay->restrictflag;
for (spline = layer->splines.first; spline; spline = spline->next) {
for (spline = masklay->splines.first; spline; spline = spline->next) {
MaskSpline *spline_new = BKE_mask_spline_copy(spline);
BLI_addtail(&layer_new->splines, spline_new);
BLI_addtail(&masklay_new->splines, spline_new);
}
return layer_new;
/* correct animation */
if (masklay->splines_shapes.first) {
MaskLayerShape *masklay_shape;
MaskLayerShape *masklay_shape_new;
for (masklay_shape = masklay->splines_shapes.first;
masklay_shape;
masklay_shape = masklay_shape->next)
{
masklay_shape_new = MEM_callocN(sizeof(MaskLayerShape), "new mask layer shape");
masklay_shape_new->data = MEM_dupallocN(masklay_shape->data);
masklay_shape_new->tot_vert = masklay_shape->tot_vert;
masklay_shape_new->flag = masklay_shape->flag;
masklay_shape_new->frame = masklay_shape->frame;
BLI_addtail(&masklay_new->splines_shapes, masklay_shape_new);
}
}
return masklay_new;
}
void BKE_mask_layer_copy_list(ListBase *masklayers_new, ListBase *masklayers)
@@ -1345,6 +1365,49 @@ Mask *BKE_mask_new(const char *name)
return mask;
}
Mask *BKE_mask_copy_nolib(Mask *mask)
{
Mask *mask_new;
mask_new = MEM_dupallocN(mask);
/*take care here! - we may want to copy anim data */
mask_new->adt = NULL;
mask_new->masklayers.first = NULL;
mask_new->masklayers.last = NULL;
BKE_mask_layer_copy_list(&mask_new->masklayers, &mask->masklayers);
/* enable fake user by default */
if (!(mask_new->id.flag & LIB_FAKEUSER)) {
mask_new->id.flag |= LIB_FAKEUSER;
mask_new->id.us++;
}
return mask_new;
}
Mask *BKE_mask_copy(Mask *mask)
{
Mask *mask_new;
mask_new = BKE_libblock_copy(&mask->id);
mask_new->masklayers.first = NULL;
mask_new->masklayers.last = NULL;
BKE_mask_layer_copy_list(&mask_new->masklayers, &mask->masklayers);
/* enable fake user by default */
if (!(mask_new->id.flag & LIB_FAKEUSER)) {
mask_new->id.flag |= LIB_FAKEUSER;
mask_new->id.us++;
}
return mask_new;
}
void BKE_mask_point_free(MaskSplinePoint *point)
{
if (point->uw)
@@ -1621,9 +1684,8 @@ static int BKE_mask_evaluate_parent(MaskParent *parent, float ctime, float r_co[
user.framenr = ctime;
if (track) {
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_framenr);
float marker_pos_ofs[2];
add_v2_v2v2(marker_pos_ofs, marker->pos, track->offset);
BKE_tracking_marker_get_subframe_position(track, clip_framenr, marker_pos_ofs);
BKE_mask_coord_from_movieclip(clip, &user, r_co, marker_pos_ofs);
return TRUE;

View File

@@ -356,7 +356,7 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type)
/* note, using this function is generally a last resort, you really want to be
* using the context when you can - campbell
* -1 for any type */
struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min)
ScrArea *BKE_screen_find_big_area(bScreen *sc, const int spacetype, const short min)
{
ScrArea *sa, *big = NULL;
int size, maxsize = 0;

View File

@@ -916,7 +916,7 @@ void BKE_tracking_track_deselect(MovieTrackingTrack *track, int area)
BKE_tracking_track_flag_clear(track, area, SELECT);
}
/*********************** Marker *************************/
/*********************** Marker *************************/
MovieTrackingMarker *BKE_tracking_marker_insert(MovieTrackingTrack *track, MovieTrackingMarker *marker)
{
@@ -1133,6 +1133,36 @@ void BKE_tracking_marker_pattern_minmax(const MovieTrackingMarker *marker, float
DO_MINMAX2(marker->pattern_corners[3], min, max);
}
void BKE_tracking_marker_get_subframe_position(MovieTrackingTrack *track, float framenr, float pos[2])
{
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, (int) framenr);
MovieTrackingMarker *marker_last = track->markers + (track->markersnr - 1);
if (marker != marker_last) {
MovieTrackingMarker *marker_next = marker + 1;
if (marker_next->framenr == marker->framenr + 1) {
/* currently only do subframing inside tracked ranges, do not extrapolate tracked segments
* could be changed when / if mask parent would be interpolating position in-between
* tracked segments
*/
float fac = (framenr - (int) framenr) / (marker_next->framenr - marker->framenr);
interp_v2_v2v2(pos, marker->pos, marker_next->pos, fac);
}
else {
copy_v2_v2(pos, marker->pos);
}
}
else {
copy_v2_v2(pos, marker->pos);
}
/* currently track offset is always wanted to be applied here, could be made an option later */
add_v2_v2(pos, track->offset);
}
/*********************** Object *************************/
MovieTrackingObject *BKE_tracking_object_add(MovieTracking *tracking, const char *name)

View File

@@ -7077,6 +7077,24 @@ static void do_version_ntree_dilateerode_264(void *UNUSED(data), ID *UNUSED(id),
}
}
static void do_version_ntree_mask_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
{
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == CMP_NODE_MASK) {
if (node->storage == NULL) {
NodeMask *data = MEM_callocN(sizeof(NodeMask), __func__);
/* move settings into own struct */
data->size_x = node->custom3;
data->size_y = node->custom4;
node->custom3 = 0.5f; /* default shutter */
node->storage = data;
}
}
}
}
static void do_version_ntree_keying_despill_balance(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
{
bNode *node;
@@ -7913,6 +7931,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
ntreetype->foreach_nodetree(main, NULL, do_version_ntree_keying_despill_balance);
}
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 17)) {
bNodeTreeType *ntreetype = ntreeGetType(NTREE_COMPOSIT);
if (ntreetype && ntreetype->foreach_nodetree)
ntreetype->foreach_nodetree(main, NULL, do_version_ntree_mask_264);
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */

View File

@@ -36,11 +36,12 @@ MaskNode::MaskNode(bNode *editorNode) : Node(editorNode)
void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
const RenderData *data = context->getRenderData();
const RenderData *rd = context->getRenderData();
OutputSocket *outputMask = this->getOutputSocket(0);
bNode *editorNode = this->getbNode();
NodeMask *data = (NodeMask *)editorNode->storage;
Mask *mask = (Mask *)editorNode->id;
// always connect the output image
@@ -48,16 +49,16 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
operation->setbNode(editorNode);
if (editorNode->custom1 & CMP_NODEFLAG_MASK_FIXED) {
operation->setMaskWidth(editorNode->custom3);
operation->setMaskHeight(editorNode->custom4);
operation->setMaskWidth(data->size_x);
operation->setMaskHeight(data->size_y);
}
else if (editorNode->custom1 & CMP_NODEFLAG_MASK_FIXED_SCENE) {
operation->setMaskWidth(editorNode->custom3 * (data->size / 100.0f));
operation->setMaskHeight(editorNode->custom4 * (data->size / 100.0f));
operation->setMaskWidth(data->size_x * (rd->size / 100.0f));
operation->setMaskHeight(data->size_y * (rd->size / 100.0f));
}
else {
operation->setMaskWidth(data->xsch * data->size / 100.0f);
operation->setMaskHeight(data->ysch * data->size / 100.0f);
operation->setMaskWidth(rd->xsch * rd->size / 100.0f);
operation->setMaskHeight(rd->ysch * rd->size / 100.0f);
}
if (outputMask->isConnected()) {
@@ -69,5 +70,13 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
operation->setSmooth((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_AA) != 0);
operation->setFeather((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0);
if ((editorNode->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) &&
(editorNode->custom2 > 1) &&
(editorNode->custom3 > FLT_EPSILON))
{
operation->setMotionBlurSamples(editorNode->custom2);
operation->setMotionBlurShutter(editorNode->custom3);
}
graph->addOperation(operation);
}

View File

@@ -137,28 +137,74 @@ MaskOperation::MaskOperation() : NodeOperation()
this->m_mask = NULL;
this->m_maskWidth = 0;
this->m_maskHeight = 0;
this->m_framenumber = 0;
this->m_rasterMaskHandle = NULL;
this->m_maskWidthInv = 0.0f;
this->m_maskHeightInv = 0.0f;
this->m_frame_shutter = 0.0f;
this->m_frame_number = 0;
this->m_rasterMaskHandleTot = 1;
memset(this->m_rasterMaskHandles, 0, sizeof(this->m_rasterMaskHandles));
}
void MaskOperation::initExecution()
{
if (this->m_mask) {
if (this->m_rasterMaskHandle == NULL) {
this->m_rasterMaskHandle = BKE_maskrasterize_handle_new();
if (this->m_mask && this->m_rasterMaskHandles[0] == NULL) {
if (this->m_rasterMaskHandleTot == 1) {
this->m_rasterMaskHandles[0] = BKE_maskrasterize_handle_new();
BKE_maskrasterize_handle_init(this->m_rasterMaskHandle, this->m_mask,
this->m_maskWidth, this->m_maskHeight,
TRUE, this->m_do_smooth, this->m_do_feather);
BKE_maskrasterize_handle_init(this->m_rasterMaskHandles[0], this->m_mask,
this->m_maskWidth, this->m_maskHeight,
TRUE, this->m_do_smooth, this->m_do_feather);
}
else {
/* make a throw away copy of the mask */
const float frame = (float)this->m_frame_number - this->m_frame_shutter;
const float frame_step = (this->m_frame_shutter * 2.0f) / this->m_rasterMaskHandleTot;
float frame_iter = frame;
Mask *mask_temp;
mask_temp = BKE_mask_copy_nolib(this->m_mask);
/* trick so we can get unkeyed edits to display */
{
MaskLayer *masklay;
MaskLayerShape *masklay_shape;
for (masklay = (MaskLayer *)mask_temp->masklayers.first;
masklay;
masklay = (MaskLayer *)masklay->next)
{
masklay_shape = BKE_mask_layer_shape_varify_frame(masklay, this->m_frame_number);
BKE_mask_layer_shape_from_mask(masklay, masklay_shape);
}
}
for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) {
this->m_rasterMaskHandles[i] = BKE_maskrasterize_handle_new();
/* re-eval frame info */
BKE_mask_evaluate(mask_temp, frame_iter, TRUE);
BKE_maskrasterize_handle_init(this->m_rasterMaskHandles[i], mask_temp,
this->m_maskWidth, this->m_maskHeight,
TRUE, this->m_do_smooth, this->m_do_feather);
frame_iter += frame_step;
}
BKE_mask_free(mask_temp);
MEM_freeN(mask_temp);
}
}
}
void MaskOperation::deinitExecution()
{
if (this->m_rasterMaskHandle) {
BKE_maskrasterize_handle_free(this->m_rasterMaskHandle);
this->m_rasterMaskHandle = NULL;
for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) {
if (this->m_rasterMaskHandles[i]) {
BKE_maskrasterize_handle_free(this->m_rasterMaskHandles[i]);
this->m_rasterMaskHandles[i] = NULL;
}
}
}
@@ -182,12 +228,28 @@ void MaskOperation::determineResolution(unsigned int resolution[], unsigned int
void MaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler)
{
if (this->m_rasterMaskHandle) {
const float xy[2] = {x * this->m_maskWidthInv, y * this->m_maskHeightInv};
color[0] = BKE_maskrasterize_handle_sample(this->m_rasterMaskHandle, xy);
const float xy[2] = {x * this->m_maskWidthInv, y * this->m_maskHeightInv};
if (this->m_rasterMaskHandleTot == 1) {
if (this->m_rasterMaskHandles[0]) {
color[0] = BKE_maskrasterize_handle_sample(this->m_rasterMaskHandles[0], xy);
}
else {
color[0] = 0.0f;
}
}
else {
/* incase loop below fails */
color[0] = 0.0f;
for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) {
if (this->m_rasterMaskHandles[i]) {
color[0] += BKE_maskrasterize_handle_sample(this->m_rasterMaskHandles[i], xy);
}
}
/* until we get better falloff */
color[0] /= this->m_rasterMaskHandleTot;
}
}

View File

@@ -54,7 +54,9 @@ protected:
float m_maskWidthInv; /* 1 / m_maskWidth */
float m_maskHeightInv; /* 1 / m_maskHeight */
int m_framenumber;
float m_frame_shutter;
int m_frame_number;
bool m_do_smooth;
bool m_do_feather;
@@ -64,7 +66,8 @@ protected:
ListBase m_maskLayers;
#else /* USE_RASKTER */
struct MaskRasterHandle *m_rasterMaskHandle;
struct MaskRasterHandle *m_rasterMaskHandles[32];
unsigned int m_rasterMaskHandleTot;
#endif /* USE_RASKTER */
/**
@@ -90,10 +93,13 @@ public:
this->m_maskHeight = height;
this->m_maskHeightInv = 1.0f / (float)height;
}
void setFramenumber(int framenumber) { this->m_framenumber = framenumber; }
void setFramenumber(int frame_number) { this->m_frame_number = frame_number; }
void setSmooth(bool smooth) { this->m_do_smooth = smooth; }
void setFeather(bool feather) { this->m_do_feather = feather; }
void setMotionBlurSamples(int samples) { this->m_rasterMaskHandleTot = max(1, samples); }
void setMotionBlurShutter(float shutter) { this->m_frame_shutter = shutter; }
#ifdef USE_RASKTER
void *initializeTileData(rcti *rect);
void executePixel(float *color, int x, int y, void *data);

View File

@@ -52,9 +52,9 @@ int ED_space_clip_tracking_poll(struct bContext *C);
int ED_space_clip_maskedit_poll(struct bContext *C);
int ED_space_clip_maskedit_mask_poll(bContext *C);
void ED_space_clip_get_size(const struct bContext *C, int *width, int *height);
void ED_space_clip_get_size_fl(const struct bContext *C, float size[2]);
void ED_space_clip_get_zoom(const struct bContext *C, float *zoomx, float *zoomy);
void ED_space_clip_get_size(struct SpaceClip *sc, int *width, int *height);
void ED_space_clip_get_size_fl(struct SpaceClip *sc, float size[2]);
void ED_space_clip_get_zoom(struct SpaceClip *sc, struct ARegion *ar, float *zoomx, float *zoomy);
void ED_space_clip_get_aspect(struct SpaceClip *sc, float *aspx, float *aspy);
void ED_space_clip_get_aspect_dimension_aware(struct SpaceClip *sc, float *aspx, float *aspy);
@@ -67,9 +67,9 @@ void ED_clip_update_frame(const struct Main *mainp, int cfra);
int ED_clip_view_selection(const struct bContext *C, struct ARegion *ar, int fit);
void ED_clip_point_undistorted_pos(struct SpaceClip *sc, const float co[2], float r_co[2]);
void ED_clip_point_stable_pos(const struct bContext *C, float x, float y, float *xr, float *yr);
void ED_clip_point_stable_pos__reverse(const struct bContext *C, const float co[2], float r_co[2]);
void ED_clip_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]);
void ED_clip_point_stable_pos(struct SpaceClip *sc, struct ARegion *ar, float x, float y, float *xr, float *yr);
void ED_clip_point_stable_pos__reverse(struct SpaceClip *sc, struct ARegion *ar, const float co[2], float r_co[2]);
void ED_clip_mouse_pos(struct SpaceClip *sc, struct ARegion *ar, struct wmEvent *event, float co[2]);
int ED_space_clip_check_show_trackedit(struct SpaceClip *sc);
int ED_space_clip_check_show_maskedit(struct SpaceClip *sc);

View File

@@ -34,11 +34,19 @@
struct wmKeyConfig;
struct MaskLayer;
struct MaskLayerShape;
struct wmEvent;
/* mask_edit.c */
void ED_mask_size(const struct bContext *C, int *width, int *height);
void ED_mask_zoom(const struct bContext *C, float *zoomx, float *zoomy);
void ED_mask_aspect(const struct bContext *C, float *aspx, float *aspy);
void ED_mask_get_size(struct ScrArea *sa, int *width, int *height);
void ED_mask_zoom(struct ScrArea *sa, struct ARegion *ar, float *zoomx, float *zoomy);
void ED_mask_get_aspect(struct ScrArea *sa, struct ARegion *ar, float *aspx, float *aspy);
void ED_mask_pixelspace_factor(struct ScrArea *sa, struct ARegion *ar, float *scalex, float *scaley);
void ED_mask_mouse_pos(struct ScrArea *sa, struct ARegion *ar, struct wmEvent *event, float co[2]);
void ED_mask_point_pos(struct ScrArea *sa, struct ARegion *ar, float x, float y, float *xr, float *yr);
void ED_mask_point_pos__reverse(struct ScrArea *sa, struct ARegion *ar,
float x, float y, float *xr, float *yr);
void ED_operatortypes_mask(void);
void ED_keymap_mask(struct wmKeyConfig *keyconf);

View File

@@ -1635,7 +1635,7 @@ static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v)
}
/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
static uiBlock *curvemap_clipping_func(bContext *C, struct ARegion *ar, void *cumap_v)
static uiBlock *curvemap_clipping_func(bContext *C, ARegion *ar, void *cumap_v)
{
CurveMapping *cumap = cumap_v;
uiBlock *block;
@@ -1696,7 +1696,7 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
ED_region_tag_redraw(CTX_wm_region(C));
}
static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap_v)
static uiBlock *curvemap_tools_func(bContext *C, ARegion *ar, void *cumap_v)
{
uiBlock *block;
short yco = 0, menuwidth = 10 * UI_UNIT_X;
@@ -1718,7 +1718,7 @@ static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap
return block;
}
static uiBlock *curvemap_brush_tools_func(bContext *C, struct ARegion *ar, void *cumap_v)
static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *ar, void *cumap_v)
{
uiBlock *block;
short yco = 0, menuwidth = 10 * UI_UNIT_X;

View File

@@ -38,6 +38,7 @@
#include "BKE_mask.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_mask_types.h"
#include "DNA_object_types.h" /* SELECT */
@@ -57,6 +58,9 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no
float *u_r, float tangent[2],
const short use_deform)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
MaskLayer *masklay, *point_masklay;
MaskSpline *point_spline;
MaskSplinePoint *point = NULL;
@@ -65,9 +69,9 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no
float u;
float scalex, scaley, aspx, aspy;
ED_mask_size(C, &width, &height);
ED_mask_aspect(C, &aspx, &aspy);
ED_mask_pixelspace_factor(C, &scalex, &scaley);
ED_mask_get_size(sa, &width, &height);
ED_mask_get_aspect(sa, ar, &aspx, &aspy);
ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley);
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
@@ -180,6 +184,8 @@ static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline
const float point_co[2], const float tangent[2], const float u,
MaskSplinePoint *reference_point, const short reference_adjacent)
{
ScrArea *sa = CTX_wm_area(C);
MaskSplinePoint *prev_point = NULL;
MaskSplinePoint *next_point = NULL;
BezTriple *bezt;
@@ -190,7 +196,7 @@ static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline
copy_v2_v2(co, point_co);
co[2] = 0.0f;
ED_mask_size(C, &width, &height);
ED_mask_get_size(sa, &width, &height);
/* point coordinate */
bezt = &new_point->bezt;
@@ -610,9 +616,12 @@ static int add_vertex_exec(bContext *C, wmOperator *op)
static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
float co[2];
ED_mask_mouse_pos(C, event, co);
ED_mask_mouse_pos(sa, ar, event, co);
RNA_float_set_array(op->ptr, "location", co);
@@ -681,9 +690,12 @@ static int add_feather_vertex_exec(bContext *C, wmOperator *op)
static int add_feather_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
float co[2];
ED_mask_mouse_pos(C, event, co);
ED_mask_mouse_pos(sa, ar, event, co);
RNA_float_set_array(op->ptr, "location", co);

View File

@@ -456,19 +456,21 @@ static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type
void ED_mask_draw(const bContext *C,
const char draw_flag, const char draw_type)
{
ScrArea *sa = CTX_wm_area(C);
Mask *mask = CTX_data_edit_mask(C);
int width, height;
if (!mask)
return;
ED_mask_size(C, &width, &height);
ED_mask_get_size(sa, &width, &height);
draw_masklays(mask, draw_flag, draw_type, width, height);
}
/* sets up the opengl context.
* width, height are to match the values from ED_mask_size() */
* width, height are to match the values from ED_mask_get_size() */
void ED_mask_draw_region(Mask *mask, ARegion *ar,
const char draw_flag, const char draw_type,
int width, int height,

View File

@@ -90,21 +90,19 @@ int ED_maskedit_mask_poll(bContext *C)
/********************** registration *********************/
void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2])
void ED_mask_mouse_pos(ScrArea *sa, ARegion *ar, wmEvent *event, float co[2])
{
ScrArea *sa = CTX_wm_area(C);
if (sa) {
switch (sa->spacetype) {
case SPACE_CLIP:
{
SpaceClip *sc = sa->spacedata.first;
ED_clip_mouse_pos(C, event, co);
ED_clip_mouse_pos(sc, ar, event, co);
BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
break;
}
case SPACE_SEQ:
{
ARegion *ar = CTX_wm_region(C);
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
break;
}
@@ -112,7 +110,6 @@ void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2])
{
float frame_size[2];
SpaceImage *sima = sa->spacedata.first;
ARegion *ar = CTX_wm_region(C);
ED_space_image_get_size_fl(sima, frame_size);
ED_image_mouse_pos(sima, ar, event, co);
BKE_mask_coord_from_frame(co, co, frame_size);
@@ -133,9 +130,8 @@ void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2])
/* input: x/y - mval space
* output: xr/yr - mask point space */
void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr)
void ED_mask_point_pos(ScrArea *sa, ARegion *ar, float x, float y, float *xr, float *yr)
{
ScrArea *sa = CTX_wm_area(C);
float co[2];
if (sa) {
@@ -143,7 +139,7 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr
case SPACE_CLIP:
{
SpaceClip *sc = sa->spacedata.first;
ED_clip_point_stable_pos(C, x, y, &co[0], &co[1]);
ED_clip_point_stable_pos(sc, ar, x, y, &co[0], &co[1]);
BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
break;
}
@@ -154,7 +150,6 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr
{
float frame_size[2];
SpaceImage *sima = sa->spacedata.first;
ARegion *ar = CTX_wm_region(C);
ED_space_image_get_size_fl(sima, frame_size);
ED_image_point_pos(sima, ar, x, y, &co[0], &co[1]);
BKE_mask_coord_from_frame(co, co, frame_size);
@@ -176,9 +171,8 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr
*yr = co[1];
}
void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, float *yr)
void ED_mask_point_pos__reverse(ScrArea *sa, ARegion *ar, float x, float y, float *xr, float *yr)
{
ScrArea *sa = CTX_wm_area(C);
float co[2];
if (sa) {
@@ -189,7 +183,7 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr,
co[0] = x;
co[1] = y;
BKE_mask_coord_to_movieclip(sc->clip, &sc->user, co, co);
ED_clip_point_stable_pos__reverse(C, co, co);
ED_clip_point_stable_pos__reverse(sc, ar, co, co);
break;
}
case SPACE_SEQ:
@@ -199,7 +193,6 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr,
{
float frame_size[2];
SpaceImage *sima = sa->spacedata.first;
ARegion *ar = CTX_wm_region(C);
ED_space_image_get_size_fl(sima, frame_size);
co[0] = x;
@@ -224,21 +217,21 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr,
*yr = co[1];
}
void ED_mask_size(const bContext *C, int *width, int *height)
void ED_mask_get_size(ScrArea *sa, int *width, int *height)
{
ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacedata.first) {
switch (sa->spacetype) {
case SPACE_CLIP:
{
ED_space_clip_get_size(C, width, height);
SpaceClip *sc = sa->spacedata.first;
ED_space_clip_get_size(sc, width, height);
break;
}
case SPACE_SEQ:
{
Scene *scene = CTX_data_scene(C);
*width = (scene->r.size * scene->r.xsch) / 100;
*height = (scene->r.size * scene->r.ysch) / 100;
// Scene *scene = CTX_data_scene(C);
// *width = (scene->r.size * scene->r.xsch) / 100;
// *height = (scene->r.size * scene->r.ysch) / 100;
break;
}
case SPACE_IMAGE:
@@ -262,14 +255,14 @@ void ED_mask_size(const bContext *C, int *width, int *height)
}
}
void ED_mask_zoom(const bContext *C, float *zoomx, float *zoomy)
void ED_mask_zoom(ScrArea *sa, ARegion *ar, float *zoomx, float *zoomy)
{
ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacedata.first) {
switch (sa->spacetype) {
case SPACE_CLIP:
{
ED_space_clip_get_zoom(C, zoomx, zoomy);
SpaceClip *sc = sa->spacedata.first;
ED_space_clip_get_zoom(sc, ar, zoomx, zoomy);
break;
}
case SPACE_SEQ:
@@ -280,7 +273,6 @@ void ED_mask_zoom(const bContext *C, float *zoomx, float *zoomy)
case SPACE_IMAGE:
{
SpaceImage *sima = sa->spacedata.first;
ARegion *ar = CTX_wm_region(C);
ED_space_image_get_zoom(sima, ar, zoomx, zoomy);
break;
}
@@ -297,9 +289,8 @@ void ED_mask_zoom(const bContext *C, float *zoomx, float *zoomy)
}
}
void ED_mask_aspect(const bContext *C, float *aspx, float *aspy)
void ED_mask_get_aspect(ScrArea *sa, ARegion *UNUSED(ar), float *aspx, float *aspy)
{
ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacedata.first) {
switch (sa->spacetype) {
case SPACE_CLIP:
@@ -332,9 +323,8 @@ void ED_mask_aspect(const bContext *C, float *aspx, float *aspy)
}
}
void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley)
void ED_mask_pixelspace_factor(ScrArea *sa, ARegion *ar, float *scalex, float *scaley)
{
ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacedata.first) {
switch (sa->spacetype) {
case SPACE_CLIP:
@@ -343,8 +333,8 @@ void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley)
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_size(sc, &width, &height);
ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
ED_space_clip_get_aspect(sc, &aspx, &aspy);
*scalex = ((float)width * aspx) * zoomx;
@@ -359,7 +349,6 @@ void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley)
case SPACE_IMAGE:
{
SpaceImage *sima = sa->spacedata.first;
ARegion *ar = CTX_wm_region(C);
int width, height;
float zoomx, zoomy, aspx, aspy;

View File

@@ -99,15 +99,6 @@ void ED_mask_select_flush_all(struct Mask *mask);
int ED_maskedit_poll(struct bContext *C);
int ED_maskedit_mask_poll(struct bContext *C);
void ED_mask_pixelspace_factor(const struct bContext *C, float *scalex, float *scaley);
void ED_mask_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]);
void ED_mask_point_pos(const struct bContext *C, float x, float y, float *xr, float *yr);
void ED_mask_point_pos__reverse(const struct bContext *C, float x, float y, float *xr, float *yr);
void ED_mask_get_zoom(const bContext *C, float *zoomx, float *zoomy);
void ED_mask_get_size(const bContext *C, float *zoomx, float *zoomy);
/* mask_shapekey.c */
void MASK_OT_shape_key_insert(struct wmOperatorType *ot);
void MASK_OT_shape_key_clear(struct wmOperatorType *ot);

View File

@@ -62,6 +62,9 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, Mask *mask, float
MaskLayer **masklay_r, MaskSpline **spline_r, int *is_handle_r,
float *score)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
MaskLayer *masklay;
MaskLayer *point_masklay = NULL;
MaskSpline *point_spline = NULL;
@@ -70,9 +73,9 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, Mask *mask, float
float len = FLT_MAX, scalex, scaley;
int is_handle = FALSE, width, height;
ED_mask_size(C, &width, &height);
ED_mask_aspect(C, &aspx, &aspy);
ED_mask_pixelspace_factor(C, &scalex, &scaley);
ED_mask_get_size(sa, &width, &height);
ED_mask_get_aspect(sa, ar, &aspx, &aspy);
ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley);
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
@@ -158,6 +161,9 @@ int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[
MaskLayer **masklay_r, MaskSpline **spline_r, MaskSplinePoint **point_r,
MaskSplinePointUW **uw_r, float *score)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
MaskLayer *masklay, *point_masklay = NULL;
MaskSpline *point_spline = NULL;
MaskSplinePoint *point = NULL;
@@ -166,9 +172,9 @@ int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[
float scalex, scaley, aspx, aspy;
int width, height;
ED_mask_size(C, &width, &height);
ED_mask_aspect(C, &aspx, &aspy);
ED_mask_pixelspace_factor(C, &scalex, &scaley);
ED_mask_get_size(sa, &width, &height);
ED_mask_get_aspect(sa, ar, &aspx, &aspy);
ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley);
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
@@ -426,6 +432,9 @@ static int slide_point_check_initial_feather(MaskSpline *spline)
static void *slide_point_customdata(bContext *C, wmOperator *op, wmEvent *event)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
SlidePointData *customdata = NULL;
MaskLayer *masklay, *cv_masklay, *feather_masklay;
@@ -437,8 +446,8 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, wmEvent *event)
float co[2], cv_score, feather_score;
const float threshold = 19;
ED_mask_mouse_pos(C, event, co);
ED_mask_size(C, &width, &height);
ED_mask_mouse_pos(sa, ar, event, co);
ED_mask_get_size(sa, &width, &height);
cv_point = ED_mask_point_find_nearest(C, mask, co, threshold, &cv_masklay, &cv_spline, &is_handle, &cv_score);
@@ -502,7 +511,7 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, wmEvent *event)
copy_m3_m3(customdata->vec, point->bezt.vec);
if (BKE_mask_point_has_handle(point))
BKE_mask_point_handle(point, customdata->handle);
ED_mask_mouse_pos(C, event, customdata->co);
ED_mask_mouse_pos(sa, ar, event, customdata->co);
}
return customdata;
@@ -639,7 +648,11 @@ static int slide_point_modal(bContext *C, wmOperator *op, wmEvent *event)
/* no break! update CV position */
case MOUSEMOVE:
ED_mask_mouse_pos(C, event, co);
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
ED_mask_mouse_pos(sa, ar, event, co);
sub_v2_v2v2(dco, co, data->co);
if (data->action == SLIDE_ACTION_HANDLE) {
@@ -768,6 +781,7 @@ static int slide_point_modal(bContext *C, wmOperator *op, wmEvent *event)
DAG_id_tag_update(&data->mask->id, 0);
break;
}
case LEFTMOUSE:
if (event->val == KM_RELEASE) {

View File

@@ -343,9 +343,12 @@ static int select_exec(bContext *C, wmOperator *op)
static int select_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
float co[2];
ED_mask_mouse_pos(C, event, co);
ED_mask_mouse_pos(sa, ar, event, co);
RNA_float_set_array(op->ptr, "location", co);
@@ -380,6 +383,9 @@ void MASK_OT_select(wmOperatorType *ot)
static int border_select_exec(bContext *C, wmOperator *op)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *masklay;
int i;
@@ -394,8 +400,8 @@ static int border_select_exec(bContext *C, wmOperator *op)
rect.xmax = RNA_int_get(op->ptr, "xmax");
rect.ymax = RNA_int_get(op->ptr, "ymax");
ED_mask_point_pos(C, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
ED_mask_point_pos(C, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
ED_mask_point_pos(sa, ar, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
ED_mask_point_pos(sa, ar, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
mode = RNA_int_get(op->ptr, "gesture_mode");
extend = RNA_boolean_get(op->ptr, "extend");
@@ -465,6 +471,9 @@ void MASK_OT_select_border(wmOperatorType *ot)
static int do_lasso_select_mask(bContext *C, int mcords[][2], short moves, short select)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *masklay;
int i;
@@ -496,7 +505,7 @@ static int do_lasso_select_mask(bContext *C, int mcords[][2], short moves, short
float screen_co[2];
/* marker in screen coords */
ED_mask_point_pos__reverse(C,
ED_mask_point_pos__reverse(sa, ar,
point_deform->bezt.vec[1][0], point_deform->bezt.vec[1][1],
&screen_co[0], &screen_co[1]);
@@ -578,6 +587,9 @@ static int mask_spline_point_inside_ellipse(BezTriple *bezt, float offset[2], fl
static int circle_select_exec(bContext *C, wmOperator *op)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *masklay;
int i;
@@ -593,14 +605,14 @@ static int circle_select_exec(bContext *C, wmOperator *op)
mode = RNA_int_get(op->ptr, "gesture_mode");
/* compute ellipse and position in unified coordinates */
ED_mask_size(C, &width, &height);
ED_mask_zoom(C, &zoomx, &zoomy);
ED_mask_get_size(sa, &width, &height);
ED_mask_zoom(sa, ar, &zoomx, &zoomy);
width = height = MAX2(width, height);
ellipse[0] = width * zoomx / radius;
ellipse[1] = height * zoomy / radius;
ED_mask_point_pos(C, x, y, &offset[0], &offset[1]);
ED_mask_point_pos(sa, ar, x, y, &offset[0], &offset[1]);
/* do actual selection */
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
@@ -663,6 +675,9 @@ void MASK_OT_select_circle(wmOperatorType *ot)
static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *masklay;
MaskSpline *spline;
@@ -674,7 +689,7 @@ static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *
const float threshold = 19;
int change = FALSE;
ED_mask_mouse_pos(C, event, co);
ED_mask_mouse_pos(sa, ar, event, co);
point = ED_mask_point_find_nearest(C, mask, co, threshold, &masklay, &spline, &is_handle, NULL);

View File

@@ -476,6 +476,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
int ok = 0;
const short view_context = (oglrender->v3d != NULL);
Object *camera = NULL;
int is_movie;
/* go to next frame */
if (CFRA < oglrender->nfra)
@@ -490,6 +491,21 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
CFRA++;
}
is_movie = BKE_imtype_is_movie(scene->r.im_format.imtype);
if (!is_movie) {
BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE);
if ((scene->r.mode & R_NO_OVERWRITE) && BLI_exists(name)) {
printf("skipping existing frame \"%s\"\n", name);
/* go to next frame */
oglrender->nfra += scene->r.frame_step;
return 1;
}
}
/* update animated image textures for gpu, etc,
* call before BKE_scene_update_for_newframe so modifiers with textures don't lag 1 frame */
ED_image_update_frame(bmain, CFRA);
@@ -538,7 +554,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
ibuf = ibuf_cpy;
}
if (BKE_imtype_is_movie(scene->r.im_format.imtype)) {
if (is_movie) {
ok = oglrender->mh->append_movie(&scene->r, SFRA, CFRA, (int *)ibuf->rect,
oglrender->sizex, oglrender->sizey, oglrender->reports);
if (ok) {
@@ -547,7 +563,6 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
}
}
else {
BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE);
ok = BKE_imbuf_write_stamp(scene, camera, ibuf, name, &scene->r.im_format);
if (ok == 0) {

View File

@@ -1425,18 +1425,17 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
glPopMatrix();
}
void clip_draw_main(const bContext *C, ARegion *ar)
void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar)
{
wmWindow *win = CTX_wm_window(C);
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
Scene *scene = CTX_data_scene(C);
ImBuf *ibuf;
int width, height;
float zoomx, zoomy;
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_zoom(C, &zoomx, &zoomy);
ED_space_clip_get_size(sc, &width, &height);
ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
/* if no clip, nothing to do */
if (!clip) {

View File

@@ -124,10 +124,8 @@ int ED_space_clip_maskedit_mask_poll(bContext *C)
/* ******** common editing functions ******** */
void ED_space_clip_get_size(const bContext *C, int *width, int *height)
void ED_space_clip_get_size(SpaceClip *sc, int *width, int *height)
{
SpaceClip *sc = CTX_wm_space_clip(C);
if (sc->clip) {
BKE_movieclip_get_size(sc->clip, &sc->user, width, height);
}
@@ -136,20 +134,19 @@ void ED_space_clip_get_size(const bContext *C, int *width, int *height)
}
}
void ED_space_clip_get_size_fl(const bContext *C, float size[2])
void ED_space_clip_get_size_fl(SpaceClip *sc, float size[2])
{
int size_i[2];
ED_space_clip_get_size(C, &size_i[0], &size_i[1]);
ED_space_clip_get_size(sc, &size_i[0], &size_i[1]);
size[0] = size_i[0];
size[1] = size_i[1];
}
void ED_space_clip_get_zoom(const bContext *C, float *zoomx, float *zoomy)
void ED_space_clip_get_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy)
{
ARegion *ar = CTX_wm_region(C);
int width, height;
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_size(sc, &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);
@@ -273,9 +270,8 @@ void ED_clip_update_frame(const Main *mainp, int cfra)
}
}
static int selected_boundbox(const bContext *C, float min[2], float max[2])
static int selected_boundbox(SpaceClip *sc, float min[2], float max[2])
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTrackingTrack *track;
int width, height, ok = FALSE;
@@ -284,7 +280,7 @@ static int selected_boundbox(const bContext *C, float min[2], float max[2])
INIT_MINMAX2(min, max);
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_size(sc, &width, &height);
track = tracksbase->first;
while (track) {
@@ -327,17 +323,17 @@ int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit)
int w, h, frame_width, frame_height;
float min[2], max[2];
ED_space_clip_get_size(C, &frame_width, &frame_height);
ED_space_clip_get_size(sc, &frame_width, &frame_height);
if (frame_width == 0 || frame_height == 0)
return FALSE;
if (!selected_boundbox(C, min, max))
if (!selected_boundbox(sc, min, max))
return FALSE;
/* center view */
clip_view_center_to_point(C, (max[0] + min[0]) / (2 * frame_width),
(max[1] + min[1]) / (2 * frame_height));
clip_view_center_to_point(sc, (max[0] + min[0]) / (2 * frame_width),
(max[1] + min[1]) / (2 * frame_height));
w = max[0] - min[0];
h = max[1] - min[1];
@@ -385,15 +381,13 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[
}
}
void ED_clip_point_stable_pos(const bContext *C, float x, float y, float *xr, float *yr)
void ED_clip_point_stable_pos(SpaceClip *sc, ARegion *ar, float x, float y, float *xr, float *yr)
{
ARegion *ar = CTX_wm_region(C);
SpaceClip *sc = CTX_wm_space_clip(C);
int sx, sy, width, height;
float zoomx, zoomy, pos[3], imat[4][4];
ED_space_clip_get_zoom(C, &zoomx, &zoomy);
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
ED_space_clip_get_size(sc, &width, &height);
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
@@ -424,18 +418,16 @@ void ED_clip_point_stable_pos(const bContext *C, float x, float y, float *xr, fl
* \brief the reverse of ED_clip_point_stable_pos(), gets the marker region coords.
* better name here? view_to_track / track_to_view or so?
*/
void ED_clip_point_stable_pos__reverse(const bContext *C, const float co[2], float r_co[2])
void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *ar, const float co[2], float r_co[2])
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
float zoomx, zoomy;
float pos[3];
int width, height;
int sx, sy;
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_zoom(C, &zoomx, &zoomy);
ED_space_clip_get_size(sc, &width, &height);
ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
ED_clip_point_undistorted_pos(sc, co, pos);
pos[2] = 0.0f;
@@ -447,9 +439,9 @@ void ED_clip_point_stable_pos__reverse(const bContext *C, const float co[2], flo
r_co[1] = (pos[1] * height * zoomy) + (float)sy;
}
void ED_clip_mouse_pos(const bContext *C, wmEvent *event, float co[2])
void ED_clip_mouse_pos(SpaceClip *sc, ARegion *ar, wmEvent *event, float co[2])
{
ED_clip_point_stable_pos(C, event->mval[0], event->mval[1], &co[0], &co[1]);
ED_clip_point_stable_pos(sc, ar, event->mval[0], event->mval[1], &co[0], &co[1]);
}
int ED_space_clip_check_show_trackedit(SpaceClip *sc)

View File

@@ -345,6 +345,7 @@ static int border_select_graph_exec(bContext *C, wmOperator *op)
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);

View File

@@ -69,7 +69,7 @@ void clip_draw_dopesheet_channels(const struct bContext *C, struct ARegion *ar);
void CLIP_OT_dopesheet_select_channel(struct wmOperatorType *ot);
/* clip_draw.c */
void clip_draw_main(const struct bContext *C, struct ARegion *ar);
void clip_draw_main(const struct bContext *C, struct SpaceClip *sc, struct ARegion *ar);
void clip_draw_grease_pencil(struct bContext *C, int onlyv2d);
void clip_draw_curfra_label(struct SpaceClip *sc, float x, float y);
@@ -125,7 +125,7 @@ void clip_graph_tracking_iterate(struct SpaceClip *sc, int selected_only, int in
void clip_delete_track(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track);
void clip_delete_marker(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker);
void clip_view_center_to_point(const struct bContext *C, float x, float y);
void clip_view_center_to_point(SpaceClip *sc, float x, float y);
void clip_draw_cfra(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene);
void clip_draw_sfra_efra(struct View2D *v2d, struct Scene *scene);

View File

@@ -74,6 +74,7 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2])
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
float oldzoom = sc->zoom;
int width, height;
@@ -81,7 +82,7 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2])
if (sc->zoom < 0.1f || sc->zoom > 4.0f) {
/* check zoom limits */
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_size(sc, &width, &height);
width *= sc->zoom;
height *= sc->zoom;
@@ -95,7 +96,7 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2])
}
if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) {
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_size(sc, &width, &height);
sc->xof += ((location[0] - 0.5f) * width - sc->xof) * (sc->zoom - oldzoom) / sc->zoom;
sc->yof += ((location[1] - 0.5f) * height - sc->yof) * (sc->zoom - oldzoom) / sc->zoom;
@@ -111,16 +112,20 @@ static void sclip_zoom_set_factor(const bContext *C, float zoomfac, float locati
static void sclip_zoom_set_factor_exec(bContext *C, wmEvent *event, float factor)
{
ARegion *ar = CTX_wm_region(C);
float location[2], *mpos = NULL;
if (event) {
ED_clip_mouse_pos(C, event, location);
SpaceClip *sc = CTX_wm_space_clip(C);
ED_clip_mouse_pos(sc, ar, event, location);
mpos = location;
}
sclip_zoom_set_factor(C, factor, mpos);
ED_region_tag_redraw(CTX_wm_region(C));
ED_region_tag_redraw(ar);
}
/******************** open clip operator ********************/
@@ -466,6 +471,8 @@ typedef struct ViewZoomData {
static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
ViewZoomData *vpd;
op->customdata = vpd = MEM_callocN(sizeof(ViewZoomData), "ClipViewZoomData");
@@ -476,7 +483,7 @@ static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event)
vpd->zoom = sc->zoom;
vpd->event_type = event->type;
ED_clip_mouse_pos(C, event, vpd->location);
ED_clip_mouse_pos(sc, ar, event, vpd->location);
WM_event_add_modal_handler(C, op);
}
@@ -593,9 +600,12 @@ static int view_zoom_in_exec(bContext *C, wmOperator *op)
static int view_zoom_in_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
float location[2];
ED_clip_mouse_pos(C, event, location);
ED_clip_mouse_pos(sc, ar, event, location);
RNA_float_set_array(op->ptr, "location", location);
return view_zoom_in_exec(C, op);
@@ -633,9 +643,12 @@ static int view_zoom_out_exec(bContext *C, wmOperator *op)
static int view_zoom_out_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
float location[2];
ED_clip_mouse_pos(C, event, location);
ED_clip_mouse_pos(sc, ar, event, location);
RNA_float_set_array(op->ptr, "location", location);
return view_zoom_out_exec(C, op);
@@ -706,7 +719,7 @@ static int view_all_exec(bContext *C, wmOperator *op)
sc = CTX_wm_space_clip(C);
ar = CTX_wm_region(C);
ED_space_clip_get_size(C, &w, &h);
ED_space_clip_get_size(sc, &w, &h);
ED_space_clip_get_aspect(sc, &aspx, &aspy);
w = w * aspx;

View File

@@ -223,13 +223,12 @@ void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase,
}
}
void clip_view_center_to_point(const bContext *C, float x, float y)
void clip_view_center_to_point(SpaceClip *sc, float x, float y)
{
SpaceClip *sc = CTX_wm_space_clip(C);
int width, height;
float aspx, aspy;
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_size(sc, &width, &height);
ED_space_clip_get_aspect(sc, &aspx, &aspy);
sc->xof = (x - 0.5f) * width * aspx;

View File

@@ -1030,7 +1030,7 @@ static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar)
float x1, y1, w, h;
int width, height, winx, winy;
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_size(sc, &width, &height);
w = width;
h = height;
@@ -1125,14 +1125,15 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar)
/* data... */
movieclip_main_area_set_view2d(C, ar);
clip_draw_main(C, ar);
clip_draw_main(C, sc, ar);
if (sc->mode == SC_MODE_MASKEDIT) {
Mask *mask = CTX_data_edit_mask(C);
if (mask) {
ScrArea *sa = CTX_wm_area(C);
int width, height;
ED_mask_size(C, &width, &height);
ED_mask_get_size(sa, &width, &height);
ED_mask_draw_region(mask, ar,
sc->mask_info.draw_flag, sc->mask_info.draw_type,
width, height,

View File

@@ -91,7 +91,7 @@ static void add_marker(const bContext *C, float x, float y)
int width, height;
int framenr = ED_space_clip_get_clip_frame_number(sc);
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_size(sc, &width, &height);
track = BKE_tracking_track_add(tracking, tracksbase, x, y, framenr, width, height);
@@ -107,7 +107,7 @@ static int add_marker_exec(bContext *C, wmOperator *op)
float pos[2];
int width, height;
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_size(sc, &width, &height);
if (!width || !height)
return OPERATOR_CANCELLED;
@@ -127,9 +127,12 @@ static int add_marker_exec(bContext *C, wmOperator *op)
static int add_marker_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
float co[2];
ED_clip_mouse_pos(C, event, co);
ED_clip_mouse_pos(sc, ar, event, co);
RNA_float_set_array(op->ptr, "location", co);
@@ -525,6 +528,8 @@ static void show_cursor(bContext *C)
MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int *area_r, int *action_r, int *corner_r)
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTrackingTrack *track;
int width, height;
@@ -533,12 +538,12 @@ MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int
int framenr = ED_space_clip_get_clip_frame_number(sc);
int action = -1, area = 0, corner = -1;
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_size(sc, &width, &height);
if (width == 0 || height == 0)
return NULL;
ED_clip_mouse_pos(C, event, co);
ED_clip_mouse_pos(sc, ar, event, co);
track = tracksbase->first;
while (track) {
@@ -622,6 +627,8 @@ MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int
static void *slide_marker_customdata(bContext *C, wmEvent *event)
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
MovieTrackingTrack *track;
int width, height;
float co[2];
@@ -629,12 +636,12 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event)
int framenr = ED_space_clip_get_clip_frame_number(sc);
int area, action, corner;
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_size(sc, &width, &height);
if (width == 0 || height == 0)
return NULL;
ED_clip_mouse_pos(C, event, co);
ED_clip_mouse_pos(sc, ar, event, co);
track = tracking_marker_check_slide(C, event, &area, &action, &corner);
if (track) {
@@ -700,6 +707,8 @@ static void free_slide_data(SlideMarkerData *data)
static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
SlideMarkerData *data = (SlideMarkerData *)op->customdata;
float dx, dy, mdelta[2];
@@ -751,7 +760,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event)
float start[2], end[2];
float scale;
ED_clip_point_stable_pos(C, data->mval[0], data->mval[1], &start[0], &start[1]);
ED_clip_point_stable_pos(sc, ar, data->mval[0], data->mval[1], &start[0], &start[1]);
sub_v2_v2(start, data->old_pos);
@@ -767,7 +776,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event)
mval[1] = event->mval[1];
}
ED_clip_point_stable_pos(C, mval[0], mval[1], &end[0], &end[1]);
ED_clip_point_stable_pos(sc, ar, mval[0], mval[1], &end[0], &end[1]);
sub_v2_v2(end, data->old_pos);
@@ -825,7 +834,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event)
sub_v2_v2v2(start, data->spos, data->old_pos);
ED_clip_point_stable_pos(C, mval[0], mval[1], &end[0], &end[1]);
ED_clip_point_stable_pos(sc, ar, mval[0], mval[1], &end[0], &end[1]);
sub_v2_v2(end, data->old_pos);
if (len_v2(start) > 0.0f) {

View File

@@ -119,7 +119,7 @@ static int track_mouse_area(const bContext *C, float co[2], MovieTrackingTrack *
float epsx, epsy;
int width, height;
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_size(sc, &width, &height);
BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
@@ -281,6 +281,9 @@ static int select_exec(bContext *C, wmOperator *op)
static int select_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
float co[2];
int extend = RNA_boolean_get(op->ptr, "extend");
@@ -299,7 +302,7 @@ static int select_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
}
ED_clip_mouse_pos(C, event, co);
ED_clip_mouse_pos(sc, ar, event, co);
RNA_float_set_array(op->ptr, "location", co);
return select_exec(C, op);
@@ -333,6 +336,8 @@ void CLIP_OT_select(wmOperatorType *ot)
static int border_select_exec(bContext *C, wmOperator *op)
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
MovieTrackingTrack *track;
@@ -348,8 +353,8 @@ static int border_select_exec(bContext *C, wmOperator *op)
rect.xmax = RNA_int_get(op->ptr, "xmax");
rect.ymax = RNA_int_get(op->ptr, "ymax");
ED_clip_point_stable_pos(C, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
ED_clip_point_stable_pos(C, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
ED_clip_point_stable_pos(sc, ar, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
ED_clip_point_stable_pos(sc, ar, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
mode = RNA_int_get(op->ptr, "gesture_mode");
extend = RNA_boolean_get(op->ptr, "extend");
@@ -414,6 +419,8 @@ void CLIP_OT_select_border(wmOperatorType *ot)
static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, short select)
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
MovieTrackingTrack *track;
@@ -435,7 +442,7 @@ static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, sho
float screen_co[2];
/* marker in screen coords */
ED_clip_point_stable_pos__reverse(C, marker->pos, screen_co);
ED_clip_point_stable_pos__reverse(sc, ar, marker->pos, screen_co);
if (BLI_in_rcti(&rect, screen_co[0], screen_co[1]) &&
BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], V2D_IS_CLIPPED))
@@ -519,6 +526,8 @@ static int marker_inside_ellipse(MovieTrackingMarker *marker, float offset[2], f
static int circle_select_exec(bContext *C, wmOperator *op)
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
MovieTrackingTrack *track;
@@ -535,13 +544,13 @@ static int circle_select_exec(bContext *C, wmOperator *op)
mode = RNA_int_get(op->ptr, "gesture_mode");
/* compute ellipse and position in unified coordinates */
ED_space_clip_get_size(C, &width, &height);
ED_space_clip_get_zoom(C, &zoomx, &zoomy);
ED_space_clip_get_size(sc, &width, &height);
ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
ellipse[0] = width * zoomx / radius;
ellipse[1] = height * zoomy / radius;
ED_clip_point_stable_pos(C, x, y, &offset[0], &offset[1]);
ED_clip_point_stable_pos(sc, ar, x, y, &offset[0], &offset[1]);
/* do selection */
track = tracksbase->first;

View File

@@ -191,7 +191,7 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha
}
static int console_textview_main__internal(struct SpaceConsole *sc, struct ARegion *ar, int draw, int mval[2], void **mouse_pick, int *pos_pick)
static int console_textview_main__internal(struct SpaceConsole *sc, ARegion *ar, int draw, int mval[2], void **mouse_pick, int *pos_pick)
{
ConsoleLine cl_dummy = {NULL};
int ret = 0;
@@ -226,19 +226,19 @@ static int console_textview_main__internal(struct SpaceConsole *sc, struct ARegi
}
void console_textview_main(struct SpaceConsole *sc, struct ARegion *ar)
void console_textview_main(struct SpaceConsole *sc, ARegion *ar)
{
int mval[2] = {INT_MAX, INT_MAX};
console_textview_main__internal(sc, ar, 1, mval, NULL, NULL);
}
int console_textview_height(struct SpaceConsole *sc, struct ARegion *ar)
int console_textview_height(struct SpaceConsole *sc, ARegion *ar)
{
int mval[2] = {INT_MAX, INT_MAX};
return console_textview_main__internal(sc, ar, 0, mval, NULL, NULL);
}
int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, int mval[2])
int console_char_pick(struct SpaceConsole *sc, ARegion *ar, int mval[2])
{
int pos_pick = 0;
void *mouse_pick = NULL;

View File

@@ -70,7 +70,7 @@
#define INACTIVATE 2
/* ---------- FILE SELECTION ------------ */
static FileSelection find_file_mouse_rect(SpaceFile *sfile, struct ARegion *ar, const rcti *rect)
static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const rcti *rect)
{
FileSelection sel;
float fxmin, fymin, fxmax, fymax;
@@ -1277,7 +1277,7 @@ void FILE_OT_hidedot(struct wmOperatorType *ot)
ot->poll = ED_operator_file_active; /* <- important, handler is on window level */
}
struct ARegion *file_buttons_region(struct ScrArea *sa)
ARegion *file_buttons_region(ScrArea *sa)
{
ARegion *ar, *arnew;

View File

@@ -265,7 +265,7 @@ void ED_fileselect_reset_params(SpaceFile *sfile)
sfile->params->title[0] = '\0';
}
int ED_fileselect_layout_numfiles(FileLayout *layout, struct ARegion *ar)
int ED_fileselect_layout_numfiles(FileLayout *layout, ARegion *ar)
{
int numfiles;
@@ -472,7 +472,7 @@ static void column_widths(struct FileList *files, struct FileLayout *layout)
}
}
void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar)
void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar)
{
FileSelectParams *params = ED_fileselect_get_params(sfile);
FileLayout *layout = NULL;
@@ -559,7 +559,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar)
layout->dirty = FALSE;
}
FileLayout *ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar)
FileLayout *ED_fileselect_get_layout(struct SpaceFile *sfile, ARegion *ar)
{
if (!sfile->layout) {
ED_fileselect_init_layout(sfile, ar);

View File

@@ -258,7 +258,7 @@ void image_preview_event(int event)
/* nothing drawn here, we use it to store values */
static void preview_cb(struct ScrArea *sa, struct uiBlock *block)
static void preview_cb(ScrArea *sa, struct uiBlock *block)
{
SpaceImage *sima = sa->spacedata.first;
rctf dispf;

View File

@@ -641,7 +641,7 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
if (mask) {
int width, height;
ED_mask_size(C, &width, &height);
ED_space_image_get_size(sima, &width, &height);
ED_mask_draw_region(mask, ar,
sima->mask_info.draw_flag, sima->mask_info.draw_type,
width, height,

View File

@@ -249,7 +249,7 @@ static int report_textview_line_color(struct TextViewContext *tvc, unsigned char
#undef USE_INFO_NEWLINE
static int info_textview_main__internal(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports, int draw, int mval[2], void **mouse_pick, int *pos_pick)
static int info_textview_main__internal(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports, int draw, int mval[2], void **mouse_pick, int *pos_pick)
{
int ret = 0;
@@ -279,7 +279,7 @@ static int info_textview_main__internal(struct SpaceInfo *sinfo, struct ARegion
return ret;
}
void *info_text_pick(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports, int mouse_y)
void *info_text_pick(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports, int mouse_y)
{
void *mouse_pick = NULL;
int mval[2];
@@ -292,13 +292,13 @@ void *info_text_pick(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *re
}
int info_textview_height(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports)
int info_textview_height(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports)
{
int mval[2] = {INT_MAX, INT_MAX};
return info_textview_main__internal(sinfo, ar, reports, 0, mval, NULL, NULL);
}
void info_textview_main(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports)
void info_textview_main(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports)
{
int mval[2] = {INT_MAX, INT_MAX};
info_textview_main__internal(sinfo, ar, reports, 1, mval, NULL, NULL);

View File

@@ -2495,18 +2495,23 @@ static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C),
static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
bNode *node = ptr->data;
uiTemplateID(layout, C, ptr, "mask", NULL, NULL, NULL);
uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "use_feather", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "size_source", 0, "", ICON_NONE);
{
bNode *node = ptr->data;
if (node->custom1 & (CMP_NODEFLAG_MASK_FIXED | CMP_NODEFLAG_MASK_FIXED_SCENE)) {
uiItemR(layout, ptr, "size_x", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "size_y", 0, NULL, ICON_NONE);
}
if (node->custom1 & (CMP_NODEFLAG_MASK_FIXED | CMP_NODEFLAG_MASK_FIXED_SCENE)) {
uiItemR(layout, ptr, "size_x", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "size_y", 0, NULL, ICON_NONE);
}
uiItemR(layout, ptr, "use_motion_blur", 0, NULL, ICON_NONE);
if (node->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) {
uiItemR(layout, ptr, "motion_blur_samples", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "motion_blur_shutter", 0, NULL, ICON_NONE);
}
}

View File

@@ -266,7 +266,7 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
}
}
static void node_area_refresh(const struct bContext *C, struct ScrArea *sa)
static void node_area_refresh(const struct bContext *C, ScrArea *sa)
{
/* default now: refresh node is starting preview */
SpaceNode *snode = sa->spacedata.first;

View File

@@ -1013,7 +1013,12 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
if (mask) {
int width, height;
ED_mask_size(C, &width, &height);
// ED_mask_get_size(C, &width, &height);
//Scene *scene = CTX_data_scene(C);
width = (scene->r.size * scene->r.xsch) / 100;
height = (scene->r.size * scene->r.ysch) / 100;
ED_mask_draw_region(mask, ar,
0, 0, /* TODO */
width, height,

View File

@@ -984,7 +984,7 @@ static void view3d_props_area_listener(ARegion *ar, wmNotifier *wmn)
}
/*area (not region) level listener*/
static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn)
static void space_view3d_listener(ScrArea *sa, struct wmNotifier *wmn)
{
View3D *v3d = sa->spacedata.first;

View File

@@ -3648,7 +3648,7 @@ int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldl
return 1;
}
int ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth)
int ED_view3d_autodist_depth(ARegion *ar, const int mval[2], int margin, float *depth)
{
*depth = view_autodist_depth_margin(ar, mval, margin);
@@ -3657,7 +3657,7 @@ int ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin,
static int depth_segment_cb(int x, int y, void *userData)
{
struct { struct ARegion *ar; int margin; float depth; } *data = userData;
struct { ARegion *ar; int margin; float depth; } *data = userData;
int mval[2];
float depth;
@@ -3675,10 +3675,10 @@ static int depth_segment_cb(int x, int y, void *userData)
}
}
int ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], const int mval_end[2],
int ED_view3d_autodist_depth_seg(ARegion *ar, const int mval_sta[2], const int mval_end[2],
int margin, float *depth)
{
struct { struct ARegion *ar; int margin; float depth; } data = {NULL};
struct { ARegion *ar; int margin; float depth; } data = {NULL};
int p1[2];
int p2[2];

View File

@@ -219,7 +219,7 @@ typedef struct FlyInfo {
} FlyInfo;
static void drawFlyPixel(const struct bContext *UNUSED(C), struct ARegion *UNUSED(ar), void *arg)
static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg)
{
FlyInfo *fly = arg;

View File

@@ -74,6 +74,7 @@
#include "ED_view3d.h"
#include "ED_mesh.h"
#include "ED_clip.h"
#include "ED_mask.h"
#include "UI_view2d.h"
#include "WM_types.h"
@@ -93,7 +94,7 @@
#include <stdio.h>
static void drawTransformApply(const struct bContext *C, struct ARegion *ar, void *arg);
static void drawTransformApply(const struct bContext *C, ARegion *ar, void *arg);
static int doEdgeSlide(TransInfo *t, float perc);
/* ************************** SPACE DEPENDANT CODE **************************** */
@@ -225,13 +226,21 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2])
project_int_noclip(t->ar, vec, adr);
}
else if (t->spacetype == SPACE_IMAGE) {
float aspx, aspy, v[2];
if (t->options & CTX_MASK) {
float v[2];
ED_mask_point_pos__reverse(t->sa, t->ar, vec[0], vec[1], &v[0], &v[1]);
adr[0] = v[0];
adr[1] = v[1];
}
else {
float aspx, aspy, v[2];
ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
v[0] = vec[0] / aspx;
v[1] = vec[1] / aspy;
ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
v[0] = vec[0] / aspx;
v[1] = vec[1] / aspy;
UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr + 1);
UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr + 1);
}
}
else if (t->spacetype == SPACE_ACTION) {
int out[2] = {0, 0};
@@ -272,10 +281,13 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2])
copy_v2_v2(v, vec);
if (t->options & CTX_MOVIECLIP)
if (t->options & CTX_MOVIECLIP) {
ED_space_clip_get_aspect_dimension_aware(t->sa->spacedata.first, &aspx, &aspy);
else if (t->options & CTX_MASK)
}
else if (t->options & CTX_MASK) {
/* MASKTODO - not working as expected */
ED_space_clip_get_aspect(t->sa->spacedata.first, &aspx, &aspy);
}
v[0] /= aspx;
v[1] /= aspy;
@@ -1485,7 +1497,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
}
}
static void drawTransformView(const struct bContext *C, struct ARegion *UNUSED(ar), void *arg)
static void drawTransformView(const struct bContext *C, ARegion *UNUSED(ar), void *arg)
{
TransInfo *t = arg;
@@ -1496,7 +1508,7 @@ static void drawTransformView(const struct bContext *C, struct ARegion *UNUSED(a
}
#if 0
static void drawTransformPixel(const struct bContext *UNUSED(C), struct ARegion *UNUSED(ar), void *UNUSED(arg))
static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar), void *UNUSED(arg))
{
// TransInfo *t = arg;
//
@@ -1937,7 +1949,7 @@ void transformApply(bContext *C, TransInfo *t)
t->context = NULL;
}
static void drawTransformApply(const bContext *C, struct ARegion *UNUSED(ar), void *arg)
static void drawTransformApply(const bContext *C, ARegion *UNUSED(ar), void *arg)
{
TransInfo *t = arg;

View File

@@ -6230,7 +6230,7 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
return;
}
ED_mask_aspect(C, &asp[0], &asp[1]);
ED_mask_get_aspect(t->sa, t->ar, &asp[0], &asp[1]);
t->total = (propmode) ? count : countsel;
td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Mask Editing)");
@@ -6281,7 +6281,7 @@ void flushTransMasking(TransInfo *t)
int a;
float asp[2], inv[2];
ED_mask_aspect(t->context, &asp[0], &asp[1]);
ED_mask_get_aspect(t->sa, t->ar, &asp[0], &asp[1]);
inv[0] = 1.0f / asp[0];
inv[1] = 1.0f / asp[1];

View File

@@ -375,8 +375,9 @@ enum {
};
enum {
CMP_NODEFLAG_MASK_AA = (1 << 0),
CMP_NODEFLAG_MASK_NO_FEATHER = (1 << 1),
CMP_NODEFLAG_MASK_AA = (1 << 0),
CMP_NODEFLAG_MASK_NO_FEATHER = (1 << 1),
CMP_NODEFLAG_MASK_MOTION_BLUR = (1 << 2),
/* we may want multiple aspect options, exposed as an rna enum */
CMP_NODEFLAG_MASK_FIXED = (1 << 8),
@@ -588,6 +589,10 @@ typedef struct NodeDilateErode {
char pad[7];
} NodeDilateErode;
typedef struct NodeMask {
int size_x, size_y;
} NodeMask;
typedef struct NodeTexBase {
TexMapping tex_mapping;
ColorMapping color_mapping;

View File

@@ -3202,20 +3202,39 @@ static void def_cmp_mask(StructRNA *srna)
RNA_def_property_ui_text(prop, "Feather", "Use feather information from the mask");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
prop = RNA_def_property(srna, "use_motion_blur", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "custom1", CMP_NODEFLAG_MASK_MOTION_BLUR);
RNA_def_property_ui_text(prop, "Motion Blur", "Use feather information from the mask");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
prop = RNA_def_property(srna, "motion_blur_samples", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "custom2");
RNA_def_property_range(prop, 1, 32);
RNA_def_property_ui_text(prop, "Samples", "Number of motion blur samples");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "custom3");
RNA_def_property_range(prop, 0.0, 1.0f);
RNA_def_property_ui_text(prop, "Shutter", "Exposure for motion blur as a factor of FPS");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
prop = RNA_def_property(srna, "size_source", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, aspect_type_items);
RNA_def_property_ui_text(prop, "Size Source", "Where to get the mask size from for aspect/size information");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
RNA_def_struct_sdna_from(srna, "NodeMask", "storage");
prop = RNA_def_property(srna, "size_x", PROP_INT, PROP_NONE);
RNA_def_property_int_funcs(prop, "rna_Node_custom3_get_as_int", "rna_Node_custom3_set_as_int", NULL);
RNA_def_property_range(prop, 1.0f, 10000.0f);
RNA_def_property_ui_text(prop, "X", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
prop = RNA_def_property(srna, "size_y", PROP_INT, PROP_NONE);
RNA_def_property_int_funcs(prop, "rna_Node_custom4_get_as_int", "rna_Node_custom4_set_as_int", NULL);
RNA_def_property_range(prop, 1.0f, 10000.0f);
RNA_def_property_ui_text(prop, "Y", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");

View File

@@ -82,6 +82,16 @@ static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **
}
}
static void node_composit_init_mask(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
{
NodeMask *data = MEM_callocN(sizeof(NodeMask), STRINGIFY(NodeMask));
data->size_x = data->size_y = 256;
node->storage = data;
node->custom2 = 16; /* samples */
node->custom3 = 0.5f; /* shutter */
}
void register_node_type_cmp_mask(bNodeTreeType *ttype)
{
static bNodeType ntype;
@@ -89,7 +99,10 @@ void register_node_type_cmp_mask(bNodeTreeType *ttype)
node_type_base(ttype, &ntype, CMP_NODE_MASK, "Mask", NODE_CLASS_INPUT, NODE_OPTIONS);
node_type_socket_templates(&ntype, NULL, cmp_node_mask_out);
node_type_size(&ntype, 140, 100, 320);
node_type_init(&ntype, node_composit_init_mask);
node_type_exec(&ntype, exec);
node_type_storage(&ntype, "NodeMask", node_free_standard_storage, node_copy_standard_storage);
nodeRegisterType(ttype, &ntype);
}