[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47584] trunk/blender: new sequence strip type for masks.
Campbell Barton
ideasman42 at gmail.com
Thu Jun 7 20:24:37 CEST 2012
Revision: 47584
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47584
Author: campbellbarton
Date: 2012-06-07 18:24:36 +0000 (Thu, 07 Jun 2012)
Log Message:
-----------
new sequence strip type for masks.
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_ui/space_clip.py
trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py
trunk/blender/source/blender/blenkernel/BKE_mask.h
trunk/blender/source/blender/blenkernel/intern/mask.c
trunk/blender/source/blender/blenkernel/intern/sequencer.c
trunk/blender/source/blender/blenloader/intern/readfile.c
trunk/blender/source/blender/compositor/operations/COM_MaskOperation.cpp
trunk/blender/source/blender/editors/include/UI_resources.h
trunk/blender/source/blender/editors/interface/resources.c
trunk/blender/source/blender/editors/space_sequencer/sequencer_add.c
trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c
trunk/blender/source/blender/editors/space_sequencer/sequencer_intern.h
trunk/blender/source/blender/editors/space_sequencer/sequencer_ops.c
trunk/blender/source/blender/editors/space_sequencer/sequencer_select.c
trunk/blender/source/blender/editors/space_sequencer/space_sequencer.c
trunk/blender/source/blender/makesdna/DNA_mask_types.h
trunk/blender/source/blender/makesdna/DNA_sequence_types.h
trunk/blender/source/blender/makesdna/DNA_userdef_types.h
trunk/blender/source/blender/makesrna/RNA_access.h
trunk/blender/source/blender/makesrna/RNA_enum_types.h
trunk/blender/source/blender/makesrna/intern/rna_mask.c
trunk/blender/source/blender/makesrna/intern/rna_sequencer.c
trunk/blender/source/blender/makesrna/intern/rna_sequencer_api.c
trunk/blender/source/blender/nodes/composite/nodes/node_composite_mask.c
trunk/blender/source/blender/windowmanager/intern/wm_operators.c
Modified: trunk/blender/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_clip.py 2012-06-07 18:21:07 UTC (rev 47583)
+++ trunk/blender/release/scripts/startup/bl_ui/space_clip.py 2012-06-07 18:24:36 UTC (rev 47584)
@@ -790,6 +790,24 @@
col.prop(sc, "show_mask_smooth")
+# TODO, move into its own file
+class CLIP_PT_mask(CLIP_PT_mask_view_panel, Panel):
+ bl_space_type = 'CLIP_EDITOR'
+ bl_region_type = 'UI'
+ bl_label = "Mask Settings"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ def draw(self, context):
+ layout = self.layout
+
+ sc = context.space_data
+ mask = sc.mask
+
+ col = layout.column(align=True)
+ col.prop(mask, "frame_start")
+ col.prop(mask, "frame_end")
+
+
class CLIP_PT_marker_display(CLIP_PT_clip_view_panel, Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'UI'
Modified: trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py 2012-06-07 18:21:07 UTC (rev 47583)
+++ trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py 2012-06-07 18:24:36 UTC (rev 47584)
@@ -198,6 +198,12 @@
else:
layout.operator_menu_enum("sequencer.movieclip_strip_add", "clip", text="Clip...")
+ if len(bpy.data.masks) > 10:
+ layout.operator_context = 'INVOKE_DEFAULT'
+ layout.operator("sequencer.mask_strip_add", text="Masks...")
+ else:
+ layout.operator_menu_enum("sequencer.mask_strip_add", "mask", text="Mask...")
+
layout.operator("sequencer.movie_strip_add", text="Movie")
layout.operator("sequencer.image_strip_add", text="Image")
layout.operator("sequencer.sound_strip_add", text="Sound")
@@ -670,6 +676,35 @@
layout.label(text="Original frame range" + ": %d-%d (%d)" % (sta, end, end - sta + 1))
+class SEQUENCER_PT_mask(SequencerButtonsPanel, Panel):
+ bl_label = "Mask"
+
+ @classmethod
+ def poll(cls, context):
+ if not cls.has_sequencer(context):
+ return False
+
+ strip = act_strip(context)
+ if not strip:
+ return False
+
+ return (strip.type == 'MASK')
+
+ def draw(self, context):
+ layout = self.layout
+
+ strip = act_strip(context)
+
+ layout.template_ID(strip, "mask")
+
+ mask = strip.mask
+
+ if mask:
+ sta = mask.frame_start
+ end = mask.frame_end
+ layout.label(text="Original frame range" + ": %d-%d (%d)" % (sta, end, end - sta + 1))
+
+
class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel):
bl_label = "Filter"
@@ -682,10 +717,10 @@
if not strip:
return False
- return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'MOVIECLIP', 'META',
- 'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
- 'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
- 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
+ return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'MOVIECLIP', 'MASK',
+ 'META', 'ADD', 'SUBTRACT', 'ALPHA_OVER',
+ 'ALPHA_UNDER', 'CROSS', 'GAMMA_CROSS', 'MULTIPLY',
+ 'OVER_DROP', 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
'MULTICAM', 'SPEED', 'ADJUSTMENT'}
def draw(self, context):
Modified: trunk/blender/source/blender/blenkernel/BKE_mask.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_mask.h 2012-06-07 18:21:07 UTC (rev 47583)
+++ trunk/blender/source/blender/blenkernel/BKE_mask.h 2012-06-07 18:24:36 UTC (rev 47584)
@@ -120,6 +120,7 @@
void BKE_mask_update_display(struct Mask *mask, float ctime);
void BKE_mask_evaluate_all_masks(struct Main *bmain, float ctime, const int do_newframe);
+void BKE_mask_evaluate(struct Mask *mask, float ctime, const int do_newframe);
void BKE_mask_update_scene(struct Main *bmain, struct Scene *scene, const int do_newframe);
void BKE_mask_parent_init(struct MaskParent *parent);
void BKE_mask_calc_handle_adjacent_interp(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u);
@@ -165,7 +166,9 @@
void BKE_mask_layer_shape_changed_remove(struct MaskLayer *masklay, int index, int count);
/* rasterization */
-void BKE_mask_rasterize(struct Mask *mask, int width, int height, float *buffer);
+int BKE_mask_get_duration(struct Mask *mask);
+void BKE_mask_rasterize(struct Mask *mask, int width, int height, float *buffer,
+ const short do_aspect_correct, const short do_linear);
#define MASKPOINT_ISSEL_ANY(p) ( ((p)->bezt.f1 | (p)->bezt.f2 | (p)->bezt.f2) & SELECT)
#define MASKPOINT_ISSEL_KNOT(p) ( (p)->bezt.f2 & SELECT)
Modified: trunk/blender/source/blender/blenkernel/intern/mask.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mask.c 2012-06-07 18:21:07 UTC (rev 47583)
+++ trunk/blender/source/blender/blenkernel/intern/mask.c 2012-06-07 18:24:36 UTC (rev 47584)
@@ -951,6 +951,10 @@
mask = mask_alloc(mask_name);
+ /* arbitrary defaults */
+ mask->sfra = 1;
+ mask->efra = 100;
+
return mask;
}
@@ -2040,7 +2044,7 @@
}
}
-static void linear_clamp_vn_vn(float *array, const int size)
+static void clamp_vn_vn_linear(float *array, const int size)
{
float *arr = array + (size - 1);
@@ -2053,8 +2057,26 @@
}
}
+static void clamp_vn_vn(float *array, const int size)
+{
+ float *arr = array + (size - 1);
+
+ int i = size;
+ while (i--) {
+ if (*arr < 0.0f) *arr = 0.0f;
+ else if (*arr > 1.0f) *arr = 1.0f;
+ arr--;
+ }
+}
+
+int BKE_mask_get_duration(Mask *mask)
+{
+ return MAX2(1, mask->efra - mask->sfra);
+}
+
/* rasterization */
-void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer)
+void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer,
+ const short do_aspect_correct, const short do_linear)
{
MaskLayer *masklay;
@@ -2087,31 +2109,32 @@
BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height,
&tot_diff_feather_points);
- /* TODO, make this optional! */
- if (width != height) {
- float *fp;
- float *ffp;
- int i;
- float asp;
+ if (do_aspect_correct) {
+ if (width != height) {
+ float *fp;
+ float *ffp;
+ int i;
+ float asp;
- if (width < height) {
- fp = &diff_points[0][0];
- ffp = tot_diff_feather_points ? &diff_feather_points[0][0] : NULL;
- asp = (float)width / (float)height;
- }
- else {
- fp = &diff_points[0][1];
- ffp = tot_diff_feather_points ? &diff_feather_points[0][1] : NULL;
- asp = (float)height / (float)width;
- }
+ if (width < height) {
+ fp = &diff_points[0][0];
+ ffp = tot_diff_feather_points ? &diff_feather_points[0][0] : NULL;
+ asp = (float)width / (float)height;
+ }
+ else {
+ fp = &diff_points[0][1];
+ ffp = tot_diff_feather_points ? &diff_feather_points[0][1] : NULL;
+ asp = (float)height / (float)width;
+ }
- for (i = 0; i < tot_diff_point; i++, fp += 2) {
- (*fp) = (((*fp) - 0.5f) / asp) + 0.5f;
- }
+ for (i = 0; i < tot_diff_point; i++, fp += 2) {
+ (*fp) = (((*fp) - 0.5f) / asp) + 0.5f;
+ }
- if (tot_diff_feather_points) {
- for (i = 0; i < tot_diff_feather_points; i++, ffp += 2) {
- (*ffp) = (((*ffp) - 0.5f) / asp) + 0.5f;
+ if (tot_diff_feather_points) {
+ for (i = 0; i < tot_diff_feather_points; i++, ffp += 2) {
+ (*ffp) = (((*ffp) - 0.5f) / asp) + 0.5f;
+ }
}
}
}
@@ -2173,7 +2196,12 @@
}
/* clamp at the end */
- linear_clamp_vn_vn(buffer, buffer_size);
+ if (do_linear) {
+ clamp_vn_vn_linear(buffer, buffer_size);
+ }
+ else {
+ clamp_vn_vn(buffer, buffer_size);
+ }
}
MEM_freeN(buffer_tmp);
Modified: trunk/blender/source/blender/blenkernel/intern/sequencer.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/sequencer.c 2012-06-07 18:21:07 UTC (rev 47583)
+++ trunk/blender/source/blender/blenkernel/intern/sequencer.c 2012-06-07 18:24:36 UTC (rev 47584)
@@ -29,7 +29,6 @@
* \ingroup bke
*/
-
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -40,6 +39,7 @@
#include "DNA_sequence_types.h"
#include "DNA_movieclip_types.h"
+#include "DNA_mask_types.h"
#include "DNA_scene_types.h"
#include "DNA_anim_types.h"
#include "DNA_object_types.h"
@@ -61,6 +61,7 @@
#include "BKE_movieclip.h"
#include "BKE_fcurve.h"
#include "BKE_scene.h"
+#include "BKE_mask.h"
#include "BKE_utildefines.h"
#include "RNA_access.h"
@@ -669,9 +670,9 @@
int prev_startdisp = 0, prev_enddisp = 0;
/* note: don't rename the strip, will break animation curves */
- if (ELEM6(seq->type,
+ if (ELEM7(seq->type,
SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE, SEQ_TYPE_SOUND_RAM,
- SEQ_TYPE_SCENE, SEQ_TYPE_META, SEQ_TYPE_MOVIECLIP) == 0)
+ SEQ_TYPE_SCENE, SEQ_TYPE_META, SEQ_TYPE_MOVIECLIP, SEQ_TYPE_MASK) == 0)
{
return;
}
@@ -731,6 +732,15 @@
seq->len = 0;
}
break;
+ case SEQ_TYPE_MASK:
+ seq->len = BKE_mask_get_duration(seq->mask);
+
+ seq->len -= seq->anim_startofs;
+ seq->len -= seq->anim_endofs;
+ if (seq->len < 0) {
+ seq->len = 0;
+ }
+ break;
case SEQ_TYPE_SOUND_RAM:
#ifdef WITH_AUDASPACE
if (!seq->sound)
@@ -903,7 +913,8 @@
case SEQ_TYPE_SCENE: return "Scene";
case SEQ_TYPE_MOVIE: return "Movie";
case SEQ_TYPE_MOVIECLIP: return "Clip";
- case SEQ_TYPE_SOUND_RAM: return "Audio";
+ case SEQ_TYPE_MASK: return "Mask";
+ case SEQ_TYPE_SOUND_RAM: return "Audio";
case SEQ_TYPE_CROSS: return "Cross";
case SEQ_TYPE_GAMCROSS: return "Gamma Cross";
case SEQ_TYPE_ADD: return "Add";
@@ -2044,6 +2055,75 @@
return ibuf;
}
+
+static ImBuf *seq_render_mask_strip(
+ SeqRenderData context, Sequence *seq, float nr)
+{
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list