Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-09-13 05:50:21 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-09-13 05:50:21 +0400
commit4cb6d5d214529749bbeeb2a63018b2d54ffa3417 (patch)
tree5cd36b8461ffa8b3ccdf74c9d80d6752db67eefe /source
parent3e4b353cfa7258a6678252db4d382094782f42f7 (diff)
code cleanup: reduce calls to CTX_ functions inline, add some docs to mask rasterizer.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/mask_rasterize.c40
-rw-r--r--source/blender/editors/animation/anim_markers.c5
-rw-r--r--source/blender/editors/mask/mask_add.c5
-rw-r--r--source/blender/editors/mask/mask_ops.c10
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h4
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c16
6 files changed, 64 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index eb96d6726b9..18617f0ef2e 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -26,6 +26,46 @@
/** \file blender/blenkernel/intern/mask_rasterize.c
* \ingroup bke
+ *
+ * This module exposes a rasterizer that works as a black box - implementation details are confined to this file,
+ *
+ * The basic method to access is:
+ * - create & initialize a handle from a #Mask datablock.
+ * - execute pixel lookups.
+ * - free the handle.
+ *
+ * This file is admittedly a bit confusticated, in quite few areas speed was chosen over readability,
+ * though it is commented - so shouldn't be so hard to see whats going on.
+ *
+ *
+ * Implementation:
+ *
+ * To rasterize the mask its converted into geometry that use a ray-cast for each pixel lookup.
+ *
+ * Initially 'kdopbvh' was used but this ended up being too slow.
+ *
+ * To gain some extra speed we take advantage of a few shortcuts that can be made rasterizing masks specifically.
+ * - all triangles are known to be completely white - so no depth check is done on triangle intersection.
+ * - all quads are known to be feather outlines - the 1 and 0 depths are known by the vertex order in the quad,
+ * - there is no color - just a value for each mask pixel.
+ * - the mask spacial structure always maps to space 0-1 on X and Y axis.
+ * - bucketing is used to speed up lookups for geometry.
+ *
+ * Other Details:
+ * - used unsigned values all over for some extra speed on some arch's.
+ * - anti-aliasing is faked, just ensuring at least one pixel feather - avoids oversampling.
+ * - initializing the spacial structure doesn't need to be as optimized as pixel lookups are.
+ * - mask lookups need not be pixel aligned so any sub-pixel values from x/y (0 - 1), can be found.
+ * (perhaps masks can be used as a vector texture in 3D later on)
+ *
+ *
+ * Currently, to build the spacial structure we have to calculate the total number of faces ahead of time.
+ *
+ * This is getting a bit complicated with the addition of unfilled splines and end capping -
+ * If large changes are needed here we would be better off using an iterable
+ * BLI_mempool for triangles and converting to a contiguous array afterwards.
+ *
+ * - Campbell
*/
#include "MEM_guardedalloc.h"
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 95adaa01b94..445b684c261 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -1019,6 +1019,7 @@ static void select_timeline_marker_frame(ListBase *markers, int frame, unsigned
static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera)
{
ListBase *markers = ED_context_get_markers(C);
+ ARegion *ar = CTX_wm_region(C);
View2D *v2d = UI_view2d_fromcontext(C);
float viewx;
int x, y, cfra;
@@ -1026,8 +1027,8 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera)
if (markers == NULL)
return OPERATOR_PASS_THROUGH;
- x = evt->x - CTX_wm_region(C)->winrct.xmin;
- y = evt->y - CTX_wm_region(C)->winrct.ymin;
+ x = evt->x - ar->winrct.xmin;
+ y = evt->y - ar->winrct.ymin;
UI_view2d_region_to_view(v2d, x, y, &viewx, NULL);
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index b37f758596b..7fe1ac09df6 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -556,6 +556,7 @@ static int add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, con
static int add_vertex_exec(bContext *C, wmOperator *op)
{
+ Scene *scene = CTX_data_scene(C);
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *masklay;
@@ -595,7 +596,7 @@ static int add_vertex_exec(bContext *C, wmOperator *op)
BKE_mask_calc_handle_point_auto(spline, point_other, FALSE);
/* TODO: only update this spline */
- BKE_mask_update_display(mask, CTX_data_scene(C)->r.cfra);
+ BKE_mask_update_display(mask, CFRA);
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
return OPERATOR_FINISHED;
@@ -617,7 +618,7 @@ static int add_vertex_exec(bContext *C, wmOperator *op)
}
/* TODO: only update this spline */
- BKE_mask_update_display(mask, CTX_data_scene(C)->r.cfra);
+ BKE_mask_update_display(mask, CFRA);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index 1df1e5a66fe..88fbb91edfb 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -915,6 +915,7 @@ static void delete_feather_points(MaskSplinePoint *point)
static int delete_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Scene *scene = CTX_data_scene(C);
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *masklay;
@@ -1002,7 +1003,7 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
}
/* TODO: only update edited splines */
- BKE_mask_update_display(mask, CTX_data_scene(C)->r.cfra);
+ BKE_mask_update_display(mask, CFRA);
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
@@ -1060,7 +1061,7 @@ static int mask_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
if (change) {
/* TODO: only update this spline */
- BKE_mask_update_display(mask, CTX_data_scene(C)->r.cfra);
+ BKE_mask_update_display(mask, CFRA);
WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask);
@@ -1126,7 +1127,7 @@ static int mask_normals_make_consistent_exec(bContext *C, wmOperator *UNUSED(op)
if (change) {
/* TODO: only update this spline */
- BKE_mask_update_display(mask, CTX_data_scene(C)->r.cfra);
+ BKE_mask_update_display(mask, CFRA);
WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask);
@@ -1324,6 +1325,7 @@ void MASK_OT_hide_view_set(wmOperatorType *ot)
static int mask_feather_weight_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Scene *scene = CTX_data_scene(C);
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *masklay;
int changed = FALSE;
@@ -1351,7 +1353,7 @@ static int mask_feather_weight_clear_exec(bContext *C, wmOperator *UNUSED(op))
if (changed) {
/* TODO: only update edited splines */
- BKE_mask_update_display(mask, CTX_data_scene(C)->r.cfra);
+ BKE_mask_update_display(mask, CFRA);
WM_event_add_notifier(C, NC_MASK | ND_DRAW, mask);
DAG_id_tag_update(&mask->id, 0);
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index d730c7d9019..9da10381af0 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -133,11 +133,11 @@ typedef struct RegionView3D {
short rflag;
- /* last view */
+ /* last view (use when switching out of camera view) */
float lviewquat[4];
short lpersp, lview; /* lpersp can never be set to 'RV3D_CAMOB' */
+
float gridview;
-
float twangle[3];
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index b583c6fd7fe..e3867c0a32a 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -326,7 +326,11 @@ static void build_pict_list(char *first, int totframes, int fstep, int fontid)
int file;
file = open(filepath, O_BINARY | O_RDONLY, 0);
- if (file < 0) return;
+ if (file < 0) {
+ /* print errno? */
+ return;
+ }
+
picture = (PlayAnimPict *)MEM_callocN(sizeof(PlayAnimPict), "picture");
if (picture == NULL) {
printf("Not enough memory for pict struct '%s'\n", filepath);
@@ -700,11 +704,11 @@ void playanim_window_open(const char *title, int posx, int posy, int sizex, int
inital_state = start_maximized ? GHOST_kWindowStateMaximized : GHOST_kWindowStateNormal;
g_WS.ghost_window = GHOST_CreateWindow(g_WS.ghost_system,
- title,
- posx, posy, sizex, sizey,
- inital_state,
- GHOST_kDrawingContextTypeOpenGL,
- FALSE /* no stereo */, FALSE);
+ title,
+ posx, posy, sizex, sizey,
+ inital_state,
+ GHOST_kDrawingContextTypeOpenGL,
+ FALSE /* no stereo */, FALSE);
//if (ghostwin) {
//if (win) {